UNPKG

portkey-ai

Version:
65 lines 2.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Configs = void 0; const apiResource_1 = require("../apiResource.js"); const createHeaders_1 = require("./createHeaders.js"); const utils_1 = require("../utils.js"); class Configs extends apiResource_1.ApiResource { constructor(client) { super(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('/configs', Object.assign({ body }, opts)); return response; } retrieve(_body, params, opts) { const body = _body; const slug = body.slug; if (params) { this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params))); } const response = this.getMethod(`/configs/${slug}`, Object.assign({}, opts)); return response; } update(_body, params, opts) { const body = _body; const slug = body.slug; if (params) { this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params))); } const response = this.put(`/configs/${slug}`, Object.assign({ body }, opts)); return response; } list(_body, params, opts) { const body = _body; const query = (0, utils_1.toQueryParams)(body); if (params) { this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params))); } const response = this.getMethod(`/configs${query}`, Object.assign({}, opts)); return response; } delete(_body, params, opts) { const body = _body; let configSlug = ''; if (body.id) { configSlug = body.id; /* eslint-disable-next-line no-console */ console.warn('You are using "id" to delete a config. This will be deprecated in the future. Please use "slug" instead.'); } else if (body.slug) { configSlug = body.slug; } if (params) { this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign({}, params))); } const response = this.deleteMethod(`/configs/${configSlug}`, Object.assign({}, opts)); return response; } } exports.Configs = Configs; //# sourceMappingURL=configs.js.map