Mulai Menggunakan Service Management API

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

  1. 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.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Enable the Service Management API.

    Enable the API

  4. Install the Google Cloud CLI.

  5. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  6. To initialize the gcloud CLI, run the following command:

    gcloud init
  7. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  8. Enable the Service Management API.

    Enable the API

  9. Install the Google Cloud CLI.

  10. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  11. To initialize the gcloud CLI, run the following command:

    gcloud init
  12. 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

    1. 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.
    2. Install the Google Cloud CLI.

    3. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

    4. To initialize the gcloud CLI, run the following command:

      gcloud init
    5. 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.

    6. Enable the Service Management API:

      gcloud services enable servicemanagement.googleapis.com
    7. 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.
    8. Install the Google Cloud CLI.

    9. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

    10. To initialize the gcloud CLI, run the following command:

      gcloud init
    11. 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.

    12. Enable the Service Management API:

      gcloud services enable servicemanagement.googleapis.com
    13. 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.
    14. Menguji dengan curl

      1. 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"'
        
      2. Coba mencantumkan layanan yang dapat diakses secara publik:

        $ gcurl https://servicemanagement.googleapis.com/v1/services
        

        Jika Anda melihat daftar layanan, berarti penyiapan berhasil.

      Langkah berikutnya

      Jika Anda membuat layanan terkelola dan tidak menggunakan Cloud Endpoints:

      1. Ikuti Membuat dan Menghapus Layanan untuk membuat layanan terkelola. Tindakan ini akan membuat resource layanan terkelola tingkat teratas.
      2. Ikuti Mengelola Konfigurasi Layanan untuk mengirimkan konfigurasi layanan guna mendeskripsikan fitur yang digunakan oleh layanan.

      3. Ikuti Meluncurkan Konfigurasi Layanan untuk meluncurkan konfigurasi layanan Anda.