

文档 AWS SDK 示例 GitHub 存储库中还有更多 [S AWS DK 示例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# API Gateway HTTP 和 WebSocket API 示例使用 AWS CLI
<a name="cli_2_apigatewayv2_code_examples"></a>

以下代码示例向您展示了如何使用 API Gateway HTTP 和 API 来执行操作和 WebSocket 实现常见场景。 AWS Command Line Interface 

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

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

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

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

### `create-api-mapping`
<a name="apigatewayv2_CreateApiMapping_cli_2_topic"></a>

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

**AWS CLI**  
**为 API 创建 API 映射**  
以下 `create-api-mapping` 示例将 API 的 `test` 阶段映射到 `regional.example.com` 自定义域名的 `/myApi` 路径。  

```
aws apigatewayv2 create-api-mapping \
    --domain-name regional.example.com \
    --api-mapping-key myApi \
    --api-id a1b2c3d4 \
    --stage test
```
输出：  

```
{
    "ApiId": "a1b2c3d4",
    "ApiMappingId": "0qzs2sy7bh",
    "ApiMappingKey": "myApi"
    "Stage": "test"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中设置区域自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateApiMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-api-mapping.html)*中的。

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

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

**AWS CLI**  
**创建 HTTP API**  
以下 `create-api` 示例使用“快速创建”功能创建一个 HTTP API。您可以使用快速创建来创建具有 AWS Lambda 或 HTTP 集成、默认包罗万象的路由以及配置为自动部署更改的默认阶段的 API。以下命令使用“快速创建”功能创建与 Lambda 函数集成的 HTTP API。  

```
aws apigatewayv2 create-api \
    --name my-http-api \
    --protocol-type HTTP \
    --target arn:aws:lambda:us-west-2:123456789012:function:my-lambda-function
```
输出：  

```
{
    "ApiEndpoint": "https://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
    "ApiId": "a1b2c3d4",
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "CreatedDate": "2020-04-08T19:05:45+00:00",
    "Name": "my-http-api",
    "ProtocolType": "HTTP",
    "RouteSelectionExpression": "$request.method $request.path"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中开发 HTTP API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop.html)。  
**创建 WebSocket API**  
以下`create-api`示例创建了一个具有指定名称的 WebSocket API。  

```
aws apigatewayv2 create-api \
    --name "myWebSocketApi" \
    --protocol-type WEBSOCKET \
    --route-selection-expression '$request.body.action'
```
输出：  

```
{
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "Name": "myWebSocketApi",
    "CreatedDate": "2018-11-15T06:23:51Z",
    "ProtocolType": "WEBSOCKET",
    "RouteSelectionExpression": "'$request.body.action'",
    "ApiId": "aabbccddee"
}
```
有关更多信息，请参阅*亚马逊 [ WebSocket API Gateway 开发者指南中的在 API Gateway 中创建](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-create-empty-api.html) API*。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-api.html)*中的。

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

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

**AWS CLI**  
**为 HTTP API 创建 JWT 授权方**  
以下 `create-authorizer` 示例创建使用 Amazon Cognito 作为身份提供商的 JWT 授权方。  

```
aws apigatewayv2 create-authorizer \
    --name my-jwt-authorizer \
    --api-id a1b2c3d4 \
    --authorizer-type JWT \
    --identity-source '$request.header.Authorization' \
    --jwt-configuration Audience=123456abc,Issuer=https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc123
```
输出：  

```
{
    "AuthorizerId": "a1b2c3",
    "AuthorizerType": "JWT",
    "IdentitySource": [
        "$request.header.Authorization"
    ],
    "JwtConfiguration": {
        "Audience": [
            "123456abc"
        ],
        "Issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc123"
    },
    "Name": "my-jwt-authorizer"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发*者指南中的[ APIs 使用 JWT 授权者控制 HTTP 的访问权限](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-authorizer.html)*中的。

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

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

**AWS CLI**  
**为 API 创建部署**  
以下 `create-deployment` 示例创建 API 的部署并将该部署与 API 的 `dev` 阶段关联。  

```
aws apigatewayv2 create-deployment \
    --api-id a1b2c3d4 \
    --stage-name dev
