Skip to content

REST API

Trevor Baker edited this page Mar 11, 2014 · 12 revisions

General

Get JSON or XML data about cloud structures from Asgard

All of the "list" and "show" URLs can take a .json or .xml suffix to the end of the URL.

Determine if a cloud object exists, such as an auto scaling group or an AMI, programmatically

Do an HTTP GET request for the JSON data for the object. Ignore the response body. Check the response HTTP status code. 200 means the object exists. 404 means the object does not exist.

curl -sL -w "%{http_code}" http://asgardprod/us-east-1/autoScaling/show/helloworld-example.json -o /dev/null

List all the regions and accounts in JSON

http://asgardprod/region/list.json

Applications

List all the applications in production in JSON

http://asgardprod/application/list.json

List all the auto scaling groups of an application like helloworld in test

List all the production instances of an application like helloworld

Clusters and Auto Scaling Groups

Note: omit the checkHealth parameter from all examples below if Eureka service is not in use

List all the instances in a cluster

Get the public DNS name of a random instance in a given cluster

http://asgardprod/us-east-1/cluster/anyInstance/helloworld-example?field=publicDnsName

Get the public DNS name of a random instance in a given auto scaling group

http://asgardprod/us-east-1/autoScaling/anyInstance/helloworld-example?field=publicDnsName

Replace an instance in an ASG in one specific zone when the service is also running in other zones, programmatically

Change the size of an ASG programmatically

Let's say the ASG is helloworld-example-v000 and the new size you want is 4. curl -d "name=helloworld-example-v000&minAndMaxSize=4" http://asgardprod/us-east-1/cluster/resize

Start a rolling push of an AMI into an existing auto scaling group, programmatically

curl -d "name=helloworld-testeng&appName=helloworld&imageId=ami-dc9169b5&instanceType=m2.2xlarge&keyName=nf-test-keypair-a&selectedSecurityGroups=helloworld&selectedSecurityGroups=helloworld-frontend&kernelId=&ramdiskId=&relaunchCount=1&concurrentRelaunches=1&newestFirst=false&checkHealth=on&afterBootWait=30" http://asgardprod/us-east-1/push/startRolling

Change those values based on what you would use in the rolling push graphical user interface http://asgardprod/us-east-1/push/editRolling/helloworld-testeng

Create the next ASG in an existing cluster such as helloworld-example

curl -d "name=helloworld-example&imageId=ami-40788629&trafficAllowed=true&checkHealth=true" http://asgardprod/us-east-1/cluster/createNextGroup

Create an ASG named helloworld-integrationtest-US-A, in three AZs, with two security groups, with image ami-3178b958, programmatically

curl -d "appName=helloworld&stack=integrationtest&detail=US-A&min=0&desiredCapacity=0&max=0&defaultCooldown=10&healthCheckType=EC2&healthCheckGracePeriod=600&selectedZones=us-east-1a&selectedZones=us-east-1c&selectedZones=us-east-1d&azRebalance=enabled&imageId=ami-3178b958&keyName=nf-test-keypair-a&selectedSecurityGroups=helloworld&selectedSecurityGroups=helloworld-frontend&instanceType=m1.large&iamInstanceProfile=AcmeAnvilsIamInstanceProfile" http://asgardprod/us-east-1/autoScaling/save

Change the state of an ASG programmatically

There are no intelligent defaults for this operation, so for now you'll need to specify each property that already exists as well as the ones that you want to change, such as the selected zones.

curl -d "name=helloworld-nactest&launchConfiguration=helloworld-nactest-20110716221107&min=1&desiredCapacity=1&max=1&defaultCooldown=10&healthCheckType=EC2&healthCheckGracePeriod=600&selectedZones=us-west-1a&selectedZones=us-west-1c&azRebalance=enabled&launch=enabled&terminate=enabled&addToLoadBalancer=enabled" http://asgardprod/us-west-1/autoScaling/update

Disable traffic on an ASG programmatically

curl -d "name=helloworld-example-v004" http://asgardprod/us-east-1/cluster/deactivate

Delete an ASG programmatically

curl -d "name=helloworld-integrationtest" http://asgardprod/us-east-1/cluster/delete

That will do a 302 redirect to a long-running task to terminated instances, wait for auto scaling activities to cease, then delete the ASG and its Launch Configurations.

Images, Volumes, Snapshots

Delete an AMI programmatically

curl -d "id=ami-ffa6f1ba&ticket=" http://asgardprod/us-east-1/image/delete

Delete an EBS volume programmatically

curl -d "volumeId=vol-7de39216&ticket=" http://asgardprod/us-east-1/volume/delete

Delete an EBS snapshot programmatically

curl -d "snapshotId=snap-65ed8d04&ticket=" http://asgardprod/us-east-1/snapshot/delete

Launch orphaned instance

Launch a temporary instance of an AMI without an Auto Scaling Group

curl -d 'owner=jsmith&pricing=ondemand&imageId=ami-b75d92de&zone=us-east-1d&instanceType=m1.large&selectedGroups=helloworld&selectedGroups=helloworld-frontend' http://asgardprod/us-east-1/image/launch.json

Security Groups

List all security groups in a region such as us-east-1

http://asgardprod/us-east-1/security/list.json

Launch Configurations

List all launch configurations in a region such as us-east-1

http://asgardprod/us-east-1/launchConfiguration/list.json

Find Instances By Property

Find all the instances for a given set of private IP addresses

Find all the instances for a given set of instance IDs

Create an Application programmatically

curl -d "name=batgirl&type=Web+Service&description=Captures+bad+guys&owner=Barbara+Gordon&email=bgordon%40wayneenterprises.com&monitorBucketType=application&ticket=" http://asgardprod/application/save

Delete an Application programmatically

curl -d "name=batgirl&ticket=" http://nactest.netflix.com/application/delete
Clone this wiki locally