

# 使用 AWS CLI 的 API Gateway 示例
<a name="cli_api-gateway_code_examples"></a>

以下代码示例演示如何通过将 AWS Command Line Interface与 API Gateway 结合使用，来执行操作和实现常见场景。

*操作是大型程序的代码摘录*，必须在上下文中运行。您可以通过操作了解如何调用单个服务函数，还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接，您可以从中找到有关如何在上下文中设置和运行代码的说明。

**Topics**
+ [操作](#actions)

## 操作
<a name="actions"></a>

### `create-api-key`
<a name="api-gateway_CreateApiKey_cli_topic"></a>

以下代码示例演示了如何使用 `create-api-key`。

**AWS CLI**  
**创建为现有 API 和阶段启用的 API 密钥**  
命令:  

```
aws apigateway create-api-key --name 'Dev API Key' --description 'Used for development' --enabled --stage-keys restApiId='a1b2c3d4e5',stageName='dev'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateApiKey](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-api-key.html)。

### `create-authorizer`
<a name="api-gateway_CreateAuthorizer_cli_topic"></a>

以下代码示例演示了如何使用 `create-authorizer`。

**AWS CLI**  
**示例 1：为 API 创建基于令牌的 API Gateway 自定义授权方**  
以下 `create-authorizer` 示例创建基于令牌的授权方。  

```
aws apigateway create-authorizer \
    --rest-api-id 1234123412 \
    --name 'First_Token_Custom_Authorizer' \
    --type TOKEN \
    --authorizer-uri 'arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:customAuthFunction/invocations' \
    --identity-source 'method.request.header.Authorization' \
    --authorizer-result-ttl-in-seconds 300
```
输出：  

```
{
    "authType": "custom",
    "name": "First_Token_Custom_Authorizer",
    "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:customAuthFunction/invocations",
    "authorizerResultTtlInSeconds": 300,
    "identitySource": "method.request.header.Authorization",
    "type": "TOKEN",
    "id": "z40xj0"
}
```
**示例 2：为 API 创建基于 Cognito 用户池的 API Gateway 自定义授权方**  
以下 `create-authorizer` 示例创建基于 Cognito 用户池的 API Gateway 自定义授权方。  

```
aws apigateway create-authorizer \
    --rest-api-id 1234123412 \
    --name 'First_Cognito_Custom_Authorizer' \
    --type COGNITO_USER_POOLS \
    --provider-arns 'arn:aws:cognito-idp:us-east-1:123412341234:userpool/us-east-1_aWcZeQbuD' \
    --identity-source 'method.request.header.Authorization'
```
输出：  

```
{
    "authType": "cognito_user_pools",
    "identitySource": "method.request.header.Authorization",
    "name": "First_Cognito_Custom_Authorizer",
    "providerARNs": [
        "arn:aws:cognito-idp:us-east-1:342398297714:userpool/us-east-1_qWbZzQhzE"
    ],
    "type": "COGNITO_USER_POOLS",
    "id": "5yid1t"
}
```
**示例 3：为 API 创建基于请求的 API Gateway 自定义授权方**  
以下 `create-authorizer` 示例创建基于请求的授权方。  

```
aws apigateway create-authorizer \
    --rest-api-id 1234123412 \
    --name 'First_Request_Custom_Authorizer' \
    --type REQUEST \
    --authorizer-uri 'arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:customAuthFunction/invocations' \
    --identity-source 'method.request.header.Authorization,context.accountId' \
    --authorizer-result-ttl-in-seconds 300
```
输出：  

```
{
    "id": "z40xj0",
    "name": "First_Request_Custom_Authorizer",
    "type": "REQUEST",
    "authType": "custom",
    "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:customAuthFunction/invocations",
    "identitySource": "method.request.header.Authorization,context.accountId",
    "authorizerResultTtlInSeconds": 300
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-authorizer.html)。

### `create-base-path-mapping`
<a name="api-gateway_CreateBasePathMapping_cli_topic"></a>

以下代码示例演示了如何使用 `create-base-path-mapping`。

**AWS CLI**  
**创建自定义域名的基础路径映射**  
命令:  

```
aws apigateway create-base-path-mapping --domain-name subdomain.domain.tld --rest-api-id 1234123412 --stage prod --base-path v1
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateBasePathMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-base-path-mapping.html)。

### `create-deployment`
<a name="api-gateway_CreateDeployment_cli_topic"></a>

以下代码示例演示了如何使用 `create-deployment`。

**AWS CLI**  
**将为 API 配置的资源部署到新阶段**  
命令:  

```
aws apigateway create-deployment --rest-api-id 1234123412 --stage-name dev --stage-description 'Development Stage' --description 'First deployment to the dev stage'
```
**将为 API 配置的资源部署到现有阶段**  
命令:  

```
aws apigateway create-deployment --rest-api-id 1234123412 --stage-name dev --description 'Second deployment to the dev stage'
```
**通过 Stage 变量将为 API 配置的资源部署到现有阶段**  
aws apigateway create-deployment --rest-api-id 1234123412 --stage-name dev --description 'Third deployment to the dev stage' --variables key='value',otherKey='otherValue'  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-deployment.html)。

### `create-domain-name-access-association`
<a name="api-gateway_CreateDomainNameAccessAssociation_cli_topic"></a>

以下代码示例演示了如何使用 `create-domain-name-access-association`。

**AWS CLI**  
**创建域名访问关联**  
以下 `create-domain-name-access-association` 示例在私有自定义域名和 VPC 端点之间创建域名访问关联。  

```
aws apigateway create-domain-name-access-association \
    --domain-name-arn arn:aws:apigateway:us-west-2:111122223333:/domainnames/my.private.domain.tld+abcd1234 \
    --access-association-source vpce-abcd1234efg \
    --access-association-source-type VPCE
```
输出：  

```
{
    "domainNameAccessAssociationArn": "arn:aws:apigateway:us-west-2:012345678910:/domainnameaccessassociations/domainname/my.private.domain.tld/vpcesource/vpce-abcd1234efg
    "accessAssociationSource": "vpce-abcd1234efg",
    "accessAssociationSourceType": "VPCE",
    "domainNameArn" : "arn:aws:apigateway:us-west-2:111122223333:/domainnames/private.example.com+abcd1234"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中私有 API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-custom-domains.html)。  
+  有关 API 详细信息，请参阅《AWS CLI Command Reference》**中的 [CreateDomainNameAccessAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-domain-name-access-association.html)。

### `create-domain-name`
<a name="api-gateway_CreateDomainName_cli_topic"></a>

以下代码示例演示了如何使用 `create-domain-name`。

**AWS CLI**  
**示例 1：创建公共自定义域名**  
以下 `create-domain-name` 示例创建公共自定义域名。  

```
aws apigateway create-domain-name \
    --domain-name 'my.domain.tld' \
    --certificate-name 'my.domain.tld cert'\
    --certificate-arn 'arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3'
```
输出：  

```
{
    "domainName": "my.domain.tld",
    "certificateName": "my.domain.tld cert",
    "certificateArn": "arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3",
    "certificateUploadDate": "2024-10-08T11:29:49-07:00",
    "distributionDomainName": "abcd1234.cloudfront.net",
    "distributionHostedZoneId": "Z2FDTNDATAQYW2",
    "endpointConfiguration": {
        "types": [
            "EDGE"
        ]
    },
    "domainNameStatus": "AVAILABLE",
    "securityPolicy": "TLS_1_2"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中公共 REST API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html)。  
**示例 2：创建私有自定义域名**  
以下 `create-domain-name` 示例创建私有自定义域名。  

```
aws apigateway create-domain-name \
    --domain-name 'my.private.domain.tld' \
    --certificate-name 'my.domain.tld cert' \
    --certificate-arn 'arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3' \
    --endpoint-configuration '{"types": ["PRIVATE"]}' \
    --security-policy 'TLS_1_2' \
    --policy file://policy.json
```
 的内容`policy.json`：  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "execute-api:Invoke",
            "Resource": [
                "execute-api:/*"
            ]
        },
        {
            "Effect": "Deny",
            "Principal": "*",
            "Action": "execute-api:Invoke",
            "Resource": [
                "execute-api:/*"
            ],
            "Condition" : {
                "StringNotEquals": {
                    "aws:SourceVpce": "vpce-abcd1234efg"
                }
            }
        }
    ]
}
```
输出：  

```
{
    "domainName": "my.private.domain.tld",
    "domainNameId": "abcd1234",
    "domainNameArn": "arn:aws:apigateway:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234",
    "certificateArn": "arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3",
    "certificateUploadDate": "2024-09-10T10:31:20-07:00",
    "endpointConfiguration": {
        "types": [
            "PRIVATE"
        ]
    },
    "domainNameStatus": "AVAILABLE",
    "securityPolicy": "TLS_1_2",
    "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234\"},{\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234\",\"Condition\":{\"StringNotEquals\":{\"aws:SourceVpc\":\"vpc-1a2b3c4d\"}}}]}"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中公共 REST API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-domain-name.html)。

### `create-model`
<a name="api-gateway_CreateModel_cli_topic"></a>

以下代码示例演示了如何使用 `create-model`。

**AWS CLI**  
**为 API 创建模型**  
命令:  

```
aws apigateway create-model --rest-api-id 1234123412 --name 'firstModel' --description 'The First Model' --content-type 'application/json'  --schema '{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "firstModel", "type": "object", "properties": { "firstProperty" : { "type": "object", "properties": { "key": { "type": "string" } } } } }'
```
输出：  

```
{
    "contentType": "application/json",
    "description": "The First Model",
    "name": "firstModel",
    "id": "2rzg0l",
    "schema": "{ \"$schema\": \"http://json-schema.org/draft-04/schema#\", \"title\": \"firstModel\", \"type\": \"object\", \"properties\": { \"firstProperty\" : { \"type\": \"object\", \"properties\": { \"key\": { \"type\": \"string\" } } } } }"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-model.html)。

### `create-resource`
<a name="api-gateway_CreateResource_cli_topic"></a>

以下代码示例演示了如何使用 `create-resource`。

**AWS CLI**  
**在 API 中创建资源**  
命令:  

```
aws apigateway create-resource --rest-api-id 1234123412 --parent-id a1b2c3 --path-part 'new-resource'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-resource.html)。

### `create-rest-api`
<a name="api-gateway_CreateRestApi_cli_topic"></a>

以下代码示例演示了如何使用 `create-rest-api`。

**AWS CLI**  
**创建 API**  
命令:  

```
aws apigateway create-rest-api --name 'My First API' --description 'This is my first API'
```
**使用现有 API 创建重复的 API**  
命令:  

```
aws apigateway create-rest-api --name 'Copy of My First API' --description 'This is a copy of my first API' --clone-from 1234123412
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateRestApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-rest-api.html)。

