Primeros pasos con la API Service Management

En esta página se describe cómo configurar tu entorno de desarrollo para trabajar con la API Service Management. La forma más sencilla de usar la API Service Management (aparte de usar la interfaz web de la Google Cloud consola ) y la que recomendamos para la mayoría de los casos prácticos operativos es a través de la gcloud interfaz de línea de comandos. Si necesitas programar con la API Service Management, te recomendamos que utilices una de nuestras bibliotecas de cliente. Para experimentar con la API, puedes seguir las instrucciones de configuración alternativa que se indican más abajo y usar el comando curl para probar la API sin configurar un entorno de desarrollo de aplicaciones completo.

Configuración 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.

    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 (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Enable the Service Management API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  4. Install the Google Cloud CLI.

  5. Si utilizas un proveedor de identidades (IdP) externo, primero debes iniciar sesión en la CLI de gcloud 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.

    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 (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  8. Enable the Service Management API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  9. Install the Google Cloud CLI.

  10. Si utilizas un proveedor de identidades (IdP) externo, primero debes iniciar sesión en la CLI de gcloud con tu identidad federada.

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

    gcloud init
  12. Configuración para llamar a la API directamente

    En esta sección se describen los pasos básicos necesarios para configurar tu entorno local y experimentar con la API Service Management mediante el comando curl. Está dirigida a desarrolladores que necesiten programar con la API 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 utilizas un proveedor de identidades (IdP) externo, primero debes iniciar sesión en la CLI de gcloud con tu identidad federada.

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

      gcloud init
    5. Create or select 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 (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.
      • 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:

      Roles required to enable APIs

      To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

      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 utilizas un proveedor de identidades (IdP) externo, primero debes iniciar sesión en la CLI de gcloud con tu identidad federada.

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

      gcloud init
    11. Create or select 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 (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.
      • 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:

      Roles required to enable APIs

      To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

      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. Prueba con curl

      1. Define un alias de shell práctico para llamar a las APIs REST de Google:

        $ alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
        
      2. Prueba a enumerar los servicios de acceso público:

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

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

      Pasos siguientes

      Si vas a crear un servicio gestionado y no usas Cloud Endpoints, sigue estos pasos:

      1. Sigue las instrucciones de Crear y eliminar servicios para crear servicios gestionados. Se creará un recurso de servicio gestionado de nivel superior.
      2. Sigue las instrucciones de Gestionar configuraciones de servicios para enviar configuraciones de servicios que describan las funciones que usa el servicio.

      3. Sigue los pasos que se indican en Poner en marcha las configuraciones de servicio para poner en marcha las configuraciones de tu servicio.