-
Notifications
You must be signed in to change notification settings - Fork 303
/
users-manager.ts
1112 lines (1005 loc) · 34.5 KB
/
users-manager.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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import * as runtime from '../../../lib/runtime.js';
import type { InitOverride, ApiResponse } from '../../../lib/runtime.js';
import type {
DeletePermissionsRequest,
DeleteUserIdentityByUserId200ResponseInner,
DeleteUserRolesRequest,
GetAuthenticationMethods200Response,
GetAuthenticationMethods200ResponseOneOfInner,
GetLogs200Response,
GetOrganizationMemberRoles200Response,
GetPermissions200Response,
GetUserOrganizations200Response,
GetUsers200Response,
GetUsers200ResponseOneOfInner,
PatchAuthenticationMethodsByAuthenticationMethodIdRequest,
PostAuthenticationMethods201Response,
PostAuthenticationMethodsRequest,
PostIdentitiesRequest,
PostPermissionsRequest,
PostRecoveryCodeRegeneration200Response,
PostUserRolesRequest,
PutAuthenticationMethods200ResponseInner,
PutAuthenticationMethodsRequestInner,
UserCreate,
UserEnrollment,
UserIdentity,
UserUpdate,
GetAuthenticationMethods200ResponseOneOf,
GetLogs200ResponseOneOf,
Log,
GetPermissions200ResponseOneOf,
GetPermissions200ResponseOneOfInner,
GetOrganizations200ResponseOneOf,
GetOrganizations200ResponseOneOfInner,
GetOrganizationMemberRoles200ResponseOneOf,
GetOrganizationMemberRoles200ResponseOneOfInner,
GetUsers200ResponseOneOf,
DeleteAuthenticationMethodsRequest,
DeleteAuthenticationMethodsByAuthenticationMethodIdRequest,
DeleteAuthenticatorsRequest,
DeleteMultifactorByProviderRequest,
DeletePermissionsOperationRequest,
DeleteUserIdentityByUserIdRequest,
DeleteUserRolesOperationRequest,
DeleteUsersByIdRequest,
GetAuthenticationMethodsRequest,
GetAuthenticationMethodsByAuthenticationMethodIdRequest,
GetEnrollmentsRequest,
GetLogsByUserRequest,
GetPermissionsRequest,
GetUserOrganizationsRequest,
GetUserRolesRequest,
GetUsersRequest,
GetUsersByIdRequest,
PatchAuthenticationMethodsByAuthenticationMethodIdOperationRequest,
PatchUsersByIdRequest,
PostAuthenticationMethodsOperationRequest,
PostIdentitiesOperationRequest,
PostInvalidateRememberBrowserRequest,
PostPermissionsOperationRequest,
PostRecoveryCodeRegenerationRequest,
PostUserRolesOperationRequest,
PutAuthenticationMethodsRequest,
} from '../models/index.js';
const { BaseAPI } = runtime;
/**
*
*/
export class UsersManager extends BaseAPI {
/**
* Deletes all authentication methods for the given user
*
* @throws {RequiredError}
*/
async deleteAuthenticationMethods(
requestParameters: DeleteAuthenticationMethodsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const response = await this.request(
{
path: `/users/{id}/authentication-methods`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'DELETE',
},
initOverrides
);
return runtime.VoidApiResponse.fromResponse(response);
}
/**
* Deletes an authentication method by ID
*
* @throws {RequiredError}
*/
async deleteAuthenticationMethod(
requestParameters: DeleteAuthenticationMethodsByAuthenticationMethodIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id', 'authentication_method_id']);
const response = await this.request(
{
path: `/users/{id}/authentication-methods/{authentication_method_id}`
.replace('{id}', encodeURIComponent(String(requestParameters.id)))
.replace(
'{authentication_method_id}',
encodeURIComponent(String(requestParameters.authentication_method_id))
),
method: 'DELETE',
},
initOverrides
);
return runtime.VoidApiResponse.fromResponse(response);
}
/**
* Delete All Authenticators
*
* @throws {RequiredError}
*/
async deleteAllAuthenticators(
requestParameters: DeleteAuthenticatorsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const response = await this.request(
{
path: `/users/{id}/authenticators`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'DELETE',
},
initOverrides
);
return runtime.VoidApiResponse.fromResponse(response);
}
/**
* Delete a <a href="https://auth0.com/docs/multifactor-authentication">multifactor</a> configuration for a user. This forces the user to re-configure the multi-factor provider.
* Delete a User's Multi-factor Provider
*
* @throws {RequiredError}
*/
async deleteMultifactorProvider(
requestParameters: DeleteMultifactorByProviderRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id', 'provider']);
const response = await this.request(
{
path: `/users/{id}/multifactor/{provider}`
.replace('{id}', encodeURIComponent(String(requestParameters.id)))
.replace('{provider}', encodeURIComponent(String(requestParameters.provider))),
method: 'DELETE',
},
initOverrides
);
return runtime.VoidApiResponse.fromResponse(response);
}
/**
* Remove permissions from a user.
*
* Remove Permissions from a User
*
* @throws {RequiredError}
*/
async deletePermissions(
requestParameters: DeletePermissionsOperationRequest,
bodyParameters: DeletePermissionsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
const response = await this.request(
{
path: `/users/{id}/permissions`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'DELETE',
headers: headerParameters,
body: bodyParameters,
},
initOverrides
);
return runtime.VoidApiResponse.fromResponse(response);
}
/**
* Unlink an identity from the target user making it a separate user account again.
* Unlink a User Identity
*
* @throws {RequiredError}
*/
async unlink(
requestParameters: DeleteUserIdentityByUserIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<DeleteUserIdentityByUserId200ResponseInner>>> {
runtime.validateRequiredRequestParams(requestParameters, ['id', 'provider', 'user_id']);
const response = await this.request(
{
path: `/users/{id}/identities/{provider}/{user_id}`
.replace('{id}', encodeURIComponent(String(requestParameters.id)))
.replace('{provider}', encodeURIComponent(String(requestParameters.provider)))
.replace('{user_id}', encodeURIComponent(String(requestParameters.user_id))),
method: 'DELETE',
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Remove roles from a user.
* Removes roles from a user
*
* @throws {RequiredError}
*/
async deleteRoles(
requestParameters: DeleteUserRolesOperationRequest,
bodyParameters: DeleteUserRolesRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
const response = await this.request(
{
path: `/users/{id}/roles`.replace('{id}', encodeURIComponent(String(requestParameters.id))),
method: 'DELETE',
headers: headerParameters,
body: bodyParameters,
},
initOverrides
);
return runtime.VoidApiResponse.fromResponse(response);
}
/**
* Delete a user.
* Delete a User
*
* @throws {RequiredError}
*/
async delete(
requestParameters: DeleteUsersByIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const response = await this.request(
{
path: `/users/{id}`.replace('{id}', encodeURIComponent(String(requestParameters.id))),
method: 'DELETE',
},
initOverrides
);
return runtime.VoidApiResponse.fromResponse(response);
}
/**
* Gets a list of authentication methods
*
* @throws {RequiredError}
*/
async getAuthenticationMethods(
requestParameters: GetAuthenticationMethodsRequest & { include_totals: true },
initOverrides?: InitOverride
): Promise<ApiResponse<GetAuthenticationMethods200ResponseOneOf>>;
async getAuthenticationMethods(
requestParameters?: GetAuthenticationMethodsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<GetAuthenticationMethods200ResponseOneOfInner>>>;
async getAuthenticationMethods(
requestParameters: GetAuthenticationMethodsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetAuthenticationMethods200Response>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const queryParameters = runtime.applyQueryParams(requestParameters, [
{
key: 'page',
config: {},
},
{
key: 'per_page',
config: {},
},
{
key: 'include_totals',
config: {},
},
]);
const response = await this.request(
{
path: `/users/{id}/authentication-methods`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'GET',
query: queryParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Gets an authentication method by ID.
*
* @throws {RequiredError}
*/
async getAuthenticationMethod(
requestParameters: GetAuthenticationMethodsByAuthenticationMethodIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetAuthenticationMethods200ResponseOneOfInner>> {
runtime.validateRequiredRequestParams(requestParameters, ['id', 'authentication_method_id']);
const response = await this.request(
{
path: `/users/{id}/authentication-methods/{authentication_method_id}`
.replace('{id}', encodeURIComponent(String(requestParameters.id)))
.replace(
'{authentication_method_id}',
encodeURIComponent(String(requestParameters.authentication_method_id))
),
method: 'GET',
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Retrieve the first confirmed <a href="https://auth0.com/docs/multifactor-authentication/guardian">Guardian</a> enrollment for a user.
* Get the First Confirmed Multi-factor Authentication Enrollment
*
* @throws {RequiredError}
*/
async getEnrollments(
requestParameters: GetEnrollmentsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<UserEnrollment>>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const response = await this.request(
{
path: `/users/{id}/enrollments`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'GET',
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Retrieve log events for a specific user.
*
* Note: For more information on all possible event types, their respective acronyms and descriptions, see <a href="https://auth0.com/docs/logs/log-event-type-codes">Log Event Type Codes</a>.
*
* For more information on the list of fields that can be used in `sort`, see <a href="https://auth0.com/docs/logs/log-search-query-syntax#searchable-fields">Searchable Fields</a>.
*
* Auth0 <a href="https://auth0.com/docs/logs/retrieve-log-events-using-mgmt-api#limitations">limits the number of logs</a> you can return by search criteria to 100 logs per request. Furthermore, you may only paginate through up to 1,000 search results. If you exceed this threshold, please redefine your search.
* Get user's log events
*
* @throws {RequiredError}
*/
async getLogs(
requestParameters: GetLogsByUserRequest & { include_totals: true },
initOverrides?: InitOverride
): Promise<ApiResponse<GetLogs200ResponseOneOf>>;
async getLogs(
requestParameters?: GetLogsByUserRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<Log>>>;
async getLogs(
requestParameters: GetLogsByUserRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetLogs200Response>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const queryParameters = runtime.applyQueryParams(requestParameters, [
{
key: 'page',
config: {},
},
{
key: 'per_page',
config: {},
},
{
key: 'sort',
config: {},
},
{
key: 'include_totals',
config: {},
},
]);
const response = await this.request(
{
path: `/users/{id}/logs`.replace('{id}', encodeURIComponent(String(requestParameters.id))),
method: 'GET',
query: queryParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Retrieve all permissions associated with the user.
* Get a User's Permissions
*
* @throws {RequiredError}
*/
async getPermissions(
requestParameters: GetPermissionsRequest & { include_totals: true },
initOverrides?: InitOverride
): Promise<ApiResponse<GetPermissions200ResponseOneOf>>;
async getPermissions(
requestParameters?: GetPermissionsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<GetPermissions200ResponseOneOfInner>>>;
async getPermissions(
requestParameters: GetPermissionsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetPermissions200Response>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const queryParameters = runtime.applyQueryParams(requestParameters, [
{
key: 'per_page',
config: {},
},
{
key: 'page',
config: {},
},
{
key: 'include_totals',
config: {},
},
]);
const response = await this.request(
{
path: `/users/{id}/permissions`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'GET',
query: queryParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* This endpoint will retrieve all organizations that the specified user is a member of.
*
* List user's organizations
*
* @throws {RequiredError}
*/
async getUserOrganizations(
requestParameters: GetUserOrganizationsRequest & { include_totals: true },
initOverrides?: InitOverride
): Promise<ApiResponse<GetOrganizations200ResponseOneOf>>;
async getUserOrganizations(
requestParameters?: GetUserOrganizationsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<GetOrganizations200ResponseOneOfInner>>>;
async getUserOrganizations(
requestParameters: GetUserOrganizationsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetUserOrganizations200Response>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const queryParameters = runtime.applyQueryParams(requestParameters, [
{
key: 'page',
config: {},
},
{
key: 'per_page',
config: {},
},
{
key: 'include_totals',
config: {},
},
]);
const response = await this.request(
{
path: `/users/{id}/organizations`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'GET',
query: queryParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* List the the roles associated with a user.
* Get a user's roles
*
* @throws {RequiredError}
*/
async getRoles(
requestParameters: GetUserRolesRequest & { include_totals: true },
initOverrides?: InitOverride
): Promise<ApiResponse<GetOrganizationMemberRoles200ResponseOneOf>>;
async getRoles(
requestParameters?: GetUserRolesRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<GetOrganizationMemberRoles200ResponseOneOfInner>>>;
async getRoles(
requestParameters: GetUserRolesRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetOrganizationMemberRoles200Response>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const queryParameters = runtime.applyQueryParams(requestParameters, [
{
key: 'per_page',
config: {},
},
{
key: 'page',
config: {},
},
{
key: 'include_totals',
config: {},
},
]);
const response = await this.request(
{
path: `/users/{id}/roles`.replace('{id}', encodeURIComponent(String(requestParameters.id))),
method: 'GET',
query: queryParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Retrieve details of users. It is possible to:
*
* - Specify a search criteria for users
* - Sort the users to be returned
* - Select the fields to be returned
* - Specify the number of users to retrieve per page and the page index
* <!-- only v3 is available -->
* The <code>q</code> query parameter can be used to get users that match the specified criteria <a href="https://manage.local.dev.auth0.com/docs/users/search/v3/query-syntax">using query string syntax.</a>
*
* <a href="https://manage.local.dev.auth0.com/docs/users/search/v3">Learn more about searching for users.</a>
*
* Read about <a href="https://manage.local.dev.auth0.com/docs/users/search/best-practices">best practices</a> when working with the API endpoints for retrieving users.
*
* Auth0 limits the number of users you can return. If you exceed this threshold, please redefine your search, use the <a href="https://manage.local.dev.auth0.com/docs/api/management/v2#!/Jobs/post_users_exports">export job</a>, or the <a href="https://manage.local.dev.auth0.com/docs/extensions/user-import-export">User Import / Export</a> extension.
*
* List or Search Users
*
* @throws {RequiredError}
*/
async getAll(
requestParameters: GetUsersRequest & { include_totals: true },
initOverrides?: InitOverride
): Promise<ApiResponse<GetUsers200ResponseOneOf>>;
async getAll(
requestParameters?: GetUsersRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<GetUsers200ResponseOneOfInner>>>;
async getAll(
requestParameters: GetUsersRequest = {},
initOverrides?: InitOverride
): Promise<ApiResponse<GetUsers200Response>> {
const queryParameters = runtime.applyQueryParams(requestParameters, [
{
key: 'page',
config: {},
},
{
key: 'per_page',
config: {},
},
{
key: 'include_totals',
config: {},
},
{
key: 'sort',
config: {},
},
{
key: 'connection',
config: {},
},
{
key: 'fields',
config: {},
},
{
key: 'include_fields',
config: {},
},
{
key: 'q',
config: {},
},
{
key: 'search_engine',
config: {},
},
]);
const response = await this.request(
{
path: `/users`,
method: 'GET',
query: queryParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Retrieve user details. A list of fields to include or exclude may also be specified.
* Get a User
*
* @throws {RequiredError}
*/
async get(
requestParameters: GetUsersByIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetUsers200ResponseOneOfInner>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const queryParameters = runtime.applyQueryParams(requestParameters, [
{
key: 'fields',
config: {},
},
{
key: 'include_fields',
config: {},
},
]);
const response = await this.request(
{
path: `/users/{id}`.replace('{id}', encodeURIComponent(String(requestParameters.id))),
method: 'GET',
query: queryParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Updates an authentication method.
*
* @throws {RequiredError}
*/
async updateAuthenticationMethod(
requestParameters: PatchAuthenticationMethodsByAuthenticationMethodIdOperationRequest,
bodyParameters: PatchAuthenticationMethodsByAuthenticationMethodIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<PutAuthenticationMethods200ResponseInner>> {
runtime.validateRequiredRequestParams(requestParameters, ['id', 'authentication_method_id']);
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
const response = await this.request(
{
path: `/users/{id}/authentication-methods/{authentication_method_id}`
.replace('{id}', encodeURIComponent(String(requestParameters.id)))
.replace(
'{authentication_method_id}',
encodeURIComponent(String(requestParameters.authentication_method_id))
),
method: 'PATCH',
headers: headerParameters,
body: bodyParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Update a user.
*
* These are the attributes that can be updated at the root level:
*
* <ul>
* <li>app_metadata</li>
* <li>blocked</li>
* <li>email</li>
* <li>email_verified</li>
* <li>family_name</li>
* <li>given_name</li>
* <li>name</li>
* <li>nickname</li>
* <li>password</li>
* <li>phone_number</li>
* <li>phone_verified</li>
* <li>picture</li>
* <li>username</li>
* <li>user_metadata</li>
* <li>verify_email</li>
* </ul>
*
* Some considerations:
* <ul>
* <li>The properties of the new object will replace the old ones.</li>
* <li>The metadata fields are an exception to this rule (<code>user_metadata</code> and <code>app_metadata</code>). These properties are merged instead of being replaced but be careful, the merge only occurs on the first level.</li>
* <li>If you are updating <code>email</code>, <code>email_verified</code>, <code>phone_number</code>, <code>phone_verified</code>, <code>username</code> or <code>password</code> of a secondary identity, you need to specify the <code>connection</code> property too.</li>
* <li>If you are updating <code>email</code> or <code>phone_number</code> you can specify, optionally, the <code>client_id</code> property.</li>
* <li>Updating <code>email_verified</code> is not supported for enterprise and passwordless sms connections.</li>
* <li>Updating the <code>blocked</code> to <code>false</code> does not affect the user's blocked state from an excessive amount of incorrectly provided credentials. Use the "Unblock a user" endpoint from the "User Blocks" API to change the user's state.</li>
* </ul>
*
* <h5>Updating a field (non-metadata property)</h5>
* To mark the email address of a user as verified, the body to send should be:
* <pre><code>{ "email_verified": true }</code></pre>
*
* <h5>Updating a user metadata root property</h5>Let's assume that our test user has the following <code>user_metadata</code>:
* <pre><code>{ "user_metadata" : { "profileCode": 1479 } }</code></pre>
*
* To add the field <code>addresses</code> the body to send should be:
* <pre><code>{ "user_metadata" : { "addresses": {"work_address": "100 Industrial Way"} }}</code></pre>
*
* The modified object ends up with the following <code>user_metadata</code> property:<pre><code>{
* "user_metadata": {
* "profileCode": 1479,
* "addresses": { "work_address": "100 Industrial Way" }
* }
* }</code></pre>
*
* <h5>Updating an inner user metadata property</h5>If there's existing user metadata to which we want to add <code>"home_address": "742 Evergreen Terrace"</code> (using the <code>addresses</code> property) we should send the whole <code>addresses</code> object. Since this is a first-level object, the object will be merged in, but its own properties will not be. The body to send should be:
* <pre><code>{
* "user_metadata": {
* "addresses": {
* "work_address": "100 Industrial Way",
* "home_address": "742 Evergreen Terrace"
* }
* }
* }</code></pre>
*
* The modified object ends up with the following <code>user_metadata</code> property:
* <pre><code>{
* "user_metadata": {
* "profileCode": 1479,
* "addresses": {
* "work_address": "100 Industrial Way",
* "home_address": "742 Evergreen Terrace"
* }
* }
* }</code></pre>
*
* Update a User
*
* @throws {RequiredError}
*/
async update(
requestParameters: PatchUsersByIdRequest,
bodyParameters: UserUpdate,
initOverrides?: InitOverride
): Promise<ApiResponse<GetUsers200ResponseOneOfInner>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
const response = await this.request(
{
path: `/users/{id}`.replace('{id}', encodeURIComponent(String(requestParameters.id))),
method: 'PATCH',
headers: headerParameters,
body: bodyParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Creates an authentication method for a given user. Authentication methods created via this endpoint will be auto confirmed and should already have verification completed.
*
* @throws {RequiredError}
*/
async createAuthenticationMethod(
requestParameters: PostAuthenticationMethodsOperationRequest,
bodyParameters: PostAuthenticationMethodsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<PostAuthenticationMethods201Response>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
const response = await this.request(
{
path: `/users/{id}/authentication-methods`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'POST',
headers: headerParameters,
body: bodyParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Link two user accounts together forming a primary and secondary relationship. On successful linking, the endpoint returns the new array of the primary account identities.
*
* Note: There are two ways of invoking the endpoint:
*
* <ul>
* <li>With the authenticated primary account's JWT in the Authorization header, which has the <code>update:current_user_identities</code> scope:
* <pre>
* POST /api/v2/users/PRIMARY_ACCOUNT_USER_ID/identities
* Authorization: "Bearer PRIMARY_ACCOUNT_JWT"
* {
* "link_with": "SECONDARY_ACCOUNT_JWT"
* }
* </pre>
* In this case, only the <code>link_with</code> param is required in the body, which also contains the JWT obtained upon the secondary account's authentication.
* </li>
* <li>With a token generated by the API V2 containing the <code>update:users</code> scope:
* <pre>
* POST /api/v2/users/PRIMARY_ACCOUNT_USER_ID/identities
* Authorization: "Bearer YOUR_API_V2_TOKEN"
* {
* "provider": "SECONDARY_ACCOUNT_PROVIDER",
* "connection_id": "SECONDARY_ACCOUNT_CONNECTION_ID(OPTIONAL)",
* "user_id": "SECONDARY_ACCOUNT_USER_ID"
* }
* </pre>
* In this case you need to send <code>provider</code> and <code>user_id</code> in the body. Optionally you can also send the <code>connection_id</code> param which is suitable for identifying a particular database connection for the 'auth0' provider.
* </li>
* </ul>
* Link a User Account
*
* @throws {RequiredError}
*/
async link(
requestParameters: PostIdentitiesOperationRequest,
bodyParameters: PostIdentitiesRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<UserIdentity>>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
const response = await this.request(
{
path: `/users/{id}/identities`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'POST',
headers: headerParameters,
body: bodyParameters,
},
initOverrides
);
return runtime.JSONApiResponse.fromResponse(response);
}
/**
* Invalidate all remembered browsers across all <a href="https://auth0.com/docs/multifactor-authentication">authentication factors</a> for a user.
* Invalidate All Remembered Browsers for Multi-factor Authentication
*
* @throws {RequiredError}
*/
async invalidateRememberBrowser(
requestParameters: PostInvalidateRememberBrowserRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const response = await this.request(
{
path: `/users/{id}/multifactor/actions/invalidate-remember-browser`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'POST',
},
initOverrides
);
return runtime.VoidApiResponse.fromResponse(response);
}
/**
* Assign permissions to a user.
* Assign Permissions to a User
*
* @throws {RequiredError}
*/
async assignPermissions(
requestParameters: PostPermissionsOperationRequest,
bodyParameters: PostPermissionsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
const response = await this.request(
{
path: `/users/{id}/permissions`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
),
method: 'POST',
headers: headerParameters,
body: bodyParameters,
},
initOverrides
);
return runtime.VoidApiResponse.fromResponse(response);
}
/**
* Remove the current <a href="https://auth0.com/docs/multifactor-authentication/guardian">multi-factor authentication</a> recovery code and generate a new one.
* Generate New Multi-factor Authentication Recovery Code
*
* @throws {RequiredError}