-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0279311
commit deed68a
Showing
14 changed files
with
347 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
arm-estimator/Products/AppService/AppServicePlanEstimationCalculation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
arm-estimator/Products/ContainerApps/ContainerAppsEstimationCalculation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
arm-estimator/Products/ContainerRegistry/ContainerRegistryEstimationCalculation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
internal class SQLEstimationCalculation : BaseEstimation, IEstimationCalculation | ||
{ | ||
public SQLEstimationCalculation(RetailItem[] items, WhatIfAfterChange change) | ||
: base(items, change) | ||
{ | ||
} | ||
|
||
public IOrderedEnumerable<RetailItem> GetItems() | ||
{ | ||
var consumptionMetrics = this.items.Where(_ => _.type != "Reservation"); | ||
|
||
return this.items.Where(_ => _.type != "Reservation").OrderByDescending(_ => _.retailPrice); | ||
} | ||
|
||
public double GetTotalCost() | ||
{ | ||
double? estimatedCost = 0; | ||
var items = GetItems(); | ||
|
||
foreach(var item in items) | ||
{ | ||
// B DTUs | ||
if(item.meterId == "cae64797-9ecf-4906-b517-6238c80c045f") | ||
{ | ||
estimatedCost += item.retailPrice * 30; | ||
} | ||
// S0 DTUs | ||
else if (item.meterId == "a149966f-73b4-4e1d-b335-d2a572b1e6bd") | ||
{ | ||
estimatedCost += item.retailPrice * 30; | ||
} | ||
// S1 DTUs | ||
else if (item.meterId == "54c6bbf3-322b-406d-8411-101bc4b9443a") | ||
{ | ||
estimatedCost += item.retailPrice * 30; | ||
} | ||
// S2 DTUs | ||
else if (item.meterId == "f303a21a-05f1-4563-b2ad-7523eebc4058") | ||
{ | ||
estimatedCost += item.retailPrice * 30; | ||
} | ||
// S3 DTUs | ||
else if (item.meterId == "6bafdc11-b964-4895-9d4e-a0e548db1b2b") | ||
{ | ||
estimatedCost += item.retailPrice * 30; | ||
} | ||
// 10 DTU - everything above S3 | ||
else if (item.meterId == "94aaed62-bf2f-4461-8f69-078933cb2f72") | ||
{ | ||
estimatedCost += item.retailPrice * 30; | ||
} | ||
else | ||
{ | ||
estimatedCost += item.retailPrice; | ||
} | ||
} | ||
|
||
return estimatedCost == null ? 0 : (double)estimatedCost; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Microsoft.Extensions.Logging; | ||
|
||
internal class SQLQueryFilter : IQueryFilter | ||
{ | ||
private const string ServiceId = "DZH3180HX10K"; | ||
|
||
private readonly WhatIfAfterChange afterState; | ||
private readonly ILogger logger; | ||
|
||
public SQLQueryFilter(WhatIfAfterChange afterState, ILogger logger) | ||
{ | ||
this.afterState = afterState; | ||
this.logger = logger; | ||
} | ||
|
||
public string? GetFiltersBasedOnDesiredState() | ||
{ | ||
var location = this.afterState.location; | ||
var sku = this.afterState.sku?.name; | ||
if (sku == null) | ||
{ | ||
this.logger.LogError("Can't create a filter for Azure SQL when SKU is unavailable."); | ||
return null; | ||
} | ||
|
||
var skuIds = SQLSupportedData.SkuToSkuIdMap[sku]; | ||
var skuIdsFilter = string.Join(" or ", skuIds.Select(_ => $"skuId eq '{_}'")); | ||
|
||
return $"$filter=serviceId eq '{ServiceId}' and armRegionName eq '{location}' and ({skuIdsFilter})"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Microsoft.Extensions.Logging; | ||
|
||
internal class SQLRetailQuery : BaseRetailQuery, IRetailQuery | ||
{ | ||
public SQLRetailQuery(WhatIfChange change, ILogger logger) | ||
: base(change, logger) | ||
{ | ||
} | ||
|
||
public string? GetQueryUrl() | ||
{ | ||
if (this.change.after == null) | ||
{ | ||
this.logger.LogError("Can't generate Retail API query if desired state is unavailable."); | ||
return null; | ||
} | ||
|
||
var filter = new SQLQueryFilter(this.change.after, this.logger).GetFiltersBasedOnDesiredState(); | ||
return $"https://prices.azure.com/api/retail/prices?{filter}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
internal class SQLSupportedData | ||
{ | ||
public static readonly IReadOnlyDictionary<string, string[]> SkuToSkuIdMap = new Dictionary<string, string[]>() | ||
{ | ||
{ "Free", new[] { | ||
"DZH318Z0BQH9/0013" | ||
} | ||
}, | ||
{ "Basic", new[] { | ||
"DZH318Z0BQGZ/004K" | ||
} | ||
}, | ||
{ "S0", new[] { | ||
"DZH318Z0BQHF/00LB" | ||
} | ||
}, | ||
{ "S1", new[] { | ||
"DZH318Z0BQHF/00LT" | ||
} | ||
}, | ||
{ "S2", new[] { | ||
"DZH318Z0BQHF/017X" | ||
} | ||
}, | ||
{ "S3", new[] { | ||
"DZH318Z0BQHF/00TX" | ||
} | ||
}, | ||
{ "S4", new[] { | ||
"DZH318Z0BQHF/014D" | ||
} | ||
}, | ||
{ "S6", new[] { | ||
"DZH318Z0BQHF/00TZ" | ||
} | ||
}, | ||
{ "S7", new[] { | ||
"DZH318Z0BQHF/012N" | ||
} | ||
}, | ||
{ "S9", new[] { | ||
"DZH318Z0BQHF/00SQ" | ||
} | ||
}, | ||
{ "S12", new[] { | ||
"DZH318Z0BQHF/00LJ" | ||
} | ||
} | ||
}; | ||
|
||
public static readonly IReadOnlyDictionary<string, int> SkuToDTUsMap = new Dictionary<string, int>() | ||
{ | ||
{ "S4", 200 }, | ||
{ "S6", 400 }, | ||
{ "S7", 800 }, | ||
{ "S9", 1600 }, | ||
{ "S12", 3000 } | ||
}; | ||
} |
4 changes: 2 additions & 2 deletions
4
arm-estimator/Products/StorageAccount/StorageAccountEstimationCalculation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.