Closed srinandan closed 2 months ago
gorun --org=$ORG --region=us-central1 apihub apis update --id=apigeecli-api-v1 --file=apigeecli-api-v1.json Command was incorrectly documented in update.go should be:
var UpdateCmd = &cobra.Command{
Use: "update",
Short: "Update an existing API Hub API",
Long: "Update an existing API Hub API",
...
_, err = hub.UpdateApi(id, apiFileBytes)
Update requires displayName and owner.
Update does not update apiStyle
{
"name": "apigeecli-api",
"displayName": "apigeecli-api-updated",
"description": "API create via apigeecli updated",
"apiStyle": {
"enumValues": {
"values": [
{
"id": "rest"
}
]
}
},
"owner": {
"email": "kurtkanaskie.google.com"
}
}
create and update use --id get, delete use --app-id they should be consistent
Help for apihub apis versions create shows: -f, --file string Path to a file containing the API defintion
Should be Path to a file containing the API version definition
Got past apis, versions and looking at specs. All looks good so far, but the get returns base64 value, should we decode or maybe an option to save decoded to a file?
gorun --org=$ORG --region=us-central1 apihub apis versions specs get --api-id=apigeecli-api-v1 --version=v1_0 --spec-id=apigeecli-api-v1-spec-id --contents { "contents": "b3BlbmFwaTogMy4wLjAKaW5mbzoKICB0aXRsZTogRm9vZCBUcnVja3MgQVBJCiAgZGVzY3JpcHR
Incorrect help for create and delete
gorun --org=$ORG --region=us-central1 apihub dependencies
Manage dependencies between consumers and suppliers
Usage:
apigeecli apihub dependencies [command]
Available Commands:
create Create a new API Deployment in API Hub
delete Delete a deployment
get Get details for a dependency
list List dependencies
Deployments should have a required parameter for version(s) since it is required in the UI.
apihub deployments create --help
Create a new API Deployment in API Hub
Usage:
apigeecli apihub deployments create [flags]
Flags:
--dep-type deploymentType The type of deployment
--description string Deployment Description
-d, --display-name string Deployment Display Name
--endpoints stringArray The endpoints at which this deployment resource is listening for API requests
--env-type environmentType The environment mapping to this deployment
--external-uri string The uri of the externally hosted documentation
-h, --help help for create
-i, --id string Deployment ID
--resource-uri string A URI to the runtime resource
--slo-type sloType The SLO for this deployment
I think then we need to add --api-id and --version-id to create the apiVersion identifier: projects/apigeex-mint-kurt/locations/us-central1/apis/apigeecli-api-v1/versions/v1_0
The UI may be forcing the user to select an API Version, however, the API does not. Deployments are set on the API Version and the other way around.
I think the UI is orchestrating two API calls. 1) Create a deployment 2) Update the API Version with the Deployment that was created.
Here is a command to create a deployment:
apigeecli apihub deployments create -n $name --dep-type apigee -d $display-name --env-type development --slo-type "99-99" --endpoints https://api.example.com --resource-uri https://apigee.googleapis.com/v1/organizations/my-project/apis/httpbin/revisions/1 -r us-central1 --default-token
For automation, I would use
deployment-name=$(apigeecli apihub deployments create -n $name --dep-type apigee -d $display-name --env-type development --slo-type "99-99" --endpoints https://api.example.com --resource-uri https://apigee.googleapis.com/v1/organizations/my-project/apis/httpbin/revisions/1 -r us-central1 --default-token | yq -r .name )
and use that variable in subsequent commands.
Hmmm, yes, when I use the API to create a deployment and I give it a version, it doesn't use it. So versions have deployments and I can create a version with a deployment. OK then how do I "update" a version to have a deployment? I can PATCH with API. update command is missing from versions.
I see deployments update was added. Missing "UpdateCmd" in deployments.go
Added that and tested, update command uses --name it should use --id like get and delete does.
Pushed changes for deployments update and externalapis Only thing left is adding the missing versions update.
This works for apihub apis versions create --id=v1_0_0_0 --api-id=apigeecli-api-v1 --file=apihub/apigee-cli-v1-version.json
{
"displayName": "Version 1",
"description": "Version One Zero via CLI updated with deployments",
"deployments": [
"projects/apigeex-mint-kurt/locations/us-central1/deployments/apigeecli-api-v1-deployment-dev-cli"
]
}
Update uses --id, but get and delete use --version, should be --id for all Update fails
apihub apis versions update --id=v1_0_0_0 --api-id=apigeecli-api-v1 --file=apihub/apigee-cli-v1-version-deployments.json
Error: json: cannot unmarshal array into Go struct field apiversion.deployments of type map[string]interface {}
exit status 1
Creating attribute with immutable fails, if removed works.
File for enums