MCPcopy
hub / github.com/logto-io/logto / createRole

Function createRole

packages/integration-tests/src/api/role.ts:15–38  ·  view source on GitHub ↗
({
  name,
  description,
  type,
  isDefault,
  scopeIds,
}: {
  name?: string;
  description?: string;
  type?: RoleType;
  isDefault?: boolean;
  scopeIds?: string[];
})

Source from the content-addressed store, hash-verified

13};
14
15export const createRole = async ({
16 name,
17 description,
18 type,
19 isDefault,
20 scopeIds,
21}: {
22 name?: string;
23 description?: string;
24 type?: RoleType;
25 isDefault?: boolean;
26 scopeIds?: string[];
27}) =>
28 authedAdminApi
29 .post('roles', {
30 json: {
31 name: name ?? generateRoleName(),
32 description: description ?? generateRoleName(),
33 isDefault,
34 type: type ?? RoleType.User,
35 scopeIds,
36 },
37 })
38 .json<Role>();
39
40export const getRoles = async (options?: GetRoleOptions) =>
41 authedAdminApi.get('roles', { searchParams: new URLSearchParams(options) }).json<Role[]>();

Calls 2

generateRoleNameFunction · 0.85
jsonMethod · 0.65

Tested by 2

createRuleMatrixFunction · 0.68