UNPKG

@mindconnect/mindconnect-nodejs

Version:

NodeJS Library for Siemens Insights Hub Connectivity - TypeScript SDK for Insights Hub and Industrial IoT - Command Line Interface - Insights Hub Development Proxy (Siemens Insights Hub was formerly known as MindSphere)

378 lines 13.3 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TenantManagementClient = void 0; const utils_1 = require("../../utils"); const sdk_client_1 = require("../common/sdk-client"); /** * The Tenant Management API provides endpoints for managing subtenants, * and the legal configuration and the basic properties of tenants * * @export * @class TenantManagementClient * @extends {SdkClient} */ class TenantManagementClient extends sdk_client_1.SdkClient { constructor() { super(...arguments); this._baseUrl = "/api/tenantmanagement/v4"; } /** * Get the complete legal information configuration of current tenant * * @returns {Promise<TenantManagementModels.LegalConfiguration>} * * @memberOf TenantManagementClient */ GetLegalConfigRegions() { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/legalConfigRegions`, }); return result; }); } /** * Creates tenant legal information * * @param {TenantManagementModels.LegalConfiguration} legalConfig * @returns {Promise<TenantManagementModels.LegalConfigurationResource>} * * @memberOf TenantManagementClient */ PostLegalConfigRegions(legalConfig) { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "POST", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/legalConfigRegions`, body: legalConfig, }); return result; }); } /** * Update a region configuration of current tenant * * @param {string} regionId * @param {TenantManagementModels.Region} region * @param {{ ifMatch: string }} params * @returns {Promise<TenantManagementModels.RegionResource>} * * @memberOf TenantManagementClient */ PutLegalConfigRegions(regionId, region, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { ifMatch } = parameters; const result = yield this.HttpAction({ verb: "PUT", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/legalConfigRegions/${regionId}`, body: region, additionalHeaders: { "If-Match": ifMatch }, }); return result; }); } /** * Delete legal Config Region * * @memberOf TenantManagementClient */ DeleteLegalConfigRegions() { return __awaiter(this, void 0, void 0, function* () { yield this.HttpAction({ verb: "DELETE", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/legalConfigRegions`, noResponse: true, }); }); } /** * Get specific legal information * * ! Fix: This was manually created in 3.12.0 as MindSphere has a copy/paste error * ! saying that this method returns LegalConfiguration * * @returns {Promise<TenantManagementModels.LegalInfo>} * * @memberOf TenantManagementClient */ GetLegalInfo() { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/legalInfo`, }); return result; }); } /** * Get the region specific legal information for a given tenant with fallback logic to core tenant * * ! Fix: This was manually created in 3.12.0 as MindSphere has a copy/paste error * ! saying that this method returns LegalConfiguration * * @param {string} tenantId * @returns {Promise<TenantManagementModels.LegalInfo>} * * @memberOf TenantManagementClient */ GetLegalInfoForTenant(tenantId) { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/legalInfo/${tenantId}`, }); return result; }); } /** * Get the region specific legal information for a given tenant without fallback logic * * ! Fix: This was manually created in 3.12.0 as MindSphere has a copy/paste error * ! saying that this method returns LegalConfiguration * * @param {string} tenantId * @returns {Promise<TenantManagementModels.LegalInfo>} * * @memberOf TenantManagementClient */ GetLegalInfoForSpecificTenant(tenantId) { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/legalInfoForSpecificTenant/${tenantId}`, }); return result; }); } /** * Get tenant info * * @returns {Promise<TenantManagementModels.TenantInfo>} * * @memberOf TenantManagementClient */ GetTenantInfo() { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/tenantInfo`, }); return result; }); } /** * Patch tenant info * * @param {TenantManagementModels.TenantInfoUpdateProperties} tenantInfoUpdateProperties * @param {{ ifMatch: string }} params * * @memberOf TenantManagementClient */ PatchTenantInfo(tenantInfoUpdateProperties, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { ifMatch } = parameters; yield this.HttpAction({ verb: "PATCH", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/tenantInfo`, body: tenantInfoUpdateProperties, additionalHeaders: { "If-Match": ifMatch }, }); }); } /** * Get tenant logo * * @returns {Promise<Response>} * * @memberOf TenantManagementClient */ GetTenantInfoLogo() { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/tenantInfo/logo`, rawResponse: true, }); return result; }); } /** * Upload tenant logo * * @param {Buffer} file * @param {string} [name] * @param {string} [mimeType] * @returns {Promise<Response>} * * @memberOf TenantManagementClient */ PostTenantInfoLogo(file, name, mimeType) { return __awaiter(this, void 0, void 0, function* () { const template = `----mindsphere\r\nContent-Disposition: form-data; name="file"; filename="${name}"\r\nContent-Type: ${mimeType || "application/octet-stream"}\r\n\r\n`; const body = Buffer.concat([Buffer.from(template), file, Buffer.from("\r\n----mindsphere--")]); const result = yield this.HttpAction({ verb: "POST", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/tenantInfo/logo`, body: body, multiPartFormData: true, rawResponse: true, additionalHeaders: { enctype: "multipart/form-data" }, }); return result; }); } /** * Get tenant logo metadata * * @returns {Promise<TenantManagementModels.UploadedFileResource>} * * @memberOf TenantManagementClient */ GetTenantInfoLogoMetaData() { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/tenantInfo/logoMetaData`, }); return result; }); } /** * Get subtenants * * @returns {Promise<TenantManagementModels.PageSubtenantResource>} * * @memberOf TenantManagementClient */ GetSubtenants(params) { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/subtenants?${(0, utils_1.toQueryString)(params)}`, }); return result; }); } /** * Create a subtenant * * @param {TenantManagementModels.Subtenant} subtenant * @returns {Promise<TenantManagementModels.SubtenantResource>} * * @memberOf TenantManagementClient */ PostSubtenant(subtenant) { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "POST", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/subtenants`, body: subtenant, }); return result; }); } /** * Get a subtenant by id. * * @param {string} id * @returns {Promise<TenantManagementModels.SubtenantResource>} * * @memberOf TenantManagementClient */ GetSubtenant(id) { return __awaiter(this, void 0, void 0, function* () { const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/subtenants/${id}`, }); return result; }); } /** * Update a subtenant by id * * @param {string} id * @param {TenantManagementModels.SubtenantUpdateProperties} subtenantUpdateProperties * @param {{ ifMatch: string }} params * @returns {Promise<TenantManagementModels.SubtenantResource>} * * @memberOf TenantManagementClient */ PutSubtenant(id, subtenantUpdateProperties, params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { ifMatch } = parameters; const result = yield this.HttpAction({ verb: "PUT", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/subtenants/${id}`, body: subtenantUpdateProperties, additionalHeaders: { "If-Match": ifMatch }, }); return result; }); } /** * Delete a subtenant by id * * @param {string} id * * @memberOf TenantManagementClient */ DeleteSubtenant(id) { return __awaiter(this, void 0, void 0, function* () { yield this.HttpAction({ verb: "DELETE", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/subtenants/${id}`, noResponse: true, }); }); } } exports.TenantManagementClient = TenantManagementClient; //# sourceMappingURL=tenant-management.js.map