### `create-stage`
<a name="api-gateway_CreateStage_cli_topic"></a>

以下代码示例演示了如何使用 `create-stage`。

**AWS CLI**  
**在 API 中创建包含现有部署的阶段**  
命令:  

```
aws apigateway create-stage --rest-api-id 1234123412 --stage-name 'dev' --description 'Development stage' --deployment-id a1b2c3
```
**在 API 中创建包含现有部署和自定义阶段变量的阶段**  
命令:  

```
aws apigateway create-stage --rest-api-id 1234123412 --stage-name 'dev' --description 'Development stage' --deployment-id a1b2c3 --variables key='value',otherKey='otherValue'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-stage.html)。

### `create-usage-plan-key`
<a name="api-gateway_CreateUsagePlanKey_cli_topic"></a>

以下代码示例演示了如何使用 `create-usage-plan-key`。

**AWS CLI**  
**将现有 API 密钥与使用计划关联**  
命令:  

```
aws apigateway create-usage-plan-key --usage-plan-id a1b2c3 --key-type "API_KEY" --key-id 4vq3yryqm5
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateUsagePlanKey](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-usage-plan-key.html)。

### `create-usage-plan`
<a name="api-gateway_CreateUsagePlan_cli_topic"></a>

以下代码示例演示了如何使用 `create-usage-plan`。

**AWS CLI**  
**创建具有节流功能和配额限制的使用计划，并在月初重置**  
命令:  

```
aws apigateway create-usage-plan --name "New Usage Plan" --description "A new usage plan" --throttle burstLimit=10,rateLimit=5 --quota limit=500,offset=0,period=MONTH
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [CreateUsagePlan](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/create-usage-plan.html)。

### `delete-api-key`
<a name="api-gateway_DeleteApiKey_cli_topic"></a>

以下代码示例演示了如何使用 `delete-api-key`。

**AWS CLI**  
**删除 API 密钥**  
命令:  

```
aws apigateway delete-api-key --api-key 8bklk8bl1k3sB38D9B3l0enyWT8c09B30lkq0blk
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteApiKey](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-api-key.html)。

### `delete-authorizer`
<a name="api-gateway_DeleteAuthorizer_cli_topic"></a>

以下代码示例演示了如何使用 `delete-authorizer`。

**AWS CLI**  
**在 API 中删除自定义授权方**  
命令:  

```
aws apigateway delete-authorizer --rest-api-id 1234123412 --authorizer-id 7gkfbo
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-authorizer.html)。

### `delete-base-path-mapping`
<a name="api-gateway_DeleteBasePathMapping_cli_topic"></a>

以下代码示例演示了如何使用 `delete-base-path-mapping`。

**AWS CLI**  
**删除自定义域名的基础路径映射**  
命令:  

```
aws apigateway delete-base-path-mapping --domain-name 'api.domain.tld' --base-path 'dev'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteBasePathMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-base-path-mapping.html)。

### `delete-client-certificate`
<a name="api-gateway_DeleteClientCertificate_cli_topic"></a>

以下代码示例演示了如何使用 `delete-client-certificate`。

**AWS CLI**  
**删除客户端证书**  
命令:  

```
aws apigateway delete-client-certificate --client-certificate-id a1b2c3
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteClientCertificate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-client-certificate.html)。

### `delete-deployment`
<a name="api-gateway_DeleteDeployment_cli_topic"></a>

以下代码示例演示了如何使用 `delete-deployment`。

**AWS CLI**  
**在 API 中删除部署**  
命令:  

```
aws apigateway delete-deployment --rest-api-id 1234123412 --deployment-id a1b2c3
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-deployment.html)。

### `delete-domain-name-access-association`
<a name="api-gateway_DeleteDomainNameAccessAssociation_cli_topic"></a>

以下代码示例演示了如何使用 `delete-domain-name-access-association`。

**AWS CLI**  
**删除域名访问关联**  
以下 `delete-domain-name-access-association` 示例删除私有自定义域名和 VPC 端点之间的域名访问关联。  

```
aws apigateway delete-domain-name-access-association \
    --domain-name-access-association-arn arn:aws:apigateway:us-west-2:012345678910:/domainnameaccessassociations/domainname/my.private.domain.tld/vpcesource/vpce-abcd1234efg
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中私有 API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-custom-domains.html)。  
+  有关 API 详细信息，请参阅《AWS CLI Command Reference》**中的 [DeleteDomainNameAccessAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-domain-name-access-association.html)。

### `delete-domain-name`
<a name="api-gateway_DeleteDomainName_cli_topic"></a>

以下代码示例演示了如何使用 `delete-domain-name`。

**AWS CLI**  
**删除自定义域名**  
命令:  

```
aws apigateway delete-domain-name --domain-name 'api.domain.tld'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-domain-name.html)。

### `delete-integration-response`
<a name="api-gateway_DeleteIntegrationResponse_cli_topic"></a>

以下代码示例演示了如何使用 `delete-integration-response`。

**AWS CLI**  
**删除 API 中给定资源、方法和状态代码的集成响应**  
命令:  

```
aws apigateway delete-integration-response --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET --status-code 200
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteIntegrationResponse](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-integration-response.html)。

### `delete-integration`
<a name="api-gateway_DeleteIntegration_cli_topic"></a>

以下代码示例演示了如何使用 `delete-integration`。

**AWS CLI**  
**删除 API 中给定资源和方法的集成**  
命令:  

```
aws apigateway delete-integration --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-integration.html)。

### `delete-method-response`
<a name="api-gateway_DeleteMethodResponse_cli_topic"></a>

以下代码示例演示了如何使用 `delete-method-response`。

**AWS CLI**  
**删除 API 中给定资源、方法和状态代码的方法响应**  
命令:  

```
aws apigateway delete-method-response --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET --status-code 200
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteMethodResponse](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-method-response.html)。

### `delete-method`
<a name="api-gateway_DeleteMethod_cli_topic"></a>

以下代码示例演示了如何使用 `delete-method`。

**AWS CLI**  
**删除 API 中给定资源的方法**  
命令:  

```
aws apigateway delete-method --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteMethod](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-method.html)。

### `delete-model`
<a name="api-gateway_DeleteModel_cli_topic"></a>

以下代码示例演示了如何使用 `delete-model`。

**AWS CLI**  
**删除给定 API 中的模型**  
命令:  

```
aws apigateway delete-model --rest-api-id 1234123412 --model-name 'customModel'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-model.html)。

### `delete-resource`
<a name="api-gateway_DeleteResource_cli_topic"></a>

以下代码示例演示了如何使用 `delete-resource`。

**AWS CLI**  
**删除 API 中的资源**  
命令:  

```
aws apigateway delete-resource --rest-api-id 1234123412 --resource-id a1b2c3
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-resource.html)。

### `delete-rest-api`
<a name="api-gateway_DeleteRestApi_cli_topic"></a>

以下代码示例演示了如何使用 `delete-rest-api`。

**AWS CLI**  
**删除 API**  
命令:  

```
aws apigateway delete-rest-api --rest-api-id 1234123412
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteRestApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-rest-api.html)。

### `delete-stage`
<a name="api-gateway_DeleteStage_cli_topic"></a>

以下代码示例演示了如何使用 `delete-stage`。

**AWS CLI**  
**删除 API 中的阶段**  
命令:  

```
aws apigateway delete-stage --rest-api-id 1234123412 --stage-name 'dev'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-stage.html)。

### `delete-usage-plan-key`
<a name="api-gateway_DeleteUsagePlanKey_cli_topic"></a>

以下代码示例演示了如何使用 `delete-usage-plan-key`。

**AWS CLI**  
**从使用计划中移除 API 密钥**  
命令:  

