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 }; 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); const locationsList = await get(userContext.subscriptionId, regionDisplayName);
if ('id' in locationsList) { if ("id" in locationsList) {
const locationId = locationsList.id; const locationId = locationsList.id;
return locationId.substring(locationId.lastIndexOf('/') + 1); return locationId.substring(locationId.lastIndexOf("/") + 1);
} }
return undefined; return undefined;
} };
const getFetchPricesPathForRegion = (subscriptionId: string): string => { const getFetchPricesPathForRegion = (subscriptionId: string): string => {
return `/subscriptions/${subscriptionId}/providers/Microsoft.CostManagement/fetchPrices`; 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}`); 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 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); regionPriceMap.set(skuName, unitPrice);
} }
priceMap.set(region, regionPriceMap); priceMap.set(region, regionPriceMap);
@ -265,10 +265,7 @@ export const getOfferingIds = async (regions: Array<RegionItem>): Promise<Offeri
method: "GET", method: "GET",
apiVersion: "2023-05-01-preview", apiVersion: "2023-05-01-preview",
queryParams: { queryParams: {
filter: filter: "armRegionNameeq '" + regionShortName + "'",
"armRegionNameeq '" +
regionShortName +
"'",
}, },
}); });

View File

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