cloudflare
Version:
The official TypeScript library for the Cloudflare API
107 lines • 3.96 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as MembersAPI from "./members.mjs";
import { BaseMembers, Members, } from "./members.mjs";
import { V4PagePaginationArray, } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseUserGroups = /* @__PURE__ */ (() => {
class BaseUserGroups extends 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(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(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(path `/accounts/${account_id}/iam/user_groups`, (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(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(path `/accounts/${account_id}/iam/user_groups/${userGroupID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseUserGroups._key = Object.freeze([
'iam',
'userGroups',
]);
return BaseUserGroups;
})();
export var UserGroups = /* @__PURE__ */ (() => {
class UserGroups extends BaseUserGroups {
constructor() {
super(...arguments);
this.members = new MembersAPI.Members(this._client);
}
}
UserGroups.Members = Members;
UserGroups.BaseMembers = BaseMembers;
return UserGroups;
})();
//# sourceMappingURL=user-groups.mjs.map