As a Automation Assembler administrator, you use the PATCH iaas/api/projects request to attach a cloud zone to a project.

If the project already has cloud zones attached, review them to ensure that all zones needed for the project are included in the PATCH request to add a new cloud zone.

Prerequisites

Procedure

  1. Assign the project ID variable.
    project_id='<your_project_id>'

    your_project_id is the ID of the new project you created.

  2. List all cloud zones.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/zones?apiVersion=$api_version"  | jq "."
  3. To obtain a cloud zone ID, examine the response and find the ID of the zone that you want to attach to your project. For a snippet of the response, see Create a Cloud Zone.
  4. Assign the cloud zone variable.
    zone_id='<your_zone_id>'
  5. List the details of your project.
    curl -X GET -H 'Accept: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/projects/$project_id?apiVersion=$api_version" | jq "."
  6. Examine the response to see the zones already attached to your project.
  7. Submit a request to attach and configure a new cloud zone that includes the ID of existing cloud zones for the project.
    Note: If the call does not include existing cloud zones that are already attached to the project, the PATCH request removes those cloud zones from the project.
    curl -X PATCH \
      "$url/iaas/api/projects/$project_id?apiVersion=$api_version" \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token" \
      -d '{
        "zoneAssignmentConfigurations" : [
          {
            "zoneId" : "'$zone_id'",
            "priority": 1,
            "maxNumberInstances": 50
          },
          {
            "zoneId" : "<existing_cloud_zone_id>",
            "priority": 2,
            "maxNumberInstances": 100
          }
        ]
      }' | jq "."

Example: Attach a Cloud Zone to Your Project

For the new project Example-project, add a cloud zone.

$ url='https://appliance.domain.com'
$ api_version='2021-07-15'
$ project_id='5944aacb-91de-4541-bb9e-ef2a5403f81b'

List all cloud zones.

$ curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/zones?apiVersion=$api_version"  | jq "."

Examine the response to find the cloud zone you want and assign the zone ID variable.

$ zone_id='4965d34c3bfe0275574bc5fd8782a'

List the details of your project.

$ curl -X GET -H 'Accept: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/projects/$project_id?apiVersion=$api_version" | jq "."

A snippet of the response shows an existing cloud zone.

...
"zones": [
    {
      "zoneId": "3cc2ecb989eee87557b0d532d4bb0",
      "priority": 0,
      "maxNumberInstances": 0
    }
...

Add the new cloud zone. Include the existing cloud zone 3cc2ecb989eee87557b0d532d4bb0 in the PATCH request.

$ curl -X PATCH \
  "$url/iaas/api/projects/$project_id?apiVersion=$api_version" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $access_token" \
  -d '{
    "zoneAssignmentConfigurations" : [
      {
        "zoneId" : "'$zone_id'",
        "priority": 1,
        "maxNumberInstances": 50
      },
      {
        "zoneId" : "3cc2ecb989eee87557b0d532d4bb0",
        "priority": 2,
        "maxNumberInstances": 100
      }
    ]
  }' | jq "."

The response after adding a cloud zone lists the project with its administrators, members, and zone.

{
  "administrators": [
    {
      "email": "[email protected]"
    }
  ],
  "members": [
    {
      "email": "[email protected]"
    }
  ],
  "zones": [
    {
      "zoneId": "4965d34c3bfe0275574bc5fd8782a",
      "priority": 1,
      "maxNumberInstances": 50
    },
    {
      "zoneId": "3cc2ecb989eee87557b0d532d4bb0",
      "priority": 2,
      "maxNumberInstances": 100
    }
  ],
  "sharedResources": true,
  "name": "Example-project",
  "description": "This is an example project",
  "id": "5944aacb-91de-4541-bb9e-ef2a5403f81b",
  "organizationId": "8327d53f-91ea-420a-8613-ba8f3149db95",
  "orgId": "8327d53f-91ea-420a-8613-ba8f3149db95",
  "_links": {
    "self": {
      "href": "/iaas/api/projects/edfd6f26-5d82-428f-96b0-b10ac5e4aca9"
    }
  }
}