cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
generated-e9b9a005fa

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/accounts/accounts.ts

215lines · modecode

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