- 22 Dec 2023
- 1 Minute to read
- Print
- DarkLight
Tenants - Users
- Updated on 22 Dec 2023
- 1 Minute to read
- Print
- DarkLight
Return specified tenant's users, sorted from A-> Z (based on the first name of Users)
Tenant's Users
Argument | Description |
---|---|
tenant_id | (required) The unique identifier of the Tenant object to be retrieved |
reverse | (optional) Results order can be reversed by adding the ?reverse=true parameter |
GET /1/tenants/{tenant_id}/users
Host: https://api.cogniac.io
Example: List Tenant's Users
curl -X GET https://api.cogniac.io/1/tenants/current/users \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
| json_pp
import requests
import json
from pprint import pprint
url_prefix = 'https://api.cogniac.io'
api_version = "1"
token = '' # add your token here
headers = {'Authorization': f'Bearer {token}'}
url = f'{url_prefix}/{api_version}/tenants/current/users'
res = requests.get(url, headers=headers)
if res.status_code == 200:
response_data = json.loads(res.content)
pprint(response_data)
else:
print(f"Error: {res.status_code}, {res.text},{res.headers}")
{
"data": [
{
"tenant_id": "qqkbbkqvio08",
"name": "Jane Smith",
"user_id": "2ke2daisdflkj",
"given_name":"Jane",
"surname":"Smith",
"username":"test@cogniac.co",
"created_by": "test@cogniac.co"
},
{
//Next User Object ...
}
]
}
Remove User From Tenant
This endpoint will remove a user from a tenant, but will not delete a user's account.
To remove a user from a tenant, the following arguments should be passed:
Argument | Description |
---|---|
user_id | (required) ID of the user to remove from the tenant. |
DELETE /1/tenants/{tenant_id}/users?user_id=fladkjhflkdaj
Host: https://api.cogniac.io
Example: Remove a User from a Tenant
curl -X DELETE https://api.cogniac.io/1/tenants/current/users?user_id=0Wd765esrdtyuijkn \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
| json_pp
import requests
from pprint import pprint
url_prefix = 'https://api.cogniac.io'
api_version = "1"
token = '' # add your token here
headers = {'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'}
user_data = {
"user_id": "QTavhd110T0BBan8Zgoalm"
}
url = f'{url_prefix}/{api_version}/tenants/current/users'
res = requests.delete(url, json=user_data, headers=headers)
print(res)
if res.status_code == 204:
print(f"{user_data} was successfully deleted. ")
else:
pprint(f"Error: {res.status_code}, {res.text},{res.headers}")
<Response [204]>
{user_id": "QTavhd110T0BBan8Zgoalm} was successfully deleted.
Tenant User roles
A user can belong to any of the 3 roles below
Tenant Admin
Tenant User
Tenant Viewer
Role | User management | App Management | Feedback | Read/Write access to tenant data |
---|---|---|---|---|
Create new users, delete, change permissions, invite users, change name, description | Add new subjects, change app name, description, type, detection thresholds | Media, apps, feedback, subjects, gateways, cameras | ||
Tenant Admin | Yes | Yes | Yes | Yes |
Tenant User | No | Only if App Manager | Yes | Yes |
Tenant Viewer | No | No | No | Read-only access |