Skip to content

Instantly share code, notes, and snippets.

@leonidlm
Created May 15, 2014 23:41
Show Gist options
  • Save leonidlm/e3804a095b88e2348067 to your computer and use it in GitHub Desktop.
Save leonidlm/e3804a095b88e2348067 to your computer and use it in GitHub Desktop.
SoftLayer basic curl API interactions
#
# List all the possible options for creating a VirtualGuest
#
curl https://<user>:<api_key>@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/getCreateObjectOptions.json | python -mjson.tool
#
# Create a new VirtualGuest
#
curl -X POST --data @/tmp/post https://<user>:<api_key>@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/createObject
/tmp/post
{
"parameters":[
{
"hostname": "test",
"domain": "mydomain.com",
"datacenter": {
"name": "ams01"
},
"startCpus": 1,
"maxMemory": 1024,
"hourlyBillingFlag": true,
"blockDevices": [
{
"device": "0",
"diskImage": {
"capacity": 25
}
}
],
"localDiskFlag": false,
"networkComponents": [
{
"maxSpeed": 10
}
],
"operatingSystemReferenceCode": "CENTOS_6_64"
}
]
}
#
# List all configured VirtualGuests for the specified account
#
curl https://<user>:<api_key>@api.softlayer.com/rest/v3/SoftLayer_Account/getHourlyVirtualGuests | python -mjson.tool
#
# Create an flex image based on globalIdentifier returned by the previous command
#
curl -X POST --data @/tmp/capture https://<user>:<api_key>@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/6314ba47-47f1-4541-8bd7-b3f59b8d512b/captureImage
/tmp/capture
{
"parameters":[
{
"description": "first capture",
"name": "first",
"summary": "some"
}
]
}
@edwardstudy
Copy link

That's great! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment