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)

52 lines 3.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 }); const console_1 = require("console"); const assets_1 = require("./assets"); const command_utils_1 = require("./command-utils"); let color = (0, command_utils_1.getColor)("magenta"); exports.default = (program) => { program .command("list-assets") .alias("la") .option("-f, --filter [filter]", `filter (see: ${color("https://developer.mindsphere.io/apis/advanced-assetmanagement/api-assetmanagement-references-filtering.html")}) `) .option("-a, --assetname [name]", "search for assets with string [name] in asset name") .option("-t, --typeid [typeid]", "search for assets with string [typeid] in typeid") .option("-c, --includeshared", "include shared assets") .option("-k, --passkey <passkey>", "passkey") .option("-y, --retry <number>", "retry attempts before giving up", "3") .option("-v, --verbose", "verbose output") .description(color(`list assets in the tenant *`)) .action((options) => { (() => __awaiter(void 0, void 0, void 0, function* () { try { checkRequiredParameters(options); const sdk = (0, command_utils_1.getSdk)(options); color = (0, command_utils_1.adjustColor)(color, options); (0, command_utils_1.homeDirLog)(options.verbose, color); (0, command_utils_1.proxyLog)(options.verbose, color); yield (0, assets_1.listAssets)(options, sdk); } catch (err) { (0, command_utils_1.errorLog)(err, options.verbose); } }))(); }) .on("--help", () => { (0, console_1.log)("\n Examples:\n"); (0, console_1.log)(` mdsp list-assets --passkey mypasskey \t\t\t\t\t\tlist all assets`); (0, console_1.log)(` mdsp la --typeid core.mclib --assetname nodered --passkey mypasskey \t\tlist all agents (assets of type core.mclib) with nodered in the name`); (0, console_1.log)(` mdsp la --filter '{"name" : {"contains" : "Engine"}}' --passkey mypasskey \tlist all assets where name contains string Engine`); (0, command_utils_1.serviceCredentialLog)(); }); }; function checkRequiredParameters(options) { } //# sourceMappingURL=mc-list-assets.js.map