UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

178 lines • 8.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Accounts = exports.BaseAccounts = void 0; const tslib_1 = require("../../internal/tslib.js"); // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../core/resource.js"); const ClientSecretAPI = tslib_1.__importStar(require("./client-secret.js")); const client_secret_1 = require("./client-secret.js"); const EntitlementsAPI = tslib_1.__importStar(require("./entitlements.js")); const entitlements_1 = require("./entitlements.js"); const InvoicesAPI = tslib_1.__importStar(require("./invoices.js")); const invoices_1 = require("./invoices.js"); const MembersAPI = tslib_1.__importStar(require("./members.js")); const members_1 = require("./members.js"); const PayBadDebtAPI = tslib_1.__importStar(require("./pay-bad-debt.js")); const pay_bad_debt_1 = require("./pay-bad-debt.js"); const PayInvoiceAPI = tslib_1.__importStar(require("./pay-invoice.js")); const pay_invoice_1 = require("./pay-invoice.js"); const PaymentMethodsAPI = tslib_1.__importStar(require("./payment-methods.js")); const payment_methods_1 = require("./payment-methods.js"); const ReceiptsAPI = tslib_1.__importStar(require("./receipts.js")); const receipts_1 = require("./receipts.js"); const RolesAPI = tslib_1.__importStar(require("./roles.js")); const roles_1 = require("./roles.js"); const LogsAPI = tslib_1.__importStar(require("./logs/logs.js")); const logs_1 = require("./logs/logs.js"); const SpeedSettingsAPI = tslib_1.__importStar(require("./speed-settings/speed-settings.js")); const speed_settings_1 = require("./speed-settings/speed-settings.js"); const SubscriptionsAPI = tslib_1.__importStar(require("./subscriptions/subscriptions.js")); const subscriptions_1 = require("./subscriptions/subscriptions.js"); const TokensAPI = tslib_1.__importStar(require("./tokens/tokens.js")); const tokens_1 = require("./tokens/tokens.js"); const pagination_1 = require("../../core/pagination.js"); const headers_1 = require("../../internal/headers.js"); const path_1 = require("../../internal/utils/path.js"); var BaseAccounts = /* @__PURE__ */ (() => { class BaseAccounts extends resource_1.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: (0, headers_1.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((0, path_1.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', (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}`, options)._thenUnwrap((obj) => obj.result); } } BaseAccounts._key = Object.freeze(['accounts']); return BaseAccounts; })(); exports.BaseAccounts = BaseAccounts; 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_1.Members; Accounts.BaseMembers = members_1.BaseMembers; Accounts.Roles = roles_1.Roles; Accounts.BaseRoles = roles_1.BaseRoles; Accounts.Subscriptions = subscriptions_1.Subscriptions; Accounts.BaseSubscriptions = subscriptions_1.BaseSubscriptions; Accounts.Tokens = tokens_1.Tokens; Accounts.BaseTokens = tokens_1.BaseTokens; Accounts.Logs = logs_1.Logs; Accounts.BaseLogs = logs_1.BaseLogs; Accounts.Entitlements = entitlements_1.Entitlements; Accounts.BaseEntitlements = entitlements_1.BaseEntitlements; Accounts.SpeedSettings = speed_settings_1.SpeedSettings; Accounts.BaseSpeedSettings = speed_settings_1.BaseSpeedSettings; Accounts.PaymentMethods = payment_methods_1.PaymentMethods; Accounts.BasePaymentMethods = payment_methods_1.BasePaymentMethods; Accounts.PayInvoice = pay_invoice_1.PayInvoice; Accounts.BasePayInvoice = pay_invoice_1.BasePayInvoice; Accounts.PayBadDebt = pay_bad_debt_1.PayBadDebt; Accounts.BasePayBadDebt = pay_bad_debt_1.BasePayBadDebt; Accounts.Receipts = receipts_1.Receipts; Accounts.BaseReceipts = receipts_1.BaseReceipts; Accounts.Invoices = invoices_1.Invoices; Accounts.BaseInvoices = invoices_1.BaseInvoices; Accounts.ClientSecret = client_secret_1.ClientSecret; Accounts.BaseClientSecret = client_secret_1.BaseClientSecret; return Accounts; })(); exports.Accounts = Accounts; //# sourceMappingURL=accounts.js.map