```
输出：  

```
{
    "AutoDeployed": false,
    "CreatedDate": "2020-04-06T23:38:08Z",
    "DeploymentId": "53lz9l",
    "DeploymentStatus": "DEPLOYED"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API 部署](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html#apigateway-definition-api-deployment)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-deployment.html)*中的。

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

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

**AWS CLI**  
**创建自定义域名**  
以下 `create-domain-name` 示例为 API 创建一个区域自定义域名。  

```
aws apigatewayv2 create-domain-name \
    --domain-name regional.example.com \
    --domain-name-configurations CertificateArn=arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678
```
输出：  

```
{
    "ApiMappingSelectionExpression": "$request.basepath",
    "DomainName": "regional.example.com",
    "DomainNameConfigurations": [
        {
            "ApiGatewayDomainName": "d-id.execute-api.us-west-2.amazonaws.com",
            "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678",
            "EndpointType": "REGIONAL",
            "HostedZoneId": "123456789111",
            "SecurityPolicy": "TLS_1_2",
            "DomainNameStatus": "AVAILABLE"
        }
    ]
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中设置区域自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-domain-name.html)*中的。

### `create-integration`
<a name="apigatewayv2_CreateIntegration_cli_2_topic"></a>

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

**AWS CLI**  
**创建 WebSocket API 集成**  
以下`create-integration`示例为 WebSocket API 创建了一个模拟集成。  

```
aws apigatewayv2 create-integration \
    --api-id aabbccddee \
    --passthrough-behavior WHEN_NO_MATCH \
    --timeout-in-millis 29000 \
    --connection-type INTERNET \
    --integration-type MOCK
```
输出：  

```
{
    "ConnectionType": "INTERNET",
    "IntegrationId": "0abcdef",
    "IntegrationResponseSelectionExpression": "${integration.response.statuscode}",
    "IntegrationType": "MOCK",
    "PassthroughBehavior": "WHEN_NO_MATCH",
    "PayloadFormatVersion": "1.0",
    "TimeoutInMillis": 29000
}
```
有关更多信息，请参阅 *Amazon WebSocket API Gateway 开发者指南中的在 API Gateway 中设置 API* [集成请求](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integration-requests.html)。  
**创建 HTTP API 集成**  
以下`create-integration`示例为 HTTP API 创建了 AWS Lambda 集成。  

```
aws apigatewayv2 create-integration \
    --api-id a1b2c3d4 \
    --integration-type AWS_PROXY \
    --integration-uri arn:aws:lambda:us-west-2:123456789012:function:my-function \
    --payload-format-version 2.0
```
输出：  

```
{
    "ConnectionType": "INTERNET",
    "IntegrationId": "0abcdef",
    "IntegrationMethod": "POST",
    "IntegrationType": "AWS_PROXY",
    "IntegrationUri": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
    "PayloadFormatVersion": "2.0",
    "TimeoutInMillis": 30000
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的[配置 HTTP 集成](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-integration.html)*中的。

### `create-route`
<a name="apigatewayv2_CreateRoute_cli_2_topic"></a>

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

**AWS CLI**  
**为 WebSocket 或 HTTP API 创建 \$1default 路由**  
以下`create-route`示例为 WebSocket 或 HTTP API 创建了一`$default`条路由。  

```
aws apigatewayv2 create-route \
    --api-id aabbccddee \
    --route-key '$default'
```
输出：  

```
{
    "ApiKeyRequired": false,
    "AuthorizationType": "NONE",
    "RouteKey": "$default",
    "RouteId": "1122334"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 WebSocket APIs*中的[使用路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-add-route.html)  
**为 HTTP API 创建路由**  
以下 `create-route` 示例创建一个接受 POST 请求的名为 `signup` 的路由。  

```
aws apigatewayv2 create-route \
    --api-id aabbccddee \
    --route-key 'POST /signup'
```
输出：  

```
{
    "ApiKeyRequired": false,
    "AuthorizationType": "NONE",
    "RouteKey": "POST /signup",
    "RouteId": "1122334"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html)  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-route.html)*中的。

### `create-routing-rule`
<a name="apigatewayv2_CreateRoutingRule_cli_2_topic"></a>

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

**AWS CLI**  
**创建路由规则**  
以下 `create-routing-rule` 示例创建优先级为 `50` 的路由规则。  

```
aws apigatewayv2 create-routing-rule \
    --domain-name 'regional.example.com' \
    --priority 50 \
    --conditions '[ \
        { \
            "MatchBasePaths": { \
                "AnyOf": [ \
                    "PetStoreShopper" \
                ] \
            } \
        } \
    ]' \
    --actions '[ \
        { \
            "InvokeApi": { \
                "ApiId": "abcd1234", \
                "Stage": "prod" \
            } \
        } \
    ]'
```
输出：  

```
{
    "Actions": [
        {
            "InvokeApi": {
                "ApiId": "abcd1234",
                "Stage": "prod",
                "StripBasePath": false
            }
        }
    ],
    "Conditions": [
        {
            "MatchBasePaths": {
                "AnyOf": [
                    "PetStoreShopper"
                ]
            }
        }
    ],
    "Priority": 50,
    "RoutingRuleArn": "arn:aws:apigateway:us-east-2:123456789012:/domainnames/regional.example.com/routingrules/aaa111",
    "RoutingRuleId": "aaa111"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs中的将 API* [阶段连接到 REST 自定义域名的路由规则](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-routing-rules.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateRoutingRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-routing-rule.html)*中的。

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

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

**AWS CLI**  
**创建阶段**  
以下 `create-stage` 示例为 API 创建一个名为 dev 的阶段。  

```
aws apigatewayv2 create-stage \
    --api-id a1b2c3d4 \
    --stage-name dev
```
输出：  

```
{
    "CreatedDate": "2020-04-06T23:23:46Z",
    "DefaultRouteSettings": {
        "DetailedMetricsEnabled": false
    },
    "LastUpdatedDate": "2020-04-06T23:23:46Z",
    "RouteSettings": {},
    "StageName": "dev",
    "StageVariables": {},
    "Tags": {}
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 的阶段](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-stages.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-stage.html)*中的。

### `create-vpc-link`
<a name="apigatewayv2_CreateVpcLink_cli_2_topic"></a>

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

**AWS CLI**  
**为 HTTP API 创建 VPC 链接**  
以下`create-vpc-link`示例为 HTTP 创建一个 VPC 链接 APIs。  

```
aws apigatewayv2 create-vpc-link \
    --name MyVpcLink \
    --subnet-ids subnet-aaaa subnet-bbbb \
    --security-group-ids sg1234 sg5678
```
输出：  

```
{
    "CreatedDate": "2020-04-07T00:11:46Z",
    "Name": "MyVpcLink",
    "SecurityGroupIds": [
        "sg1234",
        "sg5678"
    ],
    "SubnetIds": [
        "subnet-aaaa",
        "subnet-bbbb"
    ],
    "Tags": {},
    "VpcLinkId": "abcd123",
    "VpcLinkStatus": "PENDING",
    "VpcLinkStatusMessage": "VPC link is provisioning ENIs",
    "VpcLinkVersion": "V2"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 的 VPC 链接](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[CreateVpcLink](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-vpc-link.html)*中的。

### `delete-access-log-settings`
<a name="apigatewayv2_DeleteAccessLogSettings_cli_2_topic"></a>

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

**AWS CLI**  
**禁用 API 的访问日志记录**  
以下 `delete-access-log-settings` 示例删除 API `$default` 阶段的访问日志设置。要禁用阶段的访问日志记录，请删除其访问日志设置。  

```
aws apigatewayv2 delete-access-log-settings \
    --api-id a1b2c3d4 \
    --stage-name '$default'
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[为 HTTP API 配置日志记录](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-logging.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteAccessLogSettings](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-access-log-settings.html)*中的。

### `delete-api-mapping`
<a name="apigatewayv2_DeleteApiMapping_cli_2_topic"></a>

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

**AWS CLI**  
**删除 API 映射**  
以下 `delete-api-mapping` 示例删除 `api.example.com` 自定义域名的 API 映射。  

```
aws apigatewayv2 delete-api-mapping \
    --api-mapping-id a1b2c3 \
    --domain-name api.example.com
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中设置区域自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteApiMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-api-mapping.html)*中的。

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

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

**AWS CLI**  
**删除 API**  
以下 `delete-api` 示例删除 API。  

```
aws apigatewayv2 delete-api \
    --api-id a1b2c3d4
```
此命令不生成任何输出。  
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 WebSocket APIs*[中的使用](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api.html) [HTTP APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html) 和使用。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-api.html)*中的。

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

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

**AWS CLI**  
**删除授权方**  
以下 `delete-authorizer` 示例删除授权方。  

```
aws apigatewayv2 delete-authorizer \
    --api-id a1b2c3d4 \
    --authorizer-id a1b2c3
```
此命令不生成任何输出。  
有关更多信息，请参阅 *Amazon API Gateway 开发*者指南中的[ APIs 使用 JWT 授权者控制 HTTP 的访问权限](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-authorizer.html)*中的。

### `delete-cors-configuration`
<a name="apigatewayv2_DeleteCorsConfiguration_cli_2_topic"></a>

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

**AWS CLI**  
**删除 HTTP API 的 CORS 配置**  
以下 `delete-cors-configuration` 示例通过删除 HTTP API 的 CORS 配置来禁用 HTTP API 的 CORS。  

```
aws apigatewayv2 delete-cors-configuration \
    --api-id a1b2c3d4
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[为 HTTP API 配置 CORS](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteCorsConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-cors-configuration.html)*中的。

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

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

**AWS CLI**  
**删除部署**  
以下 `delete-deployment` 示例删除 API 的部署。  

```
aws apigatewayv2 delete-deployment \
    --api-id a1b2c3d4 \
    --deployment-id a1b2c3
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API 部署](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html#apigateway-definition-api-deployment)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-deployment.html)*中的。

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

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

**AWS CLI**  
**删除自定义域名**  
以下 `delete-domain-name` 示例删除一个自定义域名。  

```
aws apigatewayv2 delete-domain-name \
    --domain-name api.example.com
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中设置区域自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-domain-name.html)*中的。

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

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

