.. _PUT Service ostor-users:

PUT Service ostor-users
-----------------------

Description
~~~~~~~~~~~

Creates a new user or generates/revokes access key pairs of existing users.

Requests
~~~~~~~~

Syntax
^^^^^^

::

    PUT /?ostor-users&emailAddress=<value> HTTP/1.1
    Host: s3.amazonaws.com
    Date: <date>
    Authorization: <authorization_string>

::

    PUT /?ostor-users&emailAddress=<value>&genKey HTTP/1.1
    Host: s3.amazonaws.com
    Date: <date>
    Authorization: <authorization_string>

::

    PUT /?ostor-users&emailAddress=<value>&revokeKey=<value> HTTP/1.1
    Host: s3.amazonaws.com
    Date: <date>
    Authorization: <authorization_string>

Parameters
^^^^^^^^^^

+------------------+-------------------------------------------------------+----------+
| Parameter        | Description                                           | Required |
+==================+=======================================================+==========+
| ``emailAddress`` | User email address.                                   | Yes      |
|                  |                                                       |          |
|                  | Type: string.                                         |          |
|                  |                                                       |          |
|                  | Default value: none.                                  |          |
+------------------+-------------------------------------------------------+----------+
| ``genKey``       | Generates a new access key pair for the user. A user  | No       |
|                  | can only have two key pairs.                          |          |
|                  |                                                       |          |
|                  | Type: flag.                                           |          |
|                  |                                                       |          |
|                  | Default value: none.                                  |          |
+------------------+-------------------------------------------------------+----------+
| ``revokeKey``    | Removes the access key pair that corresponds to the   | No       |
|                  | specified access key.                                 |          |
|                  |                                                       |          |
|                  | Type: string.                                         |          |
|                  |                                                       |          |
|                  | Default value: none.                                  |          |
+------------------+-------------------------------------------------------+----------+

If neither ``genKey`` nor ``revokeKey`` are set, a new user with the specified email will be created.

Headers
^^^^^^^

This implementation uses only common request headers.

Responses
~~~~~~~~~

Headers
^^^^^^^

This implementation uses only common response headers.

Body
^^^^

If a new user is created or a key is generated, the body is a JSON dictionary with user information.

::

    {
    "UserEmail" : "<email>",
    "UserId" : "<id>",
    "AWSAccessKeys : [
    {
    "AWSAccessKeyId" : "<access_key>",
    "AWSSecretAccessKey" : "<secret_key>"
    }]
    }

If a key is revoked, the body is empty.

Examples
~~~~~~~~

Sample Request #1
^^^^^^^^^^^^^^^^^

Creates a user with the email ``test@test.test``.

::

    PUT /?ostor-users&emailAddress=test@test.test HTTP/1.1
    Host: s3.amazonaws.com
    Date: Thu, 07 Apr 2016 16:01:03 GMT +3:00
    Authorization: <authorization_string>

Sample Response #1
^^^^^^^^^^^^^^^^^^

::

    HTTP/1.1 200 OK
    x-amz-req-time-micros : 186132
    Transfer-encoding : chunked
    Server : nginx/1.8.1
    Connection : keep-alive
    X-amz-request-id : 80000000000000030003746059efad68
    Date : Thu, 07 Apr 2016 13:01:08 GMT
    Content-type : application/json
    
    {
    "UserEmail": "test@test.test",
    "UserId": "a721fc1a64f13a05",
    "AWSAccessKeys": [
    {
    "AWSAccessKeyId": "a721fc1a64f13a05OQF4",
    "AWSSecretAccessKey": "VtzYY4ZHWYzbWLUrRMSzVhB07UvD6Z5nGsAPtESV"
    }]
    }
 
Sample Request #2
^^^^^^^^^^^^^^^^^

Generates a new key pair for the user with the email ``user1@email.com``.
::

    PUT /?ostor-users&emailAddress=user1@email.com&genKey HTTP/1.1
    Host: s3.amazonaws.com
    Date: Thu, 07 Apr 2016 15:51:13 GMT +3:00 
    Authorization: <authorization_string>

Sample Response #2
^^^^^^^^^^^^^^^^^^

::

    HTTP/1.1 200 OK
    x-amz-req-time-micros : 384103
    Transfer-encoding : chunked
    Server : nginx/1.8.1
    Connection : closed
    x-amz-request-id : 8000000000000003000374603639905b
    Date : Thu, 07 Apr 2016 12:51:09 GMT
    Content-type : application/json
    
    {
    "UserEmail": "user1@email.com",
    "UserId": "8eaa6ab4749a29b4",
    "AWSAccessKeys": [
    {
    "AWSAccessKeyId": "8eaa6ab4749a29b4034G",
    "AWSSecretAccessKey": "7spuMfShCIl2tX6dFtSl7TEP7ZQbIGl1GgE0Emdy"
    },
    {
    "AWSAccessKeyId": "8eaa6ab4749a29b4EJUY",
    "AWSSecretAccessKey": "ELzQ8CTMFcYQCGSP5lnGvmJxFC9xXrEJ4CjBAA2k"
    }]
    }

