Admin Functions
To create and retrieve Admin records for Epicenter admins, leverage the Admin adapter.
Importing the adapter
To use the functions of the Admin adapter, import it as shown:
import { adminAdapter } from 'epicenter-libs';
The adminAdapter namespace exports functions that make calls to the Admin API.
learn more
For descriptions of the objects used by the Admin adapter functions, read Admin entities.
Create an admin
Create a new admin user within the epicenter/manager project.
Function description
The createAdmin() function:
- Constructs a
POSTrequest to{ACCOUNT_SHORT_NAME}/{PROJECT_SHORT_NAME}/adminsetting the path parameters{ACCOUNT_SHORT_NAME}='epicenter'and{PROJECT_SHORT_NAME}='manager'. - Accepts an object describing the admin to create.
- Returns an
Adminobject.
Function signature
export async function createAdmin(
view: {
handle: string;
email: string;
givenName?: string;
familyName?: string;
verified: true;
active?: true;
[key: string]: unknown;
},
): Promise<Admin>
Parameters
view(Type: object): Information describing the admin user to create.handle(string): Unique handle for the admin user.email(string): Email address for the admin user.givenName?(string): (Optional) Admin’s given name.familyName?(string): (Optional) Admin’s family name.verified(true): Must betrue; indicates the admin is verified.active?(true): (Optional) Whether the admin is active; defaults totrueif omitted.[key: string]: unknown: Allows additional arbitrary fields.
Return value
A promise that resolves to an Admin object representing the newly created Epicenter admin.
Usage example
import { adminAdapter } from 'epicenter-libs';
const admin = await adminAdapter.createAdmin({
handle: 'admin@example.com',
email: 'admin@example.com',
givenName: 'Jane',
familyName: 'Doe',
verified: true,
active: true,
});
Get an admin by handle
Retrieve an Epicenter admin record using their unique handle.
Function description
The getWithHandle() function:
- Constructs a
GETrequest to{ACCOUNT_SHORT_NAME}/{PROJECT_SHORT_NAME}/admin/with/{HANDLE}setting the path parameters{ACCOUNT_SHORT_NAME}='epicenter'and{PROJECT_SHORT_NAME}='manager'. - Accepts optional routing overrides.
- Returns an
Adminobject representing the retrieved admin record.
Function signature
export async function getWithHandle(handle: string, optionals: RoutingOptions = {}): Promise<Admin>
Parameters
handle(Type:string): Handle of the admin user to retrieve.optionals(Type:RoutingOptions, optional): Network call override options.
Return value
A promise that resolves to an Admin object.
Usage example
import { adminAdapter } from 'epicenter-libs';
const admin = await adminAdapter.getWithHandle('admin@example.com');