mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 06:56:38 +00:00
update pricing UPAPI properties
This commit is contained in:
parent
5de6c46a93
commit
586ae376a3
@ -195,7 +195,7 @@ export const getPriceMapAndCurrencyCode = async (map: OfferingIdMap): Promise<Pr
|
||||
|
||||
try {
|
||||
const priceMap = new Map<string, Map<string, number>>();
|
||||
let pricingCurrency;
|
||||
let billingCurrency;
|
||||
for (const region of map.keys()) {
|
||||
const regionPriceMap = new Map<string, number>();
|
||||
const regionShortName = await getRegionShortName(region);
|
||||
@ -213,30 +213,30 @@ export const getPriceMapAndCurrencyCode = async (map: OfferingIdMap): Promise<Pr
|
||||
});
|
||||
|
||||
for (const item of response.result) {
|
||||
if (pricingCurrency === undefined) {
|
||||
pricingCurrency = item.pricingCurrency;
|
||||
} else if (item.pricingCurrency !== pricingCurrency) {
|
||||
throw Error("Currency Code Mismatch: Currency code not same for all regions / skus.");
|
||||
if (item.error) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.error) {
|
||||
throw Error(`Get price error ${item.error.type} for ${item.id}: ${item.error.description}`);
|
||||
if (billingCurrency === undefined) {
|
||||
billingCurrency = item.billingCurrency;
|
||||
} else if (item.billingCurrency !== billingCurrency) {
|
||||
throw Error("Currency Code Mismatch: Currency code not same for all regions / skus.");
|
||||
}
|
||||
|
||||
const offeringId = item.id;
|
||||
const skuName = map.get(region).get(offeringId);
|
||||
const unitPrice = item.prices.find((x) => x.type === "Consumption")?.unitPrice;
|
||||
regionPriceMap.set(skuName, unitPrice);
|
||||
const unitEffectivePriceInBillingCurrency = item.prices.find((x) => x.type === "Consumption")?.unitEffectivePriceInBillingCurrency;
|
||||
regionPriceMap.set(skuName, unitEffectivePriceInBillingCurrency);
|
||||
}
|
||||
priceMap.set(region, regionPriceMap);
|
||||
}
|
||||
|
||||
selfServeTraceSuccess(telemetryData, getPriceMapAndCurrencyCodeTimestamp);
|
||||
return { priceMap: priceMap, pricingCurrency: pricingCurrency };
|
||||
return { priceMap: priceMap, billingCurrency: billingCurrency };
|
||||
} catch (err) {
|
||||
const failureTelemetry = { err, selfServeClassName: SqlX.name };
|
||||
selfServeTraceFailure(failureTelemetry, getPriceMapAndCurrencyCodeTimestamp);
|
||||
return { priceMap: undefined, pricingCurrency: undefined };
|
||||
return { priceMap: undefined, billingCurrency: undefined };
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -374,7 +374,7 @@ export default class SqlX extends SelfServeBaseClass {
|
||||
const offeringIdMap = await getOfferingIds(regions);
|
||||
const priceMapAndCurrencyCode = await getPriceMapAndCurrencyCode(offeringIdMap);
|
||||
priceMap = priceMapAndCurrencyCode.priceMap;
|
||||
currencyCode = priceMapAndCurrencyCode.pricingCurrency;
|
||||
currencyCode = priceMapAndCurrencyCode.billingCurrency;
|
||||
|
||||
const response = await getCurrentProvisioningState();
|
||||
if (response.status && response.status !== "Deleting") {
|
||||
|
@ -35,13 +35,13 @@ export type FetchPricesResponse = Array<PriceItem>;
|
||||
export type PriceItem = {
|
||||
prices: Array<PriceType>;
|
||||
id: string;
|
||||
pricingCurrency: string;
|
||||
billingCurrency: string;
|
||||
error: PriceError;
|
||||
};
|
||||
|
||||
export type PriceType = {
|
||||
type: string;
|
||||
unitPrice: number;
|
||||
unitEffectivePriceInBillingCurrency: number;
|
||||
};
|
||||
|
||||
export type PriceError = {
|
||||
@ -51,7 +51,7 @@ export type PriceError = {
|
||||
|
||||
export type PriceMapAndCurrencyCode = {
|
||||
priceMap: Map<string, Map<string, number>>;
|
||||
pricingCurrency: string;
|
||||
billingCurrency: string;
|
||||
};
|
||||
|
||||
export type GetOfferingIdsResponse = {
|
||||
|
Loading…
Reference in New Issue
Block a user