You can use the REST API reservation service to create an Amazon reservation.

Input

Use the supported input parameters to control the command output.

Parameter

Description

URL

https://$host/reservation-service/api/reservations

Method

Post

$host

Specifies the host name and fully qualified domain name or IP address of the vRealize Automation identity server.

$token

Specifies a valid HTTP bearer token with necessary credentials.

HTTP body

The HTTP body describes the reservation to create and calls the REST API used to create the reservation.

Compose the HTTP body using one of the following methods:

  • Copy the HTTP body from the JSON output from this example and edit the applicable field values to compose the HTTP body input for the command line.

  • Use the API commands in Syntax for Verifying a Reservation and Getting Reservation Details, remove the appropriate ID field from the HTTP response, and edit the field values to compose the HTTP body input for the command line.

Output

The output URL contains the new reservation ID.

Property

Description

status

When the reservation is successfully created, the HTTP response status is 201 created.

Header.Location

The HTTP response contains a Location attribute that is formatted as https://$host /reservation-service/api/reservations/$reservationId.

$reservationId

Specifies the new reservation ID.

curl Command

The following example command creates an Amazon reservation. The HTTP body is included as part of the command line input.

curl --insecure -H "Accept:application/json" 
-H "Authorization: Bearer $token" 
https://$host/reservation-service/api/reservations -d “
{
  "name": "TestEC2Reservation",
  "reservationTypeId": "Infrastructure.Reservation.Cloud.Amazon",
  "tenantId": "qe",
  "subTenantId": "a5d056be-3aa2-4fdd-ba1e-a3805f26f0e0",
  "enabled": true,
  "priority": 1,
  "reservationPolicyId": "34d2a612-718e-4814-96c5-225f7f5615a6",
  "alertPolicy": {
    "enabled": false,
    "frequencyReminder": 0,
    "emailBgMgr": true,
    "recipients": [
      
    ],
    "alerts": [
      {
        "alertPercentLevel": 80,
        "referenceResourceId": "machine",
        "id": "machine"
      }
    ]
  },
  "extensionData": {
    "entries": [
      {
        "key": "computeResource",
        "value": {
          "type": "entityRef",
          "componentId": null,
          "classId": "ComputeResource",
          "id": "9d1a3b5a-7162-4a5a-85b7-ec1b2824f554",
          "label": "EC2 841 Endpoint-us-east-1"
        }
      },
      {
        "key": "machineQuota",
        "value": {
          "type": "integer",
          "value": 0
        }
      },
      {
        "key": "securityGroups",
        "value": {
          "type": "multiple",
          "elementTypeId": "ENTITY_REFERENCE",
          "items": [
            {
              "type": "entityRef",
              "componentId": null,
              "classId": "AmazonSecurityGroup",
              "id": "10",
              "label": "default"
            }
          ]
        }
      },
      {
        "key": "loadBalancers",
        "value": {
          "type": "multiple",
          "elementTypeId": "ENTITY_REFERENCE",
          "items": [
            {
              "type": "entityRef",
              "componentId": null,
              "classId": "ElasticLoadBalancer",
              "id": "3",
              "label": "test1"
            }
          ]
        }
      },
      {
        "key": "locations",
        "value": {
          "type": "multiple",
          "elementTypeId": "ENTITY_REFERENCE",
          "items": [
            {
              "type": "entityRef",
              "componentId": null,
              "classId": "AvailabilityZone",
              "id": "10",
              "label": "us-east-1a"
            }
          ]
        }
      },
      {
        "key": "keyPairs",
        "value": {
          "type": "string",
          "value": "Per Provisioning Group"
        }
      }
    ]
  }
}”

JSON Output

The following sample location URL is displayed, including the new Amazon reservation ID.

Location: https://$host/reservation-service/api/reservations/3289b039-2a11-4ab4-a0bc-b583e4c6d085

Copy the output response into an XML editor for use in a future procedure, such as updating or deleting the reservation.