```
aws apigateway delete-usage-plan-key --usage-plan-id a1b2c3 --key-id 1NbjQzMReAkeEQPNAW8r3dXsU2rDD7fc7f2Sipnu
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteUsagePlanKey](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-usage-plan-key.html)。

### `delete-usage-plan`
<a name="api-gateway_DeleteUsagePlan_cli_topic"></a>

以下代码示例演示了如何使用 `delete-usage-plan`。

**AWS CLI**  
**删除使用计划**  
命令:  

```
aws apigateway delete-usage-plan --usage-plan-id a1b2c3
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [DeleteUsagePlan](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/delete-usage-plan.html)。

### `flush-stage-authorizers-cache`
<a name="api-gateway_FlushStageAuthorizersCache_cli_topic"></a>

以下代码示例演示了如何使用 `flush-stage-authorizers-cache`。

**AWS CLI**  
**刷新阶段的所有授权方缓存条目**  
命令:  

```
aws apigateway flush-stage-authorizers-cache --rest-api-id 1234123412 --stage-name dev
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [FlushStageAuthorizersCache](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/flush-stage-authorizers-cache.html)。

### `flush-stage-cache`
<a name="api-gateway_FlushStageCache_cli_topic"></a>

以下代码示例演示了如何使用 `flush-stage-cache`。

**AWS CLI**  
**刷新 API 阶段的缓存**  
以下 `flush-stage-cache` 示例刷新阶段缓存。  

```
aws apigateway flush-stage-cache \
    --rest-api-id 1234123412 \
    --stage-name dev
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[刷新 API Gateway 中的 API 阶段缓存](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html#flush-api-caching)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [FlushStageCache](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/flush-stage-cache.html)。

### `generate-client-certificate`
<a name="api-gateway_GenerateClientCertificate_cli_topic"></a>

以下代码示例演示了如何使用 `generate-client-certificate`。

**AWS CLI**  
**创建客户端侧 SSL 证书**  
命令:  

```
aws apigateway generate-client-certificate --description 'My First Client Certificate'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GenerateClientCertificate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/generate-client-certificate.html)。

### `get-account`
<a name="api-gateway_GetAccount_cli_topic"></a>

以下代码示例演示了如何使用 `get-account`。

**AWS CLI**  
**获取 API Gateway 账户设置**  
命令:  

```
aws apigateway get-account
```
输出：  

```
{
    "cloudwatchRoleArn": "arn:aws:iam::123412341234:role/APIGatewayToCloudWatchLogsRole",
    "throttleSettings": {
        "rateLimit": 500.0,
        "burstLimit": 1000
    }
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetAccount](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-account.html)。

### `get-api-key`
<a name="api-gateway_GetApiKey_cli_topic"></a>

以下代码示例演示了如何使用 `get-api-key`。

**AWS CLI**  
**获取有关指定 API 密钥的信息**  
命令:  

```
aws apigateway get-api-key --api-key 8bklk8bl1k3sB38D9B3l0enyWT8c09B30lkq0blk
```
输出：  

```
{
    "description": "My first key",
    "enabled": true,
    "stageKeys": [
        "a1b2c3d4e5/dev",
        "e5d4c3b2a1/dev"
    ],
    "lastUpdatedDate": 1456184515,
    "createdDate": 1456184452,
    "id": "8bklk8bl1k3sB38D9B3l0enyWT8c09B30lkq0blk",
    "name": "My key"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetApiKey](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-api-key.html)。

### `get-api-keys`
<a name="api-gateway_GetApiKeys_cli_topic"></a>

以下代码示例演示了如何使用 `get-api-keys`。

**AWS CLI**  
**获取 API 密钥列表**  
命令:  

```
aws apigateway get-api-keys
```
输出：  

```
{
    "items": [
        {
            "description": "My first key",
            "enabled": true,
            "stageKeys": [
                "a1b2c3d4e5/dev",
                "e5d4c3b2a1/dev"
            ],
            "lastUpdatedDate": 1456184515,
            "createdDate": 1456184452,
            "id": "8bklk8bl1k3sB38D9B3l0enyWT8c09B30lkq0blk",
            "name": "My key"
        }
    ]
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetApiKeys](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-api-keys.html)。

### `get-authorizer`
<a name="api-gateway_GetAuthorizer_cli_topic"></a>

以下代码示例演示了如何使用 `get-authorizer`。

**AWS CLI**  
**获取每个 API 授权方设置的 API Gateway**  
命令:  

```
aws apigateway get-authorizer --rest-api-id 1234123412 --authorizer-id gfi4n3
```
输出：  

```
{
    "authorizerResultTtlInSeconds": 300,
    "name": "MyAuthorizer",
    "type": "TOKEN",
    "identitySource": "method.request.header.Authorization",
    "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:authorizer_function/invocations",
    "id": "gfi4n3"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-authorizer.html)。

### `get-authorizers`
<a name="api-gateway_GetAuthorizers_cli_topic"></a>

以下代码示例演示了如何使用 `get-authorizers`。

**AWS CLI**  
**获取 REST API 的授权方列表**  
命令:  

```
aws apigateway get-authorizers --rest-api-id 1234123412
```
输出：  

```
{
    "items": [
        {
            "name": "MyAuthorizer",
            "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:My_Authorizer_Function/invocations",
            "authorizerResultTtlInSeconds": 300,
            "identitySource": "method.request.header.Authorization",
            "type": "TOKEN",
            "id": "gfi4n3"
        }
    ]
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetAuthorizers](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-authorizers.html)。

### `get-base-path-mapping`
<a name="api-gateway_GetBasePathMapping_cli_topic"></a>

以下代码示例演示了如何使用 `get-base-path-mapping`。

**AWS CLI**  
**获取自定义域名的一个基础路径映射**  
命令:  

```
aws apigateway get-base-path-mapping --domain-name subdomain.domain.tld --base-path v1
```
输出：  

```
{
    "basePath": "v1",
    "restApiId": "1234w4321e",
    "stage": "api"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetBasePathMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-base-path-mapping.html)。

### `get-base-path-mappings`
<a name="api-gateway_GetBasePathMappings_cli_topic"></a>

以下代码示例演示了如何使用 `get-base-path-mappings`。

**AWS CLI**  
**获取自定义域名的多个基础路径映射**  
命令:  

```
aws apigateway get-base-path-mappings --domain-name subdomain.domain.tld
```
输出：  

```
{
    "items": [
        {
            "basePath": "(none)",
            "restApiId": "1234w4321e",
            "stage": "dev"
        },
        {
            "basePath": "v1",
            "restApiId": "1234w4321e",
            "stage": "api"
        }
    ]
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetBasePathMappings](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-base-path-mappings.html)。

### `get-client-certificate`
<a name="api-gateway_GetClientCertificate_cli_topic"></a>

以下代码示例演示了如何使用 `get-client-certificate`。

**AWS CLI**  
**获取客户端证书**  
命令:  

```
aws apigateway get-client-certificate --client-certificate-id a1b2c3
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetClientCertificate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-client-certificate.html)。

### `get-client-certificates`
<a name="api-gateway_GetClientCertificates_cli_topic"></a>

以下代码示例演示了如何使用 `get-client-certificates`。

**AWS CLI**  
**获取客户端证书列表**  
命令:  

```
aws apigateway get-client-certificates
```
输出：  

```
{
    "items": [
        {
            "pemEncodedCertificate": "-----BEGIN CERTIFICATE----- <certificate content> -----END CERTIFICATE-----",
            "clientCertificateId": "a1b2c3",
            "expirationDate": 1483556561,
            "description": "My Client Certificate",
            "createdDate": 1452020561
        }
    ]
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetClientCertificates](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-client-certificates.html)。

### `get-deployment`
<a name="api-gateway_GetDeployment_cli_topic"></a>

以下代码示例演示了如何使用 `get-deployment`。

**AWS CLI**  
**获取有关部署的信息**  
命令:  

```
aws apigateway get-deployment --rest-api-id 1234123412 --deployment-id ztt4m2
```
输出：  

```
{
    "description": "myDeployment",
    "id": "ztt4m2",
    "createdDate": 1455218022
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-deployment.html)。

### `get-deployments`
<a name="api-gateway_GetDeployments_cli_topic"></a>

以下代码示例演示了如何使用 `get-deployments`。

**AWS CLI**  
**获取 REST API 的部署列表**  
命令:  

```
aws apigateway get-deployments --rest-api-id 1234123412
```
输出：  

```
{
    "items": [
        {
            "createdDate": 1453797217,
            "id": "0a2b4c",
            "description": "Deployed my API for the first time"
        }
    ]
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetDeployments](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-deployments.html)。

### `get-domain-name-access-associations`
<a name="api-gateway_GetDomainNameAccessAssociations_cli_topic"></a>

以下代码示例演示了如何使用 `get-domain-name-access-associations`。

**AWS CLI**  
**示例 1：列出所有域名访问关联**  
以下 `get-domain-name-access-associations` 示例列出所有域名访问关联。  

```
aws apigateway get-domain-name-access-associations
```
输出：  

```
{
    "items": [
        {
        "domainNameAccessAssociationArn": "arn:aws:apigateway:us-west-2:012345678910:/domainnameaccessassociations/domainname/my.private.domain.tld/vpcesource/vpce-abcd1234efg
        "accessAssociationSource": "vpce-abcd1234efg",
        "accessAssociationSourceType": "VPCE",
        "domainNameArn" : "arn:aws:apigateway:us-west-2:111122223333:/domainnames/private.example.com+abcd1234"
        }
    ]
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中私有 API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-custom-domains.html)。  
**示例 2：列出此 AWS 账户拥有的所有域名访问关联**  
以下 `get-domain-name-access-associations` 示例列出当前 AWS 账户拥有的所有域名访问关联。  

```
aws apigateway get-domain-name-access-associations \
    --resource-owner SELF
```
输出：  

```
{
    "items": [
        {
        "domainNameAccessAssociationArn": "arn:aws:apigateway:us-west-2:012345678910:/domainnameaccessassociations/domainname/my.private.domain.tld/vpcesource/vpce-abcd1234efg
        "accessAssociationSource": "vpce-abcd1234efg",
        "accessAssociationSourceType": "VPCE",
        "domainNameArn" : "arn:aws:apigateway:us-west-2:111122223333:/domainnames/private.example.com+abcd1234"
        }
    ]
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中私有 API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-custom-domains.html)。  
+  有关 API 详细信息，请参阅《AWS CLI Command Reference》**中的 [GetDomainNameAccessAssociations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-domain-name-access-associations.html)。

### `get-domain-name`
<a name="api-gateway_GetDomainName_cli_topic"></a>

以下代码示例演示了如何使用 `get-domain-name`。

**AWS CLI**  
**示例 1：获取有关公共自定义域名的信息**  
以下 `get-domain-name` 示例获取有关公共自定义域名的信息。  

```
aws apigateway get-domain-name \
    --domain-name api.domain.tld
```
输出：  

```
{
    "domainName": "api.domain.tld",
    "distributionDomainName": "d1a2f3a4c5o6d.cloudfront.net",
    "certificateName": "uploadedCertificate",
    "certificateUploadDate": 1462565487
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中公共 REST API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html)。  
**示例 2：获取有关私有自定义域名的信息**  
以下 `get-domain-name` 示例获取有关私有自定义域名的信息。  

```
aws apigateway get-domain-name \
    --domain-name api.private.domain.tld \
    --domain-name-id abcd1234
```
输出：  

```
{
    "domainName": "my.private.domain.tld",
    "domainNameId": "abcd1234",
    "domainNameArn": "arn:aws:apigateway:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234",
    "certificateArn": "arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3",
    "certificateUploadDate": "2024-09-10T10:31:20-07:00",
    "endpointConfiguration": {
        "types": [
            "PRIVATE"
        ]
    },
    "domainNameStatus": "AVAILABLE",
    "securityPolicy": "TLS_1_2",
    "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234\"},{\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234\",\"Condition\":{\"StringNotEquals\":{\"aws:SourceVpc\":\"vpc-1a2b3c4d\"}}}]}"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中公共 REST API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-domain-name.html)。

### `get-domain-names`
<a name="api-gateway_GetDomainNames_cli_topic"></a>

以下代码示例演示了如何使用 `get-domain-names`。

**AWS CLI**  
**示例 1：获取自定义域名列表**  
以下 `get-domain-names` 命令获取域名列表。  

```
aws apigateway get-domain-names
```
输出：  

```
{
    "items": [
        {
            "distributionDomainName": "d9511k3l09bkd.cloudfront.net",
            "certificateUploadDate": 1452812505,
            "certificateName": "my_custom_domain-certificate",
            "domainName": "subdomain.domain.tld"
        }
    ]
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中私有 API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-custom-domains.html)。  
**示例 2：获取此 AWS 账户拥有的自定义域名列表**  
以下 `get-domain-names` 命令获取此 AWS 账户拥有的域名列表。  

```
aws apigateway get-domain-names \
    --resource-owner SELF
```
输出：  

```
{
    "items": [
        {
            "domainName": "my.domain.tld",
            "domainNameArn": "arn:aws:apigateway:us-east-1::/domainnames/my.private.domain.tld",
            "certificateUploadDate": "2024-08-15T17:02:55-07:00",
            "regionalDomainName": "d-abcd1234.execute-api.us-east-1.amazonaws.com",
            "regionalHostedZoneId": "Z1UJRXOUMOOFQ8",
            "regionalCertificateArn": "arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3",
            "endpointConfiguration": {
                "types": [
                    "REGIONAL"
                ]
            },
            "domainNameStatus": "AVAILABLE",
            "securityPolicy": "TLS_1_2"
        },
        {
            "domainName": "my.private.domain.tld",
            "domainNameId": "abcd1234",
            "domainNameArn": "arn:aws:apigateway:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234",
            "certificateArn": "arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3",
            "certificateUploadDate": "2024-11-26T11:44:40-08:00",
            "endpointConfiguration": {
                "types": [
                    "PRIVATE"
                ]
            },
            "domainNameStatus": "AVAILABLE",
            "securityPolicy": "TLS_1_2"
        }
    ]
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中私有 API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-custom-domains.html)。  
**示例 3：获取您可以创建域名访问关联的其他 AWS 账户所拥有的自定义域名列表。**  
以下 `get-domain-names` 命令获取您有权创建域名访问关联的其他 AWS 账户所拥有的域名列表。  

```
aws apigateway get-domain-names \
    --resource-owner OTHER_ACCOUNTS
```
输出：  

```
{
    "items": [
        {
            "domainName": "my.private.domain.tld",
            "domainNameId": "abcd1234",
            "domainNameArn": "arn:aws:apigateway:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234"
        }
    ]
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中私有 API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-custom-domains.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetDomainNames](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-domain-names.html)。

### `get-export`
<a name="api-gateway_GetExport_cli_topic"></a>

以下代码示例演示了如何使用 `get-export`。

**AWS CLI**  
**获取阶段的 JSON Swagger 模板**  
命令:  

```
aws apigateway get-export --rest-api-id a1b2c3d4e5 --stage-name dev --export-type swagger /path/to/filename.json
```
**获取阶段的 JSON Swagger 模板 \$1 API Gateway 扩展**  
命令:  

```
aws apigateway get-export --parameters extensions='integrations' --rest-api-id a1b2c3d4e5 --stage-name dev --export-type swagger /path/to/filename.json
```
**获取阶段的 JSON Swagger 模板 \$1 Postman 扩展**  
命令:  

```
aws apigateway get-export --parameters extensions='postman' --rest-api-id a1b2c3d4e5 --stage-name dev --export-type swagger /path/to/filename.json
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetExport](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-export.html)。

