@opscompass/opscompass-cli 1.0.29 → 1.0.30
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.
- package/modules/compliance.js +0 -1
- package/modules/expiration-info.js +185 -0
- package/modules/license-manager.js +16 -1
- package/modules.js +2 -0
- package/package.json +2 -2
package/modules/compliance.js
CHANGED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
const { getOpsCompassClient } = require("../opscompass.js");
|
|
2
|
+
|
|
3
|
+
async function listExpirationComponents(args) {
|
|
4
|
+
for (let i = 0; i < args.length; i++) {
|
|
5
|
+
switch (args[i].toLowerCase()) {
|
|
6
|
+
case "--company":
|
|
7
|
+
callParams.company = args[++i];
|
|
8
|
+
break;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const client = await getOpsCompassClient();
|
|
14
|
+
const response = await client.expirationInfo.listExpirationComponents(callParams);
|
|
15
|
+
|
|
16
|
+
console.log(JSON.stringify(response, null, 2));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function listExpirationComponentVersions(args) {
|
|
20
|
+
for (let i = 0; i < args.length; i++) {
|
|
21
|
+
switch (args[i].toLowerCase()) {
|
|
22
|
+
case "--company":
|
|
23
|
+
callParams.company = args[++i];
|
|
24
|
+
break;
|
|
25
|
+
case "--componentslug":
|
|
26
|
+
case "--component-slug":
|
|
27
|
+
callParams.componentSlug = args[++i];
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
const client = await getOpsCompassClient();
|
|
34
|
+
const response = await client.expirationInfo.listExpirationComponentVersions(callParams);
|
|
35
|
+
|
|
36
|
+
console.log(JSON.stringify(response, null, 2));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function saveExpirationComponentVersion(args) {
|
|
40
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
41
|
+
switch (args[i].toLowerCase()) {
|
|
42
|
+
case "--company":
|
|
43
|
+
callParams.company = args[++i];
|
|
44
|
+
break;
|
|
45
|
+
case "--component-version":
|
|
46
|
+
case "--componentversion":
|
|
47
|
+
callParams.componentVersion = args[++i];
|
|
48
|
+
break;
|
|
49
|
+
case "--resource-id":
|
|
50
|
+
case "--resourceid":
|
|
51
|
+
callParams.resourceId = args[++i];
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const client = await getOpsCompassClient();
|
|
57
|
+
const response = await client.expirationInfo.saveExpirationComponentVersion(callParams);
|
|
58
|
+
|
|
59
|
+
console.log(JSON.stringify(response, null, 2));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function deleteExpirationComponentVersion(args) {
|
|
63
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
64
|
+
switch (args[i].toLowerCase()) {
|
|
65
|
+
case "--company":
|
|
66
|
+
callParams.company = args[++i];
|
|
67
|
+
break;
|
|
68
|
+
case "--component-version":
|
|
69
|
+
case "--componentversion":
|
|
70
|
+
callParams.componentVersion = args[++i];
|
|
71
|
+
break;
|
|
72
|
+
case "--resource-id":
|
|
73
|
+
case "--resourceid":
|
|
74
|
+
callParams.resourceId = args[++i];
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const client = await getOpsCompassClient();
|
|
80
|
+
const response = await client.expirationInfo.deleteExpirationComponentVersion(callParams);
|
|
81
|
+
|
|
82
|
+
console.log(JSON.stringify(response, null, 2));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function listExpirations(args) {
|
|
86
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
87
|
+
switch (args[i].toLowerCase()) {
|
|
88
|
+
case "--company":
|
|
89
|
+
callParams.company = args[++i];
|
|
90
|
+
break;
|
|
91
|
+
case "--from-date":
|
|
92
|
+
case "--fromdate":
|
|
93
|
+
callParams.fromDate = args[++i];
|
|
94
|
+
break;
|
|
95
|
+
case "--to-date":
|
|
96
|
+
case "--todate":
|
|
97
|
+
callParams.toDate = args[++i];
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const client = await getOpsCompassClient();
|
|
103
|
+
const response = await client.expirationInfo.listExpirations(callParams);
|
|
104
|
+
|
|
105
|
+
console.log(JSON.stringify(response, null, 2));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function listTracked(args) {
|
|
109
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
110
|
+
switch (args[i].toLowerCase()) {
|
|
111
|
+
case "--company":
|
|
112
|
+
callParams.company = args[++i];
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const client = await getOpsCompassClient();
|
|
118
|
+
const response = await client.expirationInfo.listTracked(callParams);
|
|
119
|
+
|
|
120
|
+
console.log(JSON.stringify(response, null, 2));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function printHelp() {
|
|
124
|
+
console.log("Actions available for expiration info:");
|
|
125
|
+
console.log();
|
|
126
|
+
console.log("list-expiration-components", "Retrieves the list of available expiration components for a company.");
|
|
127
|
+
console.log("Parameters:");
|
|
128
|
+
console.log("--company [company_slug]");
|
|
129
|
+
console.log();
|
|
130
|
+
console.log("list-expiration-component-versions", "Retrieves the list of available expiration component versions for a company.");
|
|
131
|
+
console.log("Parameters:");
|
|
132
|
+
console.log("--company [company_slug]");
|
|
133
|
+
console.log("--component-slug [component_slug]");
|
|
134
|
+
console.log();
|
|
135
|
+
console.log("list-expirations", "Retrieves the list of expirations for a company.");
|
|
136
|
+
console.log("Parameters:");
|
|
137
|
+
console.log("--company [company_slug]");
|
|
138
|
+
console.log("--from-date (optional) [string] Example: '2021-01-01T00:00:00.000Z'");
|
|
139
|
+
console.log("--to-date (optional) [string] Example: '2021-12-31T00:00:00.000Z'");
|
|
140
|
+
console.log();
|
|
141
|
+
console.log("list-tracked", "Retrieves the list of tracked expirations for a company.");
|
|
142
|
+
console.log("Parameters:");
|
|
143
|
+
console.log("--company [company_slug]");
|
|
144
|
+
console.log();
|
|
145
|
+
console.log("save-expiration-component-version", "Saves the expiration component version for a company.");
|
|
146
|
+
console.log("Parameters:");
|
|
147
|
+
console.log("--company [company_slug]");
|
|
148
|
+
console.log("--component-version [component_version] Example: 'vue/2'");
|
|
149
|
+
console.log("--resource-id (optional) [string] a resource cloud_id. include if you want to tie this component version to a resource");
|
|
150
|
+
console.log();
|
|
151
|
+
console.log("delete-expiration-component-version", "Deletes the expiration component version for a company.");
|
|
152
|
+
console.log("Parameters:");
|
|
153
|
+
console.log("--company [company_slug]");
|
|
154
|
+
console.log("--component-version [component_version] Example: 'vue/2'");
|
|
155
|
+
console.log("--resource-id (optional) [string] a resource cloud_id. include if you want to delete the tie between this component version and this resource");
|
|
156
|
+
console.log();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const expirationInfoModule = (action, ...args) => {
|
|
160
|
+
switch (action?.toLowerCase() ?? "") {
|
|
161
|
+
case "list-expiration-components":
|
|
162
|
+
return listExpirationComponents(args);
|
|
163
|
+
case "list-expiration-component-versions":
|
|
164
|
+
return listExpirationComponentVersions(args);
|
|
165
|
+
case "list-expirations":
|
|
166
|
+
return listExpirations(args);
|
|
167
|
+
case "list-tracked":
|
|
168
|
+
return listTracked(args);
|
|
169
|
+
case "save-expiration-component-version":
|
|
170
|
+
return saveExpirationComponentVersion(args);
|
|
171
|
+
case "delete-expiration-component-version":
|
|
172
|
+
return deleteExpirationComponentVersion(args);
|
|
173
|
+
case "help":
|
|
174
|
+
case "":
|
|
175
|
+
return printHelp();
|
|
176
|
+
default:
|
|
177
|
+
console.log("Unknown command:", action);
|
|
178
|
+
return printHelp();
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
expirationInfoModule.requiresLogin = true;
|
|
183
|
+
expirationInfoModule.description = "Provides access to details about expirations tracked OpsCompass.";
|
|
184
|
+
|
|
185
|
+
module.exports = expirationInfoModule;
|
|
@@ -417,20 +417,33 @@ async function getMonitoringConfiguration(args) {
|
|
|
417
417
|
|
|
418
418
|
async function createMonitoringConfiguration(args) {
|
|
419
419
|
let name = undefined;
|
|
420
|
+
let optionalParams = {
|
|
421
|
+
autoUpdateScripts: undefined,
|
|
422
|
+
autoUpdateConfigurations: undefined,
|
|
423
|
+
};
|
|
420
424
|
for (let i = 0; i < args.length - 1; i++) {
|
|
421
425
|
switch (args[i].toLowerCase()) {
|
|
422
426
|
case "--company":
|
|
423
427
|
company = args[++i];
|
|
424
428
|
break;
|
|
425
429
|
case "--configurationname":
|
|
430
|
+
case "--configuration-name":
|
|
426
431
|
name = args[++i];
|
|
427
432
|
break;
|
|
433
|
+
case "--autoupdatescripts":
|
|
434
|
+
case "--auto-update-scripts":
|
|
435
|
+
optionalParams.autoUpdateScripts = args[++i] === "true";
|
|
436
|
+
break;
|
|
437
|
+
case "--autoupdateconfigurations":
|
|
438
|
+
case "--auto-update-configurations":
|
|
439
|
+
optionalParams.autoUpdateConfigurations = args[++i] === "true";
|
|
440
|
+
break;
|
|
428
441
|
}
|
|
429
442
|
}
|
|
430
443
|
|
|
431
444
|
const client = await getOpsCompassClient();
|
|
432
445
|
const monitoringConfiguration =
|
|
433
|
-
await client.licenseManager.createMonitoringConfiguration(company, name);
|
|
446
|
+
await client.licenseManager.createMonitoringConfiguration(company, name, optionalParams);
|
|
434
447
|
|
|
435
448
|
console.log(JSON.stringify(monitoringConfiguration, null, 2));
|
|
436
449
|
}
|
|
@@ -1469,6 +1482,8 @@ async function printHelp() {
|
|
|
1469
1482
|
console.log("Parameters:");
|
|
1470
1483
|
console.log("--company [company_slug]");
|
|
1471
1484
|
console.log("--configurationName [configuration name]");
|
|
1485
|
+
console.log("--autoUpdateScripts (optional) [true | false] automatically update all scripts when the scripts are run.");
|
|
1486
|
+
console.log("--autoUpdateConfigurations (optional) [true | false] automatically update all configurations when scripts are run.");
|
|
1472
1487
|
console.log();
|
|
1473
1488
|
console.log(
|
|
1474
1489
|
"create-network-discovery-configuration",
|
package/modules.js
CHANGED
|
@@ -2,6 +2,7 @@ const resources = require("./modules/resources.js");
|
|
|
2
2
|
const accounts = require("./modules/accounts.js");
|
|
3
3
|
const licenseManager = require("./modules/license-manager.js");
|
|
4
4
|
const compliance = require("./modules/compliance.js");
|
|
5
|
+
const expirationInfo = require("./modules/expiration-info.js");
|
|
5
6
|
const defaults = require("./modules/defaults.js");
|
|
6
7
|
|
|
7
8
|
// Dynaimcally loaded modules - may be optional
|
|
@@ -26,5 +27,6 @@ module.exports = {
|
|
|
26
27
|
compliance,
|
|
27
28
|
defaults,
|
|
28
29
|
"license-manager": licenseManager,
|
|
30
|
+
"expiration-info": expirationInfo,
|
|
29
31
|
"data-gathering-scripts": dataGatheringScripts,
|
|
30
32
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opscompass/opscompass-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
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.
|
|
18
|
+
"@opscompass/opscompass-api": "^1.0.30",
|
|
19
19
|
"adm-zip": "^0.5.9",
|
|
20
20
|
"axios": "^0.21.1",
|
|
21
21
|
"fs-extra": "^10.1.0",
|