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)

115 lines 5.03 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.TimeSeriesBulkClient = void 0; const utils_1 = require("../../utils"); const sdk_client_1 = require("../common/sdk-client"); /** * This API allows the bulk import of files containing high frequent data with up to nano-second precision * to the IoT Time Series services. * Additionally it can be used to retrieve the status of a specific import job and it provides capabilities to read the data back for use in applications. * * @export * @class TimeSeriesBulkClient * @extends {SdkClient} */ class TimeSeriesBulkClient extends sdk_client_1.SdkClient { constructor() { super(...arguments); this._baseUrl = "/api/iottsbulk/v3"; } /** * Bulk imports time series data for a specific asset and aspect. * This API can also be used for submitting multiple jobs for same hour interval. * The API will not do partial processing of input files, in case the total size for a job for an hour interval exceeds 350 MB. * * @param {TimeSeriesBulkModels.BulkImportInput} job * @returns {Promise<TimeSeriesBulkModels.JobStatus>} * * @memberOf TimeSeriesBulkClient */ PostImportJob(job) { 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}/importJobs`, body: job, message: "PostImportJob" })); this.fixResultsFor3_3_0(result); return result; }); } /** * Get job status API to get current status of bulk ingest job. * * @param {string} jobId * @returns {Promise<TimeSeriesBulkModels.JobStatus>} * * @memberOf TimeSeriesBulkClient */ GetJobStatus(jobId) { 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}/importJobs/${jobId}`, message: "GetJobStatus" })); this.fixResultsFor3_3_0(result); return result; }); } fixResultsFor3_3_0(result) { // ! This is unfortunately necessary as the version of the API (3.3.0) on eu1 in April 2019 // ! was returning properties jobId, jobStartTime, jobLastModified but OpenAPI specification was id, startTime, lastModified result.id = result.id || result.jobId; result.startTime = result.startTime || result.jobStartTime; result.lastModifed = result.lastModifed || result.jobLastModified; } /** * Read time series data for a single entity and property set. * Returns data for a specified time range. * Returns the latest value if no range is provided. * Returns only the selected properties if 'select' parameter is used. * Returns a limited number of records if the 'limit' parameter is used * * @param {string} entity * @param {string} propertysetname * @param {Date} from * @param {Date} to * @param {{ limit?: number; select?: string; sort?: string }} [optional] * @returns {Promise<TimeSeriesBulkModels.Timeseries[]>} * * @memberOf TimeSeriesBulkClient */ GetTimeSeries(entity, propertysetname, from, to, optional) { return __awaiter(this, void 0, void 0, function* () { (0, utils_1.checkAssetId)(entity); const fromto = (0, utils_1.toQueryString)({ from: from, to: to }); let qs = (0, utils_1.toQueryString)(optional); if (qs !== "") qs = `&${qs}`; return (yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/timeseries/${entity}/${propertysetname}?${fromto}${qs}`, message: "GetTimeSeries" })); }); } } exports.TimeSeriesBulkClient = TimeSeriesBulkClient; //# sourceMappingURL=iot-timeseries-bulk.js.map