**AWS CLI**  
**删除集成**  
以下 `delete-integration` 示例删除 API 集成。  

```
aws apigatewayv2 delete-integration \
    --api-id a1b2c3d4 \
    --integration-id a1b2c3
```
此命令不生成任何输出。  
有关更多信息，请参阅 *Amazon API [Gateway 开发者指南中的配置 HTTP](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html) [集成 APIs和设置 WebSocket AP](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integrations.html) I* 集成。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-integration.html)*中的。

### `delete-route-settings`
<a name="apigatewayv2_DeleteRouteSettings_cli_2_topic"></a>

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

**AWS CLI**  
**删除路由设置**  
以下 `delete-route-settings` 示例删除指定路由的路由设置。  

```
aws apigatewayv2 delete-route-settings \
    --api-id a1b2c3d4 \
    --stage-name dev \
    --route-key 'GET /pets'
```
此命令不生成任何输出。  
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteRouteSettings](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-route-settings.html)*中的。

### `delete-route`
<a name="apigatewayv2_DeleteRoute_cli_2_topic"></a>

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

**AWS CLI**  
**删除路由**  
以下 `delete-route` 示例删除 API 路由。  

```
aws apigatewayv2 delete-route \
    --api-id a1b2c3d4 \
    --route-id a1b2c3
```
此命令不生成任何输出。  
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-route.html)*中的。

### `delete-routing-rule`
<a name="apigatewayv2_DeleteRoutingRule_cli_2_topic"></a>

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

**AWS CLI**  
**删除路由规则**  
以下 `delete-routing-rule` 示例删除自定义域名的路由规则。  

```
aws apigatewayv2 delete-routing-rule \
    --domain-name 'regional.example.com' \
    --routing-rule-id aaa111
```
此命令不生成任何输出。  
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs中的将 API* [阶段连接到 REST 自定义域名的路由规则](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-routing-rules.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteRoutingRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-routing-rule.html)*中的。

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

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

**AWS CLI**  
**删除阶段**  
以下 `delete-stage` 示例删除 API 的 `test` 阶段。  

```
aws apigatewayv2 delete-stage \
    --api-id a1b2c3d4 \
    --stage-name test
```
此命令不生成任何输出。  
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 的阶段](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-stages.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-stage.html)*中的。

### `delete-vpc-link`
<a name="apigatewayv2_DeleteVpcLink_cli_2_topic"></a>

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

**AWS CLI**  
**删除 HTTP API 的 VPC 链接**  
以下 `delete-vpc-link` 示例删除 VPC 链接。  

```
aws apigatewayv2 delete-vpc-link \
    --vpc-link-id abcd123
```
此命令不生成任何输出。  
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 的 VPC 链接](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DeleteVpcLink](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-vpc-link.html)*中的。

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

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

**AWS CLI**  
**导出 HTTP API 的 OpenAPI 定义**  
以下 `export-api` 示例将名为 `prod` 的 API 阶段的 OpenAPI 3.0 定义导出到名为 `stage-definition.yaml` 的 YAML 文件。默认情况下，导出的定义文件包含 API Gateway 扩展名。  

```
aws apigatewayv2 export-api \
    --api-id a1b2c3d4 \
    --output-type YAML \
    --specification OAS30 \
    --stage-name prod \
    stage-definition.yaml
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[从 API Gateway 导出 HTTP API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-export.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ExportApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/export-api.html)*中的。

### `get-api-mapping`
<a name="apigatewayv2_GetApiMapping_cli_2_topic"></a>

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

**AWS CLI**  
**获取有关自定义域名的 API 映射的信息**  
以下 `get-api-mapping` 示例显示有关 `api.example.com` 自定义域名的 API 映射的信息。  

```
aws apigatewayv2 get-api-mapping \
    --api-mapping-id a1b2c3 \
    --domain-name api.example.com
```
输出：  

```
{
    "ApiId": "a1b2c3d4",
    "ApiMappingId": "a1b2c3d5",
    "ApiMappingKey": "myTestApi"
    "Stage": "test"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中设置区域自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetApiMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-api-mapping.html)*中的。

### `get-api-mappings`
<a name="apigatewayv2_GetApiMappings_cli_2_topic"></a>

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

**AWS CLI**  
**获取自定义域名的 API 映射**  
以下 `get-api-mappings` 示例显示 `api.example.com` 自定义域名的所有 API 映射列表。  

```
aws apigatewayv2 get-api-mappings \
    --domain-name api.example.com
```
输出：  

```
{
    "Items": [
        {
            "ApiId": "a1b2c3d4",
            "ApiMappingId": "a1b2c3d5",
            "ApiMappingKey": "myTestApi"
            "Stage": "test"
        },
        {
            "ApiId": "a5b6c7d8",
            "ApiMappingId": "a1b2c3d6",
            "ApiMappingKey": "myDevApi"
            "Stage": "dev"
        },
    ]
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中设置区域自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetApiMappings](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-api-mappings.html)*中的。

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

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

**AWS CLI**  
**检索有关 API 的信息**  
以下 `get-api` 示例显示有关 API 的信息。  

```
aws apigatewayv2 get-api \
    --api-id a1b2c3d4
