UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

113 lines • 4.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UserGroups = exports.BaseUserGroups = 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 MembersAPI = tslib_1.__importStar(require("./members.js")); const members_1 = require("./members.js"); const pagination_1 = require("../../../core/pagination.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseUserGroups = /* @__PURE__ */ (() => { class BaseUserGroups extends resource_1.APIResource { /** * Create a new user group under the specified account. * * @example * ```ts * const userGroup = await client.iam.userGroups.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * name: 'My New User Group', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/iam/user_groups`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Modify an existing user group. * * @example * ```ts * const userGroup = await client.iam.userGroups.update( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ update(userGroupID, params, options) { const { account_id, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/iam/user_groups/${userGroupID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List all the user groups for an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const userGroupListResponse of client.iam.userGroups.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/iam/user_groups`, (pagination_1.V4PagePaginationArray), { query, ...options }); } /** * Remove a user group from an account. * * @example * ```ts * const userGroup = await client.iam.userGroups.delete( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(userGroupID, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/iam/user_groups/${userGroupID}`, options)._thenUnwrap((obj) => obj.result); } /** * Get information about a specific user group in an account. * * @example * ```ts * const userGroup = await client.iam.userGroups.get( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(userGroupID, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/iam/user_groups/${userGroupID}`, options)._thenUnwrap((obj) => obj.result); } } BaseUserGroups._key = Object.freeze([ 'iam', 'userGroups', ]); return BaseUserGroups; })(); exports.BaseUserGroups = BaseUserGroups; var UserGroups = /* @__PURE__ */ (() => { class UserGroups extends BaseUserGroups { constructor() { super(...arguments); this.members = new MembersAPI.Members(this._client); } } UserGroups.Members = members_1.Members; UserGroups.BaseMembers = members_1.BaseMembers; return UserGroups; })(); exports.UserGroups = UserGroups; //# sourceMappingURL=user-groups.js.map