@red-hat-developer-hub/plugin-cost-management-common 2.0.1

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +17 -0
  3. package/dist/DefaultApiClient.cjs.js +8 -0
  4. package/dist/DefaultApiClient.cjs.js.map +1 -0
  5. package/dist/DefaultApiClient.d.ts +83 -0
  6. package/dist/DefaultApiClient.esm.js +2 -0
  7. package/dist/DefaultApiClient.esm.js.map +1 -0
  8. package/dist/clients/cost-management/CostManagementSlimClient.cjs.js +378 -0
  9. package/dist/clients/cost-management/CostManagementSlimClient.cjs.js.map +1 -0
  10. package/dist/clients/cost-management/CostManagementSlimClient.esm.js +372 -0
  11. package/dist/clients/cost-management/CostManagementSlimClient.esm.js.map +1 -0
  12. package/dist/clients/optimizations/OptimizationsClient.cjs.js +99 -0
  13. package/dist/clients/optimizations/OptimizationsClient.cjs.js.map +1 -0
  14. package/dist/clients/optimizations/OptimizationsClient.esm.js +92 -0
  15. package/dist/clients/optimizations/OptimizationsClient.esm.js.map +1 -0
  16. package/dist/clients/orchestrator-slim/OrchestratorSlimClient.cjs.js +107 -0
  17. package/dist/clients/orchestrator-slim/OrchestratorSlimClient.cjs.js.map +1 -0
  18. package/dist/clients/orchestrator-slim/OrchestratorSlimClient.esm.js +105 -0
  19. package/dist/clients/orchestrator-slim/OrchestratorSlimClient.esm.js.map +1 -0
  20. package/dist/clients.cjs.js +12 -0
  21. package/dist/clients.cjs.js.map +1 -0
  22. package/dist/clients.d.ts +432 -0
  23. package/dist/clients.esm.js +4 -0
  24. package/dist/clients.esm.js.map +1 -0
  25. package/dist/generated/apis/DefaultApi.client.cjs.js +91 -0
  26. package/dist/generated/apis/DefaultApi.client.cjs.js.map +1 -0
  27. package/dist/generated/apis/DefaultApi.client.esm.js +66 -0
  28. package/dist/generated/apis/DefaultApi.client.esm.js.map +1 -0
  29. package/dist/generated/pluginId.cjs.js +6 -0
  30. package/dist/generated/pluginId.cjs.js.map +1 -0
  31. package/dist/generated/pluginId.esm.js +4 -0
  32. package/dist/generated/pluginId.esm.js.map +1 -0
  33. package/dist/index.cjs.js +14 -0
  34. package/dist/index.cjs.js.map +1 -0
  35. package/dist/index.d.ts +6 -0
  36. package/dist/index.esm.js +5 -0
  37. package/dist/index.esm.js.map +1 -0
  38. package/dist/json-utils.cjs.js +22 -0
  39. package/dist/json-utils.cjs.js.map +1 -0
  40. package/dist/json-utils.d.ts +46 -0
  41. package/dist/json-utils.esm.js +20 -0
  42. package/dist/json-utils.esm.js.map +1 -0
  43. package/dist/models.cjs.js +3 -0
  44. package/dist/models.cjs.js.map +1 -0
  45. package/dist/models.d.ts +25 -0
  46. package/dist/models.esm.js +2 -0
  47. package/dist/models.esm.js.map +1 -0
  48. package/dist/permissions.cjs.js +47 -0
  49. package/dist/permissions.cjs.js.map +1 -0
  50. package/dist/permissions.d.ts +24 -0
  51. package/dist/permissions.esm.js +36 -0
  52. package/dist/permissions.esm.js.map +1 -0
  53. package/dist/types/RecommendationList.model.d-J74WXrJI.d.ts +414 -0
  54. package/dist/util/lib/json.cjs.js +20 -0
  55. package/dist/util/lib/json.cjs.js.map +1 -0
  56. package/dist/util/lib/json.esm.js +15 -0
  57. package/dist/util/lib/json.esm.js.map +1 -0
  58. package/dist/util/lib/json_node.cjs.js +191 -0
  59. package/dist/util/lib/json_node.cjs.js.map +1 -0
  60. package/dist/util/lib/json_node.esm.js +189 -0
  61. package/dist/util/lib/json_node.esm.js.map +1 -0
  62. package/package.json +124 -0