```
输出：  

```
{
    "ApiEndpoint": "https://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
    "ApiId": "a1b2c3d4",
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "CreatedDate": "2020-03-28T00:32:37Z",
    "Name": "my-api",
    "ProtocolType": "HTTP",
    "RouteSelectionExpression": "$request.method $request.path",
    "Tags": {
        "department": "finance"
    }
}
```
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-api.html)*中的。

### `get-apis`
<a name="apigatewayv2_GetApis_cli_2_topic"></a>

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

**AWS CLI**  
**要检索列表 APIs**  
以下`get-apis`示例列出了当前用户的所有内容。 APIs   

```
aws apigatewayv2 get-apis
```
输出：  

```
{
    "Items": [
        {
            "ApiEndpoint": "wss://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
            "ApiId": "a1b2c3d4",
            "ApiKeySelectionExpression": "$request.header.x-api-key",
            "CreatedDate": "2020-04-07T20:21:59Z",
            "Name": "my-websocket-api",
            "ProtocolType": "WEBSOCKET",
            "RouteSelectionExpression": "$request.body.message",
            "Tags": {}
        },
        {
            "ApiEndpoint": "https://a1b2c3d5.execute-api.us-west-2.amazonaws.com",
            "ApiId": "a1b2c3d5",
            "ApiKeySelectionExpression": "$request.header.x-api-key",
            "CreatedDate": "2020-04-07T20:23:50Z",
            "Name": "my-http-api",
            "ProtocolType": "HTTP",
            "RouteSelectionExpression": "$request.method $request.path",
            "Tags": {}
        }
    ]
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 WebSocket APIs*[中的使用](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api.html) [HTTP APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html) 和使用。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetApis](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-apis.html)*中的。

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

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

**AWS CLI**  
**检索有关授权方的信息**  
以下 `get-authorizer` 示例显示有关授权方的信息。  

```
aws apigatewayv2 get-authorizer \
    --api-id a1b2c3d4 \
    --authorizer-id a1b2c3
```
输出：  

```
{
    "AuthorizerId": "a1b2c3",
    "AuthorizerType": "JWT",
    "IdentitySource": [
        "$request.header.Authorization"
    ],
    "JwtConfiguration": {
        "Audience": [
            "123456abc"
        ],
        "Issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc123"
    },
    "Name": "my-jwt-authorizer"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发*者指南中的[ APIs 使用 JWT 授权者控制 HTTP 的访问权限](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-authorizer.html)*中的。

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

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

**AWS CLI**  
**检索 API 的授权方列表**  
以下 `get-authorizers` 示例显示 API 的所有授权方的列表。  

```
aws apigatewayv2 get-authorizers \
    --api-id a1b2c3d4
