Manage deployments using the API (Alpha)

The following sections step through a sample scenario that demonstrates how you can manage the deployment of an API proxy using the API. For a complete list of the Apigee APIs supported, see the Apigee API reference.

Deploy an API proxy using the API

API proxies cannot be invoked until they have been deployed. Only one revision of an API proxy can be deployed in an environment at a given time. Therefore the deployed revision will be undeployed. You can control whether the new bundle is deployed as a new revision or whether it overwrites the existing revision.

Deploy an API proxy to a specific environment in your Apigee organization by issuing a POST request to the following resource:

https://apigee.googleapis.com/v1/organizations/{organizationId}/environments/{env_id}/apis/{apiProxyId}/revisions/{revision_id}/deployments

Where:

  • {organizationId} is the name of your Apigee organization.
  • {env_id} is the environment name.
  • {apiProxyId} is the name of your API proxy.
  • {revision_id} is the revision number. The revision must exist.

The following example demonstrates how to deploy revision 1 of the helloworld API proxy to the test environment. (To create an API proxy, see Create an API proxy using the API.)

curl "https://apigee.googleapis.com/v1/organizations/myorg/environments/test/apis/helloworld/revisions/1/deployments" \
-X POST \
-H "Content-type:application/x-www-form-urlencoded" \
-H "Authorization: Bearer $TOKEN"

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token. For information about the curl options used in this example, see Use curl.

The following shows an example of the response output:

{
  "environment": "test",
  "apiProxy": "helloworld",
  "revision": "1",
  "deployStartTime": "1559149080457",
  "basePath": "/"
}

For more information, see the Method: organizations.environments.apis.revisions.deployments.deploy in the Apigee API reference.

View all deployments in your Apigee organization using the API

View all deployments of API proxies and shared flows in your Apigee organization by issuing a GET request to the following resource:

https://apigee.googleapis.com/v1/organizations/{org_id}/deployments

Where {org_id} is the name of your Apigee organization.

The following example shows how to view all API proxy and shared flow deployments for myorg organization.

curl "https://apigee.googleapis.com/v1/organizations/myorg/deployments" \
-X GET \
-H "Authorization: Bearer $TOKEN"

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token. For information about the curl options used in this example, see Use curl.

The following provides an example of the response. In this example, there are three API proxies deployed, including helloworld which was deployed in the previous section.

{
  "deployments": [
    {
      "environment": "test",
      "apiProxy": "helloworld",
      "revision": "1",
      "deployStartTime": "1559149080457",
      "basePath": "/"
    },
    {
      "environment": "test",
      "apiProxy": "weather",
      "revision": "1",
      "deployStartTime": "1558620435217",
      "basePath": "/"
    },
    {
      "environment": "test",
      "apiProxy": "testproxy",
      "revision": "2",
      "deployStartTime": "1558635113086",
      "basePath": "/"
    }
  ]
}

For more information, see the Method: organizations.deployments.list in the Apigee API reference.

View the deployments of an API proxy using the API

View the deployments of an API proxy using the API, as described in the following sections.

View all deployments of an API proxy in your Apigee organization using the API

View all deployments of an API proxy in your Apigee organization by issuing a GET request to the following resource:

https://apigee.googleapis.com/v1/organizations/{organizationId}/apis/{apiProxyId}/deployments

Where:

  • {organizationId} is the name of your Apigee organization.
  • {apiProxyId} is the name of your API proxy.

For example:

curl "https://apigee.googleapis.com/v1/organizations/myorg/apis/helloworld/deployments" \
-X GET \
-H "Authorization: Bearer $TOKEN"

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token. For information about the curl options used in this example, see Use curl.

The following provides an example of the response:

{
  "deployments": [
    {
      "environment": "test",
      "apiProxy": "helloworld",
      "revision": "1",
      "deployStartTime": "1559149080457",
      "pods": [
        {
          "podName": "apigee-runtime-myorg-test-f8bdf9d-z6rvh",
          "appVersion": "self",
          "deploymentStatusTime": "1559164511972",
          "deploymentStatus": "deployed",
          "statusCode": "200",
          "statusCodeDetails": "Deployment Success",
          "deploymentTime": "1559149706738"
        }
      ],
      "basePath": "/"
    }
  ]
}

For more information, see the Method: organizations.apis.deployments.list in the Apigee API reference.

View all deployments of an API proxy revision in your Apigee organization using the API

View all deployments of an API proxy revision in your Apigee organization by issuing a GET request to the following resource:

