配置API网关方法以从阶段继承限制设置

问题描述 投票:1回答:1

我正在使用AWS CLI update-stage命令为API网关方法配置特定的限制设置,效果很好:

aws apigateway update-stage --rest-api-id <the-id> --stage-name <the-stage-name>
--patch-operations op=replace,path='/~1cats~1{pawId}/GET/throttling/rateLimit',value=10

但是,当我尝试删除刚刚配置的设置并从舞台继承节流设置时,默认情况下,我得到一个错误:

aws apigateway update-stage --rest-api-id <the-id> --stage-name <the-stage-name>
--patch-operations op=remove,path='/~1cats~1{pawId}/GET/throttling/rateLimit'
An error occurred (BadRequestException) when calling the UpdateStage operation:
Cannot remove method setting ~1cats~1{pawId}/GET/throttling/rateLimit because there
is no method setting for this method

我如何使用CLI(或与此相关的AWS开发工具包)来获得再次从舞台继承设置的方法?

amazon-web-services aws-sdk aws-api-gateway aws-cli throttling
1个回答
0
投票

这里的问题在于删除呼叫的路径。您正在使用“ /〜1cats〜1 {pawId} / GET / throttling / rateLimit”。

API网关支持删除所有方法设置,而不仅仅是特定的methodSetting。我从我的删除呼叫中删除了“ / throttling / rateLimit”,它可以正常工作。

我运行了以下命令,它起作用了

aws apigateway update-stage --rest-api-id <> --stage-name <> --patch-operations op=replace,path='/hw/GET/throttling/rateLimit',value=20
{
    "deploymentId": "<>",
    "stageName": "<>",
    "cacheClusterEnabled": false,
    "cacheClusterStatus": "NOT_AVAILABLE",
    "methodSettings": {
        "hw/GET": {
            "metricsEnabled": false,
            "dataTraceEnabled": false,
            "throttlingBurstLimit": 5000,
            "throttlingRateLimit": 20.0,
            "cachingEnabled": false,
            "cacheTtlInSeconds": 300,
            "cacheDataEncrypted": false,
            "requireAuthorizationForCacheControl": true,
            "unauthorizedCacheControlHeaderStrategy": "SUCCEED_WITH_RESPONSE_HEADER"
        }
    },
    "tracingEnabled": false,
    "createdDate": "2020-04-24T13:50:18-07:00",
    "lastUpdatedDate": "2020-04-27T01:21:45-07:00"
}
aws apigateway update-stage --rest-api-id <> --stage-name <> --patch-operations op=remove,path=/hw/GET,value=""
{
    "deploymentId": "<>",
    "stageName": "<>",
    "cacheClusterEnabled": false,
    "cacheClusterStatus": "NOT_AVAILABLE",
    "methodSettings": {},
    "tracingEnabled": false,
    "createdDate": "2020-04-24T13:50:18-07:00",
    "lastUpdatedDate": "2020-04-27T01:36:12-07:00"
}

我通过检查API网关控制台进行的网络调用找到了此解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.