1 | import type { DefaultElements, BasicMetaSysProps, SysLink, MakeRequest } from '../common-types';
|
2 | export type ActionType = 'read' | 'create' | 'update' | 'delete' | 'publish' | 'unpublish' | 'archive' | 'unarchive';
|
3 | type ConditionType = 'and' | 'or' | 'not' | 'equals';
|
4 | export type ConstraintType = {
|
5 | [key in ConditionType]?: ConstraintType[] | any;
|
6 | };
|
7 | export type RoleProps = {
|
8 | sys: BasicMetaSysProps & {
|
9 | space: SysLink;
|
10 | };
|
11 | name: string;
|
12 | description?: string;
|
13 | /**
|
14 | * Permissions for application sections
|
15 | */
|
16 | permissions: {
|
17 | ContentDelivery: string[] | string;
|
18 | ContentModel: string[];
|
19 | EnvironmentAliases: string[] | string;
|
20 | Environments: string[] | string;
|
21 | Settings: string[] | string;
|
22 | Tags: string[] | string;
|
23 | };
|
24 | policies: {
|
25 | effect: string;
|
26 | actions: ActionType[] | 'all';
|
27 | constraint: ConstraintType;
|
28 | }[];
|
29 | };
|
30 | export type CreateRoleProps = Omit<RoleProps, 'sys'>;
|
31 | export interface Role extends RoleProps, DefaultElements<RoleProps> {
|
32 | /**
|
33 | * Deletes this object on the server.
|
34 | * @memberof Role
|
35 | * @func delete
|
36 | * @return {Promise} Promise for the deletion. It contains no data, but the Promise error case should be handled.
|
37 | * @example ```javascript
|
38 | * const contentful = require('contentful-management')
|
39 | *
|
40 | * const client = contentful.createClient({
|
41 | * accessToken: '<content_management_api_key>'
|
42 | * })
|
43 | *
|
44 | * client.getSpace('<space_id>')
|
45 | * .then((space) => space.getRole('<role_id>'))
|
46 | * .then((role) => role.delete())
|
47 | * .then((role) => console.log(`role deleted.`))
|
48 | * .catch(console.error)
|
49 | * ```
|
50 | */
|
51 | delete(): Promise<void>;
|
52 | /**
|
53 | * Sends an update to the server with any changes made to the object's properties
|
54 | * @return Object returned from the server with updated changes.
|
55 | * @example ```javascript
|
56 | * const contentful = require('contentful-management')
|
57 | *
|
58 | * const client = contentful.createClient({
|
59 | * accessToken: '<content_management_api_key>'
|
60 | * })
|
61 | *
|
62 | * client.getSpace('<space_id>')
|
63 | * .then((space) => space.getRole('<roles_id>'))
|
64 | * .then((roles) => {
|
65 | * roles.name = 'New role name'
|
66 | * return roles.update()
|
67 | * })
|
68 | * .then((roles) => console.log(`roles ${roles.sys.id} updated.`))
|
69 | * .catch(console.error)
|
70 | * ```
|
71 | */
|
72 | update(): Promise<Role>;
|
73 | }
|
74 | /**
|
75 | * @private
|
76 | * @param makeRequest - function to make requests via an adapter
|
77 | * @param data - Raw role data
|
78 | * @return Wrapped role data
|
79 | */
|
80 | export declare function wrapRole(makeRequest: MakeRequest, data: RoleProps): Role;
|
81 | /**
|
82 | * @private
|
83 | */
|
84 | export declare const wrapRoleCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<RoleProps>) => import("../common-types").Collection<Role, RoleProps>;
|
85 | export {};
|