Creating and Deleting Managed Services

This page describes how to manage the life cycle of managed services using the Service Management API.

The standard life cycle of a managed service can involve the following actions:

  • Using the services.create method to create a managed service. Once the managed service is created, you can learn about using the API with service configuration and rollouts in their own guides.
  • Using the services.delete method to discard a managed service you own. Service Management soft deletes the managed service and keeps it for 30 days.
  • Using the services.undelete method to revive a deleted managed service within the 30-day retention window.

Before you begin

To run the examples in this guide, make sure you first follow the instructions to complete the initial setup in Getting Started with the Service Management API.

Creating a managed service

You can create a managed service using the services.create method. You must specify a DNS-compatible service name, and a verified domain name. To learn how to meet these requirements, see Configuring Endpoints.

The following code snippet creates a service with the name endpointsapis.appspot.com in the project endpointsapis:

# Create managed service `endpointsapis.appspot.com`
# in the project `endpointsapis`.
$ gcurl -d '{
  "serviceName": "endpointsapis.appspot.com",
  "producerProjectId": "endpointsapis"
}' https://servicemanagement.googleapis.com/v1/services
{
  "name": "operations/services.endpointsapis.appspot.com-0",
  "metadata": {
    "@type":     "type.googleapis.com/google.api.servicemanagement.v1.OperationMetadata",
    "resourceNames": [
      "/services/endpointsapis.appspot.com"
    ],
    "startTime": ...
    "persisted": true
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.api.servicemanagement.v1.ManagedService",
    "serviceName": "endpointsapis.appspot.com",
    "producerProjectId": "endpointsapis",
    ...
  }
}

The services.create method returns a Long Running Operation resource which you can poll for the operation status using the operations.get method until it is done. To learn how to do this, see Polling Long Running Operations.

Getting services

You can list services or retrieve a specific managed service using the services.list , or services.get methods:

# List services owned by the project `endpointsapis`.
$ gcurl https://servicemanagement.googleapis.com/v1/services?producerProjectId=endpointsapis
{
  "services": [
    {
      "serviceName": "endpointsapis.appspot.com",
      "producerProjectId": "endpointsapis"
    }
    ....
  ]
}


# Get a specified service.
$ gcurl https://servicemanagement.googleapis.com/v1/services/endpointsapis.appspot.com
{
  "serviceName": "endpointsapis.appspot.com",
  "producerProjectId": "endpointsapis"
}

Deleting a managed service

The services.delete method lets you request that a managed service be deleted:

# Delete the managed service `endpointsapis.appspot.com`.
$ gcurl -X DELETE https://servicemanagement.googleapis.com/v1/services/endpointsapis.appspot.com
{
  "name": "operations/services.endpointsapis.appspot.com-1",
  "metadata": {
    "@type":     "type.googleapis.com/google.api.servicemanagement.v1.OperationMetadata",
    "resourceNames": [
      "/services/endpointsapis.appspot.com"
    ],
    "startTime": ...
    "persisted": true
  },
  "response": {
  }
}

The services.delete method returns a Long Running Operation resource which you can poll for the operation status using operations.get method until it is done. To learn how to do this, see Polling Long Running Operations.

Calling the services.delete method does *not* immediately permanently delete the managed service. The managed service is disabled for 30 days, after which it is permanently deleted.

Undeleting a managed service

The services.undelete method lets you revive a previously deleted managed service. You can use this method to restore managed services within 30 days of being deleted. The following code snippet undeletes the specified managed service:

# Undelete the managed service `endpointsapis.appspot.com`.
$ gcurl -d '{}' https://servicemanagement.googleapis.com/v1/services/endpointsapis.appspot.com:undelete
{
  "name": "operations/services.endpointsapis.appspot.com-2",
  "metadata": {
    "@type":     "type.googleapis.com/google.api.servicemanagement.v1.OperationMetadata",
    "resourceNames": [
      "/services/endpointsapis.appspot.com"
    ],
    "startTime": ...
    "persisted": true
  },
  "response": {
    "@type": "type.googleapis.com/google.api.servicemanagement.v1.ManagedService",
    "serviceName": "endpointsapis.appspot.com",
    "producerProjectId": "endpointsapis",
    ...
  }
}

The services.undelete method returns a Long Running Operation resource which you can poll for the operation status using the operations.get method until it is done. To learn how to do this, see Polling Long Running Operations.

Kunde den här sidan hjälpa dig? Berätta:

Skicka feedback om ...

Service Infrastructure