cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v4.0.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/accounts/members.ts

308lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { APIResource } from '../../resource';
4import * as Core from '../../core';
5import * as Shared from '../shared';
6import { MembersV4PagePaginationArray } from '../shared';
7import { 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<Shared.Member> {
14 const { account_id, ...body } = params;
15 return (
16 this._client.post(`/accounts/${account_id}/members`, { body, ...options }) as Core.APIPromise<{
17 result: Shared.Member;
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<Shared.Member> {
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: Shared.Member }>
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<MembersV4PagePaginationArray, Shared.Member> {
46 const { account_id, ...query } = params;
47 return this._client.getAPIList(`/accounts/${account_id}/members`, MembersV4PagePaginationArray, {
48 query,
49 ...options,
50 });
51 }
52
53 /**
54 * Remove a member from an account.
55 */
56 delete(
57 memberId: string,
58 params: MemberDeleteParams,
59 options?: Core.RequestOptions,
60 ): Core.APIPromise<MemberDeleteResponse | null> {
61 const { account_id } = params;
62 return (
63 this._client.delete(`/accounts/${account_id}/members/${memberId}`, options) as Core.APIPromise<{
64 result: MemberDeleteResponse | null;
65 }>
66 )._thenUnwrap((obj) => obj.result);
67 }
68
69 /**
70 * Get information about a specific member of an account.
71 */
72 get(
73 memberId: string,
74 params: MemberGetParams,
75 options?: Core.RequestOptions,
76 ): Core.APIPromise<Shared.Member> {
77 const { account_id } = params;
78 return (
79 this._client.get(`/accounts/${account_id}/members/${memberId}`, options) as Core.APIPromise<{
80 result: Shared.Member;
81 }>
82 )._thenUnwrap((obj) => obj.result);
83 }
84}
85
86/**
87 * Whether the user is a member of the organization or has an invitation pending.
88 */
89export type Status = 'member' | 'invited';
90
91export interface MemberDeleteResponse {
92 /**
93 * Identifier
94 */
95 id: string;
96}
97
98export type MemberCreateParams =
99 | MemberCreateParams.IAMCreateMemberWithRoles
100 | MemberCreateParams.IAMCreateMemberWithPolicies;
101
102export declare namespace MemberCreateParams {
103 export interface IAMCreateMemberWithRoles {
104 /**
105 * Path param: Account identifier tag.
106 */
107 account_id: string;
108
109 /**
110 * Body param: The contact email address of the user.
111 */
112 email: string;
113
114 /**
115 * Body param: Array of roles associated with this member.
116 */
117 roles: Array<string>;
118
119 /**
120 * Body param:
121 */
122 status?: 'accepted' | 'pending';
123 }
124
125 export interface IAMCreateMemberWithPolicies {
126 /**
127 * Path param: Account identifier tag.
128 */
129 account_id: string;
130
131 /**
132 * Body param: The contact email address of the user.
133 */
134 email: string;
135
136 /**
137 * Body param: Array of policies associated with this member.
138 */
139 policies: Array<MemberCreateParams.IAMCreateMemberWithPolicies.Policy>;
140
141 /**
142 * Body param:
143 */
144 status?: 'accepted' | 'pending';
145 }
146
147 export namespace IAMCreateMemberWithPolicies {
148 export interface Policy {
149 /**
150 * Allow or deny operations against the resources.
151 */
152 access: 'allow' | 'deny';
153
154 /**
155 * A set of permission groups that are specified to the policy.
156 */
157 permission_groups: Array<Policy.PermissionGroup>;
158
159 /**
160 * A list of resource groups that the policy applies to.
161 */
162 resource_groups: Array<Policy.ResourceGroup>;
163 }
164
165 export namespace Policy {
166 /**
167 * A group of permissions.
168 */
169 export interface PermissionGroup {
170 /**
171 * Identifier of the group.
172 */
173 id: string;
174 }
175
176 /**
177 * A group of scoped resources.
178 */
179 export interface ResourceGroup {
180 /**
181 * Identifier of the group.
182 */
183 id: string;
184 }
185 }
186 }
187}
188
189export type MemberUpdateParams =
190 | MemberUpdateParams.IAMUpdateMemberWithRoles
191 | MemberUpdateParams.IAMUpdateMemberWithPolicies;
192
193export declare namespace MemberUpdateParams {
194 export interface IAMUpdateMemberWithRoles {
195 /**
196 * Path param: Account identifier tag.
197 */
198 account_id: string;
199
200 /**
201 * Body param: Roles assigned to this member.
202 */
203 roles?: Array<Shared.RoleParam>;
204 }
205
206 export interface IAMUpdateMemberWithPolicies {
207 /**
208 * Path param: Account identifier tag.
209 */
210 account_id: string;
211
212 /**
213 * Body param: Array of policies associated with this member.
214 */
215 policies: Array<MemberUpdateParams.IAMUpdateMemberWithPolicies.Policy>;
216 }
217
218 export namespace IAMUpdateMemberWithPolicies {
219 export interface Policy {
220 /**
221 * Allow or deny operations against the resources.
222 */
223 access: 'allow' | 'deny';
224
225 /**
226 * A set of permission groups that are specified to the policy.
227 */
228 permission_groups: Array<Policy.PermissionGroup>;
229
230 /**
231 * A list of resource groups that the policy applies to.
232 */
233 resource_groups: Array<Policy.ResourceGroup>;
234 }
235
236 export namespace Policy {
237 /**
238 * A group of permissions.
239 */
240 export interface PermissionGroup {
241 /**
242 * Identifier of the group.
243 */
244 id: string;
245 }
246
247 /**
248 * A group of scoped resources.
249 */
250 export interface ResourceGroup {
251 /**
252 * Identifier of the group.
253 */
254 id: string;
255 }
256 }
257 }
258}
259
260export interface MemberListParams extends V4PagePaginationArrayParams {
261 /**
262 * Path param: Account identifier tag.
263 */
264 account_id: string;
265
266 /**
267 * Query param: Direction to order results.
268 */
269 direction?: 'asc' | 'desc';
270
271 /**
272 * Query param: Field to order results by.
273 */
274 order?: 'user.first_name' | 'user.last_name' | 'user.email' | 'status';
275
276 /**
277 * Query param: A member's status in the account.
278 */
279 status?: 'accepted' | 'pending' | 'rejected';
280}
281
282export interface MemberDeleteParams {
283 /**
284 * Account identifier tag.
285 */
286 account_id: string;
287}
288
289export interface MemberGetParams {
290 /**
291 * Account identifier tag.
292 */
293 account_id: string;
294}
295
296export declare namespace Members {
297 export {
298 type Status as Status,
299 type MemberDeleteResponse as MemberDeleteResponse,
300 type MemberCreateParams as MemberCreateParams,
301 type MemberUpdateParams as MemberUpdateParams,
302 type MemberListParams as MemberListParams,
303 type MemberDeleteParams as MemberDeleteParams,
304 type MemberGetParams as MemberGetParams,
305 };
306}
307
308export { MembersV4PagePaginationArray };
309