托管式服务是一种简单的资源,用于以逻辑方式表示与 Service Infrastructure 集成的服务,例如 Gmail API 和 Spanner API。托管式服务本身只有两个不可变属性(服务名称和生产者项目),但托管式服务的实现可以提供范围广泛的各种功能。例如,Cloud Storage API 可为数百万开发者和企业提供全球级对象存储。
Service Management API 使用声明式模型进行服务管理。创建服务后,您需要推送不可变服务配置和服务发布,以实现所需的服务状态。您的服务配置用于配置 Google Cloud 基础架构服务以为您的服务提供支持,这些基础架构服务包括 Cloud Billing、Cloud Logging、Cloud Monitoring 和 Identity and Access Management。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# Managing Service Lifecycles\n\nThis page describes how to manage the lifecycles of\n[managed services](/service-infrastructure/docs/glossary#managed) using the Google Cloud CLI\n[`gcloud endpoints services`](https://cloud.google.com/sdk/gcloud/reference/endpoints/services)\ncommands.\n\nFor advanced use cases, you can use the Service Management API\nto manage services programmatically. For more information, see\n[Getting Started with the Service Management\nAPI](/service-infrastructure/docs/service-management/getting-started)\n\nIntroduction\n------------\n\nA [managed service](/service-infrastructure/docs/service-management/reference/rest/v1/services)\nis a simple resource that logically represents a service integrated with Service\nInfrastructure, such as Gmail API and Spanner API. A managed service itself\nhas only two immutable properties, a *service name* and a *producer project* ,\nbut the implementation of a managed service can provide a wide range of\nfunctionality. For example, [Cloud Storage API](/storage/docs) provides\nplanet-scale object storage for millions of developers and enterprises.\n\nA managed service has a set of\n[service consumers](/service-infrastructure/docs/service-management/reference/rest/v1/services.consumers),\na history of immutable\n[service configurations](/service-infrastructure/docs/service-management/reference/rest/v1/services.configs),\nand a history of immutable\n[service rollouts](/service-infrastructure/docs/service-management/reference/rest/v1/services.rollouts).\nThe service configurations referenced by the latest service rollout represents\nthe current state of the service, which covers all aspects of the service, from\nthe display name to metrics definitions to rate limits. For the specification,\nsee\n[`google.api.Service`](https://github.com/googleapis/googleapis/blob/master/google/api/service.proto#L73).\n\nWe will describe how to create and manage your service lifecycles in this page.\nFor more information about the service management, see\n[How-to Guides](/service-infrastructure/docs/how-to).\n\nCreating a service\n------------------\n\nTo create a service, you need to complete the following steps.\n\n1. Install and initialize\n [gcloud CLI](https://cloud.google.com/sdk/docs/initializing) on your\n computer.\n\n2. Create a dedicated producer project to host your service. A dedicated\n project provides the best security and isolation for your service.\n It also allows you to transfer the ownership of your service to another\n team or even another company.\n\n3. Enable the Service Management API and Service Control API for your project.\n\n4. Enable Cloud Billing for your project. To integrate your service with\n Service Infrastructure, you will depend on several paid Google Cloud\n products, including the Service Control API, Cloud Logging API, and\n Cloud Monitoring API.\n\n5. Prepare a simple service configuration yaml file for your service\n as follows:\n\n # Filename: endpointsapis.yaml\n type: google.api.Service\n config_version: 3\n # Update the next line to use your own service name.\n name: endpointsapis.appspot.com\n # Update the next line to use your own producer project id.\n producer_project_id: endpointsapis\n\n6. Run `gcloud` command to create your service by deploying a blank service\n configuration:\n\n gcloud endpoints services deploy endpointsapis.yaml\n\nThe service creation process takes about a minute. After that, you should be\nable to see your service listed on the\n[Endpoints](https://console.cloud.google.com/endpoints?project=_) page\nin Google Cloud console.\n\nListing services\n----------------\n\nTo list services in a project, you can use the following command: \n\n gcloud endpoints services list --project endpointsapis\n\nDescribing a service\n--------------------\n\nTo describe a service and its configuration, you can use the following command: \n\n gcloud endpoints services describe endpointsapis.appspot.com\n\nDeleting a service\n------------------\n\nIf you no longer need a service, you can delete it using the following command: \n\n gcloud endpoints services delete endpointsapis.appspot.com\n\nNOTE: Every service has a mandatory 30-day deletion retention.\n\nUndeleting a service\n--------------------\n\nYou can undelete a service within its retention window using the following\ncommand: \n\n gcloud endpoints services undelete endpointsapis.appspot.com\n\nNext steps\n----------\n\nThe Service Management API uses a declarative model for service management.\nAfter the service is created, you need to push immutable service\nconfigurations and service rollouts to reach the desired state\nof your service. Your service configurations are used to configure\nGoogle Cloud infrastructure services to support your service,\nincluding Cloud Billing, Cloud Logging, Cloud Monitoring, and\nIdentity and Access Management.\n\nFor more information about service configurations, see\n[Managing Service Configurations](/service-infrastructure/docs/manage-config).\nFor more information about service rollouts, see\n[Managing Service Rollouts](/service-infrastructure/docs/rollout)."]]