Set up the Cloud Quotas API

This page describes how to set up your development environment to use the Cloud Quotas API and how to setup the curl command to test the API without setting up a full application development environment. You don't need to complete these instructions if you want to list, enable, or disable services using Google Cloud console.

Enable the Cloud Quotas API

To use the Cloud Quotas API, you must first enable it in the Google Cloud project you want to use it for:

  1. Go to the Google Cloud console API Library page.

    Go to API Library

  2. Select the Google Cloud project that you want to use to access the service.

  3. On the API Library page, enable Cloud Quotas API.

  4. Make sure that your user account has the required IAM roles.

Set up gCurl

  1. To enable the Cloud Quotas API, run the following command to enable the service in the Google Cloud project you want to use it for:

    gcloud services enable cloudquotas.googleapis.com

  2. Successful output looks similar to the following:

    Waiting for async operation operations/acf.2e2fcfce-8327-4984-9040-a67777082687 to complete…
    Operation finished successfully.

  3. Define a convenient shell alias for calling Google REST APIs:

    BILLING_PROJECT_ID="my-billing-project-id"
    alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" -H "x-goog-user-project:${BILLING_PROJECT_ID}"'
    
  4. Set an environment variable PROJECT_ID with the identifier of your project. This can be the project ID or number:

    PROJECT_ID="my-project-id"
    
  5. Make sure that you are logged into the gcloud CLI:

    gcloud auth login
    
  6. List the enabled APIs and services in this project:

    gcurl "https://serviceusage.googleapis.com/v1/projects/${PROJECT_ID}/services?filter=state:ENABLED&fields=services.config.title,services.config.name"
    

    If you see output similar to the following, then your setup is successful:

    {
    "services": [
      ...
      {
        "config": {
          "name": "cloudquotas.googleapis.com",
          "title": "Cloud Quotas API"
        }
      },
      ...
    ]
    }
    

What's next