UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

172 lines • 7.61 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import * as ClientSecretAPI from "./client-secret.mjs"; import { BaseClientSecret, ClientSecret, } from "./client-secret.mjs"; import * as EntitlementsAPI from "./entitlements.mjs"; import { BaseEntitlements, Entitlements, } from "./entitlements.mjs"; import * as InvoicesAPI from "./invoices.mjs"; import { BaseInvoices, Invoices } from "./invoices.mjs"; import * as MembersAPI from "./members.mjs"; import { BaseMembers, Members, } from "./members.mjs"; import * as PayBadDebtAPI from "./pay-bad-debt.mjs"; import { BasePayBadDebt, PayBadDebt } from "./pay-bad-debt.mjs"; import * as PayInvoiceAPI from "./pay-invoice.mjs"; import { BasePayInvoice, PayInvoice } from "./pay-invoice.mjs"; import * as PaymentMethodsAPI from "./payment-methods.mjs"; import { BasePaymentMethods, PaymentMethods, } from "./payment-methods.mjs"; import * as ReceiptsAPI from "./receipts.mjs"; import { BaseReceipts, Receipts } from "./receipts.mjs"; import * as RolesAPI from "./roles.mjs"; import { BaseRoles, Roles } from "./roles.mjs"; import * as LogsAPI from "./logs/logs.mjs"; import { BaseLogs, Logs } from "./logs/logs.mjs"; import * as SpeedSettingsAPI from "./speed-settings/speed-settings.mjs"; import { BaseSpeedSettings, SpeedSettings } from "./speed-settings/speed-settings.mjs"; import * as SubscriptionsAPI from "./subscriptions/subscriptions.mjs"; import { BaseSubscriptions, Subscriptions, } from "./subscriptions/subscriptions.mjs"; import * as TokensAPI from "./tokens/tokens.mjs"; import { BaseTokens, Tokens, } from "./tokens/tokens.mjs"; import { V4PagePaginationArray } from "../../core/pagination.mjs"; import { buildHeaders } from "../../internal/headers.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseAccounts = /* @__PURE__ */ (() => { class BaseAccounts extends APIResource { /** * Create an Account. To create the Account within an Organization, provide * `unit.id` and omit `standalone`. To create a standalone Free Account, provide * `standalone: true` and omit `unit`. Providing both fields is invalid. If you * omit both fields, Cloudflare can determine the destination only when the User is * an administrator of exactly one Organization. Cloudflare creates the Account in * that Organization; otherwise, the request returns an error. * * @example * ```ts * const account = await client.accounts.create({ * name: 'name', * }); * ``` */ create(params, options) { const { 'Idempotency-Key': idempotencyKey, ...body } = params; return this._client.post('/accounts', { body, ...options, headers: buildHeaders([ { ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined) }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } /** * Update an existing account. * * @example * ```ts * const account = await client.accounts.update({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * id: '023e105f4ecef8ad9ca31a8372d0c353', * name: 'Demo Account', * type: 'standard', * }); * ``` */ update(params, options) { const { account_id, ...body } = params; return this._client.put(path `/accounts/${account_id}`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * List all accounts you have ownership or verified access to. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const account of client.accounts.list()) { * // ... * } * ``` */ list(query = {}, options) { return this._client.getAPIList('/accounts', (V4PagePaginationArray), { query, ...options }); } /** * Delete a specific account (only available for tenant admins at this time). This * is a permanent operation that will delete any zones or other resources under the * account * * @example * ```ts * const account = await client.accounts.delete({ * account_id: 'account_id', * }); * ``` */ delete(params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}`, options)._thenUnwrap((obj) => obj.result); } /** * Get information about a specific account that you are a member of. * * @example * ```ts * const account = await client.accounts.get({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ get(params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}`, options)._thenUnwrap((obj) => obj.result); } } BaseAccounts._key = Object.freeze(['accounts']); return BaseAccounts; })(); export var Accounts = /* @__PURE__ */ (() => { class Accounts extends BaseAccounts { constructor() { super(...arguments); this.members = new MembersAPI.Members(this._client); this.roles = new RolesAPI.Roles(this._client); this.subscriptions = new SubscriptionsAPI.Subscriptions(this._client); this.tokens = new TokensAPI.Tokens(this._client); this.logs = new LogsAPI.Logs(this._client); this.entitlements = new EntitlementsAPI.Entitlements(this._client); this.speedSettings = new SpeedSettingsAPI.SpeedSettings(this._client); this.paymentMethods = new PaymentMethodsAPI.PaymentMethods(this._client); this.payInvoice = new PayInvoiceAPI.PayInvoice(this._client); this.payBadDebt = new PayBadDebtAPI.PayBadDebt(this._client); this.receipts = new ReceiptsAPI.Receipts(this._client); this.invoices = new InvoicesAPI.Invoices(this._client); this.clientSecret = new ClientSecretAPI.ClientSecret(this._client); } } Accounts.Members = Members; Accounts.BaseMembers = BaseMembers; Accounts.Roles = Roles; Accounts.BaseRoles = BaseRoles; Accounts.Subscriptions = Subscriptions; Accounts.BaseSubscriptions = BaseSubscriptions; Accounts.Tokens = Tokens; Accounts.BaseTokens = BaseTokens; Accounts.Logs = Logs; Accounts.BaseLogs = BaseLogs; Accounts.Entitlements = Entitlements; Accounts.BaseEntitlements = BaseEntitlements; Accounts.SpeedSettings = SpeedSettings; Accounts.BaseSpeedSettings = BaseSpeedSettings; Accounts.PaymentMethods = PaymentMethods; Accounts.BasePaymentMethods = BasePaymentMethods; Accounts.PayInvoice = PayInvoice; Accounts.BasePayInvoice = BasePayInvoice; Accounts.PayBadDebt = PayBadDebt; Accounts.BasePayBadDebt = BasePayBadDebt; Accounts.Receipts = Receipts; Accounts.BaseReceipts = BaseReceipts; Accounts.Invoices = Invoices; Accounts.BaseInvoices = BaseInvoices; Accounts.ClientSecret = ClientSecret; Accounts.BaseClientSecret = BaseClientSecret; return Accounts; })(); //# sourceMappingURL=accounts.mjs.map