============ Introduction ============ cloudwang * a multi-cloud supported RESTful API that align with the HTTP principle. * an open source project that under the Apache License, Version 2.0. * utilizing the Dasein Cloud (http://dasein-cloud.sourceforge.net/). * programming for fun, welcome and open to all :-) I can be reachable by, * email <binbinwang118@gmail.com> * irc <freenode@Binbin> More info of CloudWang please see the document along with the repos, docs/CloudWang Multi-Cloud RESTful APIs (DRAFT).pdf ============ URI Modeling ============ > MachineImage RESTful Modeling http://host/rs/machineimage > HTTP Methods * GET http://host/rs/machineimage http://host/rs/machineimage?accountNumber=*** http://host/rs/machineimage/machineimage_id Accept: application/xml, application/json * HEAD http://host/rs/machineimage/machineimage_id Accept: application/xml, application/json * POST (Async Operation) http://host/rs/machineimage Accept: application/xml, application/json * PUT http://host/rs/machineimage/machineimage_id Accept: application/xml, application/json * DELETE http://host/rs/machineimage/machineimage_id Accept: application/xml, application/json > Object Modeling <cloudMachineImage> <cloudProvider>CloudWang-AWS-EC2</cloudProvider> <cloudName>AWS-EC2</cloudName> <cloudAccountNumber></cloudAccountNumber> <cloudRegionId>us-east-1</cloudRegionId> <machineImageMethod>listMachineImage</machineImageMethod> <machineImage machineImageId="0" status="ACTIVE" removable="true" sharable=”true” budget="0"> <providermachineImageId>ami-ab34dfgh</providermachineImageId> <name>Canonical Ubuntu Lucid 64-bit</name> <description>An Ubuntu image</description> <machineImageType>machine</machineImageType> <isPublic>false</isPublic> <architecture>I64</architecture> <platform>Red Hat</platform> <creationTimestamp>2010-07-14T13:18:27.947-0000</creationTimestamp> <providerOwnerId></providerOwnerId> <agentName>12</agentName> <software></software> </machineImage> <cloudMachineImage> ================= Async Job Service ================= To keep the pure HTTP principle, only POST method are allowed the async request. GET, DELETE and PUT methods can not be requested asynchronously. Sample to use the async job service, POST http://localhost:8080/cloudwang/rs/snapshot?asynch=true HTTP/1.1 202 Accepted Location: http://localhost:8080/cloudwang/rs/async/jobs/1316277771002-1 Then can perform GET, POST and DELETE operations on the job URL /async/jobs/{job-id}?wait={millisconds}|nowait=true GET if the job was completed, return whatever the JAX-RS resource method responses. if the job has not completed, return response code of 202, Accepted. POST read the job response. if the job was completed, will remove the job. DELETE clean up the job eg. POST http://localhost:8080/cloudwang/rs/async/jobs/1316277771002-1?wait=6000 ==== TEST ==== MachineImage (Template) curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/machineimage/ curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/machineimage/ curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/machineimage?accountNumber=*** curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/machineimage?accountNumber=*** curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/machineimage?keyword=***&platform=***&architecture=*** curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/machineimage?keyword=***&platform=***&architecture=*** curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/machineimage/FIX_ME_MachineImage_Id curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/machineimage/FIX_ME_MachineImage_Id curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/machineimage/FIX_ME_MachineImage_Id/share curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/machineimage/FIX_ME_MachineImage_Id/share curl -v -k -X HEAD http://localhost:8080/cloudwang/rs/machineimage/FIX_ME_MachineImage_Id curl -v -k -X HEAD http://localhost:8080/cloudwang/rs/machineimage/ curl -v -k -X POST -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudMachineImage><machineImage><description>Test</description><name>test createMachineImage</name><serverId>FIX-ME-ServerID</serverId></machineImage></cloudMachineImage>' http://localhost:8080/cloudwang/rs/machineimage/FIX_ME_MachineImage_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudMachineImage><machineImage><public>true</public></machineImage></cloudMachineImage>' http://localhost:8080/cloudwang/rs/machineimage/FIX_ME_MachineImage_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudMachineImage><machineImage><public>false</public></machineImage></cloudMachineImage>' http://localhost:8080/cloudwang/rs/machineimage/FIX_ME_MachineImage_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudMachineImage><machineImage><public>true</public><share>FIX_ME_ShareAccountId</share></machineImage></cloudMachineImage>' http://localhost:8080/cloudwang/rs/machineimage/FIX_ME_MachineImage_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudMachineImage><machineImage><public>false</public><share>FIX_ME_ShareAccountId</share></machineImage></cloudMachineImage>' http://localhost:8080/cloudwang/rs/machineimage/FIX_ME_MachineImage_Id curl -v -k -X DELETE http://localhost:8080/cloudwang/rs/machineimage/FIX_ME_MachineImage_Id Server(VirtualMachine) curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/server curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/server curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id curl -v -k -X GET http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id/console curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id/metrics curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id/metrics curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id/metrics?from=***&to=*** curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id/metrics?from=***&to=*** curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id/metrics?period=yes&from=***&to=*** curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id/metrics?period=yes&from=***&to=*** curl -v -k -X HEAD http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id curl -v -k -X HEAD http://localhost:8080/cloudwang/rs/server/ curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudServer><serverMethod>startServer</serverMethod></cloudServer>' http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudServer><serverMethod>stopServer</serverMethod></cloudServer>' http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudServer><serverMethod>rebootServer</serverMethod></cloudServer>' http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudServer><serverMethod>enableServerMetrics</serverMethod></cloudServer>' http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudServer><serverMethod>disableServerMetrics</serverMethod></cloudServer>' http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id curl -v -k -X POST -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudServer><server><providerMachineImageId>FIX_ME_MachineImage_Id</providerMachineImageId><product><cpuCount>2</cpuCount><description>Micro Instance/64-bit (t1.micro)</description><diskSizeInGb>1</diskSizeInGb><name>Micro Instance/64-bit (t1.micro)</name><productId>t1.micro</productId><ramInMb>613</ramInMb></product><name>test server</name><description>test create server</description><keyPair>FIX_ME_KeyPairName</keyPair><monitoring>enabled</monitoring><securityGroup>FIX_ME_SecurityGroupName</securityGroup></server></cloudServer>' http://localhost:8080/cloudwang/rs/server/ curl -v -k -X DELETE http://localhost:8080/cloudwang/rs/server/FIX_ME_Server_Id Volume curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/volume curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/volume curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/volume/FIX_ME_Volume_Id curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/volume/FIX_ME_Volume_Id curl -v -k -X HEAD http://localhost:8080/cloudwang/rs/volume/FIX_ME_Volume_Id curl -v -k -X HEAD http://localhost:8080/cloudwang/rs/volume/ curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudVolumes><volumeMethod>attachVolume</volumeMethod><volume><serverId>FIX_ME_ServerId</serverId><deviceId>FIX_ME_DeviceId</deviceId></volume></cloudVolumes>' http://localhost:8080/cloudwang/rs/volume/FIX_ME_Volume_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudVolumes><volumeMethod>detachVolume</volumeMethod></cloudVolumes>' http://localhost:8080/cloudwang/rs/volume/FIX_ME_Volume_Id curl -v -k -X POST -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudVolumes><volumeMethod>createVolume</volumeMethod><volume><zoneId>FIX_ME_ZoneId</zoneId><sizeInGb>FIX_ME_Volume_Size_INT</sizeInGb></volume></cloudVolumes>' http://localhost:8080/cloudwang/rs/volume/ curl -v -k -X DELETE http://localhost:8080/cloudwang/rs/volume/FIX_ME_Volume_Id Snapshot curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/snapshot curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/snapshot curl -v -k -X GET -H "Accept: application/xml" http://localhost:8080/cloudwang/rs/snapshot/FIX_ME_Snapshot_Id curl -v -k -X GET -H "Accept: application/json" http://localhost:8080/cloudwang/rs/snapshot/FIX_ME_Snapshot_Id curl -v -k -X HEAD http://localhost:8080/cloudwang/rs/snapshot/FIX_ME_Snapshot_Id curl -v -k -X HEAD http://localhost:8080/cloudwang/rs/snapshot/ curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudSnapshots><snapshot><public>true</public></snapshot></cloudSnapshots>' http://localhost:8080/cloudwang/rs/snapshot/FIX_ME_Snapshot_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudSnapshots><snapshot><public>false</public></snapshot></cloudSnapshots>' http://localhost:8080/cloudwang/rs/snapshot/FIX_ME_Snapshot_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudSnapshots><snapshot><public>true</public><shareProviderAccounts>FIX_ME_Shared_Account</shareProviderAccounts></snapshot></cloudSnapshots>' http://localhost:8080/cloudwang/rs/snapshot/FIX_ME_Snapshot_Id curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudSnapshots><snapshot><public>false</public><shareProviderAccounts>FIX_ME_Shared_Account</shareProviderAccounts></snapshot></cloudSnapshots>' http://localhost:8080/cloudwang/rs/snapshot/FIX_ME_Snapshot_Id curl -v -k -X POST -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudSnapshots><snapshot><volumeId>FIX_ME_VolumeId</volumeId><description>test created snapshot from volume</description></snapshot></cloudSnapshots>' http://localhost:8080/cloudwang/rs/snapshot curl -v -k -X DELETE http://localhost:8080/cloudwang/rs/snapshot/FIX_ME_Snapshot_Id Firewall (SecurityGroup) curl -v -k -X GET -H "Accept: application/xml" http://127.0.0.1:8080/cloudwang/rs/firewall/ curl -v -k -X GET -H "Accept: application/json" http://127.0.0.1:8080/cloudwang/rs/firewall/ curl -v -k -X GET -H "Accept: application/xml" http://127.0.0.1:8080/cloudwang/rs/firewall/FIX_ME_FirewallId curl -v -k -X GET -H "Accept: application/json" http://127.0.0.1:8080/cloudwang/rs/firewall/FIX_ME_FirewallId curl -v -k -X HEAD http://localhost:8080/cloudwang/rs/firewall/FIX_ME_FirewallId curl -v -k -X HEAD http://localhost:8080/cloudwang/rs/firewall/ curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudFirewall><firewallMethod>removeFirewallRules</firewallMethod><firewall><firewallRules><protocol>TCP</protocol><cidr>0.0.0.0/0</cidr><startPort>22</startPort><endPort>22</endPort></firewallRules></firewall></cloudFirewall>' http://localhost:8080/cloudwang/rs/firewall/FIX_ME_FirewallId curl -v -k -X PUT -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudFirewall><firewallMethod>addFirewallRules</firewallMethod><firewall><firewallRules><protocol>TCP</protocol><cidr>192.168.1/25</cidr><startPort>22</startPort><endPort>80</endPort></firewallRules></firewall></cloudFirewall>' http://localhost:8080/cloudwang/rs/firewall/FIX_ME_FirewallId curl -v -k -X POST -H "Content-Type: application/xml" --data '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cloudFirewall><firewallMethod>addFirewallRules</firewallMethod><firewall><name>test firewall</name><description>test create firewall</description></firewall></cloudFirewall>' http://localhost:8080/cloudwang/rs/firewall curl -v -k -X DELETE http://localhost:8080/cloudwang/rs/firewall/FIX_ME_FirewallId