Create and Update a Blueprint

To create a blueprint, you make a POST request. The request body includes the name of the new blueprint and the project ID of an existing project. To update a blueprint, you make a PUT request that changes one of the properties of the blueprint.

Before creating a blueprint, you get a list of blueprints to verify that the blueprint you plan to create does not already exist. After a blueprint is created, you can update it to change the blueprint definition.

Prerequisites

Procedure

  1. Assign the project ID variable.
    project_id='<your_project_id>'
  2. Assign your blueprint name variable.
    blueprint_name='<your_blueprint_name>'

    your_blueprint_name is a name that you choose.

  3. Get a list of blueprints.
    curl -X GET $url/blueprint/api/blueprints -H "Authorization: Bearer $access_token"  | jq "."
  4. To verify that the blueprint you plan to create is not already listed, examine the response.
  5. Validate the blueprint before creating it.
    curl -X POST \
      $url/blueprint/api/blueprint-validation?apiVersion=$api_version \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token"  \
      -d '{
        "name" : "'"$blueprint_name"'",
        "description" : "Basic Cloud Machine blueprint",
        "content" : "formatVersion: 1\ninputs:\n  flavor:\n    type: string\n    title: Flavor\n    description: Flavor Mapping Name\n  image:\n    type: string\n    title: Image\n    description: Image Mapping Name\n  count:\n    type: integer\n    minimum: 1\n    default: 1\n    maximum: 2\n    title: Number of Instances\nresources:\n  BasicCloudMachine:\n    type: Cloud.Machine\n    properties:\n      name: BasicCloudMachine\n      flavor: '\''${input.flavor}'\''      \n      image: '\''${input.image}'\''\n      count: '\''${input.count}'\''",
        "projectId" : "'"$project_id"'",
        "requestScopeOrg": false
    }' | jq "."
  6. Examine the response to confirm that you see "valid":true.
  7. Create a new blueprint.
    curl -X POST \
      $url/blueprint/api/blueprints?apiVersion=$api_version \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token"  \
      -d '{
        "name" : "'"$blueprint_name"'",
        "description" : "Basic Cloud Machine blueprint",
        "content" : "formatVersion: 1\ninputs:\n  flavor:\n    type: string\n    title: Flavor\n    description: Flavor Mapping Name\n  image:\n    type: string\n    title: Image\n    description: Image Mapping Name\n  count:\n    type: integer\n    minimum: 1\n    default: 1\n    maximum: 2\n    title: Number of Instances\nresources:\n  BasicCloudMachine:\n    type: Cloud.Machine\n    properties:\n      name: BasicCloudMachine\n      flavor: '\''${input.flavor}'\''      \n      image: '\''${input.image}'\''\n      count: '\''${input.count}'\''",
        "projectId" : "'"$project_id"'",
        "requestScopeOrg": false
    }' | jq "."
  8. Examine the response and record the ID of your newly created blueprint.
  9. Assign the blueprint ID variable.
    blueprint_id='<your_blueprint_id>'

    your_blueprint_id is the ID of the new blueprint that you created.

  10. To verify that the blueprint has been created, get a list of blueprints and filter for your_blueprint_name.
    curl -X GET $url/blueprint/api/blueprints?name=$blueprint_name -H "Authorization: Bearer $access_token"  | jq "."
  11. (Optional) To update the blueprint, use a PUT request and specify your_blueprint_id.
    curl -X PUT \
      $url/blueprint/api/blueprints/$blueprint_id?apiVersion=$api_version \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token"  \
      -d '{
        "name" : "'"$blueprint_name"'",
        "description" : "Basic Cloud Machine blueprint",
        "content" : "formatVersion: 1\ninputs:\n  flavor:\n    type: string\n    title: Flavor\n    description: Flavor Mapping Name\n  image:\n    type: string\n    title: Image\n    description: Image Mapping Name\n  count:\n    type: integer\n    minimum: 1\n    default: 1\n    maximum: 2\n    title: Number of Instances\nresources:\n  BasicCloudMachine:\n    type: Cloud.Machine\n    properties:\n      name: BasicCloudMachine\n      flavor: '\''${input.flavor}'\''      \n      image: '\''${input.image}'\''\n      count: '\''${input.count}'\''\n      tags: [\n        {\n          \"key\": \"env\",\n          \"value\": \"prod\"\n        }\n      ]\n",
        "projectId" : "'"$project_id"'",
        "requestScopeOrg": false
    }' | jq "."

