@opscompass/opscompass-cli 1.0.11 → 1.0.13

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/credentials.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const fs = require("fs");
2
2
  const path = require("path");
3
3
  const { redeemRefreshToken } = require("./oauth");
4
- const { opscompassHome } = require("./environment/current.js");
4
+ const { opscompassHome, cliCommand } = require("./environment/current.js");
5
5
  const {
6
6
  writeFileToHome
7
7
  } = require("./lib/homeInteraction.js");
@@ -52,12 +52,14 @@ async function getCredentials() {
52
52
  await storeCredentials(refreshedTokenData);
53
53
  resolve(refreshedTokenData);
54
54
  }
55
-
56
55
  // return the data from the file
57
56
  resolve(tokensData);
58
57
  } catch (innerError) {
59
- reject(innerError);
60
- }
58
+ reject();
59
+ console.log();
60
+ console.warn(`You aren't logged in. Please run '${cliCommand} login' to log in.`)
61
+ console.log();
62
+ }
61
63
  }
62
64
  );
63
65
  } catch (e) {
@@ -4,7 +4,15 @@ const { getCredentials } = require("../credentials.js");
4
4
  async function transferOracleDatabaseMetadata(args) {
5
5
  const callParams = genericMetadataTrasfer(args);
6
6
  const client = await getOpsCompassClient();
7
- const response = await client.compliance.transferOracleDatabaseMetadata(callParams.company, callParams.filePath);
7
+ const response = await client.compliance.transferOracleDatabaseMetadata(callParams.company, callParams.type, callParams.filePath);
8
+
9
+ console.log(JSON.stringify(response, null, 2));
10
+ }
11
+
12
+ async function transferVMwareVsphereMetadata(args) {
13
+ const callParams = genericMetadataTrasfer(args);
14
+ const client = await getOpsCompassClient();
15
+ const response = await client.compliance.transferVMwareVsphereMetadata(callParams.company, callParams.filePath);
8
16
 
9
17
  console.log(JSON.stringify(response, null, 2));
10
18
  }
@@ -12,7 +20,7 @@ const { getCredentials } = require("../credentials.js");
12
20
  async function transferSqlServerDatabaseMetadata(args) {
13
21
  const callParams = genericMetadataTrasfer(args);
14
22
  const client = await getOpsCompassClient();
15
- const response = await client.compliance.transferSqlServerDatabaseMetadata(callParams.company, callParams.filePath);
23
+ const response = await client.compliance.transferSqlServerDatabaseMetadata(callParams.company, callParams.type, callParams.filePath);
16
24
 
17
25
  console.log(JSON.stringify(response, null, 2));
18
26
  }
@@ -21,6 +29,9 @@ const { getCredentials } = require("../credentials.js");
21
29
  const callParams = {};
22
30
  for (let i = 0; i < args.length - 1; i++) {
23
31
  switch (args[i].toLowerCase()) {
32
+ case "--type":
33
+ callParams.type = args[++i];
34
+ break;
24
35
  case "--filepath":
25
36
  callParams.filePath = args[++i];
26
37
  break;
@@ -34,16 +45,78 @@ const { getCredentials } = require("../credentials.js");
34
45
 
35
46
  async function listComplianceExceptions(args) {
36
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
+ };
37
62
  for (let i = 0; i < args.length - 1; i++) {
38
63
  switch (args[i].toLowerCase()) {
39
64
  case "--company":
40
65
  company = args[++i];
41
66
  break;
42
- }
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
+ }
43
116
  }
44
117
 
45
118
  const client = await getOpsCompassClient();
46
- const complianceExceptions = await client.compliance.getComplianceExceptions(company);
119
+ const complianceExceptions = await client.compliance.getComplianceExceptions(company, optionalParams);
47
120
 
48
121
  console.log(JSON.stringify(complianceExceptions, null, 2));
49
122
  }
@@ -118,22 +191,76 @@ const { getCredentials } = require("../credentials.js");
118
191
  console.log(JSON.stringify(vCenterConfigurations, null, 2));
119
192
  }
120
193
 
