openwhisk-apigateway icon indicating copy to clipboard operation
openwhisk-apigateway copied to clipboard

When updating an existing API, a null resource is added

Open mdeuser opened this issue 8 years ago • 0 comments

  1. Create an initial api under an existing tenant. POST /apis
  "name": "/mwd_api2_bp",
  "basePath": "/mwd_api2_bp",
  "tenantId": "YOUR TENANT ID",
  "resources": {
    "/rp": {
      "operations": {
        "get": {
          "backendMethod": "POST",
          "backendUrl": "https://172.17.0.1/api/v1/namespaces/whisk.system/actions/newaction",
          "policies": [
            {
              "type": "reqMapping",
              "value": [
                {
                  "action": "transform",
                  "from": {
                    "name": "*",
                    "location": "query"
                  },
                  "to": {
                    "name": "*",
                    "location": "body"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "Basic AUTHCODE"
                  },
                  "to": {
                    "name": "Authorization",
                    "location": "header"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "application/json"
                  },
                  "to": {
                    "name": "Content-Type",
                    "location": "header"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "true"
                  },
                  "to": {
                    "name": "blocking",
                    "location": "query"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "true"
                  },
                  "to": {
                    "name": "result",
                    "location": "query"
                  }
                }
              ]
            }
          ]
        }
      }
    }
  }
}
  1. Note the API id.
  2. Add a new path or operation. in this case i just added a new operation. PUT /apis/{apiid}
{
  "id": "YOUR APP ID",
  "name": "/mwd_api2_bp",
  "basePath": "/mwd_api2_bp",
  "tenantId": "YOUR TENANT ID",
  "resources": {
    "/rp": {
      "operations": {
        "get": {
          "backendMethod": "POST",
          "backendUrl": "https://172.17.0.1/api/v1/namespaces/whisk.system/actions/newaction",
          "policies": [
            {
              "type": "reqMapping",
              "value": [
                {
                  "action": "transform",
                  "from": {
                    "name": "*",
                    "location": "query"
                  },
                  "to": {
                    "name": "*",
                    "location": "body"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "Basic AUTHCODE"
                  },
                  "to": {
                    "name": "Authorization",
                    "location": "header"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "application/json"
                  },
                  "to": {
                    "name": "Content-Type",
                    "location": "header"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "true"
                  },
                  "to": {
                    "name": "blocking",
                    "location": "query"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "true"
                  },
                  "to": {
                    "name": "result",
                    "location": "query"
                  }
                }
              ]
            }
          ]
        },
        "delete": {
          "backendMethod": "POST",
          "backendUrl": "https://172.17.0.1/api/v1/namespaces/whisk.system/actions/newaction",
          "policies": [
            {
              "type": "reqMapping",
              "value": [
                {
                  "action": "transform",
                  "from": {
                    "name": "*",
                    "location": "query"
                  },
                  "to": {
                    "name": "*",
                    "location": "body"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "Basic AUTHCODE"
                  },
                  "to": {
                    "name": "Authorization",
                    "location": "header"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "application/json"
                  },
                  "to": {
                    "name": "Content-Type",
                    "location": "header"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "true"
                  },
                  "to": {
                    "name": "blocking",
                    "location": "query"
                  }
                },
                {
                  "action": "insert",
                  "from": {
                    "value": "true"
                  },
                  "to": {
                    "name": "result",
                    "location": "query"
                  }
                }
              ]
            }
          ]
        }
      }
    }
  }
}
  1. Note the response from the gw looks fine
  2. Issue GET /apis/{apiid}. Look for "path":null
  "tenantId": "YOUR TENANT ID",
  "resources": {
    "path": null,
    "/rp": {
      "operations": {

mdeuser avatar Jan 13 '17 18:01 mdeuser