UNPKG

11.7 kBTypeScriptView Raw
1import { Cluster } from './cluster';
2import { CppManagementRbacGroup, CppManagementRbacOrigin, CppManagementRbacRole, CppManagementRbacRoleAndDescription, CppManagementRbacRoleAndOrigins, CppManagementRbacUser, CppManagementRbacUserAndMetadata } from './binding';
3import { NodeCallback } from './utilities';
4/**
5 * Contains information about an origin for a role.
6 *
7 * @category Management
8 */
9export declare class Origin {
10 /**
11 * The type of this origin.
12 */
13 type: string;
14 /**
15 * The name of this origin.
16 */
17 name?: string;
18 /**
19 * @internal
20 */
21 constructor(data: Origin);
22 /**
23 * @internal
24 */
25 static _fromCppData(data: CppManagementRbacOrigin): Origin;
26}
27/**
28 * Contains information about a role.
29 *
30 * @category Management
31 */
32export declare class Role {
33 /**
34 * The name of the role.
35 */
36 name: string;
37 /**
38 * The bucket this role applies to.
39 */
40 bucket: string | undefined;
41 /**
42 * The scope this role applies to.
43 */
44 scope: string | undefined;
45 /**
46 * The collection this role applies to.
47 */
48 collection: string | undefined;
49 /**
50 * @internal
51 */
52 constructor(data: Role);
53 /**
54 * @internal
55 */
56 static _fromCppData(data: CppManagementRbacRole): Role;
57 /**
58 * @internal
59 */
60 static _toCppData(data: Role): CppManagementRbacRole;
61}
62/**
63 * Contains information about a role along with its description.
64 *
65 * @category Management
66 */
67export declare class RoleAndDescription extends Role {
68 /**
69 * The user-friendly display name for this role.
70 */
71 displayName: string;
72 /**
73 * The description of this role.
74 */
75 description: string;
76 /**
77 * @internal
78 */
79 constructor(data: RoleAndDescription);
80 /**
81 * @internal
82 */
83 static _fromCppData(data: CppManagementRbacRoleAndDescription): RoleAndDescription;
84}
85/**
86 * Contains information about a role along with its origin.
87 *
88 * @category Management
89 */
90export declare class RoleAndOrigin extends Role {
91 /**
92 * The origins for this role.
93 */
94 origins: Origin[];
95 /**
96 * @internal
97 */
98 constructor(data: RoleAndOrigin);
99 /**
100 * @internal
101 */
102 static _fromCppData(data: CppManagementRbacRoleAndOrigins): RoleAndOrigin;
103}
104/**
105 * Specifies information about a user.
106 *
107 * @category Management
108 */
109export interface IUser {
110 /**
111 * The username of the user.
112 */
113 username: string;
114 /**
115 * The display name of the user.
116 */
117 displayName?: string;
118 /**
119 * The groups associated with this user.
120 */
121 groups?: string[];
122 /**
123 * The roles associates with this user.
124 */
125 roles?: (Role | string)[];
126 /**
127 * The password for this user.
128 */
129 password?: string;
130}
131/**
132 * Contains information about a user.
133 *
134 * @category Management
135 */
136export declare class User implements IUser {
137 /**
138 * The username of the user.
139 */
140 username: string;
141 /**
142 * The display name of the user.
143 */
144 displayName?: string;
145 /**
146 * The groups associated with this user.
147 */
148 groups: string[];
149 /**
150 * The roles associates with this user.
151 */
152 roles: Role[];
153 /**
154 * This is never populated in a result returned by the server.
155 */
156 password: undefined;
157 /**
158 * @internal
159 */
160 constructor(data: User);
161 /**
162 * @internal
163 */
164 static _fromCppData(data: CppManagementRbacUser): User;
165 /**
166 * @internal
167 */
168 static _toCppData(data: IUser): CppManagementRbacUser;
169}
170/**
171 * Contains information about a user along with some additional meta-data
172 * about that user.
173 *
174 * @category Management
175 */
176export declare class UserAndMetadata extends User {
177 /**
178 * The domain this user is part of.
179 */
180 domain: string;
181 /**
182 * The effective roles that are associated with this user.
183 */
184 effectiveRoles: RoleAndOrigin[];
185 /**
186 * The last time the users password was changed.
187 */
188 passwordChanged?: Date;
189 /**
190 * The external groups that this user is associated with.
191 */
192 externalGroups: string[];
193 /**
194 * Same as {@link effectiveRoles}, which already contains the roles
195 * including their origins.
196 *
197 * @deprecated Use {@link effectiveRoles} instead.
198 */
199 get effectiveRolesAndOrigins(): RoleAndOrigin[];
200 /**
201 * @internal
202 */
203 constructor(data: UserAndMetadata);
204 /**
205 * @internal
206 */
207 static _fromCppData(data: CppManagementRbacUserAndMetadata): UserAndMetadata;
208}
209/**
210 * Specifies information about a group.
211 *
212 * @category Management
213 */
214export interface IGroup {
215 /**
216 * The name of the group.
217 */
218 name: string;
219 /**
220 * The description for the group.
221 */
222 description?: string;
223 /**
224 * The roles which are associated with this group.
225 */
226 roles?: (Role | string)[];
227 /**
228 * The LDAP group that this group is associated with.
229 */
230 ldapGroupReference?: string;
231}
232/**
233 * Contains information about a group.
234 *
235 * @category Management
236 */
237export declare class Group {
238 /**
239 * The name of the group.
240 */
241 name: string;
242 /**
243 * The description for the group.
244 */
245 description: string;
246 /**
247 * The roles which are associated with this group.
248 */
249 roles: Role[];
250 /**
251 * The LDAP group that this group is associated with.
252 */
253 ldapGroupReference: string | undefined;
254 /**
255 * @internal
256 */
257 constructor(data: Group);
258 /**
259 * @internal
260 */
261 static _fromCppData(data: CppManagementRbacGroup): Group;
262 /**
263 * @internal
264 */
265 static _toCppData(data: IGroup): CppManagementRbacGroup;
266}
267/**
268 * @category Management
269 */
270export interface GetUserOptions {
271 /**
272 * The domain to look in for the user.
273 */
274 domainName?: string;
275 /**
276 * The timeout for this operation, represented in milliseconds.
277 */
278 timeout?: number;
279}
280/**
281 * @category Management
282 */
283export interface GetAllUsersOptions {
284 /**
285 * The domain to look in for users.
286 */
287 domainName?: string;
288 /**
289 * The timeout for this operation, represented in milliseconds.
290 */
291 timeout?: number;
292}
293/**
294 * @category Management
295 */
296export interface UpsertUserOptions {
297 /**
298 * The domain to upsert the user within.
299 */
300 domainName?: string;
301 /**
302 * The timeout for this operation, represented in milliseconds.
303 */
304 timeout?: number;
305}
306/**
307 * @category Management
308 */
309export interface ChangePasswordOptions {
310 /**
311 * The timeout for this operation, represented in milliseconds.
312 */
313 timeout?: number;
314}
315/**
316 * @category Management
317 */
318export interface DropUserOptions {
319 /**
320 * The domain to drop the user from.
321 */
322 domainName?: string;
323 /**
324 * The timeout for this operation, represented in milliseconds.
325 */
326 timeout?: number;
327}
328/**
329 * @category Management
330 */
331export interface GetRolesOptions {
332 /**
333 * The timeout for this operation, represented in milliseconds.
334 */
335 timeout?: number;
336}
337/**
338 * @category Management
339 */
340export interface GetGroupOptions {
341 /**
342 * The timeout for this operation, represented in milliseconds.
343 */
344 timeout?: number;
345}
346/**
347 * @category Management
348 */
349export interface GetAllGroupsOptions {
350 /**
351 * The timeout for this operation, represented in milliseconds.
352 */
353 timeout?: number;
354}
355/**
356 * @category Management
357 */
358export interface UpsertGroupOptions {
359 /**
360 * The timeout for this operation, represented in milliseconds.
361 */
362 timeout?: number;
363}
364/**
365 * @category Management
366 */
367export interface DropGroupOptions {
368 /**
369 * The timeout for this operation, represented in milliseconds.
370 */
371 timeout?: number;
372}
373/**
374 * UserManager is an interface which enables the management of users,
375 * groups and roles for the cluster.
376 *
377 * @category Management
378 */
379export declare class UserManager {
380 private _cluster;
381 /**
382 * @internal
383 */
384 constructor(cluster: Cluster);
385 /**
386 * Returns a specific user by their username.
387 *
388 * @param username The username of the user to fetch.
389 * @param options Optional parameters for this operation.
390 * @param callback A node-style callback to be invoked after execution.
391 */
392 getUser(username: string, options?: GetUserOptions, callback?: NodeCallback<UserAndMetadata>): Promise<UserAndMetadata>;
393 /**
394 * Returns a list of all existing users.
395 *
396 * @param options Optional parameters for this operation.
397 * @param callback A node-style callback to be invoked after execution.
398 */
399 getAllUsers(options?: GetAllUsersOptions, callback?: NodeCallback<UserAndMetadata[]>): Promise<UserAndMetadata[]>;
400 /**
401 * Creates or updates an existing user.
402 *
403 * @param user The user to update.
404 * @param options Optional parameters for this operation.
405 * @param callback A node-style callback to be invoked after execution.
406 */
407 upsertUser(user: IUser, options?: UpsertUserOptions, callback?: NodeCallback<void>): Promise<void>;
408 /**
409 * Change password for the currently authenticatd user.
410 *
411 * @param newPassword The new password to be applied.
412 * @param options Optional parameters for this operation.
413 * @param callback A node-style callback to be invoked after execution.
414 */
415 changePassword(newPassword: string, options?: ChangePasswordOptions, callback?: NodeCallback<void>): Promise<void>;
416 /**
417 * Drops an existing user.
418 *
419 * @param username The username of the user to drop.
420 * @param options Optional parameters for this operation.
421 * @param callback A node-style callback to be invoked after execution.
422 */
423 dropUser(username: string, options?: DropUserOptions, callback?: NodeCallback<void>): Promise<void>;
424 /**
425 * Returns a list of roles available on the server.
426 *
427 * @param options Optional parameters for this operation.
428 * @param callback A node-style callback to be invoked after execution.
429 */
430 getRoles(options?: GetRolesOptions, callback?: NodeCallback<Role[]>): Promise<Role[]>;
431 /**
432 * Returns a group by it's name.
433 *
434 * @param groupName The name of the group to retrieve.
435 * @param options Optional parameters for this operation.
436 * @param callback A node-style callback to be invoked after execution.
437 */
438 getGroup(groupName: string, options?: GetGroupOptions, callback?: NodeCallback<Group>): Promise<Group>;
439 /**
440 * Returns a list of all existing groups.
441 *
442 * @param options Optional parameters for this operation.
443 * @param callback A node-style callback to be invoked after execution.
444 */
445 getAllGroups(options?: GetAllGroupsOptions, callback?: NodeCallback<Group[]>): Promise<Group[]>;
446 /**
447 * Creates or updates an existing group.
448 *
449 * @param group The group to update.
450 * @param options Optional parameters for this operation.
451 * @param callback A node-style callback to be invoked after execution.
452 */
453 upsertGroup(group: IGroup, options?: UpsertGroupOptions, callback?: NodeCallback<void>): Promise<void>;
454 /**
455 * Drops an existing group.
456 *
457 * @param groupName The name of the group to drop.
458 * @param options Optional parameters for this operation.
459 * @param callback A node-style callback to be invoked after execution.
460 */
461 dropGroup(groupName: string, options?: DropGroupOptions, callback?: NodeCallback<void>): Promise<void>;
462}