Managing Users
A project in Shield looks like
{
"users": [
{
"id": "598688c6-8c6d-487f-b324-ef3f4af120bb",
"name": "John Doe",
"slug": "",
"email": "john.doe@gotocompany.com",
"metadata": {
"role": "\"user-1\""
},
"createdAt": "2022-12-09T10:45:19.134019Z",
"updatedAt": "2022-12-09T10:45:19.134019Z"
}
]
}
One thing to note here is that Shield only allow to have metadata key from a specific set of keys. This constraint is only for users. We can add metadata key using this metadata key API
API Interface
Create users
- HTTP
- CLI
$ curl --location --request POST 'http://localhost:8000/admin/v1beta1/users'
--header 'Content-Type: application/json'
--header 'Accept: application/json'
--header 'X-Shield-Email: admin@gotocompany.com'
--data-raw '{
"name": "Jonny Doe",
"email": "jonny.doe@gotocompany.com",
"metadata": {
"role": "user-3"
}
}'
$ shield user create --file=user.yaml
List users
- HTTP
- CLI
curl --location --request GET 'http://localhost:8000/admin/v1beta1/users'
--header 'Accept: application/json'
$ shield user list
Get Users
- HTTP
- CLI
$ curl --location --request GET 'http://localhost:8000/admin/v1beta1/users/e9fba4af-ab23-4631-abba-597b1c8e6608'
--header 'Accept: application/json''
$ shield user view e9fba4af-ab23-4631-abba-597b1c8e6608 --metadata
Update Projects
- HTTP
- CLI
$ curl --location --request PUT 'http://localhost:8000/admin/v1beta1/users/e9fba4af-ab23-4631-abba-597b1c8e6608'
--header 'Content-Type: application/json'
--header 'Accept: application/json'
--data-raw '{
"name": "Jonny Doe",
"email": "john.doe001@gotocompany.com",
"metadata": {
"role" : "user-3"
}
}'
$ shield user edit e9fba4af-ab23-4631-abba-597b1c8e6608 --file=user.yaml