Skip to content

Commit

Permalink
Merge pull request #11 from mr-stringer/9-create-generic-function-to-…
Browse files Browse the repository at this point in the history
…generate-api-enpoints-urls

Fixed incorrect API requested for pssd and pssdv2 disks
  • Loading branch information
mr-stringer authored Sep 3, 2024
2 parents 500b7a9 + d091181 commit 41385bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions getString_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ func TestPricer_GetString(t *testing.T) {
{"GoodPriceType", fields{apg: apiGet, Currency: "GBP", PriceType: "Reservation"}, "https://prices.azure.com/api/retail/prices?CurrencyCode=GBP&$filter=priceType%20eq%20%27Reservation%27", false},
{"GoodArmSkuName", fields{apg: apiGet, Currency: "GBP", ArmSkuName: "Standard_E48ads_v5"}, "https://prices.azure.com/api/retail/prices?CurrencyCode=GBP&$filter=armSkuName%20eq%20%27Standard_E48ads_v5%27", false},
{"GoodCombo", fields{apg: apiGet, Currency: "GBP", ArmRegionName: "uksouth", ArmSkuName: "Standard_E48ads_v5"}, "https://prices.azure.com/api/retail/prices?CurrencyCode=GBP&$filter=armRegionName%20eq%20%27uksouth%27%20and%20armSkuName%20eq%20%27Standard_E48ads_v5%27", false},
{"GoodPssd", fields{apg: apiGet, ApiVersion: "2023-01-01-preview", Currency: "GBP", ArmRegionName: "uksouth", ServiceFamily: "Storage", SkuName: "P10 LRS", ProductName: "Premium SSD Managed Disks", MeterName: "P10 LRS Disk", PriceType: "Consumption"},
"https://prices.azure.com/api/retail/prices?api-version=2023-01-01-preview&CurrencyCode=GBP&$filter=armRegionName%20eq%20%27uksouth%27%20and%20meterName%20eq%20%27P10%20LRS%20Disk%27%20and%20productName%20eq%20%27Premium%20SSD%20Managed%20Disks%27%20and%20skuName%20eq%20%27P10%20LRS%27%20and%20serviceFamily%20eq%20%27Storage%27%20and%20priceType%20eq%20%27Consumption%27", false},
{"NoCurrency", fields{apg: apiGet, Currency: ""}, "", true},
{"GoodPssdv2", fields{apg: apiGet, ApiVersion: "2023-01-01-preview", Currency: "GBP", ArmRegionName: "uksouth", ProductName: "Azure Premium SSD v2", ServiceFamily: "Storage", PriceType: "Consumption"},
"https://prices.azure.com/api/retail/prices?api-version=2023-01-01-preview&CurrencyCode=GBP&$filter=armRegionName%20eq%20%27uksouth%27%20and%20productName%20eq%20%27Azure%20Premium%20SSD%20v2%27%20and%20serviceFamily%20eq%20%27Storage%27%20and%20priceType%20eq%20%27Consumption%27", false},
{"UnsupportedCurrency", fields{apg: apiGet, Currency: "ZOP"}, "", true},
}
for _, tt := range tests {
Expand Down
3 changes: 2 additions & 1 deletion pssd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ func (p Pricer) GetPssdPrice(name, region, currency string) (PssdPrice, error) {
p.ApiVersion = ApiPreview
p.Currency = currency
p.ArmRegionName = region
p.MeterName = fmt.Sprintf("%s LRS Disk", name)
p.ProductName = "Premium SSD Managed Disks"
p.ServiceFamily = "Storage"
p.SkuName = fmt.Sprintf("%s LRS", name)
p.ProductName = fmt.Sprintf("%s LRS Disk", name)
p.PriceType = "Consumption"

s1, err := p.GetString()
Expand Down
4 changes: 2 additions & 2 deletions pssdv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func (p Pricer) GetPssdv2Price(region, currency string) (Pssdv2Price, error) {

p.ApiVersion = ApiPreview
p.Currency = currency
p.ArmRegionName = currency
p.ArmRegionName = region
p.ProductName = "Azure Premium SSD v2"
p.ServiceFamily = "Storage"
p.PriceType = "Consumption"
p.ProductName = "Azure Premium SSD v2"

s1, err := p.GetString()
if err != nil {
Expand Down

0 comments on commit 41385bd

Please sign in to comment.