API_ID는 이 API 구성과 연결된 API 게이트웨이 API의 ID를 지정합니다. API가 아직 없으면 이 명령어로 생성됩니다.
API_DEFINITION은 API 정의가 포함된 OpenAPI 사양의 이름을 지정합니다.
PROJECT_ID는 Google Cloud 프로젝트 ID를 지정합니다.
SERVICE_ACCOUNT_EMAIL은 구성된 인증으로 백엔드의 토큰을 서명하는 데 사용되는 서비스 계정을 지정합니다. 자세한 내용은 서비스 계정 구성을 참조하세요.
API 및 API 구성이 생성될 때 API 게이트웨이가 터미널에 정보를 출력합니다. API 구성이 다운스트림 시스템에 전파되기 때문에 이 작업은 완료하는 데 몇 분 정도 걸릴 수 있습니다. 복잡한 API 구성을 만들기 위해서는 최대 10분까지 걸릴 수 있습니다. 구성이 생성되는 동안에는 동일한 API에 대해 다른 구성을 만들려고 시도하지 마세요. 모든 API 구성은 한 번에 하나만 만들 수 있습니다.
성공적으로 완료되었으면 다음 명령어를 사용하여 새 API 구성에 대한 세부정보를 볼 수 있습니다.
위에 표시된 describe 명령어 또는 --format 옵션을 포함하여 list 명령어의 출력에서 라벨을 볼 수 있습니다.
gcloud api-gateway api-configs list \
--api=API_ID --project=PROJECT_ID --format="table(name, labels)"
API 구성 나열
특정 프로젝트에 대해 API 구성을 나열하려면 다음 안내를 따르세요.
gcloud api-gateway api-configs list --project=PROJECT_ID
이 명령어는 다음을 반환합니다.
NAME DISPLAY_NAME ROLLOUT_ID STATE CREATE_TIME
projects/PROJECT_ID/locations/global/apis/API_ID/configs/CONFIG_IDCONFIG_ID 2020-02-04r0 ACTIVE 2020-02-04T16:18:02.369859863Z
프로젝트에서 특정 API의 API 구성을 나열하려면 다음 안내를 따르세요.
gcloud api-gateway api-configs list --api=API_ID --project=PROJECT_ID
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-12-21(UTC)"],[[["\u003cp\u003eBefore creating an API config, you must have prepared your development environment and created an API definition as an OpenAPI spec, and optionally, you may have already created the API.\u003c/p\u003e\n"],["\u003cp\u003eThe API config ID must adhere to specific formatting rules, including a maximum length of 63 characters and the use of only lowercase letters, numbers, and dashes, without starting with a dash or using underscores.\u003c/p\u003e\n"],["\u003cp\u003eCreating an API config involves using the Google Cloud CLI to upload your API definition, specifying the API name, and if the API doesn't exist, the command will also create it, this is done by following through the steps of changing the correct directory, setting the correct project ID, and running the \u003ccode\u003egcloud api-gateway api-configs create\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eAPI configs can be listed, described, and updated, however, updating an API definition requires creating a new API config, as existing configs cannot be modified except for labels and display names.\u003c/p\u003e\n"],["\u003cp\u003eDeleting an API config requires that it is not in use by any deployed gateway, either through deploying a different config or deleting the gateway, then using the \u003ccode\u003egcloud api-gateway api-configs delete\u003c/code\u003e command.\u003c/p\u003e\n"]]],[],null,["# Creating an API config\n======================\n\nPrerequisites\n-------------\n\nBefore you can create an API config, ensure that you have:\n\n- Prepared your development environment as described in [Configuring your development environment](/api-gateway/docs/configure-dev-env).\n\n- [Created an API definition](/api-gateway/docs/openapi-overview) as an OpenAPI spec.\n\n- Optionally created an API as described in [Creating an API](/api-gateway/docs/creating-api). If the API does not already exist, then creating the API config creates it.\n\nAPI config ID requirements\n--------------------------\n\nMany of the `gcloud` commands shown below require you to specify the ID of the API config, in the form: \u003cvar translate=\"no\"\u003eCONFIG_ID\u003c/var\u003e.\nAPI Gateway enforces the following requirements for the API config ID:\n\n- Must have a maximum length of 63 characters.\n- Must contain only lowercase letters, numbers, or dashes.\n- Must not start with a dash.\n- Must not contain an underscore.\n\nCreating an API config\n----------------------\n\nUse the Google Cloud CLI to upload your API definition to create an API config.\nWhen you upload the API definition, you are required to specify the name of the API.\nIf the API does not already exist in API Gateway then this command also creates it.\n| **Note:** API Gateway supports creation of API definitions as OpenAPI specs for all available backend services. API Gateway also supports the use of gRPC service definitions and configurations for gRPC services on Cloud Run.\n\nTo create an API config:\n\n1. Change directory to the directory containing your API definition.\n\n For more on creating the OpenAPI spec for your API definition, see [OpenAPI overview](/api-gateway/docs/openapi-overview)\n and [Quickstart: Deploy an API on API Gateway](/api-gateway/docs/quickstart).\n\n For more on creating a gRPC service definition and configuration for your API definition, see [Configuring a gRPC service](/api-gateway/docs/grpc-service-config)\n and [Getting started with API Gateway and Cloud Run for gRPC](/api-gateway/docs/get-started-cloud-run-grpc).\n2. Validate the project ID returned from the following command to make sure that\n the service isn't created in the wrong project.\n\n ```\n gcloud config list project\n ```\n\n If you need to change the default project, run the following command\n and replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the Google Cloud project ID\n in which you want to create the service:: \n\n ```\n gcloud config set project PROJECT_ID\n ```\n3. View help for the `api-configs create` command:\n\n ```\n gcloud api-gateway api-configs create --help\n ```\n4. Run the following command to create the API config:\n\n ```\n gcloud api-gateway api-configs create CONFIG_ID \\\n --api=API_ID --openapi-spec=API_DEFINITION \\\n --project=PROJECT_ID --backend-auth-service-account=SERVICE_ACCOUNT_EMAIL\n ```\n\n where:\n - \u003cvar translate=\"no\"\u003eCONFIG_ID\u003c/var\u003e specifies the ID of the new API config.\n - \u003cvar translate=\"no\"\u003eAPI_ID\u003c/var\u003e specifies the ID of the API Gateway API associated with this API config. If the API does not already exist then this command creates it.\n - \u003cvar translate=\"no\"\u003eAPI_DEFINITION\u003c/var\u003e specifies the name of the OpenAPI spec containing the API definition.\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e specifies the Google Cloud project ID.\n - \u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT_EMAIL\u003c/var\u003e specifies the service account used to sign tokens for backends with authentication configured. See [Configuring a service account](/api-gateway/docs/configure-dev-env#configuring_a_service_account) for more details.\n\n As it is creating the API and API config, API Gateway outputs\n information to the terminal. This operation may take several minutes to complete as the API config is propagated to downstream systems. Creation of a complex API config could take up to ten minutes to\n complete successfully. While a config is being created, do not attempt to\n create another config for the same API. Only one config may be created\n for any API at a time.\n5. On successful completion, you can use the following command to view details about the new API config:\n\n ```\n gcloud api-gateway api-configs describe CONFIG_ID \\\n --api=API_ID --project=PROJECT_ID\n ```\n\n This command returns the following: \n\n ```scdoc\n createTime: '2020-02-04T18:33:11.882707149Z'\n displayName: CONFIG_ID\n gatewayConfig:\n backendConfig:\n googleServiceAccount: 1111111@developer.gserviceaccount.com\n labels: ''\n name: projects/PROJECT_ID/locations/global/apis/API_ID/configs/CONFIG_ID\n serviceRollout:\n rolloutId: 2020-02-04r2\n state: ACTIVE\n updateTime: '2020-02-04T18:33:12.219323647Z'\n ```\n6. Enable the API using the managed service name of the API. You can find this value in the Managed Service column for your API on the APIs landing page:\n\n \u003cbr /\u003e\n\n ```\n gcloud services enable MANAGED_SERVICE_NAME.apigateway.PROJECT_ID.cloud.goog\n ```\n\n \u003cbr /\u003e\n\n You only have to run this command once when you create the API. If you later modify the API,\n you do not have to rerun the command.\n\nThe Google Cloud CLI takes many options, including those described in the\n[gcloud Reference](/sdk/gcloud/reference). In addition,\nfor API Gateway, you can set the following options when creating an API config:\n\n- `--async`: Return control to the terminal immediately, without waiting for the operation to complete.\n- `--display-name=`\u003cvar translate=\"no\"\u003eNAME\u003c/var\u003e: Specifies the display name of the API config, meaning the name shown in the UI. Do not use spaces in the name. Use hyphens and underscores instead. The default value is \u003cvar translate=\"no\"\u003eCONFIG_ID\u003c/var\u003e.\n- `--labels=`\u003cvar translate=\"no\"\u003eKEY1\u003c/var\u003e`=`\u003cvar translate=\"no\"\u003eVALUE1\u003c/var\u003e`,`\u003cvar translate=\"no\"\u003eKEY2\u003c/var\u003e`=`\u003cvar translate=\"no\"\u003eVALUE2\u003c/var\u003e`,...`: Specifies labels associated with the API config.\n\nFor example: \n\n```\ngcloud api-gateway api-configs create CONFIG_ID \\\n --api=API_ID --openapi-spec=API_DEFINITION \\\n --project=PROJECT_ID --backend-auth-service-account=SERVICE_ACCOUNT_EMAIL \\\n --async --display-name=MyConfig --labels=a=1,b=2\n```\n\nYou can see the labels in the output of the `describe` command shown above, or in the `list` command by including the `--format` option: \n\n```\ngcloud api-gateway api-configs list \\\n --api=API_ID --project=PROJECT_ID --format=\"table(name, labels)\"\n```\n\nListing API configs\n-------------------\n\nTo list API configs for a specific project: \n\n```\ngcloud api-gateway api-configs list --project=PROJECT_ID\n```\n\nThis command returns the following: \n\n```scdoc\nNAME DISPLAY_NAME ROLLOUT_ID STATE CREATE_TIME\nprojects/PROJECT_ID/locations/global/apis/API_ID/configs/CONFIG_ID CONFIG_ID 2020-02-04r0 ACTIVE 2020-02-04T16:18:02.369859863Z\n```\n\nTo list API configs for a specific API in a project: \n\n```\ngcloud api-gateway api-configs list --api=API_ID --project=PROJECT_ID\n```\n\nUse the project, API, and config IDs to obtain detailed information about the API config: \n\n```\ngcloud api-gateway api-configs describe CONFIG_ID \\\n --api=API_ID --project=PROJECT_ID\n```\n\nUpdating an API config\n----------------------\n\nYou cannot modify an existing API config other than to update its labels and its display name.\n| **Note:** Every time you upload an API definition, API Gateway creates a new API config.\n|\n| To update an API definition:\n|\n| 1. Update the OpenAPI spec containing the API definition.\n| 2. Upload the API definition to create a **new** API config.\n|\n| Use the same command to create the **new** API config as you used to create the initial API config,\n| as shown above in [Creating an API config](#creating-an-api-config).\n\nUse the following `gcloud` to update an existing API config:\n\n- `--display-name`\n- `--update-labels`\n- `--clear-labels`\n- `--remove-labels`\n\nFor example: \n\n```\ngcloud api-gateway api-configs update CONFIG_ID \\\n --api=API_ID --project=PROJECT_ID \\\n --update-labels=a=1,b=2\n```\n\nUse the following command to view all update options: \n\n```\ngcloud api-gateway api-configs update --help\n```\n\nDeleting an API config\n----------------------\n\n| **Warning:** If you deployed the API config to a gateway, the API config may not be deleted until the gateway is no longer using that API config.\n|\n| Before you delete an API config that is in use, you must either:\n|\n| - Deploy a different API config to the gateway.\n| - Delete the gateway.\n|\n| See [Deploying an API to a gateway](/api-gateway/docs/deploying-api) for more.\n\nUse the following `gcloud` command to delete an existing API config: \n\n```\ngcloud api-gateway api-configs delete CONFIG_ID --api=API_ID --project=PROJECT_ID\n```\n\nWhat's next\n-----------\n\n- [Deploying an API to a gateway](/api-gateway/docs/deploying-api)"]]