cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/accounts/accounts.ts
208lines · 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 { isRequestOptions } from 'cloudflare/core'; |
| 6 | import * as MembersAPI from 'cloudflare/resources/accounts/members'; |
| 7 | import * as RolesAPI from 'cloudflare/resources/accounts/roles'; |
| 8 | import { V4PagePaginationArray, type V4PagePaginationArrayParams } from 'cloudflare/pagination'; |
| 9 | |
| 10 | export class Accounts extends APIResource { |
| 11 | members: MembersAPI.Members = new MembersAPI.Members(this._client); |
| 12 | roles: RolesAPI.Roles = new RolesAPI.Roles(this._client); |
| 13 | |
| 14 | /** |
| 15 | * Update an existing account. |
| 16 | */ |
| 17 | update(params: AccountUpdateParams, options?: Core.RequestOptions): Core.APIPromise<AccountUpdateResponse> { |
| 18 | const { account_id, ...body } = params; |
| 19 | return ( |
| 20 | this._client.put(`/accounts/${account_id}`, { body, ...options }) as Core.APIPromise<{ |
| 21 | result: AccountUpdateResponse; |
| 22 | }> |
| 23 | )._thenUnwrap((obj) => obj.result); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * List all accounts you have ownership or verified access to. |
| 28 | */ |
| 29 | list( |
| 30 | query?: AccountListParams, |
| 31 | options?: Core.RequestOptions, |
| 32 | ): Core.PagePromise<AccountListResponsesV4PagePaginationArray, AccountListResponse>; |
| 33 | list( |
| 34 | options?: Core.RequestOptions, |
| 35 | ): Core.PagePromise<AccountListResponsesV4PagePaginationArray, AccountListResponse>; |
| 36 | list( |
| 37 | query: AccountListParams | Core.RequestOptions = {}, |
| 38 | options?: Core.RequestOptions, |
| 39 | ): Core.PagePromise<AccountListResponsesV4PagePaginationArray, AccountListResponse> { |
| 40 | if (isRequestOptions(query)) { |
| 41 | return this.list({}, query); |
| 42 | } |
| 43 | return this._client.getAPIList('/accounts', AccountListResponsesV4PagePaginationArray, { |
| 44 | query, |
| 45 | ...options, |
| 46 | }); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Get information about a specific account that you are a member of. |
| 51 | */ |
| 52 | get(params: AccountGetParams, options?: Core.RequestOptions): Core.APIPromise<AccountGetResponse> { |
| 53 | const { account_id } = params; |
| 54 | return ( |
| 55 | this._client.get(`/accounts/${account_id}`, options) as Core.APIPromise<{ result: AccountGetResponse }> |
| 56 | )._thenUnwrap((obj) => obj.result); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | export class AccountListResponsesV4PagePaginationArray extends V4PagePaginationArray<AccountListResponse> {} |
| 61 | |
| 62 | export interface Account { |
| 63 | /** |
| 64 | * Identifier |
| 65 | */ |
| 66 | id: string; |
| 67 | |
| 68 | /** |
| 69 | * Account name |
| 70 | */ |
| 71 | name: string; |
| 72 | |
| 73 | /** |
| 74 | * Timestamp for the creation of the account |
| 75 | */ |
| 76 | created_on?: string; |
| 77 | |
| 78 | /** |
| 79 | * Account settings |
| 80 | */ |
| 81 | settings?: Account.Settings; |
| 82 | } |
| 83 | |
| 84 | export namespace Account { |
| 85 | /** |
| 86 | * Account settings |
| 87 | */ |
| 88 | export interface Settings { |
| 89 | /** |
| 90 | * Specifies the default nameservers to be used for new zones added to this |
| 91 | * account. |
| 92 | * |
| 93 | * - `cloudflare.standard` for Cloudflare-branded nameservers |
| 94 | * - `custom.account` for account custom nameservers |
| 95 | * - `custom.tenant` for tenant custom nameservers |
| 96 | * |
| 97 | * See |
| 98 | * [Custom Nameservers](https://developers.cloudflare.com/dns/additional-options/custom-nameservers/) |
| 99 | * for more information. |
| 100 | */ |
| 101 | default_nameservers?: 'cloudflare.standard' | 'custom.account' | 'custom.tenant'; |
| 102 | |
| 103 | /** |
| 104 | * Indicates whether membership in this account requires that Two-Factor |
| 105 | * Authentication is enabled |
| 106 | */ |
| 107 | enforce_twofactor?: boolean; |
| 108 | |
| 109 | /** |
| 110 | * @deprecated: Indicates whether new zones should use the account-level custom |
| 111 | * nameservers by default. |
| 112 | * |
| 113 | * Deprecated in favor of `default_nameservers`. |
| 114 | */ |
| 115 | use_account_custom_ns_by_default?: boolean; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | export type AccountUpdateResponse = unknown | string | null; |
| 120 | |
| 121 | export type AccountListResponse = unknown; |
| 122 | |
| 123 | export type AccountGetResponse = unknown | string | null; |
| 124 | |
| 125 | export interface AccountUpdateParams { |
| 126 | /** |
| 127 | * Path param: |
| 128 | */ |
| 129 | account_id: unknown; |
| 130 | |
| 131 | /** |
| 132 | * Body param: Account name |
| 133 | */ |
| 134 | name: string; |
| 135 | |
| 136 | /** |
| 137 | * Body param: Account settings |
| 138 | */ |
| 139 | settings?: AccountUpdateParams.Settings; |
| 140 | } |
| 141 | |
| 142 | export namespace AccountUpdateParams { |
| 143 | /** |
| 144 | * Account settings |
| 145 | */ |
| 146 | export interface Settings { |
| 147 | /** |
| 148 | * Specifies the default nameservers to be used for new zones added to this |
| 149 | * account. |
| 150 | * |
| 151 | * - `cloudflare.standard` for Cloudflare-branded nameservers |
| 152 | * - `custom.account` for account custom nameservers |
| 153 | * - `custom.tenant` for tenant custom nameservers |
| 154 | * |
| 155 | * See |
| 156 | * [Custom Nameservers](https://developers.cloudflare.com/dns/additional-options/custom-nameservers/) |
| 157 | * for more information. |
| 158 | */ |
| 159 | default_nameservers?: 'cloudflare.standard' | 'custom.account' | 'custom.tenant'; |
| 160 | |
| 161 | /** |
| 162 | * Indicates whether membership in this account requires that Two-Factor |
| 163 | * Authentication is enabled |
| 164 | */ |
| 165 | enforce_twofactor?: boolean; |
| 166 | |
| 167 | /** |
| 168 | * @deprecated: Indicates whether new zones should use the account-level custom |
| 169 | * nameservers by default. |
| 170 | * |
| 171 | * Deprecated in favor of `default_nameservers`. |
| 172 | */ |
| 173 | use_account_custom_ns_by_default?: boolean; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | export interface AccountListParams extends V4PagePaginationArrayParams { |
| 178 | /** |
| 179 | * Direction to order results. |
| 180 | */ |
| 181 | direction?: 'asc' | 'desc'; |
| 182 | |
| 183 | /** |
| 184 | * Name of the account. |
| 185 | */ |
| 186 | name?: string; |
| 187 | } |
| 188 | |
| 189 | export interface AccountGetParams { |
| 190 | account_id: unknown; |
| 191 | } |
| 192 | |
| 193 | export namespace Accounts { |
| 194 | export import Members = MembersAPI.Members; |
| 195 | export import UserWithInviteCode = MembersAPI.UserWithInviteCode; |
| 196 | export import MemberListResponse = MembersAPI.MemberListResponse; |
| 197 | export import MemberDeleteResponse = MembersAPI.MemberDeleteResponse; |
| 198 | export import MemberListResponsesV4PagePaginationArray = MembersAPI.MemberListResponsesV4PagePaginationArray; |
| 199 | export import MemberCreateParams = MembersAPI.MemberCreateParams; |
| 200 | export import MemberUpdateParams = MembersAPI.MemberUpdateParams; |
| 201 | export import MemberListParams = MembersAPI.MemberListParams; |
| 202 | export import MemberDeleteParams = MembersAPI.MemberDeleteParams; |
| 203 | export import MemberGetParams = MembersAPI.MemberGetParams; |
| 204 | export import Roles = RolesAPI.Roles; |
| 205 | export import RoleGetResponse = RolesAPI.RoleGetResponse; |
| 206 | export import RoleListParams = RolesAPI.RoleListParams; |
| 207 | export import RoleGetParams = RolesAPI.RoleGetParams; |
| 208 | } |