cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/accounts/members.ts
546lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import * as Core from 'cloudflare/core'; |
| 4 | import { APIResource } from 'cloudflare/resource'; |
| 5 | import * as MembersAPI from 'cloudflare/resources/accounts/members'; |
| 6 | import * as RolesAPI from 'cloudflare/resources/accounts/roles'; |
| 7 | import { V4PagePaginationArray, type V4PagePaginationArrayParams } from 'cloudflare/pagination'; |
| 8 | |
| 9 | export 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<AccountMemberWithID> { |
| 14 | const { account_id, ...body } = params; |
| 15 | return ( |
| 16 | this._client.post(`/accounts/${account_id}/members`, { body, ...options }) as Core.APIPromise<{ |
| 17 | result: AccountMemberWithID; |
| 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<AccountMember> { |
| 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: AccountMember }> |
| 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<AccountMember> { |
| 78 | const { account_id } = params; |
| 79 | return ( |
| 80 | this._client.get(`/accounts/${account_id}/members/${memberId}`, options) as Core.APIPromise<{ |
| 81 | result: AccountMember; |
| 82 | }> |
| 83 | )._thenUnwrap((obj) => obj.result); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | export class MemberListResponsesV4PagePaginationArray extends V4PagePaginationArray<MemberListResponse> {} |
| 88 | |
| 89 | export interface AccountMember { |
| 90 | /** |
| 91 | * Membership identifier tag. |
| 92 | */ |
| 93 | id: string; |
| 94 | |
| 95 | /** |
| 96 | * Roles assigned to this member. |
| 97 | */ |
| 98 | roles: Array<AccountMember.Role>; |
| 99 | |
| 100 | status: unknown; |
| 101 | |
| 102 | user: AccountMember.User; |
| 103 | } |
| 104 | |
| 105 | export namespace AccountMember { |
| 106 | export interface Role { |
| 107 | /** |
| 108 | * Role identifier tag. |
| 109 | */ |
| 110 | id: string; |
| 111 | |
| 112 | /** |
| 113 | * Description of role's permissions. |
| 114 | */ |
| 115 | description: string; |
| 116 | |
| 117 | /** |
| 118 | * Role name. |
| 119 | */ |
| 120 | name: string; |
| 121 | |
| 122 | permissions: Role.Permissions; |
| 123 | } |
| 124 | |
| 125 | export namespace Role { |
| 126 | export interface Permissions { |
| 127 | analytics?: Permissions.Analytics; |
| 128 | |
| 129 | billing?: Permissions.Billing; |
| 130 | |
| 131 | cache_purge?: Permissions.CachePurge; |
| 132 | |
| 133 | dns?: Permissions.DNS; |
| 134 | |
| 135 | dns_records?: Permissions.DNSRecords; |
| 136 | |
| 137 | lb?: Permissions.Lb; |
| 138 | |
| 139 | logs?: Permissions.Logs; |
| 140 | |
| 141 | organization?: Permissions.Organization; |
| 142 | |
| 143 | ssl?: Permissions.SSL; |
| 144 | |
| 145 | waf?: Permissions.WAF; |
| 146 | |
| 147 | zone_settings?: Permissions.ZoneSettings; |
| 148 | |
| 149 | zones?: Permissions.Zones; |
| 150 | } |
| 151 | |
| 152 | export namespace Permissions { |
| 153 | export interface Analytics { |
| 154 | read?: boolean; |
| 155 | |
| 156 | write?: boolean; |
| 157 | } |
| 158 | |
| 159 | export interface Billing { |
| 160 | read?: boolean; |
| 161 | |
| 162 | write?: boolean; |
| 163 | } |
| 164 | |
| 165 | export interface CachePurge { |
| 166 | read?: boolean; |
| 167 | |
| 168 | write?: boolean; |
| 169 | } |
| 170 | |
| 171 | export interface DNS { |
| 172 | read?: boolean; |
| 173 | |
| 174 | write?: boolean; |
| 175 | } |
| 176 | |
| 177 | export interface DNSRecords { |
| 178 | read?: boolean; |
| 179 | |
| 180 | write?: boolean; |
| 181 | } |
| 182 | |
| 183 | export interface Lb { |
| 184 | read?: boolean; |
| 185 | |
| 186 | write?: boolean; |
| 187 | } |
| 188 | |
| 189 | export interface Logs { |
| 190 | read?: boolean; |
| 191 | |
| 192 | write?: boolean; |
| 193 | } |
| 194 | |
| 195 | export interface Organization { |
| 196 | read?: boolean; |
| 197 | |
| 198 | write?: boolean; |
| 199 | } |
| 200 | |
| 201 | export interface SSL { |
| 202 | read?: boolean; |
| 203 | |
| 204 | write?: boolean; |
| 205 | } |
| 206 | |
| 207 | export interface WAF { |
| 208 | read?: boolean; |
| 209 | |
| 210 | write?: boolean; |
| 211 | } |
| 212 | |
| 213 | export interface ZoneSettings { |
| 214 | read?: boolean; |
| 215 | |
| 216 | write?: boolean; |
| 217 | } |
| 218 | |
| 219 | export interface Zones { |
| 220 | read?: boolean; |
| 221 | |
| 222 | write?: boolean; |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | export interface User { |
| 228 | /** |
| 229 | * The contact email address of the user. |
| 230 | */ |
| 231 | email: string; |
| 232 | |
| 233 | /** |
| 234 | * Identifier |
| 235 | */ |
| 236 | id?: string; |
| 237 | |
| 238 | /** |
| 239 | * User's first name |
| 240 | */ |
| 241 | first_name?: string | null; |
| 242 | |
| 243 | /** |
| 244 | * User's last name |
| 245 | */ |
| 246 | last_name?: string | null; |
| 247 | |
| 248 | /** |
| 249 | * Indicates whether two-factor authentication is enabled for the user account. |
| 250 | * Does not apply to API authentication. |
| 251 | */ |
| 252 | two_factor_authentication_enabled?: boolean; |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | export interface AccountMemberWithID { |
| 257 | /** |
| 258 | * Membership identifier tag. |
| 259 | */ |
| 260 | id: string; |
| 261 | |
| 262 | /** |
| 263 | * Roles assigned to this member. |
| 264 | */ |
| 265 | roles: Array<AccountMemberWithID.Role>; |
| 266 | |
| 267 | status: unknown; |
| 268 | |
| 269 | user: AccountMemberWithID.User; |
| 270 | |
| 271 | /** |
| 272 | * The unique activation code for the account membership. |
| 273 | */ |
| 274 | code?: string; |
| 275 | } |
| 276 | |
| 277 | export namespace AccountMemberWithID { |
| 278 | export interface Role { |
| 279 | /** |
| 280 | * Role identifier tag. |
| 281 | */ |
| 282 | id: string; |
| 283 | |
| 284 | /** |
| 285 | * Description of role's permissions. |
| 286 | */ |
| 287 | description: string; |
| 288 | |
| 289 | /** |
| 290 | * Role name. |
| 291 | */ |
| 292 | name: string; |
| 293 | |
| 294 | permissions: Role.Permissions; |
| 295 | } |
| 296 | |
| 297 | export namespace Role { |
| 298 | export interface Permissions { |
| 299 | analytics?: Permissions.Analytics; |
| 300 | |
| 301 | billing?: Permissions.Billing; |
| 302 | |
| 303 | cache_purge?: Permissions.CachePurge; |
| 304 | |
| 305 | dns?: Permissions.DNS; |
| 306 | |
| 307 | dns_records?: Permissions.DNSRecords; |
| 308 | |
| 309 | lb?: Permissions.Lb; |
| 310 | |
| 311 | logs?: Permissions.Logs; |
| 312 | |
| 313 | organization?: Permissions.Organization; |
| 314 | |
| 315 | ssl?: Permissions.SSL; |
| 316 | |
| 317 | waf?: Permissions.WAF; |
| 318 | |
| 319 | zone_settings?: Permissions.ZoneSettings; |
| 320 | |
| 321 | zones?: Permissions.Zones; |
| 322 | } |
| 323 | |
| 324 | export namespace Permissions { |
| 325 | export interface Analytics { |
| 326 | read?: boolean; |
| 327 | |
| 328 | write?: boolean; |
| 329 | } |
| 330 | |
| 331 | export interface Billing { |
| 332 | read?: boolean; |
| 333 | |
| 334 | write?: boolean; |
| 335 | } |
| 336 | |
| 337 | export interface CachePurge { |
| 338 | read?: boolean; |
| 339 | |
| 340 | write?: boolean; |
| 341 | } |
| 342 | |
| 343 | export interface DNS { |
| 344 | read?: boolean; |
| 345 | |
| 346 | write?: boolean; |
| 347 | } |
| 348 | |
| 349 | export interface DNSRecords { |
| 350 | read?: boolean; |
| 351 | |
| 352 | write?: boolean; |
| 353 | } |
| 354 | |
| 355 | export interface Lb { |
| 356 | read?: boolean; |
| 357 | |
| 358 | write?: boolean; |
| 359 | } |
| 360 | |
| 361 | export interface Logs { |
| 362 | read?: boolean; |
| 363 | |
| 364 | write?: boolean; |
| 365 | } |
| 366 | |
| 367 | export interface Organization { |
| 368 | read?: boolean; |
| 369 | |
| 370 | write?: boolean; |
| 371 | } |
| 372 | |
| 373 | export interface SSL { |
| 374 | read?: boolean; |
| 375 | |
| 376 | write?: boolean; |
| 377 | } |
| 378 | |
| 379 | export interface WAF { |
| 380 | read?: boolean; |
| 381 | |
| 382 | write?: boolean; |
| 383 | } |
| 384 | |
| 385 | export interface ZoneSettings { |
| 386 | read?: boolean; |
| 387 | |
| 388 | write?: boolean; |
| 389 | } |
| 390 | |
| 391 | export interface Zones { |
| 392 | read?: boolean; |
| 393 | |
| 394 | write?: boolean; |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | export interface User { |
| 400 | /** |
| 401 | * The contact email address of the user. |
| 402 | */ |
| 403 | email: string; |
| 404 | |
| 405 | /** |
| 406 | * Identifier |
| 407 | */ |
| 408 | id?: string; |
| 409 | |
| 410 | /** |
| 411 | * User's first name |
| 412 | */ |
| 413 | first_name?: string | null; |
| 414 | |
| 415 | /** |
| 416 | * User's last name |
| 417 | */ |
| 418 | last_name?: string | null; |
| 419 | |
| 420 | /** |
| 421 | * Indicates whether two-factor authentication is enabled for the user account. |
| 422 | * Does not apply to API authentication. |
| 423 | */ |
| 424 | two_factor_authentication_enabled?: boolean; |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | export interface MemberListResponse { |
| 429 | /** |
| 430 | * Identifier |
| 431 | */ |
| 432 | id: string; |
| 433 | |
| 434 | /** |
| 435 | * The contact email address of the user. |
| 436 | */ |
| 437 | email: string; |
| 438 | |
| 439 | /** |
| 440 | * Member Name. |
| 441 | */ |
| 442 | name: string | null; |
| 443 | |
| 444 | /** |
| 445 | * Roles assigned to this Member. |
| 446 | */ |
| 447 | roles: Array<RolesAPI.IamSchemasRole>; |
| 448 | |
| 449 | /** |
| 450 | * A member's status in the organization. |
| 451 | */ |
| 452 | status: 'accepted' | 'invited'; |
| 453 | } |
| 454 | |
| 455 | export interface MemberDeleteResponse { |
| 456 | /** |
| 457 | * Identifier |
| 458 | */ |
| 459 | id: string; |
| 460 | } |
| 461 | |
| 462 | export interface MemberCreateParams { |
| 463 | /** |
| 464 | * Path param: |
| 465 | */ |
| 466 | account_id: unknown; |
| 467 | |
| 468 | /** |
| 469 | * Body param: The contact email address of the user. |
| 470 | */ |
| 471 | email: string; |
| 472 | |
| 473 | /** |
| 474 | * Body param: Array of roles associated with this member. |
| 475 | */ |
| 476 | roles: Array<string>; |
| 477 | |
| 478 | /** |
| 479 | * Body param: |
| 480 | */ |
| 481 | status?: 'accepted' | 'pending'; |
| 482 | } |
| 483 | |
| 484 | export interface MemberUpdateParams { |
| 485 | /** |
| 486 | * Path param: |
| 487 | */ |
| 488 | account_id: unknown; |
| 489 | |
| 490 | /** |
| 491 | * Body param: Roles assigned to this member. |
| 492 | */ |
| 493 | roles: Array<MemberUpdateParams.Role>; |
| 494 | } |
| 495 | |
| 496 | export namespace MemberUpdateParams { |
| 497 | export interface Role { |
| 498 | /** |
| 499 | * Role identifier tag. |
| 500 | */ |
| 501 | id: string; |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | export interface MemberListParams extends V4PagePaginationArrayParams { |
| 506 | /** |
| 507 | * Path param: |
| 508 | */ |
| 509 | account_id: unknown; |
| 510 | |
| 511 | /** |
| 512 | * Query param: Direction to order results. |
| 513 | */ |
| 514 | direction?: 'asc' | 'desc'; |
| 515 | |
| 516 | /** |
| 517 | * Query param: Field to order results by. |
| 518 | */ |
| 519 | order?: 'user.first_name' | 'user.last_name' | 'user.email' | 'status'; |
| 520 | |
| 521 | /** |
| 522 | * Query param: A member's status in the account. |
| 523 | */ |
| 524 | status?: 'accepted' | 'pending' | 'rejected'; |
| 525 | } |
| 526 | |
| 527 | export interface MemberDeleteParams { |
| 528 | account_id: unknown; |
| 529 | } |
| 530 | |
| 531 | export interface MemberGetParams { |
| 532 | account_id: unknown; |
| 533 | } |
| 534 | |
| 535 | export namespace Members { |
| 536 | export import AccountMember = MembersAPI.AccountMember; |
| 537 | export import AccountMemberWithID = MembersAPI.AccountMemberWithID; |
| 538 | export import MemberListResponse = MembersAPI.MemberListResponse; |
| 539 | export import MemberDeleteResponse = MembersAPI.MemberDeleteResponse; |
| 540 | export import MemberListResponsesV4PagePaginationArray = MembersAPI.MemberListResponsesV4PagePaginationArray; |
| 541 | export import MemberCreateParams = MembersAPI.MemberCreateParams; |
| 542 | export import MemberUpdateParams = MembersAPI.MemberUpdateParams; |
| 543 | export import MemberListParams = MembersAPI.MemberListParams; |
| 544 | export import MemberDeleteParams = MembersAPI.MemberDeleteParams; |
| 545 | export import MemberGetParams = MembersAPI.MemberGetParams; |
| 546 | } |
| 547 | |