```
输出：  

```
{
    "Items": [
        {
            "AuthorizerId": "a1b2c3",
            "AuthorizerType": "JWT",
            "IdentitySource": [
                "$request.header.Authorization"
            ],
            "JwtConfiguration": {
                "Audience": [
                    "123456abc"
                ],
                "Issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc123"
            },
            "Name": "my-jwt-authorizer"
        },
        {
            "AuthorizerId": "a1b2c4",
            "AuthorizerType": "JWT",
            "IdentitySource": [
                "$request.header.Authorization"
            ],
            "JwtConfiguration": {
                "Audience": [
                    "6789abcde"
                ],
                "Issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc234"
            },
            "Name": "new-jwt-authorizer"
        }
    ]
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发*者指南中的[ APIs 使用 JWT 授权者控制 HTTP 的访问权限](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetAuthorizers](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-authorizers.html)*中的。

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

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

**AWS CLI**  
**检索有关部署的信息**  
以下 `get-deployment` 示例显示有关部署的信息。  

```
aws apigatewayv2 get-deployment \
    --api-id a1b2c3d4 \
    --deployment-id abcdef
```
输出：  

```
{
    "AutoDeployed": true,
    "CreatedDate": "2020-04-07T23:58:40Z",
    "DeploymentId": "abcdef",
    "DeploymentStatus": "DEPLOYED",
    "Description": "Automatic deployment triggered by changes to the Api configuration"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API 部署](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html#apigateway-definition-api-deployment)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-deployment.html)*中的。

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

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

**AWS CLI**  
**检索部署列表**  
以下 `get-deployments` 示例显示所有 API 部署的列表。  

```
aws apigatewayv2 get-deployments \
    --api-id a1b2c3d4
```
输出：  

```
{
    "Items": [
        {
            "AutoDeployed": true,
            "CreatedDate": "2020-04-07T23:58:40Z",
            "DeploymentId": "abcdef",
            "DeploymentStatus": "DEPLOYED",
            "Description": "Automatic deployment triggered by changes to the Api configuration"
        },
        {
            "AutoDeployed": true,
            "CreatedDate": "2020-04-06T00:33:00Z",
            "DeploymentId": "bcdefg",
            "DeploymentStatus": "DEPLOYED",
            "Description": "Automatic deployment triggered by changes to the Api configuration"
        }
    ]
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的 [API 部署](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html#apigateway-definition-api-deployment)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetDeployments](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-deployments.html)*中的。

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

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

**AWS CLI**  
**检索有关自定义域名的信息**  
以下 `get-domain-name` 示例显示有关自定义域名的信息。  

```
aws apigatewayv2 get-domain-name \
    --domain-name api.example.com
```
输出：  

```
{
    "ApiMappingSelectionExpression": "$request.basepath",
    "DomainName": "api.example.com",
    "DomainNameConfigurations": [
        {
            "ApiGatewayDomainName": "d-1234.execute-api.us-west-2.amazonaws.com",
            "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678",
            "EndpointType": "REGIONAL",
            "HostedZoneId": "123456789111",
            "SecurityPolicy": "TLS_1_2",
            "DomainNameStatus": "AVAILABLE"
        }
    ],
    "Tags": {}
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中设置区域自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-domain-name.html)*中的。

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

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

**AWS CLI**  
**检索自定义域名列表**  
以下 `get-domain-names` 示例显示当前用户的所有自定义域名列表。  

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

```
{
    "Items": [
        {
            "ApiMappingSelectionExpression": "$request.basepath",
            "DomainName": "api.example.com",
            "DomainNameConfigurations": [
                {
                    "ApiGatewayDomainName": "d-1234.execute-api.us-west-2.amazonaws.com",
                    "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678",
                    "EndpointType": "REGIONAL",
                    "HostedZoneId": "123456789111",
                    "SecurityPolicy": "TLS_1_2",
                    "DomainNameStatus": "AVAILABLE"
                }
            ]
        },
        {
            "ApiMappingSelectionExpression": "$request.basepath",
            "DomainName": "newApi.example.com",
            "DomainNameConfigurations": [
                {
                    "ApiGatewayDomainName": "d-5678.execute-api.us-west-2.amazonaws.com",
                    "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678",
                    "EndpointType": "REGIONAL",
                    "HostedZoneId": "123456789222",
                    "SecurityPolicy": "TLS_1_2",
                    "DomainNameStatus": "AVAILABLE"
                }
            ]
        }
    ]
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中设置区域自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetDomainNames](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-domain-names.html)*中的。

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

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

**AWS CLI**  
**检索有关集成的信息**  
以下 `get-integration` 示例显示有关集成的信息。  

```
aws apigatewayv2 get-integration \
    --api-id a1b2c3d4 \
    --integration-id a1b2c3
```
输出：  

```
{
    "ApiGatewayManaged": true,
    "ConnectionType": "INTERNET",
    "IntegrationId": "a1b2c3",
    "IntegrationMethod": "POST",
    "IntegrationType": "AWS_PROXY",
    "IntegrationUri": "arn:aws:lambda:us-west-2:12356789012:function:hello12",
    "PayloadFormatVersion": "2.0",
    "TimeoutInMillis": 30000
}
```
有关更多信息，请参阅 *Amazon API [Gateway 开发者指南中的配置 HTTP](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html) [集成 APIs和设置 WebSocket AP](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integrations.html) I* 集成。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-integration.html)*中的。

### `get-integrations`
<a name="apigatewayv2_GetIntegrations_cli_2_topic"></a>

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

**AWS CLI**  
**检索集成列表**  
以下 `get-integrations` 示例显示所有 API 集成的列表。  

```
aws apigatewayv2 get-integrations \
    --api-id a1b2c3d4
```
输出：  

```
{
    "Items": [
        {
            "ApiGatewayManaged": true,
            "ConnectionType": "INTERNET",
            "IntegrationId": "a1b2c3",
            "IntegrationMethod": "POST",
            "IntegrationType": "AWS_PROXY",
            "IntegrationUri": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
            "PayloadFormatVersion": "2.0",
            "TimeoutInMillis": 30000
        },
        {
            "ConnectionType": "INTERNET",
            "IntegrationId": "a1b2c4",
            "IntegrationMethod": "ANY",
            "IntegrationType": "HTTP_PROXY",
            "IntegrationUri": "https://www.example.com",
            "PayloadFormatVersion": "1.0",
            "TimeoutInMillis": 30000
        }
    ]
}
```
有关更多信息，请参阅 *Amazon API [Gateway 开发者指南中的配置 HTTP](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html) [集成 APIs和设置 WebSocket AP](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integrations.html) I* 集成。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetIntegrations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-integrations.html)*中的。

### `get-route`
<a name="apigatewayv2_GetRoute_cli_2_topic"></a>

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

**AWS CLI**  
**检索有关路由的信息**  
以下 `get-route` 示例显示有关路由的信息。  

```
aws apigatewayv2 get-route \
    --api-id a1b2c3d4 \
    --route-id 72jz1wk
```
输出：  

```
{
    "ApiKeyRequired": false,
    "AuthorizationType": "NONE",
    "RouteId": "72jz1wk",
    "RouteKey": "ANY /pets",
    "Target": "integrations/a1b2c3"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html)  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-route.html)*中的。

### `get-routes`
<a name="apigatewayv2_GetRoutes_cli_2_topic"></a>

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

**AWS CLI**  
**检索路由列表**  
以下 `get-routes` 示例显示所有 API 路由的列表。  

```
aws apigatewayv2 get-routes \
    --api-id a1b2c3d4
```
输出：  

```
{
    "Items": [
        {
            "ApiKeyRequired": false,
            "AuthorizationType": "NONE",
            "RouteId": "72jz1wk",
            "RouteKey": "ANY /admin",
            "Target": "integrations/a1b2c3"
        },
        {
            "ApiGatewayManaged": true,
            "ApiKeyRequired": false,
            "AuthorizationType": "NONE",
            "RouteId": "go65gqi",
            "RouteKey": "$default",
            "Target": "integrations/a1b2c4"
        }
    ]
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html)  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetRoutes](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-routes.html)*中的。

### `get-routing-rule`
<a name="apigatewayv2_GetRoutingRule_cli_2_topic"></a>

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

**AWS CLI**  
**获取路由规则**  
以下 `get-routing-rule` 示例获取域名的路由规则。  

```
aws apigatewayv2 get-routing-rule \
    --domain-name 'regional.example.com' \
    --routing-rule-id aaa111
```
输出：  

```
{
    "Actions": [
        {
            "InvokeApi": {
                "ApiId": "abcd1234",
                "Stage": "prod",
                "StripBasePath": false
            }
        }
    ],
    "Conditions": [
        {
            "MatchBasePaths": {
                "AnyOf": [
                    "PetStoreShopper"
                ]
            }
        }
    ],
    "Priority": 50,
    "RoutingRuleArn": "arn:aws:apigateway:us-east-2:123456789012:/domainnames/regional.example.com/routingrules/aaa111",
    "RoutingRuleId": "aaa111"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs中的将 API* [阶段连接到 REST 自定义域名的路由规则](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-routing-rules.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetRoutingRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-routing-rule.html)*中的。

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

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

**AWS CLI**  
**检索有关阶段的信息**  
以下 `get-stage` 示例显示有关 API `prod` 阶段的信息。  

```
aws apigatewayv2 get-stage \
    --api-id a1b2c3d4 \
    --stage-name prod
```
输出：  

```
{
    "CreatedDate": "2020-04-08T00:36:05Z",
    "DefaultRouteSettings": {
        "DetailedMetricsEnabled": false
    },
    "DeploymentId": "x1zwyv",
    "LastUpdatedDate": "2020-04-08T00:36:13Z",
    "RouteSettings": {},
    "StageName": "prod",
    "StageVariables": {
        "function": "my-prod-function"
    },
    "Tags": {}
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 的阶段](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-stages.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-stage.html)*中的。

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

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

**AWS CLI**  
**检索阶段列表**  
以下 `get-stages` 示例列出 API 的所有阶段。  

```
aws apigatewayv2 get-stages \
    --api-id a1b2c3d4
```
输出：  