194
+ async function createComplianceResourceCheckException(args) {
195
+ let complianceResourceCheckId= undefined;
196
+ let complianceExceptionType= undefined;
197
+ let reason = undefined;
198
+ let expiresAt = undefined;
199
+
200
+ for (let i = 0; i < args.length - 1; i++) {
201
+ switch (args[i].toLowerCase()) {
202
+ case "--complianceresourcecheckid":
203
+ case "--compliance-resource-check-id":
204
+ complianceResourceCheckId = args[i+1];
205
+ break;
206
+ case "--complianceexceptiontype":
207
+ case "--compliance-exception-type":
208
+ complianceExceptionType = args[i+1];
209
+ break;
210
+ case "--reason":
211
+ reason = args[i+1];
212
+ break;
213
+ case "--expiresat":
214
+ case "--expires-at":
215
+ expiresAt = args[i+1];
216
+ break;
217
+ }
218
+ }
219
+
220
+ const client = await getOpsCompassClient();
221
+ const complianceExceptions = await client.compliance.createComplianceResourceCheckException(complianceResourceCheckId, complianceExceptionType, reason, expiresAt);
222
+ console.log(JSON.stringify(complianceExceptions, null, 2));
223
+ console.log();
224
+ }
225
+
226
+
121
227
  async function printHelp() {
122
228
  console.log("Actions available for compliance:");
123
229
  console.log();
124
230
  console.log("transfer-oracle-database-metadata", "Transfers OpsCompass Oracle Database metadata report into OpsCompass for processing");
125
231
  console.log("Parameters:");
126
232
  console.log("--company [company_slug]");
233
+ console.log("--type [licensing | compliance]")
234
+ console.log("--filePath [path] Path of the file to transfer to OpsCompass for processing.");
235
+ console.log();
236
+ console.log("transfer-vmware-vsphere-metadata", "Transfers OpsCompass VMware VSphere metadata report into OpsCompass for processing");
237
+ console.log("Parameters:");
238
+ console.log("--company [company_slug]");
127
239
  console.log("--filePath [path] Path of the file to transfer to OpsCompass for processing.");
128
240
  console.log();
129
241
  console.log("transfer-sql-server-database-metadata", "Transfers OpsCompass SQL Server Database metadata report into OpsCompass for processing");
130
242
  console.log("Parameters:");
131
243
  console.log("--company [company_slug]");
244
+ console.log("--type [licensing | compliance]")
132
245
  console.log("--filePath [path] Path of the file to transfer to OpsCompass for processing.");
133
246
  console.log();
134
247
  console.log("list-compliance-exceptions", "Gets list of policy exceptions and mitigations");
135
248
  console.log("Parameters:");
136
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"');
137
264
  console.log();
138
265
  console.log("update-compliance-exception", "Updates single compliance exception record (i.e. mitigations and policy exceptions)");
139
266
  console.log("Parameters:");
@@ -154,11 +281,21 @@ const { getCredentials } = require("../credentials.js");
154
281
  console.log("For larger updates, JavaScript Object Notation (JSON) may be used with the --json-updates flag");
155
282
  console.log(`e.g. opscompass compliance update-compliance-exceptions --json-updates '[{\"id\":\"18\",\"reason\":\"Valid exception reason\"},{\"id\":\"3\",\"expiresAt\":\"2022-08-23T17:00:00Z\"}]'`);
156
283
  console.log();
284
+ console.log("create-compliance-resource-check-exceptions", "Creates a new compliance resource check exception");
285
+ console.log("Parameters:");
286
+ console.log("--compliance-resource-check-id [the compliance resource check id]");
287
+ console.log("--compliance-exception-type [string] the type of compliance exception: 'mitigation' or 'policy_exception'");
288
+ console.log("--reason [string] the reason for the compliance resource check exception");
289
+ console.log("--expires-at (optional) [string] the date at which to expire. If you want to remove a compliance exception from the list, set the expiresAt to todays date.");
290
+ console.log("Format: UTC, example: '2022-08-23T17:00:00Z' to expire August 8th, 2022 at 17:00 UTC.");
291
+ console.log();
157
292
  }
158
293
 
159
294
 
