Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions hcloud/primary_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ type PrimaryIP struct {
AutoDelete bool
Blocked bool
Created time.Time
Datacenter *Datacenter
Location *Location

// Deprecated: [PrimaryIP.Datacenter] is deprecated and will be removed after 1 July 2026.
// Use [PrimaryIP.Location] instead.
// See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters
Datacenter *Datacenter
}

// PrimaryIPProtection represents the protection level of a Primary IP.
Expand Down Expand Up @@ -88,10 +93,15 @@ type PrimaryIPCreateOpts struct {
AssigneeID *int64
AssigneeType string
AutoDelete *bool
Datacenter string
Location string
Labels map[string]string
Name string
Type PrimaryIPType

// Deprecated: [PrimaryIPCreateOpts.Datacenter] is deprecated and will be removed after 1 July 2026.
// Use [PrimaryIPCreateOpts.Location] instead.
// See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters
Datacenter string
}

// PrimaryIPCreateResult defines the response
Expand Down
4 changes: 2 additions & 2 deletions hcloud/primary_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func TestPrimaryIPClient(t *testing.T) {
Name: "my-primary-ip",
Type: "ipv4",
AssigneeType: "server",
Datacenter: "fsn-dc14",
Location: "fsn1",
Labels: Ptr(map[string]string{"key": "value"}),
}
if err := json.NewDecoder(r.Body).Decode(&reqBody); err != nil {
Expand All @@ -327,7 +327,7 @@ func TestPrimaryIPClient(t *testing.T) {
Type: PrimaryIPTypeIPv4,
AssigneeType: "server",
Labels: map[string]string{"key": "value"},
Datacenter: "fsn-dc14",
Location: "fsn1",
}

result, resp, err := env.Client.PrimaryIP.Create(ctx, opts)
Expand Down
14 changes: 12 additions & 2 deletions hcloud/schema/primary_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ type PrimaryIP struct {
AutoDelete bool `json:"auto_delete"`
Blocked bool `json:"blocked"`
Created time.Time `json:"created"`
Datacenter Datacenter `json:"datacenter"`
Location Location `json:"location"`

// Deprecated: [PrimaryIP.Datacenter] is deprecated and will be removed after 1 July 2026.
// Use [PrimaryIP.Location] instead.
// See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters
Datacenter *Datacenter `json:"datacenter"`
}

// PrimaryIPProtection represents the protection level of a Primary IP.
Expand All @@ -40,7 +45,12 @@ type PrimaryIPCreateRequest struct {
AssigneeID *int64 `json:"assignee_id,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
AutoDelete *bool `json:"auto_delete,omitempty"`
Datacenter string `json:"datacenter,omitempty"`
Location string `json:"location,omitempty"`

// Deprecated: [PrimaryIPCreateRequest.Datacenter] is deprecated and will be removed after 1 July 2026.
// Use [PrimaryIPCreateRequest.Location] instead.
// See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters
Datacenter string `json:"datacenter,omitempty"`
}

// PrimaryIPCreateResponse defines the schema of the response
Expand Down
13 changes: 11 additions & 2 deletions hcloud/schema/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ type Server struct {
RescueEnabled bool `json:"rescue_enabled"`
ISO *ISO `json:"iso"`
Locked bool `json:"locked"`
Datacenter Datacenter `json:"datacenter"`
Location Location `json:"location"`
Image *Image `json:"image"`
Protection ServerProtection `json:"protection"`
Labels map[string]string `json:"labels"`
Volumes []int64 `json:"volumes"`
PrimaryDiskSize int `json:"primary_disk_size"`
PlacementGroup *PlacementGroup `json:"placement_group"`
LoadBalancers []int64 `json:"load_balancers"`

// Deprecated: [Server.Datacenter] is deprecated and will be removed after 1 July 2026.
// Use [Server.Location] instead.
// See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters
Datacenter *Datacenter `json:"datacenter"`
}

// ServerProtection defines the schema of a server's resource protection.
Expand Down Expand Up @@ -103,7 +108,6 @@ type ServerCreateRequest struct {
Image IDOrName `json:"image"`
SSHKeys []int64 `json:"ssh_keys,omitempty"`
Location string `json:"location,omitempty"`
Datacenter string `json:"datacenter,omitempty"`
UserData string `json:"user_data,omitempty"`
StartAfterCreate *bool `json:"start_after_create,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
Expand All @@ -113,6 +117,11 @@ type ServerCreateRequest struct {
Firewalls []ServerCreateFirewalls `json:"firewalls,omitempty"`
PlacementGroup int64 `json:"placement_group,omitempty"`
PublicNet *ServerCreatePublicNet `json:"public_net,omitempty"`

// Deprecated: [ServerCreateRequest.Datacenter] is deprecated and will be removed after 1 July 2026.
// Use [ServerCreateRequest.Location] instead.
// See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters
Datacenter string `json:"datacenter,omitempty"`
}

// ServerCreatePublicNet defines the public network configuration of a server.
Expand Down
17 changes: 13 additions & 4 deletions hcloud/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Server struct {
PublicNet ServerPublicNet
PrivateNet []ServerPrivateNet
ServerType *ServerType
Datacenter *Datacenter
Location *Location
IncludedTraffic uint64
OutgoingTraffic uint64
IngoingTraffic uint64
Expand All @@ -37,6 +37,11 @@ type Server struct {
PrimaryDiskSize int
PlacementGroup *PlacementGroup
LoadBalancers []*LoadBalancer

// Deprecated: [Server.Datacenter] is deprecated and will be removed after 1 July 2026.
// Use [Server.Location] instead.
// See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters
Datacenter *Datacenter
}

// ServerProtection represents the protection level of a server.
Expand Down Expand Up @@ -292,7 +297,6 @@ type ServerCreateOpts struct {
Image *Image
SSHKeys []*SSHKey
Location *Location
Datacenter *Datacenter
UserData string
StartAfterCreate *bool
Labels map[string]string
Expand All @@ -302,6 +306,11 @@ type ServerCreateOpts struct {
Firewalls []*ServerCreateFirewall
PlacementGroup *PlacementGroup
PublicNet *ServerCreatePublicNet

// Deprecated: [ServerCreateOpts.Datacenter] is deprecated and will be removed after 1 July 2026.
// Use [ServerCreateOpts.Location] instead.
// See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters
Datacenter *Datacenter
}

type ServerCreatePublicNet struct {
Expand Down Expand Up @@ -404,9 +413,9 @@ func (c *ServerClient) Create(ctx context.Context, opts ServerCreateOpts) (Serve
}
if opts.Datacenter != nil {
if opts.Datacenter.ID != 0 {
reqBody.Datacenter = strconv.FormatInt(opts.Datacenter.ID, 10)
reqBody.Datacenter = strconv.FormatInt(opts.Datacenter.ID, 10) // nolint:staticcheck // Deprecated
} else {
reqBody.Datacenter = opts.Datacenter.Name
reqBody.Datacenter = opts.Datacenter.Name // nolint:staticcheck // Deprecated
}
}
if opts.PlacementGroup != nil {
Expand Down
Loading