@opscompass/opscompass-cli 1.0.21 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -111,6 +111,10 @@ async function get(action, args) {
111
111
  callParams.type = args[++i];
112
112
  }
113
113
  break;
114
+ case "--latest-configuration":
115
+ case "--latestconfiguration":
116
+ callParams.latestConfiguration = args[++i] == "true" ? true : undefined;
117
+ break;
114
118
  }
115
119
  }
116
120
 
@@ -340,6 +344,27 @@ async function uploadMetrics(args) {
340
344
  console.log(message);
341
345
  }
342
346
 
347
+ async function getLatestConfiguration(args) {
348
+ const callData = {};
349
+ for (let i = 0; i < args.length - 1; i++) {
350
+ switch (args[i].toLowerCase()) {
351
+ case "--company":
352
+ callData.company = args[++i];
353
+ break;
354
+ case "--id":
355
+ callData.id = args[++i];
356
+ break;
357
+ case "--resourceid":
358
+ case "--resource-id":
359
+ callData.resourceId = args[++i];
360
+ break;
361
+ }
362
+ }
363
+
364
+ const client = await getOpsCompassClient();
365
+ const latestConfiguration = await client.resources.getLatestConfiguration(callData);
366
+ console.log(JSON.stringify(latestConfiguration, null, 2));
367
+ }
343
368
 
344
369
  async function printHelp() {
345
370
  console.log("Actions available for resources:");
@@ -349,6 +374,7 @@ async function printHelp() {
349
374
  console.log("--company [company_id]");
350
375
  console.log("--id [12345]");
351
376
  console.log("--resource-id [cloud-resource-id]");
377
+ console.log("--latest-configuration (optional) [boolean]");
352
378
  console.log();
353
379
  console.log("get-compliance", "Gets compliance check details for a resource.");
354
380
  console.log("Parameters:");
@@ -435,6 +461,12 @@ async function printHelp() {
435
461
  console.log("--resourceIds (optional) [resource cloud id] Example: --resourceIds arn:aws:ec2:us-east-1:444855252760:customer-gateway/1234")
436
462
  console.log("--resourceTags (optional) [tag-value] ")
437
463
  console.log();
464
+ console.log("get-latest-configuration", "Gets the latest configuration for a resource.");
465
+ console.log("Parameters:");
466
+ console.log("--company [company_id]");
467
+ console.log("--id [resource id]");
468
+ console.log("--resource-id [cloud-resource-id]");
469
+ console.log();
438
470
  }
439
471
 
440
472
  const resourcesModule = (action, ...args) => {
@@ -459,6 +491,8 @@ const resourcesModule = (action, ...args) => {
459
491
  return getMetricNamesForResourceType(args);
460
492
  case "upload-metrics":
461
493
  return uploadMetrics(args);
494
+ case "get-latest-configuration":
495
+ return getLatestConfiguration(args);
462
496
  case "help":
463
497
  case "":
464
498
  return printHelp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opscompass/opscompass-cli",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "Calls OpsCompass's APIs",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  "author": "opscompass",
16
16
  "license": "SEE LICENSE IN license.txt",
17
17
  "dependencies": {
18
- "@opscompass/opscompass-api": "^1.0.21",
18
+ "@opscompass/opscompass-api": "^1.0.22",
19
19
  "adm-zip": "^0.5.9",
20
20
  "axios": "^0.21.1",
21
21
  "fs-extra": "^10.1.0",