https://apigee.googleapis.com/v1/organizations/{organizationId}/apis/{apiProxyId}/revisions/{revision_id}/deployments

Where:

  • {organizationId} is the name of your Apigee organization.
  • {apiProxyId} is the name of your API proxy.
  • {revision_id} is the revision number.

For example:

curl "https://apigee.googleapis.com/v1/organizations/myorg/apis/helloworld/revisions/1/deployments" \
-X GET \
-H "Authorization: Bearer $TOKEN"

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token. For information about the curl options used in this example, see Use curl.

The following provides an example of the response output:

{
  "environment": "test",
  "apiProxy": "helloworld",
  "revision": "1",
  "deployStartTime": "1559149080457",
  "pods": [
    {
      "podName": "apigee-runtime-myorg-test-f8bdf9d-2s72w",
      "appVersion": "self",
      "deploymentStatusTime": "1559164511972",
      "deploymentStatus": "deployed",
      "statusCode": "200",
      "statusCodeDetails": "Deployment Success",
      "deploymentTime": "1559149659417"
    }
  ],
  "basePath": "/"
}

For more information, see the Method: organizations.apis.revisions.deployments.list in the Apigee API reference.

View all deployments of an API proxy in an environment using the API

View all deployments of an API proxy in an environment by issuing a GET request to the following resource:

https://apigee.googleapis.com/v1/organizations/{organizationId}/environments/{env_id}/apis/{apiProxyId}/deployments

Where:

  • {organizationId} is the name of your Apigee organization.
  • {env_id} is the environment name.
  • {apiProxyId} is the name of your API proxy.

For example:

curl "https://apigee.googleapis.com/v1/organizations/myorg/environments/test/apis/helloworld/deployments" \
-X GET \
-H "Authorization: Bearer $TOKEN"

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token. For information about the curl options used in this example, see Use curl.

The following provides an example of the response:

{
  "deployments": [
    {
      "environment": "test",
      "apiProxy": "helloworld",
      "revision": "1",
      "deployStartTime": "1559149080457",
      "basePath": "/"
    }
  ]
}

For more information, see the Method: organizations.environments.apis.deployments.list in the Apigee API reference.

View all deployments of an API proxy revision in an environment using the API

View all deployments of an API proxy revision in an environment by issuing a GET request to the following resource:

https://apigee.googleapis.com/v1/organizations/{organizationId}/environments/{env_id}/apis/{apiProxyId}/revisions/{revision_id}/deployments

Where:

  • {organizationId} is the name of your Apigee organization.
  • {env_id} is the environment name.
  • {apiProxyId} is the name of your API proxy.
  • {revision_id} is the revision number.

For example:

curl "https://apigee.googleapis.com/v1/organizations/myorg/environments/test/apis/helloworld/revisions/1/deployments" \
-X GET \
-H "Authorization: Bearer $TOKEN"

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token. For information about the curl options used in this example, see Use curl.

The following provides an example of the response:

{
  "environment": "test",
  "apiProxy": "helloworld",
  "revision": "1",
  "deployStartTime": "1559149080457",
  "pods": [
    {
      "podName": "apigee-runtime-myorg-test-f8bdf9d-2s72w",
      "appVersion": "self",
      "deploymentStatusTime": "1559164511972",
      "deploymentStatus": "deployed",
      "statusCode": "200",
      "statusCodeDetails": "Deployment Success",
      "deploymentTime": "1559149659417"
    }
  ],
  "basePath": "/"
}

For more information, see the Method: organizations.environments.apis.revisions.deployments.get in the Apigee API reference.

Undeploy an API proxy using the API

Undeploy an API proxy in your Apigee organization by issuing a DELETE request to the following resource:

https://apigee.googleapis.com/v1/organizations/{organizationId}/environments/{env_id}/apis/{apiProxyId}/revisions/{revision_id}/deployments

Where:

  • {organizationId} is the name of your Apigee organization.
  • {env_id} is the environment name.
  • {apiProxyId} is the name of your API proxy.
  • {revision_id} is the revision number.

For example:

curl "https://apigee.googleapis.com/v1/organizations/myorg/environments/test/apis/helloworld/revisions/1/deployments" \
-X DELETE \
-H "Authorization: Bearer $TOKEN"

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token. For information about the curl options used in this example, see Use curl.

The following provides an example of the response output:

{}

For more information, see the Method: organizations.environments.apis.revisions.deployments.undeploy in the Apigee API reference.