This page applies to Apigee and Apigee hybrid.
This document describes how to create and manage dependencies between registered APIs. Dependencies help you see the relationships between APIs. See Introduction to dependencies.
Create a dependency
You can create a dependency entity with the REST API.
REST
To create a new dependency using the Create a dependency API:
curl -X POST 'https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/dependencies?dependency_id=DEPENDENCY_ID' \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H 'Content-Type: application/json' \ --d '{ "description": "DESCRIPTION", "supplier": { // Specify one of the following: "operation_resource_name": RESOURCE_NAME // OR "external_resource_name: RESOURCE_NAME" }, "consumer": { // Specify one of the following: "operation_resource_name": RESOURCE_NAME // OR "external_resource_name: RESOURCE_NAME" } }'
Replace the following:
- HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
- HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.
- DEPENDENCY_ID: (Optional) The identifier of the dependency. If not provided, a system-generated
ID will be used. The name must be a string of 4-500 characters, where valid characters are
/[a-z][A-Z][0-9]-_.
- DESCRIPTION: (Optional) A brief description of the dependency.
RESOURCE_NAME: (Required) Either the resource name of an operation in API hub or an external API, depending on which attribute you specify.
Operation resource names follow this format:
projects/PROJECT/locations/LOCATION/apis/API/versions/VERSION/operations/OPERATION
Operation resource example:
"projects/myproject/locations/us-central1/apis/payments-api/versions/locationv1/operations/getlocation"
.External API resource names follow this format:
projects/PROJECT/locations/LOCATION/externalApis/EXTERNAL_API
External API resource example:
"projects/myproject/locations/us-central1/externalApis/petstore"
.
Sample response:
{ "name": "projects/myproject/locations/us-central1/dependencies/user-to-pet", "consumer": { "displayName": "POST - /v2/user", "operationResourceName": "projects/myproject/locations/us-central1/apis/payments-api/versions/version1/operations/createuser" }, "supplier": { "displayName": "POST - /v2/pet", "operationResourceName": "projects/myproject/locations/us-central1/apis/payments-api/versions/version1/operations/addpet" }, "state": "VALIDATED", "description": "Dependency from user to pet API", "discoveryMode": "MANUAL", "createTime": "2024-04-17T19:33:31.664226Z", "updateTime": "2024-04-17T19:33:31.664226Z" }
Example REST
curl -X POST 'https://apihub.googleapis.com/v1/projects/myproject/locations/us-central1/dependencies?dependency_id=user-to-pet' \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H 'Content-Type: application/json' \ --d '{ "description": "Dependency from user to pet API", "consumer": { "operation_resource_name": "projects/myproject/locations/us-central1/apis/payments-api/versions/paymentv1/operations/createuser" }, "supplier": { "operation_resource_name": "projects/myproject/locations/us-central1/apis/pet-api/versions/petstorev1/operations/addpet" } }'
List dependencies
This section explains how to list the dependencies. You can list all dependencies associated with all the versions for an API, or list all dependencies associated with a specific version.
REST
To list all dependencies, use the List dependencies API:
curl "https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/dependencies" -H "Authorization: Bearer: $(gcloud auth print-access-token)" -X GET -H "Content-Type: application/json"
Replace the following:
- HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
- HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.
Sample output:
{ "dependencies": [ { "name": "projects/myproject/locations/us-central1/dependencies/user-to-pet", "consumer": { "displayName": "POST - /v2/user", "operationResourceName": "projects/myproject/locations/us-central1/apis/payments-api/versions/version1/operations/createuser" }, "supplier": { "displayName": "POST - /v2/pet", "operationResourceName": "projects/myproject/locations/us-central1/apis/payments-api/versions/version1/operations/addpet" } } ] }
Get dependency details
This section explains how to get the details about an API dependency with the REST API.
REST
To view details of a dependency, use the Get dependency details API:
curl "https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/dependencies/DEPENDENCY_ID" -H "Authorization: Bearer: $(gcloud auth print-access-token)" -X GET -H "Content-Type: application/json"
Replace the following:
- HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
- HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.
- DEPENDENCY_ID: The unique ID of the dependency.
Sample response:
{ "name": "projects/myproject/locations/us-central1/dependencies/user-to-pet", "consumer": { "displayName": "POST - /v2/user", "operationResourceName": "projects/myproject/locations/us-central1/apis/payments-api/versions/version1/operations/createuser" }, "supplier": { "displayName": "POST - /v2/pet", "operationResourceName": "projects/myproject/locations/us-central1/apis/payments-api/versions/version1/operations/addpet" }, "state": "VALIDATED", "description": "Dependency from user to pet API", "discoveryMode": "MANUAL", "createTime": "2024-04-17T19:33:31.215978712Z", "updateTime": "2024-04-17T19:33:31.737505297Z" }
Delete an API dependency
This section explains how to delete an API dependency.
REST
To delete a dependency from API hub, use the Delete dependency API:
curl "https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/dependencies/DEPENDENCY_ID" -H "Authorization: Bearer: $(gcloud auth print-access-token)" -X DELETE -H "Content-Type: application/json"
Replace the following:
- HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
- HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.
- DEPENDENCY_ID: The ID of the dependency to delete.
Edit a dependency
This section explains how to edit a dependency. The only editable attribute is the description.
REST
To edit a deployment, use the Patch dependencies API:
curl "https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/dependencies/DEPENDENCY_ID" -H "Authorization: Bearer: $(gcloud auth print-access-token)" -X PATCH -H "Content-Type: application/json" '{ 'description': DESCRIPTION {'
Replace the following:
- HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
- HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.
- DEPLOYMENT_ID: The ID of the deployment to edit.
- DESCRIPTION: The only editable attribute is the description.