UNPKG

6.13 kBTypeScriptView Raw
1import type { RawAxiosRequestHeaders } from 'axios';
2import type { CollectionProp, GetOrganizationParams, GetSpaceParams, QueryParams } from '../../common-types';
3import type { OptionalDefaults } from '../wrappers/wrap';
4import type { CreateRoleProps, RoleProps } from '../../entities/role';
5export type RolePlainClientAPI = {
6 /** Fetches a Role
7 *
8 * @param params Space ID and Role ID
9 * @returns the Role
10 * @throws if the request fails, or the Role is not found
11 * @example
12 * ```javascript
13 * const role = await client.role.get({
14 * spaceId: '<space_id>',
15 * roleId: '<role_id>',
16 * });
17 * ```
18 */
19 get(params: OptionalDefaults<GetSpaceParams & {
20 roleId: string;
21 }>): Promise<RoleProps>;
22 /** Fetches all Roles for the given Space
23 *
24 * @param params Space ID and optional query parameters
25 * @returns All the Roles for the given Space
26 * @throws if the request fails, or the Space is not found
27 * @example
28 * ```javascript
29 * const results = await client.role.getMany({
30 * spaceId: '<space_id>',
31 * query: {
32 * limit: 100,
33 * }
34 * });
35 * ```
36 */
37 getMany(params: OptionalDefaults<GetSpaceParams & QueryParams>): Promise<CollectionProp<RoleProps>>;
38 /** Fetches all Roles for the given Organization
39 *
40 * @param params Organization ID and optional query parameters
41 * @returns All the Roles for the given Organization
42 * @throws if the request fails, or the Organization is not found
43 * @example
44 * ```javascript
45 * const results = await client.role.getManyForOrganization({
46 * organizationId: '<organization_id>',
47 * query: {
48 * limit: 100,
49 * }
50 * });
51 * ```
52 */
53 getManyForOrganization(params: OptionalDefaults<GetOrganizationParams & QueryParams>): Promise<CollectionProp<RoleProps>>;
54 /** Creates a Role
55 *
56 * @param params Space ID and the Role to create
57 * @returns the created Role
58 * @throws if the request fails, the Space is not found, or the payload is malformed
59 * @example
60 * ```javascript
61 * const role = await client.role.create(
62 * {
63 * spaceId: '<space_id>',
64 * },
65 * {
66 * name: 'My role',
67 * description: 'My role description',
68 * permissions: {
69 * ContentModel: [
70 * 'read'
71 * ],
72 * ContentDelivery: 'all',
73 * Environments: 'all',
74 * EnvironmentAliases: 'all',
75 * Settings: 'all'
76 * },
77 * policies: [
78 * {
79 * effect: 'allow',
80 * actions: [
81 * 'read',
82 * 'create',
83 * 'update',
84 * 'delete',
85 * 'publish',
86 * 'unpublish',
87 * 'archive',
88 * 'unarchive'
89 * ],
90 * constraint: {
91 * and: [
92 * [
93 * 'equals',
94 * {
95 * doc: 'sys.type'
96 * },
97 * 'Entry'
98 * ]
99 * ]
100 * }
101 * }
102 * ]
103 * });
104 * ```
105 */
106 create(params: OptionalDefaults<GetSpaceParams>, data: CreateRoleProps, headers?: RawAxiosRequestHeaders): Promise<RoleProps>;
107 /** Creates a Role with a given ID
108 *
109 * @param params Space ID, Role ID, and the Role to create
110 * @returns the created Role
111 * @throws if the request fails, the Space is not found, or the payload is malformed
112 * @example
113 * ```javascript
114 * const role = await client.role.create(
115 * {
116 * spaceId: '<space_id>',
117 * roleId: '<role_id>',
118 * },
119 * {
120 * name: 'My role',
121 * description: 'My role description',
122 * permissions: {
123 * ContentModel: [
124 * 'read'
125 * ],
126 * ContentDelivery: 'all',
127 * Environments: 'all',
128 * EnvironmentAliases: 'all',
129 * Settings: 'all'
130 * },
131 * policies: [
132 * {
133 * effect: 'allow',
134 * actions: [
135 * 'read',
136 * 'create',
137 * 'update',
138 * 'delete',
139 * 'publish',
140 * 'unpublish',
141 * 'archive',
142 * 'unarchive'
143 * ],
144 * constraint: {
145 * and: [
146 * [
147 * 'equals',
148 * {
149 * doc: 'sys.type'
150 * },
151 * 'Entry'
152 * ]
153 * ]
154 * }
155 * }
156 * ]
157 * });
158 * ```
159 */
160 createWithId(params: OptionalDefaults<GetSpaceParams & {
161 roleId: string;
162 }>, data: CreateRoleProps, headers?: RawAxiosRequestHeaders): Promise<RoleProps>;
163 /** Updates a Role
164 *
165 * @param params Space ID and Role ID
166 * @param rawData the Role update
167 * @returns the updated Role
168 * @throws if the request fails, the Role is not found, or the payload is malformed
169 * @example
170 * ```javascript
171 * let role = await client.role.get({
172 * spaceId: '<space_id>',
173 * roleId: '<role_id>',
174 * });
175 *
176 * role = await client.role.update(
177 * {
178 * spaceId: '<space_id>',
179 * roleId: '<role_id>',
180 * },
181 * {
182 * ...role,
183 * name: 'My updated role name',
184 * }
185 * );
186 * ```
187 */
188 update(params: OptionalDefaults<GetSpaceParams & {
189 roleId: string;
190 }>, rawData: RoleProps, headers?: RawAxiosRequestHeaders): Promise<RoleProps>;
191 /** Deletes a Role
192 *
193 * @param params Space ID and Role ID
194 * @throws if the request fails, or the Role is not found
195 * @example
196 * ```javascript
197 * await client.role.delete({
198 * spaceId: '<space_id>',
199 * roleId: '<role_id>',
200 * });
201 * ```
202 */
203 delete(params: OptionalDefaults<GetSpaceParams & {
204 roleId: string;
205 }>): Promise<any>;
206};