apigee / apigeecli

This is a tool to interact with Apigee APIs. The tool lets you manage (create, del, get, list) environments, proxies, etc.
Apache License 2.0
51 stars 28 forks source link

apihub apis versions specs update - incorrectly builds updateMask #498

Closed kurtkanaskie closed 1 month ago

kurtkanaskie commented 1 month ago

The following fails

gorun --org=$ORG --region=us-central1 apihub apis versions specs update \
    --api-id=apigeecli-api-v1 \
    --id=spec-v1_0_0_0 \
    --version=v1_0_0_0 \
    --display-name=apigeecli-api-v1-spec-v1_0_0_0 \
    --file=apihub/foodtrucks.yaml
{
  "error": {
    "code": 400,
    "message": "source_uri cannot be updated if spec contains contents",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SPEC_INVALID_ARGUMENT",
        "domain": "apihub.googleapis.com"
      }
    ]
  }
}

Couple issues: spec_type cannot be specified in updateMask documentation is not supported in updateMask contents and source_uri are mutually exclusive. See docs for details: https://cloud.google.com/apigee/docs/reference/apis/apihub/rest/v1/projects.locations.apis.versions.specs/patch

In hub.go

q.Set("updateMask", "display_name,source_uri,documentation,contents,spec_type")

should be built dynamically based on the input command.