### `get-integration-response`
<a name="api-gateway_GetIntegrationResponse_cli_topic"></a>

以下代码示例演示了如何使用 `get-integration-response`。

**AWS CLI**  
**获取在 REST API 资源下定义的 HTTP 方法的集成响应配置**  
命令:  

```
aws apigateway get-integration-response --rest-api-id 1234123412 --resource-id y9h6rt --http-method GET --status-code 200
```
输出：  

```
{
    "statusCode": "200",
    "responseTemplates": {
        "application/json": null
    }
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetIntegrationResponse](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-integration-response.html)。

### `get-integration`
<a name="api-gateway_GetIntegration_cli_topic"></a>

以下代码示例演示了如何使用 `get-integration`。

**AWS CLI**  
**获取在 REST API 资源下定义的 HTTP 方法的集成配置**  
命令:  

```
aws apigateway get-integration --rest-api-id 1234123412 --resource-id y9h6rt --http-method GET
```
输出：  

```
{
    "httpMethod": "POST",
    "integrationResponses": {
        "200": {
            "responseTemplates": {
                "application/json": null
            },
            "statusCode": "200"
        }
    },
    "cacheKeyParameters": [],
    "type": "AWS",
    "uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:My_Function/invocations",
    "cacheNamespace": "y9h6rt"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-integration.html)。

### `get-method-response`
<a name="api-gateway_GetMethodResponse_cli_topic"></a>

以下代码示例演示了如何使用 `get-method-response`。

**AWS CLI**  
**获取在 REST API 资源下定义的 HTTP 方法的方法响应资源配置**  
命令:  

```
aws apigateway get-method-response --rest-api-id 1234123412 --resource-id y9h6rt --http-method GET --status-code 200
```
输出：  

```
{
    "responseModels": {
        "application/json": "Empty"
    },
    "statusCode": "200"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetMethodResponse](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-method-response.html)。

### `get-method`
<a name="api-gateway_GetMethod_cli_topic"></a>

以下代码示例演示了如何使用 `get-method`。

**AWS CLI**  
**获取在 REST API 资源下定义的 HTTP 方法的方法资源配置**  
命令:  

```
aws apigateway get-method --rest-api-id 1234123412 --resource-id y9h6rt --http-method GET
```
输出：  

```
{
    "apiKeyRequired": false,
    "httpMethod": "GET",
    "methodIntegration": {
        "integrationResponses": {
            "200": {
                "responseTemplates": {
                    "application/json": null
                },
                "statusCode": "200"
            }
        },
        "cacheKeyParameters": [],
        "uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:My_Function/invocations",
        "httpMethod": "POST",
        "cacheNamespace": "y9h6rt",
        "type": "AWS"
    },
    "requestParameters": {},
    "methodResponses": {
        "200": {
            "responseModels": {
                "application/json": "Empty"
            },
            "statusCode": "200"
        }
    },
    "authorizationType": "NONE"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetMethod](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-method.html)。

### `get-model-template`
<a name="api-gateway_GetModelTemplate_cli_topic"></a>

以下代码示例演示了如何使用 `get-model-template`。

