@opscompass/opscompass-cli 1.0.12 → 1.0.14
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 +78 -2
- package/modules/license-manager.js +22 -1
- package/modules/resources.js +78 -0
- package/package.json +2 -2
package/modules/compliance.js
CHANGED
|
@@ -45,16 +45,78 @@ const { getCredentials } = require("../credentials.js");
|
|
|
45
45
|
|
|
46
46
|
async function listComplianceExceptions(args) {
|
|
47
47
|
let company = undefined;
|
|
48
|
+
let optionalParams = {
|
|
49
|
+
fromIndex: undefined,
|
|
50
|
+
numberOfRecords: undefined,
|
|
51
|
+
complianceExceptionSort: undefined,
|
|
52
|
+
complianceExceptionSortDirection: undefined,
|
|
53
|
+
searchText: undefined,
|
|
54
|
+
typeFilter: undefined,
|
|
55
|
+
statusFilter: undefined,
|
|
56
|
+
expiresAtFrom: undefined,
|
|
57
|
+
expiresAtTo: undefined,
|
|
58
|
+
checkIdsFilter: undefined,
|
|
59
|
+
resourceIdsFilter: undefined,
|
|
60
|
+
creatorIdsFilter: undefined
|
|
61
|
+
};
|
|
48
62
|
for (let i = 0; i < args.length - 1; i++) {
|
|
49
63
|
switch (args[i].toLowerCase()) {
|
|
50
64
|
case "--company":
|
|
51
65
|
company = args[++i];
|
|
52
66
|
break;
|
|
53
|
-
|
|
67
|
+
case "--from-index":
|
|
68
|
+
case "--fromindex":
|
|
69
|
+
optionalParams.fromIndex = args[++i];
|
|
70
|
+
break;
|
|
71
|
+
case "--number-of-records":
|
|
72
|
+
case "--numberofrecords":
|
|
73
|
+
optionalParams.numberOfRecords = args[++i];
|
|
74
|
+
break;
|
|
75
|
+
case "--compliance-exception-sort":
|
|
76
|
+
case "--complianceexceptionsort":
|
|
77
|
+
optionalParams.complianceExceptionSort = args[++i];
|
|
78
|
+
break;
|
|
79
|
+
case "--compliance-exception-sort-direction":
|
|
80
|
+
case "--complianceexceptionsortdirection":
|
|
81
|
+
optionalParams.complianceExceptionSortDirection = args[++i];
|
|
82
|
+
break;
|
|
83
|
+
case "--search-text":
|
|
84
|
+
case "--searchtext":
|
|
85
|
+
optionalParams.searchText = args[++i];
|
|
86
|
+
break;
|
|
87
|
+
case "--type-filter":
|
|
88
|
+
case "--typefilter":
|
|
89
|
+
optionalParams.typeFilter = args[++i];
|
|
90
|
+
break;
|
|
91
|
+
case "--status-filter":
|
|
92
|
+
case "--statusfilter":
|
|
93
|
+
optionalParams.statusFilter = args[++i];
|
|
94
|
+
break;
|
|
95
|
+
case "--expires-at-from":
|
|
96
|
+
case "--expiresatfrom":
|
|
97
|
+
optionalParams.expiresAtFrom = args[++i];
|
|
98
|
+
break;
|
|
99
|
+
case "--expires-at-to":
|
|
100
|
+
case "--expiresatto":
|
|
101
|
+
optionalParams.expiresAtTo = args[++i];
|
|
102
|
+
break;
|
|
103
|
+
case "--check-ids-filter":
|
|
104
|
+
case "--checkidsfilter":
|
|
105
|
+
optionalParams.checkIdsFilter = args[++i];
|
|
106
|
+
break;
|
|
107
|
+
case "--resource-ids-filter":
|
|
108
|
+
case "--resourceidsfilter":
|
|
109
|
+
optionalParams.resourceIdsFilter = args[++i];
|
|
110
|
+
break;
|
|
111
|
+
case "--creator-ids-filter":
|
|
112
|
+
case "--creatoridsfilter":
|
|
113
|
+
optionalParams.creatorIdsFilter = args[++i];
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
54
116
|
}
|
|
55
117
|
|
|
56
118
|
const client = await getOpsCompassClient();
|
|
57
|
-
const complianceExceptions = await client.compliance.getComplianceExceptions(company);
|
|
119
|
+
const complianceExceptions = await client.compliance.getComplianceExceptions(company, optionalParams);
|
|
58
120
|
|
|
59
121
|
console.log(JSON.stringify(complianceExceptions, null, 2));
|
|
60
122
|
}
|
|
@@ -185,6 +247,20 @@ const { getCredentials } = require("../credentials.js");
|
|
|
185
247
|
console.log("list-compliance-exceptions", "Gets list of policy exceptions and mitigations");
|
|
186
248
|
console.log("Parameters:");
|
|
187
249
|
console.log("--company [company_slug]");
|
|
250
|
+
console.log("--from-index (optional) [number] the record index to start at when fetching the next round of records (helps with fetching all records over multiple requests)");
|
|
251
|
+
console.log("--number-of-records (optional) [number] the number of records to fetch with one request");
|
|
252
|
+
console.log("--compliance-exception-sort: (optional) [resource | check | type | created-at | expires-at | reason] the column on which to sort records by");
|
|
253
|
+
console.log("--compliance-exception-sort-direction: (optional) [asc | desc] the direction to sort records by");
|
|
254
|
+
console.log("--search-text: (optional) [string] search columns by this text");
|
|
255
|
+
console.log('--type-filter: (optional) [mitigation and/or policy_exception] filter results by type. Ex: --type-filter "policy_exception, mitigation"');
|
|
256
|
+
console.log('--status-filter: (optional) [active and/or expired] filter results by status. Ex: --status-filter "expired, active"');
|
|
257
|
+
console.log("--expires-at-from: (optional) [string] the date at which to not show records before.");
|
|
258
|
+
console.log("Format: UTC, example: '2022-08-23T17:00:00Z' to filter by August 8th, 2022 at 17:00 UTC.");
|
|
259
|
+
console.log("--expires-at-to: (optional) [string] the date at which to not show records after.");
|
|
260
|
+
console.log("Format: UTC, example: '2022-08-23T17:00:00Z' to filter by August 8th, 2022 at 17:00 UTC.");
|
|
261
|
+
console.log('--check-ids-filter: (optional) [string] check ids to filter records by. Ex: --check-ids-filter "123, 456, 789"');
|
|
262
|
+
console.log('--resource-ids-filter: (optional) [string] resource ids to filter records by. Ex: --resource-ids-filter "123, 456, 789"');
|
|
263
|
+
console.log('--creator-ids-filter: (optional) [string] user ids to filter records by. Ex: --creator-ids-filter "123, 456, 789"');
|
|
188
264
|
console.log();
|
|
189
265
|
console.log("update-compliance-exception", "Updates single compliance exception record (i.e. mitigations and policy exceptions)");
|
|
190
266
|
console.log("Parameters:");
|
|
@@ -615,6 +615,21 @@ async function updateVCenterConfigurations(args) {
|
|
|
615
615
|
const msqlConfigurations = await client.licenseManager.updateMsqlConfigurations(callParamsArray);
|
|
616
616
|
console.log(JSON.stringify(msqlConfigurations, null, 2));
|
|
617
617
|
}
|
|
618
|
+
|
|
619
|
+
async function getMssqlEntitlementComponents(args) {
|
|
620
|
+
let company = undefined;
|
|
621
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
622
|
+
switch (args[i].toLowerCase()) {
|
|
623
|
+
case "--company":
|
|
624
|
+
company = args[++i];
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
const client = await getOpsCompassClient();
|
|
630
|
+
const entitlementComponents = await client.licenseManager.getMssqlEntitlementComponents(company);
|
|
631
|
+
console.log(JSON.stringify(entitlementComponents, null, 2));
|
|
632
|
+
}
|
|
618
633
|
|
|
619
634
|
async function printHelp() {
|
|
620
635
|
console.log("Actions available for license-manager:");
|
|
@@ -782,6 +797,10 @@ async function printHelp() {
|
|
|
782
797
|
console.log("For larger updates, JavaScript Object Notation (JSON) may be used with the --json-updates flag");
|
|
783
798
|
console.log(`e.g. opscompass license-manager update-msql-configurations --json-updates '[{\"id\":\"25\",\"configurationName\":\"25\", \"server\":\"100.232.2423\", \"user\":\"tony\", \"actions\":[\"skip\", \"dblicensing\"]}, {\"id\":\"31\",\"configurationName\":\"31\", \"server\":\"100.232.2423\", \"user\":\"tony\", \"actions\":[\"skip\", \"dblicensing\"]}]'`);
|
|
784
799
|
console.log();
|
|
800
|
+
console.log("get-mssql-entitlement-components", "Gets the components that can be used to build MSSql entitlement objects.");
|
|
801
|
+
console.log("Parameters:");
|
|
802
|
+
console.log("--company [company_slug]");
|
|
803
|
+
console.log();
|
|
785
804
|
}
|
|
786
805
|
|
|
787
806
|
const licenseManagerModule = (action, ...args) => {
|
|
@@ -833,7 +852,9 @@ const licenseManagerModule = (action, ...args) => {
|
|
|
833
852
|
case "update-msql-configuration":
|
|
834
853
|
return updateMsqlConfiguration(args);
|
|
835
854
|
case "update-msql-configurations":
|
|
836
|
-
return updateMsqlConfigurations(args)
|
|
855
|
+
return updateMsqlConfigurations(args);
|
|
856
|
+
case "get-mssql-entitlement-components":
|
|
857
|
+
return getMssqlEntitlementComponents(args);
|
|
837
858
|
case "help":
|
|
838
859
|
case "":
|
|
839
860
|
return printHelp();
|
package/modules/resources.js
CHANGED
|
@@ -135,6 +135,65 @@ async function list(args) {
|
|
|
135
135
|
console.log(JSON.stringify(resource, null, 2));
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
async function getUsageAnalytics(args) {
|
|
139
|
+
let resourceId = undefined;
|
|
140
|
+
let metricType = undefined;
|
|
141
|
+
let optionalParams = { analysisType: undefined, groupingPeriod: undefined, calculatedAtFrom: undefined, calculatedAtTo: undefined }
|
|
142
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
143
|
+
switch (args[i].toLowerCase()) {
|
|
144
|
+
case "--id":
|
|
145
|
+
resourceId = args[++i];
|
|
146
|
+
break;
|
|
147
|
+
case "--metric-type":
|
|
148
|
+
case "--metrictype":
|
|
149
|
+
metricType = args[++i];
|
|
150
|
+
break;
|
|
151
|
+
case "--analysis-type":
|
|
152
|
+
case "--analysistype":
|
|
153
|
+
optionalParams.analysisType = args[++i];
|
|
154
|
+
break;
|
|
155
|
+
case "--grouping-period":
|
|
156
|
+
case "--groupingperiod":
|
|
157
|
+
optionalParams.groupingPeriod = args[++i];
|
|
158
|
+
break;
|
|
159
|
+
case "--calculated-at-from":
|
|
160
|
+
case "--calculatedatfrom":
|
|
161
|
+
optionalParams.calculatedAtFrom = args[++i];
|
|
162
|
+
break;
|
|
163
|
+
case "--calculated-at-to":
|
|
164
|
+
case "--calculatedatto":
|
|
165
|
+
optionalParams.calculatedAtTo = args[++i];
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const client = await getOpsCompassClient();
|
|
171
|
+
const usageAnalytics = await client.resources.getUsageAnalytics(resourceId, metricType, optionalParams);
|
|
172
|
+
|
|
173
|
+
console.log(JSON.stringify(usageAnalytics, null, 2));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function getMetricNamesForResourceType(args) {
|
|
177
|
+
let company = undefined;
|
|
178
|
+
let resourceType = undefined;
|
|
179
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
180
|
+
switch (args[i].toLowerCase()) {
|
|
181
|
+
case "--company":
|
|
182
|
+
company = args[++i];
|
|
183
|
+
break;
|
|
184
|
+
case "--resource-type":
|
|
185
|
+
case "--resourcetype":
|
|
186
|
+
resourceType = args[++i];
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const client = await getOpsCompassClient();
|
|
192
|
+
const usageAnalytics = await client.resources.getMetricNamesForResourceType(company, resourceType);
|
|
193
|
+
|
|
194
|
+
console.log(JSON.stringify(usageAnalytics, null, 2));
|
|
195
|
+
}
|
|
196
|
+
|
|
138
197
|
async function printHelp() {
|
|
139
198
|
console.log("Actions available for resources:");
|
|
140
199
|
console.log();
|
|
@@ -172,6 +231,21 @@ async function printHelp() {
|
|
|
172
231
|
console.log("--open-compliance-issues [true | false]");
|
|
173
232
|
console.log("--unacknowledged-changes [true | false]");
|
|
174
233
|
console.log("--skip [12345]");
|
|
234
|
+
console.log();
|
|
235
|
+
console.log("get-usage-analytics", "Calculates the resource usage analytics for given criteria.");
|
|
236
|
+
console.log("Parameters:");
|
|
237
|
+
console.log("--id [resource_id]");
|
|
238
|
+
console.log("--metric-type [string]");
|
|
239
|
+
console.log("--analysis-type (optional) [string]");
|
|
240
|
+
console.log("--grouping-period (optional) [h | d | m | y]");
|
|
241
|
+
console.log("--calculated-at-from (optional) [2021-09-01T00:00:00.000Z]");
|
|
242
|
+
console.log("--calculated-at-to (optional) [2023-10-01T00:00:00.000Z]");
|
|
243
|
+
console.log();
|
|
244
|
+
console.log("get-metric-names-for-resource-type", "Fetches metric names for provided resource type.");
|
|
245
|
+
console.log("Parameters:");
|
|
246
|
+
console.log("--company [company slug]");
|
|
247
|
+
console.log("--resource-type [string]");
|
|
248
|
+
console.log();
|
|
175
249
|
}
|
|
176
250
|
|
|
177
251
|
const resourcesModule = (action, ...args) => {
|
|
@@ -182,6 +256,10 @@ const resourcesModule = (action, ...args) => {
|
|
|
182
256
|
return get(action, args);
|
|
183
257
|
case "list":
|
|
184
258
|
return list(args)
|
|
259
|
+
case "get-usage-analytics":
|
|
260
|
+
return getUsageAnalytics(args);
|
|
261
|
+
case "get-metric-names-for-resource-type":
|
|
262
|
+
return getMetricNamesForResourceType(args);
|
|
185
263
|
case "help":
|
|
186
264
|
case "":
|
|
187
265
|
return printHelp();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opscompass/opscompass-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
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.14",
|
|
19
19
|
"adm-zip": "^0.5.9",
|
|
20
20
|
"axios": "^0.21.1",
|
|
21
21
|
"fs-extra": "^10.1.0",
|