Dennis
Dennis

Reputation: 51

How can I create a softlayer public image via the api?

I would like to automate the following ui process:

  1. Devices->Manage->Images
  2. Select image
  3. Actions->Create Public Image
  4. Fill out fields, select all locations
  5. Click Create

Can this be done via the api? Can you point me to some documentation detailing this?

Upvotes: 0

Views: 96

Answers (1)

F.Ojeda
F.Ojeda

Reputation: 728

To create a public image by api you can use the following rest api:

Method: POST

https://[username]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/[imageId]/createPublicArchiveTransaction

Body: Json

{
  "parameters": [
      "groupName",
      "summary",
      "note",
        [
          {
            "id": 265592
          },
          {
            "id": 1555995
          }
        ]
  ]
}

Reference: https://softlayer.github.io/reference/services/SoftLayer_Virtual_Guest_Block_Device_Template_Group/createPublicArchiveTransaction/

To get the private images Ids available in your account use this rest example:

Method: GET

https://[username]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_Account/getPrivateBlockDeviceTemplateGroups

To get the location ids available for the image use the following rest api:

Method: GET

https://[username]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/[imageId]/getStorageLocations

Or you can use this other rest example to get the locations:

Method: GET

https://[username]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_Location/getDatacenters

Upvotes: 1

Related Questions