代管服務是一種簡單的資源,可從邏輯上代表與服務基礎架構整合的服務,例如 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"]],["上次更新時間: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)."]]