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)

894 lines (892 loc) 117 kB
"use strict"; // noinspection JSValidateJSDoc 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.FirmwareDeploymentClient = exports.EdgeAppDeploymentClient = exports.EdgeAppInstanceManagementClient = exports.DeploymentWorkflowClient = exports.DeviceConfigurationClient = exports.DeviceStatusManagementClient = exports.DeviceManagementClient = void 0; const utils_1 = require("../../utils"); const sdk_client_1 = require("../common/sdk-client"); const open_edge_models_1 = require("./open-edge-models"); /** * Device Management API * Device Managment API can be used by device builders to define device types and by device operators to manage device instances. At the moment, device types are only visible to the tenant creating them. Devices are the basis for managing software and configuration in other edge APIs. Each device is associated to a device type, which defines the firmware to be installed on the device. Once a device is created, the device type association cannot be changed anymore. Agents must be associated to devices to be able to access the Deployment Workflow API. * * @export * @class DeviceManagementClient * @extends {SdkClient} */ class DeviceManagementClient extends sdk_client_1.SdkClient { constructor() { super(...arguments); this._baseUrl = "/api/devicemanagement/v3"; } /** * * DeviceTypes * * Get all device types * @summary Get all device types * @param {{ * owner?: string; * code?: string; * assetTypeId?: string; * page?: number; * size?: number; * sort?: string; * }} [params] * @param {string} [params.owner] Owner tenant * @param {string} [params.code] Device Type Code * @param {string} [params.assetTypeId] Associated asset type id * @param {number} [params.size] The maximum number of elements returned in one page * @param {number} [params.page] The (0-based) index of the page * @param {string} [params.sort] The order of returned elements.&lt;br/&gt;Multiple fields could be used separated by commas (e.g. &#39;field1,field2&#39;).&lt;br/&gt;Descending order could be requested by appending &#39;,desc&#39; at the end of parameter.(e.g. &#39;field1,field2,desc&#39;) * @example await deviceManagement.GetDeviceTypes(); * @example await deviceManagement.GetDeviceTypes({sort: 'id,name'}); * @returns {Promise<DeviceManagementModels.PaginatedDeviceType>} * * @memberOf DeviceManagementClient */ GetDeviceTypes(params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { owner, code, assetTypeId, page, size, sort } = parameters; const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/deviceTypes?${(0, utils_1.toQueryString)({ owner, code, assetTypeId, page, size, sort })}`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * * DeviceTypes * * Get device type by given device type id * @summary Get device type by given device type id * @param {string} id Id of device type * @returns {Promise<DeviceManagementModels.DeviceType>} * * @example await deviceManagement.GetDeviceType("mdsp.EnvironmentDevice") * @memberOf DeviceManagementClient */ GetDeviceType(id) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceManagementModels.RequiredError("id", "Required parameter id was null or undefined when calling GetDeviceType."); } const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/deviceTypes/${id}`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * * DeviceTypes * Create a new device type * @summary Create a new device type * @param {DeviceType} deviceType Device type fields * @returns {Promise<DeviceManagementModels.DeviceType>} * * @example await deviceManagement.PostDeviceType (myDeviceType) * @memberOf DeviceManagementClient */ PostDeviceType(deviceType) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'deviceType' is not null or undefined if (deviceType === null || deviceType === undefined) { throw new open_edge_models_1.DeviceManagementModels.RequiredError("deviceType", "Required parameter deviceType was null or undefined when calling PostDeviceType."); } const result = yield this.HttpAction({ verb: "POST", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/deviceTypes`, body: deviceType, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * * DeviceTypes * Update device type by given device type id * @summary Update device type by given device type id * @param {string} id Id of device type * @param {DeviceManagementModels.DeviceTypeUpdate} deviceType Device type info in JSON format * @returns {Promise<DeviceManagementModels.DeviceType>} * * @example await deviceManagement.PostDeviceType (myDeviceType) * @memberOf DeviceManagementClient */ PatchDeviceType(id, deviceType) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceManagementModels.RequiredError("id", "Required parameter id was null or undefined when calling PatchDeviceType."); } // verify required parameter 'deviceType' is not null or undefined if (deviceType === null || deviceType === undefined) { throw new open_edge_models_1.DeviceManagementModels.RequiredError("deviceType", "Required parameter deviceType was null or undefined when calling PatchDeviceType."); } const result = yield this.HttpAction({ verb: "PATCH", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/deviceTypes/${id}`, body: deviceType, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Deletes the device type with the specified id # Idempotency # This endpoint provides idempotent deletes, i.e., repeated deletes to the same resource will always return 204 responses regardless whether the resource existed in the first place or not. * @summary Delete devicetype * @param {string} id id of the device tye * * @example await deviceManagement.DeleteDeviceType("mdsp.EnvironmentDevice") * * @memberOf DeviceManagementClient */ DeleteDeviceType(id) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceManagementModels.RequiredError("id", "Required parameter id was null or undefined when calling DeleteDeviceType."); } try { yield this.HttpAction({ verb: "DELETE", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/deviceTypes/${id}`, noResponse: true, }); } catch (error) { console.error("At the time of creation of this client (May 2021), MindSphere didn't have any support for DELETE operation on device-types."); console.error("This was reported to mindsphere development team and should eventually start working."); throw error; } }); } /** * * Devices * Returns a paginated list of all devices within the caller tenant Searching / filtering is currently not supported * @summary List devices * @summary List devices * @param {{ * assetId?: string; * page?: number; * size?: number; * }} [params] * @param {number} [params.size] The maximum number of elements returned in one page * @param {number} [params.page] The (0-based) index of the page * @param {string} [params.assetId] Associated asset id * * @example await deviceManagement.GetDevices(); * @example await deviceManagement.GetDevices({size: 10}); * @returns {Promise<DeviceManagementModels.PaginatedDevice>} * * @memberOf DeviceManagementClient */ GetDevices(params) { return __awaiter(this, void 0, void 0, function* () { const parameters = params || {}; const { assetId, page, size } = parameters; const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices?${(0, utils_1.toQueryString)({ assetId, page, size })}`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * * Devices * Returns the specified device * @summary Fetch a device * @param {string} id id of the device * @returns {Promise<DeviceManagementModels.Device>} * * @example await deviceManagement.GetDevice("mdsp.EnvironmentDevice") * @memberOf DeviceManagementClient */ GetDevice(id) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceManagementModels.RequiredError("id", "Required parameter id was null or undefined when calling GetDevice."); } const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * * Devices * Updates the device. # Constraints # * All fields are optional. If a field is null or is omitted, the current value will be preserved. * If the read-only fields `id` and `deviceTypeId` are present, they must match the current value or an error is returned. * The `agents` list and `properties` json block are replaced with the content specified in the request if present. Partial modification of these elements is not possible. * @summary Update device * @param {string} id id of the device * @param {DeviceManagementModels.DeviceUpdate} deviceMetadata Device metadata * @returns {Promise<Device>} * * @example await deviceManagement.PatchDevice("mdsp.EnvironmentDevice", myDevice;Metadata) * @memberOf DeviceManagementClient */ PatchDevice(id, deviceMetadata) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceManagementModels.RequiredError("id", "Required parameter id was null or undefined when calling PatchDevice."); } // verify required parameter 'deviceMetadata' is not null or undefined if (deviceMetadata === null || deviceMetadata === undefined) { throw new open_edge_models_1.DeviceManagementModels.RequiredError("deviceMetadata", "Required parameter deviceMetadata was null or undefined when calling PatchDevice."); } const result = yield this.HttpAction({ verb: "PATCH", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}`, body: deviceMetadata, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * * Devices * Creates a new device. # Constraints # The (mandatory) device type cannot be modified after the device has been created. * @summary Create a new device * @param {DeviceManagementModels.DeviceCreation} deviceMetadata Device metadata * @returns {Promise<DeviceManagementModels.Device} * * @example await deviceManagement.PostDeviceType (myDeviceType) * @memberOf DeviceManagementClient */ PostDevice(deviceMetadata) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'deviceType' is not null or undefined if (deviceMetadata === null || deviceMetadata === undefined) { throw new open_edge_models_1.DeviceManagementModels.RequiredError("deviceMetadata", "Required parameter deviceMetadata was null or undefined when calling PostDevice."); } const result = yield this.HttpAction({ verb: "POST", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices`, body: deviceMetadata, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Deletes the device with the specified id # Idempotency # This endpoint provides idempotent deletes, i.e., repeated deletes to the same resource will always return 204 responses regardless whether the resource existed in the first place or not. * @summary Delete device * @param {string} id id of the device * * @example await deviceManagement.DeleteDevice("mdsp.EnvironmentDevice") * * @memberOf DeviceManagementClient */ DeleteDevice(id) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceManagementModels.RequiredError("id", "Required parameter id was null or undefined when calling DeleteDevice."); } yield this.HttpAction({ verb: "DELETE", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}`, noResponse: true, }); }); } } exports.DeviceManagementClient = DeviceManagementClient; /** * Device Status API * Device Status API allows devices to provide status information to be queried by backend applications. Device status comprises information about device health, connection status, and the installed software inventory. Health information can be flexibly extended to contain custom health information. * * * @export * @class DeviceStatusManagementClient * @extends {SdkClient} */ class DeviceStatusManagementClient extends sdk_client_1.SdkClient { constructor() { super(...arguments); this._baseUrl = "/api/devicestatus/v3"; } /** * Allows the devices to report on the device health status * @summary Report device health status * @param {string} id ID of the device * @param {DeviceStatusModels.DeviceHealthStatusReportInput} healthStatusReport Report of the device health status * @throws {DeviceStatusModels.RequiredError} * @memberof DeviceStatusManagementClient */ PatchDeviceHealth(id, healthStatusReport) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("id", "Required parameter id was null or undefined when calling PatchDeviceHealth."); } // verify required parameter 'healthStatusReport' is not null or undefined if (healthStatusReport === null || healthStatusReport === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("healthStatusReport", "Required parameter healthStatusReport was null or undefined when calling PatchDeviceHealth."); } const result = yield this.HttpAction({ verb: "PATCH", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/health`, body: healthStatusReport, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Retrieves the device health status * @summary Retrieves the device health status * @param {string} id id of the device * @throws {DeviceStatusModels.RequiredError} * @memberof DeviceStatusManagementClient */ GetDeviceHealth(id) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("id", "Required parameter id was null or undefined when calling GetDeviceHealth."); } const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/health`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Persist data configuration health status. * @summary Persist data configuration health status * @param {string} id ID of the device * @param {DeviceStatusModels.DataConfigHealthInput} dataConfig Data configuration health status * @throws {DeviceStatusModels.RequiredError} * @memberof DeviceStatusManagementClient */ PatchDeviceHealthDataConfig(id, dataConfig) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("id", "Required parameter id was null or undefined when calling PatchDeviceHealthDataConfig."); } // verify required parameter 'dataConfig' is not null or undefined if (dataConfig === null || dataConfig === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("dataConfig", "Required parameter dataConfig was null or undefined when calling PatchDeviceHealthDataConfig."); } const result = yield this.HttpAction({ verb: "PATCH", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/health/dataConfig`, body: dataConfig, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Retrieves the data configuration health status. * @summary Retrieves the data configuration health status * @param {string} id id of the device * @throws {DeviceStatusModels.RequiredError} * @memberof DeviceStatusManagementClient */ GetDeviceHealthDataConfig(id) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("id", "Required parameter id was null or undefined when calling GetDeviceHealthDataConfig."); } const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/health/dataConfig`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Sends the heartbeat. * @summary Sends the heartbeat * @param {string} id ID of the device * @throws {DeviceStatusModels.RequiredError} * @memberof DeviceStatusManagementClient */ PostDeviceHeartbeat(id) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("id", "Required parameter id was null or undefined when calling PostDeviceHeartbeat."); } const result = yield this.HttpAction({ verb: "POST", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/sendHeartbeat/`, rawResponse: true, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Retrieves the device connection status * @summary Retrieves the device connection status * @param {string} id ID of the device * @throws {DeviceStatusModels.RequiredError} * @memberof DeviceStatusManagementClient */ GetDeviceConnectionStatus(id) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("id", "Required parameter id was null or undefined when calling GetDeviceConnectionStatus."); } const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/connectionStatus`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Returns a paginated list of all software (firmware, apps, etc) installed on the device # Searching / Filtering # The following filter criteria can be specified as query parameters * *type*: return only firmware or apps or ... * *softwareId*: return only software belonging to the specified product (potentially multiple different versions could be installed at the same time) * @summary List software installed on device * @param {string} id ID of the device * @param {'FIRMWARE' | 'APP'} [type] type of software * @param {string} [softwareId] id of the software * @param {number} [size] The maximum number of elements returned in one page * @param {number} [page] The (0-based) index of the page * @throws {DeviceStatusModels.RequiredError} * @memberof DeviceStatusManagementClient */ GetDeviceSoftwares(id, type, softwareId, page, size) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("id", "Required parameter id was null or undefined when calling GetDeviceSoftwares."); } const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/software?${(0, utils_1.toQueryString)({ type, softwareId, size, page })}`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Returns the software inventory of the device. * @summary Get inventory * @param {string} id ID of the device * @param {'FIRMWARE' | 'APP'} [type] type of software * @throws {DeviceStatusModels.RequiredError} * @memberof DeviceStatusManagementClient */ GetDeviceInventory(id, type) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("id", "Required parameter id was null or undefined when calling GetDeviceInventory."); } const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/inventory?${(0, utils_1.toQueryString)({ type })}`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Updates the software inventory of the device. The whole inventory is replaced with the content sent by the device. * @summary Update inventory * @param {string} id ID of the device * @param {Array<DeviceStatusModels.InventoryEntry>} installationSoftwareInventory List of installed software * @throws {DeviceStatusModels.RequiredError} * @memberof DeviceStatusManagementClient */ PatchDeviceSoftwareInventory(id, installationSoftwareInventory) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("id", "Required parameter id was null or undefined when calling PatchDeviceSoftwareInventory."); } // verify required parameter 'installationSoftwareInventory' is not null or undefined if (installationSoftwareInventory === null || installationSoftwareInventory === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("installationSoftwareInventory", "Required parameter installationSoftwareInventory was null or undefined when calling PatchDeviceSoftwareInventory."); } const result = yield this.HttpAction({ verb: "PATCH", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/inventory`, body: installationSoftwareInventory, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Updates the software inventory of the device for firmware type Provided as a convenience method for device implementations that use separate processes for managing firmware and app updates. By utilizing this endpoint the device does not have to aggregate firmware and apps into a wholistic list but can update firmware independently. * @summary Update firmware inventory on a device * @param {string} id ID of the device * @param {Array<DeviceStatusModels.InventoryFirmwareEntry>} installationFirmwareInventory List of installed firmware * @throws {DeviceStatusModels.RequiredError} * @memberof DeviceStatusManagementClient */ PatchDeviceFirmwareInventory(id, installationFirmwareInventory) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("id", "Required parameter id was null or undefined when calling PatchDeviceFirmwareInventory."); } // verify required parameter 'installationFirmwareInventory' is not null or undefined if (installationFirmwareInventory === null || installationFirmwareInventory === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("installationFirmwareInventory", "Required parameter installationFirmwareInventory was null or undefined when calling PatchDeviceFirmwareInventory."); } const result = yield this.HttpAction({ verb: "PATCH", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/inventory/firmware`, body: installationFirmwareInventory, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Updates the software inventory of the device for edge application type Provided as a convenience method for device implementations that use separate processes for managing firmware and app updates. By utilizing this endpoint the device does not have to aggregate firmware and apps into a wholistic list but can update edge applications independently. * @summary Update edge application inventory on a device * @param {string} id ID of the device * @param {Array<DeviceStatusModels.InventoryApplicationEntry>} installationApplicationInventory List of installed edge applications * @throws {DeviceStatusModels.RequiredError} * @memberof DeviceStatusManagementClient */ PatchDeviceApplicationInventory(id, installationApplicationInventory) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("id", "Required parameter id was null or undefined when calling PatchDeviceApplicationInventory."); } // verify required parameter 'installationApplicationInventory' is not null or undefined if (installationApplicationInventory === null || installationApplicationInventory === undefined) { throw new open_edge_models_1.DeviceStatusModels.RequiredError("installationApplicationInventory", "Required parameter installationApplicationInventory was null or undefined when calling PatchDeviceApplicationInventory."); } const result = yield this.HttpAction({ verb: "PATCH", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/inventory/apps`, body: installationApplicationInventory, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } } exports.DeviceStatusManagementClient = DeviceStatusManagementClient; /** * Device Configuration API * Device Configuration API can be used to manage device configuration files and to coordinate configuration tasks for devices. The provided operations do not trigger any actions themselves, but are meant to be used by northbound applications to coordinate user and device efforts. Configuration tasks consist of different states that require the app operator user and the target device to participate in order to complete a task. Devices should use Deployment Workflow API to find out about configuration tasks. Device Configuration Service is based on Deployment Workflow Service and reflects all changes applied through Deployment Workflow API. Once a task is created in this API, it will be available also through Deployment Workflow API. The configuration task status can be advanced at this API or at Deployment Workflow API. * * @export * @class DeviceConfigurationClient * @extends {SdkClient} */ class DeviceConfigurationClient extends sdk_client_1.SdkClient { constructor() { super(...arguments); this._baseUrl = "/api/deviceconfiguration/v3"; } /** * Returns a paginated list of all tasks of the specified device ordered by descending creation date (newest tasks first) * @summary List all tasks of a device * @param {string} id Id of the device that owns the task. * @param {number} [size] The maximum number of elements returned in one page * @param {number} [page] The (0-based) index of the page * @param {string} [sort] The order in which the elements are returned. Multiple fields could be used spearated by comma * @returns {Promise<DeviceConfigurationModels.PaginatedConfigurationTask>} * @throws {DeviceConfigurationModels.RequiredError} * * @example await deviceConfigurationClient.GetConfigurationTasks("mdsp.myDevice") * @memberof DeviceConfigurationClient */ GetConfigurationTasks(id, size, page, sort) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'deviceId' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("deviceId", "Required parameter id was null or undefined when calling GetConfigurationTasks."); } const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/configurationTasks?${(0, utils_1.toQueryString)({ size, page, sort })}`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Returns the specified task # Current State # The `currentState` field contains information about the current state in the state machine as well as the progress inside this state (if updated by the device) # History # The 'history' field contains a \"trace\" of all the past states this task was in, as well as the entry and exit times. It can be used to reconstruct the sequence of event/ actions that happend in this task. * @summary Get task * @param {string} id Id of the device that owns the task. * @param {string} taskId Id of the task * @returns {Promise<DeviceConfigurationModels.ConfigurationTask>} * @throws {DeviceConfigurationModels.RequiredError} * * @example await deviceConfigurationClient.GetDeviceConfigurationTask("mdsp.EnvironmentDevice", "345af46...") * @memberOf DeviceConfigurationClient */ GetDeviceConfigurationTask(id, taskId) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("id", "Required parameter id was null or undefined when calling GetDeviceConfigurationTask."); } // verify required parameter 'taskId' is not null or undefined if (taskId === null || taskId === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("taskId", "Required parameter taskId was null or undefined when calling GetDeviceConfigurationTask."); } const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/configurationTasks/${taskId}`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Create a new config deployment task. # Start of Execution # The newly created task will be in the CREATED state and thus not visible to the device. In order to start the execution of the task, update it to the CONFIGURE state. # Files # Each task refers to one or more files. Devices are expected to apply all files of a task in an \"atomic\" fashion (as far as this is feasible) The specified URI will be passed \"as-is\" to the device. Devices are expected to access this URI using Mindsphere credentials. Typically this URI will refer to a file in the Configuration File Storage, however it is possible to pass any URIs to the device as long as the device has the appropriate credentials to access the URI. # CustomData # The optional customData field can be used to pass arbitrary json data from the backend to the device in order. The backend will forward this information \"as-is\" to the device. * @summary Create new task * @param {string} id Id of the device that owns the task. * @param {DeviceConfigurationModels.TaskDefinition} taskDefinition task definition * @returns {Promise<DeviceConfigurationModels.ConfigurationTask>} * @throws {DeviceConfigurationModels.RequiredError} * * @example await DeviceConfigurationClient.PostNewDeploymentTaskConfiguration("myDeviceID", ...) * @memberOf DeviceConfigurationClient */ PostNewDeploymentTaskConfiguration(id, taskDefinition) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("id", "Required parameter id was null or undefined when calling PostNewDeploymentTaskConfiguration."); } // verify required parameter 'taskDefinition' is not null or undefined if (taskDefinition === null || taskDefinition === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("taskDefinition", "Required parameter taskDefinition was null or undefined when calling PostNewDeploymentTaskConfiguration."); } const result = yield this.HttpAction({ verb: "POST", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/configurationTasks`, body: taskDefinition, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Updates the task. Updates must follow the state machine definition. Failing to do so will cause a 409 error * @summary Update a task * @param {string} id Id of the device that owns the task. * @param {string} taskId Id of the task * @param {DeviceConfigurationModels.Updatetask} progressReport Updated configuration * @returns {Promise<DeviceConfigurationModels.ConfigurationTask>} * * @example await DeviceConfigurationClient.PatchDeploymentTaskConfiguration("myDeviceID", "mytaskID", ...) * @memberOf DeviceConfigurationClient */ PatchDeploymentTaskConfiguration(id, taskId, progressReport) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("id", "Required parameter id was null or undefined when calling PatchDeploymentTaskConfiguration."); } // verify required parameter 'taskId' is not null or undefined if (taskId === null || taskId === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("taskId", "Required parameter taskId was null or undefined when calling PatchDeploymentTaskConfiguration."); } // verify required parameter 'progressReport' is not null or undefined if (progressReport === null || progressReport === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("progressReport", "Required parameter progressReport was null or undefined when calling PatchDeploymentTaskConfiguration."); } const result = yield this.HttpAction({ verb: "PATCH", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/devices/${id}/configurationTasks/${taskId}`, body: progressReport, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Lists all files # Filtering / Searching # Using the `pathPrefix` query parameter, this endpoint can be used to look up the ids of files with a given path prefix. The supplied prefix will be compared with the `path` field of the file metadata. Users of the API should pick a naming scheme that allows efficient searching of files, e.g., using `{id}/{filename}.json` allows efficient listing of all files \"belonging\" to a specific device id. * @summary List files * @param {string} pathPrefix the prefix to search for * @param {number} [size] The maximum number of elements returned in one page * @param {number} [page] The (0-based) index of the page * @param {string} [sort] The order in which the elements are returned. Multiple fields could be used spearated by comma * @returns {Promise<DeviceConfigurationModels.PaginatedFileMetaData>} * @throws {DeviceConfigurationModels.RequiredError} * * @example await deviceConfigurationClient.GetFiles("./myfile") * @memberof DeviceConfigurationClient */ GetFiles(pathPrefix, size, page, sort) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'pathPrefix' is not null or undefined if (pathPrefix === null || pathPrefix === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("pathPrefix", "Required parameter pathPrefix was null or undefined when calling GetFiles."); } const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/files?${(0, utils_1.toQueryString)({ pathPrefix, size, page, sort })}`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Returns the metadata of the specified file. # File Id to Path Mapping # To obtain the id of a file, the GET `files` endpoint can be used which allows looking up file ids based on a path prefix # File Metadata / File Content # This endpoint returns the metadata of the file. To access the content of the file, either use the `files/{id}/head` endpoint (to access the latest revision) or list all available revisions via `files/{id}/revisions` and access the content of a specific revision via `files/{id}/revisions/{hash}/content` * @summary Get file metadata * @param {string} id the ID of the file * @returns {Promise<DeviceConfigurationModels.FileMetaData>} * @throws {DeviceConfigurationModels.RequiredError} * * @example await deviceConfigurationClient.GetFileMetadata("myFileID") * @memberOf DeviceConfigurationClient */ GetFileMetadata(id) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("id", "Required parameter id was null or undefined when calling GetFileMetadata."); } const result = yield this.HttpAction({ verb: "GET", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/files/${id}`, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Create a new config file. The specified path must be unique (see general documentation about paths) * @summary Create a new empty file * @param {DeviceConfigurationModels.ConfigurationFile} file configuration file object * @returns {Promise<DeviceConfigurationModels.FileMetaData>} * @throws {DeviceConfigurationModels.RequiredError} * * @example await DeviceConfigurationClient.PostNewFile( ...) * @memberOf DeviceConfigurationClient */ PostNewFile(file) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'file' is not null or undefined if (file === null || file === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("file", "Required parameter file was null or undefined when calling PostNewFile."); } const result = yield this.HttpAction({ verb: "POST", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/files`, body: file, additionalHeaders: { "Content-Type": "application/json" }, }); return result; }); } /** * Updates the \"head\" of this file, i.e., creates a new revision containing the data sent with the requests and updates the head resource to point to this new revision. Clients should use the If-Match header to safeguard against lost updates, i.e. concurrent access to the head resource # Content Metadata # Information about the content type and content length of the file are taken from the corresponding http header fields and must be correctly set by the client * @summary Update \"head\" * @param {string} id the ID of the file * @param {DeviceConfigurationModels.Payload} content Binary content of file. * @param {string} [contentType] Defines the accept header value to be used when retrieving the content * @returns {Promise<DeviceConfigurationModels.FileMetaData>} * * @example await DeviceConfigurationClient.PatchDeploymentTaskConfiguration("myFileID", ...) * @memberOf DeviceConfigurationClient */ PatchFileHead(id, content, contentType) { return __awaiter(this, void 0, void 0, function* () { // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("id", "Required parameter id was null or undefined when calling PatchFileHead."); } // verify required parameter 'content' is not null or undefined if (content === null || content === undefined) { throw new open_edge_models_1.DeviceConfigurationModels.RequiredError("content", "Required parameter content was null or undefined when calling PatchFileHead."); } const result = yield this.HttpAction({ verb: "PATCH", gateway: this.GetGateway(), authorization: yield this.GetToken(), baseUrl: `${this._baseUrl}/files/${id}/head`, body: content, additionalHeaders: { "Content-Type": contentType ? contentType : "*/*" }, }); return result; }); } /** * Deletes the specified file. This will also delete any revisions of this file and their content. # Idempotency # This endpoint provides idempotent deletes, i.e., repeated deletes to the same resource will al