Calling the REST API

In this guide, you learn how to call the Private Catalog Producer REST API.

Before you begin

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. In the Cloud Console, on the project selector page, select or create a Cloud project.

    Go to the project selector page

  3. Make sure that billing is enabled for your Google Cloud project. Learn how to confirm billing is enabled for your project.

  4. Enable the Deployment Manager and Compute Engine APIs.

    Enable the APIs

Configure authentication

As a cloud admin, you can make REST calls to perform actions on Private Catalog. To get started, set up your access credentials:

  1. Get your client ID and secret.
  2. Get your access token.
  3. Make sure to send https://www.googleapis.com/auth/cloud-platform in the scope parameter.

Create a catalog

To create a catalog, run the following command and replace <token> with your OAuth2 access token and <organization-ID> with your organization ID:

curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d "{parent:"//cloudresourcemanager.googleapis.com/organizations/<organization-ID>", display_name:"Mobile catalog", description: "description"}" https://cloudprivatecatalogproducer.googleapis.com/v1beta1/catalogs

The response body contains data similar to the following output:

{
  "name": "operations/ccb.515502c5-81ad-4226-8037-1b802eed8f69"
}

This is the operation name. You can derive the operation ID from the operation name by removing the prefix operation/. In the previous example response, the operation ID is ccb.515502c5-81ad-4226-8037-1b802eed8f69. You can use the operation ID to check the status of the creation of the catalog.

Check the status of a catalog creation operation

To create a catalog, run the following command and replace <operation-ID> with the operation ID from the previous response:

curl -s -H "Authorization: Bearer <token>" https://cloudprivatecatalogproducer.googleapis.com/v1beta1/operations/<operation-ID>

List your organization's catalogs

To list catalogs that you have access to, within the scope of an organization, run the following command and replace <organization-number> with the organization number:

curl -s -H "Authorization: Bearer <token>" https://cloudprivatecatalogproducer.googleapis.com/v1beta1/catalogs?parent=//cloudresourcemanager.googleapis.com/organizations/<organization-number>

The response body contains data similar to the following output:

{
  "catalogs": [
    {
      "name": "catalogs/<catalog-ID>",
      "parent": "//cloudresourcemanager.googleapis.com/organizations/<organization-ID>",
      "displayName": "Mobile catalog",
      "description": "Mobile-related applications",
      "createTime": "2019-01-01T22:05:19.541Z",
      "updateTime": "2019-01-01T22:05:26.097Z"
    },
    {
      "name": "catalogs/<catalog ID>",
      "parent": "//cloudresourcemanager.googleapis.com/organizations/<organization-ID>",
      "displayName": "Development tools",
      "description": "Applications and tools for developers",
      "createTime": "2019-01-06T00:08:06.090Z",
      "updateTime": "2019-01-06T00:08:08.069Z"
    },
    {
      "name": "catalogs/<catalog ID>",
      "parent": "//cloudresourcemanager.googleapis.com/organizations/<organization-ID>",
      "displayName": "Data science catalog",
      "description": "Applications for data scientists",
      "createTime": "2019-01-06T00:09:45.319Z",
      "updateTime": "2019-01-06T00:09:48.050Z"
    },
    {
      "name": "catalogs/<catalog ID>",
      "parent": "//cloudresourcemanager.googleapis.com/organizations/<organization-ID>",
      "displayName": "Training catalog",
      "description": "Training applications and software",
      "createTime": "2019-01-06T22:13:38.261Z",
      "updateTime": "2019-01-06T22:13:46.291Z"
    },
    {
      "name": "catalogs/<catalog-ID>",
      "parent": "//cloudresourcemanager.googleapis.com/organizations/<organization-ID>",
      "displayName": "Media catalog",
      "description": "Applications for handling audio and visual media",
      "createTime": "2019-01-07T00:15:11.949Z",
      "updateTime": "2019-01-07T00:15:15.426Z"
    }
  ]
}

Get information about a particular catalog

To get information about a catalog, run the following command and replace <catalog-ID> with the catalog ID from the response of an API call to list your organization's catalogs:

curl -s -H "Authorization: Bearer <token>" https://cloudprivatecatalogproducer.googleapis.com/v1beta1/catalogs/<catalog-ID>

The response body contains data similar to the following output:

