Upstream now distinguishes whether a saved build already existed, so I can use it for autodelete. Also make constants for the root paths. And then forgot to commit it.
This commit is contained in:
parent
27b824f152
commit
0126ec1204
@ -1,7 +1,7 @@
|
|||||||
# Maintainer: Zergling_man, from fedora.email
|
# Maintainer: Zergling_man, from fedora.email
|
||||||
|
|
||||||
pkgname=swat-codegen
|
pkgname=swat-codegen
|
||||||
pkgver=1.0.10
|
pkgver=1.1.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="A simple CLI interface to RCPDv3, the rank code management service for the game SWAT: Aftermath"
|
pkgdesc="A simple CLI interface to RCPDv3, the rank code management service for the game SWAT: Aftermath"
|
||||||
arch=('any')
|
arch=('any')
|
||||||
|
@ -2,18 +2,21 @@
|
|||||||
|
|
||||||
loc=$(dirname $(readlink -f "$0"))
|
loc=$(dirname $(readlink -f "$0"))
|
||||||
|
|
||||||
|
account_server_root_url=https://swataftermath.com:8443
|
||||||
|
code_server_root_url=https://swataftermath.com:9443/account
|
||||||
|
|
||||||
# TOKEN MANAGEMENT
|
# TOKEN MANAGEMENT
|
||||||
function migrate
|
function migrate
|
||||||
{
|
{
|
||||||
curl "https://swataftermath.com:8443/account/$1/activate-migrated" --json '{"currentPassword":"'"$3"'","emailAddress":"'"$2"'","newPassword":"'"$3"'"}'
|
curl "$account_server_root_url/account/$1/activate-migrated" --json '{"currentPassword":"'"$3"'","emailAddress":"'"$2"'","newPassword":"'"$3"'"}'
|
||||||
curl "https://swataftermath.com:8443/account/$1/verify-email" --json '{"verificationCode":"'"$(cat)"'"}'
|
curl "$account_server_root_url/account/$1/verify-email" --json '{"verificationCode":"'"$(cat)"'"}'
|
||||||
login "$1" "$3"
|
login "$1" "$3"
|
||||||
}
|
}
|
||||||
|
|
||||||
function login
|
function login
|
||||||
{
|
{
|
||||||
[ -n "$2" ] || { echo "Please provide a username and password, in that order, when calling this"; exit; }
|
[ -n "$2" ] || { echo "Please provide a username and password, in that order, when calling this"; exit; }
|
||||||
curl https://swataftermath.com:8443/login --json '{"username":"'"$1"'","password":"'"$2"'"}' > ~/.config/rcpd.cfg
|
curl $account_server_root_url/login --json '{"username":"'"$1"'","password":"'"$2"'"}' > ~/.config/rcpd.cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_token
|
function get_token
|
||||||
@ -25,19 +28,19 @@ function get_token
|
|||||||
function get
|
function get
|
||||||
{
|
{
|
||||||
TOKE=`get_token`
|
TOKE=`get_token`
|
||||||
curl -H "Authorization:Bearer $TOKE" https://swataftermath.com:9443/account/$1
|
curl -H "Authorization:Bearer $TOKE" $code_server_root_url/$1
|
||||||
}
|
}
|
||||||
|
|
||||||
function post
|
function post
|
||||||
{
|
{
|
||||||
TOKE=`get_token`
|
TOKE=`get_token`
|
||||||
curl -H "Authorization:Bearer $TOKE" https://swataftermath.com:9443/account/$1 --json "$2"
|
curl -$3H "Authorization:Bearer $TOKE" $code_server_root_url/$1 --json "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_code
|
function delete_code
|
||||||
{
|
{
|
||||||
TOKE=`get_token`
|
TOKE=`get_token`
|
||||||
curl -H "Authorization:Bearer $TOKE" https://swataftermath.com:9443/account/rank-code/$1 -X DELETE
|
curl -H "Authorization:Bearer $TOKE" $code_server_root_url/rank-code/$1 -X DELETE
|
||||||
}
|
}
|
||||||
|
|
||||||
# UTILS
|
# UTILS
|
||||||
@ -65,9 +68,11 @@ function builds
|
|||||||
function save
|
function save
|
||||||
{
|
{
|
||||||
if [ -n "$2" ]; then name=',"buildName":"'"${*:2}"'"'; fi
|
if [ -n "$2" ]; then name=',"buildName":"'"${*:2}"'"'; fi
|
||||||
res=`post rank-code '{"rankCode":"'$1'"'"$name"'}'`
|
res=`post rank-code '{"rankCode":"'$1'"'"$name"'}' i`
|
||||||
|
created=`head -n 1 <<< "$res" | cut -d' ' -f2`
|
||||||
|
res=`tr -d '\r' <<< "$res" | awk -F '\r\n' 'BEGIN { a=1 } a==0 { print } $0=="" { a=0 }'`
|
||||||
jq <<< "$res"
|
jq <<< "$res"
|
||||||
if [ -z "`jq -r '.[0].buildName // ""' <<< "$res"`" ]; then delete_code $1; fi # Don't bother storing any build that doesn't have a name. Assume it's just logging the results of a game.
|
if [ $created = 201 -a -z "$2" ]; then delete_code $1; fi # Don't bother storing any build that doesn't have a name if it didn't already exist. Assume it's just logging the results of a game.
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate
|
function generate
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"info" : {
|
"info" : {
|
||||||
"title" : "SWAT Account Service API",
|
"title" : "SWAT Account Service API",
|
||||||
"description" : "API for the SWAT Account Service that allows creation, management, and authentication of SWAT accounts. A SWAT account can be used to access SWAT services, such as RCPD 3.0 (rcpd-service) and map marker. Accounts in RCPD 2.0 have been migrated to SWAT accounts with the same username and password.",
|
"description" : "API for the SWAT Account Service that allows creation, management, and authentication of SWAT accounts. A SWAT account can be used to access SWAT services, such as RCPD 3.0 (rcpd-service) and map marker. Accounts in RCPD 2.0 have been migrated to SWAT accounts with the same username and password.",
|
||||||
"version" : "0.14.0"
|
"version" : "0.14.1"
|
||||||
},
|
},
|
||||||
"externalDocs" : {
|
"externalDocs" : {
|
||||||
"url" : "/"
|
"url" : "/"
|
||||||
@ -417,7 +417,7 @@
|
|||||||
},
|
},
|
||||||
"responses" : {
|
"responses" : {
|
||||||
"200" : {
|
"200" : {
|
||||||
"description" : "Successfully logged in.",
|
"description" : "Generated JWT returned. Tokens expire 2 hours after creation.",
|
||||||
"headers" : { },
|
"headers" : { },
|
||||||
"content" : {
|
"content" : {
|
||||||
"application/json" : {
|
"application/json" : {
|
||||||
|
@ -3,7 +3,7 @@ info:
|
|||||||
title: SWAT Aftermath - RCPD Service
|
title: SWAT Aftermath - RCPD Service
|
||||||
description: "Rank code manager service for storing rank codes, generating rank\
|
description: "Rank code manager service for storing rank codes, generating rank\
|
||||||
\ codes, earning titles, etc. The back end for RPCD 3.0"
|
\ codes, earning titles, etc. The back end for RPCD 3.0"
|
||||||
version: 0.24.3
|
version: 0.25.0
|
||||||
servers:
|
servers:
|
||||||
- url: https://swataftermath.com:9443/
|
- url: https://swataftermath.com:9443/
|
||||||
tags:
|
tags:
|
||||||
@ -870,11 +870,27 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/ErrorResponse"
|
$ref: "#/components/schemas/ErrorResponse"
|
||||||
"200":
|
"200":
|
||||||
description: "The saved build, plus any other saved builds that have had\
|
description: "The updated saved build, plus any other saved builds that\
|
||||||
\ medals or titles updated as a result of the new build being saved. If\
|
\ have had medals or titles updated as a result of the new build being\
|
||||||
\ the build that was saved had earned any medals or titles, then all saved\
|
\ saved. If the build that was saved had earned any medals or titles,\
|
||||||
\ builds with the same class/trait/specialization combination will be\
|
\ then all saved builds with the same class/trait/specialization combination\
|
||||||
\ updated and returned. This avoids the scenario of earning a medal/title\
|
\ will be updated and returned. This avoids the scenario of earning a\
|
||||||
|
\ medal/title on one build, and then earning the same medal/title on another\
|
||||||
|
\ build with the same class/trait/specialization combination which shares\
|
||||||
|
\ the new medal/title."
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
minItems: 1
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/HeroBuildResponse"
|
||||||
|
"201":
|
||||||
|
description: "The newly saved build, plus any other saved builds that have\
|
||||||
|
\ had medals or titles updated as a result of the new build being saved.\
|
||||||
|
\ If the build that was saved had earned any medals or titles, then all\
|
||||||
|
\ saved builds with the same class/trait/specialization combination will\
|
||||||
|
\ be updated and returned. This avoids the scenario of earning a medal/title\
|
||||||
\ on one build, and then earning the same medal/title on another build\
|
\ on one build, and then earning the same medal/title on another build\
|
||||||
\ with the same class/trait/specialization combination which shares the\
|
\ with the same class/trait/specialization combination which shares the\
|
||||||
\ new medal/title."
|
\ new medal/title."
|
||||||
@ -956,11 +972,27 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/ErrorResponse"
|
$ref: "#/components/schemas/ErrorResponse"
|
||||||
"200":
|
"200":
|
||||||
description: "The saved build, plus any other saved builds that have had\
|
description: "The updated saved build, plus any other saved builds that\
|
||||||
\ medals or titles updated as a result of the new build being saved. If\
|
\ have had medals or titles updated as a result of the new build being\
|
||||||
\ the build that was saved had earned any medals or titles, then all saved\
|
\ saved. If the build that was saved had earned any medals or titles,\
|
||||||
\ builds with the same class/trait/specialization combination will be\
|
\ then all saved builds with the same class/trait/specialization combination\
|
||||||
\ updated and returned. This avoids the scenario of earning a medal/title\
|
\ will be updated and returned. This avoids the scenario of earning a\
|
||||||
|
\ medal/title on one build, and then earning the same medal/title on another\
|
||||||
|
\ build with the same class/trait/specialization combination which shares\
|
||||||
|
\ the new medal/title."
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
minItems: 1
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/HeroBuildResponse"
|
||||||
|
"201":
|
||||||
|
description: "The newly saved build, plus any other saved builds that have\
|
||||||
|
\ had medals or titles updated as a result of the new build being saved.\
|
||||||
|
\ If the build that was saved had earned any medals or titles, then all\
|
||||||
|
\ saved builds with the same class/trait/specialization combination will\
|
||||||
|
\ be updated and returned. This avoids the scenario of earning a medal/title\
|
||||||
\ on one build, and then earning the same medal/title on another build\
|
\ on one build, and then earning the same medal/title on another build\
|
||||||
\ with the same class/trait/specialization combination which shares the\
|
\ with the same class/trait/specialization combination which shares the\
|
||||||
\ new medal/title."
|
\ new medal/title."
|
||||||
@ -1751,13 +1783,6 @@ components:
|
|||||||
\ and build name."
|
\ and build name."
|
||||||
BuildRequest:
|
BuildRequest:
|
||||||
title: Build Request
|
title: Build Request
|
||||||
required:
|
|
||||||
- armor
|
|
||||||
- gun
|
|
||||||
- specialization
|
|
||||||
- swatClass
|
|
||||||
- talent
|
|
||||||
- trait
|
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
swatClass:
|
swatClass:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user