開発環境に対する Service Usage の設定
このページでは、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 プロジェクトで Service Usage API を有効にする必要があります。
- アカウントにログインします。 Google Cloud を初めて使用する場合は、 アカウントを作成して、実際のシナリオで Google プロダクトのパフォーマンスを評価してください。 Google Cloud新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $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.- ユーザー アカウントに Service Usage 管理者ロールが付与されていることを確認します。
curl によるテスト
環境変数
PROJECT_IDにプロジェクトの識別子を設定します。PROJECT_ID=PROJECT_IDPROJECT_ID は、実際の Google Cloud プロジェクト ID または プロジェクト番号に置き換えます。
「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 プロジェクトのサービスの一覧表示をご覧ください。