Add project field to product cost api calls
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
Project,
|
||||
ProductCost,
|
||||
Group,
|
||||
Maybe,
|
||||
} from '@backstage/plugin-cost-insights';
|
||||
|
||||
export class ExampleCostInsightsClient implements CostInsightsApi {
|
||||
@@ -122,9 +123,38 @@ export class ExampleCostInsightsClient implements CostInsightsApi {
|
||||
product: string,
|
||||
group: string,
|
||||
duration: Duration,
|
||||
project: Maybe<string>,
|
||||
): Promise<ProductCost> {
|
||||
const projectProductInsights = await this.request(
|
||||
{ product, group, duration, project },
|
||||
{
|
||||
aggregation: [80_000, 110_000],
|
||||
change: {
|
||||
ratio: 0.375,
|
||||
amount: 30_000,
|
||||
},
|
||||
entities: [
|
||||
{
|
||||
id: null, // entities with null ids will be appear as "Unlabeled" in product panels
|
||||
aggregation: [45_000, 50_000],
|
||||
},
|
||||
{
|
||||
id: 'entity-a',
|
||||
aggregation: [15_000, 20_000],
|
||||
},
|
||||
{
|
||||
id: 'entity-b',
|
||||
aggregation: [20_000, 30_000],
|
||||
},
|
||||
{
|
||||
id: 'entity-e',
|
||||
aggregation: [0, 10_000],
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
const productInsights: ProductCost = await this.request(
|
||||
{ product, group, duration },
|
||||
{ product, group, duration, project },
|
||||
{
|
||||
aggregation: [200_000, 250_000],
|
||||
change: {
|
||||
@@ -172,7 +202,7 @@ export class ExampleCostInsightsClient implements CostInsightsApi {
|
||||
},
|
||||
);
|
||||
|
||||
return productInsights;
|
||||
return project ? projectProductInsights : productInsights;
|
||||
}
|
||||
|
||||
async getAlerts(group: string): Promise<Alert[]> {
|
||||
|
||||
Reference in New Issue
Block a user