# 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)
application/json | CloudCredentials (JSON)

Response Codes
code | condition
--- | ---
404 | Key can't be empty
404 | Cloud provider's name 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/json | string (JSON)
application/xml | string (XML)

#### Example

##### Request

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

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

##### Response

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

    ...

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

Deletes all credentials. Use with caution !

Security Roles Allowed
  ADMIN

Response Codes
code | condition
--- | ---
200 | Credentiasl exist
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/credentials/cloud/all
    Accept: application/json

##### Response

    HTTP/1.1 200 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
--- | ---
200 | Credentials exist
401 | Bad credentials

Response Body
media type | data type | description
--- | --- | ---
application/json | array of string (JSON) | a list of stored IDs
application/json | array of string (JSON)
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/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",
      "cloudProviderName" : "ec2",
      "accessKeyId" : "AKIKIQY9K1ZUQ6M7YBSQ",
      "attributes" : {
        "property1" : { },
        "property2" : { }
      },
      "owner" : "user1",
      "id" : "58e3946e0fb4f562d84ba1ad",
      "timestamp" : 1499793079011
    }

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

Delete the cloud credentials

Security Roles Allowed
  ADMIN, USER

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

Response Codes
code | condition
--- | ---
200 | Credential exists
401 | Bad credentials

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

#### Example

##### Request

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

##### Response

    HTTP/1.1 200 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 | constraints
--- | --- | --- | ---
id | path | the id of the cloud credentials | required

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

Response Body
media type | data type | description
--- | --- | ---
application/json | CloudCredentials (JSON) | the cloud credentials
application/json | CloudCredentials (JSON)
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",
      "cloudProviderName" : "ec2",
      "accessKeyId" : "AKIKIQY9K1ZUQ6M7YBSQ",
      "attributes" : {
        "property1" : { },
        "property2" : { }
      },
      "owner" : "user1",
      "id" : "58e3946e0fb4f562d84ba1ad",
      "timestamp" : 1499793079011
    }

### 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 | constraints
--- | --- | --- | ---
id | path |  | required
file | query |  | required

Response Codes
code | condition
--- | ---
404 | Credential not found
400 | Did not upload file
200 | Key added to credential
401 | Bad credentials

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

#### Example

##### Request

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

##### Response

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

    ...