This page applies to Apigee and Apigee hybrid.
This page describes how to create and manage API operations in API hub. To learn more about operations, see Introduction to API operations.
Add an operation to an API version
You can add an API operation to an existing API version in the console or with the REST API.
Console
To add a new API operation to an API version, do the following:
In the Google Cloud console, go to the API hub page.
Go to API hub- Click APIs.
- Locate the API you wish to add an operation to. Use Filter to specify keywords to filter the list of APIs. If needed, use Search to locate an API.
- Click the API to view its details.
- Click the Versions tab and select the version you wish to add from the Select a version drop-down list.
- Go to the Operations section, click Add operation.
- Specify operation details in the Add operation form.
- Operation ID: Click Specify Unique ID to optionally provide a unique ID for the operation. If you omit the ID, API hub creates one for you.
- Documentation: Enter the URL to documentation for the API operation.
- Description: Add a description of the operation.
- Operation type: This field is automatically set as
HTTP
. - Deprecated: Select if the operation is deprecated.
- Path: Enter the path of the operation.
- Path description: Enter the description of the path of the operation.
- Method: Enter the method of the operation.
- Additional attributes: Add user-defined attributes based on your organizational or team needs. See User attributes.
- Click Create.
REST
To add a new API operation using the Create operations API, use the following command:
curl --location --request POST 'https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/apis/API_ID/versions/VERSION_ID/operations?api_operation_id=OPERATION_ID' \ --header 'Authorization: Bearer $(gcloud auth print-access-token)' \ --header 'Content-Type: application/json' \ --data '{ "details":{ "description":"DESCRIPTION", "deprecated":false, "documentation":{ "external_uri":"EXTERNAL_URI" }, "http_operation":{ "method":"METHOD", "path":{ "path":"PATH", "description":"DESCRIPTION" } } } }'
Replace the following:
- HUB_PROJECT: The project ID of the API hub project.
- HUB_LOCATION: The location of the API hub project.
- API_ID: The ID of the API.
- VERSION_ID: The ID of the API version.
- OPERATION_ID: The ID of the API operation.
- DESCRIPTION: The description of the API operation.
- EXTERNAL_URI: The external URI of the API operation.
- METHOD: The method of the API operation.
- PATH: The path of the API operation.
Example:
curl --location --request POST 'https://apihub.googleapis.com/v1/projects/test-project/locations/us-central1/apis/test-api/versions/version-id/operations?api_operation_id=test-operation' \ --header 'Authorization: Bearer $(gcloud auth print-access-token)' \ --header 'Content-Type: application/json' \ --data '{ "details":{ "description":"api to create root level entity api in apihub", "deprecated":false, "documentation":{ "external_uri":"https://google.com" }, "http_operation":{ "method":"POST", "path":{ "path":"/apis", "description":"It is ccfe managed resource" } } } }'
Edit an API operation
You can edit an API operation of an API version in the console or with the REST API.
Console
To edit an API operation, do the following:
In the Google Cloud console, go to the API hub page.
Go to API hub- Click APIs.
- Locate the API with the version that contains the operation you wish to edit. Use Filter to specify keywords to filter the list of APIs. If needed, use Search to locate an API.
- Click the API to view its details.
- Click the Versions tab and select the version that contains the operation you wish to edit.
- Go to the Operations section and locate the operation you wish to edit.
- Select Edit from the Actions menu in the row of the operation you wish to edit.
- In the Edit operation form, make the required changes to the operation details.
- Click Save.
REST
To edit or update an API operation using the Patch operations API, use the following command:
curl --location --request PATCH 'https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/apis/API_ID/versions/VERSION_ID/operations/OPERATION_ID?update_mask=UPDATE_MASK' \ --header 'Authorization: Bearer $(gcloud auth print-access-token)' \ --data '{ "details":{ "description":"DESCRIPTION", "deprecated":false, "documentation":{ "external_uri":"EXTERNAL_URI" }, "http_operation":{ "method":"METHOD", "path":{ "path":"PATH", "description":"DESCRIPTION" } } } }'
Replace the following:
- HUB_PROJECT: The project ID of the API hub project.
- HUB_LOCATION: The location of the API hub project.
- API_ID: The ID of the API.
- VERSION_ID: The ID of the API version.
- OPERATION_ID: The ID of the API operation.
- UPDATE_MASK: The update mask of the API operation.
- DESCRIPTION: The description of the API operation.
- EXTERNAL_URI: The external URI of the API operation.
- PATH: The path of the API operation.
Example:
curl --location --request PATCH 'https://apihub.googleapis.com/v1/projects/test-project/locations/us-central1/apis/test-api/versions/version-id/operations/test-operation?update_mask=details.http_operation.path' \ --header 'Authorization: Bearer $(gcloud auth print-access-token)' \ --data '{ "details":{ "description":"api to create root level entity api in apihub update", "deprecated":false, "documentation":{ "external_uri":"https://google.com" }, "http_operation":{ "method":"POST", "path":{ "path":"/apiss", "description":"It is ccfe managed api" } } } }'
Delete an API operation
You can delete an API operation in the console or with the REST API.
Console
To delete an API operation, do the following:
In the Google Cloud console, go to the API hub page.
Go to API hub- Click APIs.
- Locate the API with the version that contains the operation you wish to delete. Use Filter to specify keywords to filter the list of APIs. If needed, use Search to locate an API.
- Click the API to view its details.
- Click the Versions tab and select the version that contains the operation you wish to delete.
- Go to the Operations section and locate the operation you wish to delete.
- Select Delete from the Actions menu in the row of the operation you wish to delete.
- Click Delete in the confirmation dialog.
REST
To delete an API operation using the Delete operations API, use the following command:
curl --location --request DELETE 'https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/apis/API_ID/versions/VERSION_ID/operations/OPERATION_ID' \ --header 'Authorization: Bearer $(gcloud auth print-access-token)'
Replace the following:
- HUB_PROJECT: The project ID of the API hub project.
- HUB_LOCATION: The location of the API hub project.
- API_ID: The ID of the API.
- VERSION_ID: The ID of the API version.
- OPERATION_ID: The ID of the API operation.
Example:
curl --location --request DELETE 'https://apihub.googleapis.com/v1/projects/test-project/locations/us-central1/apis/test-api/versions/version-id/operations/test-operation' \ --header 'Authorization: Bearer $(gcloud auth print-access-token)'
List API operations
You can list or view the API operations of an API version using the API hub console UI or using the List operations API.
Console
To view the API operations of an API version, do the following:
In the Google Cloud console, go to the API hub page.
Go to API hub- Click APIs.
- Locate the API you wish to inspect. Use Filter to specify keywords to filter the list of APIs. If needed, use Search to locate an API.
- Select an API.
- Go to the Versions tables in the API details page.
- Select an API version.
- The API operations for the selected API version are listed in the Operations table on the page.
REST
To list the API operations of an API version, use the following command:
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -X GET https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/apis/API_ID/versions/VERSION_ID/operations
Replace the following:
- HUB_PROJECT: The project ID of the API hub project.
- HUB_LOCATION: The location of the API hub project.
- API_ID: The ID of the API.
- VERSION_ID: The ID of the API version.
Example:
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -X GET https://apihub.googleapis.com/v1/projects/test-project/locations/us-central1/apis/test-api/versions/version-id/operations
Get API operation
You can get the details of an API operation using the Get operations API. These details include the name, specification, description, create time, update time, and user-defined attributes.
REST
To get the details of an API operation, use the following command:
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -X GET https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/apis/API_ID/versions/VERSION_ID/operations/OPERATION_ID
Replace the following:
- HUB_PROJECT: The project ID of the API hub project.
- HUB_LOCATION: The location of the API hub project.
- API_ID: The ID of the API.
- VERSION_ID: The ID of the API version.
- OPERATION_ID: The ID of the API operation.
Example:
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -X GET https://apihub.googleapis.com/v1/projects/test-project/locations/us-central1/apis/test-api/versions/version-id/operations/test-operation
Considerations
- For API versions with a valid OpenAPI specification and parsed operations, the Operations API can't be used to add, modify, or delete operations.
- When a valid OpenAPI specification is added to an API version containing existing operations, the operations defined in the specification will take precedence and replace the current ones.
What's next
- See the API reference documentation for the Operations API.
- Learn more about API specifications.
- Learn more about API operations.