@opscompass/opscompass-cli 1.0.13 → 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.
@@ -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();
@@ -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.13",
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.13",
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",