Comienza a usar la API de Service Management

Esta página describe cómo configurar tu entorno de desarrollo para trabajar con la API de Service Management. El enfoque más simple para usar la API de Service Management (que no sea solo usar la IU web de la consola deGoogle Cloud ), y nuestra recomendación para la mayoría de los casos prácticos operativos, es a través de la interfaz de línea de comandos de gcloud. Si necesitas programar en la API de Service Management, te recomendamos que utilices una de nuestras bibliotecas cliente proporcionadas. Para experimentar con la API, puedes seguir las instrucciones alternativas de configuración que figuran a continuación y utilizar el comando curl para practicar con la API sin configurar un entorno de desarrollo de aplicaciones completo.

Realiza configuraciones con 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. Si usas un proveedor de identidad externo (IdP), primero debes acceder a gcloud CLI con tu identidad federada.

  6. Para inicializar gcloud CLI, ejecuta el siguiente comando:

    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. Si usas un proveedor de identidad externo (IdP), primero debes acceder a gcloud CLI con tu identidad federada.

  11. Para inicializar gcloud CLI, ejecuta el siguiente comando:

    gcloud init
  12. Realiza configuraciones para llamar a la API directamente

    Esta sección describe los pasos básicos necesarios para configurar su entorno local a fin de experimentar con la API de administración de servicios mediante el comando de curl. Está dirigido a desarrolladores que necesitan programar en la API de Service Management.

    Configuración inicial

    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. Si usas un proveedor de identidad externo (IdP), primero debes acceder a gcloud CLI con tu identidad federada.

    4. Para inicializar gcloud CLI, ejecuta el siguiente comando:

      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 the following:

      • PROJECT_ID: your project ID.
      • USER_IDENTIFIER: the identifier for your user account—for example, myemail@example.com.
      • ROLE: the IAM role that you grant to your user account.
    8. Install the Google Cloud CLI.

    9. Si usas un proveedor de identidad externo (IdP), primero debes acceder a gcloud CLI con tu identidad federada.

    10. Para inicializar gcloud CLI, ejecuta el siguiente comando:

      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 the following:

      • PROJECT_ID: your project ID.
      • USER_IDENTIFIER: the identifier for your user account—for example, myemail@example.com.
      • ROLE: the IAM role that you grant to your user account.
    14. Realiza pruebas con curl

      1. Define un alias de shell conveniente para llamar a las API de REST de Google:

        $ alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
        
      2. Intenta crear una lista de los servicios accesibles públicos:

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

        Si ves una lista de servicios, la configuración se realizó correctamente.

      Próximos pasos

      Si creas un servicio administrado y no utilizas Cloud Endpoints:

      1. Sigue las instrucciones en Crea y borra servicios para crear servicios administrados. Esto creará un recurso de servicio administrado de nivel superior.
      2. Sigue las instrucciones en Administra configuraciones de servicio para enviar las configuraciones de servicio a fin de describir las características que utiliza el servicio.

      3. Sigue las instrucciones en Implementa configuraciones de servicio para aplicar las configuraciones de servicio.