diff --git a/swat-codegen/PKGBUILD b/swat-codegen/PKGBUILD index 37e29d8..abeb5b3 100644 --- a/swat-codegen/PKGBUILD +++ b/swat-codegen/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Zergling_man, from fedora.email pkgname=swat-codegen -pkgver=1.0.10 +pkgver=1.1.0 pkgrel=1 pkgdesc="A simple CLI interface to RCPDv3, the rank code management service for the game SWAT: Aftermath" arch=('any') diff --git a/swat-codegen/codegen.sh b/swat-codegen/codegen.sh index 87fc408..8968503 100755 --- a/swat-codegen/codegen.sh +++ b/swat-codegen/codegen.sh @@ -2,18 +2,21 @@ loc=$(dirname $(readlink -f "$0")) +account_server_root_url=https://swataftermath.com:8443 +code_server_root_url=https://swataftermath.com:9443/account + # TOKEN MANAGEMENT function migrate { - curl "https://swataftermath.com:8443/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/activate-migrated" --json '{"currentPassword":"'"$3"'","emailAddress":"'"$2"'","newPassword":"'"$3"'"}' + curl "$account_server_root_url/account/$1/verify-email" --json '{"verificationCode":"'"$(cat)"'"}' login "$1" "$3" } function login { [ -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 @@ -25,19 +28,19 @@ function get_token function get { 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 { 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 { 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 @@ -65,9 +68,11 @@ function builds function save { 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" - 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 diff --git a/swat-codegen/documentation.yaml b/swat-codegen/documentation.yaml index 46a73e6..4cd298c 100644 --- a/swat-codegen/documentation.yaml +++ b/swat-codegen/documentation.yaml @@ -3,7 +3,7 @@ "info" : { "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.", - "version" : "0.14.0" + "version" : "0.14.1" }, "externalDocs" : { "url" : "/" @@ -417,7 +417,7 @@ }, "responses" : { "200" : { - "description" : "Successfully logged in.", + "description" : "Generated JWT returned. Tokens expire 2 hours after creation.", "headers" : { }, "content" : { "application/json" : { diff --git a/swat-codegen/openapi.yaml b/swat-codegen/openapi.yaml index ebff393..dcc3892 100644 --- a/swat-codegen/openapi.yaml +++ b/swat-codegen/openapi.yaml @@ -3,7 +3,7 @@ info: title: SWAT Aftermath - RCPD Service description: "Rank code manager service for storing rank codes, generating rank\ \ codes, earning titles, etc. The back end for RPCD 3.0" - version: 0.24.3 + version: 0.25.0 servers: - url: https://swataftermath.com:9443/ tags: @@ -870,11 +870,27 @@ paths: schema: $ref: "#/components/schemas/ErrorResponse" "200": - description: "The 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\ + description: "The updated 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 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\ \ with the same class/trait/specialization combination which shares the\ \ new medal/title." @@ -956,11 +972,27 @@ paths: schema: $ref: "#/components/schemas/ErrorResponse" "200": - description: "The 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\ + description: "The updated 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 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\ \ with the same class/trait/specialization combination which shares the\ \ new medal/title." @@ -1751,13 +1783,6 @@ components: \ and build name." BuildRequest: title: Build Request - required: - - armor - - gun - - specialization - - swatClass - - talent - - trait type: object properties: swatClass: