Skip to content

Latest commit

 

History

History
187 lines (156 loc) · 4.9 KB

partitions.md

File metadata and controls

187 lines (156 loc) · 4.9 KB

Partitions API Reference

Partitions

The partitions allow you to group physical machines in a specific policy areas.

Method HTTP request Description
create POST /partitions/
list GET /partitions
get GET /partitions/:name
get GET /partitions/:name/hosts/
delete DELETE /partitions/:name
update PUT /partitions/:name/host/:hostname

Note: URIs relative to https://www.yourhostname.com/api/virtshell/v1, unless otherwise noted.

Resource representation

{
  "uuid": "ab8076c0-db91-11e2-82ce-0002a5d5c51b",
  "name": "development_co",
  "description": "Collection of servers oriented to development team in Colombia.", 
  "hosts": [ ... list of hosts associated with the partition ...],
  "created": {"at":"1429207233", "by":"92d30f0c-8c9c-11e5-8994-feff819cdc9f"},
  "modified": {"at":"1529207233", "by":"92d31132-8c9c-11e5-8994-feff819cdc9f"}
}

###Examples###

POST /api/virtshell/v1/partitions

Create a new partition.

curl -sv -X POST \
  -H 'accept: application/json' \
  -H 'X-VirtShell-Authorization: UserId:Signature' \
  -d '{
       "name": "development_co",
       "description": "Collection of servers oriented to development team in colombia."
      }' \
   'http://localhost:8080/api/virtshell/v1/partitions'

Response:

HTTP/1.1 200 OK
Content-Type: application/json
{ "create": "success" }

GET /api/virtshell/v1/partitions/

Get all partitions.

curl -sv -H 'accept: application/json' 
     -H 'X-VirtShell-Authorization: UserId:Signature' \ 
     'http://localhost:8080/api/virtshell/v1/partitions'

Response:

HTTP/1.1 200 OK
Content-Type: application/json
{
  "partitions": [
    {
      "uuid": "ab8076c0-db91-11e2-82ce-0002a5d5c51b",
      "name": "development_co",
      "description": "Collection of servers oriented to development team in colombia.",
      "hosts": [ ... list of hosts associated with the section ...],
      "created": {"at":"1429207233", "by":"92d30f0c-8c9c-11e5-8994-feff819cdc9f"},
      "modified": {"at":"1529207233", "by":"92d31132-8c9c-11e5-8994-feff819cdc9f"}
    },
    { 
      "uuid": "efa1777c-cad7-11e5-9956-625662870761",
      "name": "production_us_miami",
      "description": "Collection of servers oriented to production in us.",
      "hosts": [ ... list of hosts associated with the section ...],      
      "created": {"at":"1429207233", "by":"1a900cdc-cad8-11e5-9956-625662870761"},
      "modified": {"at":"1529207233", "by":"2163b554-cad8-11e5-9956-625662870761"}
    }    
  ]
}   

`GET /api/virtshell/v1/partitions/:name

Get an partitions.

curl -sv -H 'accept: application/json' 
     -H 'X-VirtShell-Authorization: UserId:Signature' \ 
     'http://<host>:<port>/api/virtshell/v1/partitions/development_co'

Response:

HTTP/1.1 200 OK
Content-Type: application/json
```json
{
  "uuid": "efa1777c-cad7-11e5-9956-625662870761",
  "name": "backend_development_04",
  "description": "Servers for backend of the company", 
  "hosts": [ ... list of hosts associated with the section ...],  
  "created": {"at":"1429207233", "by":"1a900cdc-cad8-11e5-9956-625662870761"},
  "modified": {"at":"1529207233", "by":"2163b554-cad8-11e5-9956-625662870761"}
}

`GET /api/virtshell/v1/partitions/:name/hosts

Get the hosts associated to the partitions.

curl -sv -H 'accept: application/json' 
     -H 'X-VirtShell-Authorization: UserId:Signature' \ 
     'http://<host>:<port>/api/virtshell/v1/partitions/backend_development_04/hosts'

Response:

HTTP/1.1 200 OK
Content-Type: application/json
```json
{
  "hosts": [ ... list of hosts associated with the section ...],  
}

DELETE /api/virtshell/v1/partitions/:name

Delete an existing partition.

curl -sv -X DELETE \
   -H 'accept: application/json' \
   -H 'X-VirtShell-Authorization: UserId:Signature' \
   'http://<host>:<port>/api/virtshell/v1/partitions/backend_development_04'

Response:

HTTP/1.1 200 OK
Content-Type: application/json
{ "delete": "success" }

PUT /api/virtshell/v1/partitions/:name/host/:hostname

Add a host to partition.

curl -sv -X PUT \
  -H 'accept: application/json' \
  -H 'X-VirtShell-Authorization: UserId:Signature' \
  'http://localhost:8080/virtshell/api/v1/partitions/:name/host/:hostname'

Response:

HTTP/1.1 200 OK
Content-Type: application/json
{ "add_host": "success" }