|
| 1 | +# How to create a domain and add users |
| 2 | + |
| 3 | +**Prerequisites:** |
| 4 | + |
| 5 | +- Enterprise account with permission to create domains |
| 6 | + |
| 7 | +**Endpoints used:** |
| 8 | + |
| 9 | +- `POST /domains` |
| 10 | +- `POST /users` |
| 11 | + |
| 12 | +<br> |
| 13 | + |
| 14 | +### Step 1: Create a domain |
| 15 | + |
| 16 | +To create a domain, send a `POST` request to the endpoint `/domains`. Customize the data in the request body with the necessary parameters for creating a domain: the domain identity and description. Domain identity consists of the root domain name followed by any number of sub-domain names, and must start and end with ”/”, for example: “/sub_domain1/sub_domain2/”. The following is an example of the request: |
| 17 | + |
| 18 | + |
| 19 | +=== "cURL" |
| 20 | + |
| 21 | + ``` |
| 22 | + curl -X POST \ |
| 23 | + -H "Authorization: Bearer #TOKEN" \ |
| 24 | + -H "Content-Type: application/json" \ |
| 25 | + -d '{"id":"/sub_domain1/sub_domain2/","description":"Example domain"}' \ |
| 26 | + https://#HOSTNAME/api/coiotedm/v3/domains |
| 27 | + ``` |
| 28 | + |
| 29 | +=== "Coiote Python" |
| 30 | + |
| 31 | + ``` python |
| 32 | + from coiote.client import Coiote |
| 33 | + from coiote.v3.model.domains import Domain |
| 34 | + |
| 35 | + coiote_auth = "#TOKEN" |
| 36 | + client = Coiote( |
| 37 | + url="https://#HOSTNAME", |
| 38 | + auth=coiote_auth |
| 39 | + ) |
| 40 | + domain = Domain( |
| 41 | + id="/sub_domain1/sub_domain2/", |
| 42 | + description="Example domain" |
| 43 | + ) |
| 44 | + print( |
| 45 | + client.domains.add_domain(domain) |
| 46 | + ) |
| 47 | + |
| 48 | + ``` |
| 49 | + |
| 50 | +Replace `#TOKEN` with your actual access token and `#HOSTNAME` with your actual hostname. |
| 51 | + |
| 52 | +### Step 2: Add users to your domain |
| 53 | + |
| 54 | +To add users, send a `POST` request to the endpoint `/users`. Specify your domain in the path parameter. In the request body provide a user object. You have to include the following information: |
| 55 | +- login - user's login |
| 56 | +- email - user's email |
| 57 | +- emailVerified - set true to create a user with already verified email |
| 58 | +- domain - user's domain |
| 59 | +- password - user's password |
| 60 | +- roles - user's roles, leave empty if not willing to add any |
| 61 | +- permissions - user's permissions, leave empty if not willing to add any |
| 62 | +- tosAccepted - set true to create a user with already accepted Terms of Service |
| 63 | + |
| 64 | +The following is an example of the request: |
| 65 | + |
| 66 | +=== "cURL" |
| 67 | + |
| 68 | + ``` |
| 69 | + curl -X POST \ |
| 70 | + -H "Authorization: Bearer #TOKEN" \ |
| 71 | + -H "Content-Type: application/json" \ |
| 72 | + -d '{"login":"example_user","email":"[email protected]","emailVerified":true,"domain":"/sub_domain1/sub_domain2/","password":"example_password","roles":["string"],"permissions":["string"],"tosAccepted":true"}' \ |
| 73 | + https://#HOSTNAME/api/coiotedm/v3/users |
| 74 | + ``` |
| 75 | + |
| 76 | +=== "Coiote Python" |
| 77 | + |
| 78 | + ``` python |
| 79 | + from coiote.client import Coiote |
| 80 | + from coiote.v3.model.users import UserCreateRequest |
| 81 | + |
| 82 | + coiote_auth = "#TOKEN" |
| 83 | + client = Coiote( |
| 84 | + url="https://#HOSTNAME", |
| 85 | + auth=coiote_auth |
| 86 | + ) |
| 87 | + user = UserCreateRequest( |
| 88 | + login="example_user", |
| 89 | + |
| 90 | + emailVerified=True, |
| 91 | + password="example_password", |
| 92 | + roles=["string"], |
| 93 | + permissions=["string"], |
| 94 | + tosAccepted=True, |
| 95 | + domain="/sub_domain1/sub_domain2/" |
| 96 | + ) |
| 97 | + |
| 98 | + print( |
| 99 | + client.users.create_one(user).json() |
| 100 | + ) |
| 101 | + |
| 102 | + ``` |
| 103 | + |
| 104 | +Replace `#TOKEN` with your actual access token and `#HOSTNAME` with your actual hostname. |
0 commit comments