UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

102 lines • 3.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Members = exports.BaseMembers = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../core/resource.js"); const pagination_1 = require("../../core/pagination.js"); const path_1 = require("../../internal/utils/path.js"); var BaseMembers = /* @__PURE__ */ (() => { class BaseMembers extends resource_1.APIResource { /** * Add a user to the list of members for this account. * * @example * ```ts * const member = await client.accounts.members.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * email: 'user@example.com', * roles: ['3536bcfad5faccb999b47003c79917fb'], * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/members`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Modify an account member. * * @example * ```ts * const member = await client.accounts.members.update( * '4536bcfad5faccb111b47003c79917fa', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ update(memberID, params, options) { const { account_id, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/members/${memberID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List all members of an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const member of client.accounts.members.list({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * })) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/members`, (pagination_1.V4PagePaginationArray), { query, ...options }); } /** * Remove a member from an account. * * @example * ```ts * const member = await client.accounts.members.delete( * '4536bcfad5faccb111b47003c79917fa', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(memberID, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/members/${memberID}`, options)._thenUnwrap((obj) => obj.result); } /** * Get information about a specific member of an account. * * @example * ```ts * const member = await client.accounts.members.get( * '4536bcfad5faccb111b47003c79917fa', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(memberID, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/members/${memberID}`, options)._thenUnwrap((obj) => obj.result); } } BaseMembers._key = Object.freeze([ 'accounts', 'members', ]); return BaseMembers; })(); exports.BaseMembers = BaseMembers; class Members extends BaseMembers { } exports.Members = Members; //# sourceMappingURL=members.js.map