cli
cli copied to clipboard
Primary IP assignee ID is null in API response but 0 in JSON output
TL;DR
The API Response and JSON output diverge in how they represent the assignee_id field.
Expected behavior
The assignee_id should be null in the json output if the API response is null.
Observed behavior
The assignee_id is 0 in the JSON output when the API response is null
Minimal working example
export HCLOUD_TOKEN="$(get-tmp-hcloud-token)"
hcloud primary-ip create --type ipv4 --name tmp --datacenter fsn1-dc14
HCLOUD_DEBUG=true hcloud primary-ip describe tmp --output json
Log output
--- Request:
GET /v1/primary_ips?name=tmp HTTP/1.1
Host: api.hetzner.cloud
User-Agent: hcloud-cli/1.42.0 hcloud-go/2.6.0
Authorization: REDACTED
Accept-Encoding: gzip
--- Response:
HTTP/2.0 200 OK
Content-Length: 3312
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 1728000
Content-Type: application/json
Date: Tue, 20 Feb 2024 17:53:14 GMT
Link: <https://api.hetzner.cloud/v1/primary_ips?page=1&per_page=25>; rel="last"
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Correlation-Id: 2d0557a4591bcd54
{
"meta": {
"pagination": {
"last_page": 1,
"next_page": null,
"page": 1,
"per_page": 25,
"previous_page": null,
"total_entries": 1
}
},
"primary_ips": [
{
"assignee_id": null,
"assignee_type": "server",
"auto_delete": false,
"blocked": false,
"created": "2024-02-20T17:47:41Z",
"datacenter": {
"description": "Falkenstein 1 virtual DC 14",
"id": 4,
"location": {
"city": "Falkenstein",
"country": "DE",
"description": "Falkenstein DC Park 1",
"id": 1,
"latitude": 50.47612,
"longitude": 12.370071,
"name": "fsn1",
"network_zone": "eu-central"
},
"name": "fsn1-dc14",
"server_types": {
"available": [
1,
3,
5,
7,
9,
22,
23,
24,
25,
26,
45,
93,
94,
95,
96,
97,
98,
99,
100
],
"available_for_migration": [
1,
3,
5,
7,
9,
22,
23,
24,
25,
26,
45,
93,
94,
95,
96,
97,
98,
99,
100,
101
],
"supported": [
9,
7,
5,
3,
1,
22,
23,
24,
25,
26,
45,
93,
94,
95,
96,
97,
98,
99,
100,
101
]
}
},
"dns_ptr": [
{
"ip": "78.46.140.156",
"dns_ptr": "static.156.140.46.78.clients.your-server.de"
}
],
"id": 52324729,
"ip": "78.46.140.156",
"labels": {},
"name": "tmp",
"protection": {
"delete": false
},
"type": "ipv4"
}
]
}
{
"id": 52324729,
"ip": "78.46.140.156",
"labels": {},
"name": "tmp",
"type": "ipv4",
"protection": {
"delete": false
},
"dns_ptr": [
{
"dns_ptr": "static.156.140.46.78.clients.your-server.de",
"ip": "78.46.140.156"
}
],
"assignee_id": 0,
"assignee_type": "server",
"auto_delete": false,
"blocked": false,
"created": "2024-02-20T17:47:41Z",
"datacenter": {
"id": 4,
"name": "fsn1-dc14",
"description": "Falkenstein 1 virtual DC 14",
"location": {
"id": 1,
"name": "fsn1",
"description": "Falkenstein DC Park 1",
"country": "DE",
"city": "Falkenstein",
"latitude": 50.47612,
"longitude": 12.370071,
"network_zone": "eu-central"
},
"server_types": {
"supported": [
9,
7,
5,
3,
1,
22,
23,
24,
25,
26,
45,
93,
94,
95,
96,
97,
98,
99,
100,
101
],
"available_for_migration": [
1,
3,
5,
7,
9,
22,
23,
24,
25,
26,
45,
93,
94,
95,
96,
97,
98,
99,
100,
101
],
"available": [
1,
3,
5,
7,
9,
22,
23,
24,
25,
26,
45,
93,
94,
95,
96,
97,
98,
99,
100
]
}
}
}
Additional information
No response