UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

124 lines • 4.87 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../../core/resource.mjs"; import * as ActiveSessionsAPI from "./active-sessions.mjs"; import { ActiveSessions, BaseActiveSessions, } from "./active-sessions.mjs"; import * as FailedLoginsAPI from "./failed-logins.mjs"; import { BaseFailedLogins, FailedLogins, } from "./failed-logins.mjs"; import * as LastSeenIdentityAPI from "./last-seen-identity.mjs"; import { BaseLastSeenIdentity, LastSeenIdentity, } from "./last-seen-identity.mjs"; import { V4PagePaginationArray, } from "../../../../core/pagination.mjs"; import { path } from "../../../../internal/utils/path.mjs"; export var BaseUsers = /* @__PURE__ */ (() => { class BaseUsers extends APIResource { /** * Creates a new user. * * @example * ```ts * const user = await client.zeroTrust.access.users.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * email: 'jdoe@example.com', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/access/users`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Updates a specific user's name for an account. Requires the user's current email * as confirmation (email cannot be changed). * * @example * ```ts * const user = await client.zeroTrust.access.users.update( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * email: 'jdoe@example.com', * name: 'Jane Doe', * }, * ); * ``` */ update(userID, params, options) { const { account_id, ...body } = params; return this._client.put(path `/accounts/${account_id}/access/users/${userID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Gets a list of users for an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const userListResponse of client.zeroTrust.access.users.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/access/users`, (V4PagePaginationArray), { query, ...options }); } /** * Deletes a specific user for an account. This will also revoke any active seats * and tokens for the user. * * @example * ```ts * const user = await client.zeroTrust.access.users.delete( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(userID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/access/users/${userID}`, options)._thenUnwrap((obj) => obj.result); } /** * Gets a specific user for an account. * * @example * ```ts * const user = await client.zeroTrust.access.users.get( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(userID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/access/users/${userID}`, options)._thenUnwrap((obj) => obj.result); } } BaseUsers._key = Object.freeze([ 'zeroTrust', 'access', 'users', ]); return BaseUsers; })(); export var Users = /* @__PURE__ */ (() => { class Users extends BaseUsers { constructor() { super(...arguments); this.activeSessions = new ActiveSessionsAPI.ActiveSessions(this._client); this.lastSeenIdentity = new LastSeenIdentityAPI.LastSeenIdentity(this._client); this.failedLogins = new FailedLoginsAPI.FailedLogins(this._client); } } Users.ActiveSessions = ActiveSessions; Users.BaseActiveSessions = BaseActiveSessions; Users.LastSeenIdentity = LastSeenIdentity; Users.BaseLastSeenIdentity = BaseLastSeenIdentity; Users.FailedLogins = FailedLogins; Users.BaseFailedLogins = BaseFailedLogins; return Users; })(); //# sourceMappingURL=users.mjs.map