To request a deployment from a catalog item, you make a POST request with a project ID that has a cloud template version released to the project. The request body includes the ID of the catalog item from which you are requesting the deployment, and the version of the released cloud template.

Prerequisites

Procedure

  1. Assign the project ID variable.
    project_id='<your_project_id>'
  2. Assign the catalog item ID variable.
    catalog_item_id='<your_catalog_item_id>'
  3. List the available versions of the catalog item that can be requested.
    curl -X GET \
      $url/catalog/api/items/$catalog_item_id/versions \
      -H "Authorization: Bearer $access_token" | jq "."
  4. Examine the response to verify the version of the item that you want has been published to the catalog.
  5. Assign the catalog item version.
    catalog_item_version='<your_catalog_item_version>'
  6. Assign your deployment name variable.
    deployment_name='<your_deployment_name>'
    If your deployment name includes spaces, use double quotes as in the following example.
    deployment_name="This deployment name includes spaces"
    1. To ensure that the deployment name you plan to use does not already exist, list all deployments.
      curl -X GET \
        -G --data-urlencode "name=$deployment_name" \
        $url/deployment/api/deployments?apiVersion=$api_version \
        -H "Authorization: Bearer $access_token" | jq "."
    2. Examine the response. If your deployment name appears, create a new name and reassign your deployment name variable.
  7. To deploy a cloud template, assign variables for image mapping and flavor mapping.
    image_mapping='<your_image_mapping_name>'
    flavor_mapping='<your_flavor_mapping_name>'
    

    The image mapping specifies the OS image for a VM. The flavor mapping specifies the CPU count and RAM of a VM.

  8. Request the deployment from a catalog item.
    curl -X POST \
      $url/catalog/api/items/$catalog_item_id/request?apiVersion=$api_version \
      -H "Authorization: Bearer $access_token"  \
      -H 'Content-Type: application/json' \
      -d '{
        "deploymentName":"'"$deployment_name"'",
        "projectId":"'"$project_id"'",
        "inputs":{
            "count":1,
            "image":"'"$image_mapping"'",
            "flavor":"'"$flavor_mapping"'"
        },
        "version":"'"$catalog_item_version"'"
    }' | jq "."

    The inputs field includes values for request time variables such as size, image, or password.

  9. To obtain the deployment ID, examine the response.
  10. Assign the deployment ID variable.
    deployment_id='<your_deployment_id>'
  11. Get the status of the deployment.
    curl -X GET \
      $url/deployment/api/deployments/$deployment_id?apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" | jq "."

Example: Request Deployment of a Cloud Template from a Catalog Item

Request the deployment of a cloud template with catalog item ID 718917c0-1e02-3141-8142-11da5acaed8f. When requesting the deployment, set image mapping set to ubuntu and flavor mapping set to small.

Assign variables.

$ url='https://appliance.domain.com'
$ api_version='2020-08-25'
$ project_id='394a4ccb-22c6-4ef0-8c75-8b77efbefb51'
$ catalog_item_id='718917c0-1e02-3141-8142-11da5acaed8f'

List available versions.

$ curl -X GET \
  $url/catalog/api/items/$catalog_item_id/versions \
  -H "Authorization: Bearer $access_token" | jq "."

A snippet of the response shows version numbers.

...    
{
      "id": "v2",
      "description": "Creating a version from the current draft",
      "createdAt": "2021-11-087T19:33:04.445Z"
    },
    {
      "id": "v1",
      "description": "Creating a version from the current draft",
      "createdAt": "2021-11-08T19:25:43.327Z"
    }
...

Assign the catalog item version number.

$ catalog_item_version='v2'

Assign a deployment name and check to ensure that it does not already exist.

$ deployment_name="Example Deployment of Cloud Template"
$ curl -X GET \
  -G --data-urlencode "name=$deployment_name" \
  $url/deployment/api/deployments?apiVersion=$api_version \
  -H "Authorization: Bearer $access_token" | jq "."

A snippet of the response shows existing deployments. Example Deployment of Cloud Template is not listed.

{
      "id": "c14e787f-60ee-4cce-a5b5-c9440bf181ab",
      "name": "Not Example Deployment",
      "orgId": "c9258a19-fef0-4431-a999-d711e1741c60",
      "catalogItemId": "947b9db2-cf89-3b83-8035-bbcf83bd4c34",
...

To deploy a cloud template, you must assign image mapping and flavor mapping variables.

$ image_mapping='ubuntu'
$ flavor_mapping='small'

Request a deployment from the catalog item.

$ curl -X POST \
  $url/catalog/api/items/$catalog_item_id/request?apiVersion=$api_version \
  -H "Authorization: Bearer $access_token"  \
  -H 'Content-Type: application/json' \
  -d '{
    "deploymentName":"'"$deployment_name"'",
    "projectId":"'"$project_id"'",
    "inputs":{
        "count":1,
        "image":"'"$image_mapping"'",
        "flavor":"'"$flavor_mapping"'"
    },
    "version":"'"$catalog_item_version"'"
}' | jq "."

The response provides the deployment ID.

{
  "deploymentId": "3721d9e2-fce3-48eb-96e5-d8f381354610",
  "deploymentName": "Example Deployment of Cloud Template"
}

Assign the deployment ID.

$ deployment_id='3721d9e2-fce3-48eb-96e5-d8f381354610'

Get the deployment status.

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

A snippet of the response shows the deployment status.

},
  "projectId": "394a4ccb-22c6-4ef0-8c75-8b77efbefb51",
  "status": "CREATE_SUCCESSFUL"
}