cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/accounts/accounts.ts
222lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import { APIResource } from '../../resource'; |
| 4 | import { isRequestOptions } from '../../core'; |
| 5 | import * as Core from '../../core'; |
| 6 | import * as MembersAPI from './members'; |
| 7 | import * as RolesAPI from './roles'; |
| 8 | import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../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 | * Sets an abuse contact email to notify for abuse reports. |
| 91 | */ |
| 92 | abuse_contact_email?: string; |
| 93 | |
| 94 | /** |
| 95 | * Specifies the default nameservers to be used for new zones added to this |
| 96 | * account. |
| 97 | * |
| 98 | * - `cloudflare.standard` for Cloudflare-branded nameservers |
| 99 | * - `custom.account` for account custom nameservers |
| 100 | * - `custom.tenant` for tenant custom nameservers |
| 101 | * |
| 102 | * See |
| 103 | * [Custom Nameservers](https://developers.cloudflare.com/dns/additional-options/custom-nameservers/) |
| 104 | * for more information. |
| 105 | */ |
| 106 | default_nameservers?: 'cloudflare.standard' | 'custom.account' | 'custom.tenant'; |
| 107 | |
| 108 | /** |
| 109 | * Indicates whether membership in this account requires that Two-Factor |
| 110 | * Authentication is enabled |
| 111 | */ |
| 112 | enforce_twofactor?: boolean; |
| 113 | |
| 114 | /** |
| 115 | * @deprecated: Indicates whether new zones should use the account-level custom |
| 116 | * nameservers by default. |
| 117 | * |
| 118 | * Deprecated in favor of `default_nameservers`. |
| 119 | */ |
| 120 | use_account_custom_ns_by_default?: boolean; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | export type AccountUpdateResponse = unknown; |
| 125 | |
| 126 | export type AccountListResponse = unknown; |
| 127 | |
| 128 | export type AccountGetResponse = unknown; |
| 129 | |
| 130 | export interface AccountUpdateParams { |
| 131 | /** |
| 132 | * Path param: |
| 133 | */ |
| 134 | account_id: unknown; |
| 135 | |
| 136 | /** |
| 137 | * Body param: Account name |
| 138 | */ |
| 139 | name: string; |
| 140 | |
| 141 | /** |
| 142 | * Body param: Account settings |
| 143 | */ |
| 144 | settings?: AccountUpdateParams.Settings; |
| 145 | } |
| 146 | |
| 147 | export namespace AccountUpdateParams { |
| 148 | /** |
| 149 | * Account settings |
| 150 | */ |
| 151 | export interface Settings { |
| 152 | /** |
| 153 | * Sets an abuse contact email to notify for abuse reports. |
| 154 | */ |
| 155 | abuse_contact_email?: string; |
| 156 | |
| 157 | /** |
| 158 | * Specifies the default nameservers to be used for new zones added to this |
| 159 | * account. |
| 160 | * |
| 161 | * - `cloudflare.standard` for Cloudflare-branded nameservers |
| 162 | * - `custom.account` for account custom nameservers |
| 163 | * - `custom.tenant` for tenant custom nameservers |
| 164 | * |
| 165 | * See |
| 166 | * [Custom Nameservers](https://developers.cloudflare.com/dns/additional-options/custom-nameservers/) |
| 167 | * for more information. |
| 168 | */ |
| 169 | default_nameservers?: 'cloudflare.standard' | 'custom.account' | 'custom.tenant'; |
| 170 | |
| 171 | /** |
| 172 | * Indicates whether membership in this account requires that Two-Factor |
| 173 | * Authentication is enabled |
| 174 | */ |
| 175 | enforce_twofactor?: boolean; |
| 176 | |
| 177 | /** |
| 178 | * @deprecated: Indicates whether new zones should use the account-level custom |
| 179 | * nameservers by default. |
| 180 | * |
| 181 | * Deprecated in favor of `default_nameservers`. |
| 182 | */ |
| 183 | use_account_custom_ns_by_default?: boolean; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | export interface AccountListParams extends V4PagePaginationArrayParams { |
| 188 | /** |
| 189 | * Direction to order results. |
| 190 | */ |
| 191 | direction?: 'asc' | 'desc'; |
| 192 | |
| 193 | /** |
| 194 | * Name of the account. |
| 195 | */ |
| 196 | name?: string; |
| 197 | } |
| 198 | |
| 199 | export interface AccountGetParams { |
| 200 | account_id: unknown; |
| 201 | } |
| 202 | |
| 203 | export namespace Accounts { |
| 204 | export import Members = MembersAPI.Members; |
| 205 | export import Status = MembersAPI.Status; |
| 206 | export import UserWithInviteCode = MembersAPI.UserWithInviteCode; |
| 207 | export import MemberCreateResponse = MembersAPI.MemberCreateResponse; |
| 208 | export import MemberUpdateResponse = MembersAPI.MemberUpdateResponse; |
| 209 | export import MemberListResponse = MembersAPI.MemberListResponse; |
| 210 | export import MemberDeleteResponse = MembersAPI.MemberDeleteResponse; |
| 211 | export import MemberGetResponse = MembersAPI.MemberGetResponse; |
| 212 | export import MemberListResponsesV4PagePaginationArray = MembersAPI.MemberListResponsesV4PagePaginationArray; |
| 213 | export import MemberCreateParams = MembersAPI.MemberCreateParams; |
| 214 | export import MemberUpdateParams = MembersAPI.MemberUpdateParams; |
| 215 | export import MemberListParams = MembersAPI.MemberListParams; |
| 216 | export import MemberDeleteParams = MembersAPI.MemberDeleteParams; |
| 217 | export import MemberGetParams = MembersAPI.MemberGetParams; |
| 218 | export import Roles = RolesAPI.Roles; |
| 219 | export import RoleGetResponse = RolesAPI.RoleGetResponse; |
| 220 | export import RoleListParams = RolesAPI.RoleListParams; |
| 221 | export import RoleGetParams = RolesAPI.RoleGetParams; |
| 222 | } |
| 223 | |