개발 환경의 서비스 사용량 설정
이 페이지에서는 Service Usage API를 사용하기 위한 개발 환경을 설정하는 방법에 대해 설명합니다.
- 대부분의 운영 사용 사례에서 서비스를 사용 설정 및 중지하는 가장 간단한 방법은 Google Cloud 콘솔을 사용하는 것입니다.
- 스크립트를 작성해야 하는 경우 Google Cloud CLI를 사용할 수 있습니다.
- Service Usage API에서 프로그래밍해야 하는 경우 클라이언트 라이브러리 중 하나를 사용합니다.
- API를 실험하려면 이 가이드의 대체 설정 지침에 따라
curl명령어를 사용하여 전체 애플리케이션 개발 환경을 설정하지 않고 API를 테스트할 수 있습니다.
API를 직접 호출하도록 설정
이 섹션에서는 curl 명령어를 사용하여 Service Usage API를 시험하기 위한 로컬 환경을 설정하는 데 필요한 기본 단계를 설명합니다. 이는 Service Usage API와 달리 프로그래밍해야 하는 개발자를 대상으로 합니다.
Service Usage API 사용 설정
Service Usage API를 사용하려면 먼저 Google Cloud 프로젝트에서 사용 설정해야 합니다.
- 계정에 로그인합니다. Google Cloud 를 처음 사용하는 경우 Google Cloud, 계정을 만들고 Google 제품의 실제 성능을 평가해 보세요. 신규 고객에게는 워크로드를 실행, 테스트, 배포하는 데 사용할 수 있는 $300의 무료 크레딧이 제공됩니다.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
Enable the Service Usage API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
Enable the Service Usage API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.- 사용자 계정에 서비스 사용량 관리자 역할이 부여되었는지 확인합니다.
curl로 테스트
프로젝트 식별자로 환경 변수
PROJECT_ID를 설정합니다.PROJECT_ID=PROJECT_IDPROJECT_ID를 프로젝트 ID 또는 번호로 바꿉니다. Google Cloud
'gcloud'에 로그인되어 있는지 확인합니다.
gcloud auth login이 프로젝트에서 사용 설정된 API 및 서비스를 나열합니다.
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" "https://serviceusage.googleapis.com/v1/projects/${PROJECT_ID}/services?filter=state:ENABLED&fields=services.config.title,services.config.name"다음과 같은 출력이 표시되면 설정에 성공한 것입니다.
{ "services": [ { "config": { "name": "bigquery.googleapis.com", "title": "BigQuery API" } }, { "config": { "name": "bigquerystorage.googleapis.com", "title": "BigQuery Storage API" } }, ...
다음 단계
프로젝트에서 사용 설정되거나 사용 가능한 API 및 서비스를 나열하려면 서비스 나열을 참조하세요.Google Cloud