Skip to content
Open
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
10 changes: 0 additions & 10 deletions hcloud/primary_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ type PrimaryIP struct {
Blocked bool
Created time.Time
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
}

func (o *PrimaryIP) pathID() (string, error) {
Expand Down Expand Up @@ -105,11 +100,6 @@ type PrimaryIPCreateOpts struct {
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
10 changes: 0 additions & 10 deletions hcloud/schema/primary_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ type PrimaryIP struct {
Blocked bool `json:"blocked"`
Created time.Time `json:"created"`
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 @@ -45,11 +40,6 @@ type PrimaryIPCreateRequest struct {
Labels *map[string]string `json:"labels,omitempty"`
AutoDelete *bool `json:"auto_delete,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
10 changes: 0 additions & 10 deletions hcloud/schema/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ type Server struct {
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 @@ -117,11 +112,6 @@ 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
20 changes: 0 additions & 20 deletions hcloud/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ 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
}

func (o *Server) pathID() (string, error) {
Expand Down Expand Up @@ -316,11 +311,6 @@ 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 All @@ -346,9 +336,6 @@ func (o ServerCreateOpts) Validate() error {
if o.Image == nil || (o.Image.ID == 0 && o.Image.Name == "") {
return missingField(o, "Image")
}
if o.Location != nil && o.Datacenter != nil {
return mutuallyExclusiveFields(o, "Location", "Datacenter")
}
return nil
}

Expand Down Expand Up @@ -421,13 +408,6 @@ func (c *ServerClient) Create(ctx context.Context, opts ServerCreateOpts) (Serve
reqBody.Location = opts.Location.Name
}
}
if opts.Datacenter != nil {
if opts.Datacenter.ID != 0 {
reqBody.Datacenter = strconv.FormatInt(opts.Datacenter.ID, 10) // nolint:staticcheck // Deprecated
} else {
reqBody.Datacenter = opts.Datacenter.Name // nolint:staticcheck // Deprecated
}
}
if opts.PlacementGroup != nil {
reqBody.PlacementGroup = opts.PlacementGroup.ID
}
Expand Down
102 changes: 0 additions & 102 deletions hcloud/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,38 +125,6 @@ func TestServerClientGetByID(t *testing.T) {
}
]
},
"datacenter": {
"id": 3,
"description": "Helsinki 1 virtual DC 2",
"location": {
"id": 3,
"name": "hel1",
"description": "Helsinki DC Park 1",
"city": "Helsinki",
"country": "FI",
"latitude": 60.169855,
"longitude": 24.938379,
"network_zone": "eu-central"
},
"name": "hel1-dc2",
"server_types": {
"available": [
22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 45, 93, 94, 95, 96, 97, 98,
99, 100, 101, 102, 104, 105, 108, 109, 110, 111, 112, 113, 114, 115,
116, 117
],
"available_for_migration": [
22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 45, 93, 94, 95, 96, 97, 98,
99, 100, 101, 102, 104, 105, 108, 109, 110, 111, 112, 113, 114, 115,
116, 117
],
"supported": [
1, 3, 5, 7, 9, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 33, 34, 35, 36, 37, 38, 45, 93, 94, 95, 96, 97, 98, 99, 100, 101,
104, 105, 106, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117
]
}
},
"location": {
"id": 3,
"name": "hel1",
Expand Down Expand Up @@ -237,8 +205,6 @@ func TestServerClientGetByID(t *testing.T) {
assert.Equal(t, ServerStatusRunning, result.Status)
assert.Equal(t, int64(104), result.ServerType.ID)
assert.Equal(t, "cx22", result.ServerType.Name)
assert.Equal(t, int64(3), result.Datacenter.ID)
assert.Equal(t, "hel1-dc2", result.Datacenter.Name)
assert.Equal(t, int64(3), result.Location.ID)
assert.Equal(t, "hel1", result.Location.Name)
assert.Equal(t, int64(310554929), result.Image.ID)
Expand Down Expand Up @@ -870,74 +836,6 @@ func TestServersCreateWithDefaultPublicNet(t *testing.T) {
}
}

func TestServersCreateWithDatacenterID(t *testing.T) {
env := newTestEnv()
defer env.Teardown()

env.Mux.HandleFunc("/servers", func(w http.ResponseWriter, r *http.Request) {
var reqBody schema.ServerCreateRequest
if err := json.NewDecoder(r.Body).Decode(&reqBody); err != nil {
t.Fatal(err)
}
if reqBody.Datacenter != "1" { // nolint:staticcheck // Deprecated
t.Errorf("unexpected datacenter: %v", reqBody.Datacenter) // nolint:staticcheck // Deprecated
}
json.NewEncoder(w).Encode(schema.ServerCreateResponse{
Server: schema.Server{
ID: 1,
},
})
})

ctx := context.Background()
result, _, err := env.Client.Server.Create(ctx, ServerCreateOpts{
Name: "test",
ServerType: &ServerType{ID: 1},
Image: &Image{ID: 2},
Datacenter: &Datacenter{ID: 1},
})
if err != nil {
t.Fatal(err)
}
if result.Server == nil {
t.Fatal("no server")
}
}

func TestServersCreateWithDatacenterName(t *testing.T) {
env := newTestEnv()
defer env.Teardown()

env.Mux.HandleFunc("/servers", func(w http.ResponseWriter, r *http.Request) {
var reqBody schema.ServerCreateRequest
if err := json.NewDecoder(r.Body).Decode(&reqBody); err != nil {
t.Fatal(err)
}
if reqBody.Datacenter != "dc1" { // nolint:staticcheck // Deprecated
t.Errorf("unexpected datacenter: %v", reqBody.Datacenter) // nolint:staticcheck // Deprecated
}
json.NewEncoder(w).Encode(schema.ServerCreateResponse{
Server: schema.Server{
ID: 1,
},
})
})

ctx := context.Background()
result, _, err := env.Client.Server.Create(ctx, ServerCreateOpts{
Name: "test",
ServerType: &ServerType{ID: 1},
Image: &Image{ID: 2},
Datacenter: &Datacenter{Name: "dc1"},
})
if err != nil {
t.Fatal(err)
}
if result.Server == nil {
t.Fatal("no server")
}
}

func TestServersCreateWithLocationID(t *testing.T) {
env := newTestEnv()
defer env.Teardown()
Expand Down
31 changes: 0 additions & 31 deletions hcloud/zz_schema_converter.go

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

Loading