# ProvisionController Resource

This controller is responsible for obtaining resources from cloud providers based the plan generated by the planner

### DELETE /user/v1.0/provisioner/all

Deletes all entries. Use with caution !

Security Roles Allowed
  ADMIN

Response Codes
code | condition
--- | ---
200 | Successful delete
401 | Bad credentials

Response Body
media type | data type
--- | ---
application/json | string (JSON)
application/json | string (JSON)
application/xml | string (XML)

#### Example

##### Request

    DELETE /user/v1.0/provisioner/all
    Accept: application/json

##### Response

    HTTP/1.1 200 Looks Good
    Content-Type: application/json

    ...

### GET /user/v1.0/provisioner/ids

Gets the IDs of all the stored ProvisionRequest

Security Roles Allowed
  ADMIN, USER

Response Codes
code | condition
--- | ---
200 | Successful query
401 | Bad credentials

Response Body
media type | data type | description
--- | --- | ---
application/json | array of string (JSON) | a list of IDs
application/json | array of string (JSON)
application/xml | list of string (XML)

#### Example

##### Request

    GET /user/v1.0/provisioner/ids
    Accept: application/json

##### Response

    HTTP/1.1 200 Looks Good
    Content-Type: application/json

    ...

### GET /user/v1.0/provisioner/providers

Gets the supported providers

Security Roles Allowed
  ADMIN, USER

Response Codes
code | condition
--- | ---
404 | object not found
200 | object exists
401 | Bad credentials

Response Body
media type | data type | description
--- | --- | ---
application/json | array of string (JSON) | the supported providers
application/json | array of string (JSON)
application/xml | list of string (XML)

#### Example

##### Request

    GET /user/v1.0/provisioner/providers
    Accept: application/json

##### Response

    HTTP/1.1 200 Looks Good
    Content-Type: application/json

    ...

### POST /user/v1.0/provisioner/provision

Provision the resources specified by a plan.

Security Roles Allowed
  ADMIN, USER

Request Body
media type | data type
--- | ---
application/json | ProvisionRequest (JSON)
application/json | ProvisionRequest (JSON)
application/xml | provisionRequest (XML)

Response Codes
code | condition
--- | ---
400 | Plan not found or credentials not found
200 | provision success
401 | Bad credentials

Response Body
media type | data type | description
--- | --- | ---
application/json | string (JSON) | The ID of the provisioned ProvisionRequest
application/json | string (JSON)
application/xml | string (XML)

#### Example

##### Request

    POST /user/v1.0/provisioner/provision
    Content-Type: application/json
    Accept: application/json

    {
      "cloudCredentialsIDs" : [ "58e3946e0fb4f562d84ba1ad", "..." ],
      "planID" : "ASedsfd46b4fDFd83ba1q",
      "userKeyPairIDs" : [ "ASedsfd46b4fFd344a1A", "..." ],
      "deployerKeyPairIDs" : [ "...", "..." ],
      "keyValue" : {
        "property1" : { },
        "property2" : { }
      },
      "owner" : "user1",
      "id" : "58e3946e0fb4f562d84ba1ad",
      "timestamp" : 1499793079011
    }

##### Response

    HTTP/1.1 200 Looks Good
    Content-Type: application/json

    ...

### GET /user/v1.0/provisioner/sample

Security Roles Allowed
  ADMIN, USER

Response Codes
code | condition
--- | ---
401 | Bad credentials

Response Body
media type | data type
--- | ---
application/json | ProvisionRequest (JSON)
application/json | ProvisionRequest (JSON)
application/xml | provisionRequest (XML)

#### Example

##### Request

    GET /user/v1.0/provisioner/sample
    Accept: application/json

##### Response

    HTTP/1.1 200 Looks Good
    Content-Type: application/json

    {
      "cloudCredentialsIDs" : [ "58e3946e0fb4f562d84ba1ad", "..." ],
      "planID" : "ASedsfd46b4fDFd83ba1q",
      "userKeyPairIDs" : [ "ASedsfd46b4fFd344a1A", "..." ],
      "deployerKeyPairIDs" : [ "...", "..." ],
      "keyValue" : {
        "property1" : { },
        "property2" : { }
      },
      "owner" : "user1",
      "id" : "58e3946e0fb4f562d84ba1ad",
      "timestamp" : 1499793079011
    }

### POST /user/v1.0/provisioner/scale

Security Roles Allowed
  ADMIN, USER

Request Body
media type | data type
--- | ---
application/json | ScaleRequest (JSON)
application/json | ScaleRequest (JSON)
application/xml | scaleRequest (XML)

Response Codes
code | condition
--- | ---
401 | Bad credentials

