2016-03-06 88 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