fix format

This commit is contained in:
Tara Zou 2024-04-26 15:12:11 -04:00
parent 6ba2ff6000
commit c7c0a3a979
3 changed files with 13 additions and 17 deletions

View File

@ -254,4 +254,3 @@ export async function initializeConfiguration(): Promise<ConfigContext> {
}
export { configContext };

View File

@ -170,15 +170,15 @@ export const getRegions = async (): Promise<Array<RegionItem>> => {
}
};
export const getRegionShortName = async (regionDisplayName: string) : Promise<string> => {
export const getRegionShortName = async (regionDisplayName: string): Promise<string> => {
const locationsList = await get(userContext.subscriptionId, regionDisplayName);
if ('id' in locationsList) {
const locationId = locationsList.id;
return locationId.substring(locationId.lastIndexOf('/') + 1);
if ("id" in locationsList) {
const locationId = locationsList.id;
return locationId.substring(locationId.lastIndexOf("/") + 1);
}
return undefined;
}
};
const getFetchPricesPathForRegion = (subscriptionId: string): string => {
return `/subscriptions/${subscriptionId}/providers/Microsoft.CostManagement/fetchPrices`;
@ -223,9 +223,9 @@ export const getPriceMapAndCurrencyCode = async (map: OfferingIdMap): Promise<Pr
throw Error(`Get price error ${item.error.type} for ${item.id}: ${item.error.description}`);
}
const offeringId = item.id;
const offeringId = item.id;
const skuName = map.get(region).get(offeringId);
const unitPrice = item.prices.find(x => x.type == "Consumption")?.unitPrice;
const unitPrice = item.prices.find((x) => x.type == "Consumption")?.unitPrice;
regionPriceMap.set(skuName, unitPrice);
}
priceMap.set(region, regionPriceMap);
@ -265,10 +265,7 @@ export const getOfferingIds = async (regions: Array<RegionItem>): Promise<Offeri
method: "GET",
apiVersion: "2023-05-01-preview",
queryParams: {
filter:
"armRegionNameeq '" +
regionShortName +
"'",
filter: "armRegionNameeq '" + regionShortName + "'",
},
});

View File

@ -42,12 +42,12 @@ export type PriceItem = {
export type PriceType = {
type: string;
unitPrice: number;
}
};
export type PriceError = {
type: string;
description: string;
}
};
export type PriceMapAndCurrencyCode = {
priceMap: Map<string, Map<string, number>>;
@ -66,12 +66,12 @@ export type OfferingIdItem = {
export type OfferingProperties = {
offeringId: string;
}
};
export type OfferingIdRequest = {
ids: Array<string>;
location: string,
}
location: string;
};
export type OfferingIdMap = Map<string, Map<string, string>>;