Response Body
media type | data type
--- | ---
application/json | string (JSON)
application/json | string (JSON)
application/xml | string (XML)

#### Example

##### Request

    POST /user/v1.0/provisioner/scale
    Content-Type: application/json
    Accept: application/json

    {
      "scaleTargetID" : "58e3946e0fb4f562d84ba1ad",
      "scaleTargetName" : "telegreen_db",
      "numOfInstances" : 5,
      "owner" : "user1",
      "id" : "58e3946e0fb4f562d84ba1ad",
      "timestamp" : 1499793079011
    }

##### Response

    HTTP/1.1 201 Looks Good
    Content-Type: application/json

    ...

### DELETE /user/v1.0/provisioner/{id}

Deletes the ProvisionRequest

Security Roles Allowed
  ADMIN, USER

Request Parameters
name | type | description | constraints
--- | --- | --- | ---
id | path |  | required

Response Codes
code | condition
--- | ---
404 | object not found
200 | delete successful
401 | Bad credentials

Response Body
media type | data type | description
--- | --- | ---
application/json | string (JSON) | the ID of the deleted ProvisionRequest
application/json | string (JSON)
application/xml | string (XML)

#### Example

##### Request

    DELETE /user/v1.0/provisioner/{id}
    Accept: application/json

##### Response

    HTTP/1.1 200 Looks Good
    Content-Type: application/json

    ...

### GET /user/v1.0/provisioner/{id}

Gets the ProvisionRequest

Security Roles Allowed
  ADMIN, USER

Request Parameters
name | type | description | constraints
--- | --- | --- | ---
id | path |  | required

Response Codes
code | condition
--- | ---
404 | object not found
200 | object exists
401 | Bad credentials

Response Body
media type | data type | description
--- | --- | ---
application/json | ProvisionResponse (JSON) | the requested ProvisionRequest
application/json | ProvisionResponse (JSON)
application/xml | provisionResponse (XML)

#### Example

##### Request

    GET /user/v1.0/provisioner/{id}
    Accept: application/json

##### Response

    HTTP/1.1 200 Looks Good
    Content-Type: application/json

    {
      "deployParameters" : [ {
        "IP" : "52.73.245.157",
        "user" : "vm_user",
        "role" : "slave"
      }, {
        "IP" : "...",
        "user" : "...",
        "role" : "..."
      } ],
      "cloudKeyPairIDs" : [ "...", "..." ],
      "cloudCredentialsIDs" : [ "58e3946e0fb4f562d84ba1ad", "..." ],
      "planID" : "ASedsfd46b4fDFd83ba1q",
      "userKeyPairIDs" : [ "ASedsfd46b4fFd344a1A", "..." ],
      "deployerKeyPairIDs" : [ "...", "..." ],
      "keyValue" : {
        "property1" : { },
        "property2" : { }
      },
      "owner" : "user1",
      "id" : "58e3946e0fb4f562d84ba1ad",
      "timestamp" : 1499793079011
    }

### POST /user/v1.0/provisioner/post/provision

Updates or creates a new ProvisionResponse.

Security Roles Allowed
  ADMIN, USER

Request Body
media type | data type
--- | ---
application/json | ProvisionResponse (JSON)
application/json | ProvisionResponse (JSON)
application/xml | provisionResponse (XML)

Response Codes
code | condition
--- | ---
400 | Plan not found or credentials not found or something important
200 | provision success
401 | Bad credentials

Response Body
media type | data type
--- | ---
application/json | string (JSON)
application/json | string (JSON)
application/xml | string (XML)

#### Example

##### Request

    POST /user/v1.0/provisioner/post/provision
    Content-Type: application/json
    Accept: application/json

    {
      "deployParameters" : [ {
        "IP" : "52.73.245.157",
        "user" : "vm_user",
        "role" : "slave"
      }, {
        "IP" : "...",
        "user" : "...",
        "role" : "..."
      } ],
      "cloudKeyPairIDs" : [ "...", "..." ],
      "cloudCredentialsIDs" : [ "58e3946e0fb4f562d84ba1ad", "..." ],
      "planID" : "ASedsfd46b4fDFd83ba1q",
      "userKeyPairIDs" : [ "ASedsfd46b4fFd344a1A", "..." ],
      "deployerKeyPairIDs" : [ "...", "..." ],
      "keyValue" : {
        "property1" : { },
        "property2" : { }
      },
      "owner" : "user1",
      "id" : "58e3946e0fb4f562d84ba1ad",
      "timestamp" : 1499793079011
    }

##### Response

    HTTP/1.1 200 Looks Good
    Content-Type: application/json

    ...