**AWS CLI**  
**获取在 REST API 下定义的模型的映射模板**  
命令:  

```
aws apigateway get-model-template --rest-api-id 1234123412 --model-name Empty
```
输出：  

```
{
    "value": "#set($inputRoot = $input.path('$'))\n{ }"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetModelTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-model-template.html)。

### `get-model`
<a name="api-gateway_GetModel_cli_topic"></a>

以下代码示例演示了如何使用 `get-model`。

**AWS CLI**  
**获取在 REST API 下定义的模型的配置**  
命令:  

```
aws apigateway get-model --rest-api-id 1234123412 --model-name Empty
```
输出：  

```
{
    "contentType": "application/json",
    "description": "This is a default empty schema model",
    "name": "Empty",
    "id": "etd5w5",
    "schema": "{\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n  \"title\" : \"Empty Schema\",\n  \"type\" : \"object\"\n}"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-model.html)。

### `get-models`
<a name="api-gateway_GetModels_cli_topic"></a>

以下代码示例演示了如何使用 `get-models`。

**AWS CLI**  
**获取 REST API 的模板列表**  
命令:  

```
aws apigateway get-models --rest-api-id 1234123412
```
输出：  

```
{
    "items": [
        {
            "description": "This is a default error schema model",
            "schema": "{\n  \"$schema\" : \"http://json-schema.org/draft-04/schema#\",\n  \"title\" : \"Error Schema\",\n  \"type\" : \"object\",\n  \"properties\" : {\n    \"message\" : { \"type\" : \"string\" }\n  }\n}",
            "contentType": "application/json",
            "id": "7tpbze",
            "name": "Error"
        },
        {
            "description": "This is a default empty schema model",
            "schema": "{\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n  \"title\" : \"Empty Schema\",\n  \"type\" : \"object\"\n}",
            "contentType": "application/json",
            "id": "etd5w5",
            "name": "Empty"
        }
    ]
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetModels](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-models.html)。

### `get-resource`
<a name="api-gateway_GetResource_cli_topic"></a>

以下代码示例演示了如何使用 `get-resource`。

**AWS CLI**  
**获取有关资源的信息**  
命令:  

```
aws apigateway get-resource --rest-api-id 1234123412 --resource-id zwo0y3
```
输出：  

```
{
    "path": "/path",
    "pathPart": "path",
    "id": "zwo0y3",
    "parentId": "uyokt6ij2g"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-resource.html)。

### `get-resources`
<a name="api-gateway_GetResources_cli_topic"></a>

以下代码示例演示了如何使用 `get-resources`。

**AWS CLI**  
**获取 REST API 的资源列表**  
命令:  

```
aws apigateway get-resources --rest-api-id 1234123412
```
输出：  

```
{
    "items": [
        {
            "path": "/resource/subresource",
            "resourceMethods": {
                "POST": {}
            },
            "id": "024ace",
            "pathPart": "subresource",
            "parentId": "ai5b02"
        }
    ]
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetResources](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-resources.html)。

### `get-rest-api`
<a name="api-gateway_GetRestApi_cli_topic"></a>

以下代码示例演示了如何使用 `get-rest-api`。

**AWS CLI**  
**获取有关 API 的信息**  
命令:  

```
aws apigateway get-rest-api --rest-api-id 1234123412
```
输出：  

```
{
    "name": "myAPI",
    "id": "o1y243m4f5",
    "createdDate": 1453416433
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetRestApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-rest-api.html)。

### `get-rest-apis`
<a name="api-gateway_GetRestApis_cli_topic"></a>

以下代码示例演示了如何使用 `get-rest-apis`。

**AWS CLI**  
**获取 REST API 列表**  
命令:  

```
aws apigateway get-rest-apis
```
输出：  

```
{
    "items": [
        {
            "createdDate": 1438884790,
            "id": "12s44z21rb",
            "name": "My First API"
        }
    ]
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetRestApis](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-rest-apis.html)。

### `get-sdk`
<a name="api-gateway_GetSdk_cli_topic"></a>

以下代码示例演示了如何使用 `get-sdk`。

**AWS CLI**  
**获取适用于 REST API 阶段的 Android SDK**  
命令:  

```
aws apigateway get-sdk --rest-api-id 1234123412 --stage-name dev --sdk-type android --parameters groupId='com.mycompany',invokerPackage='com.mycompany.clientsdk',artifactId='Mycompany-client',artifactVersion='1.0.0' /path/to/android_sdk.zip
```
输出：  

```
{
    "contentType": "application/octet-stream",
    "contentDisposition": "attachment; filename=\"android_2016-02-22_23-52Z.zip\""
}
```
**获取适用于 REST API 阶段的 IOS SDK**  
命令:  

```
aws apigateway get-sdk --rest-api-id 1234123412 --stage-name dev --sdk-type objectivec --parameters classPrefix='myprefix' /path/to/iOS_sdk.zip
```
输出：  

```
{
    "contentType": "application/octet-stream",
    "contentDisposition": "attachment; filename=\"objectivec_2016-02-22_23-52Z.zip\""
}
```
**获取适用于 REST API 阶段的 Javascript SDK**  
命令:  

```
aws apigateway get-sdk --rest-api-id 1234123412 --stage-name dev --sdk-type javascript /path/to/javascript_sdk.zip
```
输出：  

```
{
    "contentType": "application/octet-stream",
    "contentDisposition": "attachment; filename=\"javascript_2016-02-22_23-52Z.zip\""
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetSdk](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-sdk.html)。

### `get-stage`
<a name="api-gateway_GetStage_cli_topic"></a>

以下代码示例演示了如何使用 `get-stage`。

**AWS CLI**  
**获取有关 API 阶段的信息**  
命令:  

```
aws apigateway get-stage --rest-api-id 1234123412 --stage-name dev
```
输出：  

```
{
    "stageName": "dev",
    "cacheClusterSize": "0.5",
    "cacheClusterEnabled": false,
    "cacheClusterStatus": "NOT_AVAILABLE",
    "deploymentId": "rbh1fj",
    "lastUpdatedDate": 1466802961,
    "createdDate": 1460682074,
    "methodSettings": {
        "*/*": {
            "cacheTtlInSeconds": 300,
            "loggingLevel": "INFO",
            "dataTraceEnabled": false,
            "metricsEnabled": true,
            "unauthorizedCacheControlHeaderStrategy": "SUCCEED_WITH_RESPONSE_HEADER",
            "throttlingRateLimit": 500.0,
            "cacheDataEncrypted": false,
            "cachingEnabled": false,
            "throttlingBurstLimit": 1000,
            "requireAuthorizationForCacheControl": true
        },
        "~1resource/GET": {
            "cacheTtlInSeconds": 300,
            "loggingLevel": "INFO",
            "dataTraceEnabled": false,
            "metricsEnabled": true,
            "unauthorizedCacheControlHeaderStrategy": "SUCCEED_WITH_RESPONSE_HEADER",
            "throttlingRateLimit": 500.0,
            "cacheDataEncrypted": false,
            "cachingEnabled": false,
            "throttlingBurstLimit": 1000,
            "requireAuthorizationForCacheControl": true
        }
    }
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-stage.html)。

### `get-stages`
<a name="api-gateway_GetStages_cli_topic"></a>

以下代码示例演示了如何使用 `get-stages`。

**AWS CLI**  
**获取 REST API 的阶段列表**  
命令:  

```
aws apigateway get-stages --rest-api-id 1234123412
```
输出：  

```
{
    "item": [
        {
            "stageName": "dev",
            "cacheClusterSize": "0.5",
            "cacheClusterEnabled": true,
            "cacheClusterStatus": "AVAILABLE",
            "deploymentId": "123h64",
            "lastUpdatedDate": 1456185138,
            "createdDate": 1453589092,
            "methodSettings": {
                "~1resource~1subresource/POST": {
                    "cacheTtlInSeconds": 300,
                    "loggingLevel": "INFO",
                    "dataTraceEnabled": true,
                    "metricsEnabled": true,
                    "throttlingRateLimit": 500.0,
                    "cacheDataEncrypted": false,
                    "cachingEnabled": false,
                    "throttlingBurstLimit": 1000
                }
            }
        }
    ]
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetStages](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-stages.html)。

### `get-usage-plan-key`
<a name="api-gateway_GetUsagePlanKey_cli_topic"></a>

以下代码示例演示了如何使用 `get-usage-plan-key`。

**AWS CLI**  
**获取与使用计划关联的 API 密钥的详细信息**  
命令:  

```
aws apigateway get-usage-plan-key --usage-plan-id a1b2c3 --key-id 1NbjQzMReAkeEQPNAW8r3dXsU2rDD7fc7f2Sipnu
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetUsagePlanKey](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-usage-plan-key.html)。

### `get-usage-plan-keys`
<a name="api-gateway_GetUsagePlanKeys_cli_topic"></a>

以下代码示例演示了如何使用 `get-usage-plan-keys`。

**AWS CLI**  
**获取与使用计划关联的 API 密钥列表**  
命令:  

```
aws apigateway get-usage-plan-keys --usage-plan-id a1b2c3
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetUsagePlanKeys](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-usage-plan-keys.html)。

### `get-usage-plan`
<a name="api-gateway_GetUsagePlan_cli_topic"></a>

以下代码示例演示了如何使用 `get-usage-plan`。

