The registry tool allows you to import and export information from API hub in yaml format. A quick start guide for using the registry tool can be found here.
To export an API from the registry use:
registry export yaml apis/openapi-sample > openapi-sample.yaml
This will generate a yaml file, which has sections for specifying API Versions / Specs / Deployments/ Artifacts. This file can be maintained in source control and updates can be automatically deployed using registry tool or the Apigee Registry Maven Plugin.
Below is a sample cloudbuild.yaml for deploying API information to API hub. More detailed instructions are available on GitHub repository
steps:
- id: "Authenticate to gcloud"
name: gcr.io/cloud-builders/gcloud
entrypoint: /bin/bash
args:
- -c
- |
gcloud auth application-default print-access-token > /workspace/creds
- id: "Apply API details to API Hub instance"
name: 'ghcr.io/apigee/registry-tools:latest'
entrypoint: /bin/bash
args:
- -c
- |
registry apply -f demoapi.yaml \
--parent=projects/$PROJECT_ID/locations/global \
--registry.address=apigeeregistry.googleapis.com:443 \
--registry.token=$(cat /workspace/creds)
serviceAccount: 'projects/$PROJECT_ID/serviceAccounts/${_SERVICE_ACCOUNT}'
options:
logging: CLOUD_LOGGING_ONLY
Please refer to the article published by @ssvaidyanathan about the maven plugin. Samples for maven deployment are available on GitHub repository .