```
{
    "Items": [
        {
            "ApiGatewayManaged": true,
            "AutoDeploy": true,
            "CreatedDate": "2020-04-08T00:08:44Z",
            "DefaultRouteSettings": {
                "DetailedMetricsEnabled": false
            },
            "DeploymentId": "dty748",
            "LastDeploymentStatusMessage": "Successfully deployed stage with deployment ID 'dty748'",
            "LastUpdatedDate": "2020-04-08T00:09:49Z",
            "RouteSettings": {},
            "StageName": "$default",
            "StageVariables": {},
            "Tags": {}
        },
        {
            "AutoDeploy": true,
            "CreatedDate": "2020-04-08T00:35:06Z",
            "DefaultRouteSettings": {
                "DetailedMetricsEnabled": false
            },
            "LastUpdatedDate": "2020-04-08T00:35:48Z",
            "RouteSettings": {},
            "StageName": "dev",
            "StageVariables": {
                "function": "my-dev-function"
            },
            "Tags": {}
        },
        {
            "CreatedDate": "2020-04-08T00:36:05Z",
            "DefaultRouteSettings": {
                "DetailedMetricsEnabled": false
            },
            "DeploymentId": "x1zwyv",
            "LastUpdatedDate": "2020-04-08T00:36:13Z",
            "RouteSettings": {},
            "StageName": "prod",
            "StageVariables": {
                "function": "my-prod-function"
            },
            "Tags": {}
        }
    ]
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 的阶段](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-stages.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetStages](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-stages.html)*中的。

### `get-tags`
<a name="apigatewayv2_GetTags_cli_2_topic"></a>

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

**AWS CLI**  
**检索资源的标签列表**  
以下 `get-tags` 示例列出 API 的所有标签。  

```
aws apigatewayv2 get-tags \
    --resource-arn arn:aws:apigateway:us-west-2::/apis/a1b2c3d4