**AWS CLI**  
**获取使用计划的详细信息**  
命令:  

```
aws apigateway get-usage-plan --usage-plan-id a1b2c3
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetUsagePlan](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-usage-plan.html)。

### `get-usage-plans`
<a name="api-gateway_GetUsagePlans_cli_topic"></a>

以下代码示例演示了如何使用 `get-usage-plans`。

**AWS CLI**  
**获取所有使用计划的详细信息**  
命令:  

```
aws apigateway get-usage-plans
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetUsagePlans](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-usage-plans.html)。

### `get-usage`
<a name="api-gateway_GetUsage_cli_topic"></a>

以下代码示例演示了如何使用 `get-usage`。

**AWS CLI**  
**获取使用计划的使用详细信息**  
命令:  

```
aws apigateway get-usage --usage-plan-id a1b2c3 --start-date "2016-08-16" --end-date "2016-08-17"
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [GetUsage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/get-usage.html)。

### `import-rest-api`
<a name="api-gateway_ImportRestApi_cli_topic"></a>

以下代码示例演示了如何使用 `import-rest-api`。

**AWS CLI**  
**导入 Swagger 模板并创建 API**  
命令:  

```
aws apigateway import-rest-api --body 'file:///path/to/API_Swagger_template.json'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [ImportRestApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/import-rest-api.html)。

### `put-integration-response`
<a name="api-gateway_PutIntegrationResponse_cli_topic"></a>

以下代码示例演示了如何使用 `put-integration-response`。

**AWS CLI**  
**使用定义的映射模板创建集成响应作为默认响应**  
命令:  

```
aws apigateway put-integration-response --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET --status-code 200 --selection-pattern "" --response-templates '{"application/json": "{\"json\": \"template\"}"}'
```
**使用正则表达式为 400 的静态定义的标头值创建集成响应**  
命令:  

```
aws apigateway put-integration-response --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET --status-code 400 --selection-pattern 400 --response-parameters '{"method.response.header.custom-header": "'"'"'custom-value'"'"'"}'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [PutIntegrationResponse](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/put-integration-response.html)。

### `put-integration`
<a name="api-gateway_PutIntegration_cli_topic"></a>

以下代码示例演示了如何使用 `put-integration`。

**AWS CLI**  
**创建 MOCK 集成请求**  
命令:  

```
aws apigateway put-integration --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET --type MOCK --request-templates '{ "application/json": "{\"statusCode\": 200}" }'
```
**创建 HTTP 集成请求**  
命令:  

```
aws apigateway put-integration --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET --type HTTP --integration-http-method GET --uri 'https://domain.tld/path'
```
**使用 Lambda 函数端点创建 AWS 集成请求**  
命令:  

```
aws apigateway put-integration --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET --type AWS --integration-http-method POST --uri 'arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:function_name/invocations'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [PutIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/put-integration.html)。

### `put-method-response`
<a name="api-gateway_PutMethodResponse_cli_topic"></a>

以下代码示例演示了如何使用 `put-method-response`。

**AWS CLI**  
**基于指定状态代码，通过自定义方法响应标头创建方法响应**  
命令:  

```
aws apigateway put-method-response --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET --status-code 400 --response-parameters "method.response.header.custom-header=false"
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [PutMethodResponse](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/put-method-response.html)。

### `put-method`
<a name="api-gateway_PutMethod_cli_topic"></a>

以下代码示例演示了如何使用 `put-method`。

**AWS CLI**  
**在没有授权、没有 API 密钥和自定义方法请求标头的情况下为 API 中的资源创建方法**  
命令:  

```
aws apigateway put-method --rest-api-id 1234123412 --resource-id a1b2c3 --http-method PUT --authorization-type "NONE" --no-api-key-required --request-parameters "method.request.header.custom-header=false"
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [PutMethod](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/put-method.html)。

### `put-rest-api`
<a name="api-gateway_PutRestApi_cli_topic"></a>

以下代码示例演示了如何使用 `put-rest-api`。

**AWS CLI**  
**使用 Swagger 模板覆盖现有 API**  
命令:  

```
aws apigateway put-rest-api --rest-api-id 1234123412 --mode overwrite --body 'fileb:///path/to/API_Swagger_template.json'
```
**将 Swagger 模板合并到现有 API 中**  
命令:  

```
aws apigateway put-rest-api --rest-api-id 1234123412 --mode merge --body 'fileb:///path/to/API_Swagger_template.json'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [PutRestApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/put-rest-api.html)。

### `reject-domain-name-access-association`
<a name="api-gateway_RejectDomainNameAccessAssociation_cli_topic"></a>

以下代码示例演示了如何使用 `reject-domain-name-access-association`。

**AWS CLI**  
**拒绝域名访问关联**  
以下 `reject-domain-name-access-association` 示例拒绝私有自定义域名和 VPC 端点之间的域名访问关联。  

```
aws apigateway reject-domain-name-access-association \
    --domain-name-access-association-arn arn:aws:apigateway:us-west-2:012345678910:/domainnameaccessassociations/domainname/my.private.domain.tld/vpcesource/vpce-abcd1234efg \
    --domain-name-arn arn:aws:apigateway:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API Gateway 中私有 API 的自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-custom-domains.html)。  
+  有关 API 详细信息，请参阅《AWS CLI Command Reference》**中的 [RejectDomainNameAccessAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/reject-domain-name-access-association.html)。

### `test-invoke-authorizer`
<a name="api-gateway_TestInvokeAuthorizer_cli_topic"></a>

以下代码示例演示了如何使用 `test-invoke-authorizer`。

**AWS CLI**  
**测试包含所需标头和值的自定义授权方的调用请求**  
命令:  

```
aws apigateway test-invoke-authorizer --rest-api-id 1234123412 --authorizer-id 5yid1t --headers Authorization='Value'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [TestInvokeAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/test-invoke-authorizer.html)。

### `test-invoke-method`
<a name="api-gateway_TestInvokeMethod_cli_topic"></a>

以下代码示例演示了如何使用 `test-invoke-method`。

**AWS CLI**  
**通过发出 GET 请求，在 API 中测试调用根资源**  
命令:  

```
aws apigateway test-invoke-method --rest-api-id 1234123412 --resource-id avl5sg8fw8 --http-method GET --path-with-query-string '/'
```
**通过发出指定路径参数值的 GET 请求，在 API 中测试调用子资源**  
命令:  

```
aws apigateway test-invoke-method --rest-api-id 1234123412 --resource-id 3gapai --http-method GET --path-with-query-string '/pets/1'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [TestInvokeMethod](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/test-invoke-method.html)。

### `update-account`
<a name="api-gateway_UpdateAccount_cli_topic"></a>

以下代码示例演示了如何使用 `update-account`。

**AWS CLI**  
**更改用于登录 CloudWatch Logs 的 IAM 角色 ARN**  
命令:  

```
aws apigateway update-account --patch-operations op='replace',path='/cloudwatchRoleArn',value='arn:aws:iam::123412341234:role/APIGatewayToCloudWatchLogs'
```
输出：  

```
{
    "cloudwatchRoleArn": "arn:aws:iam::123412341234:role/APIGatewayToCloudWatchLogs",
    "throttleSettings": {
        "rateLimit": 1000.0,
        "burstLimit": 2000
    }
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateAccount](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-account.html)。

### `update-api-key`
<a name="api-gateway_UpdateApiKey_cli_topic"></a>

以下代码示例演示了如何使用 `update-api-key`。

**AWS CLI**  
**更改 API 密钥的名称**  
命令:  

```
aws apigateway update-api-key --api-key sNvjQDMReA1eEQPNAW8r37XsU2rDD7fc7m2SiMnu --patch-operations op='replace',path='/name',value='newName'
```
输出：  

```
{
    "description": "currentDescription",
    "enabled": true,
    "stageKeys": [
        "41t2j324r5/dev"
    ],
    "lastUpdatedDate": 1470086052,
    "createdDate": 1445460347,
    "id": "sNvjQDMReA1vEQPNzW8r3dXsU2rrD7fcjm2SiMnu",
    "name": "newName"
}
```
**禁用 API 密钥**  
命令:  

```
aws apigateway update-api-key --api-key sNvjQDMReA1eEQPNAW8r37XsU2rDD7fc7m2SiMnu --patch-operations op='replace',path='/enabled',value='false'
```
输出：  

```
{
    "description": "currentDescription",
    "enabled": false,
    "stageKeys": [
        "41t2j324r5/dev"
    ],
    "lastUpdatedDate": 1470086052,
    "createdDate": 1445460347,
    "id": "sNvjQDMReA1vEQPNzW8r3dXsU2rrD7fcjm2SiMnu",
    "name": "newName"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateApiKey](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-api-key.html)。

### `update-authorizer`
<a name="api-gateway_UpdateAuthorizer_cli_topic"></a>

以下代码示例演示了如何使用 `update-authorizer`。

**AWS CLI**  
**更改自定义授权方的名称**  
命令:  

```
aws apigateway update-authorizer --rest-api-id 1234123412 --authorizer-id gfi4n3 --patch-operations op='replace',path='/name',value='testAuthorizer'
```
输出：  

