Curlコマンドを用いたREST APIの使用例は以下のとおりです。
サービスの一覧を取得する場合
> curl -X GET "http://192.168.0.100:3680/api/v1/services?name=system1" -H "Authorization: Bearer bb7a442e-cd39-4878-b3c3-9dde3382ae39" -H "Accept: application/json" -i<RETURN> % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 970 0 970 0 0 580 0 --:--:-- 0:00:01 --:--:-- 586 HTTP/1.1 200 OK X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/FUJITSU LIMITED/1.7) Server: GlassFish Server Open Source Edition 3.1.2.2 Content-Type: application/json Transfer-Encoding: chunked Date: Sun, 17 Dec 2017 05:37:25 GMT Cache-Control: proxy-revalidate Proxy-Connection: Keep-Alive Connection: Keep-Alive Age: 0 { "meta":{ "type":"INFO","code":"0001","message":"Processing has succeeded." }, "data":[ { "uuid":"165ee06c-393a-4c97-834a-fae16e9cce13", "serviceId":"ti-2z4o-aa", "name":"ti-system1", "type":"TI" },{ "uuid":"61b12d21-844c-41a9-ba99-ea5267b406c8", "serviceId":"system1-vm", "name":"system1-vm", "type":"VM", "instance":{"status":"running"} } ] }
サービスを作成する場合
> curl -X POST "http://192.168.0.100:3680/api/v1/services" -H "Authorization: Bearer bb7a442e-cd39-4878-b3c3-9dde3382ae39" -H "Accept: application/json" -H "Content-Type: application/json" -d '{"serviceId":"system2-vm","name":"system2","bizSystem":{"id":"bizsys001"},"type":"VM","memo":"Memo","instance":{"instanceType":{"id":"1901"},"systemdisk":{"systemdiskImage":{"id":"cent72_small_disk"}}}}' -i<RETURN> % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 277 0 76 100 201 9 25 0:00:08 0:00:08 --:--:-- 0 HTTP/1.1 202 Accepted X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/FUJITSU LIMITED/1.7) Server: GlassFish Server Open Source Edition 3.1.2.2 Content-Type: application/json Transfer-Encoding: chunked Date: Sun, 17 Dec 2017 08:26:26 GMT Cache-Control: proxy-revalidate Proxy-Connection: Keep-Alive Connection: Keep-Alive Age: 0 { "meta":{ "type":"INFO", "code":"0001", "message":"Processing has succeeded." } }
スナップショットを採取する場合
> curl -X POST "http://192.168.0.100:3680/api/v1/services/32ebe889-f546-4b9d-b66c-b94f65e00486/snapshots" -H "Authorization: Bearer bb7a442e-cd39-4878-b3c3-9dde3382ae39" -H "Accept: application/json" -H "Content-Type: application/json" -d '{"name": "system1-snapshot", "comment": "system1"}' -i<RETURN> % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 126 0 76 100 50 11 7 0:00:07 0:00:06 0:00:01 5 HTTP/1.1 202 Accepted X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/FUJITSU LIMITED/1.7) Server: GlassFish Server Open Source Edition 3.1.2.2 Content-Type: application/json Transfer-Encoding: chunked Date: Sun, 17 Dec 2017 07:55:45 GMT Cache-Control: proxy-revalidate Proxy-Connection: Keep-Alive Connection: Keep-Alive Age: 0 { "meta":{ "type":"INFO", "code":"0001", "message":"Processing has succeeded." } }