cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v3.3.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/resources/accounts/members.ts

1075lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import * as Core from '../../core';
4import { APIResource } from '../../resource';
5import * as MembersAPI from './members';
6import * as Shared from '../shared';
7import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination';
8
9export class Members extends APIResource {
10 /**
11 * Add a user to the list of members for this account.
12 */
13 create(params: MemberCreateParams, options?: Core.RequestOptions): Core.APIPromise<MemberCreateResponse> {
14 const { account_id, ...body } = params;
15 return (
16 this._client.post(`/accounts/${account_id}/members`, { body, ...options }) as Core.APIPromise<{
17 result: MemberCreateResponse;
18 }>
19 )._thenUnwrap((obj) => obj.result);
20 }
21
22 /**
23 * Modify an account member.
24 */
25 update(
26 memberId: string,
27 params: MemberUpdateParams,
28 options?: Core.RequestOptions,
29 ): Core.APIPromise<MemberUpdateResponse> {
30 const { account_id, ...body } = params;
31 return (
32 this._client.put(`/accounts/${account_id}/members/${memberId}`, {
33 body,
34 ...options,
35 }) as Core.APIPromise<{ result: MemberUpdateResponse }>
36 )._thenUnwrap((obj) => obj.result);
37 }
38
39 /**
40 * List all members of an account.
41 */
42 list(
43 params: MemberListParams,
44 options?: Core.RequestOptions,
45 ): Core.PagePromise<MemberListResponsesV4PagePaginationArray, MemberListResponse> {
46 const { account_id, ...query } = params;
47 return this._client.getAPIList(
48 `/accounts/${account_id}/members`,
49 MemberListResponsesV4PagePaginationArray,
50 { query, ...options },
51 );
52 }
53
54 /**
55 * Remove a member from an account.
56 */
57 delete(
58 memberId: string,
59 params: MemberDeleteParams,
60 options?: Core.RequestOptions,
61 ): Core.APIPromise<MemberDeleteResponse | null> {
62 const { account_id } = params;
63 return (
64 this._client.delete(`/accounts/${account_id}/members/${memberId}`, options) as Core.APIPromise<{
65 result: MemberDeleteResponse | null;
66 }>
67 )._thenUnwrap((obj) => obj.result);
68 }
69
70 /**
71 * Get information about a specific member of an account.
72 */
73 get(
74 memberId: string,
75 params: MemberGetParams,
76 options?: Core.RequestOptions,
77 ): Core.APIPromise<MemberGetResponse> {
78 const { account_id } = params;
79 return (
80 this._client.get(`/accounts/${account_id}/members/${memberId}`, options) as Core.APIPromise<{
81 result: MemberGetResponse;
82 }>
83 )._thenUnwrap((obj) => obj.result);
84 }
85}
86
87export class MemberListResponsesV4PagePaginationArray extends V4PagePaginationArray<MemberListResponse> {}
88
89/**
90 * Whether the user is a member of the organization or has an invitation pending.
91 */
92export type Status = 'member' | 'invited';
93
94export interface UserWithInviteCode {
95 /**
96 * Membership identifier tag.
97 */
98 id?: string;
99
100 /**
101 * The unique activation code for the account membership.
102 */
103 code?: string;
104
105 /**
106 * Roles assigned to this member.
107 */
108 roles?: Array<UserWithInviteCode.Role>;
109
110 /**
111 * A member's status in the account.
112 */
113 status?: 'accepted' | 'pending';
114
115 /**
116 * Details of the user associated to the membership.
117 */
118 user?: UserWithInviteCode.User;
119}
120
121export namespace UserWithInviteCode {
122 export interface Role {
123 /**
124 * Role identifier tag.
125 */
126 id: string;
127
128 /**
129 * Description of role's permissions.
130 */
131 description: string;
132
133 /**
134 * Role name.
135 */
136 name: string;
137
138 permissions: Role.Permissions;
139 }
140
141 export namespace Role {
142 export interface Permissions {
143 analytics?: Shared.PermissionGrant;
144
145 billing?: Shared.PermissionGrant;
146
147 cache_purge?: Shared.PermissionGrant;
148
149 dns?: Shared.PermissionGrant;
150
151 dns_records?: Shared.PermissionGrant;
152
153 lb?: Shared.PermissionGrant;
154
155 logs?: Shared.PermissionGrant;
156
157 organization?: Shared.PermissionGrant;
158
159 ssl?: Shared.PermissionGrant;
160
161 waf?: Shared.PermissionGrant;
162
163 zone_settings?: Shared.PermissionGrant;
164
165 zones?: Shared.PermissionGrant;
166 }
167 }
168
169 /**
170 * Details of the user associated to the membership.
171 */
172 export interface User {
173 /**
174 * The contact email address of the user.
175 */
176 email: string;
177
178 /**
179 * Identifier
180 */
181 id?: string;
182
183 /**
184 * User's first name
185 */
186 first_name?: string | null;
187
188 /**
189 * User's last name
190 */
191 last_name?: string | null;
192
193 /**
194 * Indicates whether two-factor authentication is enabled for the user account.
195 * Does not apply to API authentication.
196 */
197 two_factor_authentication_enabled?: boolean;
198 }
199}
200
201export interface MemberCreateResponse {
202 /**
203 * Membership identifier tag.
204 */
205 id?: string;
206
207 /**
208 * Access policy for the membership
209 */
210 policies?: Array<MemberCreateResponse.Policy>;
211
212 /**
213 * Roles assigned to this Member.
214 */
215 roles?: Array<Shared.Role>;
216
217 /**
218 * A member's status in the account.
219 */
220 status?: 'accepted' | 'pending';
221
222 /**
223 * Details of the user associated to the membership.
224 */
225 user?: MemberCreateResponse.User;
226}
227
228export namespace MemberCreateResponse {
229 export interface Policy {
230 /**
231 * Policy identifier.
232 */
233 id?: string;
234
235 /**
236 * Allow or deny operations against the resources.
237 */
238 access?: 'allow' | 'deny';
239
240 /**
241 * A set of permission groups that are specified to the policy.
242 */
243 permission_groups?: Array<Policy.PermissionGroup>;
244
245 /**
246 * A list of resource groups that the policy applies to.
247 */
248 resource_groups?: Array<Policy.ResourceGroup>;
249 }
250
251 export namespace Policy {
252 /**
253 * A named group of permissions that map to a group of operations against
254 * resources.
255 */
256 export interface PermissionGroup {
257 /**
258 * Identifier of the group.
259 */
260 id: string;
261
262 /**
263 * Attributes associated to the permission group.
264 */
265 meta?: unknown;
266
267 /**
268 * Name of the group.
269 */
270 name?: string;
271 }
272
273 /**
274 * A group of scoped resources.
275 */
276 export interface ResourceGroup {
277 /**
278 * Identifier of the group.
279 */
280 id: string;
281
282 /**
283 * The scope associated to the resource group
284 */
285 scope: Array<ResourceGroup.Scope>;
286
287 /**
288 * Attributes associated to the resource group.
289 */
290 meta?: unknown;
291
292 /**
293 * Name of the resource group.
294 */
295 name?: string;
296 }
297
298 export namespace ResourceGroup {
299 /**
300 * A scope is a combination of scope objects which provides additional context.
301 */
302 export interface Scope {
303 /**
304 * This is a combination of pre-defined resource name and identifier (like Account
305 * ID etc.)
306 */
307 key: string;
308
309 /**
310 * A list of scope objects for additional context.
311 */
312 objects: Array<Scope.Object>;
313 }
314
315 export namespace Scope {
316 /**
317 * A scope object represents any resource that can have actions applied against
318 * invite.
319 */
320 export interface Object {
321 /**
322 * This is a combination of pre-defined resource name and identifier (like Zone ID
323 * etc.)
324 */
325 key: string;
326 }
327 }
328 }
329 }
330
331 /**
332 * Details of the user associated to the membership.
333 */
334 export interface User {
335 /**
336 * The contact email address of the user.
337 */
338 email: string;
339
340 /**
341 * Identifier
342 */
343 id?: string;
344
345 /**
346 * User's first name
347 */
348 first_name?: string | null;
349
350 /**
351 * User's last name
352 */
353 last_name?: string | null;
354
355 /**
356 * Indicates whether two-factor authentication is enabled for the user account.
357 * Does not apply to API authentication.
358 */
359 two_factor_authentication_enabled?: boolean;
360 }
361}
362
363export interface MemberUpdateResponse {
364 /**
365 * Membership identifier tag.
366 */
367 id?: string;
368
369 /**
370 * Access policy for the membership
371 */
372 policies?: Array<MemberUpdateResponse.Policy>;
373
374 /**
375 * Roles assigned to this Member.
376 */
377 roles?: Array<Shared.Role>;
378
379 /**
380 * A member's status in the account.
381 */
382 status?: 'accepted' | 'pending';
383
384 /**
385 * Details of the user associated to the membership.
386 */
387 user?: MemberUpdateResponse.User;
388}
389
390export namespace MemberUpdateResponse {
391 export interface Policy {
392 /**
393 * Policy identifier.
394 */
395 id?: string;
396
397 /**
398 * Allow or deny operations against the resources.
399 */
400 access?: 'allow' | 'deny';
401
402 /**
403 * A set of permission groups that are specified to the policy.
404 */
405 permission_groups?: Array<Policy.PermissionGroup>;
406
407 /**
408 * A list of resource groups that the policy applies to.
409 */
410 resource_groups?: Array<Policy.ResourceGroup>;
411 }
412
413 export namespace Policy {
414 /**
415 * A named group of permissions that map to a group of operations against
416 * resources.
417 */
418 export interface PermissionGroup {
419 /**
420 * Identifier of the group.
421 */
422 id: string;
423
424 /**
425 * Attributes associated to the permission group.
426 */
427 meta?: unknown;
428
429 /**
430 * Name of the group.
431 */
432 name?: string;
433 }
434
435 /**
436 * A group of scoped resources.
437 */
438 export interface ResourceGroup {
439 /**
440 * Identifier of the group.
441 */
442 id: string;
443
444 /**
445 * The scope associated to the resource group
446 */
447 scope: Array<ResourceGroup.Scope>;
448
449 /**
450 * Attributes associated to the resource group.
451 */
452 meta?: unknown;
453
454 /**
455 * Name of the resource group.
456 */
457 name?: string;
458 }
459
460 export namespace ResourceGroup {
461 /**
462 * A scope is a combination of scope objects which provides additional context.
463 */
464 export interface Scope {
465 /**
466 * This is a combination of pre-defined resource name and identifier (like Account
467 * ID etc.)
468 */
469 key: string;
470
471 /**
472 * A list of scope objects for additional context.
473 */
474 objects: Array<Scope.Object>;
475 }
476
477 export namespace Scope {
478 /**
479 * A scope object represents any resource that can have actions applied against
480 * invite.
481 */
482 export interface Object {
483 /**
484 * This is a combination of pre-defined resource name and identifier (like Zone ID
485 * etc.)
486 */
487 key: string;
488 }
489 }
490 }
491 }
492
493 /**
494 * Details of the user associated to the membership.
495 */
496 export interface User {
497 /**
498 * The contact email address of the user.
499 */
500 email: string;
501
502 /**
503 * Identifier
504 */
505 id?: string;
506
507 /**
508 * User's first name
509 */
510 first_name?: string | null;
511
512 /**
513 * User's last name
514 */
515 last_name?: string | null;
516
517 /**
518 * Indicates whether two-factor authentication is enabled for the user account.
519 * Does not apply to API authentication.
520 */
521 two_factor_authentication_enabled?: boolean;
522 }
523}
524
525export interface MemberListResponse {
526 /**
527 * Membership identifier tag.
528 */
529 id?: string;
530
531 /**
532 * Access policy for the membership
533 */
534 policies?: Array<MemberListResponse.Policy>;
535
536 /**
537 * Roles assigned to this Member.
538 */
539 roles?: Array<Shared.Role>;
540
541 /**
542 * A member's status in the account.
543 */
544 status?: 'accepted' | 'pending';
545
546 /**
547 * Details of the user associated to the membership.
548 */
549 user?: MemberListResponse.User;
550}
551
552export namespace MemberListResponse {
553 export interface Policy {
554 /**
555 * Policy identifier.
556 */
557 id?: string;
558
559 /**
560 * Allow or deny operations against the resources.
561 */
562 access?: 'allow' | 'deny';
563
564 /**
565 * A set of permission groups that are specified to the policy.
566 */
567 permission_groups?: Array<Policy.PermissionGroup>;
568
569 /**
570 * A list of resource groups that the policy applies to.
571 */
572 resource_groups?: Array<Policy.ResourceGroup>;
573 }
574
575 export namespace Policy {
576 /**
577 * A named group of permissions that map to a group of operations against
578 * resources.
579 */
580 export interface PermissionGroup {
581 /**
582 * Identifier of the group.
583 */
584 id: string;
585
586 /**
587 * Attributes associated to the permission group.
588 */
589 meta?: unknown;
590
591 /**
592 * Name of the group.
593 */
594 name?: string;
595 }
596
597 /**
598 * A group of scoped resources.
599 */
600 export interface ResourceGroup {
601 /**
602 * Identifier of the group.
603 */
604 id: string;
605
606 /**
607 * The scope associated to the resource group
608 */
609 scope: Array<ResourceGroup.Scope>;
610
611 /**
612 * Attributes associated to the resource group.
613 */
614 meta?: unknown;
615
616 /**
617 * Name of the resource group.
618 */
619 name?: string;
620 }
621
622 export namespace ResourceGroup {
623 /**
624 * A scope is a combination of scope objects which provides additional context.
625 */
626 export interface Scope {
627 /**
628 * This is a combination of pre-defined resource name and identifier (like Account
629 * ID etc.)
630 */
631 key: string;
632
633 /**
634 * A list of scope objects for additional context.
635 */
636 objects: Array<Scope.Object>;
637 }
638
639 export namespace Scope {
640 /**
641 * A scope object represents any resource that can have actions applied against
642 * invite.
643 */
644 export interface Object {
645 /**
646 * This is a combination of pre-defined resource name and identifier (like Zone ID
647 * etc.)
648 */
649 key: string;
650 }
651 }
652 }
653 }
654
655 /**
656 * Details of the user associated to the membership.
657 */
658 export interface User {
659 /**
660 * The contact email address of the user.
661 */
662 email: string;
663
664 /**
665 * Identifier
666 */
667 id?: string;
668
669 /**
670 * User's first name
671 */
672 first_name?: string | null;
673
674 /**
675 * User's last name
676 */
677 last_name?: string | null;
678
679 /**
680 * Indicates whether two-factor authentication is enabled for the user account.
681 * Does not apply to API authentication.
682 */
683 two_factor_authentication_enabled?: boolean;
684 }
685}
686
687export interface MemberDeleteResponse {
688 /**
689 * Identifier
690 */
691 id: string;
692}
693
694export interface MemberGetResponse {
695 /**
696 * Membership identifier tag.
697 */
698 id?: string;
699
700 /**
701 * Access policy for the membership
702 */
703 policies?: Array<MemberGetResponse.Policy>;
704
705 /**
706 * Roles assigned to this Member.
707 */
708 roles?: Array<Shared.Role>;
709
710 /**
711 * A member's status in the account.
712 */
713 status?: 'accepted' | 'pending';
714
715 /**
716 * Details of the user associated to the membership.
717 */
718 user?: MemberGetResponse.User;
719}
720
721export namespace MemberGetResponse {
722 export interface Policy {
723 /**
724 * Policy identifier.
725 */
726 id?: string;
727
728 /**
729 * Allow or deny operations against the resources.
730 */
731 access?: 'allow' | 'deny';
732
733 /**
734 * A set of permission groups that are specified to the policy.
735 */
736 permission_groups?: Array<Policy.PermissionGroup>;
737
738 /**
739 * A list of resource groups that the policy applies to.
740 */
741 resource_groups?: Array<Policy.ResourceGroup>;
742 }
743
744 export namespace Policy {
745 /**
746 * A named group of permissions that map to a group of operations against
747 * resources.
748 */
749 export interface PermissionGroup {
750 /**
751 * Identifier of the group.
752 */
753 id: string;
754
755 /**
756 * Attributes associated to the permission group.
757 */
758 meta?: unknown;
759
760 /**
761 * Name of the group.
762 */
763 name?: string;
764 }
765
766 /**
767 * A group of scoped resources.
768 */
769 export interface ResourceGroup {
770 /**
771 * Identifier of the group.
772 */
773 id: string;
774
775 /**
776 * The scope associated to the resource group
777 */
778 scope: Array<ResourceGroup.Scope>;
779
780 /**
781 * Attributes associated to the resource group.
782 */
783 meta?: unknown;
784
785 /**
786 * Name of the resource group.
787 */
788 name?: string;
789 }
790
791 export namespace ResourceGroup {
792 /**
793 * A scope is a combination of scope objects which provides additional context.
794 */
795 export interface Scope {
796 /**
797 * This is a combination of pre-defined resource name and identifier (like Account
798 * ID etc.)
799 */
800 key: string;
801
802 /**
803 * A list of scope objects for additional context.
804 */
805 objects: Array<Scope.Object>;
806 }
807
808 export namespace Scope {
809 /**
810 * A scope object represents any resource that can have actions applied against
811 * invite.
812 */
813 export interface Object {
814 /**
815 * This is a combination of pre-defined resource name and identifier (like Zone ID
816 * etc.)
817 */
818 key: string;
819 }
820 }
821 }
822 }
823
824 /**
825 * Details of the user associated to the membership.
826 */
827 export interface User {
828 /**
829 * The contact email address of the user.
830 */
831 email: string;
832
833 /**
834 * Identifier
835 */
836 id?: string;
837
838 /**
839 * User's first name
840 */
841 first_name?: string | null;
842
843 /**
844 * User's last name
845 */
846 last_name?: string | null;
847
848 /**
849 * Indicates whether two-factor authentication is enabled for the user account.
850 * Does not apply to API authentication.
851 */
852 two_factor_authentication_enabled?: boolean;
853 }
854}
855
856export type MemberCreateParams =
857 | MemberCreateParams.IAMCreateMemberWithRoles
858 | MemberCreateParams.IAMCreateMemberWithPolicies;
859
860export namespace MemberCreateParams {
861 export interface IAMCreateMemberWithRoles {
862 /**
863 * Path param: Account identifier tag.
864 */
865 account_id: string;
866
867 /**
868 * Body param: The contact email address of the user.
869 */
870 email: string;
871
872 /**
873 * Body param: Array of roles associated with this member.
874 */
875 roles: Array<string>;
876
877 /**
878 * Body param:
879 */
880 status?: 'accepted' | 'pending';
881 }
882
883 export interface IAMCreateMemberWithPolicies {
884 /**
885 * Path param: Account identifier tag.
886 */
887 account_id: string;
888
889 /**
890 * Body param: The contact email address of the user.
891 */
892 email: string;
893
894 /**
895 * Body param: Array of policies associated with this member.
896 */
897 policies: Array<MemberCreateParams.IAMCreateMemberWithPolicies.Policy>;
898
899 /**
900 * Body param:
901 */
902 status?: 'accepted' | 'pending';
903 }
904
905 export namespace IAMCreateMemberWithPolicies {
906 export interface Policy {
907 /**
908 * Allow or deny operations against the resources.
909 */
910 access: 'allow' | 'deny';
911
912 /**
913 * A set of permission groups that are specified to the policy.
914 */
915 permission_groups: Array<Policy.PermissionGroup>;
916
917 /**
918 * A list of resource groups that the policy applies to.
919 */
920 resource_groups: Array<Policy.ResourceGroup>;
921 }
922
923 export namespace Policy {
924 /**
925 * A group of permissions.
926 */
927 export interface PermissionGroup {
928 /**
929 * Identifier of the group.
930 */
931 id: string;
932 }
933
934 /**
935 * A group of scoped resources.
936 */
937 export interface ResourceGroup {
938 /**
939 * Identifier of the group.
940 */
941 id: string;
942 }
943 }
944 }
945}
946
947export type MemberUpdateParams = MemberUpdateParams.Member | MemberUpdateParams.IAMUpdateMemberWithPolicies;
948
949export namespace MemberUpdateParams {
950 export interface Member {
951 /**
952 * Path param: Account identifier tag.
953 */
954 account_id: string;
955
956 /**
957 * Body param: Roles assigned to this member.
958 */
959 roles?: Array<MemberUpdateParams.Member.Role>;
960 }
961
962 export namespace Member {
963 export interface Role {
964 /**
965 * Role identifier tag.
966 */
967 id: string;
968 }
969 }
970
971 export interface IAMUpdateMemberWithPolicies {
972 /**
973 * Path param: Account identifier tag.
974 */
975 account_id: string;
976
977 /**
978 * Body param: Array of policies associated with this member.
979 */
980 policies: Array<MemberUpdateParams.IAMUpdateMemberWithPolicies.Policy>;
981 }
982
983 export namespace IAMUpdateMemberWithPolicies {
984 export interface Policy {
985 /**
986 * Allow or deny operations against the resources.
987 */
988 access: 'allow' | 'deny';
989
990 /**
991 * A set of permission groups that are specified to the policy.
992 */
993 permission_groups: Array<Policy.PermissionGroup>;
994
995 /**
996 * A list of resource groups that the policy applies to.
997 */
998 resource_groups: Array<Policy.ResourceGroup>;
999 }
1000
1001 export namespace Policy {
1002 /**
1003 * A group of permissions.
1004 */
1005 export interface PermissionGroup {
1006 /**
1007 * Identifier of the group.
1008 */
1009 id: string;
1010 }
1011
1012 /**
1013 * A group of scoped resources.
1014 */
1015 export interface ResourceGroup {
1016 /**
1017 * Identifier of the group.
1018 */
1019 id: string;
1020 }
1021 }
1022 }
1023}
1024
1025export interface MemberListParams extends V4PagePaginationArrayParams {
1026 /**
1027 * Path param: Account identifier tag.
1028 */
1029 account_id: string;
1030
1031 /**
1032 * Query param: Direction to order results.
1033 */
1034 direction?: 'asc' | 'desc';
1035
1036 /**
1037 * Query param: Field to order results by.
1038 */
1039 order?: 'user.first_name' | 'user.last_name' | 'user.email' | 'status';
1040
1041 /**
1042 * Query param: A member's status in the account.
1043 */
1044 status?: 'accepted' | 'pending' | 'rejected';
1045}
1046
1047export interface MemberDeleteParams {
1048 /**
1049 * Account identifier tag.
1050 */
1051 account_id: string;
1052}
1053
1054export interface MemberGetParams {
1055 /**
1056 * Account identifier tag.
1057 */
1058 account_id: string;
1059}
1060
1061export namespace Members {
1062 export import Status = MembersAPI.Status;
1063 export import UserWithInviteCode = MembersAPI.UserWithInviteCode;
1064 export import MemberCreateResponse = MembersAPI.MemberCreateResponse;
1065 export import MemberUpdateResponse = MembersAPI.MemberUpdateResponse;
1066 export import MemberListResponse = MembersAPI.MemberListResponse;
1067 export import MemberDeleteResponse = MembersAPI.MemberDeleteResponse;
1068 export import MemberGetResponse = MembersAPI.MemberGetResponse;
1069 export import MemberListResponsesV4PagePaginationArray = MembersAPI.MemberListResponsesV4PagePaginationArray;
1070 export import MemberCreateParams = MembersAPI.MemberCreateParams;
1071 export import MemberUpdateParams = MembersAPI.MemberUpdateParams;
1072 export import MemberListParams = MembersAPI.MemberListParams;
1073 export import MemberDeleteParams = MembersAPI.MemberDeleteParams;
1074 export import MemberGetParams = MembersAPI.MemberGetParams;
1075}
1076