cloudflare
Version:
The official TypeScript library for the Cloudflare API
130 lines • 5.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Users = exports.BaseUsers = 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 ActiveSessionsAPI = tslib_1.__importStar(require("./active-sessions.js"));
const active_sessions_1 = require("./active-sessions.js");
const FailedLoginsAPI = tslib_1.__importStar(require("./failed-logins.js"));
const failed_logins_1 = require("./failed-logins.js");
const LastSeenIdentityAPI = tslib_1.__importStar(require("./last-seen-identity.js"));
const last_seen_identity_1 = require("./last-seen-identity.js");
const pagination_1 = require("../../../../core/pagination.js");
const path_1 = require("../../../../internal/utils/path.js");
var BaseUsers = /* @__PURE__ */ (() => {
class BaseUsers extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/access/users`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/access/users/${userID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseUsers._key = Object.freeze([
'zeroTrust',
'access',
'users',
]);
return BaseUsers;
})();
exports.BaseUsers = BaseUsers;
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 = active_sessions_1.ActiveSessions;
Users.BaseActiveSessions = active_sessions_1.BaseActiveSessions;
Users.LastSeenIdentity = last_seen_identity_1.LastSeenIdentity;
Users.BaseLastSeenIdentity = last_seen_identity_1.BaseLastSeenIdentity;
Users.FailedLogins = failed_logins_1.FailedLogins;
Users.BaseFailedLogins = failed_logins_1.BaseFailedLogins;
return Users;
})();
exports.Users = Users;
//# sourceMappingURL=users.js.map