Create a Catalog Source and List Discovered Items

To create a catalog source, you make a POST request with a project ID that has a blueprint version released to the project.

Because you are requesting the deployment of a blueprint from the catalog, this example lists the steps required to create a Cloud Assembly Blueprint source type.

Prerequisites

Procedure

  1. Assign the project ID variable.
    project_id='<your_project_id>'
  2. List all available sources in your catalog.
    curl -X GET \
      $url/catalog/api/admin/sources?apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" | jq "."
  3. Examine the response to confirm that the name of the catalog source that you plan to create is not listed.
  4. List all available catalog source types.
    curl -X GET \
      $url/catalog/api/types?apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" | jq "."
  5. Examine the response to find the catalog source type that you want to create.
  6. Assign the catalog type ID variable for the Cloud Assembly Blueprint source type.
    catalog_type_id='com.vmw.blueprint'
  7. Create a catalog source for your blueprint.
    curl -X POST \
      $url/catalog/api/admin/sources?apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" \
      -H "Content-Type: application/json" \
      -d '{
        "config":{
        "sourceProjectId":"'$project_id'"
      },
        "typeId":"'"$catalog_type_id"'",
        "name":"<your_catalog_source_name>"
    }' | jq "."
  8. To obtain the catalog source ID, examine the response.
  9. List all items discovered in the project.
    curl -X GET \
      $url/catalog/api/admin/items?projectId=$project_id&apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" | jq "."
  10. To obtain the catalog item ID, examine the response.
  11. (Optional) Assign the blueprint name variable.
    blueprint_name='<your_blueprint_name_that_was_released_to_catalog>'
  12. (Optional) To get the catalog item ID, you can also list discovered items by name.
    curl -X GET \
      $url/catalog/api/admin/items?projectId=$project_id&search=$blueprint_name&apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" | jq "."

Example: Create a catalog source and list discovered items

Create a catalog source for a blueprint named BasicCloudMachine.

Assign variables.

$ url='https://appliance.domain.com'
$ api_version='2019-01-15'
$ project_id='394a4ccb-22c6-4ef0-8c75-8b77efbefb51'

List all available sources in your catalog.

$ curl -X GET \
  $url/catalog/api/admin/sources?apiVersion=$api_version \
  -H "Authorization: Bearer $access_token" | jq "."

Examine the response to confirm that the name of the catalog source that you plan to create is not listed. The following snippet shows that you cannot create a catalog source with the name Catalog Source from Blueprintecho s.

...
      "id": "753d24a3-e2b0-4d5e-bba6-9e32e5964c69",
      "name": "Catalog Source from Blueprintecho s",
...

List all available catalog source types.

$ curl -X GET \
  $url/catalog/api/types?apiVersion=$api_version \
  -H "Authorization: Bearer $access_token" | jq "."

Examine the response to find the catalog source named Cloud Assemby Blueprint.

...
      "id": "com.vmw.blueprint",
      "name": "Cloud Assembly Blueprint",
      "baseUri": "http://catalog-service:8000/catalog/api/provider/blueprint",
      "createdBy": "deploymentservice",
...

Assign the ID of Cloud Assemby Blueprint to the catalog type variable.

$ catalog_type_id='com.vmw.blueprint'

Create a catalog source.

$ curl -X POST \
  $url/catalog/api/admin/sources?apiVersion=$api_version \
  -H "Authorization: Bearer $access_token" \
  -H "Content-Type: application/json" \
  -d '{
    "config":{
    "sourceProjectId":"'$project_id'"
  },
    "typeId":"'"$catalog_type_id"'",
    "name":"Catalog Source from Blueprints"
}' | jq "."

A snippet of the response shows the catalog source ID.

{
  "id": "753d24a3-e2b0-4d5e-bba6-9e32e5964c69",
  "name": "Catalog Source from Blueprints",
  "typeId": "com.vmw.blueprint",
  "createdAt": "2019-08-05T22:02:33.553Z",
...

Assign the catalog source ID.

$ catalog_source_id='753d24a3-e2b0-4d5e-bba6-9e32e5964c69'

List items discovered in your project.

$ curl -X GET \
  $url/catalog/api/admin/items?projectId=$project_id&apiVersion=$api_version \
  -H "Authorization: Bearer $access_token" | jq "."

A snippet of the response shows the catalog item ID with your blueprint name.

{      
      "id": "718917c0-1e02-3141-8142-11da5acaed8f",
      "name": "BasicCloudMachine",
      "description": "Basic Cloud Machine blueprint",
      "sourceId": "753d24a3-e2b0-4d5e-bba6-9e32e5964c69",
...

Assign the catalog item ID.

$ catalog_item_id='718917c0-1e02-3141-8142-11da5acaed8f'

What to do next

You use the catalog_source_id to create entitlement for the catalog source. Or you can use the catalog_item_id to create entitlement for the blueprint item. See Create Entitlements.