Manage dependencies

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": {
          "operation_resource_name": SUPPLIER_OPERATION
      },
      "consumer": {
          "operation_resource_name": CONSUMER_OPERATION
      }
  }'

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.
  • SUPPLIER_OPERATION: (Required) The fully-qualified name of the supplier operation. For example: "projects/myproject/locations/us-central1/apis/payments-api/versions/locationv1/operations/getlocation".
  • CONSUMER_OPERATION: (Required) The fully-qualified name of the consumer operation. This operation depends on (calls) the supplier operation. For example: "projects/myproject/locations/us-central1/apis/payments-api/versions/locationv1/operations/createuser".

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.