# User and Workspace management commands

This page describes all commands that allow users and workspaces to be managed with their options (see also [common options](#clireference-commonoptions) available for all commands).

| Command                                     | Description          |
| ------------------------------------------- | -------------------- |
| [create workspace](#create-a-new-workspace) | create a workspace   |
| [update workspace](#update-a-workspace)     | update a workspace   |
| [delete workspace](#delete-a-workspace)     | delete a workspace   |
| [list users](#list-available-users)         | list users           |
| [create user](#create-user)                 | create a user        |
| [describe user](#describe-a-user)           | describe a user      |
| [update user](#update-a-user-profile)       | update user profile  |
| [update password](#update-user-password)    | update user password |
| [delete user](#delete-a-user)               | delete a user        |

Notice: an Akamas workspace (user) is an Akamas resource (see list of [Akamas resources](..#clireference-operations)) so you can also refer to [resource management commands](cli-reference-2).

## Create workspace <a href="#create-a-new-workspace" id="create-a-new-workspace"></a>

The `create workspace` command allows defining a new workspace:

```bash
akamas create workspace NAME
```

The following snippet shows an example:

```bash
akamas create  workspace 'New Workspace'
```

## Update workspace <a href="#update-a-workspace" id="update-a-workspace"></a>

The `update workspace` command allows updating the workspace name:

```bash
akamas update workspace [OPTIONS] IDENTIFIER
```

with the following options:

| Option        | Required | Description        |
| ------------- | -------- | ------------------ |
| `--name` TEXT | yes      | New workspace name |

The following snippet shows an example:

```bash
akamas update workspace 'New Workspace' --name 'New Name'
```

## Delete workspace <a href="#delete-a-workspace" id="delete-a-workspace"></a>

The `delete workspace` command allows deleting a workspace:

```bash
akamas delete workspace [OPTIONS] IDENTIFIER
```

with the following options:

| Option | Required | Description                |
| ------ | -------- | -------------------------- |
| `-y`   | no       | Show this message and exit |

The following snippet shows an example:

```bash
akamas delete workspace 'New Workspace'
```

## List users <a href="#create-a-new-user" id="create-a-new-user"></a>

The `list users` command returns the list of the available users.

```bash
akamas list users
```

The following snippet shows an example:

```
$ akamas list users

                 Id                    Username   First Name   Last Name   Workspaces       User Type
=======================================================================================================
66778cc3-4b01-4f3e-8921-c279600c8e07   akamas     -            -           -              Administrator
ae8bfe02-e32d-480b-92ed-30a8d8e835ef   newuser    new          user        Default W      User
                                                                           Workspace1 R
```

## Create user

The `create user` command allows defining a new user and assigning it to one or more workspaces.

```bash
akamas create user [OPTIONS]
```

with the following options

| Option                          | Required | Description                                                                                                                                                                          |
| ------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `-u`, `--username` TEXT         | yes      | Username                                                                                                                                                                             |
| `-p`, `--password` TEXT         | yes      | Password                                                                                                                                                                             |
| `--first-name` TEXT             | no       | User first name                                                                                                                                                                      |
| `--last-name` TEXT              | no       | User last name                                                                                                                                                                       |
| `--email` TEXT                  | no       | Valid email                                                                                                                                                                          |
| `-w`, `--add-to-workspace` TEXT | no       | Add the user to the specified workspace with the specified role (R\|W) (e.g., --add-to-workspace WORKSPACE\_A R). The option can be specified multiple times to add more workspaces. |
| `--admin`                       | no       | Specify if you want to give Administration privileges to the user                                                                                                                    |

The default policy requires the password to satisfy the following rules:

* Include one or more uppercase characters (A-Z)
* Include one or more special characters (\~!@#$%^&\*\_-+=\`|\\(){}\[]:;"'<>,.?/)

The username and password can be either provided interactively or as command arguments.

The following snippet shows the process of creating a new user interactively:

```
$ akamas create user

Username: newuser
Password:
Repeat for confirmation:
User first name: John
User last name: Doe
Email: john.doe@akamas.io
```

The same action can be performed using the command options:

```
$ akamas create user -u newuser -p P455w0rd
```

## Describe user <a href="#describe-a-user" id="describe-a-user"></a>

The `describe user` command returns the detail of a valid user matching the provided username or id:

```bash
akamas describe user IDENTIFIER
```

Notice: users without administrative privileges can only describe their profiles, while administrators can inspect any profile.

The following snippet shows an example:

```
$ akamas describe user newuser

Id         | a81fd6e5-aedc-4b74-b6d2-40650441935b
Username   | newuser
First Name | new
Last Name  | user
Email      | newuser@akamas.io
Workspaces | - Default R
           | - Workspace1 W
User Type  | User
```

## Update user <a href="#update-a-user-profile" id="update-a-user-profile"></a>

The `update user` command allows updating the user profile attributes for the user matching the username or id:

```bash
akamas update user [OPTIONS] IDENTIFIER
```

with the following options:

| Option                               | Required | Description                                                                                                                                                                          |
| ------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--first-name` TEXT                  | no       | User first name                                                                                                                                                                      |
| `--last-name` TEXT                   | no       | User last name                                                                                                                                                                       |
| `--email` TEXT                       | no       | Valid email                                                                                                                                                                          |
| `-w`, `--add-to-workspace` TEXT      | no       | Add the user to the specified workspace with the specified role (R\|W) (e.g., --add-to-workspace WORKSPACE\_A R). The option can be specified multiple times to add more workspaces. |
| `-r`, `--remove-from-workspace` TEXT | no       | Remove the user from the specified workspace                                                                                                                                         |
| `--admin`                            | no       | Specify if you want to give Administration privileges to the user                                                                                                                    |
| `--no-admin`                         | no       | Specify if you want to remove Administration privileges to the user                                                                                                                  |

The following snippet shows an example of updating the email of a user:

```bash
akamas update user --email 'new.email@akamas.io' newuser
```

This command is also used to grant or revoke access to workspaces and administrative privileges to users.

The following snippet shows an example of updating the user’s workspace access privileges, adding write privileges on _Workspace 1,_ and revoking access on _Default_:

```bash
akamas update user -w 'Workspace 1' W -r Default newuser
```

## Update password <a href="#update-user-password" id="update-user-password"></a>

The `update password` command updates the password for the user matching the username or id:

```bash
akamas update password [OPTIONS] IDENTIFIER
```

with the following options:

| Option                  | Required | Description  |
| ----------------------- | -------- | ------------ |
| `-p`, `--password` TEXT | yes      | New password |

Notice: users without administrative privileges can update only their own password, while administrators can perform this action on any profile.

The default policy requires the password to satisfy the following rules:

* Include one or more uppercase characters (A-Z)
* Include one or more special characters (\~!@#$%^&\*\_-+=\`|\\(){}\[]:;"'<>,.?/)

The password can be either provided interactively or as command arguments.

The following snippet shows an example of updating interactively the password for a user:

```
$ akamas update password newuser

New password:
Repeat for confirmation:
```

The same action can be performed using the command options:

```bash
akamas update password -p P455w0rd newuser
```

## Delete user <a href="#delete-a-user" id="delete-a-user"></a>

The `delete user` command removes the user with the provided username or id:

```bash
akamas delete user IDENTIFIER
```

with the following options:

| Option | Required | Description              |
| ------ | -------- | ------------------------ |
| `-y`   | no       | Automatic yes to prompts |

The following snippet shows an example of deleting interactively a user:

```
akamas delete user newuser

Confirm deletion of newuser [y/N]: y
```