Example: Create a Blueprint and Update it

Create a blueprint named MyExampleBlueprint. This example assumes that MyExampleBlueprint does not already exist.

Assign variables.

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

Validate the blueprint.

$ curl -X POST \
  $url/blueprint/api/blueprint-validation?apiVersion=$api_version \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $access_token"  \
  -d '{
    "name" : "'"$blueprint_name"'",
    "description" : "Basic Cloud Machine blueprint",
    "content" : "formatVersion: 1\ninputs:\n  flavor:\n    type: string\n    title: Flavor\n    description: Flavor Mapping Name\n  image:\n    type: string\n    title: Image\n    description: Image Mapping Name\n  count:\n    type: integer\n    minimum: 1\n    default: 1\n    maximum: 2\n    title: Number of Instances\nresources:\n  BasicCloudMachine:\n    type: Cloud.Machine\n    properties:\n      name: BasicCloudMachine\n      flavor: '\''${input.flavor}'\''      \n      image: '\''${input.image}'\''\n      count: '\''${input.count}'\''",
    "projectId" : "'"$project_id"'",
    "requestScopeOrg": false
}' | jq "."

Examine the response to confirm that "valid":true.

{
  "valid": true,
  "validationMessages": []
}

Create the blueprint.

$ curl -X POST \
  $url/blueprint/api/blueprints?apiVersion=$api_version \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $access_token"  \
  -d '{
    "name" : "'"$blueprint_name"'",
    "description" : "Basic Cloud Machine blueprint",
    "content" : "formatVersion: 1\ninputs:\n  flavor:\n    type: string\n    title: Flavor\n    description: Flavor Mapping Name\n  image:\n    type: string\n    title: Image\n    description: Image Mapping Name\n  count:\n    type: integer\n    minimum: 1\n    default: 1\n    maximum: 2\n    title: Number of Instances\nresources:\n  BasicCloudMachine:\n    type: Cloud.Machine\n    properties:\n      name: BasicCloudMachine\n      flavor: '\''${input.flavor}'\''      \n      image: '\''${input.image}'\''\n      count: '\''${input.count}'\''",
    "projectId" : "'"$project_id"'",
    "requestScopeOrg": false
}' | jq "."

The response from your request to create the blueprint shows the blueprint ID.

{
  "id": "1f170637-81a3-4257-b1cd-b2219ee8034c",
  "createdAt": "2019-10-10T23:43:27.001Z",
  ...
  "selfLink": "/blueprint/api/blueprints/1f170637-81a3-4257-b1cd-b2219ee8034c"
  ...
}

Assign the blueprint ID variable.

$ blueprint_id='1f170637-81a3-4257-b1cd-b2219ee8034c'

Update the blueprint to set a tag on the machine properties in the blueprint.

$ curl -X PUT \
  $url/blueprint/api/blueprints/$blueprint_id?apiVersion=$api_version \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $access_token"  \
  -d '{
    "name" : "'"$blueprint_name"'",
    "description" : "Basic Cloud Machine blueprint",
    "content" : "formatVersion: 1\ninputs:\n  flavor:\n    type: string\n    title: Flavor\n    description: Flavor Mapping Name\n  image:\n    type: string\n    title: Image\n    description: Image Mapping Name\n  count:\n    type: integer\n    minimum: 1\n    default: 1\n    maximum: 2\n    title: Number of Instances\nresources:\n  BasicCloudMachine:\n    type: Cloud.Machine\n    properties:\n      name: BasicCloudMachine\n      flavor: '\''${input.flavor}'\''      \n      image: '\''${input.image}'\''\n      count: '\''${input.count}'\''\n      tags: [\n        {\n          \"key\": \"env\",\n          \"value\": \"prod\"\n        }\n      ]\n",
    "projectId" : "'"$project_id"'",
    "requestScopeOrg": false
}' | jq "."

What to do next

Use the blueprint ID to version and release the blueprint to a catalog.