```
{
    "authType": "custom",
    "name": "testAuthorizer",
    "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:customAuthorizer/invocations",
    "authorizerResultTtlInSeconds": 300,
    "identitySource": "method.request.header.Authorization",
    "type": "TOKEN",
    "id": "gfi4n3"
}
```
**更改自定义授权方调用的 Lambda 函数**  
命令:  

```
aws apigateway update-authorizer --rest-api-id 1234123412 --authorizer-id gfi4n3 --patch-operations op='replace',path='/authorizerUri',value='arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:newAuthorizer/invocations'
```
输出：  

```
{
    "authType": "custom",
    "name": "testAuthorizer",
    "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:newAuthorizer/invocations",
    "authorizerResultTtlInSeconds": 300,
    "identitySource": "method.request.header.Authorization",
    "type": "TOKEN",
    "id": "gfi4n3"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-authorizer.html)。

### `update-base-path-mapping`
<a name="api-gateway_UpdateBasePathMapping_cli_topic"></a>

以下代码示例演示了如何使用 `update-base-path-mapping`。

**AWS CLI**  
**更改自定义域名的基础路径**  
命令:  

```
aws apigateway update-base-path-mapping --domain-name api.domain.tld --base-path prod --patch-operations op='replace',path='/basePath',value='v1'
```
输出：  

```
{
    "basePath": "v1",
    "restApiId": "1234123412",
    "stage": "api"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateBasePathMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-base-path-mapping.html)。

### `update-client-certificate`
<a name="api-gateway_UpdateClientCertificate_cli_topic"></a>

以下代码示例演示了如何使用 `update-client-certificate`。

**AWS CLI**  
**更新客户端证书的说明**  
命令:  

```
aws apigateway update-client-certificate --client-certificate-id a1b2c3 --patch-operations op='replace',path='/description',value='My new description'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateClientCertificate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-client-certificate.html)。

### `update-deployment`
<a name="api-gateway_UpdateDeployment_cli_topic"></a>

以下代码示例演示了如何使用 `update-deployment`。

**AWS CLI**  
**更改部署的说明**  
命令:  

```
aws apigateway update-deployment --rest-api-id 1234123412 --deployment-id ztt4m2 --patch-operations op='replace',path='/description',value='newDescription'
```
输出：  

```
{
    "description": "newDescription",
    "id": "ztt4m2",
    "createdDate": 1455218022
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-deployment.html)。

### `update-domain-name`
<a name="api-gateway_UpdateDomainName_cli_topic"></a>

以下代码示例演示了如何使用 `update-domain-name`。

**AWS CLI**  
**更改自定义域名的证书名称**  
以下 `update-domain-name` 示例更改自定义域的证书名称。  

```
aws apigateway update-domain-name \
    --domain-name api.domain.tld \
    --patch-operations op='replace',path='/certificateArn',value='arn:aws:acm:us-west-2:111122223333:certificate/CERTEXAMPLE123EXAMPLE'
```
输出：  

```
{
    "domainName": "api.domain.tld",
    "distributionDomainName": "d123456789012.cloudfront.net",
    "certificateArn": "arn:aws:acm:us-west-2:111122223333:certificate/CERTEXAMPLE123EXAMPLE",
    "certificateUploadDate": 1462565487
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中为 API 设置自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-domain-name.html)。

### `update-integration-response`
<a name="api-gateway_UpdateIntegrationResponse_cli_topic"></a>

以下代码示例演示了如何使用 `update-integration-response`。

**AWS CLI**  
**将集成响应标头更改为具有“\$1”的静态映射**  
命令:  

```
aws apigateway update-integration-response --rest-api-id 1234123412 --resource-id 3gapai --http-method GET --status-code 200 --patch-operations op='replace',path='/responseParameters/method.response.header.Access-Control-Allow-Origin',value='"'"'*'"'"'
```
输出：  

```
{
    "statusCode": "200",
    "responseParameters": {
        "method.response.header.Access-Control-Allow-Origin": "'*'"
    }
}
```
**移除集成响应标头**  
命令:  

```
aws apigateway update-integration-response --rest-api-id 1234123412 --resource-id 3gapai --http-method GET --status-code 200 --patch-operations op='remove',path='/responseParameters/method.response.header.Access-Control-Allow-Origin'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateIntegrationResponse](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-integration-response.html)。

### `update-integration`
<a name="api-gateway_UpdateIntegration_cli_topic"></a>

以下代码示例演示了如何使用 `update-integration`。

**AWS CLI**  
**添加配置了输入直通的“Content-Type: application/json”映射模板**  
命令:  

```
aws apigateway update-integration \
    --rest-api-id a1b2c3d4e5 \
    --resource-id a1b2c3 \
    --http-method POST \
    --patch-operations "op='add',path='/requestTemplates/application~1json'"
```
**更新（替换）使用自定义模板配置的“Content-Type: application/json”映射模板**  
命令:  

```
aws apigateway update-integration \
    --rest-api-id a1b2c3d4e5 \
    --resource-id a1b2c3 \
    --http-method POST \
    --patch-operations "op='replace',path='/requestTemplates/application~1json',value='{"example": "json"}'"
```
**使用输入直通更新（替换）与“Content-Type: application/json”关联的自定义模板**  
命令:  

```
aws apigateway update-integration \
    --rest-api-id a1b2c3d4e5 \
    --resource-id a1b2c3 \
    --http-method POST \
    --patch-operations "op='replace',path='requestTemplates/application~1json'"
```
**移除“Content-Type: application/json”映射模板**  
命令:  

```
aws apigateway update-integration \
    --rest-api-id a1b2c3d4e5 \
    --resource-id a1b2c3 \
    --http-method POST \
    --patch-operations "op='remove',path='/requestTemplates/application~1json'"
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-integration.html)。

### `update-method-response`
<a name="api-gateway_UpdateMethodResponse_cli_topic"></a>

以下代码示例演示了如何使用 `update-method-response`。

**AWS CLI**  
**为方法中的 200 响应创建新的方法响应标头，并将其定义为非必填（默认值）**  
命令:  

```
aws apigateway update-method-response --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET --status-code 200 --patch-operations op="add",path="/responseParameters/method.response.header.custom-header",value="false"
```
**在方法中删除 200 响应的响应模型**  
命令:  

```
aws apigateway update-method-response --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET --status-code 200 --patch-operations op="remove",path="/responseModels/application~1json"
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateMethodResponse](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-method-response.html)。

### `update-method`
<a name="api-gateway_UpdateMethod_cli_topic"></a>

以下代码示例演示了如何使用 `update-method`。

**AWS CLI**  
**示例 1：将方法修改为需要 API 密钥**  
以下 `update-method` 示例将方法修改为需要 API 密钥。  

```
aws apigateway update-method \
    --rest-api-id 1234123412 \
    --resource-id a1b2c3 \
    --http-method GET \
    --patch-operations op="replace",path="/apiKeyRequired",value="true"
```
输出：  

```
{
    "httpMethod": "GET",
    "authorizationType": "NONE",
    "apiKeyRequired": true,
    "methodResponses": {
        "200": {
            "statusCode": "200",
            "responseModels": {}
        }
    },
    "methodIntegration": {
        "type": "AWS",
        "httpMethod": "POST",
        "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789111:function:hello-world/invocations",
        "passthroughBehavior": "WHEN_NO_MATCH",
        "contentHandling": "CONVERT_TO_TEXT",
        "timeoutInMillis": 29000,
        "cacheNamespace": "h7i8j9",
        "cacheKeyParameters": [],
        "integrationResponses": {
            "200": {
                "statusCode": "200",
                "responseTemplates": {}
            }
        }
    }
}
```
**示例 2：将方法修改为需要 IAM 授权**  
以下 `update-method` 示例将方法修改为需要 IAM 授权。  

```
aws apigateway update-method \
    --rest-api-id 1234123412 \
    --resource-id a1b2c3 \
    --http-method GET \
    --patch-operations op="replace",path="/authorizationType",value="AWS_IAM"
```
输出：  

```
 {
    "httpMethod": "GET",
    "authorizationType": "AWS_IAM",
    "apiKeyRequired": false,
    "methodResponses": {
        "200": {
            "statusCode": "200",
            "responseModels": {}
        }
    },
    "methodIntegration": {
        "type": "AWS",
        "httpMethod": "POST",
        "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789111:function:hello-world/invocations",
        "passthroughBehavior": "WHEN_NO_MATCH",
        "contentHandling": "CONVERT_TO_TEXT",
        "timeoutInMillis": 29000,
        "cacheNamespace": "h7i8j9",
        "cacheKeyParameters": [],
        "integrationResponses": {
            "200": {
                "statusCode": "200",
                "responseTemplates": {}
            }
        }
    }
}
```
**示例 3：将方法修改为需要 Lambda 授权**  
以下 `update-method` 示例将方法修改为需要 Lambda 授权。  

```
aws apigateway update-method --rest-api-id 1234123412 \
    --resource-id a1b2c3 \
    --http-method GET \
    --patch-operations op="replace",path="/authorizationType",value="CUSTOM" op="replace",path="/authorizerId",value="e4f5g6"
```
输出：  

