This repository has been archived by the owner on Feb 8, 2024. It is now read-only.
/
people.api.ts
418 lines (356 loc) · 13.1 KB
/
people.api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ClientBody } from '../model/clientBody';
import { PasswordResetBody } from '../model/passwordResetBody';
import { PersonBodyCreate } from '../model/personBodyCreate';
import { PersonBodyUpdate } from '../model/personBodyUpdate';
import { PersonEntry } from '../model/personEntry';
import { PersonPaging } from '../model/personPaging';
import { BaseApi } from './base.api';
import { throwIfNotDefined } from '../../../assert';
import { buildCollectionParam } from '../../../alfrescoApiClient';
import { ContentFieldsQuery, ContentIncludeQuery, ContentPagingQuery } from './types';
/**
* People service.
* @module PeopleApi
*/
export class PeopleApi extends BaseApi {
/**
* Create person
*
* **Note:** this endpoint is available in Alfresco 5.2 and newer versions.
Create a person.
If applicable, the given person's login access can also be optionally disabled.
You must have admin rights to create a person.
You can set custom properties when you create a person:
JSON
{
\"id\": \"abeecher\",
\"firstName\": \"Alice\",
\"lastName\": \"Beecher\",
\"displayName\": \"Alice Beecher\",
\"email\": \"abeecher@example.com\",
\"password\": \"secret\",
\"properties\":
{
\"my:property\": \"The value\"
}
}
**Note:** setting properties of type d:content and d:category are not supported.
*
* @param personBodyCreate The person details.
* @param opts Optional parameters
* @return Promise<PersonEntry>
*/
createPerson(personBodyCreate: PersonBodyCreate, opts?: ContentFieldsQuery): Promise<PersonEntry> {
throwIfNotDefined(personBodyCreate, 'personBodyCreate');
const queryParams = {
fields: buildCollectionParam(opts?.fields, 'csv')
};
return this.post({
path: '/people',
queryParams,
bodyParam: personBodyCreate,
returnType: PersonEntry
});
}
/**
* Delete avatar image
*
* **Note:** this endpoint is available in Alfresco 5.2.2 and newer versions.
*
* Deletes the avatar image related to person **personId**.
*
* You must be the person or have admin rights to update a person's avatar.
*
* You can use the -me- string in place of <personId> to specify the currently authenticated user.
*
* @param personId The identifier of a person.
* @return Promise<{}>
*/
deleteAvatarImage(personId: string): Promise<void> {
throwIfNotDefined(personId, 'personId');
const pathParams = {
personId: personId
};
return this.delete({
path: '/people/{personId}/avatar',
pathParams
});
}
/**
* Get avatar image
*
* **Note:** this endpoint is available in Alfresco 5.2.2 and newer versions.
Gets the avatar image related to the person **personId**. If the person has no related avatar then
the **placeholder** query parameter can be optionally used to request a placeholder image to be returned.
You can use the -me- string in place of <personId> to specify the currently authenticated user.
*
* @param personId The identifier of a person.
* @param opts Optional parameters
* @param opts.attachment **true** enables a web browser to download the file as an attachment.
**false** means a web browser may preview the file in a new tab or window, but not
download the file.
You can only set this parameter to **false** if the content type of the file is in the supported list;
for example, certain image files and PDF files.
If the content type is not supported for preview, then a value of **false** is ignored, and
the attachment will be returned in the response.
(default to true)
* @param opts.ifModifiedSince Only returns the content if it has been modified since the date provided.
Use the date format defined by HTTP. For example, Wed, 09 Mar 2016 16:56:34 GMT.
* @param opts.placeholder If **true** and there is no avatar for this **personId**
then the placeholder image is returned, rather than a 404 response.
(default to true)
* @return Promise<Blob>
*/
getAvatarImage(personId: string, opts?: { attachment?: boolean; placeholder?: boolean; ifModifiedSince?: string }): Promise<Blob> {
throwIfNotDefined(personId, 'personId');
const pathParams = {
personId
};
const queryParams = {
attachment: opts?.attachment,
placeholder: opts?.placeholder
};
const headerParams = {
'If-Modified-Since': opts?.ifModifiedSince
};
const accepts = ['application/octet-stream'];
return this.get({
path: '/people/{personId}/avatar',
pathParams,
queryParams,
headerParams,
accepts,
returnType: 'blob'
});
}
/**
* Get a person
*
* Gets information for the person **personId**.
*
* You can use the -me- string in place of <personId> to specify the currently authenticated user.
*
* @param personId The identifier of a person.
* @param opts Optional parameters
* @return Promise<PersonEntry>
*/
getPerson(personId: string, opts?: ContentFieldsQuery): Promise<PersonEntry> {
throwIfNotDefined(personId, 'personId');
const pathParams = {
personId
};
const queryParams = {
fields: buildCollectionParam(opts?.fields, 'csv')
};
return this.get({
path: '/people/{personId}',
pathParams,
queryParams,
returnType: PersonEntry
});
}
/**
* List people
*
* **Note:** this endpoint is available in Alfresco 5.2 and newer versions.
*
* List people.
*
* You can use the **include** parameter to return any additional information.
*
* The default sort order for the returned list is for people to be sorted by ascending id.
* You can override the default by using the **orderBy** parameter.
*
* You can use any of the following fields to order the results:
* - id
* - firstName
* - lastName
*
* @param opts Optional parameters
* @param opts.orderBy A string to control the order of the entities returned in a list. You can use the **orderBy** parameter to
* sort the list by one or more fields.
*
* Each field has a default sort order, which is normally ascending order. Read the API method implementation notes
* above to check if any fields used in this method have a descending default search order.
*
* To sort the entities in a specific order, you can use the **ASC** and **DESC** keywords for any field.
* @return Promise<PersonPaging>
*/
listPeople(
opts?: {
orderBy?: string[];
} & ContentPagingQuery &
ContentIncludeQuery &
ContentFieldsQuery
): Promise<PersonPaging> {
const queryParams = {
skipCount: opts?.skipCount,
maxItems: opts?.maxItems,
orderBy: buildCollectionParam(opts?.orderBy, 'csv'),
include: buildCollectionParam(opts?.include, 'csv'),
fields: buildCollectionParam(opts?.fields, 'csv')
};
return this.get({
path: '/people',
queryParams,
returnType: PersonPaging
});
}
/**
* Request password reset
*
* **Note:** this endpoint is available in Alfresco 5.2.1 and newer versions.
Initiates the reset password workflow to send an email with reset password instruction to the user's registered email.
The client is mandatory in the request body. For example:
JSON
{
\"client\": \"myClient\"
}
**Note:** The client must be registered before this API can send an email. See [server documentation]. However, out-of-the-box
share is registered as a default client, so you could pass **share** as the client name:
JSON
{
\"client\": \"share\"
}
**Note:** No authentication is required to call this endpoint.
*
* @param personId The identifier of a person.
* @param clientBody The client name to send email with app-specific url.
* @return Promise<{}>
*/
requestPasswordReset(personId: string, clientBody: ClientBody): Promise<any> {
throwIfNotDefined(personId, 'personId');
throwIfNotDefined(clientBody, 'clientBody');
const pathParams = {
personId
};
return this.post({
path: '/people/{personId}/request-password-reset',
pathParams,
bodyParam: clientBody
});
}
/**
* Reset password
*
* **Note:** this endpoint is available in Alfresco 5.2.1 and newer versions.
Resets user's password
The password, id and key properties are mandatory in the request body. For example:
JSON
{
\"password\":\"newPassword\",
\"id\":\"activiti$10\",
\"key\":\"4dad6d00-0daf-413a-b200-f64af4e12345\"
}
**Note:** No authentication is required to call this endpoint.
*
* @param personId The identifier of a person.
* @param passwordResetBody The reset password details
* @return Promise<{}>
*/
resetPassword(personId: string, passwordResetBody: PasswordResetBody): Promise<any> {
throwIfNotDefined(personId, 'personId');
throwIfNotDefined(passwordResetBody, 'passwordResetBody');
const pathParams = {
personId
};
return this.post({
path: '/people/{personId}/reset-password',
pathParams,
bodyParam: passwordResetBody
});
}
/**
* Update avatar image
*
* **Note:** this endpoint is available in Alfresco 5.2.2 and newer versions.
*
* Updates the avatar image related to the person **personId**.
*
* The request body should be the binary stream for the avatar image. The content type of the file
* should be an image file. This will be used to generate an \"avatar\" thumbnail rendition.
*
* You must be the person or have admin rights to update a person's avatar.
*
* You can use the -me- string in place of <personId> to specify the currently authenticated user.
*
* @param personId The identifier of a person.
* @param contentBodyUpdate The binary content
* @return Promise<{}>
*/
updateAvatarImage(personId: string, contentBodyUpdate: string): Promise<any> {
throwIfNotDefined(personId, 'personId');
throwIfNotDefined(contentBodyUpdate, 'contentBodyUpdate');
const pathParams = {
personId: personId
};
const contentTypes = ['application/octet-stream'];
return this.put({
path: '/people/{personId}/avatar',
pathParams,
bodyParam: contentBodyUpdate,
contentTypes
});
}
/**
* Update person
*
* **Note:** this endpoint is available in Alfresco 5.2 and newer versions.
Update the given person's details.
You can use the -me- string in place of <personId> to specify the currently authenticated user.
If applicable, the given person's login access can also be optionally disabled or re-enabled.
You must have admin rights to update a person — unless updating your own details.
If you are changing your password, as a non-admin user, then the existing password must also
be supplied (using the oldPassword field in addition to the new password value).
Admin users cannot be disabled by setting enabled to false.
Non-admin users may not disable themselves.
You can set custom properties when you update a person:
JSON
{
\"firstName\": \"Alice\",
\"properties\":
{
\"my:property\": \"The value\"
}
}
**Note:** setting properties of type d:content and d:category are not supported.
*
* @param personId The identifier of a person.
* @param personBodyUpdate The person details.
* @param opts Optional parameters
* @return Promise<PersonEntry>
*/
updatePerson(personId: string, personBodyUpdate: PersonBodyUpdate, opts?: ContentFieldsQuery): Promise<PersonEntry> {
throwIfNotDefined(personId, 'personId');
throwIfNotDefined(personBodyUpdate, 'personBodyUpdate');
const pathParams = {
personId
};
const queryParams = {
fields: buildCollectionParam(opts?.fields, 'csv')
};
return this.put({
path: '/people/{personId}',
pathParams,
queryParams,
bodyParam: personBodyUpdate,
returnType: PersonEntry
});
}
}