如何在AWS API Gateway中创建父资源?

3
当使用AWS Api-Gateway服务时,我想添加一个“父级”资源,而不需要删除和重建资源结构。具体来说,我想更改以下内容:
resource/name
resource/name

同时添加一个“父”资源(v1),而无需删除和重新创建两个“resource/name”资源,像这样:

/v1
  /resource/name
  /resource/name

如果需要使用CLI,一个示例命令看起来会是什么样子?
更新:
感谢Ka Hou Ieong的出色回答。以下是实现它的一些说明:
rest-api-id : Put the api id here. You can look it up with this command: aws apigateway get-rest-apis

resource-id : Put the id of the resource you'd like to move here. You can look it up with this command: aws apigateway get-resources --rest-api-id API-ID-HERE

replace : Leave this; it's the operation.

/parentId : Leave this. It refers to the "key" of the value that you'll replace.

<new parent resourceId> : Replace this with the ID of the parent you'd like.

看起来可以使用CLI实现:http://docs.aws.amazon.com/cli/latest/reference/apigateway/create-resource.html - user3303554
1
原来,在使用基本参数时,“create-resource”会创建一个新的子资源,但不会创建新的父资源。 - user3303554
1个回答

3
您可以创建一个路径部分为“/v1”的资源,然后使用CLI工具或SDK重新定位这些资源。
重新命名资源的示例CLI命令:
aws apigateway  update-resource \
    --rest-api-id rest-api-id \
    --resource-id resource-id \
    --cli-input-json "{\"patchOperations\" : [ 
          {
            \"op\" : \"replace\",
            \"path\" : \"/parentId\",
            \"value\" : \"<new parent resourceId>\"
          } 
    ]}"

以下是CLI工具文档:http://docs.aws.amazon.com/cli/latest/reference/apigateway/update-resource.html

以下是API参考文档:http://docs.aws.amazon.com/apigateway/api-reference/link-relation/resource-update/


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接