```
 {
    "httpMethod": "GET",
    "authorizationType": "CUSTOM",
    "authorizerId" : "e4f5g6",
    "apiKeyRequired": false,
    "methodResponses": {
        "200": {
            "statusCode": "200",
            "responseModels": {}
        }
    },
    "methodIntegration": {
        "type": "AWS",
        "httpMethod": "POST",
        "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789111:function:hello-world/invocations",
        "passthroughBehavior": "WHEN_NO_MATCH",
        "contentHandling": "CONVERT_TO_TEXT",
        "timeoutInMillis": 29000,
        "cacheNamespace": "h7i8j9",
        "cacheKeyParameters": [],
        "integrationResponses": {
            "200": {
                "statusCode": "200",
                "responseTemplates": {}
            }
        }
    }
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[使用 API Gateway CLI 和 REST API 创建、配置和测试使用计划](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-usage-plans-with-rest-api.html)和[在 API Gateway 中控制和管理 REST API 的访问权限](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-control-access-to-api.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateMethod](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-method.html)。

### `update-model`
<a name="api-gateway_UpdateModel_cli_topic"></a>

以下代码示例演示了如何使用 `update-model`。

**AWS CLI**  
**在 API 中更改模型的说明**  
命令:  

```
aws apigateway update-model --rest-api-id 1234123412 --model-name 'Empty' --patch-operations op=replace,path=/description,value='New Description'
```
**在 API 中更改模型的架构**  
命令:  

```
aws apigateway update-model --rest-api-id 1234123412 --model-name 'Empty' --patch-operations op=replace,path=/schema,value='"{ \"$schema\": \"http://json-schema.org/draft-04/schema#\", \"title\" : \"Empty Schema\", \"type\" : \"object\" }"'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-model.html)。

### `update-resource`
<a name="api-gateway_UpdateResource_cli_topic"></a>

以下代码示例演示了如何使用 `update-resource`。

**AWS CLI**  
**在 API 中移动资源并将其置于不同的父资源下**  
命令:  

```
aws apigateway update-resource --rest-api-id 1234123412 --resource-id 1a2b3c --patch-operations op=replace,path=/parentId,value='3c2b1a'
```
输出：  

```
{
    "path": "/resource",
    "pathPart": "resource",
    "id": "1a2b3c",
    "parentId": "3c2b1a"
}
```
**在 API 中重命名资源（pathPart**  
命令:  

```
aws apigateway update-resource --rest-api-id 1234123412 --resource-id 1a2b3c --patch-operations op=replace,path=/pathPart,value=newresourcename
```
输出：  

```
{
    "path": "/newresourcename",
    "pathPart": "newresourcename",
    "id": "1a2b3c",
    "parentId": "3c2b1a"
}
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-resource.html)。

### `update-rest-api`
<a name="api-gateway_UpdateRestApi_cli_topic"></a>

以下代码示例演示了如何使用 `update-rest-api`。

**AWS CLI**  
**更改 API 的名称**  
命令:  

```
aws apigateway update-rest-api --rest-api-id 1234123412 --patch-operations op=replace,path=/name,value='New Name'
```
**更改 API 的说明**  
命令:  

```
aws apigateway update-rest-api --rest-api-id 1234123412 --patch-operations op=replace,path=/description,value='New Description'
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateRestApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-rest-api.html)。

### `update-stage`
<a name="api-gateway_UpdateStage_cli_topic"></a>

以下代码示例演示了如何使用 `update-stage`。

**AWS CLI**  
**示例 1：覆盖资源和方法的阶段设置**  
以下 `update-stage` 示例覆盖阶段设置并关闭指定资源和方法的完整请求/响应日志记录。  

```
aws apigateway update-stage \
    --rest-api-id 1234123412 \
    --stage-name 'dev' \
    --patch-operations op=replace,path=/~1resourceName/GET/logging/dataTrace,value=false
```
输出：  

```
{
    "deploymentId": "5ubd17",
    "stageName": "dev",
    "cacheClusterEnabled": false,
    "cacheClusterStatus": "NOT_AVAILABLE",
    "methodSettings": {
        "~1resourceName/GET": {
            "metricsEnabled": false,
            "dataTraceEnabled": false,
            "throttlingBurstLimit": 5000,
            "throttlingRateLimit": 10000.0,
            "cachingEnabled": false,
            "cacheTtlInSeconds": 300,
            "cacheDataEncrypted": false,
            "requireAuthorizationForCacheControl": true,
            "unauthorizedCacheControlHeaderStrategy": "SUCCEED_WITH_RESPONSE_HEADER"
        }
    },
    "tracingEnabled": false,
    "createdDate": "2022-07-18T10:11:18-07:00",
    "lastUpdatedDate": "2022-07-18T10:19:04-07:00"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[为 REST API 设置阶段](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-stages.html)。  
**示例 2：更新 API 阶段的所有资源和方法的阶段设置**  
以下 `update-stage` 示例为 API 阶段的所有资源和方法开启完整请求/响应日志记录。  

```
aws apigateway update-stage \
    --rest-api-id 1234123412 \
    --stage-name 'dev' \
    --patch-operations 'op=replace,path=/*/*/logging/dataTrace,value=true'
```
输出：  

```
{
    "deploymentId": "5ubd17",
    "stageName": "dev",
    "cacheClusterEnabled": false,
    "cacheClusterStatus": "NOT_AVAILABLE",
    "methodSettings": {
        "*/*": {
            "metricsEnabled": false,
            "dataTraceEnabled": true,
            "throttlingBurstLimit": 5000,
            "throttlingRateLimit": 10000.0,
            "cachingEnabled": false,
            "cacheTtlInSeconds": 300,
            "cacheDataEncrypted": false,
            "requireAuthorizationForCacheControl": true,
            "unauthorizedCacheControlHeaderStrategy": "SUCCEED_WITH_RESPONSE_HEADER"
        }
    },
    "tracingEnabled": false,
    "createdDate": "2022-07-18T10:11:18-07:00",
    "lastUpdatedDate": "2022-07-18T10:31:04-07:00"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[为 REST API 设置阶段](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-stages.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-stage.html)。

### `update-usage-plan`
<a name="api-gateway_UpdateUsagePlan_cli_topic"></a>

以下代码示例演示了如何使用 `update-usage-plan`。

**AWS CLI**  
**更改使用计划中定义的期限**  
命令:  

```
aws apigateway update-usage-plan --usage-plan-id a1b2c3 --patch-operations op="replace",path="/quota/period",value="MONTH"
```
**更改使用计划中定义的配额限制**  
命令:  

```
aws apigateway update-usage-plan --usage-plan-id a1b2c3 --patch-operations op="replace",path="/quota/limit",value="500"
```
**更改使用计划中定义的节流速率限制**  
命令:  

```
aws apigateway update-usage-plan --usage-plan-id a1b2c3 --patch-operations op="replace",path="/throttle/rateLimit",value="10"
```
**更改使用计划中定义的节流爆发限制**  
命令:  

```
aws apigateway update-usage-plan --usage-plan-id a1b2c3 --patch-operations op="replace",path="/throttle/burstLimit",value="20"
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateUsagePlan](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-usage-plan.html)。

### `update-usage`
<a name="api-gateway_UpdateUsage_cli_topic"></a>

以下代码示例演示了如何使用 `update-usage`。

**AWS CLI**  
**临时修改使用计划中定义的当前时间段内 API 密钥的配额**  
命令:  

```
aws apigateway update-usage --usage-plan-id a1b2c3 --key-id 1NbjQzMReAkeEQPNAW8r3dXsU2rDD7fc7f2Sipnu --patch-operations op="replace",path="/remaining",value="50"
```
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateUsage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-usage.html)。

### `update-vpc-link`
<a name="api-gateway_UpdateVpcLink_cli_topic"></a>

以下代码示例演示了如何使用 `update-vpc-link`。

**AWS CLI**  
**示例 1：更新现有 VPC 链接名称**  
以下 `update-vpc-link` 示例更新指定 VPC 链接的名称。  

```
aws apigateway update-vpc-link  \
    --vpc-link-id ab3de6 \
    --patch-operations op=replace,path=/name,value=my-vpc-link
```
输出：  

```
{
    "id": "ab3de6",
    "name": "my-vpc-link",
    "targetArns": [
        "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/my-lb/12a456s89aaa12345"
    ],
    "status": "AVAILABLE",
    "statusMessage": "Your vpc link is ready for use",
    "tags": {}
}
```
有关更多信息，请参阅《AWS CLI 命令参考》**中的[更新现有 VPC 链接](https://docs.aws.amazon.com/cli/latest/reference/apigateway/update-vpc-link.html)。  
**示例 2：更新现有 VPC 链接名称和描述**  
以下 `update-vpc-link` 示例更新指定 VPC 链接的名称。  

```
aws apigateway update-vpc-link  \
    --vpc-link-id ab3de6 \
    --patch-operations op=replace,path=/name,value=my-vpc-link op=replace,path=/description,value="My custom description"
```
输出：  

```
{
    "id": "ab3de6",
    "name": "my-vpc-link",
    "description": "My custom description",
    "targetArns": [
        "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/my-lb/12a456s89aaa12345"
    ],
    "status": "AVAILABLE",
    "statusMessage": "Your vpc link is ready for use",
    "tags": {}
}
```
有关更多信息，请参阅《AWS CLI 命令参考》**中的[更新现有 VPC 链接](https://docs.aws.amazon.com/cli/latest/reference/apigateway/update-vpc-link.html)。  
+  有关 API 详细信息，请参阅《AWS CLI 命令参考》**中的 [UpdateVpcLink](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigateway/update-vpc-link.html)。