Skip to content

Commit

Permalink
feat: add missing properties (#349)
Browse files Browse the repository at this point in the history
Multiple properties were missing, even though they are documented in the
API docs.

This PR needs #343 to be
merged first.

Continuation of #347
  • Loading branch information
phm07 committed Dec 12, 2023
1 parent 6feda4d commit c8a28d0
Show file tree
Hide file tree
Showing 8 changed files with 101 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
10 changes: 10 additions & 0 deletions hcloud/schema_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ You can find a documentation of goverter here: https://goverter.jmattheis.de/
// 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 @@ -389,6 +391,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
111 changes: 72 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 c8a28d0

Please sign in to comment.