<commit_before># User-API Documentation

The User-API provides user management over all controllers.

**Currently, all the calls must be made with BasicAuth in the request!**

## API Calls
- [/users](#users)
- [/users/[user]](#user)
- [/users/[user]/ssh](#ssh)
- [/users/[user]/credentials](#credentials)
- [/users/[user]/controllers](#controllers)
- [/users/[user]/controllers/[controller]](#controller)
- [/users/[user]/controllers/[controller]/models](#models)
- [/users/[user]/controllers/[controller]/models/[model]](#model)

## **/users** <a name="users"></a>
#### **Request type**: GET
* **Description**:
  Returns all of the information of all the users (with all their controller access and model access)
* **Required headers**:
  - api-key
  - Content-Type:application/json
* **Required body**:

* **Successful response**:
  - code: 200
  - message:
  ```json
  {
          "name": "admin",
          "active": true,
          "credentials": [
              {
                  "name": "admin",
                  "type": "jsonfile",
                  "key": {
                      "file": "{"google_cred_file"}"
                  }
              }
          ],
          "ssh_keys": [
              null
          ],
          "access": [
              {
                  "testcontroller": {
                      "access": "superuser",
                      "models": [
                          {
                              "controller": "admin"
                          },
                          {
                              "default": "admin"
                          }
                      ],
                      "type": "google"
                  }
              }
          ]
      }
  ```

#### **Request type**: POST
* **Description**:
  Creates a new user. Checks if the user exists.
* **Required headers**:
  - api-key
  - Content-Type:application/json
* **Required body**:
  - username
  - password
* **Successful response**:
  - code: 200
  - message:
  ```json
"User <username> succesfully created."
  ```

## **/users/[user]** <a name="user"></a>
#### **Request type**: GET
* **Description**:
  Gets the info of a user. Checks if the user exists.
* **Required headers**:
  - api-key
  - Content-Type:application/json
* **Required body**:

* **Successful response**:
  - code: 200
  - message:
  ```json
  {
          "name": "admin",
          "active": true,
          "credentials": [
              {
                  "name": "admin",
                  "type": "jsonfile",
                  "key": {
                      "file": "{"google_cred_file"}"
                  }
              }
          ],
          "ssh_keys": [
              null
          ],
          "access": [
              {
                  "testcontroller": {
                      "access": "superuser",
                      "models": [
                          {
                              "controller": "admin"
                          },
                          {
                              "default": "admin"
                          }
                      ],
                      "type": "google"
                  }
              }
          ]
      }
  ```

#### **Request type**: PUT
* **Description**:
  Changes the user password.
* **Required headers**:
  - api-key
  - Content-Type:application/json
* **Required body**:
  - password
* **Successful response**:
  - code: 200
  - message:
  ```json
"succesfully changed password for user admin"
  ```

#### **Request type**: DELETE
* **Description**:
  Removes the user.
* **Required headers**:
  - api-key
  - Content-Type:application/json
* **Required body**:

* **Successful response**:<commit_msg>Fixed issue 10<commit_after># User-API Documentation

The User-API provides user management over all controllers.

**Currently, all the calls must be made with BasicAuth in the request!**

## API Calls
- [/users](#users)
- [/users/[user]](#user)
- [/users/[user]/ssh](#ssh)
- [/users/[user]/credentials](#credentials)
- [/users/[user]/controllers](#controllers)
- [/users/[user]/controllers/[controller]](#controller)
- [/users/[user]/controllers/[controller]/models](#models)
- [/users/[user]/controllers/[controller]/models/[model]](#model)

## **/users** <a name="users"></a>
#### **Request type**: GET
* **Description**:
  Returns all of the information of all the users (with all their controller access and model access)
* **Required headers**:
  - api-key
  - Content-Type:application/json
* **Required body**:

* **Successful response**:
  - code: 200
  - message:
  Remark: credentials are cloud-type specific: the actual value of the key-attribute depends on the type.
  ```json
  [
    {
      "name": "admin",
      "active": true,
      "credentials": [
        {
          "name": "admin",
          "type": "jsonfile",
          "key": {
            "file": "google_cred_file"
          }
        }
      ],
      "ssh_keys": [],
      "controllers": [
        {
          "name": "gce1",
          "access": "superuser",
          "models": [
            {
              "name": "default",
              "access": "admin"
            }
          ]
        }
      ]
    }     
  ]
  ```

#### **Request type**: POST
* **Description**:
  Creates a new user. Checks if the user exists.
* **Required headers**:
  - api-key
  - Content-Type:application/json
* **Required body**:
  - username
  - password
* **Successful response**:
  - code: 200
  - message:
  ```json
"User <username> succesfully created."
  ```

## **/users/[user]** <a name="user"></a>
#### **Request type**: GET
* **Description**:
  Gets the info of a user. Checks if the user exists.
* **Required headers**:
  - api-key
  - Content-Type:application/json
* **Required body**:

* **Successful response**:
  - code: 200
  - message:
  Remark: credentials are cloud-type specific: the actual value of the key-attribute depends on the type.
  ```json
  {
    "name": "admin",
    "active": true,
    "credentials": [
      {
        "name": "admin",
        "type": "jsonfile",
        "key": {
          "file": "google_cred_file"
        }
      }
    ],
    "ssh_keys": [],
    "controllers": [
      {
        "name": "gce1",
        "access": "superuser",
        "models": [
          {
            "name": "default",
            "access": "admin"
          }
        ]
      }
    ]
  }    
  ```

#### **Request type**: PUT
* **Description**:
  Changes the user password.
* **Required headers**:
  - api-key
  - Content-Type:application/json
* **Required body**:
  - password
* **Successful response**:
  - code: 200
  - message:
  ```json
"succesfully changed password for user admin"
  ```

#### **Request type**: DELETE
* **Description**:
  Removes the user.
* **Required headers**:
  - api-key
  - Content-Type:application/json
* **Required body**:

* **Successful response**:
{'fraction_non_alphanumeric': 0.17055393586005832, 'fraction_numerical': 0.004081632653061225, 'mean_word_length': 1.737829209896249, 'pattern_counts': {'":': 58, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6108456', 'n_tokens_mistral': 2037, 'n_tokens_neox': 1936, 'n_words': 471}