UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

97 lines • 3.5 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { V4PagePaginationArray } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseMembers = /* @__PURE__ */ (() => { class BaseMembers extends 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(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(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(path `/accounts/${account_id}/members`, (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(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(path `/accounts/${account_id}/members/${memberID}`, options)._thenUnwrap((obj) => obj.result); } } BaseMembers._key = Object.freeze([ 'accounts', 'members', ]); return BaseMembers; })(); export class Members extends BaseMembers { } //# sourceMappingURL=members.mjs.map