@@ -0,0 +1,432 @@
1
+ import { DiscoveryApi, FetchApi, IdentityApi } from '@backstage/core-plugin-api';
2
+ import { DefaultApiClient, TypedResponse, RequestOptions } from './DefaultApiClient.js';
3
+ import { R as RecommendationBoxPlots, U as RecommendationList } from './types/RecommendationList.model.d-J74WXrJI.js';
4
+ import { JsonObject } from '@backstage/types';
5
+
6
+ /** @public */
7
+ type OptimizationsApi = Omit<InstanceType<typeof DefaultApiClient>, 'fetchApi' | 'discoveryApi'>;
8
+ /**
9
+ * This is a copy of GetTokenResponse, to avoid importing cost-management-backend.
10
+ *
11
+ * @public
12
+ */
13
+ interface GetTokenResponse {
14
+ accessToken: string;
15
+ /** The Unix Epoch at which the token will expire */
16
+ expiresAt: number;
17
+ }
18
+ /**
19
+ * @public
20
+ */
21
+ interface GetAccessResponse {
22
+ decision: string;
23
+ authorizeClusterIds: string[];
24
+ authorizeProjects: string[];
25
+ }
26
+ /**
27
+ * Response from cost management access endpoint
28
+ * @public
29
+ */
30
+ interface GetCostManagementAccessResponse {
31
+ decision: string;
32
+ authorizedClusterNames: string[];
33
+ authorizeProjects: string[];
34
+ }
35
+ /** @public */
36
+ type GetRecommendationByIdRequest = Parameters<OptimizationsApi['getRecommendationById']>[0];
37
+ /** @public */
38
+ type GetRecommendationListRequest = Parameters<OptimizationsApi['getRecommendationList']>[0];
39
+
40
+ /**
41
+ * Client for the Optimizations (ROS) API.
42
+ *
43
+ * In the frontend, requests are routed through the backend plugin's secure
44
+ * proxy (`/api/cost-management/proxy/...`), which keeps the SSO token
45
+ * server-side and enforces RBAC before forwarding to the Cost Management API.
46
+ *
47
+ * When a `token` is provided via `RequestOptions` (backend use-case), the
48
+ * request goes directly to the upstream API.
49
+ *
50
+ * @public
51
+ */
52
+ declare class OptimizationsClient implements OptimizationsApi {
53
+ private static requestKeysToSkip;
54
+ private static responseKeysToSkip;
55
+ /** Used for backend-to-RHCC calls (token provided by caller). */
56
+ private readonly directClient;
57
+ /** Used for frontend calls routed through the backend secure proxy. */
58
+ private readonly proxyClient;
59
+ constructor(options: {
60
+ discoveryApi: DiscoveryApi;
61
+ fetchApi?: FetchApi;
62
+ });
63
+ getRecommendationById(request: GetRecommendationByIdRequest): Promise<TypedResponse<RecommendationBoxPlots>>;
64
+ getRecommendationList(request: GetRecommendationListRequest, options?: RequestOptions): Promise<TypedResponse<RecommendationList>>;
65
+ }
66
+
67
+ /** @public */
68
+ type WorkflowUnavailableReason = 'not_configured' | 'not_found' | 'access_denied' | 'service_unavailable';
69
+ /** @public */
70
+ interface WorkflowAvailabilityResult {
71
+ available: boolean;
72
+ reason?: WorkflowUnavailableReason;
73
+ errorMessage?: string;
74
+ }
75
+ /** @public */
76
+ interface OrchestratorSlimApi {
77
+ isWorkflowAvailable(workflowId: string): Promise<boolean>;
78
+ checkWorkflowAvailability(workflowId: string): Promise<WorkflowAvailabilityResult>;
79
+ executeWorkflow<D = JsonObject>(workflowId: string, workflowInputData: D): Promise<{
80
+ id: string;
81
+ }>;
82
+ }
83
+
84
+ /** @public */
85
+ declare class OrchestratorSlimClient implements OrchestratorSlimApi {
86
+ private readonly discoveryApi;
87
+ private readonly fetchApi;
88
+ private baseUrl?;
89
+ /** @deprecated identityApi is retained for backward compatibility but no longer used. */
90
+ constructor(options: {
91
+ discoveryApi: DiscoveryApi;
92
+ fetchApi: FetchApi;
93
+ identityApi?: IdentityApi;
94
+ });
95
+ isWorkflowAvailable(workflowId: string): Promise<boolean>;
96
+ checkWorkflowAvailability(workflowId: string): Promise<WorkflowAvailabilityResult>;
97
+ /**
98
+ * Executes a workflow through the cost-management backend which validates
99
+ * inputs and checks ros.apply permission before forwarding to orchestrator.
100
+ * @public
101
+ */
102
+ executeWorkflow<D = JsonObject>(workflowId: string, workflowInputData: D): Promise<{
103
+ id: string;
104
+ }>;
105
+ }
106
+
107
+ /** @public */
108
+ type CurrencyCode = 'USD' | 'EUR' | 'GBP' | 'JPY' | 'AUD' | 'CAD' | 'CHF' | 'CNY' | 'INR' | 'MXN' | 'NZD' | 'SEK' | 'SGD' | 'HKD' | 'TWD' | 'THB' | 'RUB' | 'BRL' | 'ZAR' | 'PLN' | 'KRW' | 'TRY' | 'IDR' | 'MYR' | 'PHP' | 'VND' | 'HUF' | 'CZK' | 'NOK' | 'DKK' | 'NGN';
109
+ /** @public */
110
+ interface GetCostManagementRequest {
111
+ query: {
112
+ currency?: CurrencyCode;
113
+ delta?: string;
114
+ 'filter[limit]'?: number;
115
+ 'filter[offset]'?: number;
116
+ 'filter[resolution]'?: 'daily' | 'monthly';
117
+ 'filter[time_scope_units]'?: 'day' | 'month';
118
+ 'filter[time_scope_value]'?: number;
119
+ 'filter[exact:cluster]'?: string;
120
+ 'group_by[project]'?: '*' | string;
121
+ 'group_by[cluster]'?: '*' | string;
122
+ 'group_by[node]'?: '*' | string;
123
+ 'group_by[tag]'?: '*' | string;
124
+ 'order_by[cost]'?: 'asc' | 'desc';
125
+ 'order_by[distributed_cost]'?: 'asc' | 'desc';
126
+ 'order_by[markup_cost]'?: 'asc' | 'desc';
127
+ 'order_by[raw_cost]'?: 'asc' | 'desc';
128
+ [key: string]: string | number | undefined;
129
+ };
130
+ }
131
+ /** @public */
132
+ type ExportFormat = 'csv' | 'json';
133
+ /** @public */
134
+ interface DownloadCostManagementRequest extends GetCostManagementRequest {
135
+ format: ExportFormat;
136
+ }
137
+ /** @public */
138
+ interface CostValue {
139
+ value: number;
140
+ units: string;
141
+ }
142
+ /** @public */
143
+ interface BasicCost {
144
+ raw: CostValue;
145
+ markup: CostValue;
146
+ usage: CostValue;
147
+ total: CostValue;
148
+ }
149
+ /** @public */
150
+ interface DistributedCost extends BasicCost {
151
+ platform_distributed: CostValue;
152
+ worker_unallocated_distributed: CostValue;
153
+ network_unattributed_distributed: CostValue;
154
+ storage_unattributed_distributed: CostValue;
155
+ distributed: CostValue;
156
+ }
157
+ /** @public */
158
+ interface ProjectValue {
159
+ date: string;
160
+ project?: string;
161
+ cluster?: string;
162
+ node?: string;
163
+ tag?: string;
164
+ cost_group: number | string;
165
+ classification: string;
166
+ source_uuid: string[];
167
+ clusters: string[];
168
+ delta_value: number;
169
+ delta_percent: number;
170
+ infrastructure: BasicCost;
171
+ supplementary: BasicCost;
172
+ cost: DistributedCost;
173
+ }
174
+ /** @public */
175
+ interface Project {
176
+ project?: string;
177
+ values: ProjectValue[];
178
+ }
179
+ /** @public */
180
+ interface Cluster {
181
+ cluster: string;
182
+ values: ProjectValue[];
183
+ }
184
+ /** @public */
185
+ interface Node {
186
+ node: string;
187
+ values: ProjectValue[];
188
+ }
189
+ /** @public */
190
+ interface Tag {
191
+ tag: string;
192
+ values: ProjectValue[];
193
+ }
194
+ /** @public */
195
+ interface DateData {
196
+ date: string;
197
+ projects?: Project[];
198
+ clusters?: Cluster[];
199
+ nodes?: Node[];
200
+ tags?: Tag[];
201
+ [key: string]: unknown;
202
+ }
203
+ /** @public */
204
+ interface CostManagementReport {
205
+ meta: {
206
+ count: number;
207
+ limit: number;
208
+ offset: number;
209
+ others: number;
210
+ currency: string;
211
+ delta: {
212
+ value: number;
213
+ percent: number;
214
+ };
215
+ filter: {
216
+ resolution: string;
217
+ time_scope_value: string;
218
+ time_scope_units: string;
219
+ limit: number;
220
+ offset: number;
221
+ };
222
+ group_by: {
223
+ [key: string]: string[];
224
+ };
225
+ order_by: {
226
+ [key: string]: string;
227
+ };
228
+ exclude: Record<string, unknown>;
229
+ distributed_overhead: boolean;
230
+ total: {
231
+ infrastructure: BasicCost;
232
+ supplementary: BasicCost;
233
+ cost: DistributedCost;
234
+ };
235
+ };
236
+ links: {
237
+ first: string;
238
+ next: string | null;
239
+ previous: string | null;
240
+ last: string;
241
+ };
242
+ data: DateData[];
243
+ }
244
+
245
+ /** @public */
246
+ interface CostManagementSlimApi {
247
+ getCostManagementReport(request: GetCostManagementRequest): Promise<TypedResponse<CostManagementReport>>;
248
+ downloadCostManagementReport(request: DownloadCostManagementRequest): Promise<void>;
249
+ searchOpenShiftProjects(search?: string, options?: {
250
+ token?: string;
251
+ limit?: number;
252
+ }): Promise<TypedResponse<{
253
+ data: Array<{
254
+ value: string;
255
+ }>;
256
+ meta?: any;
257
+ links?: any;
258
+ }>>;
259
+ searchOpenShiftClusters(search?: string, options?: {
260
+ token?: string;
261
+ limit?: number;
262
+ }): Promise<TypedResponse<{
263
+ data: Array<{
264
+ value: string;
265
+ cluster_alias: string;
266
+ }>;
267
+ meta?: any;
268
+ links?: any;
269
+ }>>;
270
+ searchOpenShiftNodes(search?: string): Promise<TypedResponse<{
271
+ data: Array<{
272
+ value: string;
273
+ }>;
274
+ meta?: any;
275
+ links?: any;
276
+ }>>;
277
+ getOpenShiftTags(timeScopeValue?: number): Promise<TypedResponse<{
278
+ data: string[];
279
+ meta?: any;
280
+ links?: any;
281
+ }>>;
282
+ getOpenShiftTagValues(tagKey: string, timeScopeValue?: number): Promise<TypedResponse<{
283
+ data: Array<{
284
+ key: string;
285
+ values: string[];
286
+ enabled: boolean;
287
+ }>;
288
+ meta?: any;
289
+ links?: any;
290
+ }>>;
291
+ }
292
+
293
+ /**
294
+ * Client for Cost Management data.
295
+ *
296
+ * In the frontend, requests are routed through the backend plugin's secure
297
+ * proxy (`/api/cost-management/proxy/...`), which keeps the SSO token
298
+ * server-side and enforces RBAC before forwarding to the Cost Management API.
299
+ *
300
+ * @public
301
+ */
302
+ declare class CostManagementSlimClient implements CostManagementSlimApi {
303
+ private readonly discoveryApi;
304
+ private readonly fetchApi;
305
+ constructor(options: {
306
+ discoveryApi: DiscoveryApi;
307
+ fetchApi?: FetchApi;
308
+ });
309
+ getCostManagementReport(request: GetCostManagementRequest): Promise<TypedResponse<CostManagementReport>>;
310
+ downloadCostManagementReport(request: DownloadCostManagementRequest): Promise<void>;
311
+ /**
312
+ * Converts CSV string to JSON string
313
+ * @param csv - The CSV data as a string
314
+ * @returns JSON string representation of the CSV data
315
+ */
316
+ private convertCsvToJson;
317
+ /**
318
+ * Parses a CSV line handling quoted values
319
+ * @param line - A single line from CSV
320
+ * @returns Array of values
321
+ */
322
+ private parseCsvLine;
323
+ /**
324
+ * Builds query parameters for cost management report request
325
+ * @param request - The cost management request
326
+ * @returns URLSearchParams with all query parameters
327
+ */
328
+ private buildCostManagementQueryParams;
329
+ /**
330
+ * Appends basic query parameters (currency, delta, and standard filters)
331
+ */
332
+ private appendBasicQueryParams;
333
+ /**
334
+ * Appends dynamic parameters that match a specific prefix (e.g., 'group_by[', 'order_by[')
335
+ */
336
+ private appendDynamicParams;
337
+ /**
338
+ * Appends dynamic filter parameters, excluding those already handled explicitly
339
+ */
340
+ private appendDynamicFilterParams;
341
+ /**
342
+ * Appends dynamic exclude parameters (e.g., exclude[project], exclude[cluster], exclude[tag:key])
343
+ */
344
+ private appendDynamicExcludeParams;
345
+ /**
346
+ * Search OpenShift projects
347
+ * @param search - Search term to filter projects
348
+ * @param options - Optional request options including token and limit
349
+ * @param options.token - Bearer token for authentication (backend use)
350
+ * @param options.limit - Maximum number of results to return (default: 10, use large number for all)
351
+ */
352
+ searchOpenShiftProjects(search?: string, options?: {
353
+ token?: string;
354
+ limit?: number;
355
+ }): Promise<TypedResponse<{
356
+ data: Array<{
357
+ value: string;
358
+ }>;
359
+ meta?: any;
360
+ links?: any;
361
+ }>>;
362
+ /**
363
+ * Search OpenShift clusters
364
+ * @param search - Search term to filter clusters
365
+ */
366
+ searchOpenShiftClusters(search?: string, options?: {
367
+ token?: string;
368
+ limit?: number;
369
+ }): Promise<TypedResponse<{
370
+ data: Array<{
371
+ value: string;
372
+ cluster_alias: string;
373
+ }>;
374
+ meta?: any;
375
+ links?: any;
376
+ }>>;
377
+ /**
378
+ * Search OpenShift nodes
379
+ * @param search - Search term to filter nodes
380
+ */
381
+ searchOpenShiftNodes(search?: string): Promise<TypedResponse<{
382
+ data: Array<{
383
+ value: string;
384
+ }>;
385
+ meta?: any;
386
+ links?: any;
387
+ }>>;
388
+ /**
389
+ * Get OpenShift tags
390
+ * @param timeScopeValue - Time scope value (-1 for month-to-date, -2 for previous-month). Defaults to -1.
391
+ * @returns TypedResponse with array of tag strings
392
+ */
393
+ getOpenShiftTags(timeScopeValue?: number): Promise<TypedResponse<{
394
+ data: string[];
395
+ meta?: any;
396
+ links?: any;
397
+ }>>;
398
+ /**
399
+ * Get OpenShift tag values for a specific tag key
400
+ * @param tagKey - The tag key to get values for
401
+ * @param timeScopeValue - Time scope value (-1 for month-to-date, -2 for previous-month). Defaults to -1.
402
+ * @returns TypedResponse with array of tag value objects
403
+ */
404
+ getOpenShiftTagValues(tagKey: string, timeScopeValue?: number): Promise<TypedResponse<{
405
+ data: Array<{
406
+ key: string;
407
+ values: string[];
408
+ enabled: boolean;
409
+ }>;
410
+ meta?: any;
411
+ links?: any;
412
+ }>>;
413
+ private fetchResourceType;
414
+ /**
415
+ * Builds resource type URL routed through the backend secure proxy
416
+ */
417
+ private buildResourceTypeUrl;
418
+ /**
419
+ * Fetches with externally provided token (for backend use).
420
+ * This path bypasses the secure proxy since it's already server-side.
421
+ */
422
+ private fetchWithExternalToken;
423
+ /**
424
+ * Fetches a URL via the backend secure proxy. No Authorization header
425
+ * is sent; the backend injects the SSO token and RBAC filters
426
+ * server-side. Authentication is via the Backstage session cookie.
427
+ */
428
+ private fetchViaBackendProxy;
429
+ }
430
+
431
+ export { CostManagementSlimClient, OptimizationsClient, OrchestratorSlimClient };
432
+ export type { BasicCost, Cluster, CostManagementReport, CostManagementSlimApi, CostValue, CurrencyCode, DateData, DistributedCost, DownloadCostManagementRequest, ExportFormat, GetAccessResponse, GetCostManagementAccessResponse, GetCostManagementRequest, GetRecommendationByIdRequest, GetRecommendationListRequest, GetTokenResponse, Node, OptimizationsApi, OrchestratorSlimApi, Project, ProjectValue, Tag, WorkflowAvailabilityResult, WorkflowUnavailableReason };
@@ -0,0 +1,4 @@
1
+ export { OptimizationsClient } from './clients/optimizations/OptimizationsClient.esm.js';
2
+ export { OrchestratorSlimClient } from './clients/orchestrator-slim/OrchestratorSlimClient.esm.js';
3
+ export { CostManagementSlimClient } from './clients/cost-management/CostManagementSlimClient.esm.js';
4
+ //# sourceMappingURL=clients.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clients.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,91 @@
1
+ 'use strict';
2
+
3
+ var crossFetch = require('cross-fetch');
4
+ var pluginId = require('../pluginId.cjs.js');
5
+ var parser = require('uri-template');
6
+
7
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
8
+
9
+ function _interopNamespaceCompat(e) {
10
+ if (e && typeof e === 'object' && 'default' in e) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var crossFetch__default = /*#__PURE__*/_interopDefaultCompat(crossFetch);
28
+ var parser__namespace = /*#__PURE__*/_interopNamespaceCompat(parser);
29
+
30
+ class DefaultApiClient {
31
+ discoveryApi;
32
+ fetchApi;
33
+ constructor(options) {
34
+ this.discoveryApi = options.discoveryApi;
35
+ this.fetchApi = options.fetchApi || { fetch: crossFetch__default.default };
36
+ }
37
+ /**
38
+ * This feature is in limited preview for select customers
39
+ * Get recommendation for container
40
+ * @param recommendationId - The recommendation UUID
41
+ * @param memoryUnit - unit preference for memory
42
+ * @param cpuUnit - unit preference for cpu
43
+ */
44
+ async getRecommendationById(request, options) {
45
+ const baseUrl = await this.discoveryApi.getBaseUrl(pluginId.pluginId);
46
+ const uriTemplate = `/recommendations/openshift/{recommendation_id}{?memory_unit,cpu_unit}`;
47
+ const uri = parser__namespace.parse(uriTemplate).expand({
48
+ recommendation_id: request.path.recommendationId,
49
+ ...request.query
50
+ });
51
+ return await this.fetchApi.fetch(`${baseUrl}${uri}`, {
52
+ headers: {
53
+ "Content-Type": "application/json",
54
+ ...options?.token && { Authorization: `Bearer ${options?.token}` }
55
+ },
56
+ method: "GET"
57
+ });
58
+ }
59
+ /**
60
+ * This feature is in limited preview for select customers
61
+ * Get all recommendations
62
+ * @param cluster - Cluster alias or UUID
63
+ * @param workloadType - Options are daemonset, deployment, deploymentconfig, replicaset, replicationcontroller, statefulset
64
+ * @param workload - Workload name
65
+ * @param container - Container name
66
+ * @param project - Project name
67
+ * @param startDate - Start date
68
+ * @param endDate - End date
69
+ * @param offset - Pagination offset
70
+ * @param limit - Pagination limit
71
+ * @param orderBy - Options are cluster, project, workload_type, workload, container, last_reported
72
+ * @param orderHow - Options are ASC, DESC
73
+ */
74
+ async getRecommendationList(request, options) {
75
+ const baseUrl = await this.discoveryApi.getBaseUrl(pluginId.pluginId);
76
+ const uriTemplate = `/recommendations/openshift{?cluster*,workload_type*,workload*,container*,project*,start_date,end_date,offset,limit,order_by,order_how}`;
77
+ const uri = parser__namespace.parse(uriTemplate).expand({
78
+ ...request.query
79
+ });
80
+ return await this.fetchApi.fetch(`${baseUrl}${uri}`, {
81
+ headers: {
82
+ "Content-Type": "application/json",
83
+ ...options?.token && { Authorization: `Bearer ${options?.token}` }
84
+ },
85
+ method: "GET"
86
+ });
87
+ }
88
+ }
89
+
90
+ exports.DefaultApiClient = DefaultApiClient;
91
+ //# sourceMappingURL=DefaultApi.client.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultApi.client.cjs.js","sources":["../../../src/generated/apis/DefaultApi.client.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// ******************************************************************\n// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *\n// ******************************************************************\nimport { DiscoveryApi } from '../types/discovery';\nimport { FetchApi } from '../types/fetch';\nimport crossFetch from 'cross-fetch';\nimport { pluginId } from '../pluginId';\nimport * as parser from 'uri-template';\n\nimport { RecommendationBoxPlots } from '../models/RecommendationBoxPlots.model';\nimport { RecommendationList } from '../models/RecommendationList.model';\n\n/**\n * Wraps the Response type to convey a type on the json call.\n *\n * @public\n */\nexport type TypedResponse<T> = Omit<Response, 'json'> & {\n json: () => Promise<T>;\n};\n\n/**\n * Options you can pass into a request for additional information.\n *\n * @public\n */\nexport interface RequestOptions {\n token?: string;\n}\n\n/**\n * no description\n * @public\n */\nexport class DefaultApiClient {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n constructor(options: {\n discoveryApi: { getBaseUrl(pluginId: string): Promise<string> };\n fetchApi?: { fetch: typeof fetch };\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi || { fetch: crossFetch };\n }\n\n /**\n * This feature is in limited preview for select customers\n * Get recommendation for container\n * @param recommendationId - The recommendation UUID\n * @param memoryUnit - unit preference for memory\n * @param cpuUnit - unit preference for cpu\n */\n public async getRecommendationById(\n // @ts-ignore\n request: {\n path: {\n recommendationId: string;\n };\n query: {\n memoryUnit?: 'bytes' | 'MiB' | 'GiB';\n cpuUnit?: 'millicores' | 'cores';\n };\n },\n options?: RequestOptions,\n ): Promise<TypedResponse<RecommendationBoxPlots>> {\n const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);\n\n const uriTemplate = `/recommendations/openshift/{recommendation_id}{?memory_unit,cpu_unit}`;\n\n const uri = parser.parse(uriTemplate).expand({\n recommendation_id: request.path.recommendationId,\n ...request.query,\n });\n\n return await this.fetchApi.fetch(`${baseUrl}${uri}`, {\n headers: {\n 'Content-Type': 'application/json',\n ...(options?.token && { Authorization: `Bearer ${options?.token}` }),\n },\n method: 'GET',\n });\n }\n\n /**\n * This feature is in limited preview for select customers\n * Get all recommendations\n * @param cluster - Cluster alias or UUID\n * @param workloadType - Options are daemonset, deployment, deploymentconfig, replicaset, replicationcontroller, statefulset\n * @param workload - Workload name\n * @param container - Container name\n * @param project - Project name\n * @param startDate - Start date\n * @param endDate - End date\n * @param offset - Pagination offset\n * @param limit - Pagination limit\n * @param orderBy - Options are cluster, project, workload_type, workload, container, last_reported\n * @param orderHow - Options are ASC, DESC\n */\n public async getRecommendationList(\n // @ts-ignore\n request: {\n query: {\n cluster?: Array<string>;\n workloadType?: Array<string>;\n workload?: Array<string>;\n container?: Array<string>;\n project?: Array<string>;\n startDate?: string;\n endDate?: string;\n offset?: number;\n limit?: number;\n orderBy?:\n | 'cluster'\n | 'project'\n | 'workload_type'\n | 'workload'\n | 'container'\n | 'last_reported';\n orderHow?: 'asc' | 'desc';\n };\n },\n options?: RequestOptions,\n ): Promise<TypedResponse<RecommendationList>> {\n const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);\n\n const uriTemplate = `/recommendations/openshift{?cluster*,workload_type*,workload*,container*,project*,start_date,end_date,offset,limit,order_by,order_how}`;\n\n const uri = parser.parse(uriTemplate).expand({\n ...request.query,\n });\n\n return await this.fetchApi.fetch(`${baseUrl}${uri}`, {\n headers: {\n 'Content-Type': 'application/json',\n ...(options?.token && { Authorization: `Bearer ${options?.token}` }),\n },\n method: 'GET',\n });\n }\n}\n"],"names":["crossFetch","pluginId","parser"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDO,MAAM,gBAAiB,CAAA;AAAA,EACX,YAAA;AAAA,EACA,QAAA;AAAA,EAEjB,YAAY,OAGT,EAAA;AACD,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA;AAC5B,IAAA,IAAA,CAAK,QAAW,GAAA,OAAA,CAAQ,QAAY,IAAA,EAAE,OAAOA,2BAAW,EAAA;AAAA;AAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAa,qBAEX,CAAA,OAAA,EASA,OACgD,EAAA;AAChD,IAAA,MAAM,OAAU,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,WAAWC,iBAAQ,CAAA;AAE3D,IAAA,MAAM,WAAc,GAAA,CAAA,qEAAA,CAAA;AAEpB,IAAA,MAAM,GAAM,GAAAC,iBAAA,CAAO,KAAM,CAAA,WAAW,EAAE,MAAO,CAAA;AAAA,MAC3C,iBAAA,EAAmB,QAAQ,IAAK,CAAA,gBAAA;AAAA,MAChC,GAAG,OAAQ,CAAA;AAAA,KACZ,CAAA;AAED,IAAO,OAAA,MAAM,KAAK,QAAS,CAAA,KAAA,CAAM,GAAG,OAAO,CAAA,EAAG,GAAG,CAAI,CAAA,EAAA;AAAA,MACnD,OAAS,EAAA;AAAA,QACP,cAAgB,EAAA,kBAAA;AAAA,QAChB,GAAI,SAAS,KAAS,IAAA,EAAE,eAAe,CAAU,OAAA,EAAA,OAAA,EAAS,KAAK,CAAG,CAAA;AAAA,OACpE;AAAA,MACA,MAAQ,EAAA;AAAA,KACT,CAAA;AAAA;AACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,MAAa,qBAEX,CAAA,OAAA,EAqBA,OAC4C,EAAA;AAC5C,IAAA,MAAM,OAAU,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,WAAWD,iBAAQ,CAAA;AAE3D,IAAA,MAAM,WAAc,GAAA,CAAA,sIAAA,CAAA;AAEpB,IAAA,MAAM,GAAM,GAAAC,iBAAA,CAAO,KAAM,CAAA,WAAW,EAAE,MAAO,CAAA;AAAA,MAC3C,GAAG,OAAQ,CAAA;AAAA,KACZ,CAAA;AAED,IAAO,OAAA,MAAM,KAAK,QAAS,CAAA,KAAA,CAAM,GAAG,OAAO,CAAA,EAAG,GAAG,CAAI,CAAA,EAAA;AAAA,MACnD,OAAS,EAAA;AAAA,QACP,cAAgB,EAAA,kBAAA;AAAA,QAChB,GAAI,SAAS,KAAS,IAAA,EAAE,eAAe,CAAU,OAAA,EAAA,OAAA,EAAS,KAAK,CAAG,CAAA;AAAA,OACpE;AAAA,MACA,MAAQ,EAAA;AAAA,KACT,CAAA;AAAA;AAEL;;;;"}
@@ -0,0 +1,66 @@
1
+ import crossFetch from 'cross-fetch';
2
+ import { pluginId } from '../pluginId.esm.js';
3
+ import * as parser from 'uri-template';
4
+
5
+ class DefaultApiClient {
6
+ discoveryApi;
7
+ fetchApi;
8
+ constructor(options) {
9
+ this.discoveryApi = options.discoveryApi;
10
+ this.fetchApi = options.fetchApi || { fetch: crossFetch };
11
+ }
12
+ /**
13
+ * This feature is in limited preview for select customers
14
+ * Get recommendation for container
15
+ * @param recommendationId - The recommendation UUID
16
+ * @param memoryUnit - unit preference for memory
17
+ * @param cpuUnit - unit preference for cpu
18
+ */
19
+ async getRecommendationById(request, options) {
20
+ const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);
21
+ const uriTemplate = `/recommendations/openshift/{recommendation_id}{?memory_unit,cpu_unit}`;
22
+ const uri = parser.parse(uriTemplate).expand({
23
+ recommendation_id: request.path.recommendationId,
24
+ ...request.query
25
+ });
26
+ return await this.fetchApi.fetch(`${baseUrl}${uri}`, {
27
+ headers: {
28
+ "Content-Type": "application/json",
29
+ ...options?.token && { Authorization: `Bearer ${options?.token}` }
30
+ },
31
+ method: "GET"
32
+ });
33
+ }
34
+ /**
35
+ * This feature is in limited preview for select customers
36
+ * Get all recommendations
37
+ * @param cluster - Cluster alias or UUID
38
+ * @param workloadType - Options are daemonset, deployment, deploymentconfig, replicaset, replicationcontroller, statefulset
39
+ * @param workload - Workload name
40
+ * @param container - Container name
41
+ * @param project - Project name
42
+ * @param startDate - Start date
43
+ * @param endDate - End date
44
+ * @param offset - Pagination offset
45
+ * @param limit - Pagination limit
46
+ * @param orderBy - Options are cluster, project, workload_type, workload, container, last_reported
47
+ * @param orderHow - Options are ASC, DESC
48
+ */
49
+ async getRecommendationList(request, options) {
50
+ const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);
51
+ const uriTemplate = `/recommendations/openshift{?cluster*,workload_type*,workload*,container*,project*,start_date,end_date,offset,limit,order_by,order_how}`;
52
+ const uri = parser.parse(uriTemplate).expand({
53
+ ...request.query
54
+ });
55
+ return await this.fetchApi.fetch(`${baseUrl}${uri}`, {
56
+ headers: {
57
+ "Content-Type": "application/json",
58
+ ...options?.token && { Authorization: `Bearer ${options?.token}` }
59
+ },
60
+ method: "GET"
61
+ });
62
+ }
63
+ }
64
+
65
+ export { DefaultApiClient };
66
+ //# sourceMappingURL=DefaultApi.client.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultApi.client.esm.js","sources":["../../../src/generated/apis/DefaultApi.client.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// ******************************************************************\n// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *\n// ******************************************************************\nimport { DiscoveryApi } from '../types/discovery';\nimport { FetchApi } from '../types/fetch';\nimport crossFetch from 'cross-fetch';\nimport { pluginId } from '../pluginId';\nimport * as parser from 'uri-template';\n\nimport { RecommendationBoxPlots } from '../models/RecommendationBoxPlots.model';\nimport { RecommendationList } from '../models/RecommendationList.model';\n\n/**\n * Wraps the Response type to convey a type on the json call.\n *\n * @public\n */\nexport type TypedResponse<T> = Omit<Response, 'json'> & {\n json: () => Promise<T>;\n};\n\n/**\n * Options you can pass into a request for additional information.\n *\n * @public\n */\nexport interface RequestOptions {\n token?: string;\n}\n\n/**\n * no description\n * @public\n */\nexport class DefaultApiClient {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n constructor(options: {\n discoveryApi: { getBaseUrl(pluginId: string): Promise<string> };\n fetchApi?: { fetch: typeof fetch };\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi || { fetch: crossFetch };\n }\n\n /**\n * This feature is in limited preview for select customers\n * Get recommendation for container\n * @param recommendationId - The recommendation UUID\n * @param memoryUnit - unit preference for memory\n * @param cpuUnit - unit preference for cpu\n */\n public async getRecommendationById(\n // @ts-ignore\n request: {\n path: {\n recommendationId: string;\n };\n query: {\n memoryUnit?: 'bytes' | 'MiB' | 'GiB';\n cpuUnit?: 'millicores' | 'cores';\n };\n },\n options?: RequestOptions,\n ): Promise<TypedResponse<RecommendationBoxPlots>> {\n const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);\n\n const uriTemplate = `/recommendations/openshift/{recommendation_id}{?memory_unit,cpu_unit}`;\n\n const uri = parser.parse(uriTemplate).expand({\n recommendation_id: request.path.recommendationId,\n ...request.query,\n });\n\n return await this.fetchApi.fetch(`${baseUrl}${uri}`, {\n headers: {\n 'Content-Type': 'application/json',\n ...(options?.token && { Authorization: `Bearer ${options?.token}` }),\n },\n method: 'GET',\n });\n }\n\n /**\n * This feature is in limited preview for select customers\n * Get all recommendations\n * @param cluster - Cluster alias or UUID\n * @param workloadType - Options are daemonset, deployment, deploymentconfig, replicaset, replicationcontroller, statefulset\n * @param workload - Workload name\n * @param container - Container name\n * @param project - Project name\n * @param startDate - Start date\n * @param endDate - End date\n * @param offset - Pagination offset\n * @param limit - Pagination limit\n * @param orderBy - Options are cluster, project, workload_type, workload, container, last_reported\n * @param orderHow - Options are ASC, DESC\n */\n public async getRecommendationList(\n // @ts-ignore\n request: {\n query: {\n cluster?: Array<string>;\n workloadType?: Array<string>;\n workload?: Array<string>;\n container?: Array<string>;\n project?: Array<string>;\n startDate?: string;\n endDate?: string;\n offset?: number;\n limit?: number;\n orderBy?:\n | 'cluster'\n | 'project'\n | 'workload_type'\n | 'workload'\n | 'container'\n | 'last_reported';\n orderHow?: 'asc' | 'desc';\n };\n },\n options?: RequestOptions,\n ): Promise<TypedResponse<RecommendationList>> {\n const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);\n\n const uriTemplate = `/recommendations/openshift{?cluster*,workload_type*,workload*,container*,project*,start_date,end_date,offset,limit,order_by,order_how}`;\n\n const uri = parser.parse(uriTemplate).expand({\n ...request.query,\n });\n\n return await this.fetchApi.fetch(`${baseUrl}${uri}`, {\n headers: {\n 'Content-Type': 'application/json',\n ...(options?.token && { Authorization: `Bearer ${options?.token}` }),\n },\n method: 'GET',\n });\n }\n}\n"],"names":[],"mappings":";;;;AAkDO,MAAM,gBAAiB,CAAA;AAAA,EACX,YAAA;AAAA,EACA,QAAA;AAAA,EAEjB,YAAY,OAGT,EAAA;AACD,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA;AAC5B,IAAA,IAAA,CAAK,QAAW,GAAA,OAAA,CAAQ,QAAY,IAAA,EAAE,OAAO,UAAW,EAAA;AAAA;AAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAa,qBAEX,CAAA,OAAA,EASA,OACgD,EAAA;AAChD,IAAA,MAAM,OAAU,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,WAAW,QAAQ,CAAA;AAE3D,IAAA,MAAM,WAAc,GAAA,CAAA,qEAAA,CAAA;AAEpB,IAAA,MAAM,GAAM,GAAA,MAAA,CAAO,KAAM,CAAA,WAAW,EAAE,MAAO,CAAA;AAAA,MAC3C,iBAAA,EAAmB,QAAQ,IAAK,CAAA,gBAAA;AAAA,MAChC,GAAG,OAAQ,CAAA;AAAA,KACZ,CAAA;AAED,IAAO,OAAA,MAAM,KAAK,QAAS,CAAA,KAAA,CAAM,GAAG,OAAO,CAAA,EAAG,GAAG,CAAI,CAAA,EAAA;AAAA,MACnD,OAAS,EAAA;AAAA,QACP,cAAgB,EAAA,kBAAA;AAAA,QAChB,GAAI,SAAS,KAAS,IAAA,EAAE,eAAe,CAAU,OAAA,EAAA,OAAA,EAAS,KAAK,CAAG,CAAA;AAAA,OACpE;AAAA,MACA,MAAQ,EAAA;AAAA,KACT,CAAA;AAAA;AACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,MAAa,qBAEX,CAAA,OAAA,EAqBA,OAC4C,EAAA;AAC5C,IAAA,MAAM,OAAU,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,WAAW,QAAQ,CAAA;AAE3D,IAAA,MAAM,WAAc,GAAA,CAAA,sIAAA,CAAA;AAEpB,IAAA,MAAM,GAAM,GAAA,MAAA,CAAO,KAAM,CAAA,WAAW,EAAE,MAAO,CAAA;AAAA,MAC3C,GAAG,OAAQ,CAAA;AAAA,KACZ,CAAA;AAED,IAAO,OAAA,MAAM,KAAK,QAAS,CAAA,KAAA,CAAM,GAAG,OAAO,CAAA,EAAG,GAAG,CAAI,CAAA,EAAA;AAAA,MACnD,OAAS,EAAA;AAAA,QACP,cAAgB,EAAA,kBAAA;AAAA,QAChB,GAAI,SAAS,KAAS,IAAA,EAAE,eAAe,CAAU,OAAA,EAAA,OAAA,EAAS,KAAK,CAAG,CAAA;AAAA,OACpE;AAAA,MACA,MAAQ,EAAA;AAAA,KACT,CAAA;AAAA;AAEL;;;;"}
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ const pluginId = "cost-management";
4
+
5
+ exports.pluginId = pluginId;
6
+ //# sourceMappingURL=pluginId.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginId.cjs.js","sources":["../../src/generated/pluginId.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @public\n */\nexport const pluginId = 'cost-management';\n"],"names":[],"mappings":";;AAmBO,MAAM,QAAW,GAAA;;;;"}
@@ -0,0 +1,4 @@
1
+ const pluginId = "cost-management";
2
+
3
+ export { pluginId };
4
+ //# sourceMappingURL=pluginId.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginId.esm.js","sources":["../../src/generated/pluginId.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @public\n */\nexport const pluginId = 'cost-management';\n"],"names":[],"mappings":"AAmBO,MAAM,QAAW,GAAA;;;;"}
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var OptimizationsClient = require('./clients/optimizations/OptimizationsClient.cjs.js');
4
+ var OrchestratorSlimClient = require('./clients/orchestrator-slim/OrchestratorSlimClient.cjs.js');
5
+ var CostManagementSlimClient = require('./clients/cost-management/CostManagementSlimClient.cjs.js');
6
+ var DefaultApi_client = require('./generated/apis/DefaultApi.client.cjs.js');
7
+
8
+
9
+
10
+ exports.OptimizationsClient = OptimizationsClient.OptimizationsClient;
11
+ exports.OrchestratorSlimClient = OrchestratorSlimClient.OrchestratorSlimClient;
12
+ exports.CostManagementSlimClient = CostManagementSlimClient.CostManagementSlimClient;
13
+ exports.DefaultApiClient = DefaultApi_client.DefaultApiClient;
14
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}