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 a5cd797 commit eec1993
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 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:"datacenter"`
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
6 changes: 3 additions & 3 deletions hcloud/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,7 @@ func TestPricingFromSchema(t *testing.T) {
{
"prices": [
{
"datacenter": "fsn1-dc8",
"location": "fsn1",
"price_hourly": {
"gross": "1.1900000000000000",
"net": "1.0000000000"
Expand Down 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-dc8" {
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 eec1993

Please sign in to comment.