Skip to content

Commit ad5a7b6

Browse files
lukasmetznerjooola
andauthored
feat(primary-ip): --assignee-type is optional when creating a Primary IP (#1395)
#### Primary IPs `assignee_type` behavior change As of 1 August 2026, the behavior of the Primary IP `assignee_type` property will change, and will return `unassigned` when the Primary IP is not assigned (when `assignee_id` is `null`). The goal is to eventually assign Primary IPs to other resource types, not only to `server`. See the [changelog](https://docs.hetzner.cloud/changelog#2026-04-27-primary-ips-will-return-unassigned) for more details. In addition, the Primary IP request body `assignee_type` property of the operation [`POST /v1/primary_ips`](https://docs.hetzner.cloud/reference/cloud#tag/primary-ips/create_primary_ip) is now optional. Primary IPs created without `assignee_type` return `server` until 1 August 2026, after this date, its value will be `unassigned`. See the [changelog](https://docs.hetzner.cloud/changelog#2026-04-27-primary-ips-make-assignee_type-optional) for more details. --------- Co-authored-by: jo <ljonas@riseup.net>
1 parent a518481 commit ad5a7b6

3 files changed

Lines changed: 40 additions & 17 deletions

File tree

docs/reference/manual/hcloud_primary-ip_create.md

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/primaryip/create.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ var CreateCmd = base.CreateCmd[*hcloud.PrimaryIP]{
2222
Long: `Create a Primary IP.
2323
2424
The --datacenter flag is deprecated. Use --location or --assignee-id instead.
25-
See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.`,
25+
See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.
26+
27+
The --assignee-type flag will be required together with the --assignee-id flag. Using
28+
the default value (server) for the --assignee-type flag is deprecated. Consider
29+
explicitly setting the --assignee-type flag.
30+
31+
See https://docs.hetzner.cloud/changelog#2026-04-27-primary-ips-will-return-unassigned
32+
and https://docs.hetzner.cloud/changelog#2026-04-27-primary-ips-make-assignee_type-optional.
33+
`,
2634
TraverseChildren: true,
2735
DisableFlagsInUseLine: true,
2836
}
@@ -71,13 +79,22 @@ See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.`,
7179
}
7280

7381
createOpts := hcloud.PrimaryIPCreateOpts{
74-
Type: hcloud.PrimaryIPType(typ),
75-
Name: name,
76-
AssigneeType: assigneeType,
77-
Labels: labels,
82+
Type: hcloud.PrimaryIPType(typ),
83+
Name: name,
84+
Labels: labels,
7885
}
7986
if assigneeID != 0 {
8087
createOpts.AssigneeID = &assigneeID
88+
if !cmd.Flags().Changed("assignee-type") {
89+
cmd.PrintErrln(
90+
"Warning: " +
91+
"The --assignee-type flag will be required together " +
92+
"with the --assignee-id flag and will no longer default " +
93+
"to 'server'. Consider explicitly setting the " +
94+
"--assignee-type flag.",
95+
)
96+
}
97+
createOpts.AssigneeType = assigneeType
8198
}
8299
if cmd.Flags().Changed("auto-delete") {
83100
createOpts.AutoDelete = &autoDelete

internal/cmd/primaryip/create_test.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ func TestCreate(t *testing.T) {
3737
Create(
3838
gomock.Any(),
3939
hcloud.PrimaryIPCreateOpts{
40-
Name: "my-ip",
41-
Type: "ipv4",
42-
Location: "fsn1",
43-
Labels: map[string]string{"foo": "bar"},
44-
AssigneeType: "server",
45-
AutoDelete: hcloud.Ptr(true),
40+
Name: "my-ip",
41+
Type: "ipv4",
42+
Location: "fsn1",
43+
Labels: map[string]string{"foo": "bar"},
44+
AutoDelete: hcloud.Ptr(true),
4645
},
4746
).
4847
Return(
@@ -107,12 +106,11 @@ func TestCreateJSON(t *testing.T) {
107106
Create(
108107
gomock.Any(),
109108
hcloud.PrimaryIPCreateOpts{
110-
Name: "my-ip",
111-
Type: "ipv4",
112-
Location: "fsn1",
113-
Labels: map[string]string{"foo": "bar"},
114-
AssigneeType: "server",
115-
AutoDelete: hcloud.Ptr(true),
109+
Name: "my-ip",
110+
Type: "ipv4",
111+
Location: "fsn1",
112+
Labels: map[string]string{"foo": "bar"},
113+
AutoDelete: hcloud.Ptr(true),
116114
},
117115
).
118116
Return(

0 commit comments

Comments
 (0)