Skip to content

Commit

Permalink
feat: add missing properties
Browse files Browse the repository at this point in the history
`hcloud.Server.LoadBalancers` and `Datacenter.ServerTypes.AvailableForMigration` were missing, even though they are documented in the API docs.
  • Loading branch information
phm07 committed Dec 5, 2023
1 parent 419834f commit 04cfd08
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 49 deletions.
5 changes: 3 additions & 2 deletions hcloud/datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ type Datacenter struct {

// DatacenterServerTypes represents the server types available and supported in a datacenter.
type DatacenterServerTypes struct {
Supported []*ServerType
Available []*ServerType
Supported []*ServerType
AvailableForMigration []*ServerType
Available []*ServerType
}

// DatacenterClient is a client for the datacenter API.
Expand Down
1 change: 1 addition & 0 deletions hcloud/load_balancer_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type LoadBalancerType struct {
MaxTargets int
MaxAssignedCertificates int
Pricings []LoadBalancerTypeLocationPricing
Deprecated *string
}

// LoadBalancerTypeClient is a client for the Load Balancer types API.
Expand Down
20 changes: 12 additions & 8 deletions hcloud/schema/datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ package schema

// Datacenter defines the schema of a datacenter.
type Datacenter struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Location Location `json:"location"`
ServerTypes struct {
Supported []int64 `json:"supported"`
Available []int64 `json:"available"`
} `json:"server_types"`
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Location Location `json:"location"`
ServerTypes DatacenterServerTypes `json:"server_types"`
}

// DatacenterServerTypes defines the schema of the server types available in a datacenter.
type DatacenterServerTypes struct {
Supported []int64 `json:"supported"`
AvailableForMigration []int64 `json:"available_for_migration"`
Available []int64 `json:"available"`
}

// DatacenterGetResponse defines the schema of the response when retrieving a single datacenter.
Expand Down
1 change: 1 addition & 0 deletions hcloud/schema/load_balancer_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type LoadBalancerType struct {
MaxTargets int `json:"max_targets"`
MaxAssignedCertificates int `json:"max_assigned_certificates"`
Prices []PricingLoadBalancerTypePrice `json:"prices"`
Deprecated *string `json:"deprecated"`
}

// LoadBalancerTypeListResponse defines the schema of the response when
Expand Down
1 change: 1 addition & 0 deletions hcloud/schema/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Server struct {
Volumes []int64 `json:"volumes"`
PrimaryDiskSize int `json:"primary_disk_size"`
PlacementGroup *PlacementGroup `json:"placement_group"`
LoadBalancers []int64 `json:"load_balancers"`
}

// ServerProtection defines the schema of a server's resource protection.
Expand Down
2 changes: 2 additions & 0 deletions hcloud/schema/server_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type ServerType struct {
Architecture string `json:"architecture"`
IncludedTraffic int64 `json:"included_traffic"`
Prices []PricingServerTypePrice `json:"prices"`
// Deprecated: Use Deprecation instead
Deprecated bool `json:"deprecated"`
DeprecatableResource
}

Expand Down
10 changes: 10 additions & 0 deletions hcloud/schema_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
// goverter:extend int64FromServer
// goverter:extend networkFromInt64
// goverter:extend int64FromNetwork
// goverter:extend loadBalancerFromInt64
// goverter:extend int64FromLoadBalancer
// goverter:extend volumeFromInt64
// goverter:extend int64FromVolume
// goverter:extend certificateFromInt64
Expand Down Expand Up @@ -366,6 +368,14 @@ func int64FromNetwork(network Network) int64 {
return network.ID
}

func loadBalancerFromInt64(id int64) LoadBalancer {
return LoadBalancer{ID: id}
}

func int64FromLoadBalancer(lb LoadBalancer) int64 {
return lb.ID
}

func volumeFromInt64(id int64) *Volume {
return &Volume{ID: id}
}
Expand Down
1 change: 1 addition & 0 deletions hcloud/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Server struct {
Volumes []*Volume
PrimaryDiskSize int
PlacementGroup *PlacementGroup
LoadBalancers []*LoadBalancer
}

// ServerProtection represents the protection level of a server.
Expand Down
2 changes: 2 additions & 0 deletions hcloud/server_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type ServerType struct {
// IncludedTraffic is the free traffic per month in bytes
IncludedTraffic int64
Pricings []ServerTypeLocationPricing
// Deprecated: Use DeprecatableResource instead
Deprecated bool
DeprecatableResource
}

Expand Down
113 changes: 74 additions & 39 deletions hcloud/zz_schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 04cfd08

Please sign in to comment.