Skip to content

Commit

Permalink
fix: deprecate PricingPrimaryIPTypePrice.Datacenter for Location
Browse files Browse the repository at this point in the history
  • Loading branch information
byReqz committed Dec 27, 2022
1 parent 168a3a3 commit e3f41ff
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion hcloud/pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ type FloatingIPTypePricing struct {
// PrimaryIPTypePricing defines the schema of pricing information for a primary IP
// type at a datacenter.
type PrimaryIPTypePricing struct {
Datacenter string
Datacenter string // Deprecated: the API does not return pricing for the individual DCs anymore
Location string
Hourly PrimaryIPPrice
Monthly PrimaryIPPrice
}
Expand Down
2 changes: 1 addition & 1 deletion hcloud/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ func PricingFromSchema(s schema.Pricing) Pricing {
var pricings []PrimaryIPTypePricing
for _, price := range primaryIPType.Prices {
p := PrimaryIPTypePricing{
Datacenter: price.Datacenter,
Location: price.Location,
Monthly: PrimaryIPPrice{
Net: price.PriceMonthly.Net,
Gross: price.PriceMonthly.Gross,
Expand Down
3 changes: 2 additions & 1 deletion hcloud/schema/pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ type PricingGetResponse struct {
// PricingPrimaryIPTypePrice defines the schema of pricing information for a primary IP
// type at a datacenter.
type PricingPrimaryIPTypePrice struct {
Datacenter string `json:"location"`
Datacenter string `json:"datacenter"` // Deprecated: the API does not return pricing for the individual DCs anymore
Location string `json:"location"`
PriceHourly Price `json:"price_hourly"`
PriceMonthly Price `json:"price_monthly"`
}
Expand Down
4 changes: 2 additions & 2 deletions hcloud/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2185,8 +2185,8 @@ func TestPricingFromSchema(t *testing.T) {
if len(ip.Pricings) != 1 {
t.Errorf("unexpected number of prices: %d", len(ip.Pricings))
} else {
if ip.Pricings[0].Datacenter != "fsn1" {
t.Errorf("unexpected Datacenter: %v", ip.Pricings[0].Datacenter)
if ip.Pricings[0].Location != "fsn1" {
t.Errorf("unexpected Location: %v", ip.Pricings[0].Location)
}
if ip.Pricings[0].Monthly.Net != "1.0000000000" {
t.Errorf("unexpected Monthly.Net: %v", ip.Pricings[0].Monthly.Net)
Expand Down

0 comments on commit e3f41ff

Please sign in to comment.