Halaman ini menjelaskan cara menyiapkan lingkungan pengembangan untuk menggunakan Service Management API. Pendekatan paling sederhana untuk menggunakan Service Management API (selain hanya menggunakan UI web Google Cloud konsol), dan rekomendasi kami untuk sebagian besar kasus penggunaan operasional, adalah melalui gcloud
antarmuka command line. Jika Anda perlu memprogram terhadap Service Management API, sebaiknya gunakan salah satu library klien yang kami sediakan.
Untuk bereksperimen dengan API, Anda dapat mengikuti petunjuk penyiapan alternatif di bawah dan menggunakan perintah curl
untuk mencoba API tanpa menyiapkan lingkungan pengembangan aplikasi lengkap.
Penyiapan menggunakan gcloud
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Enable the Service Management API.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Enable the Service Management API.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
Create or select a Google Cloud project.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_ID
with a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_ID
with your Google Cloud project name.
-
-
Enable the Service Management API:
gcloud services enable servicemanagement.googleapis.com
-
Grant roles to your user account. Run the following command once for each of the following IAM roles:
roles/servicemanagement.admin
gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE
- Replace
PROJECT_ID
with your project ID. -
Replace
USER_IDENTIFIER
with the identifier for your user account. For example,user:[email protected]
. - Replace
ROLE
with each individual role.
- Replace
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
Create or select a Google Cloud project.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_ID
with a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_ID
with your Google Cloud project name.
-
-
Enable the Service Management API:
gcloud services enable servicemanagement.googleapis.com
-
Grant roles to your user account. Run the following command once for each of the following IAM roles:
roles/servicemanagement.admin
gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE
- Replace
PROJECT_ID
with your project ID. -
Replace
USER_IDENTIFIER
with the identifier for your user account. For example,user:[email protected]
. - Replace
ROLE
with each individual role.
- Replace
Tentukan alias shell yang mudah untuk memanggil Google REST API:
$ alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
Coba mencantumkan layanan yang dapat diakses secara publik:
$ gcurl https://servicemanagement.googleapis.com/v1/services
Jika Anda melihat daftar layanan, berarti penyiapan berhasil.
- Ikuti Membuat dan Menghapus Layanan untuk membuat layanan terkelola. Tindakan ini akan membuat resource layanan terkelola tingkat teratas.
Ikuti Mengelola Konfigurasi Layanan untuk mengirimkan konfigurasi layanan guna mendeskripsikan fitur yang digunakan oleh layanan.
Ikuti Meluncurkan Konfigurasi Layanan untuk meluncurkan konfigurasi layanan Anda.
Penyiapan untuk memanggil API secara langsung
Bagian ini menjelaskan langkah-langkah dasar yang diperlukan untuk menyiapkan lingkungan lokal Anda guna bereksperimen dengan Service Management API menggunakan perintah curl
. Ditujukan untuk developer yang perlu memprogram Service Management API.
Penyiapan awal
Menguji dengan curl
Langkah berikutnya
Jika Anda membuat layanan terkelola dan tidak menggunakan Cloud Endpoints: