Principals
This endpoint will search for all the available principals in when given a query string. We define a principal as any user or group in the system. This endpoint requires an authenticated user.
Search Principals
To retrieve a list of principals given a search string, call the /@principals endpoint with a GET request and a search query parameter:
GET /@principals?search=dmin HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({ username: 'admin', password: 'admin' });
const { data } = await cli.getPrincipals({
token: login.data.token,
search: 'dmin',
});
The server will respond with a list of the users and groups in the portal that match the query string:
HTTP/1.1 200 OK
Content-Type: application/json
{
"users": [
{
"@id": "http://localhost:8080/@users/admin",
"id": "admin",
"fullname": "Admin",
"email": "admin@example.com",
"roles": [
"Administrator"
],
"groups": []
}
],
"groups": [
{
"@id": "http://localhost:8080/@groups/Administrators",
"description": "",
"email": "",
"groupname": "Administrators",
"id": "Administrators",
"roles": [
"Administrator"
],
"title": "Administrators"
}
]
}