# UserController Resource

This controller is responsible for handling user accounts

### GET /manager/v1.0/user/all

Security Roles Allowed
  ADMIN

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

Response Body
media type | data type
--- | ---
application/json | array of User (JSON)
application/xml | list of user (XML)

#### Example

##### Request

    GET /manager/v1.0/user/all
    Accept: application/json

##### Response

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

    [ {
      "roles" : [ "[\"ADMIN\",\"USER\"]", "..." ],
      "username" : "user",
      "accountNonExpired" : true,
      "credentialsNonExpired" : true,
      "password" : "...",
      "enabled" : true,
      "accountNonLocked" : true,
      "id" : "58e3946e0fb4f562d84ba1ad"
    } ]

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

Gets the IDs of all the stored users

Security Roles Allowed
  ADMIN

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

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

#### Example

##### Request

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

##### Response

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

    ...

### POST /manager/v1.0/user/modify

Security Roles Allowed
  ADMIN

Request Body
media type | data type
--- | ---
application/json | User (JSON)
application/xml | user (XML)

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

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

#### Example

##### Request

    POST /manager/v1.0/user/modify
    Content-Type: application/json
    Accept: application/json

    {
      "roles" : [ "[\"ADMIN\",\"USER\"]", "..." ],
      "username" : "user",
      "accountNonExpired" : true,
      "credentialsNonExpired" : true,
      "password" : "...",
      "enabled" : true,
      "accountNonLocked" : true,
      "id" : "58e3946e0fb4f562d84ba1ad"
    }

##### Response

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

    ...

### POST /manager/v1.0/user/register

Register new user. A normal user cannot create accounts, only the user with the 'ADMIN' role can do that.

Security Roles Allowed
  ADMIN

Request Body
media type | data type
--- | ---
application/json | User (JSON)
application/xml | user (XML)

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

Response Body
media type | data type | description
--- | --- | ---
application/json | string (JSON) | Response on success: The ID of the newly register user. Response on fail: If the user name already exists, or the user name is 'null' or the password is 'null' there will be a 'BadRequestException'
application/xml | string (XML)

#### Example

##### Request

    POST /manager/v1.0/user/register
    Content-Type: application/json
    Accept: application/json

    {
      "roles" : [ "[\"ADMIN\",\"USER\"]", "..." ],
      "username" : "user",
      "accountNonExpired" : true,
      "credentialsNonExpired" : true,
      "password" : "...",
      "enabled" : true,
      "accountNonLocked" : true,
      "id" : "58e3946e0fb4f562d84ba1ad"
    }

##### Response

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

    ...

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

Deletes a user

Security Roles Allowed
  ADMIN

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

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

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

#### Example

##### Request

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

##### Response

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

    ...

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

Gets the user.

Security Roles Allowed
  ADMIN

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

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

Response Body
media type | data type | description
--- | --- | ---
application/json | User (JSON) | the requested user.
application/xml | user (XML)

#### Example

##### Request

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

##### Response

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

    {
      "roles" : [ "[\"ADMIN\",\"USER\"]", "..." ],
      "username" : "user",
      "accountNonExpired" : true,
      "credentialsNonExpired" : true,
      "password" : "...",
      "enabled" : true,
      "accountNonLocked" : true,
      "id" : "58e3946e0fb4f562d84ba1ad"
    }