rest_server: fix token release

resource.usage_token_put() works on the Token instance, and not
the uuid string.  So we first need to look-up the Token instance
for the client-provided UUID string, and then we can call
usage_token_put()
This commit is contained in:
Harald Welte 2023-06-04 20:40:22 +02:00
parent 6544151ff9
commit 425f84f552
1 changed files with 6 additions and 2 deletions

View File

@ -71,10 +71,14 @@ class PwrMgmtRestServer:
set_headers(request)
return json.dumps(token.to_dict())
@app.route('/api/v1/resource/<resrc>/token/<token>/release', methods=['GET'])
def token_release(self, request, resrc, token):
@app.route('/api/v1/resource/<resrc>/token/<token_uuid>/release', methods=['GET'])
def token_release(self, request, resrc, token_uuid):
resource = self.resources[resrc]
# find token within resource
token = resource.usage_token_find(token_uuid)
if not token:
request.setResponseCode(404)
return
resource.usage_token_put(token)
#set_headers(request)
request.setResponseCode(200)