在AWS API网关中移动资源

jam*_*rta 3 amazon-web-services aws-cli aws-api-gateway

我想将一些资源移到上面一层,例如:

\v1\test1 -> \test1
\v2\test2 -> \test2
Run Code Online (Sandbox Code Playgroud)

这里的文档说它是可能的.但是当我运行以下命令时:

aws apigateway  update-resource \
--rest-api-id xvxi2smff9 \
--resource-id 2r0epq \
--cli-input-json "{\"patchOperations\" : [ 
      {
        \"op\" : \"move\",
        \"path\" : \"eysorw\",
        \"value\" : \"2r0epq\",
        \"from\" : \"xvxi2smff9\"
      } 
]}"
Run Code Online (Sandbox Code Playgroud)

我得到的错误是它是一个无效的补丁操作.

A client error (BadRequestException) occurred when calling the UpdateResource operation: Invalid patch operation specified. Must be 'add'|'remove'|'replace'
Run Code Online (Sandbox Code Playgroud)

Lor*_*ara 8

您可以通过使用新父级的resourceId replace/parentId路径发出补丁操作来"重新显示"资源:

aws apigateway update-resource \
   --rest-api-id xvxi2smff9 \
   --resource-id 2r0epq \
   --patch-operations op=replace,path=/parentId,value=eysorw
Run Code Online (Sandbox Code Playgroud)

[编辑以使用补丁操作替换patchOperations - 评论以满足6个字符的最小编辑]