Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't figure out the format for API Gateway update_usage_plan call #825

Closed
sunghospark opened this issue Sep 28, 2016 · 2 comments
Closed

Comments

@sunghospark
Copy link

I'm trying to map usage plan to API Gateway stage with the following update_usage_plan api call
http://boto3.readthedocs.io/en/latest/reference/services/apigateway.html#APIGateway.Client.update_usage_plan

Here are few formats I tried but I couldn't figure it out yet..

apig.update_usage_plan(usagePlanId='9rc890', patchOperations=[{'op': 'add', 'path': '/apiStages', 'value': '{"apiId": "kx2asm6go3", "stage": "dev"}'}])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 159, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 494, in _make_api_call
    raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (NotFoundException) when calling the UpdateUsagePlan operation: API Stage not found: {"apiId": "kx2asm6go3", "stage"

It parses value string and omit the second value for some reason.

Also tried following

apig.update_usage_plan(usagePlanId='9rc890', patchOperations=[{'op': 'add', 'path': '/apiStages', 'value': 'apiId=kx2asm6go3,stage=test'}])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 159, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 494, in _make_api_call
    raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (BadRequestException) when calling the UpdateUsagePlan operation: Invalid API Stage specified

and finally, replace operation simply does not work with apiStages

apig.update_usage_plan(usagePlanId='9rc890', patchOperations=[{'op': 'replace', 'path': '/apiStages', 'value': '[{"apiId": "kx2asm6go3", "stage": "dev"}]'}])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 159, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 494, in _make_api_call
    raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (BadRequestException) when calling the UpdateUsagePlan operation: Invalid patch path  '/apiStages' specified for op 'replace'. Must be one of: [/name, /description, /quota/period, /quota/limit, /quota/offset, /throttle/rateLimit, /throttle/burstLimit]

any help would be appreciated.

@sunghospark
Copy link
Author

Here is an example of valid format that works:

response = client.update_usage_plan(usagePlanId='9rc890', patchOperations=[{'op': 'add', 'path': '/apiStages', 'value': 'bf4ye4g8hk:test'}])

So the value is string of 'apigid:stage'

@bofaalsarah
Copy link

I am facing a similar issue but I am trying to grant a usage extension to an API Key in a usage plan

I have tried the below code but I am getting Invalid patch path '/quota/limit' specified for op 'add'. Must be one of: []

apigateway.update_usage( usagePlanId=usage_plan_id, keyId=key_id, patchOperations=[ { 'op': 'add', 'path': '/quota/limit', 'value': value }, ] )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants