# CloudCredentialsController Resource

This controller is responsible for handling CloudCredentials. CloudCredentials are a represntation of the credentials that are used by the provisoner to request for resources (VMs)

### POST /user/v1.0/credentials/cloud

Post the cloud credentials.

Security Roles Allowed
  ADMIN, USER

Request Body
media type | data type
--- | ---
application/json | CloudCredentials (JSON)

Response Codes
code | condition
--- | ---
400 | Access key ID can't be empty
200 | At least one key ID is posted
401 | Bad credentials

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

#### Example

##### Request

    POST /user/v1.0/credentials/cloud
    Content-Type: application/json
    Accept: application/json

    {
      "secretKey" : "7A7vo19ffdfa4SAsA6gsF5Fgbfb5rtwY6hBxtYt12",
      "attributes" : {
        "property1" : { },
        "property2" : { }
      },
      "cloudProviderName" : "ec2",
      "accessKeyId" : "AKIKIQY9K1ZUQ6M7YBSQ",
      "timestamp" : 12345,
      "id" : "58e3946e0fb4f562d84ba1ad",
      "owner" : "user1"
    }

##### Response

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

    ...

### DELETE /user/v1.0/credentials/cloud/all

Security Roles Allowed
  ADMIN

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

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

#### Example

##### Request

    DELETE /user/v1.0/credentials/cloud/all
    Accept: application/json

##### Response

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

    ...

### GET /user/v1.0/credentials/cloud/ids

Gets all the IDs of the stored cloud credentials

Security Roles Allowed
  ADMIN, USER

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

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

#### Example

##### Request

    GET /user/v1.0/credentials/cloud/ids
    Accept: application/json

##### Response

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

    ...

### GET /user/v1.0/credentials/cloud/sample

Security Roles Allowed
  ADMIN, USER

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

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

#### Example

##### Request

    GET /user/v1.0/credentials/cloud/sample
    Accept: application/json

##### Response

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

    {
      "secretKey" : "7A7vo19ffdfa4SAsA6gsF5Fgbfb5rtwY6hBxtYt12",
      "attributes" : {
        "property1" : { },
        "property2" : { }
      },
      "cloudProviderName" : "ec2",
      "accessKeyId" : "AKIKIQY9K1ZUQ6M7YBSQ",
      "timestamp" : 12345,
      "id" : "58e3946e0fb4f562d84ba1ad",
      "owner" : "user1"
    }

### DELETE /user/v1.0/credentials/cloud/{id}

Delete the cloud credentials

Security Roles Allowed
  ADMIN, USER

Request Parameters
name | type | description
--- | --- | ---
id | path | the id of the cloud credentials

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

Response Body
media type | data type | description
--- | --- | ---
application/json | string (JSON) | the id of the cloud credentials
application/xml | string (XML)

#### Example

##### Request

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

##### Response

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

    ...

### GET /user/v1.0/credentials/cloud/{id}

Get the cloud credentials

Security Roles Allowed
  ADMIN, USER

Request Parameters
name | type | description
--- | --- | ---
id | path | the id of the cloud credentials

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

Response Body
media type | data type | description
--- | --- | ---
application/json | CloudCredentials (JSON) | the cloud credentials
application/xml | cloudCredentials (XML)

#### Example

##### Request

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

##### Response

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

    {
      "secretKey" : "7A7vo19ffdfa4SAsA6gsF5Fgbfb5rtwY6hBxtYt12",
      "attributes" : {
        "property1" : { },
        "property2" : { }
      },
      "cloudProviderName" : "ec2",
      "accessKeyId" : "AKIKIQY9K1ZUQ6M7YBSQ",
      "timestamp" : 12345,
      "id" : "58e3946e0fb4f562d84ba1ad",
      "owner" : "user1"
    }

### POST /user/v1.0/credentials/cloud/upload/{id}

Upload the login keys for a cloud provider. The cloud credentials have to be created

Security Roles Allowed
  ADMIN, USER

Request Parameters
name | type | description
--- | --- | ---
id | path |
file | query |

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

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

#### Example

##### Request

    POST /user/v1.0/credentials/cloud/upload/{id}
    Accept: application/json

##### Response

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

    ...