{
  "name": "catalogs/<catalog-ID>",
  "parent": "//cloudresourcemanager.googleapis.com/organizations/<organizaton-ID>",
  "displayName": "Data science catalog",
  "description": "Applications for data scientists",
  "createTime": "2019-01-01T22:05:19.541Z",
  "updateTime": "2019-01-01T22:05:26.097Z"
}

Create a product

To create a product, run the following command and replace <catalog-ID> with the catalog ID from the response of an API call to list your organization's catalogs:

curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d @/tmp/rest_create_product_request https://cloudprivatecatalogproducer.googleapis.com/v1beta1/catalogs/<catalog-ID>/products

The following example illustrates the contents of the /tmp/rest_create_product_request file:

{
  name:"catalogs/<catalog-ID>/products/<product-name>",
  asset_type:"google.deploymentmanager.Template",
  display_metadata:{
    name:"<product-name>",
    description:"Sample Description"
  }
}

List the products in a catalog

To list products in a catalog, run the following command and replace <catalog-ID> with the catalog ID from the response of an API call to list your organization's catalogs:

curl -s -H "Authorization: Bearer <token>" https://cloudprivatecatalogproducer.googleapis.com/v1beta1/catalogs/<catalog-ID>/products

The response body contains data similar to the following output:

{
  "products": [
    {
      "name": "catalogs/<catalog-ID>/products/dm-product",
      "assetType": "google.deploymentmanager.Template",
      "displayMetadata": {
        "name": "sample-metadata-name",
        "description": "sample-metadata-description",
        "tagline": "sample-metadata-tagline",
        "support_info": "sample-metadata-support-info"
      },
      "createTime": "2019-01-04T19:36:02.573Z"
    },
    {
      "name": "catalogs/<catalog-ID>/products/listingonly",
      "assetType": "google.private-catalog.ListingOnly",
      "displayMetadata": {
        "name": "listing-based product",
        "description": "description",
        "tagline": "tagline",
        "support_info": "support_info",
        "signup_url": "https://cloud.google.com/launcher",
        "documentations": [
          {
            "url": "https://cloud.google.com/launcher"
          }
        ]
      },
      "createTime": "2019-01-06T00:25:44.722Z"
    }
  ]
}

Create a product version

To create a product version, run the following command and replace <catalog-ID> with a catalog ID and <product-name> with the name of the product you want to create a version for:

curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d @/tmp/rest_create_version_request https://cloudprivatecatalogproducer.googleapis.com/v1beta1/catalogs/<catalog-ID>/products/<product-name>/versions

The following example illustrates the contents of the /tmp/rest_create_version_request file:

{
  name: "catalogs/<catalog-ID>/products/<product-name>/versions/v1",
  description: "v1",
  original_asset: {
        imports: [
                {
                  name: "my-template",
                  content: "resources:\n name: \'awesome template\'\n  properties:\n",
                },
                {
                  name: "my-template.schema",
                  content: ""
                }
        ],
        mainTemplate: "my-template",
        templateFileType: "JINJA"
  }
}

The response body contains data about the resulting operation, similar to the following output:

{
  "name": "operations/cvb.efcd831d-257d-43f7-8650-f7016c7469cb"
}

List the versions of a product

To list the versions of a product, run the following command and replace <catalog-ID> with the catalog ID and <product-name> with the name of the product you want to list versions for:

curl -s -H "Authorization: Bearer <token>" https://cloudprivatecatalogproducer.googleapis.com/v1beta1/catalogs/<catalog-ID>/products/<product-name>/versions

The response body contains data similar to the following output:

{
  "versions": [
    {
      "name": "catalogs/<catalog-ID>/products/<product-name>/versions/v1",
      "createTime": "2019-01-04T19:37:47.519Z",
      "updateTime": "2019-01-04T19:37:47.519Z"
    }
  ]
}

Upload a product icon

To upload a product icon, run the following command and replace <catalog-ID> with the catalog ID and <product-name> with the name of the product you want to upload an icon for:

curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d @/tmp/rest_upload_icon_request https://cloudprivatecatalogproducer.googleapis.com/v1beta1/catalogs/<catalog-id>/products/<product-name>/icons:upload

The following example illustrates the contents of the /tmp/rest_upload_icon_request file:

{
  icon_bytes: "iVBORw0KGgoA...Jggg=="
}