UNPKG

11.2 kBTypeScriptView Raw
1import { Cluster } from './cluster';
2import { NodeCallback } from './utilities';
3/**
4 * Contains information about an origin for a role.
5 *
6 * @category Management
7 */
8export declare class Origin {
9 /**
10 * The type of this origin.
11 */
12 type: string;
13 /**
14 * The name of this origin.
15 */
16 name: string;
17 /**
18 * @internal
19 */
20 constructor(data: Origin);
21 /**
22 * @internal
23 */
24 static _fromNsData(data: any): Origin;
25}
26/**
27 * Contains information about a role.
28 *
29 * @category Management
30 */
31export declare class Role {
32 /**
33 * The name of the role.
34 */
35 name: string;
36 /**
37 * The bucket this role applies to.
38 */
39 bucket: string | undefined;
40 /**
41 * The scope this role applies to.
42 */
43 scope: string | undefined;
44 /**
45 * The collection this role applies to.
46 */
47 collection: string | undefined;
48 /**
49 * @internal
50 */
51 constructor(data: Role);
52 /**
53 * @internal
54 */
55 static _fromNsData(data: any): Role;
56 /**
57 * @internal
58 */
59 static _toNsStr(role: string | Role): string;
60}
61/**
62 * Contains information about a role along with its description.
63 *
64 * @category Management
65 */
66export declare class RoleAndDescription extends Role {
67 /**
68 * The user-friendly display name for this role.
69 */
70 displayName: string;
71 /**
72 * The description of this role.
73 */
74 description: string;
75 /**
76 * @internal
77 */
78 constructor(data: RoleAndDescription);
79 /**
80 * @internal
81 */
82 static _fromNsData(data: any): RoleAndDescription;
83}
84/**
85 * Contains information about a role along with its origin.
86 *
87 * @category Management
88 */
89export declare class RoleAndOrigin extends Role {
90 /**
91 * The origins for this role.
92 */
93 origins: Origin[];
94 /**
95 * @internal
96 */
97 constructor(data: RoleAndOrigin);
98 /**
99 * @internal
100 */
101 static _fromNsData(data: any): RoleAndOrigin;
102}
103/**
104 * Specifies information about a user.
105 *
106 * @category Management
107 */
108export interface IUser {
109 /**
110 * The username of the user.
111 */
112 username: string;
113 /**
114 * The display name of the user.
115 */
116 displayName?: string;
117 /**
118 * The groups associated with this user.
119 */
120 groups?: string[];
121 /**
122 * The roles associates with this user.
123 */
124 roles?: (Role | string)[];
125 /**
126 * The password for this user.
127 */
128 password?: string;
129}
130/**
131 * Contains information about a user.
132 *
133 * @category Management
134 */
135export declare class User implements IUser {
136 /**
137 * The username of the user.
138 */
139 username: string;
140 /**
141 * The display name of the user.
142 */
143 displayName: string;
144 /**
145 * The groups associated with this user.
146 */
147 groups: string[];
148 /**
149 * The roles associates with this user.
150 */
151 roles: Role[];
152 /**
153 * This is never populated in a result returned by the server.
154 */
155 password: undefined;
156 /**
157 * @internal
158 */
159 constructor(data: User);
160 /**
161 * @internal
162 */
163 static _fromNsData(data: any): User;
164 /**
165 * @internal
166 */
167 static _toNsData(user: IUser): any;
168}
169/**
170 * Contains information about a user along with some additional meta-data
171 * about that user.
172 *
173 * @category Management
174 */
175export declare class UserAndMetadata extends User {
176 /**
177 * The domain this user is part of.
178 */
179 domain: string;
180 /**
181 * The effective roles that are associated with this user.
182 */
183 effectiveRoles: RoleAndOrigin[];
184 /**
185 * The last time the users password was changed.
186 */
187 passwordChanged: Date;
188 /**
189 * The external groups that this user is associated with.
190 */
191 externalGroups: string[];
192 /**
193 * Same as {@link effectiveRoles}, which already contains the roles
194 * including their origins.
195 *
196 * @deprecated Use {@link effectiveRoles} instead.
197 */
198 get effectiveRolesAndOrigins(): RoleAndOrigin[];
199 /**
200 * @internal
201 */
202 constructor(data: UserAndMetadata);
203 /**
204 * @internal
205 */
206 static _fromNsData(data: any): UserAndMetadata;
207}
208/**
209 * Specifies information about a group.
210 *
211 * @category Management
212 */
213export interface IGroup {
214 /**
215 * The name of the group.
216 */
217 name: string;
218 /**
219 * The description for the group.
220 */
221 description?: string;
222 /**
223 * The roles which are associated with this group.
224 */
225 roles?: (Role | string)[];
226 /**
227 * The LDAP group that this group is associated with.
228 */
229 ldapGroupReference?: string;
230}
231/**
232 * Contains information about a group.
233 *
234 * @category Management
235 */
236export declare class Group {
237 /**
238 * The name of the group.
239 */
240 name: string;
241 /**
242 * The description for the group.
243 */
244 description: string;
245 /**
246 * The roles which are associated with this group.
247 */
248 roles: Role[];
249 /**
250 * The LDAP group that this group is associated with.
251 */
252 ldapGroupReference: string | undefined;
253 /**
254 * @internal
255 */
256 constructor(data: Group);
257 /**
258 * @internal
259 */
260 static _fromNsData(data: any): Group;
261 /**
262 * @internal
263 */
264 static _toNsData(group: IGroup): any;
265}
266/**
267 * @category Management
268 */
269export interface GetUserOptions {
270 /**
271 * The domain to look in for the user.
272 */
273 domainName?: string;
274 /**
275 * The timeout for this operation, represented in milliseconds.
276 */
277 timeout?: number;
278}
279/**
280 * @category Management
281 */
282export interface GetAllUsersOptions {
283 /**
284 * The domain to look in for users.
285 */
286 domainName?: string;
287 /**
288 * The timeout for this operation, represented in milliseconds.
289 */
290 timeout?: number;
291}
292/**
293 * @category Management
294 */
295export interface UpsertUserOptions {
296 /**
297 * The domain to upsert the user within.
298 */
299 domainName?: string;
300 /**
301 * The timeout for this operation, represented in milliseconds.
302 */
303 timeout?: number;
304}
305/**
306 * @category Management
307 */
308export interface ChangePasswordOptions {
309 /**
310 * The timeout for this operation, represented in milliseconds.
311 */
312 timeout?: number;
313}
314/**
315 * @category Management
316 */
317export interface DropUserOptions {
318 /**
319 * The domain to drop the user from.
320 */
321 domainName?: string;
322 /**
323 * The timeout for this operation, represented in milliseconds.
324 */
325 timeout?: number;
326}
327/**
328 * @category Management
329 */
330export interface GetRolesOptions {
331 /**
332 * The timeout for this operation, represented in milliseconds.
333 */
334 timeout?: number;
335}
336/**
337 * @category Management
338 */
339export interface GetGroupOptions {
340 /**
341 * The timeout for this operation, represented in milliseconds.
342 */
343 timeout?: number;
344}
345/**
346 * @category Management
347 */
348export interface GetAllGroupsOptions {
349 /**
350 * The timeout for this operation, represented in milliseconds.
351 */
352 timeout?: number;
353}
354/**
355 * @category Management
356 */
357export interface UpsertGroupOptions {
358 /**
359 * The timeout for this operation, represented in milliseconds.
360 */
361 timeout?: number;
362}
363/**
364 * @category Management
365 */
366export interface DropGroupOptions {
367 /**
368 * The timeout for this operation, represented in milliseconds.
369 */
370 timeout?: number;
371}
372/**
373 * UserManager is an interface which enables the management of users,
374 * groups and roles for the cluster.
375 *
376 * @category Management
377 */
378export declare class UserManager {
379 private _cluster;
380 /**
381 * @internal
382 */
383 constructor(cluster: Cluster);
384 private get _http();
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}