160
295
  const complianceModule = (action, ...args) => {
161
296
  switch (action?.toLowerCase() ?? "") {
297
+ case "transfer-vmware-vsphere-metadata":
298
+ return transferVMwareVsphereMetadata(args);
162
299
  case "transfer-oracle-database-metadata":
163
300
  return transferOracleDatabaseMetadata(args);
164
301
  case "transfer-sql-server-database-metadata":
@@ -169,6 +306,8 @@ const { getCredentials } = require("../credentials.js");
169
306
  return updateComplianceException(args);
170
307
  case "update-compliance-exceptions":
171
308
  return updateComplianceExceptions(args);
309
+ case "create-compliance-resource-check-exception":
310
+ return createComplianceResourceCheckException(args);
172
311
  case "help":
173
312
  case "":
174
313
  return printHelp();
@@ -171,24 +171,25 @@ async function printHelp() {
171
171
  console.log("download-scripts", "Downloads scripts for the passed script type.");
172
172
  console.log("Parameters:");
173
173
  console.log("--company [company_slug]");
174
- console.log("--script-type ['oracle-compliance', 'oracle-features', 'vsphere', 'msql-license']");
174
+ console.log("--script-type ['discovery-tools', 'oracle-compliance', 'oracle-features', 'vsphere', 'msql-license', 'msql-compliance']");
175
175
  console.log("--script-version (optional) [version] if not provided, the latest script will be downloaded");
176
176
  console.log();
177
177
  console.log("check-script-updates", "Checks locally installed script version against the latest published version for the passed script type.");
178
178
  console.log("Parameters:");
179
179
  console.log("--company [company_slug]");
180
- console.log("--script-type ['oracle-compliance', 'oracle-features', 'vsphere', 'msql-license']");
180
+ console.log("--script-type ['oracle-compliance', 'oracle-features', 'vsphere', 'msql-license', 'msql-compliance']");
181
181
  console.log();
182
182
  console.log("manually-run-scripts", "Do not run this unless you know what you are doing. This manually runs all the scripts.");
183
183
  console.log();
184
184
  }
185
185
 
186
186
  const dataGatheringScriptsModule = (action, ...args) => {
187
- // If it is a module with no arguments or if user is manually checking the version, do not run the auto version check
188
- if (action !== 'check-script-updates' && args.length > 0 ) {
187
+ // If it is a module with no arguments or if user is manually checking the version, do not run the auto version check. If user is already trying to download the latest versionm they do not need to be told to do so.
188
+ if (args.length > 0 && action !== 'check-script-updates' && action !== 'download-scripts' && !args.includes("--script-version")) {
189
189
  autoCheckScriptUpdates(args)
190
190
  }
191
191
 
192
+
192
193
  switch (action?.toLowerCase() ?? "") {
193
194
  case "download-scripts":
194
195
  return downloadScripts(args);
@@ -34,6 +34,22 @@ async function deleteVCenterConfiguration(args){
34
34
  console.log(JSON.stringify(response, null, 2));
35
35
  }
36
36
 
37
+ async function deleteMsqlConfiguration(args){
38
+ let id = undefined;
39
+ for (let i = 0; i < args.length - 1; i++) {
40
+ switch (args[i].toLowerCase()) {
41
+ case "--id":
42
+ id = args[++i];
43
+ break;
44
+ }
45
+ }
46
+
47
+ const client = await getOpsCompassClient();
48
+ const response = await client.licenseManager.deleteMsqlConfiguration(id);
49
+
50
+ console.log(JSON.stringify(response, null, 2));
51
+ }
52
+
37
53
  async function deleteMonitoringConfiguration(args){
38
54
  let id = undefined;
39
55
  for (let i = 0; i < args.length - 1; i++) {
@@ -224,6 +240,76 @@ async function createVCenterConfiguration(args) {
224
240
  console.log(JSON.stringify(monitoringConfig, null, 2));
225
241
  }
226
242
 
243
+ async function listMsqlConfigurations(args) {
244
+ let id = undefined;
245
+ for (let i = 0; i < args.length - 1; i++) {
246
+ switch (args[i].toLowerCase()) {
247
+ case "--monitoringconfigurationid":
248
+ case "--monitoring-configuration-id":
249
+ id = args[++i];
250
+ break;
251
+ }
252
+ }
253
+
254
+ const client = await getOpsCompassClient();
255
+ const listMsqlConfigs = await client.licenseManager.listMsqlConfigurations(id);
256
+
257
+ console.log(JSON.stringify(listMsqlConfigs, null, 2));
258
+ }
259
+
260
+ async function createMsqlConfiguration(args) {
261
+ let id = undefined;
262
+ let configurationName = undefined;
263
+ let optionalParams = { actions: undefined, server: undefined, user: undefined, password: undefined };
264
+ for (let i = 0; i < args.length - 1; i++) {
265
+ switch (args[i].toLowerCase()) {
266
+ case "--monitoringconfigurationid":
267
+ case "--monitoring-configuration-id":
268
+ id = args[++i];
269
+ break;
270
+ case "--configuration-name":
271
+ case "--configurationname":
272
+ configurationName = args[++i];
273
+ break;
274
+ case "--action":
275
+ if (optionalParams.actions === undefined) optionalParams.actions = [];
276
+ optionalParams.actions.push(args[++i]);
277
+ break;
278
+ case "--server":
279
+ optionalParams.server = args[++i];;
280
+ break;
281
+ case "--user":
282
+ optionalParams.user = args[++i];
283
+ break;
284
+ case "--password":
285
+ optionalParams.password = args[++i];
286
+ break;
287
+ }
288
+ }
289
+
290
+ const client = await getOpsCompassClient();
291
+
292
+ const msqlConfiguration = await client.licenseManager.createMsqlConfiguration(id, configurationName, optionalParams);
293
+
294
+ console.log(JSON.stringify(msqlConfiguration, null, 2));
295
+ }
296
+
297
+ async function getMsqlConfiguration(args) {
298
+ let id = undefined;
299
+ for (let i = 0; i < args.length - 1; i++) {
300
+ switch (args[i].toLowerCase()) {
301
+ case "--id":
302
+ id = args[++i];
303
+ break;
304
+ }
305
+ }
306
+
307
+ const client = await getOpsCompassClient();
308
+ const getMsqlConfig = await client.licenseManager.getMsqlConfiguration(id);
309
+
310
+ console.log(JSON.stringify(getMsqlConfig, null, 2));
311
+ }
312
+
227
313
  async function createOracleDatabaseConfiguration(args) {
228
314
  let id = undefined;
229
315
  let name = undefined;
@@ -262,7 +348,9 @@ async function updateMonitoringConfiguration(args) {
262
348
  case "--id":
263
349
  callParams.id = args[++i];
264
350
  break;
351
+ case "--name":
265
352
  case "--configurationname":
353
+ case "--configuration-name":
266
354
  callParams.configurationName = args[++i];
267
355
  break;
268
356
  case "--datafileretaindays":
@@ -306,6 +394,8 @@ async function updateOracleDatabaseConfiguration(args) {
306
394
  callParams.id = args[++i];
307
395
  break;
308
396
  case "--name":
397
+ case "--configurationname":
398
+ case "--configuration-name":
309
399
  callParams.name = args[++i];
310
400
  break;
311
401
  case "--action":
@@ -345,7 +435,7 @@ async function updateOracleDatabaseConfigurations(args) {
345
435
  callParamsArray.push(callParams)
346
436
  /* Create the object's properties based on the index (e.g. if the index is --id, you'll find the value at the next index */
347
437
  callParams.id = args[i + 1];
348
- } else if(args[i] === '--configurationName') {
438
+ } else if(args[i].toLowerCase() === '--configurationname' || args[i].toLowerCase() === '--configuration-name' || args[i].toLowerCase() === "--name" ){
349
439
  callParams.configurationName = args[i + 1];
350
440
  } else if(args[i] === '--connectionstring') {
351
441
  callParams.connectionString = args[i + 1];
@@ -356,6 +446,7 @@ async function updateOracleDatabaseConfigurations(args) {
356
446
  }
357
447
  } else {
358
448
  console.warn("Invalid input, please see help for examples.")
449
+ return console.log("")
359
450
  }
360
451
  /* Call the API and print to console */
361
452
  const client = await getOpsCompassClient();
@@ -373,6 +464,8 @@ async function updateVCenterConfiguration(args) {
373
464
  callParams.id = args[++i];
374
465
  break;
375
466
  case "--name":
467
+ case "--configurationname":
468
+ case "--configuration-name":
376
469
  callParams.name = args[++i];
377
470
  break;
378
471
  case "--action":
@@ -418,21 +511,22 @@ async function updateVCenterConfigurations(args) {
418
511
  callParamsArray.push(callParams)
419
512
  /* Create the object's properties based on the index (e.g. if the index is --id, you'll find the value at the next index */
420
513
  callParams.id = args[i + 1];
421
- } else if(args[i] === '--configurationName') {
514
+ } else if(args[i].toLowerCase() === '--configurationname' || args[i].toLowerCase() === '--configuration-name' || args[i].toLowerCase() === "--name" ) {
422
515
  callParams.configurationName = args[i + 1];
423
- } else if(args[i] === '--action') {
516
+ } else if(args[i].toLowerCase() === '--action') {
424
517
  if (callParams.actions === undefined) callParams.actions = [];
425
- callParams.actions = args[i + 1];
426
- } else if(args[i] === '--connection') {
518
+ callParams.actions.push(args[i + 1]);
519
+ } else if(args[i.toLowerCase] === '--connection') {
427
520
  callParams.connection = args[i + 1];
428
- } else if(args[i] === '--user') {
521
+ } else if(args[i.toLowerCase] === '--user') {
429
522
  callParams.user = args[i + 1];
430
- } else if(args[i] === '--password') {
523
+ } else if(args[i.toLowerCase] === '--password') {
431
524
  callParams.password = args[i + 1];
432
525
  }
433
526
  }
434
527
  } else {
435
528
  console.warn("Invalid input, please see help for examples.")
529
+ return console.log("")
436
530
  }
437
531
 
438
532
  /* Call the API and print to console */
@@ -441,13 +535,94 @@ async function updateVCenterConfigurations(args) {
441
535
  console.log(JSON.stringify(vCenterConfigurations, null, 2));
442
536
  }
443
537
 
538
+ async function updateMsqlConfiguration(args) {
539
+ const callParams = {
540
+ };
541
+ for (let i = 0; i < args.length - 1; i++) {
542
+ switch (args[i].toLowerCase()) {
543
+ case "--id":
544
+ callParams.id = args[++i];
545
+ break;
546
+ case "--name":
547
+ case "--configurationname":
548
+ case "--configuration-name":
549
+ callParams.configurationName = args[++i];
550
+ break;
551
+ case "--action":
552
+ if (callParams.actions === undefined) callParams.actions = [];
553
+ callParams.actions.push(args[++i]);
554
+ break;
555
+ case "--server":
556
+ callParams.server = args[++i];
557
+ break;
558
+ case "--user":
559
+ callParams.user = args[++i];
560
+ break;
561
+ case "--password":
562
+ callParams.password = args[++i];
563
+ break;
564
+ }
565
+ }
566
+ const client = await getOpsCompassClient();
567
+ const msqlConfiguration = await client.licenseManager.updateMsqlConfiguration(callParams.id, callParams);
568
+ console.log(JSON.stringify(msqlConfiguration, null, 2));
569
+ }
570
+
571
+
572
+ async function updateMsqlConfigurations(args) {
573
+
574
+ let callParamsArray = [];
575
+ let jsonIndex = args.indexOf('--json-updates')
576
+ let idIndex = args.indexOf('--id')
577
+ let callParams = {};
578
+
579
+ /* Process bulk update with JSON */
580
+ if (jsonIndex !== -1) {
581
+ const jsonString = args[jsonIndex + 1];
582
+ callParamsArray = JSON.parse(jsonString);
583
+
584
+ /* If no '--json-updates' flag, process bulk update with parameter flags (e.g. --id, --name, etc.) */
585
+ } else if (idIndex !== -1) {
586
+ for(let i = 0; i < args.length - 1; i++) {
587
+ if(args[i] === '--id') {
588
+ /* Reset callParams object when a second id is encountered */
589
+ callParams = {
590
+ };
591
+ /* if theres an existing callParams object, toss it into the array and move on. */
592
+ callParamsArray.push(callParams)
593
+ /* Create the object's properties based on the index (e.g. if the index is --id, you'll find the value at the next index */
594
+ callParams.id = args[i + 1];
595
+ } else if(args[i].toLowerCase() === '--configurationname' || args[i].toLowerCase() === '--configuration-name' || args[i].toLowerCase() === "--name" ) {
596
+ callParams.configurationName = args[i + 1];
597
+ } else if(args[i].toLowerCase() === '--action') {
598
+ if (callParams.actions === undefined) callParams.actions = [];
599
+ callParams.actions.push(args[i + 1]);
600
+ } else if(args[i].toLowerCase() === '--server') {
601
+ callParams.server = args[i + 1];
602
+ } else if(args[i].toLowerCase() === '--user') {
603
+ callParams.user = args[i + 1];
604
+ } else if(args[i].toLowerCase() === '--password') {
605
+ callParams.password = args[i + 1];
606
+ }
607
+ }
608
+ } else {
609
+ console.warn("Invalid input, please see help for examples.")
610
+ return console.log("")
611
+ }
612
+
613
+ /* Call the API and print to console */
614
+ const client = await getOpsCompassClient();
615
+ const msqlConfigurations = await client.licenseManager.updateMsqlConfigurations(callParamsArray);
616
+ console.log(JSON.stringify(msqlConfigurations, null, 2));
617
+ }
618
+
444
619
  async function printHelp() {
445
620
  console.log("Actions available for license-manager:");
446
621
  console.log();
447
622
  console.log("get-secret-for-configuration", "Gets a secret for a single configuration passed.");
448
623
  console.log("Parameters:");
449
- console.log("--id [vcenter_configuration_id | oracle_database_configuration_id]");
450
- console.log("--recordType ['oracle_database_configuration' | 'vcenter_configuration'");
624
+ console.log("--id [vcenter_configuration_id | oracle_database_configuration_id | msql_configuration_id]");
625
+ console.log("--recordType ['oracle_database_configuration' | 'vcenter_configuration' | 'msql_configuration'");
451
626
  console.log();
452
627
  console.log("list-monitoring-configurations", "Lists all of the monitoring configurations associated with the give company.");
453
628
  console.log("Parameters:");
@@ -483,22 +658,39 @@ async function printHelp() {
483
658
  console.log("Parameters:");
484
659
  console.log("--monitoringConfigurationId [monitoring_configuration_id]");
485
660
  console.log("--name [unique name]");
486
- console.log("--action (optional) pass multiple times to define which actions this connection can take ['skip', 'inventory', 'vmotion']");
661
+ console.log(`--action (optional) pass multiple times to define which actions this connection can take e.g. --action "skip" --action "vmotion"`);
487
662
  console.log("--connection (optional) [the hostname or ip address]");
488
663
  console.log("--user (optional) [connection username]");
489
664
  console.log("--password (optional) [connection password]");
490
665
  console.log();
666
+ console.log("list-msql-configurations", "Lists all of the msql configurations associated with the given monitoring configuration");
667
+ console.log("Parameters:");
668
+ console.log("--monitoring-configuration-id [monitoring_configuration_id]");
669
+ console.log();
670
+ console.log("create-msql-configuration", "Create a single msql configuration associated with the given monitoring configuration.");
671
+ console.log("Parameters:");
672
+ console.log("--monitoring-configuration-id [monitoring_configuration_id]");
673
+ console.log("--configurationName [unique name]");
674
+ console.log(`--action (optional) pass multiple times to define which actions this connection can take e.g. --action "skip" --action "compliance"`);
675
+ console.log("--server (optional) [the hostname or ip address]");
676
+ console.log("--user (optional) [connection username]");
677
+ console.log("--password (optional) [connection password]");
678
+ console.log();
679
+ console.log("get-msql-configuration", "Get a single msql configuration associated with the given monitoring configuration");
680
+ console.log("Parameters:");
681
+ console.log("--id [msql_configuration_id]");
682
+ console.log();
491
683
  console.log("create-oracle-database-configuration", "Create a single oracle database configuration associated with the given monitoring configuration.");
492
684
  console.log("Parameters:");
493
685
  console.log("--monitoringConfigurationId [monitoring_configuration_id]");
494
686
  console.log("--name [unique name]");
495
- console.log("--action (optional) pass multiple times to define which actions this connection can take ['skip', 'compliance', 'dblicensing']");
687
+ console.log(`--action (optional) pass multiple times to define which actions this connection can take e.g. --action "skip" --action "dbcompliance"`);
496
688
  console.log("--connectionString (optional) [the database connection string]");
497
689
  console.log();
498
690
  console.log("update-monitoring-configuration", "Update a single monitoring configuration.");
499
691
  console.log("Parameters:");
500
692
  console.log("--id [monitoring_configuration id]");
501
- console.log("--configurationName (optional) [unique name]");
693
+ console.log("--name or --configuration-name (optional) [unique name]");
502
694
  console.log("--dataFileRetainDays (optional) [determines how many days to retain encrypted output files locally]");
503
695
  console.log("--dataFileRetainTextDays (optional) [determines how many days to retain individual script output files locally]");
504
696
  console.log("--forceFileEncryption (optional) [enforce encryption of datafiles before being sent]");
@@ -511,27 +703,27 @@ async function printHelp() {
511
703
  console.log("update-oracle-database-configuration", "Update a single oracle database configuration.");
512
704
  console.log("Parameters:");
513
705
  console.log("--id [configuration id]");
514
- console.log("--name (optional) [unique name]");
515
- console.log("--action (optional) pass multiple times to define which actions this connection can take ['skip', 'compliance', 'dblicensing']");
706
+ console.log("--name or --configuration-name (optional) [unique name]");
707
+ console.log(`--action (optional) pass multiple times to define which actions this connection can take --action "skip" --action "dbcompliance"`);
516
708
  console.log("--connectionString (optional) [the database connection string]");
517
709
  console.log();
518
710
  console.log("update-oracle-database-configurations", "Bulk update oracle database configurations.");
519
711
  console.log("Parameters:");
520
712
  console.log("--id [configuration id]");
521
- console.log("--name (optional) [unique name]");
522
- console.log("--action (optional) pass multiple times to define which actions this connection can take ['skip', 'compliance', 'dblicensing']");
713
+ console.log("--name or --configuration-name (optional) [unique name]");
714
+ console.log(`--action (optional) pass multiple times to define which actions this connection can take e.g. --action "skip" --action "dbcompliance"`);
523
715
  console.log("--connectionString (optional) [the database connection string]");
524
716
  console.log("OR --json-updates [stringified json objects with your updates]");
525
717
  console.log("For quick updates, you may use the above parameters");
526
- console.log(`e.g. opscompass license-manager update-oracle-database-configurations --id 57 --configurationName "updatedName" --id 62 --configurationName "otherUpdatedName" --id 77 --configurationName "lastUpdatedName";`);
718
+ console.log(`e.g. opscompass license-manager update-oracle-database-configurations --id 57 --name "updatedName" --id 62 --name "otherUpdatedName" --id 77 --name "lastUpdatedName";`);
527
719
  console.log("For larger updates, JavaScript Object Notation (JSON) may be used with the --json-updates flag");
528
720
  console.log(`e.g. opscompass license-manager update-oracle-database-configurations --json-updates '[{\"id\":\"57\",\"configurationName\":\"updatedName\"},{\"id\":\"77\", \"configurationName\":\"otherUpdatedName\", \"action\":\"null\"},{\"id\":\"79\", \"configurationName\":\"lastUpdatedName\"}]'`);
529
721
  console.log();
530
722
  console.log("update-vcenter-configuration", "Update a single vcenter configuration.");
531
723
  console.log("Parameters:");
532
724
  console.log("--id [configuration id]");
533
- console.log("--name (optional) [unique name]");
534
- console.log("--action (optional) pass multiple times to define which actions this connection can take ['skip', 'inventory', 'vmotion']");
725
+ console.log("--name or --configuration-name (optional) [unique name]");
726
+ console.log("--action (optional) pass multiple times to define which actions this connection can take e.g. --action 'skip' --action 'vmotion']");
535
727
  console.log("--connection (optional) [the hostname or ip address]");
536
728
  console.log("--user (optional) [connection username]");
537
729
  console.log("--password (optional) [connection password]");
@@ -539,16 +731,16 @@ async function printHelp() {
539
731
  console.log("update-vcenter-configurations", "Bulk Update vcenter configurations.");
540
732
  console.log("Parameters:");
541
733
  console.log("--id [configuration id]");
542
- console.log("--name (optional) [unique name]");
543
- console.log("--action (optional) pass multiple times to define which actions this connection can take ['skip', 'inventory', 'vmotion']");
734
+ console.log("--name or --configuration-name (optional) [unique name]");
735
+ console.log(`--action (optional) pass multiple times to define which actions this connection can take e.g. --action "skip" --action "vmotion"`);
544
736
  console.log("--connection (optional) [the hostname or ip address]");
545
737
  console.log("--user (optional) [connection username]");
546
738
  console.log("--password (optional) [connection password]");
547
739
  console.log("OR --json-updates [stringified json objects with your updates]");
548
740
  console.log("For quick updates, you may use the above parameters");
549
- console.log(`e.g. opscompass license-manager update-vcenter-configurations --id 137 --configurationName "updatedName" --id 138 --configurationName "otherUpdatedName" --id 144 --configurationName "lastUpdatedName";`);
741
+ console.log(`e.g. opscompass license-manager update-vcenter-configurations --id 137 --name "updatedName" --id 138 --name "otherUpdatedName" --id 144 --name "lastUpdatedName" --action "skip" --action "vmotion";`);
550
742
  console.log("For larger updates, JavaScript Object Notation (JSON) may be used with the --json-updates flag");
551
- console.log(`e.g. opscompass license-manager update-vcenter-configurations --json-updates '[{\"id\":\"137\",\"configurationName\":\"updatedName\"},{\"id\":\"138\",\"configurationName\":\"otherUpdatedName\"},{\"id\":\"144\",\"configurationName\":\"lastUpdatedName\"}]'`);
743
+ console.log(`e.g. opscompass license-manager update-vcenter-configurations --json-updates '[{\"id\":\"137\",\"configurationName\":\"updatedName\"},{\"id\":\"138\",\"configurationName\":\"otherUpdatedName\"},{\"id\":\"144\",\"configurationName\":\"lastUpdatedName\", \"actions\":[\"skip\", \"vmotion\"]}]'`);
552
744
  console.log();
553
745
  console.log("delete-monitoring-configuration", "Delete a monitoring configuration");
554
746
  console.log("Parameters:");
@@ -562,6 +754,34 @@ async function printHelp() {
562
754
  console.log("Parameters:");
563
755
  console.log("--id [vcenter_configuration_id]");
564
756
  console.log();
757
+ console.log("delete-msql-configuration", "Delete a msql configuration");
758
+ console.log("Parameters:");
759
+ console.log("--id [msql_configuration_id]");
760
+ console.log();
761
+ console.log("update-msql-configuration", "Update a single msql configuration.");
762
+ console.log("Parameters:");
763
+ console.log("--id [configuration id]");
764
+ console.log("--name or --configuration-name (optional) [unique name]");
765
+ console.log("--action (optional) pass multiple times to define which actions this connection can take e.g. --action 'skip' --action 'dblicensing'");
766
+ console.log("--server (optional) [the server]");
767
+ console.log("--user (optional) [connection username]");
768
+ console.log("--password (optional) [connection password]");
769
+ console.log();
770
+ console.log();
771
+ console.log("update-msql-configurations", "Bulk Update Msql Configurations.");
772
+ console.log("Parameters:");
773
+ console.log("--id [configuration id]");
774
+ console.log("--name or --configuration-name (optional) [unique name]");
775
+ console.log("--action (optional) pass multiple times to define which actions this connection can take e.g. --action 'skip' --action 'dblicensing'");
776
+ console.log("--connection (optional) [the hostname or ip address]");
777
+ console.log("--user (optional) [connection username]");
778
+ console.log("--password (optional) [connection password]");
779
+ console.log("OR --json-updates [stringified json objects with your updates]");
780
+ console.log("For quick updates, you may use the above parameters");
781
+ console.log(`e.g. opscompass license-manager update-msql-configurations --id 31 --name "newname" --server "233.533.343" --user "joe" --action "skip" --id 25 --name "secondname" --actions"skip" --action "dblicensing"`);
782
+ console.log("For larger updates, JavaScript Object Notation (JSON) may be used with the --json-updates flag");
783
+ 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
+ console.log();
565
785
  }
566
786
 
567
787
  const licenseManagerModule = (action, ...args) => {
@@ -580,6 +800,12 @@ const licenseManagerModule = (action, ...args) => {
580
800
  return getVCenterConfiguration(args);
581
801
  case "create-vcenter-configuration":
582
802
  return createVCenterConfiguration(args);
803
+ case "list-msql-configurations":
804
+ return listMsqlConfigurations(args);
805
+ case "create-msql-configuration":
806
+ return createMsqlConfiguration(args);
807
+ case "get-msql-configuration":
808
+ return getMsqlConfiguration(args);
583
809
  case "get-oracle-database-configuration":
584
810
  return getOracleDatabaseConfiguration(args);
585
811
  case "list-oracle-database-configurations":
@@ -594,14 +820,20 @@ const licenseManagerModule = (action, ...args) => {
594
820
  return updateOracleDatabaseConfigurations(args);
595
821
  case "update-vcenter-configuration":
596
822
  return updateVCenterConfiguration(args);
597
- case "update-vcenter-configurations":
598
- return updateVCenterConfigurations(args);
823
+ case "update-vcenter-configurations":
824
+ return updateVCenterConfigurations(args);
599
825
  case "delete-monitoring-configuration":
600
826
  return deleteMonitoringConfiguration(args);
601
827
  case "delete-oracle-database-configuration":
602
828
  return deleteOracleDatabaseConfiguration(args);
603
829
  case "delete-vcenter-configuration":
604
830
  return deleteVCenterConfiguration(args);
831
+ case "delete-msql-configuration":
832
+ return deleteMsqlConfiguration(args);
833
+ case "update-msql-configuration":
834
+ return updateMsqlConfiguration(args);
835
+ case "update-msql-configurations":
836
+ return updateMsqlConfigurations(args)
605
837
  case "help":
606
838
  case "":
607
839
  return printHelp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opscompass/opscompass-cli",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
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.11",
18
+ "@opscompass/opscompass-api": "^1.0.13",
19
19
  "adm-zip": "^0.5.9",
20
20
  "axios": "^0.21.1",
21
21
  "fs-extra": "^10.1.0",
package/updates.js CHANGED
@@ -15,9 +15,7 @@ function versionCheck() {
15
15
  console.log(`error: ${error.message}`);
16
16
  return;
17
17
  }
18
- if (stderr) {
19
- console.log(`stderr: ${stderr}`);
20
- };
18
+
21
19
  /* Semver used to semantically compare version numbers */
22
20
  if (semver.gt(latestVersion, pkg.version)) {
23
21
  console.error(yellowText, `Warning! You are using CLI version ${pkg.version}, but the latest version is ${latestVersion}To upgrade to the latest version, please run:`);