2016-03-06 86 views
1

当使用AWS Api-Gateway服务时,我想添加一个“父”资源而不删除和重建资源结构。具体来说,我想改变这种:如何在AWS API网关中创建父资源?

resource/name 
resource/name 

而且没有删除和改造两个“资源/名称”资源添加一个“父”资源给它(V1),像这样:

/v1 
    /resource/name 
    /resource/name 

如果需要使用CLI,示例命令将是什么样子?

更新:

谢谢你的伟大答案卡厚怡。这里是实现它的一些注意事项:

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. 
+0

看起来它可以使用CLI是可能的: http://docs.aws.amazon.com/cli/latest/reference/apigateway/create-resource.html – user3303554

+0

原来 - 使用基本参数 - “create-resource”创建一个新的子资源,但不会使新的父母资源CES。 – user3303554

回答

1

您可以创建路径部分“/ 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/

+0

很好,谢谢! – user3303554