```
输出：  

```
{
    "Tags": {
        "owner": "dev-team",
        "environment": "prod"
    }
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[标记您的 API Gateway 资源](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-tagging.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetTags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-tags.html)*中的。

### `get-vpc-link`
<a name="apigatewayv2_GetVpcLink_cli_2_topic"></a>

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

**AWS CLI**  
**检索有关 VPC 链接的信息**  
以下 `get-vpc-link` 示例显示有关 VPC 链接的信息。  

```
aws apigatewayv2 get-vpc-link \
    --vpc-link-id abcd123
```
输出：  

```
{
    "CreatedDate": "2020-04-07T00:27:47Z",
    "Name": "MyVpcLink",
    "SecurityGroupIds": [
        "sg1234",
        "sg5678"
    ],
    "SubnetIds": [
        "subnet-aaaa",
        "subnet-bbbb"
    ],
    "Tags": {},
    "VpcLinkId": "abcd123",
    "VpcLinkStatus": "AVAILABLE",
    "VpcLinkStatusMessage": "VPC link is ready to route traffic",
    "VpcLinkVersion": "V2"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 的 VPC 链接](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetVpcLink](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-vpc-link.html)*中的。

### `get-vpc-links`
<a name="apigatewayv2_GetVpcLinks_cli_2_topic"></a>

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

**AWS CLI**  
**检索 VPC 链接列表**  
以下 `get-vpc-links` 示例显示当前用户所有 VPC 链接的列表。  

```
aws apigatewayv2 get-vpc-links
```
输出：  

```
{
    "Items": [
        {
            "CreatedDate": "2020-04-07T00:27:47Z",
            "Name": "MyVpcLink",
            "SecurityGroupIds": [
                "sg1234",
                "sg5678"
            ],
            "SubnetIds": [
                "subnet-aaaa",
                "subnet-bbbb"
            ],
            "Tags": {},
            "VpcLinkId": "abcd123",
            "VpcLinkStatus": "AVAILABLE",
            "VpcLinkStatusMessage": "VPC link is ready to route traffic",
            "VpcLinkVersion": "V2"
        }
        {
            "CreatedDate": "2020-04-07T00:27:47Z",
            "Name": "MyOtherVpcLink",
            "SecurityGroupIds": [
                "sg1234",
                "sg5678"
            ],
            "SubnetIds": [
                "subnet-aaaa",
                "subnet-bbbb"
            ],
            "Tags": {},
            "VpcLinkId": "abcd456",
            "VpcLinkStatus": "AVAILABLE",
            "VpcLinkStatusMessage": "VPC link is ready to route traffic",
            "VpcLinkVersion": "V2"
        }
    ]
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 的 VPC 链接](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[GetVpcLinks](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-vpc-links.html)*中的。

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

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

**AWS CLI**  
**导入 HTTP API**  
以下 `import-api` 示例从名为 `api-definition.yaml` 的 OpenAPI 3.0 定义文件创建 HTTP API。  

```
aws apigatewayv2 import-api \
    --body file://api-definition.yaml
```
`api-definition.yaml` 的内容：  

```
openapi: 3.0.1
info:
    title: My Lambda API
    version: v1.0
paths:
    /hello:
        x-amazon-apigateway-any-method:
            x-amazon-apigateway-integration:
                payloadFormatVersion: 2.0
                type: aws_proxy
                httpMethod: POST
                uri: arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:hello/invocations
                connectionType: INTERNET
```
输出：  

```
{
    "ApiEndpoint": "https://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
    "ApiId": "a1b2c3d4",
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "CreatedDate": "2020-04-08T17:19:38+00:00",
    "Name": "My Lambda API",
    "ProtocolType": "HTTP",
    "RouteSelectionExpression": "$request.method $request.path",
    "Tags": {},
    "Version": "v1.0"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs中的使用 HTTP 的 OpenAPI* [定义](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-open-api.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ImportApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/import-api.html)*中的。

### `list-routing-rules`
<a name="apigatewayv2_ListRoutingRules_cli_2_topic"></a>

以下代码示例演示了如何使用 `list-routing-rules`。

**AWS CLI**  
**列出路由规则**  
以下 `list-routing-rules` 示例列出域名的路由规则。  

```
aws apigatewayv2 list-routing-rules \
    --domain-name 'regional.example.com'
```
输出：  

```
{
    "RoutingRules": [
        {
            "Actions": [
                {
                    "InvokeApi": {
                        "ApiId": "abcd1234",
                        "Stage": "prod",
                        "StripBasePath": false
                    }
                }
            ],
            "Conditions": [
                {
                    "MatchBasePaths": {
                        "AnyOf": [
                            "PetStoreShopper"
                        ]
                    }
                }
            ],
            "Priority": 150,
            "RoutingRuleArn": "arn:aws:apigateway:us-east-1:123456789012:/domainnames/regional.example.com/routingrules/aaa111",
            "RoutingRuleId": "aaa111"
        }
    ]
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs中的将 API* [阶段连接到 REST 自定义域名的路由规则](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-routing-rules.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListRoutingRules](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/list-routing-rules.html)*中的。

### `put-routing-rule`
<a name="apigatewayv2_PutRoutingRule_cli_2_topic"></a>

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

**AWS CLI**  
**更新路由规则**  
以下 `put-routing-rule` 示例更新路由规则的优先级。  

```
aws apigatewayv2 put-routing-rule \
    --domain-name 'regional.example.com' \
    --priority 150 \
    --conditions '[ \
        { \
            "MatchBasePaths": { \
                "AnyOf": [ \
                    "PetStoreShopper" \
                ] \
            } \
        } \
    ]' \
    --actions '[ \
        { \
            "InvokeApi": { \
                "ApiId": "abcd1234", \
                "Stage": "prod" \
            } \
        } \
    ]'
```
输出：  

```
{
    "Actions": [
        {
            "InvokeApi": {
                "ApiId": "abcd1234",
                "Stage": "prod",
                "StripBasePath": false
            }
        }
    ],
    "Conditions": [
        {
            "MatchBasePaths": {
                "AnyOf": [
                    "PetStoreShopper"
                ]
            }
        }
    ],
    "Priority": 150,
    "RoutingRuleArn": "arn:aws:apigateway:us-east-2:123456789012:/domainnames/regional.example.com/routingrules/aaa111",
    "RoutingRuleId": "aaa111"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs中的将 API* [阶段连接到 REST 自定义域名的路由规则](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-routing-rules.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[PutRoutingRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/put-routing-rule.html)*中的。

### `reimport-api`
<a name="apigatewayv2_ReimportApi_cli_2_topic"></a>

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

**AWS CLI**  
**重新导入 HTTP API**  
以下 `reimport-api` 示例将现有 HTTP API 更新为使用 `api-definition.yaml` 中指定的 OpenAPI 3.0 定义。  

```
aws apigatewayv2 reimport-api \
    --body file://api-definition.yaml \
    --api-id a1b2c3d4
```
`api-definition.yaml` 的内容：  

```
openapi: 3.0.1
info:
    title: My Lambda API
    version: v1.0
paths:
    /hello:
        x-amazon-apigateway-any-method:
            x-amazon-apigateway-integration:
                payloadFormatVersion: 2.0
                type: aws_proxy
                httpMethod: POST
                uri: arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:12356789012:function:hello/invocations
                connectionType: INTERNET
```
输出：  

```
{
    "ApiEndpoint": "https://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
    "ApiId": "a1b2c3d4",
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "CreatedDate": "2020-04-08T17:19:38+00:00",
    "Name": "My Lambda API",
    "ProtocolType": "HTTP",
    "RouteSelectionExpression": "$request.method $request.path",
    "Tags": {},
    "Version": "v1.0"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs中的使用 HTTP 的 OpenAPI* [定义](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-open-api.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ReimportApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/reimport-api.html)*中的。

### `tag-resource`
<a name="apigatewayv2_TagResource_cli_2_topic"></a>

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

**AWS CLI**  
**标记资源**  
以下 `tag-resource` 示例向指定的 API 添加了键名称为 `Department` 和值为 `Accounting` 的标签。  

```
aws apigatewayv2 tag-resource \
    --resource-arn arn:aws:apigateway:us-west-2::/apis/a1b2c3d4 \
    --tags Department=Accounting
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[标记您的 API Gateway 资源](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-tagging.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/tag-resource.html)*中的。

### `untag-resource`
<a name="apigatewayv2_UntagResource_cli_2_topic"></a>

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

**AWS CLI**  
**从资源中删除标签**  
以下 `untag-resource` 示例从指定 API 中移除键名为 `Project` 和 `Owner` 的标签。  

```
aws apigatewayv2 untag-resource \
    --resource-arn arn:aws:apigateway:us-west-2::/apis/a1b2c3d4 \
    --tag-keys Project Owner
```
此命令不生成任何输出。  
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[标记您的 API Gateway 资源](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-tagging.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/untag-resource.html)*中的。

### `update-api-mapping`
<a name="apigatewayv2_UpdateApiMapping_cli_2_topic"></a>

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

**AWS CLI**  
**更新 API 映射**  
以下 `update-api-mapping` 示例更改自定义域名的 API 映射。这样，使用指定 API 和阶段的自定义域名的基础 URL 会变为 `https://api.example.com/dev`。  

```
aws apigatewayv2 update-api-mapping \
    --api-id a1b2c3d4 \
    --stage dev \
    --domain-name api.example.com \
    --api-mapping-id 0qzs2sy7bh \
    --api-mapping-key dev
```
输出：  

```
{
    "ApiId": "a1b2c3d4",
    "ApiMappingId": "0qzs2sy7bh",
    "ApiMappingKey": "dev"
    "Stage": "dev"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中设置区域自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateApiMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-api-mapping.html)*中的。

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

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

**AWS CLI**  
**为 HTTP API 启用 CORS**  
以下 `update-api` 示例更新指定 API 的 CORS 配置，以允许来自 `https://www.example.com` 的请求。  

```
aws apigatewayv2 update-api \
    --api-id a1b2c3d4 \
    --cors-configuration AllowOrigins=https://www.example.com
```
输出：  

```
{
    "ApiEndpoint": "https://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
    "ApiId": "a1b2c3d4",
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "CorsConfiguration": {
        "AllowCredentials": false,
        "AllowHeaders": [
            "header1",
            "header2"
        ],
        "AllowMethods": [
            "GET",
            "OPTIONS"
        ],
        "AllowOrigins": [
            "https://www.example.com"
        ]
    },
    "CreatedDate": "2020-04-08T18:39:37+00:00",
    "Name": "my-http-api",
    "ProtocolType": "HTTP",
    "RouteSelectionExpression": "$request.method $request.path",
    "Tags": {},
    "Version": "v1.0"
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[为 HTTP API 配置 CORS](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-api.html)*中的。

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

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

**AWS CLI**  
**更新授权方**  
以下 `update-authorizer` 示例将 JWT 授权方的身份源更改为名为 `Authorization` 的标头。  

```
aws apigatewayv2 update-authorizer \
    --api-id a1b2c3d4 \
    --authorizer-id a1b2c3 \
    --identity-source '$request.header.Authorization'
```
输出：  

```
{
    "AuthorizerId": "a1b2c3",
    "AuthorizerType": "JWT",
    "IdentitySource": [
        "$request.header.Authorization"
    ],
    "JwtConfiguration": {
        "Audience": [
            "123456abc"
        ],
        "Issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc123"
    },
    "Name": "my-jwt-authorizer"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发*者指南中的[ APIs 使用 JWT 授权者控制 HTTP 的访问权限](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-authorizer.html)*中的。

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

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

**AWS CLI**  
**更改部署的说明**  
以下 `update-deployment` 示例更新部署的说明。  

```
aws apigatewayv2 update-deployment \
    --api-id a1b2c3d4 \
    --deployment-id abcdef \
    --description 'Manual deployment to fix integration test failures.'
```
输出：  

```
{
    "AutoDeployed": false,
    "CreatedDate": "2020-02-05T16:21:48+00:00",
    "DeploymentId": "abcdef",
    "DeploymentStatus": "DEPLOYED",
    "Description": "Manual deployment to fix integration test failures."
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中开发 HTTP API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-deployment.html)*中的。

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

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

**AWS CLI**  
**更新自定义域名**  
以下 `update-domain-name` 示例为 `api.example.com` 自定义域名指定新的 ACM 证书。  

```
aws apigatewayv2 update-domain-name \
    --domain-name api.example.com \
    --domain-name-configurations CertificateArn=arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678
```
输出：  

```
{
    "ApiMappingSelectionExpression": "$request.basepath",
    "DomainName": "regional.example.com",
    "DomainNameConfigurations": [
        {
            "ApiGatewayDomainName": "d-id.execute-api.us-west-2.amazonaws.com",
            "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678",
            "EndpointType": "REGIONAL",
            "HostedZoneId": "123456789111",
            "SecurityPolicy": "TLS_1_2",
            "DomainNameStatus": "AVAILABLE"
        }
    ]
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[在 API Gateway 中设置区域自定义域名](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-domain-name.html)*中的。

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

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

**AWS CLI**  
**更新 Lambda 集成**  
以下`update-integration`示例将现有的 AWS Lambda 集成更新为使用指定的 Lambda 函数。  

```
aws apigatewayv2 update-integration \
    --api-id a1b2c3d4 \
    --integration-id a1b2c3 \
    --integration-uri arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:my-new-function/invocations
```
输出：  

```
{
    "ConnectionType": "INTERNET",
    "IntegrationId": "a1b2c3",
    "IntegrationMethod": "POST",
    "IntegrationType": "AWS_PROXY",
    "IntegrationUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:my-new-function/invocations",
    "PayloadFormatVersion": "2.0",
    "TimeoutInMillis": 5000
}
```
有关更多信息，请参阅 *Amazon API [Gateway 开发者指南中的配置 HTTP](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html) [集成 APIs和设置 WebSocket AP](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integrations.html) I* 集成。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-integration.html)*中的。

### `update-route`
<a name="apigatewayv2_UpdateRoute_cli_2_topic"></a>

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

**AWS CLI**  
**示例 1：更新路由的集成**  
以下 `update-route` 示例更新指定路由的集成。  

```
aws apigatewayv2 update-route \
    --api-id a1b2c3d4 \
    --route-id a1b2c3 \
    --target integrations/a1b2c6
```
输出：  

```
{
    "ApiKeyRequired": false,
    "AuthorizationType": "NONE",
    "RouteId": "a1b2c3",
    "RouteKey": "ANY /pets",
    "Target": "integrations/a1b2c6"
}
```
**示例 2：向路由添加授权方**  
以下 `update-route` 示例将指定路由更新为使用 JWT 授权方。  

```
aws apigatewayv2 update-route \
    --api-id a1b2c3d4  \
    --route-id a1b2c3  \
    --authorization-type JWT \
    --authorizer-id a1b2c5 \
    --authorization-scopes user.id user.email
```
输出：  

```
{
    "ApiKeyRequired": false,
    "AuthorizationScopes": [
        "user.id",
        "user.email"
    ],
    "AuthorizationType": "JWT",
    "AuthorizerId": "a1b2c5",
    "OperationName": "GET HTTP",
    "RequestParameters": {},
    "RouteId": "a1b2c3",
    "RouteKey": "GET /pets",
    "Target": "integrations/a1b2c6"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发*者指南中的[ APIs 使用 JWT 授权者控制 HTTP 的访问权限](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-route.html)*中的。

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

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

**AWS CLI**  
**配置自定义节流**  
以下 `update-stage` 示例为 API 的指定阶段和路由配置自定义节流。  

```
aws apigatewayv2 update-stage \
    --api-id a1b2c3d4 \
    --stage-name dev \
    --route-settings '{"GET /pets":{"ThrottlingBurstLimit":100,"ThrottlingRateLimit":2000}}'
```
输出：  

```
{
    "CreatedDate": "2020-04-05T16:21:16+00:00",
    "DefaultRouteSettings": {
        "DetailedMetricsEnabled": false
    },
    "DeploymentId": "shktxb",
    "LastUpdatedDate": "2020-04-08T22:23:17+00:00",
    "RouteSettings": {
        "GET /pets": {
            "ThrottlingBurstLimit": 100,
            "ThrottlingRateLimit": 2000.0
        }
    },
    "StageName": "dev",
    "StageVariables": {},
    "Tags": {}
}
```
有关更多信息，请参阅《Amazon API Gateway 开发人员指南》**中的[保护 HTTP API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-protect.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-stage.html)*中的。

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

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

**AWS CLI**  
**更新 VPC 链接**  
以下 `update-vpc-link` 示例更新 VPC 链接的名称。创建 VPC 链接后，您无法更改其安全组或子网。  

```
aws apigatewayv2 update-vpc-link \
    --vpc-link-id abcd123 \
    --name MyUpdatedVpcLink
```
输出：  

```
{
    "CreatedDate": "2020-04-07T00:27:47Z",
    "Name": "MyUpdatedVpcLink",
    "SecurityGroupIds": [
        "sg1234",
        "sg5678"
    ],
    "SubnetIds": [
        "subnet-aaaa",
        "subnet-bbbb"
    ],
    "Tags": {},
    "VpcLinkId": "abcd123",
    "VpcLinkStatus": "AVAILABLE",
    "VpcLinkStatusMessage": "VPC link is ready to route traffic",
    "VpcLinkVersion": "V2"
}
```
有关更多信息，请参阅 *Amazon API Gateway 开发者指南 APIs*中的使用 [HTTP 的 VPC 链接](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[UpdateVpcLink](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-vpc-link.html)*中的。