portkey-ai
Version:
Node client library for the Portkey API
212 lines • 9.64 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Member = exports.Workspaces = exports.Invites = exports.Users = exports.Admin = void 0;
const apiResource_1 = require("../apiResource.js");
const createHeaders_1 = require("./createHeaders.js");
const utils_1 = require("../utils.js");
// Function to convert UsersGetParams to query parameters
class Admin extends apiResource_1.ApiResource {
constructor(client) {
super(client);
this.users = new Users(client);
this.workspaces = new Workspaces(client);
}
}
exports.Admin = Admin;
class Users extends apiResource_1.ApiResource {
constructor() {
super(...arguments);
this.invites = new Invites(this.client);
}
retrieve(_body, params, opts) {
const body = _body;
const userId = body.userId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.getMethod(`/admin/users/${userId}`, Object.assign({}, opts));
return response;
}
list(_body, params, opts) {
const body = _body;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const query = (0, utils_1.toQueryParams)(body);
const response = this.getMethod(`/admin/users${query}`, Object.assign({}, opts));
return response;
}
update(_body, params, opts) {
const body = _body;
const userId = body.userId;
delete body.userId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.put(`/admin/users/${userId}`, Object.assign({ body }, opts));
return response;
}
delete(_body, params, opts) {
const body = _body;
const userId = body.userId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.deleteMethod(`/admin/users/${userId}`, Object.assign({ body }, opts));
return response;
}
}
exports.Users = Users;
class Invites extends apiResource_1.ApiResource {
create(_body, params, opts) {
const body = _body;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.post('/admin/users/invites', Object.assign({ body }, opts));
return response;
}
retrieve(_body, params, opts) {
const body = _body;
const inviteId = body.inviteId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.getMethod(`/admin/users/invites/${inviteId}`, Object.assign({}, opts));
return response;
}
list(_body, params, opts) {
const body = _body;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const query = body ? (0, utils_1.toQueryParams)(body) : '';
const response = this.getMethod(`/admin/users/invites${query}`, Object.assign({}, opts));
return response;
}
delete(_body, params, opts) {
const body = _body;
const inviteId = body.inviteId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.deleteMethod(`/admin/users/invites/${inviteId}`, Object.assign({ body }, opts));
return response;
}
resend(_body, params, opts) {
const body = _body;
const inviteId = body.inviteId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.post(`/admin/users/invites/${inviteId}/resend`, Object.assign({}, opts));
return response;
}
}
exports.Invites = Invites;
class Workspaces extends apiResource_1.ApiResource {
constructor() {
super(...arguments);
this.users = new Member(this.client);
}
create(_body, params, opts) {
const body = _body;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.post('/admin/workspaces', Object.assign({ body }, opts));
return response;
}
retrieve(_body, params, opts) {
const body = _body;
const workspaceId = body.workspaceId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.getMethod(`/admin/workspaces/${workspaceId}`, Object.assign({}, opts));
return response;
}
list(_body, params, opts) {
const body = _body;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const query = (0, utils_1.toQueryParams)(body);
const response = this.getMethod(`/admin/workspaces${query}`, Object.assign({}, opts));
return response;
}
update(_body, params, opts) {
const body = _body;
const workspaceId = body.workspaceId;
delete body.workspaceId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.put(`/admin/workspaces/${workspaceId}`, Object.assign({ body }, opts));
return response;
}
delete(_body, params, opts) {
const body = _body;
const workspaceId = body.workspaceId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.deleteMethod(`/admin/workspaces/${workspaceId}`, Object.assign({ body }, opts));
return response;
}
}
exports.Workspaces = Workspaces;
class Member extends apiResource_1.ApiResource {
create(_body, params, opts) {
const body = _body;
const workspaceId = body.workspaceId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.post(`/admin/workspaces/${workspaceId}/users`, Object.assign({ body }, opts));
return response;
}
retrieve(_body, params, opts) {
const body = _body;
const workspaceId = body.workspaceId;
const userId = body.userId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.getMethod(`/admin/workspaces/${workspaceId}/users/${userId}`, Object.assign({}, opts));
return response;
}
list(_body, params, opts) {
const body = _body;
const workspaceId = body.workspaceId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const query = (0, utils_1.toQueryParams)(body);
const response = this.getMethod(`/admin/workspaces/${workspaceId}/users${query}`, Object.assign({}, opts));
return response;
}
delete(_body, params, opts) {
const body = _body;
const workspaceId = body.workspaceId;
const userId = body.userId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.deleteMethod(`/admin/workspaces/${workspaceId}/users/${userId}`, Object.assign({ body }, opts));
return response;
}
update(_body, params, opts) {
const body = _body;
const workspaceId = body.workspaceId;
const userId = body.userId;
delete body.workspaceId;
if (params) {
this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params)));
}
const response = this.put(`/admin/workspaces/${workspaceId}/users/${userId}`, Object.assign({ body }, opts));
return response;
}
}
exports.Member = Member;
//# sourceMappingURL=admin.js.map