From ff437f404dd9231a982af24bbb8a6b5d150c4cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6stler?= Date: Sun, 24 Aug 2025 23:45:17 +0200 Subject: [PATCH 1/8] Schema: Include server URLs for each path --- openapi/hcloud.json | 912 +++++++++++++++++++++++++++++++++++++------- src/index.ts | 35 +- 2 files changed, 815 insertions(+), 132 deletions(-) diff --git a/openapi/hcloud.json b/openapi/hcloud.json index 7543a8e..c2ddac8 100644 --- a/openapi/hcloud.json +++ b/openapi/hcloud.json @@ -6,7 +6,7 @@ }, "description": "Copied from the official API documentation for the Public Hetzner Cloud.", "title": "Hetzner Cloud API", - "version": "4f5630d-dirty" + "version": "4575182-dirty" }, "servers": [ { @@ -6865,7 +6865,12 @@ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Action.AllWithOpts(ctx, hcloud.ActionListOpts{ID: []int64{123, 456}})\n}" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/actions/{id}": { "get": { @@ -6914,7 +6919,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.actions.get_by_id(123)" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/certificates": { "get": { @@ -7246,7 +7256,12 @@ "source": "hcloud certificate create \\\n --name \"my website cert\" \\\n --type uploaded \\\n --cert-file my-cert.pem \\\n --key-file my-key.pem" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/certificates/{id}": { "delete": { @@ -7460,7 +7475,12 @@ "source": "hcloud certificate update $CERTIFICATE --name \"my website cert\"\nhcloud certificate add-label --overwrite $CERTIFICATE \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud certificate remove-label $CERTIFICATE \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/certificates/{id}/actions": { "get": { @@ -7601,7 +7621,12 @@ "tags": [ "certificates" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/certificates/{id}/actions/{action_id}": { "get": { @@ -7671,7 +7696,12 @@ "tags": [ "certificates" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/certificates/{id}/actions/retry": { "post": { @@ -7745,7 +7775,12 @@ "source": "hcloud certificate retry $CERTIFICATE" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/certificates/actions": { "get": { @@ -7868,7 +7903,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.certificates.actions.get_all()" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/certificates/actions/{id}": { "get": { @@ -7917,7 +7957,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.certificates.actions.get_by_id(123)" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/datacenters": { "get": { @@ -8011,7 +8056,12 @@ "source": "hcloud datacenter list" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/datacenters/{id}": { "get": { @@ -8065,7 +8115,12 @@ "source": "hcloud datacenter describe $DATACENTER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/firewalls": { "get": { @@ -8244,7 +8299,12 @@ "source": "hcloud firewall create \\\n --name \"Corporate Intranet Protection\" \\\n --label \"env=dev\" \\\n --rules-file <(echo '[\n {\n \"description\": \"Allow port 80\",\n \"direction\": \"in\",\n \"port\": \"80\",\n \"protocol\": \"tcp\",\n \"source_ips\": [\n \"28.239.13.1/32\",\n \"28.239.14.0/24\",\n \"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b/128\"\n ]\n }\n]')" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/firewalls/{id}": { "delete": { @@ -8404,7 +8464,12 @@ "source": "hcloud firewall update $FIREWALL --name \"new-name\"\nhcloud firewall add-label --overwrite $FIREWALL \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud firewall remove-label $FIREWALL \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/firewalls/{id}/actions": { "get": { @@ -8545,7 +8610,12 @@ "tags": [ "firewalls" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/firewalls/{id}/actions/{action_id}": { "get": { @@ -8615,7 +8685,12 @@ "tags": [ "firewalls" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/firewalls/{id}/actions/apply_to_resources": { "post": { @@ -8714,7 +8789,12 @@ "source": "hcloud firewall apply-to-resource $FIREWALL \\\n --type server \\\n --server $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/firewalls/{id}/actions/remove_from_resources": { "post": { @@ -8813,7 +8893,12 @@ "source": "hcloud firewall remove-from-resource $FIREWALL \\\n --type server \\\n --server $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/firewalls/{id}/actions/set_rules": { "post": { @@ -8935,7 +9020,12 @@ "source": "hcloud firewall replace-rules $FIREWALL --rules-file <(echo '[\n {\n \"description\": \"Allow port 80\",\n \"direction\": \"in\",\n \"port\": \"80\",\n \"protocol\": \"tcp\",\n \"source_ips\": [\n \"28.239.13.1/32\",\n \"28.239.14.0/24\",\n \"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b/128\"\n ]\n }\n]')" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/firewalls/actions": { "get": { @@ -9058,7 +9148,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.firewalls.actions.get_all()" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/firewalls/actions/{id}": { "get": { @@ -9107,7 +9202,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.firewalls.actions.get_by_id(123)" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/floating_ips": { "get": { @@ -9309,7 +9409,12 @@ "source": "hcloud floating-ip create \\\n --description \"This describes my resource\" \\\n --home-location fsn1 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name my-resource \\\n --server 42 \\\n --type ipv4" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/floating_ips/{id}": { "delete": { @@ -9503,7 +9608,12 @@ "source": "hcloud floating-ip update $FLOATINGIP \\\n --description \"This describes my resource\" \\\n --name my-resource\nhcloud floating-ip add-label --overwrite $FLOATINGIP \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud floating-ip remove-label $FLOATINGIP \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/floating_ips/{id}/actions": { "get": { @@ -9647,7 +9757,12 @@ "tags": [ "floating_ips" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/floating_ips/{id}/actions/{action_id}": { "get": { @@ -9721,7 +9836,12 @@ "tags": [ "floating_ips" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/floating_ips/{id}/actions/assign": { "post": { @@ -9808,7 +9928,12 @@ "source": "hcloud floating-ip assign $FLOATINGIP $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/floating_ips/{id}/actions/change_dns_ptr": { "post": { @@ -9892,7 +10017,12 @@ "source": "hcloud floating-ip set-rdns $FLOATINGIP \\\n --ip 2001:db8::1 \\\n --hostname server.example.com" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/floating_ips/{id}/actions/change_protection": { "post": { @@ -9975,7 +10105,12 @@ "source": "hcloud floating-ip enable-protection $FLOATINGIP delete\nhcloud floating-ip disable-protection $FLOATINGIP delete" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/floating_ips/{id}/actions/unassign": { "post": { @@ -10053,7 +10188,12 @@ "source": "hcloud floating-ip unassign $FLOATINGIP" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/floating_ips/actions": { "get": { @@ -10176,7 +10316,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.floating_ips.actions.get_all()" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/floating_ips/actions/{id}": { "get": { @@ -10225,7 +10370,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.floating_ips.actions.get_by_id(123)" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/images": { "get": { @@ -10406,7 +10556,12 @@ "source": "hcloud image list" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/images/{id}": { "delete": { @@ -10595,7 +10750,12 @@ "source": "hcloud image update $IMAGE --description \"My new Image description\"\nhcloud image add-label --overwrite $IMAGE \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud image remove-label $IMAGE \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/images/{id}/actions": { "get": { @@ -10735,7 +10895,12 @@ "tags": [ "images" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/images/{id}/actions/{action_id}": { "get": { @@ -10805,7 +10970,12 @@ "tags": [ "images" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/images/{id}/actions/change_protection": { "post": { @@ -10888,7 +11058,12 @@ "source": "hcloud image enable-protection $IMAGE delete\nhcloud image disable-protection $IMAGE delete" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/images/actions": { "get": { @@ -11011,7 +11186,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.images.actions.get_all()" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/images/actions/{id}": { "get": { @@ -11060,7 +11240,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.images.actions.get_by_id(123)" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/isos": { "get": { @@ -11158,7 +11343,12 @@ "source": "hcloud iso list" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/isos/{id}": { "get": { @@ -11212,7 +11402,12 @@ "source": "hcloud iso describe $ISO" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancer_types": { "get": { @@ -11286,7 +11481,12 @@ "source": "hcloud load-balancer-type list" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancer_types/{id}": { "get": { @@ -11340,7 +11540,12 @@ "source": "hcloud load-balancer-type describe $LOADBALANCERTYPE" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers": { "get": { @@ -11645,7 +11850,12 @@ "source": "hcloud load-balancer create \\\n --algorithm-type round_robin \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --type lb11 \\\n --location fsn1 \\\n --name \"Web Frontend\"\n\nhcloud load-balancer enable-public-interface \"Web Frontend\"\n\nhcloud load-balancer add-service \"Web Frontend\" \\\n --destination-port 80 \\\n --health-check-http-domain example.com \\\n --health-check-http-path \"/\" \\\n --health-check-http-response '{\"status\": \"ok\"}' \\\n --health-check-http-status-codes \"2??,3??\" \\\n --health-check-http-tls=false \\\n --health-check-interval 15s \\\n --health-check-port 4711 \\\n --health-check-protocol http \\\n --health-check-retries 3 \\\n --health-check-timeout 10s \\\n --http-certificates 897 \\\n --http-cookie-lifetime 300s \\\n --http-cookie-name HCLBSTICKY \\\n --http-redirect-http=true \\\n --http-sticky-sessions=true \\\n --listen-port 443 \\\n --protocol https \\\n --proxy-protocol=false\n\nhcloud load-balancer add-target \"Web Frontend\" --ip 203.0.113.1\nhcloud load-balancer add-target \"Web Frontend\" --label-selector \"env=prod\"\nhcloud load-balancer add-target \"Web Frontend\" --server 80 --use-private-ip" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}": { "delete": { @@ -11946,7 +12156,12 @@ "source": "hcloud load-balancer update $LOADBALANCER --name new-name\nhcloud load-balancer add-label --overwrite $LOADBALANCER \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud load-balancer remove-label $LOADBALANCER \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions": { "get": { @@ -12086,7 +12301,12 @@ "tags": [ "load_balancers" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/{action_id}": { "get": { @@ -12156,7 +12376,12 @@ "tags": [ "load_balancers" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/add_service": { "post": { @@ -12239,7 +12464,12 @@ "source": "hcloud load-balancer add-service $LOADBALANCER \\\n --destination-port 80 \\\n --health-check-http-domain example.com \\\n --health-check-http-path \"/\" \\\n --health-check-http-response '{\"status\": \"ok\"}' \\\n --health-check-http-status-codes \"2??,3??\" \\\n --health-check-http-tls=false \\\n --health-check-interval 15s \\\n --health-check-port 4711 \\\n --health-check-protocol http \\\n --health-check-retries 3 \\\n --health-check-timeout 10s \\\n --http-certificates 897 \\\n --http-cookie-lifetime 300s \\\n --http-cookie-name HCLBSTICKY \\\n --http-redirect-http=true \\\n --http-sticky-sessions=true \\\n --listen-port 443 \\\n --protocol https \\\n --proxy-protocol=false" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/add_target": { "post": { @@ -12322,7 +12552,12 @@ "source": "hcloud load-balancer add-target $LOADBALANCER --ip 203.0.113.1\nhcloud load-balancer add-target $LOADBALANCER --label-selector \"env=prod\"\nhcloud load-balancer add-target $LOADBALANCER --server 80 --use-private-ip" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/attach_to_network": { "post": { @@ -12405,7 +12640,12 @@ "source": "hcloud load-balancer attach-to-network $LOADBALANCER \\\n --ip 10.0.1.1 \\\n --network 4711" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/change_algorithm": { "post": { @@ -12488,7 +12728,12 @@ "source": "hcloud load-balancer change-algorithm $LOADBALANCER \\\n --algorithm-type round_robin" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/change_dns_ptr": { "post": { @@ -12572,7 +12817,12 @@ "source": "hcloud load-balancer set-rdns $LOADBALANCER \\\n --ip 1.2.3.4 \\\n --hostname lb1.example.com" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/change_protection": { "post": { @@ -12655,7 +12905,12 @@ "source": "hcloud load-balancer enable-protection $LOADBALANCER delete\nhcloud load-balancer disable-protection $LOADBALANCER delete" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/change_type": { "post": { @@ -12738,7 +12993,12 @@ "source": "hcloud load-balancer change-type $LOADBALANCER lb21" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/delete_service": { "post": { @@ -12821,7 +13081,12 @@ "source": "hcloud load-balancer delete-service $LOADBALANCER \\\n --listen-port 443" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/detach_from_network": { "post": { @@ -12908,7 +13173,12 @@ "source": "hcloud load-balancer detach-from-network $LOADBALANCER \\\n --network $NETWORK" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/disable_public_interface": { "post": { @@ -12986,7 +13256,12 @@ "source": "hcloud load-balancer disable-public-interface $LOADBALANCER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/enable_public_interface": { "post": { @@ -13064,7 +13339,12 @@ "source": "hcloud load-balancer enable-public-interface $LOADBALANCER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/remove_target": { "post": { @@ -13147,7 +13427,12 @@ "source": "hcloud load-balancer remove-target $LOADBALANCER --ip 203.0.113.1\nhcloud load-balancer remove-target $LOADBALANCER --label-selector \"env=prod\"\nhcloud load-balancer remove-target $LOADBALANCER --server 80 --use-private-ip" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/actions/update_service": { "post": { @@ -13230,7 +13515,12 @@ "source": "hcloud load-balancer update-service $LOADBALANCER \\\n --listen-port 443 \\\n --destination-port 80 \\\n --health-check-http-domain example.com \\\n --health-check-http-path \"/\" \\\n --health-check-http-response '{\"status\": \"ok\"}' \\\n --health-check-http-status-codes \"2??,3??\" \\\n --health-check-http-tls=false \\\n --health-check-interval 15s \\\n --health-check-port 4711 \\\n --health-check-protocol http \\\n --health-check-retries 3 \\\n --health-check-timeout 10s \\\n --http-certificates 897 \\\n --http-cookie-lifetime 300s \\\n --http-cookie-name HCLBSTICKY \\\n --http-redirect-http=true \\\n --http-sticky-sessions=true \\\n --protocol https \\\n --proxy-protocol=false" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/{id}/metrics": { "get": { @@ -13326,7 +13616,12 @@ "source": "hcloud load-balancer metrics $LOADBALANCER \\\n --type open_connections,connections_per_second,requests_per_second,bandwidth \\\n --start 2017-01-01T00:00:00Z \\\n --end 2017-01-01T23:00:00Z" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/actions": { "get": { @@ -13449,7 +13744,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.load_balancers.actions.get_all()" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/load_balancers/actions/{id}": { "get": { @@ -13498,7 +13798,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.actions.get_by_id(123)" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/locations": { "get": { @@ -13592,7 +13897,12 @@ "source": "hcloud location list" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/locations/{id}": { "get": { @@ -13646,7 +13956,12 @@ "source": "hcloud location describe $LOCATION" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks": { "get": { @@ -13798,7 +14113,12 @@ "source": "hcloud network create \\\n --expose-routes-to-vswitch=false \\\n --ip-range 10.0.0.0/16 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name mynet\n\nhcloud network add-route mynet \\\n --destination 10.100.1.0/24 \\\n --gateway 10.0.1.1\n\nhcloud network add-subnet mynet \\\n --ip-range 10.0.1.0/24 \\\n --network-zone eu-central \\\n --type cloud \\\n --vswitch-id 1000" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks/{id}": { "delete": { @@ -13993,7 +14313,12 @@ "source": "hcloud network update $NETWORK --name new-name\nhcloud network expose-routes-to-vswitch --disable $NETWORK\nhcloud network add-label --overwrite $NETWORK \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud network remove-label $NETWORK \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks/{id}/actions": { "get": { @@ -14133,7 +14458,12 @@ "tags": [ "networks" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks/{id}/actions/{action_id}": { "get": { @@ -14203,7 +14533,12 @@ "tags": [ "networks" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks/{id}/actions/add_route": { "post": { @@ -14286,7 +14621,12 @@ "source": "hcloud network add-route $NETWORK \\\n --destination 10.100.1.0/24 \\\n --gateway 10.0.1.1" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks/{id}/actions/add_subnet": { "post": { @@ -14369,7 +14709,12 @@ "source": "hcloud network add-subnet $NETWORK \\\n --ip-range 10.0.1.0/24 \\\n --network-zone eu-central \\\n --type cloud \\\n --vswitch-id 1000" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks/{id}/actions/change_ip_range": { "post": { @@ -14452,7 +14797,12 @@ "source": "hcloud network change-ip-range $NETWORK \\\n --ip-range 10.0.0.0/16" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks/{id}/actions/change_protection": { "post": { @@ -14535,7 +14885,12 @@ "source": "hcloud network enable-protection $NETWORK delete\nhcloud network disable-protection $NETWORK delete" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks/{id}/actions/delete_route": { "post": { @@ -14618,7 +14973,12 @@ "source": "hcloud network remove-route $NETWORK \\\n --destination 10.100.1.0/24 \\\n --gateway 10.0.1.1" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks/{id}/actions/delete_subnet": { "post": { @@ -14701,7 +15061,12 @@ "source": "hcloud network remove-subnet $NETWORK \\\n --ip-range 10.0.1.0/24" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks/actions": { "get": { @@ -14824,7 +15189,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.networks.actions.get_all()" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/networks/actions/{id}": { "get": { @@ -14873,7 +15243,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.actions.get_by_id(123)" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/placement_groups": { "get": { @@ -15085,7 +15460,12 @@ "source": "hcloud placement-group create \\\n --name \"my Placement Group\" \\\n --type spread" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/placement_groups/{id}": { "delete": { @@ -15275,7 +15655,12 @@ "source": "hcloud placement-group update $PLACEMENTGROUP --name \"my Placement Group\"\nhcloud placement-group add-label --overwrite $PLACEMENTGROUP \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud placement-group remove-label $PLACEMENTGROUP \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/pricing": { "get": { @@ -15304,7 +15689,12 @@ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tpricing, _, err := client.Pricing.Get(ctx)\n}" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/primary_ips": { "get": { @@ -15539,7 +15929,12 @@ "source": "hcloud primary-ip create \\\n --assignee-id 17 \\\n --auto-delete=false \\\n --datacenter fsn1-dc8 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name my-ip \\\n --type ipv4" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/primary_ips/{id}": { "delete": { @@ -15699,7 +16094,12 @@ "source": "hcloud primary-ip update $PRIMARYIP \\\n --auto-delete=false \\\n --name \"new-name\"\nhcloud primary-ip add-label --overwrite $PRIMARYIP \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud primary-ip remove-label $PRIMARYIP \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/primary_ips/{id}/actions/assign": { "post": { @@ -15786,7 +16186,12 @@ "source": "hcloud primary-ip assign --server 4711 $PRIMARYIP" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/primary_ips/{id}/actions/change_dns_ptr": { "post": { @@ -15870,7 +16275,12 @@ "source": "hcloud primary-ip set-rdns $PRIMARYIP \\\n --ip 1.2.3.4 \\\n --hostname server02.example.com" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/primary_ips/{id}/actions/change_protection": { "post": { @@ -15953,7 +16363,12 @@ "source": "hcloud primary-ip enable-protection $PRIMARYIP delete\nhcloud primary-ip disable-protection $PRIMARYIP delete" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/primary_ips/{id}/actions/unassign": { "post": { @@ -16031,7 +16446,12 @@ "source": "hcloud primary-ip unassign $PRIMARYIP" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/primary_ips/actions": { "get": { @@ -16154,7 +16574,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.primary_ips.actions.get_all()" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/primary_ips/actions/{id}": { "get": { @@ -16203,7 +16628,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.primary_ips.actions.get_by_id(123)" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/server_types": { "get": { @@ -16277,7 +16707,12 @@ "source": "hcloud server-type list" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/server_types/{id}": { "get": { @@ -16331,7 +16766,12 @@ "source": "hcloud server-type describe $SERVERTYPE" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers": { "get": { @@ -16713,7 +17153,12 @@ "source": "hcloud server create \\\n --automount=false \\\n --datacenter nbg1-dc3 \\\n --firewall 38 \\\n --image ubuntu-20.04 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --location nbg1 \\\n --name my-server \\\n --network 456 \\\n --placement-group 1 \\\n --without-ipv4 \\\n --without-ipv6 \\\n --type cx22 \\\n --ssh-key my-ssh-key \\\n --start-after-create \\\n --volume 123 \\\n --user-data-from-file <(printf '#cloud-config\\nruncmd:\\n- [touch, /root/cloud-init-worked]\\n')" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}": { "delete": { @@ -16880,7 +17325,12 @@ "source": "hcloud server update $SERVER --name \"my-server\"\nhcloud server add-label --overwrite $SERVER \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud server remove-label $SERVER \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions": { "get": { @@ -17021,7 +17471,12 @@ "tags": [ "servers" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/{action_id}": { "get": { @@ -17091,7 +17546,12 @@ "tags": [ "servers" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/add_to_placement_group": { "post": { @@ -17174,7 +17634,12 @@ "source": "hcloud server add-to-placement-group --placement-group 1 $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/attach_iso": { "post": { @@ -17257,7 +17722,12 @@ "source": "hcloud server attach-iso $SERVER \"FreeBSD-11.0-RELEASE-amd64-dvd1\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/attach_to_network": { "post": { @@ -17344,7 +17814,12 @@ "source": "hcloud server attach-to-network $SERVER \\\n --alias-ips 10.0.1.2 \\\n --ip 10.0.1.1 \\\n --network 4711" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/change_alias_ips": { "post": { @@ -17431,7 +17906,12 @@ "source": "hcloud server change-alias-ips $SERVER \\\n --alias-ips 10.0.1.2 \\\n --network 4711" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/change_dns_ptr": { "post": { @@ -17515,7 +17995,12 @@ "source": "hcloud server set-rdns $SERVER \\\n --ip 1.2.3.4 \\\n --hostname server01.example.com" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/change_protection": { "post": { @@ -17598,7 +18083,12 @@ "source": "hcloud server enable-protection $SERVER delete rebuild\nhcloud server disable-protection $SERVER delete rebuild" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/change_type": { "post": { @@ -17681,7 +18171,12 @@ "source": "hcloud server change-type --keep-disk $SERVER cx22" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/create_image": { "post": { @@ -17791,7 +18286,12 @@ "source": "hcloud server create-image $SERVER \\\n --description \"my image\" \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --type snapshot" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/detach_from_network": { "post": { @@ -17878,7 +18378,12 @@ "source": "hcloud server detach-from-network --network 4711 $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/detach_iso": { "post": { @@ -17952,7 +18457,12 @@ "source": "hcloud server detach-iso $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/disable_backup": { "post": { @@ -18026,7 +18536,12 @@ "source": "hcloud server disable-backup $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/disable_rescue": { "post": { @@ -18100,7 +18615,12 @@ "source": "hcloud server disable-rescue $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/enable_backup": { "post": { @@ -18174,7 +18694,12 @@ "source": "hcloud server enable-backup $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/enable_rescue": { "post": { @@ -18258,7 +18783,12 @@ "source": "hcloud server enable-rescue $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/poweroff": { "post": { @@ -18332,7 +18862,12 @@ "source": "hcloud server poweroff $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/poweron": { "post": { @@ -18406,7 +18941,12 @@ "source": "hcloud server poweron $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/reboot": { "post": { @@ -18480,7 +19020,12 @@ "source": "hcloud server reboot $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/rebuild": { "post": { @@ -18565,7 +19110,12 @@ "source": "hcloud server rebuild --image ubuntu-20.04 $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/remove_from_placement_group": { "post": { @@ -18639,7 +19189,12 @@ "source": "hcloud server remove-from-placement-group $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/request_console": { "post": { @@ -18715,7 +19270,12 @@ "source": "hcloud server request-console $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/reset": { "post": { @@ -18789,7 +19349,12 @@ "source": "hcloud server reset $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/reset_password": { "post": { @@ -18864,7 +19429,12 @@ "source": "hcloud server reset-password $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/actions/shutdown": { "post": { @@ -18938,7 +19508,12 @@ "source": "hcloud server shutdown $SERVER" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/{id}/metrics": { "get": { @@ -19033,7 +19608,12 @@ "source": "hcloud server metrics $SERVER \\\n --type cpu,network,disk \\\n --start 2017-01-01T00:00:00Z \\\n --end 2017-01-01T23:00:00Z" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/actions": { "get": { @@ -19156,7 +19736,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.servers.actions.get_all()" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/servers/actions/{id}": { "get": { @@ -19205,7 +19790,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.actions.get_by_id(123)" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/ssh_keys": { "get": { @@ -19363,7 +19953,12 @@ "source": "hcloud ssh-key create \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name \"My ssh key\" \\\n --public-key \"ssh-rsa AAAjjk76kgf...Xt\"\n# --public-key-from-file ~/.ssh/id_rsa.pub" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/ssh_keys/{id}": { "delete": { @@ -19535,7 +20130,12 @@ "source": "hcloud ssh-key update $SSHKEY --name \"My ssh key\"\nhcloud ssh-key add-label --overwrite $SSHKEY \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud ssh-key remove-label $SSHKEY \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/volumes": { "get": { @@ -19789,7 +20389,12 @@ "source": "hcloud volume create \\\n --automount=false \\\n --format xfs \\\n --label \"key=value\" \\\n --location nbg1 \\\n --name test-database \\\n --size 42" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/volumes/{id}": { "delete": { @@ -19977,7 +20582,12 @@ "source": "hcloud volume update $VOLUME --name \"database-storage\"\nhcloud volume add-label --overwrite $VOLUME \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud volume remove-label $VOLUME \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/volumes/{id}/actions": { "get": { @@ -20121,7 +20731,12 @@ "tags": [ "volumes" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/volumes/{id}/actions/{action_id}": { "get": { @@ -20191,7 +20806,12 @@ "tags": [ "volumes" ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/volumes/{id}/actions/attach": { "post": { @@ -20278,7 +20898,12 @@ "source": "hcloud volume attach $VOLUME \\\n --automount=false \\\n --server 43" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/volumes/{id}/actions/change_protection": { "post": { @@ -20365,7 +20990,12 @@ "source": "hcloud volume enable-protection $VOLUME delete\nhcloud volume disable-protection $VOLUME delete" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/volumes/{id}/actions/detach": { "post": { @@ -20439,7 +21069,12 @@ "source": "hcloud volume detach $VOLUME" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/volumes/{id}/actions/resize": { "post": { @@ -20522,7 +21157,12 @@ "source": "hcloud volume resize --size 50 $VOLUME" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/volumes/actions": { "get": { @@ -20645,7 +21285,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.volumes.actions.get_all()" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, "/volumes/actions/{id}": { "get": { @@ -20694,7 +21339,12 @@ "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.volumes.actions.get_by_id(123)" } ] - } + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] } }, "security": [ diff --git a/src/index.ts b/src/index.ts index 2ce7017..277627a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -159,15 +159,32 @@ function sortObjectRecursive(obj: OpenApiDocumentFragment) { return obj; } +function isVerb(verb: string) { + return [ + "delete", + "get", + "head", + "options", + "patch", + "post", + "put", + "trace", + ].includes(verb); +} + async function createComponents(document: OpenApiDocumentFragment) { const paths = document.paths as OpenApiDocumentFragment; - const base_url = "https://api.hetzner.cloud/v1"; + const base_url = "https://api.hetzner.cloud/v1"; // TODO // const schemas = document.components.schemas ?? {}; const schemas = {}; // all components in the original spec are currently not referenced for (const [path, path_obj] of Object.entries(paths)) { for (const [verb, verb_obj] of Object.entries(path_obj)) { + if (!isVerb(verb)) { + continue; + } + const verb_data = verb_obj as OpenApiDocumentFragment; const id = toSchemaName("request", verb, verb_data.summary); @@ -233,11 +250,26 @@ function transformPath( } } +async function addServersToPaths(document: OpenApiDocumentFragment) { + const servers = document.servers as OpenApiDocumentFragment; + if (Array.isArray(servers) && servers.length != 1) { + throw new Error("Expected exactly one server"); + } + + const paths = document.paths as OpenApiDocumentFragment; + for (const [path, path_obj] of Object.entries(paths)) { + path_obj.servers = servers; + } +} + async function transformPaths(document: OpenApiDocumentFragment) { const paths = document.paths as OpenApiDocumentFragment; for (const [path, path_obj] of Object.entries(paths)) { for (const [verb, verb_obj] of Object.entries(path_obj)) { + if (!isVerb(verb)) { + continue; + } transformPath(path, verb, verb_obj as OpenApiDocumentFragment); } } @@ -350,6 +382,7 @@ async function main() { try { // load document from source let document = (await getContents(args.source)) as OpenApiDocumentFragment; + await addServersToPaths(document); await preTransformDocument(document); From 63e7ea2c9f4449fdc7d9aaf71793781fbfab64e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6stler?= Date: Mon, 25 Aug 2025 00:14:53 +0200 Subject: [PATCH 2/8] Schema!: Merge with schema for Hetzner API --- README.md | 93 +- openapi/hcloud.json | 18196 +++++++++++++--------- resources/document_transformations.json | 205 +- resources/paths.json | 24 +- resources/schema_types.json | 68 + src/index.ts | 96 +- 6 files changed, 11188 insertions(+), 7494 deletions(-) diff --git a/README.md b/README.md index 03a9f89..61f1b57 100644 --- a/README.md +++ b/README.md @@ -5,66 +5,60 @@ This is an attempt to improve Hetzner's own OpenAPI specification to make it usable in code generation. When this project was started, Hetzner had not published their own OpenAPI specification for their cloud API, so I decided to build my own based on the HTML documentation on their website. -Luckily, Hetzner has actually published an [OpenAPI spec for their API](https://docs.hetzner.cloud/cloud.spec.json) in the meantime but I think this project still adds some value. +By now, Hetzner has actually published an [OpenAPI spec for their API](https://docs.hetzner.cloud/cloud.spec.json) and recently also [a new API for Storage Boxes](https://docs.hetzner.cloud/hetzner.spec.json) However, I think this project still adds some value. While Hetzner now appears to generate their documentation website from the OpenAPI spec, the spec is not very useful for automatic code generation. -This project aims to convert the official spec to an improved version with the following main features: +This project aims to convert the official specs to an improved version with the following main features: +- A single file describing all API endpoints from multiple source documents - Definition of common components that are reused throughout the schema -- Added pagination support - API-friendly tag names - Unique `operationId`s -As an added benefit, mainly from use of common components, the improved spec is much smaller (548 KiB vs 1.4 MiB) than the original. +As an added benefit, mainly from use of common components, the improved spec is much smaller (945 KB vs 2.291 MB) than the original. ## Further Reading - [Link to the generated openAPI document](openapi/hcloud.json) - [Official API documentation](https://docs.hetzner.cloud/) -- [OpenAPI spec document provided by Hetzner](https://docs.hetzner.cloud/cloud.spec.json) +- [OpenAPI spec document provided by Hetzner for cloud services](https://docs.hetzner.cloud/cloud.spec.json) +- [OpenAPI spec document provided by Hetzner for storage boxes](https://docs.hetzner.cloud/hetzner.spec.json) - [OpenAPI standard](https://swagger.io/specification/) ## Use Cases + This API description is currently being used by the following projects: + - [hcloud-rust](https://github.com/HenningHolmDE/hcloud-rust) [![Crates.io](https://img.shields.io/crates/v/hcloud.svg)](https://crates.io/crates/hcloud) [![Documentation](https://docs.rs/hcloud/badge.svg)](https://docs.rs/hcloud/) ## Supported Endpoints - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
actionscertificatesdatacenters
floating_ipsimagesisos
load_balancer_typesload_balancerslocations
networkspricingserver_types
serversssh_keysvolumes
firewallsplacement_groupsprimary_ips
+ +- actions +- certificates +- datacenters +- firewalls +- floating_ips +- images +- isos +- load_balancer_types +- load_balancers +- locations +- networks +- placement_groups +- pricing +- primary_ips +- server_types +- servers +- ssh_keys +- storage_box_types +- storage_boxes +- volumes ``` +# Main hcloud API + /actions (GET) /actions/{id} (GET) /certificates (GET, POST) @@ -195,6 +189,31 @@ This API description is currently being used by the following projects: /volumes/{id}/actions/resize (POST) /volumes/actions (GET) /volumes/actions/{id} (GET) + +# Storage Boxes + +/storage_box_types (GET) +/storage_box_types/{id} (GET) +/storage_boxes (GET, POST) +/storage_boxes/actions (GET) +/storage_boxes/actions/{id} (GET) +/storage_boxes/{id} (DELETE, GET, PUT) +/storage_boxes/{id}/actions (GET) +/storage_boxes/{id}/actions/change_protection (POST) +/storage_boxes/{id}/actions/change_type (POST) +/storage_boxes/{id}/actions/disable_snapshot_plan (POST) +/storage_boxes/{id}/actions/enable_snapshot_plan (POST) +/storage_boxes/{id}/actions/reset_password (POST) +/storage_boxes/{id}/actions/rollback_snapshot (POST) +/storage_boxes/{id}/actions/update_access_settings (POST) +/storage_boxes/{id}/actions/{action_id} (GET) +/storage_boxes/{id}/folders (GET) +/storage_boxes/{id}/snapshots (GET, POST) +/storage_boxes/{id}/snapshots/{snapshot_id} (DELETE, GET, PUT) +/storage_boxes/{id}/subaccounts (GET, POST) +/storage_boxes/{id}/subaccounts/{subaccount_id} (DELETE, GET, PUT) +/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/reset_subaccount_password (POST) +/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/update_access_settings (POST) ``` ## Quick Start diff --git a/openapi/hcloud.json b/openapi/hcloud.json index c2ddac8..19b6ae9 100644 --- a/openapi/hcloud.json +++ b/openapi/hcloud.json @@ -6,12 +6,16 @@ }, "description": "Copied from the official API documentation for the Public Hetzner Cloud.", "title": "Hetzner Cloud API", - "version": "4575182-dirty" + "version": "e80474a-dirty" }, "servers": [ { - "description": "Official production server", + "description": "API for cloud services", "url": "https://api.hetzner.cloud/v1" + }, + { + "description": "API for storage boxes", + "url": "https://api.hetzner.com/v1" } ], "tags": [ @@ -82,6 +86,14 @@ "description": "SSH keys are public keys you provide to the cloud system. They can be injected into Servers at creation time. We highly recommend that you use keys instead of passwords to manage your Servers.\n", "name": "ssh_keys" }, + { + "description": "Storage Box types define storage products of different sizes. Each type has an hourly and a monthly cost. You will pay whichever cost is lower for your usage of this specific Storage Box. Costs may differ between Locations.\n\nAll prices are displayed in the currency of the project owner's account.\n", + "name": "storage_box_types" + }, + { + "description": "Storage Boxes offer storage capacity for both small and large amounts of data. Any data you save in your Storage Box is saved on several disks configured in a RAID array, increasing redundancy and fault tolerance.\n\nPlease see [Hetzner Docs](https://docs.hetzner.com/storage/storage-box) for more details about Storage Boxes.\n\n### Password policy\n\nThis policy applies to both Storage Boxes and Storage Box Subaccounts.\n\n- The password must be between 8 and 128 characters long\n- The password can only contain these characters: `a-z A-Z 0-9 ! ? . = + %% # _ * ~ & $ ( ) / [ ] { } -`\n- The password must contain at least one upper case letter, one lower case letter and one number or a special character\n- The password must not have appeared in any known data breach\n", + "name": "storage_boxes" + }, { "description": "A Volume is a highly-available, scalable, and SSD-based block storage for Servers.\n\nPricing for Volumes depends on the Volume size and Location, not the actual used storage.\n\nPlease see [Hetzner Docs](https://docs.hetzner.com/cloud/#Volumes) for more details about Volumes.\n", "name": "volumes" @@ -1022,6 +1034,22 @@ "title": "ActionResponse", "type": "object" }, + "change_storage_box_protection_request": { + "$ref": "#/components/schemas/protection" + }, + "change_storage_box_protection_response": { + "description": "Response to POST https://api.hetzner.com/v1/storage_boxes/{id}/actions/change_protection", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, "change_type_of_load_balancer_request": { "description": "Request for POST https://api.hetzner.cloud/v1/load_balancers/{id}/actions/change_type", "properties": { @@ -1083,6 +1111,33 @@ "title": "ActionResponse", "type": "object" }, + "change_type_of_storage_box_request": { + "description": "Request for POST https://api.hetzner.com/v1/storage_boxes/{id}/actions/change_type", + "properties": { + "storage_box_type": { + "description": "The ID or the name of the Storage Box Type.", + "example": "BX21", + "type": "string" + } + }, + "required": [ + "storage_box_type" + ], + "type": "object" + }, + "change_type_of_storage_box_response": { + "description": "Response to POST https://api.hetzner.com/v1/storage_boxes/{id}/actions/change_type", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, "change_volume_protection_request": { "description": "Request for POST https://api.hetzner.cloud/v1/volumes/{id}/actions/change_protection", "properties": { @@ -1909,6 +1964,56 @@ "title": "CreateServerResponse", "type": "object" }, + "create_snapshot_request": { + "description": "Request for POST https://api.hetzner.com/v1/storage_boxes/{id}/snapshots", + "properties": { + "description": { + "description": "Description of the Snapshot.", + "example": "snapshot-0001", + "maxLength": 1000, + "pattern": "[a-zA-Z0-9-_,:<>+#!\\(\\)\\[\\]\\{\\} ]*", + "type": "string" + } + }, + "title": "CreateSnapshot", + "type": "object" + }, + "create_snapshot_response": { + "description": "Response to POST https://api.hetzner.com/v1/storage_boxes/{id}/snapshots", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + }, + "snapshot": { + "properties": { + "id": { + "description": "ID of the Storage Box Snapshot.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "storage_box": { + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + "required": [ + "id", + "storage_box" + ], + "type": "object" + } + }, + "required": [ + "snapshot", + "action" + ], + "type": "object" + }, "create_ssh_key_request": { "description": "Request for POST https://api.hetzner.cloud/v1/ssh_keys", "properties": { @@ -1944,6 +2049,193 @@ ], "type": "object" }, + "create_storage_box_request": { + "description": "Request for POST https://api.hetzner.com/v1/storage_boxes", + "properties": { + "access_settings": { + "properties": { + "reachable_externally": { + "description": "Whether the Storage Box should be accessible from outside the Hetzner network.", + "nullable": true, + "type": "boolean" + }, + "samba_enabled": { + "description": "Whether the Samba subsystem should be enabled.", + "nullable": true, + "type": "boolean" + }, + "ssh_enabled": { + "description": "Whether the SSH subsystem should be enabled.", + "example": true, + "nullable": true, + "type": "boolean" + }, + "webdav_enabled": { + "description": "Whether the WebDAV subsystem should be enabled.", + "nullable": true, + "type": "boolean" + }, + "zfs_enabled": { + "description": "Whether the ZFS Snapshot folder should be visible.", + "nullable": true, + "type": "boolean" + } + }, + "title": "UpdateAccessSettings", + "type": "object" + }, + "labels": { + "$ref": "#/components/schemas/labels" + }, + "location": { + "description": "Unique identifier of the [Location](#locations).", + "example": "fsn1", + "type": "string" + }, + "name": { + "description": "Name of the Resource. Must be unique per Project.", + "example": "my-resource", + "type": "string" + }, + "password": { + "description": "The password that will be set for this Storage Box.", + "type": "string" + }, + "ssh_keys": { + "description": "Array of SSH public keys in OpenSSH format which should be injected into the Storage Box.", + "items": { + "example": "ssh-rsa AAAjjk76kgf...Xt", + "type": "string" + }, + "type": "array" + }, + "storage_box_type": { + "description": "The name or the ID of the Storage Box Type.", + "example": "bx20", + "type": "string" + } + }, + "required": [ + "storage_box_type", + "location", + "name", + "password" + ], + "type": "object" + }, + "create_storage_box_response": { + "description": "Response to POST https://api.hetzner.com/v1/storage_boxes", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + }, + "storage_box": { + "$ref": "#/components/schemas/storage_box" + } + }, + "required": [ + "storage_box", + "action" + ], + "type": "object" + }, + "create_subaccount_request": { + "description": "Request for POST https://api.hetzner.com/v1/storage_boxes/{id}/subaccounts", + "properties": { + "access_settings": { + "properties": { + "reachable_externally": { + "description": "Whether the Subaccount should be accessible from outside the Hetzner network.", + "nullable": true, + "type": "boolean" + }, + "readonly": { + "description": "Whether the Subaccount should be read-only.", + "nullable": true, + "type": "boolean" + }, + "samba_enabled": { + "description": "Whether the Samba subsystem should be enabled.", + "nullable": true, + "type": "boolean" + }, + "ssh_enabled": { + "description": "Whether the SSH subsystem should be enabled.", + "example": true, + "nullable": true, + "type": "boolean" + }, + "webdav_enabled": { + "description": "Whether the WebDAV subsystem should be enabled.", + "nullable": true, + "type": "boolean" + } + }, + "type": "object" + }, + "description": { + "description": "A description to remind you of the purpose of this Subaccount.", + "example": "my-backup-server01", + "maxLength": 1000, + "nullable": true, + "type": "string" + }, + "home_directory": { + "description": "Home directory of the Subaccount. Will be created if it doesn't exist yet.", + "example": "my-backup/server01", + "nullable": true, + "type": "string" + }, + "labels": { + "$ref": "#/components/schemas/labels" + }, + "password": { + "description": "New password.", + "type": "string" + } + }, + "required": [ + "password", + "home_directory" + ], + "type": "object" + }, + "create_subaccount_response": { + "description": "Response to POST https://api.hetzner.com/v1/storage_boxes/{id}/subaccounts", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + }, + "subaccount": { + "properties": { + "id": { + "description": "ID of the Storage Box Subaccount.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "storage_box": { + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + "required": [ + "id", + "storage_box" + ], + "type": "object" + } + }, + "required": [ + "subaccount", + "action" + ], + "type": "object" + }, "create_volume_request": { "description": "Request for POST https://api.hetzner.cloud/v1/volumes", "properties": { @@ -2170,6 +2462,45 @@ "title": "ActionResponse", "type": "object" }, + "delete_snapshot_response": { + "description": "Response to DELETE https://api.hetzner.com/v1/storage_boxes/{id}/snapshots/{snapshot_id}", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, + "delete_storage_box_response": { + "description": "Response to DELETE https://api.hetzner.com/v1/storage_boxes/{id}", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, + "delete_subaccount_response": { + "description": "Response to DELETE https://api.hetzner.com/v1/storage_boxes/{id}/subaccounts/{subaccount_id}", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, "delete_subnet_from_network_request": { "description": "Request for POST https://api.hetzner.cloud/v1/networks/{id}/actions/delete_subnet", "properties": { @@ -2344,6 +2675,19 @@ "title": "ActionResponse", "type": "object" }, + "disable_snapshot_plan_response": { + "description": "Response to POST https://api.hetzner.com/v1/storage_boxes/{id}/actions/disable_snapshot_plan", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, "dns_ptr": { "description": "Request for POST https://api.hetzner.cloud/v1/floating_ips/{id}/actions/change_dns_ptr | Request for POST https://api.hetzner.cloud/v1/primary_ips/{id}/actions/change_dns_ptr", "properties": { @@ -2429,15 +2773,74 @@ }, "type": "object" }, - "error": { - "description": "Error message for the Action if an error occurred, otherwise null.", - "nullable": true, + "enable_snapshot_plan_request": { + "description": "Request for POST https://api.hetzner.com/v1/storage_boxes/{id}/actions/enable_snapshot_plan", "properties": { - "code": { - "description": "Fixed error code for machines.", - "example": "action_failed", - "type": "string" - }, + "day_of_month": { + "description": "Day of the month the Snapshot Plan should be executed on. Null means every day.", + "maximum": 31, + "minimum": 1, + "nullable": true, + "type": "integer" + }, + "day_of_week": { + "description": "Day of the week the Snapshot Plan should be executed on. Starts at 1 for Monday til 7 for Sunday. Null means every day.", + "maximum": 7, + "minimum": 1, + "nullable": true, + "type": "integer" + }, + "hour": { + "description": "Hour the Snapshot Plan should be executed on (UTC). Null means every hour.", + "example": 3, + "maximum": 23, + "minimum": 0, + "nullable": true, + "type": "integer" + }, + "max_snapshots": { + "description": "Maximum amount of Snapshots that should be created by this Snapshot Plan. Older Snapshots will be deleted.", + "example": 10, + "exclusiveMinimum": true, + "minimum": 0, + "type": "integer" + }, + "minute": { + "description": "Minute the Snapshot Plan should be executed on (UTC). Null means every minute.", + "example": 30, + "maximum": 59, + "minimum": 0, + "nullable": true, + "type": "integer" + } + }, + "required": [ + "max_snapshots" + ], + "type": "object" + }, + "enable_snapshot_plan_response": { + "description": "Response to POST https://api.hetzner.com/v1/storage_boxes/{id}/actions/enable_snapshot_plan", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, + "error": { + "description": "Error message for the Action if an error occurred, otherwise null.", + "nullable": true, + "properties": { + "code": { + "description": "Fixed error code for machines.", + "example": "action_failed", + "type": "string" + }, "message": { "description": "Error message for humans.", "example": "Action failed", @@ -3053,6 +3456,15 @@ ], "type": "object" }, + "get_snapshot_response": { + "description": "Response to GET https://api.hetzner.com/v1/storage_boxes/{id}/snapshots/{snapshot_id}", + "properties": { + "snapshot": { + "$ref": "#/components/schemas/snapshot" + } + }, + "type": "object" + }, "get_ssh_key_response": { "description": "Response to GET https://api.hetzner.cloud/v1/ssh_keys/{id}", "properties": { @@ -3065,6 +3477,39 @@ ], "type": "object" }, + "get_storage_box_response": { + "description": "Response to GET https://api.hetzner.com/v1/storage_boxes/{id}", + "properties": { + "storage_box": { + "$ref": "#/components/schemas/storage_box" + } + }, + "required": [ + "storage_box" + ], + "type": "object" + }, + "get_storage_box_type_response": { + "description": "Response to GET https://api.hetzner.com/v1/storage_box_types/{id}", + "properties": { + "storage_box_type": { + "$ref": "#/components/schemas/storage_box_type" + } + }, + "required": [ + "storage_box_type" + ], + "type": "object" + }, + "get_subaccount_response": { + "description": "Response to GET https://api.hetzner.com/v1/storage_boxes/{id}/subaccounts/{subaccount_id}", + "properties": { + "subaccount": { + "$ref": "#/components/schemas/subaccount" + } + }, + "type": "object" + }, "get_volume_response": { "description": "Response to GET https://api.hetzner.cloud/v1/volumes/{id}", "properties": { @@ -3584,7 +4029,7 @@ "pattern": "^(()|[a-z0-9A-Z]|([a-z0-9A-Z][a-z0-9A-Z\\._-]{0,61}[a-z0-9A-Z]))$", "type": "string" }, - "description": "User-defined labels (`key/value` pairs) for the Resource.\nFor more information, see \"[Labels](#labels)\".\n | User-defined labels (`key/value` pairs) for the Resource.\n\nNote that the set of [Labels](#labels) provided in the request will overwrite the\nexisting one.\n\nFor more information, see \"[Labels](#labels)\".\n", + "description": "User-defined labels (`key/value` pairs) for the Resource.\nFor more information, see \"[Labels](#labels)\".\n | User-defined labels (`key/value` pairs) for the Resource.\n\nNote that the set of [Labels](#labels) provided in the request will overwrite the\nexisting one.\n\nFor more information, see \"[Labels](#labels)\".\n | The Storage Boxes' labels. | The Subaccounts' labels. | The Snapshots' labels.", "example": { "environment": "prod", "example.com/my": "label", @@ -3632,6 +4077,21 @@ "title": "CertificatesResponse", "type": "object" }, + "list_content_of_storage_box_response": { + "description": "Response to GET https://api.hetzner.com/v1/storage_boxes/{id}/folders", + "properties": { + "folders": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "folders" + ], + "type": "object" + }, "list_datacenters_response": { "description": "Response to GET https://api.hetzner.cloud/v1/datacenters", "properties": { @@ -4231,6 +4691,21 @@ ], "type": "object" }, + "list_snapshots_for_storage_box_response": { + "description": "Response to GET https://api.hetzner.com/v1/storage_boxes/{id}/snapshots", + "properties": { + "snapshots": { + "items": { + "$ref": "#/components/schemas/snapshot" + }, + "type": "array" + } + }, + "required": [ + "snapshots" + ], + "type": "object" + }, "list_ssh_keys_response": { "description": "Response to GET https://api.hetzner.cloud/v1/ssh_keys", "properties": { @@ -4250,6 +4725,59 @@ ], "type": "object" }, + "list_storage_box_types_response": { + "description": "Response to GET https://api.hetzner.com/v1/storage_box_types", + "properties": { + "meta": { + "$ref": "#/components/schemas/meta" + }, + "storage_box_types": { + "items": { + "$ref": "#/components/schemas/storage_box_type" + }, + "type": "array" + } + }, + "required": [ + "storage_box_types", + "meta" + ], + "type": "object" + }, + "list_storage_boxes_response": { + "description": "Response to GET https://api.hetzner.com/v1/storage_boxes", + "properties": { + "meta": { + "$ref": "#/components/schemas/meta" + }, + "storage_boxes": { + "items": { + "$ref": "#/components/schemas/storage_box" + }, + "type": "array" + } + }, + "required": [ + "storage_boxes", + "meta" + ], + "type": "object" + }, + "list_subaccounts_for_storage_box_response": { + "description": "Response to GET https://api.hetzner.com/v1/storage_boxes/{id}/subaccounts", + "properties": { + "subaccounts": { + "items": { + "$ref": "#/components/schemas/subaccount" + }, + "type": "array" + } + }, + "required": [ + "subaccounts" + ], + "type": "object" + }, "list_volumes_response": { "description": "Response to GET https://api.hetzner.cloud/v1/volumes", "properties": { @@ -5116,7 +5644,7 @@ "type": "object" }, "price": { - "description": "Hourly price in this [Location](#locations). | Monthly price in this [Location](#locations). | Additional traffic price per TB in this [Location](#locations). | Price of [Images](#images) per GB/month. | Price of [Volumes](#volumes) per GB/month. | Price of one [Floating IP](#floating-ips) per month.", + "description": "Hourly price in this [Location](#locations). | Monthly price in this [Location](#locations). | Additional traffic price per TB in this [Location](#locations). | Price of [Images](#images) per GB/month. | Price of [Volumes](#volumes) per GB/month. | Price of one [Floating IP](#floating-ips) per month. | Setup fee in this [Location](#locations).", "properties": { "gross": { "description": "Price with VAT added.", @@ -5733,6 +6261,35 @@ }, "type": "object" }, + "replace_snapshot_request": { + "description": "Request for PUT https://api.hetzner.com/v1/storage_boxes/{id}/snapshots/{snapshot_id}", + "properties": { + "description": { + "description": "Description of the Snapshot.", + "example": "snapshot-0001", + "maxLength": 1000, + "pattern": "[a-zA-Z0-9-_,:<>+#!\\(\\)\\[\\]\\{\\} ]*", + "type": "string" + }, + "labels": { + "$ref": "#/components/schemas/labels" + } + }, + "required": [ + "description", + "labels" + ], + "type": "object" + }, + "replace_snapshot_response": { + "description": "Response to PUT https://api.hetzner.com/v1/storage_boxes/{id}/snapshots/{snapshot_id}", + "properties": { + "snapshot": { + "$ref": "#/components/schemas/snapshot" + } + }, + "type": "object" + }, "replace_ssh_key_request": { "description": "Request for PUT https://api.hetzner.cloud/v1/ssh_keys/{id}", "properties": { @@ -5759,6 +6316,60 @@ ], "type": "object" }, + "replace_storage_box_request": { + "description": "Request for PUT https://api.hetzner.com/v1/storage_boxes/{id}", + "properties": { + "labels": { + "$ref": "#/components/schemas/labels" + }, + "name": { + "description": "The Storage Boxes' name.", + "type": "string" + } + }, + "type": "object" + }, + "replace_storage_box_response": { + "description": "Response to PUT https://api.hetzner.com/v1/storage_boxes/{id}", + "properties": { + "storage_box": { + "$ref": "#/components/schemas/storage_box" + } + }, + "required": [ + "storage_box" + ], + "type": "object" + }, + "replace_subaccount_request": { + "description": "Request for PUT https://api.hetzner.com/v1/storage_boxes/{id}/subaccounts/{subaccount_id}", + "properties": { + "description": { + "description": "A description to remind you of the purpose of this Subaccount.", + "example": "my-backup-server01", + "maxLength": 1000, + "nullable": true, + "type": "string" + }, + "labels": { + "$ref": "#/components/schemas/labels" + } + }, + "required": [ + "labels", + "description" + ], + "type": "object" + }, + "replace_subaccount_response": { + "description": "Response to PUT https://api.hetzner.com/v1/storage_boxes/{id}/subaccounts/{subaccount_id}", + "properties": { + "subaccount": { + "$ref": "#/components/schemas/subaccount" + } + }, + "type": "object" + }, "replace_volume_request": { "description": "Request for PUT https://api.hetzner.cloud/v1/volumes/{id}", "properties": { @@ -5810,6 +6421,33 @@ ], "type": "object" }, + "reset_password_request": { + "description": "Request for POST https://api.hetzner.com/v1/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/reset_subaccount_password", + "properties": { + "password": { + "description": "New password.", + "type": "string" + } + }, + "required": [ + "password" + ], + "title": "ResetPassword", + "type": "object" + }, + "reset_password_response": { + "description": "Response to POST https://api.hetzner.com/v1/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/reset_subaccount_password", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, "reset_root_password_of_server_response": { "description": "Response to POST https://api.hetzner.cloud/v1/servers/{id}/actions/reset_password", "properties": { @@ -5914,6 +6552,35 @@ "title": "ActionResponse", "type": "object" }, + "rollback_snapshot_request": { + "description": "Request for POST https://api.hetzner.com/v1/storage_boxes/{id}/actions/rollback_snapshot", + "properties": { + "snapshot_id": { + "description": "ID of the Storage Box Snapshot.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + "required": [ + "snapshot_id" + ], + "type": "object" + }, + "rollback_snapshot_response": { + "description": "Response to POST https://api.hetzner.com/v1/storage_boxes/{id}/actions/rollback_snapshot", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, "route": { "description": "Request for POST https://api.hetzner.cloud/v1/networks/{id}/actions/add_route | Request for POST https://api.hetzner.cloud/v1/networks/{id}/actions/delete_route", "properties": { @@ -6441,39 +7108,30 @@ "title": "ActionResponse", "type": "object" }, - "soft_reboot_server_response": { - "description": "Response to POST https://api.hetzner.cloud/v1/servers/{id}/actions/reboot", - "properties": { - "action": { - "$ref": "#/components/schemas/action" - } - }, - "required": [ - "action" - ], - "title": "ActionResponse", - "type": "object" - }, - "ssh_key": { - "description": "SSH keys are public keys you provide to the cloud system. They can be injected into Servers at creation time. We highly recommend that you use keys instead of passwords to manage your Servers.", + "snapshot": { "properties": { "created": { - "description": "Point in time when the Resource was created (in ISO-8601 format).", + "description": "Point in time (in ISO-8601 format).", "example": "2016-01-30T23:55:00+00:00", "type": "string" }, - "fingerprint": { - "description": "MD5 fingerprint of the SSH public key.", - "example": "b7:2f:30:a0:2f:6c:58:6c:21:04:58:61:ba:06:3b:2f", + "description": { + "description": "Description of the Resource.", + "example": "This describes my resource", + "nullable": true, "type": "string" }, "id": { - "description": "ID of the SSH Key.", + "description": "ID of the Storage Box Snapshot.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" }, + "is_automatic": { + "description": "Whether the Snapshot was created automatically.", + "type": "boolean" + }, "labels": { "$ref": "#/components/schemas/labels" }, @@ -6482,113 +7140,83 @@ "example": "my-resource", "type": "string" }, - "public_key": { - "description": "Public key.", - "example": "ssh-rsa AAAjjk76kgf...Xt", - "type": "string" + "stats": { + "$ref": "#/components/schemas/snapshot_stats" + }, + "storage_box": { + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" } }, "required": [ "id", "name", - "fingerprint", - "public_key", + "description", + "stats", + "is_automatic", "labels", - "created" + "created", + "storage_box" ], "type": "object" }, - "subnet": { - "description": "Subnets divide the ip_range from the parent Network object into multiple Subnetworks that you can use for different specific purposes.", + "snapshot_plan": { + "description": "Details of the active snapshot plan. Not available if the status is \"initializing\".", + "nullable": true, "properties": { - "ip_range": { - "description": "IP range of the subnet.\n\nUses CIDR notation.\n\nMust be a subnet of the parent [Networks](#networks) `ip_range`.\n\nMust not overlap with any other subnets or with any destinations in routes.\n\nMinimum network size is /30. We highly recommend that you pick a larger subnet with a /24 netmask.\n", - "example": "10.0.1.0/24", - "type": "string" - }, - "network_zone": { - "description": "Name of the [Network Zone](#network-zones).\n\nThe [Location](#locations) contains the `network_zone` property it belongs to.\n | Name of the [Network Zone](#network-zones).\n\nThe [Location](#locations) contains the `network_zone` it belongs to.\n", - "example": "eu-central", - "type": "string" - }, - "type": { - "description": "Type of subnet.\n\n- `cloud` - Used to connect cloud [Servers](#servers) and [Load Balancers](#load-balancers).\n- `server` - Same as the `cloud` type. **Deprecated**, use the `cloud` type instead.\n- `vswitch` - Used to [connect cloud Servers and Load Balancers with dedicated Servers](https://docs.hetzner.com/cloud/networks/connect-dedi-vswitch).\n", - "enum": [ - "cloud", - "server", - "vswitch" - ], - "type": "string" - }, - "vswitch_id": { - "description": "ID of the robot vSwitch.\n\nMust only be supplied for subnets of type `vswitch`.\n | ID of the robot vSwitch.\n\nMust be supplied if the subnet is of type `vswitch`.\n", - "example": 1000, - "format": "int64", + "day_of_month": { + "description": "Day of the month the Snapshot Plan is executed on.", + "nullable": true, "type": "integer" - } - }, - "required": [ - "type", - "network_zone" - ], - "type": "object" - }, - "subnet_with_gateway": { - "properties": { - "gateway": { - "description": "Gateway for [Servers](#servers) attached to this subnet.\n\nFor subnets of type `server` this is always the first IP of the subnets IP range.\n", - "example": "10.0.0.1", - "type": "string" }, - "ip_range": { - "description": "IP range of the subnet.\n\nUses CIDR notation.\n", - "example": "10.0.1.0/24", - "type": "string" + "day_of_week": { + "description": "Day of the week the Snapshot Plan is executed on.", + "nullable": true, + "type": "integer" }, - "network_zone": { - "description": "Name of the [Network Zone](#network-zones).\n\nThe [Location](#locations) contains the `network_zone` property it belongs to.\n", - "example": "eu-central", - "type": "string" + "hour": { + "description": "Hour the Snapshot Plan is executed at (UTC).", + "nullable": true, + "type": "integer" }, - "type": { - "description": "Type of subnet.\n\n- `cloud` - Used to connect cloud [Servers](#servers) and [Load Balancers](#load-balancers).\n- `server` - Same as the `cloud` type. **Deprecated**, use the `cloud` type instead.\n- `vswitch` - Used to [connect cloud Servers and Load Balancers with dedicated Servers](https://docs.hetzner.com/cloud/networks/connect-dedi-vswitch).\n", - "enum": [ - "cloud", - "server", - "vswitch" - ], - "type": "string" + "max_snapshots": { + "description": "Maximum amount of Snapshots that will be created by this Snapshot Plan. Older Snapshots will be deleted.", + "type": "integer" }, - "vswitch_id": { - "description": "ID of the robot vSwitch if the subnet is of type `vswitch`.", - "example": 1000, - "format": "int64", + "minute": { + "description": "Minute the Snapshot Plan is executed at (UTC).", "nullable": true, "type": "integer" } }, "required": [ - "type", - "network_zone", - "gateway" + "max_snapshots" ], "type": "object" }, - "unassign_floating_ip_response": { - "description": "Response to POST https://api.hetzner.cloud/v1/floating_ips/{id}/actions/unassign", + "snapshot_stats": { + "description": "Information about disk usage.", "properties": { - "action": { - "$ref": "#/components/schemas/action" + "size": { + "description": "Current storage requirements of the Snapshot in bytes.", + "type": "integer" + }, + "size_filesystem": { + "description": "Size of the compressed file system contained in the Snapshot in bytes.", + "type": "integer" } }, "required": [ - "action" + "size", + "size_filesystem" ], - "title": "ActionResponse", "type": "object" }, - "unassign_primary_ip_from_resource_response": { - "description": "Response to POST https://api.hetzner.cloud/v1/primary_ips/{id}/actions/unassign", + "soft_reboot_server_response": { + "description": "Response to POST https://api.hetzner.cloud/v1/servers/{id}/actions/reboot", "properties": { "action": { "$ref": "#/components/schemas/action" @@ -6600,156 +7228,62 @@ "title": "ActionResponse", "type": "object" }, - "update_load_balancer_service": { - "description": "An update to a service for a Load Balancer.", + "ssh_key": { + "description": "SSH keys are public keys you provide to the cloud system. They can be injected into Servers at creation time. We highly recommend that you use keys instead of passwords to manage your Servers.", "properties": { - "destination_port": { - "description": "Port the Load Balancer will balance to.", - "example": 80, - "type": "integer" - }, - "health_check": { - "additionalProperties": false, - "description": "Service health check.", - "properties": { - "http": { - "additionalProperties": false, - "description": "Additional configuration for protocol http.", - "properties": { - "domain": { - "description": "Host header to send in the HTTP request. May not contain spaces, percent or backslash symbols. Can be null, in that case no host header is sent.", - "example": "example.com", - "nullable": true, - "type": "string" - }, - "path": { - "description": "HTTP path to use for health checks. May not contain literal spaces, use percent-encoding instead.", - "example": "/", - "type": "string" - }, - "response": { - "description": "String that must be contained in HTTP response in order to pass the health check.", - "example": "{\"status\": \"ok\"}", - "type": "string" - }, - "status_codes": { - "default": [ - "2??", - "3??" - ], - "description": "List of returned HTTP status codes in order to pass the health check. Supports the wildcards `?` for exactly one character and `*` for multiple ones.", - "example": [ - "2??", - "3??" - ], - "items": { - "type": "string" - }, - "type": "array" - }, - "tls": { - "description": "Use HTTPS for health check.", - "example": false, - "type": "boolean" - } - }, - "type": "object" - }, - "interval": { - "description": "Time interval in seconds health checks are performed.", - "example": 15, - "type": "integer" - }, - "port": { - "description": "Port the health check will be performed on.", - "example": 4711, - "type": "integer" - }, - "protocol": { - "description": "Type of the health check.", - "enum": [ - "http", - "tcp" - ], - "example": "http", - "type": "string" - }, - "retries": { - "description": "Unsuccessful retries needed until a target is considered unhealthy; an unhealthy target needs the same number of successful retries to become healthy again.", - "example": 3, - "type": "integer" - }, - "timeout": { - "description": "Time in seconds after an attempt is considered a timeout.", - "example": 10, - "type": "integer" - } - }, - "title": "UpdateLoadBalancerServiceHealthCheck", - "type": "object" + "created": { + "description": "Point in time when the Resource was created (in ISO-8601 format).", + "example": "2016-01-30T23:55:00+00:00", + "type": "string" }, - "http": { - "$ref": "#/components/schemas/http" + "fingerprint": { + "description": "MD5 fingerprint of the SSH public key.", + "example": "b7:2f:30:a0:2f:6c:58:6c:21:04:58:61:ba:06:3b:2f", + "type": "string" }, - "listen_port": { - "description": "Port the Load Balancer listens on.", - "example": 443, + "id": { + "description": "ID of the SSH Key.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, "type": "integer" }, - "protocol": { - "description": "Protocol of the Load Balancer.", - "enum": [ - "http", - "https", - "tcp" - ], - "example": "https", + "labels": { + "$ref": "#/components/schemas/labels" + }, + "name": { + "description": "Name of the Resource. Must be unique per Project.", + "example": "my-resource", "type": "string" }, - "proxyprotocol": { - "description": "Is Proxyprotocol enabled or not.", - "example": false, - "type": "boolean" - } - }, - "required": [ - "listen_port" - ], - "title": "UpdateLoadBalancerService", - "type": "object" - }, - "update_service_request": { - "$ref": "#/components/schemas/update_load_balancer_service" - }, - "update_service_response": { - "description": "Response to POST https://api.hetzner.cloud/v1/load_balancers/{id}/actions/update_service", - "properties": { - "action": { - "$ref": "#/components/schemas/action" + "public_key": { + "description": "Public key.", + "example": "ssh-rsa AAAjjk76kgf...Xt", + "type": "string" } }, "required": [ - "action" + "id", + "name", + "fingerprint", + "public_key", + "labels", + "created" ], - "title": "ActionResponse", "type": "object" }, - "volume": { - "description": "A Volume is a highly-available, scalable, and SSD-based block storage for Servers. Pricing for Volumes depends on the Volume size and Location, not the actual used storage. Please see [Hetzner Wiki](https://wiki.hetzner.de/index.php/CloudServer/en#Volumes) for more details about Volumes.", + "storage_box": { "properties": { + "access_settings": { + "$ref": "#/components/schemas/storage_box_access_setting" + }, "created": { - "description": "Point in time when the Resource was created (in ISO-8601 format).", + "description": "Point in time (in ISO-8601 format).", "example": "2016-01-30T23:55:00+00:00", "type": "string" }, - "format": { - "description": "Filesystem of the Volume if formatted on creation, null if not formatted on creation.", - "example": "xfs", - "nullable": true, - "type": "string" - }, "id": { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -6758,78 +7292,2895 @@ "labels": { "$ref": "#/components/schemas/labels" }, - "linux_device": { - "description": "Device path on the file system for the Volume.", - "example": "/dev/disk/by-id/scsi-0HC_Volume_4711", - "type": "string" - }, "location": { "$ref": "#/components/schemas/location" }, "name": { - "description": "Name of the Resource. Must be unique per Project.", - "example": "my-resource", "type": "string" }, "protection": { "$ref": "#/components/schemas/protection" }, "server": { - "description": "ID of the Server the Volume is attached to, null if it is not attached at all.", - "example": 12, - "format": "int64", + "description": "FQDN of the Storage Box. Not available if the status is \"initializing\".", + "example": "u1337.your-storagebox.de", + "nullable": true, + "type": "string" + }, + "snapshot_plan": { + "$ref": "#/components/schemas/snapshot_plan" + }, + "stats": { + "$ref": "#/components/schemas/storage_box_stats" + }, + "status": { + "enum": [ + "active", + "initializing", + "locked" + ], + "type": "string" + }, + "storage_box_type": { + "$ref": "#/components/schemas/storage_box_type" + }, + "system": { + "description": "Storage Box host system. Not available if the status is \"initializing\".", + "example": "FSN1-BX355", + "nullable": true, + "type": "string" + }, + "username": { + "description": "Primary username of the Storage Box.\n\nNot available if the status is \"initializing\".\n", + "example": "u12345", + "nullable": true, + "type": "string" + } + }, + "required": [ + "id", + "status", + "name", + "storage_box_type", + "location", + "access_settings", + "server", + "system", + "stats", + "labels", + "protection", + "snapshot_plan", + "created" + ], + "type": "object" + }, + "storage_box_access_setting": { + "properties": { + "reachable_externally": { + "description": "Whether the Storage Box is accessible from outside the Hetzner network.", + "type": "boolean" + }, + "samba_enabled": { + "description": "Whether the Samba subsystem is enabled.", + "type": "boolean" + }, + "ssh_enabled": { + "description": "Whether the SSH subsystem is enabled.", + "type": "boolean" + }, + "webdav_enabled": { + "description": "Whether the WebDAV subsystem is enabled.", + "type": "boolean" + }, + "zfs_enabled": { + "description": "Whether the ZFS snapshot folder is visible.", + "type": "boolean" + } + }, + "required": [ + "reachable_externally", + "samba_enabled", + "ssh_enabled", + "webdav_enabled", + "zfs_enabled" + ], + "type": "object" + }, + "storage_box_stats": { + "description": "Information about disk usage. Not available if the status is \"initializing\".", + "nullable": true, + "properties": { + "size": { + "description": "Current disk usage in bytes.", + "type": "integer" + }, + "size_data": { + "description": "Current disk usage for data in bytes.", + "type": "integer" + }, + "size_snapshots": { + "description": "Current disk usage for snapshots in bytes.", + "type": "integer" + } + }, + "required": [ + "size", + "size_data", + "size_snapshots" + ], + "type": "object" + }, + "storage_box_type": { + "properties": { + "automatic_snapshot_limit": { + "description": "Maximum number of snapshots created automatically by a snapshot plan.", + "example": 10, "nullable": true, "type": "integer" }, + "deprecation": { + "$ref": "#/components/schemas/deprecation_info" + }, + "description": { + "description": "Description of the Storage Box type.", + "example": "BX11", + "type": "string" + }, + "id": { + "description": "ID of the Storage Box Type.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "name": { + "description": "Unique identifier of the Storage Box type.", + "example": "bx11", + "type": "string" + }, + "prices": { + "description": "Price per [Location](#locations).", + "items": { + "properties": { + "location": { + "description": "Name of the [Location](#locations) the price is for.", + "example": "fsn1", + "type": "string" + }, + "price_hourly": { + "$ref": "#/components/schemas/price" + }, + "price_monthly": { + "$ref": "#/components/schemas/price" + }, + "setup_fee": { + "$ref": "#/components/schemas/price" + } + }, + "required": [ + "location", + "price_hourly", + "price_monthly", + "setup_fee" + ], + "type": "object" + }, + "type": "array" + }, "size": { - "description": "Size in GB of the Volume.", + "description": "Available storage in bytes.", + "example": 1073741824, + "type": "integer" + }, + "snapshot_limit": { + "description": "Maximum number of allowed manual snapshots.", + "example": 10, + "nullable": true, + "type": "integer" + }, + "subaccounts_limit": { + "description": "Maximum number of subaccounts.", + "example": 200, + "type": "integer" + } + }, + "required": [ + "id", + "name", + "description", + "snapshot_limit", + "automatic_snapshot_limit", + "subaccounts_limit", + "size", + "prices", + "deprecation" + ], + "type": "object" + }, + "subaccount": { + "properties": { + "access_settings": { + "$ref": "#/components/schemas/subaccount_access_setting" + }, + "created": { + "description": "Point in time (in ISO-8601 format).", + "example": "2016-01-30T23:55:00+00:00", + "type": "string" + }, + "description": { + "description": "A description to remind you of the purpose of this Subaccount.", + "example": "host01 backup", + "maxLength": 1000, + "type": "string" + }, + "home_directory": { + "description": "Home directory of the Subaccount.", + "example": "my_backups/host01.my.company", + "type": "string" + }, + "id": { + "description": "ID of the Storage Box Subaccount.", "example": 42, - "type": "number" + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" }, - "status": { - "description": "Status of the Volume.", + "labels": { + "$ref": "#/components/schemas/labels" + }, + "server": { + "description": "FQDN of the Subaccount.", + "example": "u1337-sub1.your-storagebox.de", + "type": "string" + }, + "storage_box": { + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "username": { + "description": "Username of the Subaccount.", + "example": "u1337-sub1", + "type": "string" + } + }, + "required": [ + "id", + "username", + "home_directory", + "server", + "description", + "labels", + "created", + "storage_box" + ], + "type": "object" + }, + "subaccount_access_setting": { + "properties": { + "reachable_externally": { + "description": "Whether the Subaccount is accessible from outside the Hetzner network.", + "type": "boolean" + }, + "readonly": { + "description": "Whether the Subaccount is read-only.", + "type": "boolean" + }, + "samba_enabled": { + "description": "Whether the Samba subsystem is enabled.", + "type": "boolean" + }, + "ssh_enabled": { + "description": "Whether the SSH subsystem is enabled.", + "type": "boolean" + }, + "webdav_enabled": { + "description": "Whether the WebDAV subsystem is enabled.", + "type": "boolean" + } + }, + "required": [ + "reachable_externally", + "readonly", + "samba_enabled", + "ssh_enabled", + "webdav_enabled" + ], + "type": "object" + }, + "subnet": { + "description": "Subnets divide the ip_range from the parent Network object into multiple Subnetworks that you can use for different specific purposes.", + "properties": { + "ip_range": { + "description": "IP range of the subnet.\n\nUses CIDR notation.\n\nMust be a subnet of the parent [Networks](#networks) `ip_range`.\n\nMust not overlap with any other subnets or with any destinations in routes.\n\nMinimum network size is /30. We highly recommend that you pick a larger subnet with a /24 netmask.\n", + "example": "10.0.1.0/24", + "type": "string" + }, + "network_zone": { + "description": "Name of the [Network Zone](#network-zones).\n\nThe [Location](#locations) contains the `network_zone` property it belongs to.\n | Name of the [Network Zone](#network-zones).\n\nThe [Location](#locations) contains the `network_zone` it belongs to.\n", + "example": "eu-central", + "type": "string" + }, + "type": { + "description": "Type of subnet.\n\n- `cloud` - Used to connect cloud [Servers](#servers) and [Load Balancers](#load-balancers).\n- `server` - Same as the `cloud` type. **Deprecated**, use the `cloud` type instead.\n- `vswitch` - Used to [connect cloud Servers and Load Balancers with dedicated Servers](https://docs.hetzner.com/cloud/networks/connect-dedi-vswitch).\n", "enum": [ - "available", - "creating" + "cloud", + "server", + "vswitch" + ], + "type": "string" + }, + "vswitch_id": { + "description": "ID of the robot vSwitch.\n\nMust only be supplied for subnets of type `vswitch`.\n | ID of the robot vSwitch.\n\nMust be supplied if the subnet is of type `vswitch`.\n", + "example": 1000, + "format": "int64", + "type": "integer" + } + }, + "required": [ + "type", + "network_zone" + ], + "type": "object" + }, + "subnet_with_gateway": { + "properties": { + "gateway": { + "description": "Gateway for [Servers](#servers) attached to this subnet.\n\nFor subnets of type `server` this is always the first IP of the subnets IP range.\n", + "example": "10.0.0.1", + "type": "string" + }, + "ip_range": { + "description": "IP range of the subnet.\n\nUses CIDR notation.\n", + "example": "10.0.1.0/24", + "type": "string" + }, + "network_zone": { + "description": "Name of the [Network Zone](#network-zones).\n\nThe [Location](#locations) contains the `network_zone` property it belongs to.\n", + "example": "eu-central", + "type": "string" + }, + "type": { + "description": "Type of subnet.\n\n- `cloud` - Used to connect cloud [Servers](#servers) and [Load Balancers](#load-balancers).\n- `server` - Same as the `cloud` type. **Deprecated**, use the `cloud` type instead.\n- `vswitch` - Used to [connect cloud Servers and Load Balancers with dedicated Servers](https://docs.hetzner.com/cloud/networks/connect-dedi-vswitch).\n", + "enum": [ + "cloud", + "server", + "vswitch" ], - "example": "available", "type": "string" + }, + "vswitch_id": { + "description": "ID of the robot vSwitch if the subnet is of type `vswitch`.", + "example": 1000, + "format": "int64", + "nullable": true, + "type": "integer" + } + }, + "required": [ + "type", + "network_zone", + "gateway" + ], + "type": "object" + }, + "unassign_floating_ip_response": { + "description": "Response to POST https://api.hetzner.cloud/v1/floating_ips/{id}/actions/unassign", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, + "unassign_primary_ip_from_resource_response": { + "description": "Response to POST https://api.hetzner.cloud/v1/primary_ips/{id}/actions/unassign", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, + "update_access_settings_request": { + "description": "Request for POST https://api.hetzner.com/v1/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/update_access_settings", + "properties": { + "home_directory": { + "description": "Home directory of the Subaccount. Will be created if it doesn't exist yet.", + "example": "my-backup/server01", + "nullable": true, + "type": "string" + }, + "reachable_externally": { + "description": "Whether the Subaccount should be accessible from outside the Hetzner network.", + "nullable": true, + "type": "boolean" + }, + "readonly": { + "description": "Whether the Subaccount should be read-only.", + "nullable": true, + "type": "boolean" + }, + "samba_enabled": { + "description": "Whether the Samba subsystem should be enabled.", + "nullable": true, + "type": "boolean" + }, + "ssh_enabled": { + "description": "Whether the SSH subsystem should be enabled.", + "example": true, + "nullable": true, + "type": "boolean" + }, + "webdav_enabled": { + "description": "Whether the WebDAV subsystem should be enabled.", + "nullable": true, + "type": "boolean" + } + }, + "title": "UpdateAccessSettings", + "type": "object" + }, + "update_access_settings_response": { + "description": "Response to POST https://api.hetzner.com/v1/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/update_access_settings", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, + "update_load_balancer_service": { + "description": "An update to a service for a Load Balancer.", + "properties": { + "destination_port": { + "description": "Port the Load Balancer will balance to.", + "example": 80, + "type": "integer" + }, + "health_check": { + "additionalProperties": false, + "description": "Service health check.", + "properties": { + "http": { + "additionalProperties": false, + "description": "Additional configuration for protocol http.", + "properties": { + "domain": { + "description": "Host header to send in the HTTP request. May not contain spaces, percent or backslash symbols. Can be null, in that case no host header is sent.", + "example": "example.com", + "nullable": true, + "type": "string" + }, + "path": { + "description": "HTTP path to use for health checks. May not contain literal spaces, use percent-encoding instead.", + "example": "/", + "type": "string" + }, + "response": { + "description": "String that must be contained in HTTP response in order to pass the health check.", + "example": "{\"status\": \"ok\"}", + "type": "string" + }, + "status_codes": { + "default": [ + "2??", + "3??" + ], + "description": "List of returned HTTP status codes in order to pass the health check. Supports the wildcards `?` for exactly one character and `*` for multiple ones.", + "example": [ + "2??", + "3??" + ], + "items": { + "type": "string" + }, + "type": "array" + }, + "tls": { + "description": "Use HTTPS for health check.", + "example": false, + "type": "boolean" + } + }, + "type": "object" + }, + "interval": { + "description": "Time interval in seconds health checks are performed.", + "example": 15, + "type": "integer" + }, + "port": { + "description": "Port the health check will be performed on.", + "example": 4711, + "type": "integer" + }, + "protocol": { + "description": "Type of the health check.", + "enum": [ + "http", + "tcp" + ], + "example": "http", + "type": "string" + }, + "retries": { + "description": "Unsuccessful retries needed until a target is considered unhealthy; an unhealthy target needs the same number of successful retries to become healthy again.", + "example": 3, + "type": "integer" + }, + "timeout": { + "description": "Time in seconds after an attempt is considered a timeout.", + "example": 10, + "type": "integer" + } + }, + "title": "UpdateLoadBalancerServiceHealthCheck", + "type": "object" + }, + "http": { + "$ref": "#/components/schemas/http" + }, + "listen_port": { + "description": "Port the Load Balancer listens on.", + "example": 443, + "type": "integer" + }, + "protocol": { + "description": "Protocol of the Load Balancer.", + "enum": [ + "http", + "https", + "tcp" + ], + "example": "https", + "type": "string" + }, + "proxyprotocol": { + "description": "Is Proxyprotocol enabled or not.", + "example": false, + "type": "boolean" + } + }, + "required": [ + "listen_port" + ], + "title": "UpdateLoadBalancerService", + "type": "object" + }, + "update_service_request": { + "$ref": "#/components/schemas/update_load_balancer_service" + }, + "update_service_response": { + "description": "Response to POST https://api.hetzner.cloud/v1/load_balancers/{id}/actions/update_service", + "properties": { + "action": { + "$ref": "#/components/schemas/action" + } + }, + "required": [ + "action" + ], + "title": "ActionResponse", + "type": "object" + }, + "volume": { + "description": "A Volume is a highly-available, scalable, and SSD-based block storage for Servers. Pricing for Volumes depends on the Volume size and Location, not the actual used storage. Please see [Hetzner Wiki](https://wiki.hetzner.de/index.php/CloudServer/en#Volumes) for more details about Volumes.", + "properties": { + "created": { + "description": "Point in time when the Resource was created (in ISO-8601 format).", + "example": "2016-01-30T23:55:00+00:00", + "type": "string" + }, + "format": { + "description": "Filesystem of the Volume if formatted on creation, null if not formatted on creation.", + "example": "xfs", + "nullable": true, + "type": "string" + }, + "id": { + "description": "ID of the Volume.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "labels": { + "$ref": "#/components/schemas/labels" + }, + "linux_device": { + "description": "Device path on the file system for the Volume.", + "example": "/dev/disk/by-id/scsi-0HC_Volume_4711", + "type": "string" + }, + "location": { + "$ref": "#/components/schemas/location" + }, + "name": { + "description": "Name of the Resource. Must be unique per Project.", + "example": "my-resource", + "type": "string" + }, + "protection": { + "$ref": "#/components/schemas/protection" + }, + "server": { + "description": "ID of the Server the Volume is attached to, null if it is not attached at all.", + "example": 12, + "format": "int64", + "nullable": true, + "type": "integer" + }, + "size": { + "description": "Size in GB of the Volume.", + "example": 42, + "type": "number" + }, + "status": { + "description": "Status of the Volume.", + "enum": [ + "available", + "creating" + ], + "example": "available", + "type": "string" + } + }, + "required": [ + "id", + "created", + "name", + "server", + "location", + "size", + "linux_device", + "protection", + "labels", + "status", + "format" + ], + "type": "object" + } + }, + "securitySchemes": { + "APIToken": { + "scheme": "bearer", + "type": "http" + } + } + }, + "paths": { + "/actions": { + "get": { + "description": "Returns multiple Action objects specified by the `id` parameter.\n\n**Note**: This endpoint previously allowed listing all actions in the project. This functionality was deprecated in July 2023 and removed on 30 January 2025.\n\n- Announcement: https://docs.hetzner.cloud/changelog#2023-07-20-actions-list-endpoint-is-deprecated\n- Removal: https://docs.hetzner.cloud/changelog#2025-01-30-listing-arbitrary-actions-in-the-actions-list-endpoint-is-removed\n", + "operationId": "get_multiple_actions", + "parameters": [ + { + "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", + "in": "query", + "name": "id", + "required": true, + "schema": { + "items": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "type": "array" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_multiple_actions_response" + } + } + }, + "description": "Response for listing [Actions](#actions)." + } + }, + "summary": "Get multiple Actions", + "tags": [ + "actions" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Action.AllWithOpts(ctx, hcloud.ActionListOpts{ID: []int64{123, 456}})\n}" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/actions/{id}": { + "get": { + "description": "Returns a specific Action object.", + "operationId": "get_action", + "parameters": [ + { + "description": "ID of the Action", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_action_response" + } + } + }, + "description": "Response for getting an [Action](#actions)." + } + }, + "summary": "Get an Action", + "tags": [ + "actions" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Action.GetByID(ctx, 123)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.actions.get_by_id(123)" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/certificates": { + "get": { + "description": "Returns all Certificate objects.", + "operationId": "list_certificates", + "parameters": [ + { + "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "name", + "name:asc", + "name:desc", + "created", + "created:asc", + "created:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "in": "query", + "name": "label_selector", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter resources by type. Can be used multiple times. The response will only\ncontain the resources with the specified type.\n", + "in": "query", + "name": "type", + "required": false, + "schema": { + "items": { + "description": "Type of the Certificate.", + "enum": [ + "uploaded", + "managed" + ], + "example": "uploaded", + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "certificates": [ + { + "certificate": "-----BEGIN CERTIFICATE-----\n...", + "created": "2019-01-08T12:10:00+00:00", + "domain_names": [ + "example.com", + "webmail.example.com", + "www.example.com" + ], + "fingerprint": "03:c7:55:9b:2a:d1:04:17:09:f6:d0:7f:18:34:63:d4:3e:5f", + "id": 897, + "labels": { + "key": "value" + }, + "name": "my website cert", + "not_valid_after": "2019-07-08T09:59:59+00:00", + "not_valid_before": "2019-01-08T10:00:00+00:00", + "status": null, + "type": "uploaded", + "used_by": [ + { + "id": 4711, + "type": "load_balancer" + } + ] + } + ], + "meta": { + "pagination": { + "last_page": 1, + "next_page": null, + "page": 1, + "per_page": 25, + "previous_page": null, + "total_entries": 21 + } + } + }, + "schema": { + "$ref": "#/components/schemas/list_certificates_response" + } + } + }, + "description": "The `certificates` key contains an array of Certificate objects." + } + }, + "summary": "List Certificates", + "tags": [ + "certificates" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tcertificates, err := client.Certificate.All(ctx)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ncertificates = client.certificates.get_all()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud certificate list" + } + ] + }, + "post": { + "description": "Creates a new Certificate.\n\nThe default type **uploaded** allows for uploading your existing `certificate` and `private_key` in PEM format. You have to monitor its expiration date and handle renewal yourself.\n\nIn contrast, type **managed** requests a new Certificate from *Let's Encrypt* for the specified `domain_names`. Only domains managed by *Hetzner DNS* are supported. We handle renewal and timely alert the project owner via email if problems occur.\n\nFor type `managed` Certificates the `action` key of the response contains the Action that allows for tracking the issuance process. For type `uploaded` Certificates the `action` is always null.\n", + "operationId": "create_certificate", + "requestBody": { + "content": { + "application/json": { + "examples": { + "managed": { + "summary": "Creating a type `managed` Certificate", + "value": { + "domain_names": [ + "example.com", + "webmail.example.com", + "www.example.com" + ], + "name": "my website cert", + "type": "managed" + } + }, + "uploaded": { + "summary": "Creating a type `uploaded` Certificate", + "value": { + "certificate": "-----BEGIN CERTIFICATE-----\n...", + "name": "my website cert", + "private_key": "-----BEGIN PRIVATE KEY-----\n...", + "type": "uploaded" + } + } + }, + "schema": { + "$ref": "#/components/schemas/create_certificate_request" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "examples": { + "managed": { + "summary": "Response when creating a type `managed` Certificate", + "value": { + "action": { + "command": "create_certificate", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 879, + "type": "certificate" + } + ], + "started": "2019-01-08T12:10:00+00:00", + "status": "running" + }, + "certificate": { + "certificate": null, + "created": "2019-01-08T12:10:00+00:00", + "domain_names": [ + "example.com", + "webmail.example.com", + "www.example.com" + ], + "fingerprint": null, + "id": 897, + "labels": { + "key": "value" + }, + "name": "my website cert", + "not_valid_after": null, + "not_valid_before": null, + "status": { + "error": null, + "issuance": "pending", + "renewal": "unavailable" + }, + "type": "managed", + "used_by": [ + { + "id": 4711, + "type": "load_balancer" + } + ] + } + } + }, + "uploaded": { + "summary": "Response when creating a type `uploaded` Certificate", + "value": { + "action": null, + "certificate": { + "certificate": "-----BEGIN CERTIFICATE-----\n...", + "created": "2019-01-08T12:10:00+00:00", + "domain_names": [ + "example.com", + "webmail.example.com", + "www.example.com" + ], + "fingerprint": "03:c7:55:9b:2a:d1:04:17:09:f6:d0:7f:18:34:63:d4:3e:5f", + "id": 897, + "labels": { + "key": "value" + }, + "name": "my website cert", + "not_valid_after": "2019-07-08T09:59:59+00:00", + "not_valid_before": "2019-01-08T10:00:00+00:00", + "status": null, + "type": "uploaded", + "used_by": [ + { + "id": 4711, + "type": "load_balancer" + } + ] + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/create_certificate_response" + } + } + }, + "description": "The `certificate` key contains the Certificate that was just created. For type `managed` Certificates the `action` key contains the Action that allows for tracking the issuance process. For type `uploaded` Certificates the `action` is always null." + } + }, + "summary": "Create a Certificate", + "tags": [ + "certificates" + ], + "x-codeSamples": [ + { + "label": "Go (managed)", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tcertificate, _, err := client.Certificate.Create(ctx, hcloud.CertificateCreateOpts{\n\t\tDomainNames: []string{\n\t\t\t\"example.com\",\n\t\t\t\"webmail.example.com\",\n\t\t\t\"www.example.com\",\n\t\t},\n\t\tName: \"my website cert\",\n\t\tType: hcloud.CertificateTypeManaged,\n\t})\n}" + }, + { + "label": "Go (uploaded)", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tcertificate, _, err := client.Certificate.Create(ctx, hcloud.CertificateCreateOpts{\n\t\tCertificate: \"-----BEGIN CERTIFICATE-----\\n...\",\n\t\tName: \"my website cert\",\n\t\tPrivateKey: \"-----BEGIN PRIVATE KEY-----\\n...\",\n\t\tType: hcloud.CertificateTypeUploaded,\n\t})\n}" + }, + { + "label": "Python (managed)", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ncertificate = client.certificates.create_managed(\n domain_names=[\n \"example.com\",\n \"webmail.example.com\",\n \"www.example.com\",\n ],\n name=\"my website cert\",\n)" + }, + { + "label": "Python (uploaded)", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ncertificate = client.certificates.create(\n certificate=\"-----BEGIN CERTIFICATE-----\\n...\",\n name=\"my website cert\",\n private_key=\"-----BEGIN PRIVATE KEY-----\\n...\",\n)" + }, + { + "label": "CLI (managed)", + "lang": "Shell", + "source": "hcloud certificate create \\\n --name \"my website cert\" \\\n --type managed \\\n --domain example.com \\\n --domain webmail.example.com \\\n --domain www.example.com" + }, + { + "label": "CLI (uploaded)", + "lang": "Shell", + "source": "hcloud certificate create \\\n --name \"my website cert\" \\\n --type uploaded \\\n --cert-file my-cert.pem \\\n --key-file my-key.pem" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/certificates/{id}": { + "delete": { + "description": "Deletes a Certificate.", + "operationId": "delete_certificate", + "parameters": [ + { + "description": "ID of the Certificate.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Certificate.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "204": { + "description": "Certificate deleted." + } + }, + "summary": "Delete a Certificate", + "tags": [ + "certificates" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.Certificate.Delete(ctx, &hcloud.Certificate{ID: 123})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.certificates.delete(certificate=Certificate(id=123))" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud certificate delete $CERTIFICATE" + } + ] + }, + "get": { + "description": "Gets a specific Certificate object.", + "operationId": "get_certificate", + "parameters": [ + { + "description": "ID of the Certificate.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Certificate.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "certificate": { + "certificate": "-----BEGIN CERTIFICATE-----\n...", + "created": "2019-01-08T12:10:00+00:00", + "domain_names": [ + "example.com", + "webmail.example.com", + "www.example.com" + ], + "fingerprint": "03:c7:55:9b:2a:d1:04:17:09:f6:d0:7f:18:34:63:d4:3e:5f", + "id": 897, + "labels": { + "key": "value" + }, + "name": "my website cert", + "not_valid_after": "2019-07-08T09:59:59+00:00", + "not_valid_before": "2019-01-08T10:00:00+00:00", + "status": null, + "type": "uploaded", + "used_by": [ + { + "id": 4711, + "type": "load_balancer" + } + ] + } + }, + "schema": { + "$ref": "#/components/schemas/get_certificate_response" + } + } + }, + "description": "The `certificate` key contains a Certificate object." + } + }, + "summary": "Get a Certificate", + "tags": [ + "certificates" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tcertificate, _, err := client.Certificate.GetByID(ctx, 123)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ncertificate = client.certificates.get_by_id(123)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud certificate describe $CERTIFICATE" + } + ] + }, + "put": { + "description": "Updates the Certificate properties.\n\nNote: if the Certificate object changes during the request, the response will be a “conflict” error.\n", + "operationId": "replace_certificate", + "parameters": [ + { + "description": "ID of the Certificate.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Certificate.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/replace_certificate_request" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "certificate": { + "certificate": "-----BEGIN CERTIFICATE-----\n...", + "created": "2019-01-08T12:10:00+00:00", + "domain_names": [ + "example.com", + "webmail.example.com", + "www.example.com" + ], + "fingerprint": "03:c7:55:9b:2a:d1:04:17:09:f6:d0:7f:18:34:63:d4:3e:5f", + "id": 897, + "labels": { + "key": "value" + }, + "name": "my website cert", + "not_valid_after": "2019-07-08T09:59:59+00:00", + "not_valid_before": "2019-01-08T10:00:00+00:00", + "status": null, + "type": "uploaded", + "used_by": [ + { + "id": 4711, + "type": "load_balancer" + } + ] + } + }, + "schema": { + "$ref": "#/components/schemas/replace_certificate_response" + } + } + }, + "description": "The `certificate` key contains the Certificate that was just updated." + } + }, + "summary": "Update a Certificate", + "tags": [ + "certificates" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tcertificate, _, err := client.Certificate.Update(ctx, &hcloud.Certificate{ID: 123}, hcloud.CertificateUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"my website cert\",\n\t})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ncertificate = client.certificates.update(\n certificate=Certificate(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my website cert\",\n)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud certificate update $CERTIFICATE --name \"my website cert\"\nhcloud certificate add-label --overwrite $CERTIFICATE \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud certificate remove-label $CERTIFICATE \\\n \"environment\" \"example.com\" \"just-a-key\"" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/certificates/{id}/actions": { + "get": { + "description": "Returns all Action objects for a Certificate. You can sort the results by using the `sort` URI parameter, and filter them with the `status` parameter.\n\nOnly type `managed` Certificates can have Actions. For type `uploaded` Certificates the `actions` key will always contain an empty array.\n", + "operationId": "list_actions_for_certificate", + "parameters": [ + { + "description": "ID of the Certificate", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Certificate. Limited to 52 bits to ensure compatability with JSON double precision floats.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "title": "Certificate ID", + "type": "integer" + } + }, + { + "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "command", + "command:asc", + "command:desc", + "status", + "status:asc", + "status:desc", + "started", + "started:asc", + "started:desc", + "finished", + "finished:asc", + "finished:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Action.", + "enum": [ + "running", + "success", + "error" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "actions": [ + { + "command": "issue_certificate", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2021-01-30T23:57:00+00:00", + "id": 14, + "progress": 100, + "resources": [ + { + "id": 896, + "type": "certificate" + } + ], + "started": "2021-01-30T23:55:00+00:00", + "status": "success" + } + ], + "meta": { + "pagination": { + "last_page": 1, + "next_page": null, + "page": 1, + "per_page": 25, + "previous_page": null, + "total_entries": 21 + } + } + }, + "schema": { + "$ref": "#/components/schemas/list_actions_response" + } + } + }, + "description": "The `actions` key contains a list of Actions." + } + }, + "summary": "List Actions for a Certificate", + "tags": [ + "certificates" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/certificates/{id}/actions/{action_id}": { + "get": { + "description": "Returns a specific Action for a Certificate. Only type `managed` Certificates have Actions.", + "operationId": "get_action_for_certificate", + "parameters": [ + { + "description": "ID of the Certificate.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Certificate.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + { + "description": "ID of the Action.", + "in": "path", + "name": "action_id", + "required": true, + "schema": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "action": { + "command": "issue_certificate", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2021-01-30T23:57:00+00:00", + "id": 14, + "progress": 100, + "resources": [ + { + "id": 896, + "type": "certificate" + } + ], + "started": "2021-01-30T23:55:00+00:00", + "status": "success" + } + }, + "schema": { + "$ref": "#/components/schemas/get_action_response" + } + } + }, + "description": "The `action` key contains the Certificate Action." + } + }, + "summary": "Get an Action for a Certificate", + "tags": [ + "certificates" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/certificates/{id}/actions/retry": { + "post": { + "description": "Retry a failed Certificate issuance or renewal.\n\nOnly applicable if the type of the Certificate is `managed` and the issuance or renewal status is `failed`.\n\n#### Call specific error codes\n\n| Code | Description |\n|---------------------------------------------------------|---------------------------------------------------------------------------|\n| `caa_record_does_not_allow_ca` | CAA record does not allow certificate authority |\n| `ca_dns_validation_failed` | Certificate Authority: DNS validation failed |\n| `ca_too_many_authorizations_failed_recently` | Certificate Authority: Too many authorizations failed recently |\n| `ca_too_many_certificates_issued_for_registered_domain` | Certificate Authority: Too many certificates issued for registered domain |\n| `ca_too_many_duplicate_certificates` | Certificate Authority: Too many duplicate certificates |\n| `could_not_verify_domain_delegated_to_zone` | Could not verify domain delegated to zone |\n| `dns_zone_not_found` | DNS zone not found |\n| `dns_zone_is_secondary_zone` | DNS zone is a secondary zone |\n", + "operationId": "retry_issuance_or_renewal", + "parameters": [ + { + "description": "ID of the Certificate.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Certificate.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "201": { + "content": { + "application/json": { + "example": { + "action": { + "command": "issue_certificate", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2021-01-30T23:57:00+00:00", + "id": 14, + "progress": 100, + "resources": [ + { + "id": 896, + "type": "certificate" + } + ], + "started": "2021-01-30T23:55:00+00:00", + "status": "success" + } + }, + "schema": { + "$ref": "#/components/schemas/retry_issuance_or_renewal_response" + } + } + }, + "description": "The `action` key contains the resulting Action." + } + }, + "summary": "Retry Issuance or Renewal", + "tags": [ + "certificates" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Certificate.RetryIssuance(ctx, &hcloud.Certificate{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.certificates.retry_issuance(certificate=Certificate(id=123))\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud certificate retry $CERTIFICATE" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/certificates/actions": { + "get": { + "description": "Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.", + "operationId": "list_certificate_actions", + "parameters": [ + { + "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", + "in": "query", + "name": "id", + "required": false, + "schema": { + "items": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "type": "array" + } + }, + { + "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "command", + "command:asc", + "command:desc", + "status", + "status:asc", + "status:desc", + "started", + "started:asc", + "started:desc", + "finished", + "finished:asc", + "finished:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Action.", + "enum": [ + "running", + "success", + "error" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/list_actions_response" + } + } + }, + "description": "The `actions` key contains a list of Actions." + } + }, + "summary": "List Actions", + "tags": [ + "certificates" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Certificate.Action.All(ctx, hcloud.ActionListOpts{})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.certificates.actions.get_all()" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/certificates/actions/{id}": { + "get": { + "description": "Returns a specific Action object.", + "operationId": "get_certificate_action", + "parameters": [ + { + "description": "ID of the Action", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_action_response" + } + } + }, + "description": "The `action` key in the reply has this structure." + } + }, + "summary": "Get an Action", + "tags": [ + "certificates" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Certificate.Action.GetByID(ctx, 123)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.certificates.actions.get_by_id(123)" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/datacenters": { + "get": { + "description": "Returns all [Datacenters](#datacenters).", + "operationId": "list_datacenters", + "parameters": [ + { + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "name", + "name:asc", + "name:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/list_datacenters_response" + } + } + }, + "description": "Contains the queried [Datacenters](#datacenters)." + } + }, + "summary": "List Datacenters", + "tags": [ + "datacenters" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tdatacenters, err := client.Datacenter.All(ctx)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ndatacenters = client.datacenters.get_all()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud datacenter list" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/datacenters/{id}": { + "get": { + "description": "Returns a single [Datacenter](#datacenters).", + "operationId": "get_datacenter", + "parameters": [ + { + "description": "ID of the Datacenter.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Datacenter.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_datacenter_response" + } + } + }, + "description": "Contains the queried [Datacenter](#datacenters)." + } + }, + "summary": "Get a Datacenter", + "tags": [ + "datacenters" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tdatacenter, _, err := client.Datacenter.GetByID(ctx, 123)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ndatacenter = client.datacenters.get_by_id(123)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud datacenter describe $DATACENTER" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/firewalls": { + "get": { + "description": "Returns all [Firewalls](#firewalls).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_firewalls", + "parameters": [ + { + "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "name", + "name:asc", + "name:desc", + "created", + "created:asc", + "created:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "in": "query", + "name": "label_selector", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/list_firewalls_response" + } + } + }, + "description": "The `firewalls` key contains the [Firewalls](#firewalls)." + } + }, + "summary": "List Firewalls", + "tags": [ + "firewalls" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfirewalls, err := client.Firewall.All(ctx)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nfirewalls = client.firewalls.get_all()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud firewall list" + } + ] + }, + "post": { + "description": "Create a [Firewall](#firewalls).\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|------------------------------ |-----------------------------------------------------------------------------|\n| `server_already_added` | [Server](#servers) applied more than once |\n| `incompatible_network_type` | The resources network type is not supported by [Firewalls](#firewalls) |\n| `firewall_resource_not_found` | The resource the [Firewall](#firewalls) should be attached to was not found |\n", + "operationId": "create_firewall", + "requestBody": { + "content": { + "application/json": { + "example": { + "apply_to": [ + { + "server": { + "id": 42 + }, + "type": "server" + } + ], + "labels": { + "key": "value" + }, + "name": "Corporate Intranet Protection", + "rules": [ + { + "description": "Allow port 80", + "direction": "in", + "port": "80", + "protocol": "tcp", + "source_ips": [ + "28.239.13.1/32", + "28.239.14.0/24", + "ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b/128" + ] + } + ] + }, + "schema": { + "$ref": "#/components/schemas/create_firewall_request" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/create_firewall_response" + } + } + }, + "description": "The `firewall` key contains the created [Firewall](#firewalls)." + } + }, + "summary": "Create a Firewall", + "tags": [ + "firewalls" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nimport (\n\t\"net\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Firewall.Create(ctx, hcloud.FirewallCreateOpts{\n\t\tApplyTo: []hcloud.FirewallResource{\n\t\t\t{\n\t\t\t\tType: hcloud.FirewallResourceTypeServer,\n\t\t\t\tServer: &hcloud.FirewallResourceServer{\n\t\t\t\t\tID: 42,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tLabels: map[string]string{\n\t\t\t\"env\": \"dev\",\n\t\t},\n\t\tName: \"Corporate Intranet Protection\",\n\t\tRules: []hcloud.FirewallRule{\n\t\t\t{\n\t\t\t\tDescription: hcloud.Ptr(\"Allow port 80\"),\n\t\t\t\tDirection: hcloud.FirewallRuleDirectionIn,\n\t\t\t\tPort: hcloud.Ptr(\"80\"),\n\t\t\t\tProtocol: hcloud.FirewallRuleProtocolTCP,\n\t\t\t\tSourceIPs: []net.IPNet{\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"28.239.13.1\"),\n\t\t\t\t\t\tMask: net.CIDRMask(32, 32),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"28.239.14.0\"),\n\t\t\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b\"),\n\t\t\t\t\t\tMask: net.CIDRMask(128, 128),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Actions...)\n\n\tfirewall := result.Firewall\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import FirewallResource, FirewallRule\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.firewalls.create(\n resources=[\n FirewallResource(\n type=\"server\",\n server=Server(id=42),\n )\n ],\n labels={\n \"env\": \"dev\",\n },\n name=\"Corporate Intranet Protection\",\n rules=[\n FirewallRule(\n description=\"Allow port 80\",\n direction=\"in\",\n port=\"80\",\n protocol=\"tcp\",\n source_ips=[\n \"28.239.13.1\",\n \"28.239.14.0/24\",\n \"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b\",\n ],\n )\n ],\n)\n\nfor action in response.actions:\n action.wait_until_finished()\n\nfirewall = response.firewall" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud firewall create \\\n --name \"Corporate Intranet Protection\" \\\n --label \"env=dev\" \\\n --rules-file <(echo '[\n {\n \"description\": \"Allow port 80\",\n \"direction\": \"in\",\n \"port\": \"80\",\n \"protocol\": \"tcp\",\n \"source_ips\": [\n \"28.239.13.1/32\",\n \"28.239.14.0/24\",\n \"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b/128\"\n ]\n }\n]')" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/firewalls/{id}": { + "delete": { + "description": "Deletes the [Firewall](#firewalls).\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|--------------------- |----------------------------------------------------|\n| `resource_in_use` | [Firewall](#firewalls) still applied to a resource |\n", + "operationId": "delete_firewall", + "parameters": [ + { + "description": "ID of the Firewall.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Firewall.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "204": { + "description": "Firewall deleted." + } + }, + "summary": "Delete a Firewall", + "tags": [ + "firewalls" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.Firewall.Delete(ctx, &hcloud.Firewall{ID: 123})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.firewalls.delete(firewall=Firewall(id=123))" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud firewall delete $FIREWALL" + } + ] + }, + "get": { + "description": "Returns a single [Firewall](#firewalls).", + "operationId": "get_firewall", + "parameters": [ + { + "description": "ID of the Firewall.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Firewall.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_firewall_response" + } + } + }, + "description": "The `firewall` key contains the [Firewall](#firewalls)." + } + }, + "summary": "Get a Firewall", + "tags": [ + "firewalls" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfirewall, _, err := client.Firewall.GetByID(ctx, 123)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nfirewall = client.firewalls.get_by_id(123)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud firewall describe $FIREWALL" + } + ] + }, + "put": { + "description": "Update a [Firewall](#firewalls).\n\nIn case of a parallel running change on the [Firewall](#firewalls) a `conflict` error will be returned.\n", + "operationId": "replace_firewall", + "parameters": [ + { + "description": "ID of the Firewall.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Firewall.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/replace_firewall_request" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/replace_firewall_response" + } + } + }, + "description": "The `firewall` key contains the updated [Firewall](#firewalls)." + } + }, + "summary": "Update a Firewall", + "tags": [ + "firewalls" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfirewall, _, err := client.Firewall.Update(ctx, &hcloud.Firewall{ID: 123}, hcloud.FirewallUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"new-name\",\n\t})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.firewalls.update(\n firewall=Firewall(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"new-name\",\n)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud firewall update $FIREWALL --name \"new-name\"\nhcloud firewall add-label --overwrite $FIREWALL \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud firewall remove-label $FIREWALL \\\n \"environment\" \"example.com\" \"just-a-key\"" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/firewalls/{id}/actions": { + "get": { + "description": "Returns all [Actions](#actions) for the [Firewall](#firewalls).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_actions_for_firewall", + "parameters": [ + { + "description": "ID of the Firewall", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Firewall. Limited to 52 bits to ensure compatability with JSON double precision floats.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "title": "Firewall ID", + "type": "integer" + } + }, + { + "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "command", + "command:asc", + "command:desc", + "status", + "status:asc", + "status:desc", + "started", + "started:asc", + "started:desc", + "finished", + "finished:asc", + "finished:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Action.", + "enum": [ + "running", + "success", + "error" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "actions": [ + { + "command": "set_firewall_rules", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 38, + "type": "firewall" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + ], + "meta": { + "pagination": { + "last_page": 1, + "next_page": null, + "page": 1, + "per_page": 25, + "previous_page": null, + "total_entries": 21 + } + } + }, + "schema": { + "$ref": "#/components/schemas/list_actions_response" + } + } + }, + "description": "The `actions` key contains a list of [Actions](#actions)." + } + }, + "summary": "List Actions for a Firewall", + "tags": [ + "firewalls" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/firewalls/{id}/actions/{action_id}": { + "get": { + "description": "Returns a specific [Action](#actions) for a [Firewall](#firewalls).", + "operationId": "get_action_for_firewall", + "parameters": [ + { + "description": "ID of the Firewall.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Firewall.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + { + "description": "ID of the Action.", + "in": "path", + "name": "action_id", + "required": true, + "schema": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "action": { + "command": "set_firewall_rules", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 38, + "type": "firewall" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, + "schema": { + "$ref": "#/components/schemas/get_action_response" + } + } + }, + "description": "The `action` key contains the [Firewall](#firewalls) [Action](#actions)." + } + }, + "summary": "Get an Action for a Firewall", + "tags": [ + "firewalls" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/firewalls/{id}/actions/apply_to_resources": { + "post": { + "description": "Applies a [Firewall](#firewalls) to multiple resources.\n\nSupported resources:\n- [Servers](#servers) (with a public network interface)\n- [Label Selectors](#label-selector)\n\nA server can be applied to [a maximum of 5 Firewalls](https://docs.hetzner.com/cloud/firewalls/overview#limits).\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|-------------------------------|-------------------------------------------------------------------------------------------------|\n| `firewall_already_applied` | [Firewall](#firewalls) is already applied to resource |\n| `incompatible_network_type` | The network type of the resource is not supported by [Firewalls](#firewalls) |\n| `firewall_resource_not_found` | The resource the [Firewall](#firewalls) should be applied to was not found |\n| `private_net_only_server` | The [Server](#servers) the [Firewall](#firewalls) should be applied to has no public interface |\n", + "operationId": "apply_to_resources", + "parameters": [ + { + "description": "ID of the Firewall.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Firewall.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "example": { + "apply_to": [ + { + "server": { + "id": 42 + }, + "type": "server" + } + ] + }, + "schema": { + "$ref": "#/components/schemas/apply_to_resources_request" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "example": { + "actions": [ + { + "command": "apply_firewall", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 14, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" + }, + { + "id": 38, + "type": "firewall" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + ] + }, + "schema": { + "$ref": "#/components/schemas/apply_to_resources_response" + } + } + }, + "description": "The `actions` key contains multiple [Actions](#actions) with the `apply_firewall` command." + } + }, + "summary": "Apply to Resources", + "tags": [ + "firewalls" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, _, err := client.Firewall.ApplyResources(ctx, &hcloud.Firewall{ID: 123}, []hcloud.FirewallResource{\n\t\t{\n\t\t\tType: hcloud.FirewallResourceTypeServer,\n\t\t\tServer: &hcloud.FirewallResourceServer{\n\t\t\t\tID: 42,\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, actions...)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall, FirewallResource\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.firewalls.apply_to_resources(\n firewall=Firewall(id=123),\n resources=[\n FirewallResource(\n type=\"server\",\n server=Server(id=42),\n )\n ],\n)\n\nfor action in actions:\n action.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud firewall apply-to-resource $FIREWALL \\\n --type server \\\n --server $SERVER" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/firewalls/{id}/actions/remove_from_resources": { + "post": { + "description": "Removes a [Firewall](#firewalls) from multiple resources.\n\nSupported resources:\n- [Servers](#servers) (with a public network interface)\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|---------------------------------------|---------------------------------------------------------------------------------------------------------|\n| `firewall_already_removed` | [Firewall](#firewalls) is already removed from the resource |\n| `firewall_resource_not_found` | The resource the [Firewall](#firewalls) should be removed from was not found |\n| `firewall_managed_by_label_selector` | [Firewall](#firewall) is applied via a [Label Selector](#label-selector) and cannot be removed manually |\n", + "operationId": "remove_from_resources", + "parameters": [ + { + "description": "ID of the Firewall.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Firewall.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "example": { + "remove_from": [ + { + "server": { + "id": 42 + }, + "type": "server" + } + ] + }, + "schema": { + "$ref": "#/components/schemas/remove_from_resources_request" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "example": { + "actions": [ + { + "command": "remove_firewall", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 14, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" + }, + { + "id": 38, + "type": "firewall" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + ] + }, + "schema": { + "$ref": "#/components/schemas/remove_from_resources_response" + } + } + }, + "description": "The `actions` key contains multiple [Actions](#actions) with the `remove_firewall` command." + } + }, + "summary": "Remove from Resources", + "tags": [ + "firewalls" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, _, err := client.Firewall.RemoveResources(ctx, &hcloud.Firewall{ID: 123}, []hcloud.FirewallResource{\n\t\t{\n\t\t\tType: hcloud.FirewallResourceTypeServer,\n\t\t\tServer: &hcloud.FirewallResourceServer{\n\t\t\t\tID: 42,\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, actions...)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall, FirewallResource\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.firewalls.remove_from_resources(\n firewall=Firewall(id=123),\n resources=[\n FirewallResource(\n type=\"server\",\n server=Server(id=42),\n )\n ],\n)\n\nfor action in actions:\n action.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud firewall remove-from-resource $FIREWALL \\\n --type server \\\n --server $SERVER" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/firewalls/{id}/actions/set_rules": { + "post": { + "description": "Set the rules of a [Firewall](#firewalls).\n\nOverwrites the existing rules with the given ones. Pass an empty array to remove all rules.\n\nRules are limited to 50 entries per [Firewall](#firewalls) and [500 effective rules](https://docs.hetzner.com/cloud/firewalls/overview#limits).\n", + "operationId": "set_rules", + "parameters": [ + { + "description": "ID of the Firewall.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Firewall.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "example": { + "rules": [ + { + "description": "Allow port 80", + "direction": "in", + "port": "80", + "protocol": "tcp", + "source_ips": [ + "28.239.13.1/32", + "28.239.14.0/24", + "ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b/128" + ] + } + ] + }, + "schema": { + "$ref": "#/components/schemas/set_rules_request" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "example": { + "actions": [ + { + "command": "set_firewall_rules", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 38, + "type": "firewall" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + }, + { + "command": "apply_firewall", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 14, + "progress": 100, + "resources": [ + { + "id": 38, + "type": "firewall" + }, + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + ] + }, + "schema": { + "$ref": "#/components/schemas/set_rules_response" + } + } + }, + "description": "The `action` key contains an [Action](#actions) with the `set_firewall_rules` command and additionally one with the `apply_firewall` command per resource of the [Firewall](#firewalls)." } }, - "required": [ - "id", - "created", - "name", - "server", - "location", - "size", - "linux_device", - "protection", - "labels", - "status", - "format" + "summary": "Set Rules", + "tags": [ + "firewalls" ], - "type": "object" - } + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, _, err := client.Firewall.SetRules(ctx, &hcloud.Firewall{ID: 123}, hcloud.FirewallSetRulesOpts{\n\t\tRules: []hcloud.FirewallRule{\n\t\t\t{\n\t\t\t\tDescription: hcloud.Ptr(\"Allow port 80\"),\n\t\t\t\tDirection: hcloud.FirewallRuleDirectionIn,\n\t\t\t\tPort: hcloud.Ptr(\"80\"),\n\t\t\t\tProtocol: hcloud.FirewallRuleProtocolTCP,\n\t\t\t\tSourceIPs: []net.IPNet{\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"28.239.13.1\"),\n\t\t\t\t\t\tMask: net.CIDRMask(32, 32),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"28.239.14.0\"),\n\t\t\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b\"),\n\t\t\t\t\t\tMask: net.CIDRMask(128, 128),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, actions...)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall, FirewallRule\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.firewalls.set_rules(\n firewall=Firewall(id=123),\n rules=[\n FirewallRule(\n description=\"Allow port 80\",\n direction=\"in\",\n port=\"80\",\n protocol=\"tcp\",\n source_ips=[\n \"28.239.13.1\",\n \"28.239.14.0/24\",\n \"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b\",\n ],\n )\n ],\n)\n\nfor action in actions:\n action.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud firewall replace-rules $FIREWALL --rules-file <(echo '[\n {\n \"description\": \"Allow port 80\",\n \"direction\": \"in\",\n \"port\": \"80\",\n \"protocol\": \"tcp\",\n \"source_ips\": [\n \"28.239.13.1/32\",\n \"28.239.14.0/24\",\n \"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b/128\"\n ]\n }\n]')" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] }, - "securitySchemes": { - "APIToken": { - "scheme": "bearer", - "type": "http" - } - } - }, - "paths": { - "/actions": { + "/firewalls/actions": { "get": { - "description": "Returns multiple Action objects specified by the `id` parameter.\n\n**Note**: This endpoint previously allowed listing all actions in the project. This functionality was deprecated in July 2023 and removed on 30 January 2025.\n\n- Announcement: https://docs.hetzner.cloud/changelog#2023-07-20-actions-list-endpoint-is-deprecated\n- Removal: https://docs.hetzner.cloud/changelog#2025-01-30-listing-arbitrary-actions-in-the-actions-list-endpoint-is-removed\n", - "operationId": "get_multiple_actions", + "description": "Returns all [Actions](#actions) for [Firewalls](#firewalls).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_firewall_actions", "parameters": [ { "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", "in": "query", "name": "id", - "required": true, + "required": false, "schema": { "items": { "description": "ID of the Action.", @@ -6840,6 +10191,77 @@ }, "type": "array" } + }, + { + "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "command", + "command:asc", + "command:desc", + "status", + "status:asc", + "status:desc", + "started", + "started:asc", + "started:desc", + "finished", + "finished:asc", + "finished:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Action.", + "enum": [ + "running", + "success", + "error" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" + } } ], "responses": { @@ -6847,22 +10269,27 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/get_multiple_actions_response" + "$ref": "#/components/schemas/list_actions_response" } } }, - "description": "Response for listing [Actions](#actions)." + "description": "The `actions` key contains a list of [Actions](#actions)." } }, - "summary": "Get multiple Actions", + "summary": "List Actions", "tags": [ - "actions" + "firewalls" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Action.AllWithOpts(ctx, hcloud.ActionListOpts{ID: []int64{123, 456}})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Firewall.Action.All(ctx, hcloud.ActionListOpts{})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.firewalls.actions.get_all()" } ] }, @@ -6872,10 +10299,10 @@ } ] }, - "/actions/{id}": { + "/firewalls/actions/{id}": { "get": { - "description": "Returns a specific Action object.", - "operationId": "get_action", + "description": "Returns the specific [Action](#actions).", + "operationId": "get_firewall_action", "parameters": [ { "description": "ID of the Action", @@ -6900,23 +10327,23 @@ } } }, - "description": "Response for getting an [Action](#actions)." + "description": "The `action` key contains the [Action](#actions)." } }, "summary": "Get an Action", "tags": [ - "actions" + "firewalls" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Action.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Firewall.Action.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.actions.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.firewalls.actions.get_by_id(123)" } ] }, @@ -6926,34 +10353,11 @@ } ] }, - "/certificates": { + "/floating_ips": { "get": { - "description": "Returns all Certificate objects.", - "operationId": "list_certificates", + "description": "List multiple [Floating IPs](#floating-ips).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_floating_ips", "parameters": [ - { - "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "name", - "name:asc", - "name:desc", - "created", - "created:asc", - "created:desc" - ], - "type": "string" - }, - "type": "array" - } - }, { "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", "in": "query", @@ -6973,18 +10377,20 @@ } }, { - "description": "Filter resources by type. Can be used multiple times. The response will only\ncontain the resources with the specified type.\n", + "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", "in": "query", - "name": "type", + "name": "sort", "required": false, "schema": { "items": { - "description": "Type of the Certificate.", "enum": [ - "uploaded", - "managed" + "id", + "id:asc", + "id:desc", + "created", + "created:asc", + "created:desc" ], - "example": "uploaded", "type": "string" }, "type": "array" @@ -7019,241 +10425,132 @@ "200": { "content": { "application/json": { - "example": { - "certificates": [ - { - "certificate": "-----BEGIN CERTIFICATE-----\n...", - "created": "2019-01-08T12:10:00+00:00", - "domain_names": [ - "example.com", - "webmail.example.com", - "www.example.com" - ], - "fingerprint": "03:c7:55:9b:2a:d1:04:17:09:f6:d0:7f:18:34:63:d4:3e:5f", - "id": 897, - "labels": { - "key": "value" - }, - "name": "my website cert", - "not_valid_after": "2019-07-08T09:59:59+00:00", - "not_valid_before": "2019-01-08T10:00:00+00:00", - "status": null, - "type": "uploaded", - "used_by": [ - { - "id": 4711, - "type": "load_balancer" - } - ] - } - ], - "meta": { - "pagination": { - "last_page": 1, - "next_page": null, - "page": 1, - "per_page": 25, - "previous_page": null, - "total_entries": 21 - } - } - }, "schema": { - "$ref": "#/components/schemas/list_certificates_response" + "$ref": "#/components/schemas/list_floating_ips_response" } } }, - "description": "The `certificates` key contains an array of Certificate objects." + "description": "Response for listing [Floating IPs](#floating-ips)." } }, - "summary": "List Certificates", + "summary": "List Floating IPs", "tags": [ - "certificates" + "floating_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tcertificates, err := client.Certificate.All(ctx)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfloatingIPs, err := client.FloatingIP.All(ctx)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ncertificates = client.certificates.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nfloating_ips = client.floating_ips.get_all()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud certificate list" + "source": "hcloud floating-ip list" } ] }, "post": { - "description": "Creates a new Certificate.\n\nThe default type **uploaded** allows for uploading your existing `certificate` and `private_key` in PEM format. You have to monitor its expiration date and handle renewal yourself.\n\nIn contrast, type **managed** requests a new Certificate from *Let's Encrypt* for the specified `domain_names`. Only domains managed by *Hetzner DNS* are supported. We handle renewal and timely alert the project owner via email if problems occur.\n\nFor type `managed` Certificates the `action` key of the response contains the Action that allows for tracking the issuance process. For type `uploaded` Certificates the `action` is always null.\n", - "operationId": "create_certificate", + "description": "Create a [Floating IP](#floating-ips).\n\nProvide the `server` attribute to assign the [Floating IP](#floating-ips) to that server or provide a `home_location` to locate the [Floating IP](#floating-ips) at. Note that the [Floating IP](#floating-ips) can be assigned to a [Server](#servers) in any [Location](#locations) later on. For optimal routing it is advised to use the [Floating IP](#floating-ips) in the same [Location](#locations) it was created in.\n", + "operationId": "create_floating_ip", "requestBody": { "content": { "application/json": { - "examples": { - "managed": { - "summary": "Creating a type `managed` Certificate", - "value": { - "domain_names": [ - "example.com", - "webmail.example.com", - "www.example.com" - ], - "name": "my website cert", - "type": "managed" - } - }, - "uploaded": { - "summary": "Creating a type `uploaded` Certificate", - "value": { - "certificate": "-----BEGIN CERTIFICATE-----\n...", - "name": "my website cert", - "private_key": "-----BEGIN PRIVATE KEY-----\n...", - "type": "uploaded" - } - } - }, "schema": { - "$ref": "#/components/schemas/create_certificate_request" + "$ref": "#/components/schemas/create_floating_ip_request" } } - } + }, + "description": "The `type` argument is required while `home_location` and `server` are mutually exclusive." }, "responses": { "201": { "content": { "application/json": { - "examples": { - "managed": { - "summary": "Response when creating a type `managed` Certificate", - "value": { - "action": { - "command": "create_certificate", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 879, - "type": "certificate" - } - ], - "started": "2019-01-08T12:10:00+00:00", - "status": "running" - }, - "certificate": { - "certificate": null, - "created": "2019-01-08T12:10:00+00:00", - "domain_names": [ - "example.com", - "webmail.example.com", - "www.example.com" - ], - "fingerprint": null, - "id": 897, - "labels": { - "key": "value" - }, - "name": "my website cert", - "not_valid_after": null, - "not_valid_before": null, - "status": { - "error": null, - "issuance": "pending", - "renewal": "unavailable" - }, - "type": "managed", - "used_by": [ - { - "id": 4711, - "type": "load_balancer" - } - ] + "example": { + "action": { + "command": "create_floating_ip", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" } - } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" }, - "uploaded": { - "summary": "Response when creating a type `uploaded` Certificate", - "value": { - "action": null, - "certificate": { - "certificate": "-----BEGIN CERTIFICATE-----\n...", - "created": "2019-01-08T12:10:00+00:00", - "domain_names": [ - "example.com", - "webmail.example.com", - "www.example.com" - ], - "fingerprint": "03:c7:55:9b:2a:d1:04:17:09:f6:d0:7f:18:34:63:d4:3e:5f", - "id": 897, - "labels": { - "key": "value" - }, - "name": "my website cert", - "not_valid_after": "2019-07-08T09:59:59+00:00", - "not_valid_before": "2019-01-08T10:00:00+00:00", - "status": null, - "type": "uploaded", - "used_by": [ - { - "id": 4711, - "type": "load_balancer" - } - ] + "floating_ip": { + "blocked": false, + "created": "2016-01-30T23:50:00+00:00", + "description": "Web Frontend", + "dns_ptr": [ + { + "dns_ptr": "server.example.com", + "ip": "2001:db8::1" } - } + ], + "home_location": { + "city": "Falkenstein", + "country": "DE", + "description": "Falkenstein DC Park 1", + "id": 1, + "latitude": 50.47612, + "longitude": 12.370071, + "name": "fsn1", + "network_zone": "eu-central" + }, + "id": 4711, + "ip": "2001:db8::/64", + "labels": { + "key": "value" + }, + "name": "Web Frontend", + "protection": { + "delete": false + }, + "server": 42, + "type": "ipv6" } }, "schema": { - "$ref": "#/components/schemas/create_certificate_response" + "$ref": "#/components/schemas/create_floating_ip_response" } } }, - "description": "The `certificate` key contains the Certificate that was just created. For type `managed` Certificates the `action` key contains the Action that allows for tracking the issuance process. For type `uploaded` Certificates the `action` is always null." + "description": "Response for creating a [Floating IP](#floating-ips).\n\nContains the created IP.\n" } }, - "summary": "Create a Certificate", + "summary": "Create a Floating IP", "tags": [ - "certificates" + "floating_ips" ], "x-codeSamples": [ { - "label": "Go (managed)", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tcertificate, _, err := client.Certificate.Create(ctx, hcloud.CertificateCreateOpts{\n\t\tDomainNames: []string{\n\t\t\t\"example.com\",\n\t\t\t\"webmail.example.com\",\n\t\t\t\"www.example.com\",\n\t\t},\n\t\tName: \"my website cert\",\n\t\tType: hcloud.CertificateTypeManaged,\n\t})\n}" - }, - { - "label": "Go (uploaded)", + "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tcertificate, _, err := client.Certificate.Create(ctx, hcloud.CertificateCreateOpts{\n\t\tCertificate: \"-----BEGIN CERTIFICATE-----\\n...\",\n\t\tName: \"my website cert\",\n\t\tPrivateKey: \"-----BEGIN PRIVATE KEY-----\\n...\",\n\t\tType: hcloud.CertificateTypeUploaded,\n\t})\n}" - }, - { - "label": "Python (managed)", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ncertificate = client.certificates.create_managed(\n domain_names=[\n \"example.com\",\n \"webmail.example.com\",\n \"www.example.com\",\n ],\n name=\"my website cert\",\n)" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.FloatingIP.Create(ctx, hcloud.FloatingIPCreateOpts{\n\t\tDescription: hcloud.Ptr(\"This describes my resource\"),\n\t\tHomeLocation: &hcloud.Location{Name: \"fsn1\"},\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: hcloud.Ptr(\"my-resource\"),\n\t\tServer: &hcloud.Server{ID: 42},\n\t\tType: hcloud.FloatingIPTypeIPv4,\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tfloatingIP := result.FloatingIP\n}" }, { - "label": "Python (uploaded)", + "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ncertificate = client.certificates.create(\n certificate=\"-----BEGIN CERTIFICATE-----\\n...\",\n name=\"my website cert\",\n private_key=\"-----BEGIN PRIVATE KEY-----\\n...\",\n)" - }, - { - "label": "CLI (managed)", - "lang": "Shell", - "source": "hcloud certificate create \\\n --name \"my website cert\" \\\n --type managed \\\n --domain example.com \\\n --domain webmail.example.com \\\n --domain www.example.com" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.locations import Location\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.floating_ips.create(\n description=\"This describes my resource\",\n home_location=Location(name=\"fsn1\"),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-resource\",\n server=Server(id=42),\n type=\"ipv4\",\n)\n\nresponse.action.wait_until_finished()\n\nfloating_ip = response.floating_ip" }, { - "label": "CLI (uploaded)", + "label": "CLI", "lang": "Shell", - "source": "hcloud certificate create \\\n --name \"my website cert\" \\\n --type uploaded \\\n --cert-file my-cert.pem \\\n --key-file my-key.pem" + "source": "hcloud floating-ip create \\\n --description \"This describes my resource\" \\\n --home-location fsn1 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name my-resource \\\n --server 42 \\\n --type ipv4" } ] }, @@ -7263,18 +10560,18 @@ } ] }, - "/certificates/{id}": { + "/floating_ips/{id}": { "delete": { - "description": "Deletes a Certificate.", - "operationId": "delete_certificate", + "description": "Deletes a [Floating IP](#floating-ips).\n\nIf the IP is assigned to a resource it will be unassigned.\n", + "operationId": "delete_floating_ip", "parameters": [ { - "description": "ID of the Certificate.", + "description": "ID of the Floating IP.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Certificate.", + "description": "ID of the Floating IP.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -7284,42 +10581,42 @@ ], "responses": { "204": { - "description": "Certificate deleted." + "description": "Floating IP deleted." } }, - "summary": "Delete a Certificate", + "summary": "Delete a Floating IP", "tags": [ - "certificates" + "floating_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.Certificate.Delete(ctx, &hcloud.Certificate{ID: 123})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.FloatingIP.Delete(ctx, &hcloud.FloatingIP{ID: 123})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.certificates.delete(certificate=Certificate(id=123))" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.floating_ips.delete(floating_ip=FloatingIP(id=123))" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud certificate delete $CERTIFICATE" + "source": "hcloud floating-ip delete $FLOATINGIP" } ] }, "get": { - "description": "Gets a specific Certificate object.", - "operationId": "get_certificate", + "description": "Returns a single [Floating IP](#floating-ips).", + "operationId": "get_floating_ip", "parameters": [ { - "description": "ID of the Certificate.", + "description": "ID of the Floating IP.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Certificate.", + "description": "ID of the Floating IP.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -7331,74 +10628,47 @@ "200": { "content": { "application/json": { - "example": { - "certificate": { - "certificate": "-----BEGIN CERTIFICATE-----\n...", - "created": "2019-01-08T12:10:00+00:00", - "domain_names": [ - "example.com", - "webmail.example.com", - "www.example.com" - ], - "fingerprint": "03:c7:55:9b:2a:d1:04:17:09:f6:d0:7f:18:34:63:d4:3e:5f", - "id": 897, - "labels": { - "key": "value" - }, - "name": "my website cert", - "not_valid_after": "2019-07-08T09:59:59+00:00", - "not_valid_before": "2019-01-08T10:00:00+00:00", - "status": null, - "type": "uploaded", - "used_by": [ - { - "id": 4711, - "type": "load_balancer" - } - ] - } - }, "schema": { - "$ref": "#/components/schemas/get_certificate_response" + "$ref": "#/components/schemas/get_floating_ip_response" } } }, - "description": "The `certificate` key contains a Certificate object." + "description": "Response for getting a single [Floating IP](#floating-ips)." } }, - "summary": "Get a Certificate", + "summary": "Get a Floating IP", "tags": [ - "certificates" + "floating_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tcertificate, _, err := client.Certificate.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfloatingIP, _, err := client.FloatingIP.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ncertificate = client.certificates.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nfloating_ip = client.floating_ips.get_by_id(123)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud certificate describe $CERTIFICATE" + "source": "hcloud floating-ip describe $FLOATINGIP" } ] }, "put": { - "description": "Updates the Certificate properties.\n\nNote: if the Certificate object changes during the request, the response will be a “conflict” error.\n", - "operationId": "replace_certificate", + "description": "Update a [Floating IP](#floating-ips).\n", + "operationId": "replace_floating_ip", "parameters": [ { - "description": "ID of the Certificate.", + "description": "ID of the Floating IP.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Certificate.", + "description": "ID of the Floating IP.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -7410,7 +10680,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/replace_certificate_request" + "$ref": "#/components/schemas/replace_floating_ip_request" } } } @@ -7420,59 +10690,66 @@ "content": { "application/json": { "example": { - "certificate": { - "certificate": "-----BEGIN CERTIFICATE-----\n...", - "created": "2019-01-08T12:10:00+00:00", - "domain_names": [ - "example.com", - "webmail.example.com", - "www.example.com" + "floating_ip": { + "blocked": false, + "created": "2016-01-30T23:50:00+00:00", + "description": "Web Frontend", + "dns_ptr": [ + { + "dns_ptr": "server.example.com", + "ip": "2001:db8::1" + } ], - "fingerprint": "03:c7:55:9b:2a:d1:04:17:09:f6:d0:7f:18:34:63:d4:3e:5f", - "id": 897, + "home_location": { + "city": "Falkenstein", + "country": "DE", + "description": "Falkenstein DC Park 1", + "id": 1, + "latitude": 50.47612, + "longitude": 12.370071, + "name": "fsn1", + "network_zone": "eu-central" + }, + "id": 4711, + "ip": "2001:db8::/64", "labels": { "key": "value" }, - "name": "my website cert", - "not_valid_after": "2019-07-08T09:59:59+00:00", - "not_valid_before": "2019-01-08T10:00:00+00:00", - "status": null, - "type": "uploaded", - "used_by": [ - { - "id": 4711, - "type": "load_balancer" - } - ] + "name": "Web Frontend", + "protection": { + "delete": false + }, + "server": 42, + "type": "ipv6" } }, "schema": { - "$ref": "#/components/schemas/replace_certificate_response" + "$ref": "#/components/schemas/replace_floating_ip_response" } } }, - "description": "The `certificate` key contains the Certificate that was just updated." + "description": "Response for updating a [Floating IP](#floating-ips).\n\nContains the updated [Floating IP](#floating-ips).\n" } }, - "summary": "Update a Certificate", + "summary": "Update a Floating IP", "tags": [ - "certificates" + "floating_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tcertificate, _, err := client.Certificate.Update(ctx, &hcloud.Certificate{ID: 123}, hcloud.CertificateUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"my website cert\",\n\t})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfloatingIP, _, err := client.FloatingIP.Update(ctx, &hcloud.FloatingIP{ID: 123}, hcloud.FloatingIPUpdateOpts{\n\t\tDescription: \"This describes my resource\",\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"my-resource\",\n\t})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ncertificate = client.certificates.update(\n certificate=Certificate(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my website cert\",\n)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.floating_ips.update(\n floating_ip=FloatingIP(id=123),\n description=\"This describes my resource\",\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-resource\",\n)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud certificate update $CERTIFICATE --name \"my website cert\"\nhcloud certificate add-label --overwrite $CERTIFICATE \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud certificate remove-label $CERTIFICATE \\\n \"environment\" \"example.com\" \"just-a-key\"" + "source": "hcloud floating-ip update $FLOATINGIP \\\n --description \"This describes my resource\" \\\n --name my-resource\nhcloud floating-ip add-label --overwrite $FLOATINGIP \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud floating-ip remove-label $FLOATINGIP \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] }, @@ -7482,22 +10759,21 @@ } ] }, - "/certificates/{id}/actions": { + "/floating_ips/{id}/actions": { "get": { - "description": "Returns all Action objects for a Certificate. You can sort the results by using the `sort` URI parameter, and filter them with the `status` parameter.\n\nOnly type `managed` Certificates can have Actions. For type `uploaded` Certificates the `actions` key will always contain an empty array.\n", - "operationId": "list_actions_for_certificate", + "description": "Lists [Actions](#actions) for a [Floating IP](#floating-ips).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_actions_for_floating_ip", "parameters": [ { - "description": "ID of the Certificate", + "description": "ID of the Floating IP.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Certificate. Limited to 52 bits to ensure compatability with JSON double precision floats.", + "description": "ID of the Floating IP.", "example": 42, "format": "int64", "maximum": 9007199254740991, - "title": "Certificate ID", "type": "integer" } }, @@ -7572,54 +10848,229 @@ "type": "integer" } } - ], + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "actions": [ + { + "command": "assign_floating_ip", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 4711, + "type": "server" + }, + { + "id": 4712, + "type": "floating_ip" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + ], + "meta": { + "pagination": { + "last_page": 1, + "next_page": null, + "page": 1, + "per_page": 25, + "previous_page": null, + "total_entries": 21 + } + } + }, + "schema": { + "$ref": "#/components/schemas/list_actions_response" + } + } + }, + "description": "Response for listing [Actions](#actions)." + } + }, + "summary": "List Actions for a Floating IP", + "tags": [ + "floating_ips" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/floating_ips/{id}/actions/{action_id}": { + "get": { + "description": "Returns a specific [Action](#actions) for a [Floating IP](#floating-ips).", + "operationId": "get_action_for_floating_ip", + "parameters": [ + { + "description": "ID of the Floating IP.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Floating IP.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + { + "description": "ID of the Action.", + "in": "path", + "name": "action_id", + "required": true, + "schema": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "action": { + "command": "assign_floating_ip", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" + }, + { + "id": 4711, + "type": "floating_ip" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, + "schema": { + "$ref": "#/components/schemas/get_action_response" + } + } + }, + "description": "Response for getting an [Action](#actions)." + } + }, + "summary": "Get an Action for a Floating IP", + "tags": [ + "floating_ips" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/floating_ips/{id}/actions/assign": { + "post": { + "description": "Assigns a [Floating IP](#floating-ips) to a [Server](#servers).", + "operationId": "assign_floating_ip_to_server", + "parameters": [ + { + "description": "ID of the Floating IP.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Floating IP.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/assign_floating_ip_to_server_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { "example": { - "actions": [ - { - "command": "issue_certificate", - "error": { - "code": "action_failed", - "message": "Action failed" + "action": { + "command": "assign_floating_ip", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" }, - "finished": "2021-01-30T23:57:00+00:00", - "id": 14, - "progress": 100, - "resources": [ - { - "id": 896, - "type": "certificate" - } - ], - "started": "2021-01-30T23:55:00+00:00", - "status": "success" - } - ], - "meta": { - "pagination": { - "last_page": 1, - "next_page": null, - "page": 1, - "per_page": 25, - "previous_page": null, - "total_entries": 21 - } + { + "id": 4711, + "type": "floating_ip" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" } }, "schema": { - "$ref": "#/components/schemas/list_actions_response" + "$ref": "#/components/schemas/assign_floating_ip_to_server_response" } } }, - "description": "The `actions` key contains a list of Actions." + "description": "Response for assigning a [Floating IP](#floating-ips).\n\nContains an [Action](#actions) of type `assign_floating_ip`.\n" } }, - "summary": "List Actions for a Certificate", + "summary": "Assign a Floating IP to a Server", "tags": [ - "certificates" + "floating_ips" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.FloatingIP.Assign(ctx, &hcloud.FloatingIP{ID: 123}, &hcloud.Server{ID: 456})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.floating_ips.assign(\n floating_ip=FloatingIP(id=123),\n server=Server(id=42),\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud floating-ip assign $FLOATINGIP $SERVER" + } ] }, "servers": [ @@ -7628,31 +11079,107 @@ } ] }, - "/certificates/{id}/actions/{action_id}": { - "get": { - "description": "Returns a specific Action for a Certificate. Only type `managed` Certificates have Actions.", - "operationId": "get_action_for_certificate", + "/floating_ips/{id}/actions/change_dns_ptr": { + "post": { + "description": "Change the reverse DNS records for this [Floating IP](#floating-ips).\n\nAllows to modify the PTR records set for the IP address.\n", + "operationId": "change_reverse_dns_records_for_floating_ip", "parameters": [ { - "description": "ID of the Certificate.", + "description": "ID of the Floating IP.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Certificate.", + "description": "ID of the Floating IP.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_reverse_dns_records_for_floating_ip_request" + } + } + }, + "description": "The `ip` attributes specifies for which IP address the record is set. For IPv4 addresses this must be the exact address of the [Floating IP](#floating-ips). For IPv6 addresses this must be a single address within the `/64` subnet of the [Floating IP](#floating-ips).\n\nThe `dns_ptr` attribute specifies the hostname used for the IP address.\n\nFor IPv6 [Floating IPs](#floating-ips) up to 100 entries can be created.\n" + }, + "responses": { + "201": { + "content": { + "application/json": { + "example": { + "action": { + "command": "change_dns_ptr", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 4711, + "type": "floating_ip" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, + "schema": { + "$ref": "#/components/schemas/change_reverse_dns_records_for_floating_ip_response" + } + } + }, + "description": "Response for changing a [Floating IPs](#floating-ips) DNS pointer.\n\nContains an [Action](#actions) of type `change_dns_ptr`.\n" + } + }, + "summary": "Change reverse DNS records for a Floating IP", + "tags": [ + "floating_ips" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.FloatingIP.ChangeDNSPtr(ctx, &hcloud.FloatingIP{ID: 123}, \"2001:db8::1\", hcloud.Ptr(\"server.example.com\"))\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { - "description": "ID of the Action.", + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.floating_ips.change_dns_ptr(\n floating_ip=FloatingIP(id=123),\n dns_ptr=\"server.example.com\",\n ip=\"2001:db8::1\",\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud floating-ip set-rdns $FLOATINGIP \\\n --ip 2001:db8::1 \\\n --hostname server.example.com" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/floating_ips/{id}/actions/change_protection": { + "post": { + "description": "Changes the protection settings configured for the [Floating IP](#floating-ips).", + "operationId": "change_floating_ip_protection", + "parameters": [ + { + "description": "ID of the Floating IP.", "in": "path", - "name": "action_id", + "name": "id", "required": true, "schema": { - "description": "ID of the Action.", + "description": "ID of the Floating IP.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -7660,41 +11187,67 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_floating_ip_protection_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { "example": { "action": { - "command": "issue_certificate", + "command": "change_protection", "error": { "code": "action_failed", "message": "Action failed" }, - "finished": "2021-01-30T23:57:00+00:00", - "id": 14, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, "progress": 100, "resources": [ { - "id": 896, - "type": "certificate" + "id": 4711, + "type": "floating_ip" } ], - "started": "2021-01-30T23:55:00+00:00", + "started": "2016-01-30T23:55:00+00:00", "status": "success" } }, "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/change_floating_ip_protection_response" } } }, - "description": "The `action` key contains the Certificate Action." + "description": "Response for changing a [Floating IPs](#floating-ips) protection settings.\n\nContains an [Action](#actions) of type `change_protection`.\n" } }, - "summary": "Get an Action for a Certificate", + "summary": "Change Floating IP Protection", "tags": [ - "certificates" + "floating_ips" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.FloatingIP.ChangeProtection(ctx, &hcloud.FloatingIP{ID: 123},\n\t\thcloud.FloatingIPChangeProtectionOpts{Delete: hcloud.Ptr(false)})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.floating_ips.change_protection(\n floating_ip=FloatingIP(id=123), delete=False\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud floating-ip enable-protection $FLOATINGIP delete\nhcloud floating-ip disable-protection $FLOATINGIP delete" + } ] }, "servers": [ @@ -7703,18 +11256,18 @@ } ] }, - "/certificates/{id}/actions/retry": { + "/floating_ips/{id}/actions/unassign": { "post": { - "description": "Retry a failed Certificate issuance or renewal.\n\nOnly applicable if the type of the Certificate is `managed` and the issuance or renewal status is `failed`.\n\n#### Call specific error codes\n\n| Code | Description |\n|---------------------------------------------------------|---------------------------------------------------------------------------|\n| `caa_record_does_not_allow_ca` | CAA record does not allow certificate authority |\n| `ca_dns_validation_failed` | Certificate Authority: DNS validation failed |\n| `ca_too_many_authorizations_failed_recently` | Certificate Authority: Too many authorizations failed recently |\n| `ca_too_many_certificates_issued_for_registered_domain` | Certificate Authority: Too many certificates issued for registered domain |\n| `ca_too_many_duplicate_certificates` | Certificate Authority: Too many duplicate certificates |\n| `could_not_verify_domain_delegated_to_zone` | Could not verify domain delegated to zone |\n| `dns_zone_not_found` | DNS zone not found |\n| `dns_zone_is_secondary_zone` | DNS zone is a secondary zone |\n", - "operationId": "retry_issuance_or_renewal", + "description": "Unassigns a [Floating IP](#floating-ips).\n\nResults in the IP being unreachable. Can be assigned to another resource again.\n", + "operationId": "unassign_floating_ip", "parameters": [ { - "description": "ID of the Certificate.", + "description": "ID of the Floating IP.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Certificate.", + "description": "ID of the Floating IP.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -7728,51 +11281,55 @@ "application/json": { "example": { "action": { - "command": "issue_certificate", + "command": "unassign_floating_ip", "error": { "code": "action_failed", "message": "Action failed" }, - "finished": "2021-01-30T23:57:00+00:00", - "id": 14, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, "progress": 100, "resources": [ { - "id": 896, - "type": "certificate" + "id": 42, + "type": "server" + }, + { + "id": 4711, + "type": "floating_ip" } ], - "started": "2021-01-30T23:55:00+00:00", + "started": "2016-01-30T23:55:00+00:00", "status": "success" } }, "schema": { - "$ref": "#/components/schemas/retry_issuance_or_renewal_response" + "$ref": "#/components/schemas/unassign_floating_ip_response" } } }, - "description": "The `action` key contains the resulting Action." + "description": "Response for unassigning a [Floating IP](#floating-ips).\n\nContains an [Action](#actions) of type `unassign_floating_ip`.\n" } }, - "summary": "Retry Issuance or Renewal", + "summary": "Unassign a Floating IP", "tags": [ - "certificates" + "floating_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Certificate.RetryIssuance(ctx, &hcloud.Certificate{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.FloatingIP.Unassign(ctx, &hcloud.FloatingIP{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.certificates.retry_issuance(certificate=Certificate(id=123))\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.floating_ips.unassign(\n floating_ip=FloatingIP(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud certificate retry $CERTIFICATE" + "source": "hcloud floating-ip unassign $FLOATINGIP" } ] }, @@ -7782,10 +11339,10 @@ } ] }, - "/certificates/actions": { + "/floating_ips/actions": { "get": { - "description": "Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.", - "operationId": "list_certificate_actions", + "description": "Lists multiple [Actions](#actions).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_floating_ip_actions", "parameters": [ { "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", @@ -7884,23 +11441,23 @@ } } }, - "description": "The `actions` key contains a list of Actions." + "description": "Response for listing [Actions](#actions)." } }, "summary": "List Actions", "tags": [ - "certificates" + "floating_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Certificate.Action.All(ctx, hcloud.ActionListOpts{})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.FloatingIP.Action.All(ctx, hcloud.ActionListOpts{})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.certificates.actions.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.floating_ips.actions.get_all()" } ] }, @@ -7910,10 +11467,10 @@ } ] }, - "/certificates/actions/{id}": { + "/floating_ips/actions/{id}": { "get": { - "description": "Returns a specific Action object.", - "operationId": "get_certificate_action", + "description": "Returns a single [Action](#actions).", + "operationId": "get_floating_ip_action", "parameters": [ { "description": "ID of the Action", @@ -7938,23 +11495,23 @@ } } }, - "description": "The `action` key in the reply has this structure." + "description": "Response for getting a single [Action](#actions)." } }, "summary": "Get an Action", "tags": [ - "certificates" + "floating_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Certificate.Action.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.FloatingIP.Action.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.certificates.actions.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.floating_ips.actions.get_by_id(123)" } ] }, @@ -7964,20 +11521,11 @@ } ] }, - "/datacenters": { + "/images": { "get": { - "description": "Returns all [Datacenters](#datacenters).", - "operationId": "list_datacenters", + "description": "Returns all Image objects. You can select specific Image types only and sort the results by using URI parameters.", + "operationId": "list_images", "parameters": [ - { - "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", - "in": "query", - "name": "name", - "required": false, - "schema": { - "type": "string" - } - }, { "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", "in": "query", @@ -7991,13 +11539,109 @@ "id:desc", "name", "name:asc", - "name:desc" + "name:desc", + "created", + "created:asc", + "created:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter resources by type. Can be used multiple times. The response will only\ncontain the resources with the specified type.\n", + "in": "query", + "name": "type", + "required": false, + "schema": { + "items": { + "description": "Type of the Image.", + "enum": [ + "system", + "app", + "snapshot", + "backup" + ], + "example": "snapshot", + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter resources by status. Can be used multiple times. The response will only\ncontain the resources with the specified status.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Image.", + "enum": [ + "available", + "creating", + "unavailable" ], + "example": "available", + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Can be used multiple times. Server ID linked to the Image. Only available for Images of type `backup`.", + "in": "query", + "name": "bound_to", + "required": false, + "schema": { + "items": { "type": "string" }, "type": "array" } }, + { + "description": "Can be used multiple times.", + "in": "query", + "name": "include_deprecated", + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "in": "query", + "name": "label_selector", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter resources by cpu architecture. The response will only contain the resources\nwith the specified cpu architecture.\n", + "in": "query", + "name": "architecture", + "required": false, + "schema": { + "description": "CPU architecture of the Resource.", + "enum": [ + "x86", + "arm" + ], + "example": "x86", + "type": "string" + } + }, { "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", "in": "query", @@ -8028,32 +11672,32 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/list_datacenters_response" + "$ref": "#/components/schemas/list_images_response" } } }, - "description": "Contains the queried [Datacenters](#datacenters)." + "description": "The `images` key in the reply contains an array of Image objects with this structure." } }, - "summary": "List Datacenters", + "summary": "List Images", "tags": [ - "datacenters" + "images" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tdatacenters, err := client.Datacenter.All(ctx)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\timages, err := client.Image.All(ctx)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ndatacenters = client.datacenters.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nimages = client.images.get_all()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud datacenter list" + "source": "hcloud image list" } ] }, @@ -8063,18 +11707,115 @@ } ] }, - "/datacenters/{id}": { + "/images/{id}": { + "delete": { + "description": "Deletes an Image. Only Images of type `snapshot` and `backup` can be deleted.", + "operationId": "delete_image", + "parameters": [ + { + "description": "ID of the Image.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Image.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "204": { + "description": "Image deleted." + } + }, + "summary": "Delete an Image", + "tags": [ + "images" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.Image.Delete(ctx, &hcloud.Image{ID: 123})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.images import Image\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nimage = client.images.delete(Image(id=123))" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud image delete $IMAGE" + } + ] + }, "get": { - "description": "Returns a single [Datacenter](#datacenters).", - "operationId": "get_datacenter", + "description": "Returns a specific Image object.", + "operationId": "get_image", + "parameters": [ + { + "description": "ID of the Image.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Image.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_image_response" + } + } + }, + "description": "The `image` key in the reply contains an Image object with this structure." + } + }, + "summary": "Get an Image", + "tags": [ + "images" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\timage, _, err := client.Image.GetByID(ctx, 123)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nimage = client.images.get_by_id(123)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud image describe $IMAGE" + } + ] + }, + "put": { + "description": "Updates the Image. You may change the description, convert a Backup Image to a Snapshot Image or change the Image labels. Only Images of type `snapshot` and `backup` can be updated.\n", + "operationId": "replace_image", "parameters": [ { - "description": "ID of the Datacenter.", + "description": "ID of the Image.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Datacenter.", + "description": "ID of the Image.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -8082,37 +11823,75 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/replace_image_request" + } + } + } + }, "responses": { "200": { "content": { "application/json": { + "example": { + "image": { + "architecture": "x86", + "bound_to": null, + "created": "2016-01-30T23:50:00+00:00", + "created_from": { + "id": 1, + "name": "Server" + }, + "deleted": null, + "deprecated": "2018-02-28T00:00:00+00:00", + "description": "My new Image description", + "disk_size": 10, + "id": 4711, + "image_size": 2.3, + "labels": { + "key": "value" + }, + "name": null, + "os_flavor": "ubuntu", + "os_version": "20.04", + "protection": { + "delete": false + }, + "rapid_deploy": false, + "status": "available", + "type": "snapshot" + } + }, "schema": { - "$ref": "#/components/schemas/get_datacenter_response" + "$ref": "#/components/schemas/replace_image_response" } } }, - "description": "Contains the queried [Datacenter](#datacenters)." + "description": "The image key in the reply contains the modified Image object." } }, - "summary": "Get a Datacenter", + "summary": "Update an Image", "tags": [ - "datacenters" + "images" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tdatacenter, _, err := client.Datacenter.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\timage, _, err := client.Image.Update(ctx, &hcloud.Image{ID: 123}, hcloud.ImageUpdateOpts{\n\t\tDescription: hcloud.Ptr(\"My new Image description\"),\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tType: hcloud.ImageTypeSnapshot,\n\t})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\ndatacenter = client.datacenters.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.images import Image\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nimage = client.images.update(\n image=Image(id=123),\n description=\"My new Image description\",\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n type=\"snapshot\",\n)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud datacenter describe $DATACENTER" + "source": "hcloud image update $IMAGE --description \"My new Image description\"\nhcloud image add-label --overwrite $IMAGE \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud image remove-label $IMAGE \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] }, @@ -8122,13 +11901,26 @@ } ] }, - "/firewalls": { + "/images/{id}/actions": { "get": { - "description": "Returns all [Firewalls](#firewalls).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_firewalls", + "description": "Returns all Action objects for an Image. You can sort the results by using the `sort` URI parameter, and filter them with the `status` parameter.", + "operationId": "list_actions_for_image", "parameters": [ { - "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "description": "ID of the Image.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Image.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + { + "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", "in": "query", "name": "sort", "required": false, @@ -8138,12 +11930,18 @@ "id", "id:asc", "id:desc", - "name", - "name:asc", - "name:desc", - "created", - "created:asc", - "created:desc" + "command", + "command:asc", + "command:desc", + "status", + "status:asc", + "status:desc", + "started", + "started:asc", + "started:desc", + "finished", + "finished:asc", + "finished:desc" ], "type": "string" }, @@ -8151,21 +11949,21 @@ } }, { - "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", - "in": "query", - "name": "name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", "in": "query", - "name": "label_selector", + "name": "status", "required": false, "schema": { - "type": "string" + "items": { + "description": "Status of the Action.", + "enum": [ + "running", + "success", + "error" + ], + "type": "string" + }, + "type": "array" } }, { @@ -8197,107 +11995,49 @@ "200": { "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/list_firewalls_response" - } - } - }, - "description": "The `firewalls` key contains the [Firewalls](#firewalls)." - } - }, - "summary": "List Firewalls", - "tags": [ - "firewalls" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfirewalls, err := client.Firewall.All(ctx)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nfirewalls = client.firewalls.get_all()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud firewall list" - } - ] - }, - "post": { - "description": "Create a [Firewall](#firewalls).\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|------------------------------ |-----------------------------------------------------------------------------|\n| `server_already_added` | [Server](#servers) applied more than once |\n| `incompatible_network_type` | The resources network type is not supported by [Firewalls](#firewalls) |\n| `firewall_resource_not_found` | The resource the [Firewall](#firewalls) should be attached to was not found |\n", - "operationId": "create_firewall", - "requestBody": { - "content": { - "application/json": { - "example": { - "apply_to": [ - { - "server": { - "id": 42 - }, - "type": "server" + "example": { + "actions": [ + { + "command": "change_protection", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 4711, + "type": "image" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + ], + "meta": { + "pagination": { + "last_page": 1, + "next_page": null, + "page": 1, + "per_page": 25, + "previous_page": null, + "total_entries": 21 + } } - ], - "labels": { - "key": "value" }, - "name": "Corporate Intranet Protection", - "rules": [ - { - "description": "Allow port 80", - "direction": "in", - "port": "80", - "protocol": "tcp", - "source_ips": [ - "28.239.13.1/32", - "28.239.14.0/24", - "ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b/128" - ] - } - ] - }, - "schema": { - "$ref": "#/components/schemas/create_firewall_request" - } - } - } - }, - "responses": { - "201": { - "content": { - "application/json": { "schema": { - "$ref": "#/components/schemas/create_firewall_response" + "$ref": "#/components/schemas/list_actions_response" } } }, - "description": "The `firewall` key contains the created [Firewall](#firewalls)." + "description": "The `actions` key contains a list of Actions." } }, - "summary": "Create a Firewall", + "summary": "List Actions for an Image", "tags": [ - "firewalls" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nimport (\n\t\"net\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Firewall.Create(ctx, hcloud.FirewallCreateOpts{\n\t\tApplyTo: []hcloud.FirewallResource{\n\t\t\t{\n\t\t\t\tType: hcloud.FirewallResourceTypeServer,\n\t\t\t\tServer: &hcloud.FirewallResourceServer{\n\t\t\t\t\tID: 42,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tLabels: map[string]string{\n\t\t\t\"env\": \"dev\",\n\t\t},\n\t\tName: \"Corporate Intranet Protection\",\n\t\tRules: []hcloud.FirewallRule{\n\t\t\t{\n\t\t\t\tDescription: hcloud.Ptr(\"Allow port 80\"),\n\t\t\t\tDirection: hcloud.FirewallRuleDirectionIn,\n\t\t\t\tPort: hcloud.Ptr(\"80\"),\n\t\t\t\tProtocol: hcloud.FirewallRuleProtocolTCP,\n\t\t\t\tSourceIPs: []net.IPNet{\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"28.239.13.1\"),\n\t\t\t\t\t\tMask: net.CIDRMask(32, 32),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"28.239.14.0\"),\n\t\t\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b\"),\n\t\t\t\t\t\tMask: net.CIDRMask(128, 128),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Actions...)\n\n\tfirewall := result.Firewall\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import FirewallResource, FirewallRule\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.firewalls.create(\n resources=[\n FirewallResource(\n type=\"server\",\n server=Server(id=42),\n )\n ],\n labels={\n \"env\": \"dev\",\n },\n name=\"Corporate Intranet Protection\",\n rules=[\n FirewallRule(\n description=\"Allow port 80\",\n direction=\"in\",\n port=\"80\",\n protocol=\"tcp\",\n source_ips=[\n \"28.239.13.1\",\n \"28.239.14.0/24\",\n \"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b\",\n ],\n )\n ],\n)\n\nfor action in response.actions:\n action.wait_until_finished()\n\nfirewall = response.firewall" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud firewall create \\\n --name \"Corporate Intranet Protection\" \\\n --label \"env=dev\" \\\n --rules-file <(echo '[\n {\n \"description\": \"Allow port 80\",\n \"direction\": \"in\",\n \"port\": \"80\",\n \"protocol\": \"tcp\",\n \"source_ips\": [\n \"28.239.13.1/32\",\n \"28.239.14.0/24\",\n \"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b/128\"\n ]\n }\n]')" - } + "images" ] }, "servers": [ @@ -8306,63 +12046,31 @@ } ] }, - "/firewalls/{id}": { - "delete": { - "description": "Deletes the [Firewall](#firewalls).\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|--------------------- |----------------------------------------------------|\n| `resource_in_use` | [Firewall](#firewalls) still applied to a resource |\n", - "operationId": "delete_firewall", + "/images/{id}/actions/{action_id}": { + "get": { + "description": "Returns a specific Action for an Image.", + "operationId": "get_action_for_image", "parameters": [ { - "description": "ID of the Firewall.", + "description": "ID of the Image.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Firewall.", + "description": "ID of the Image.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } - } - ], - "responses": { - "204": { - "description": "Firewall deleted." - } - }, - "summary": "Delete a Firewall", - "tags": [ - "firewalls" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.Firewall.Delete(ctx, &hcloud.Firewall{ID: 123})\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.firewalls.delete(firewall=Firewall(id=123))" }, { - "label": "CLI", - "lang": "Shell", - "source": "hcloud firewall delete $FIREWALL" - } - ] - }, - "get": { - "description": "Returns a single [Firewall](#firewalls).", - "operationId": "get_firewall", - "parameters": [ - { - "description": "ID of the Firewall.", + "description": "ID of the Action.", "in": "path", - "name": "id", + "name": "action_id", "required": true, "schema": { - "description": "ID of the Firewall.", + "description": "ID of the Action.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -8374,47 +12082,57 @@ "200": { "content": { "application/json": { + "example": { + "action": { + "command": "change_protection", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 4711, + "type": "image" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, "schema": { - "$ref": "#/components/schemas/get_firewall_response" + "$ref": "#/components/schemas/get_action_response" } } }, - "description": "The `firewall` key contains the [Firewall](#firewalls)." + "description": "The `action` key contains the Image Action." } }, - "summary": "Get a Firewall", + "summary": "Get an Action for an Image", "tags": [ - "firewalls" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfirewall, _, err := client.Firewall.GetByID(ctx, 123)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nfirewall = client.firewalls.get_by_id(123)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud firewall describe $FIREWALL" - } + "images" ] }, - "put": { - "description": "Update a [Firewall](#firewalls).\n\nIn case of a parallel running change on the [Firewall](#firewalls) a `conflict` error will be returned.\n", - "operationId": "replace_firewall", + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/images/{id}/actions/change_protection": { + "post": { + "description": "Changes the protection configuration of the Image. Can only be used on snapshots.", + "operationId": "change_image_protection", "parameters": [ { - "description": "ID of the Firewall.", + "description": "ID of the Image.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Firewall.", + "description": "ID of the Image.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -8426,42 +12144,62 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/replace_firewall_request" + "$ref": "#/components/schemas/change_image_protection_request" } } } }, "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "change_protection", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 4711, + "type": "image" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, "schema": { - "$ref": "#/components/schemas/replace_firewall_response" + "$ref": "#/components/schemas/change_image_protection_response" } } }, - "description": "The `firewall` key contains the updated [Firewall](#firewalls)." + "description": "The `action` key contains the `change_protection` Action." } }, - "summary": "Update a Firewall", + "summary": "Change Image Protection", "tags": [ - "firewalls" + "images" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfirewall, _, err := client.Firewall.Update(ctx, &hcloud.Firewall{ID: 123}, hcloud.FirewallUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"new-name\",\n\t})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Image.ChangeProtection(ctx, &hcloud.Image{ID: 123},\n\t\thcloud.ImageChangeProtectionOpts{Delete: hcloud.Ptr(true)})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.firewalls.update(\n firewall=Firewall(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"new-name\",\n)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.images import Image\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.images.change_protection(image=Image(id=123), delete=True)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud firewall update $FIREWALL --name \"new-name\"\nhcloud firewall add-label --overwrite $FIREWALL \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud firewall remove-label $FIREWALL \\\n \"environment\" \"example.com\" \"just-a-key\"" + "source": "hcloud image enable-protection $IMAGE delete\nhcloud image disable-protection $IMAGE delete" } ] }, @@ -8471,23 +12209,25 @@ } ] }, - "/firewalls/{id}/actions": { + "/images/actions": { "get": { - "description": "Returns all [Actions](#actions) for the [Firewall](#firewalls).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_actions_for_firewall", + "description": "Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.", + "operationId": "list_image_actions", "parameters": [ { - "description": "ID of the Firewall", - "in": "path", + "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", + "in": "query", "name": "id", - "required": true, + "required": false, "schema": { - "description": "ID of the Firewall. Limited to 52 bits to ensure compatability with JSON double precision floats.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "title": "Firewall ID", - "type": "integer" + "items": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "type": "array" } }, { @@ -8543,108 +12283,21 @@ "name": "page", "required": false, "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, - "schema": { - "default": 25, - "example": 25, - "format": "int64", - "type": "integer" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "example": { - "actions": [ - { - "command": "set_firewall_rules", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 38, - "type": "firewall" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - ], - "meta": { - "pagination": { - "last_page": 1, - "next_page": null, - "page": 1, - "per_page": 25, - "previous_page": null, - "total_entries": 21 - } - } - }, - "schema": { - "$ref": "#/components/schemas/list_actions_response" - } - } - }, - "description": "The `actions` key contains a list of [Actions](#actions)." - } - }, - "summary": "List Actions for a Firewall", - "tags": [ - "firewalls" - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/firewalls/{id}/actions/{action_id}": { - "get": { - "description": "Returns a specific [Action](#actions) for a [Firewall](#firewalls).", - "operationId": "get_action_for_firewall", - "parameters": [ - { - "description": "ID of the Firewall.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the Firewall.", - "example": 42, + "default": 1, + "example": 2, "format": "int64", - "maximum": 9007199254740991, "type": "integer" } }, { - "description": "ID of the Action.", - "in": "path", - "name": "action_id", - "required": true, + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, "schema": { - "description": "ID of the Action.", - "example": 42, + "default": 25, + "example": 25, "format": "int64", - "maximum": 9007199254740991, "type": "integer" } } @@ -8653,37 +12306,29 @@ "200": { "content": { "application/json": { - "example": { - "action": { - "command": "set_firewall_rules", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 38, - "type": "firewall" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - }, "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/list_actions_response" } } }, - "description": "The `action` key contains the [Firewall](#firewalls) [Action](#actions)." + "description": "The `actions` key contains a list of Actions." } }, - "summary": "Get an Action for a Firewall", + "summary": "List Actions", "tags": [ - "firewalls" + "images" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Image.Action.All(ctx, hcloud.ActionListOpts{})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.images.actions.get_all()" + } ] }, "servers": [ @@ -8692,18 +12337,18 @@ } ] }, - "/firewalls/{id}/actions/apply_to_resources": { - "post": { - "description": "Applies a [Firewall](#firewalls) to multiple resources.\n\nSupported resources:\n- [Servers](#servers) (with a public network interface)\n- [Label Selectors](#label-selector)\n\nA server can be applied to [a maximum of 5 Firewalls](https://docs.hetzner.com/cloud/firewalls/overview#limits).\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|-------------------------------|-------------------------------------------------------------------------------------------------|\n| `firewall_already_applied` | [Firewall](#firewalls) is already applied to resource |\n| `incompatible_network_type` | The network type of the resource is not supported by [Firewalls](#firewalls) |\n| `firewall_resource_not_found` | The resource the [Firewall](#firewalls) should be applied to was not found |\n| `private_net_only_server` | The [Server](#servers) the [Firewall](#firewalls) should be applied to has no public interface |\n", - "operationId": "apply_to_resources", + "/images/actions/{id}": { + "get": { + "description": "Returns a specific Action object.", + "operationId": "get_image_action", "parameters": [ { - "description": "ID of the Firewall.", + "description": "ID of the Action", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Firewall.", + "description": "ID of the Action.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -8711,82 +12356,32 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "example": { - "apply_to": [ - { - "server": { - "id": 42 - }, - "type": "server" - } - ] - }, - "schema": { - "$ref": "#/components/schemas/apply_to_resources_request" - } - } - } - }, "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "actions": [ - { - "command": "apply_firewall", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 14, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - }, - { - "id": 38, - "type": "firewall" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - ] - }, "schema": { - "$ref": "#/components/schemas/apply_to_resources_response" + "$ref": "#/components/schemas/get_action_response" } } }, - "description": "The `actions` key contains multiple [Actions](#actions) with the `apply_firewall` command." + "description": "The `action` key in the reply has this structure." } }, - "summary": "Apply to Resources", + "summary": "Get an Action", "tags": [ - "firewalls" + "images" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, _, err := client.Firewall.ApplyResources(ctx, &hcloud.Firewall{ID: 123}, []hcloud.FirewallResource{\n\t\t{\n\t\t\tType: hcloud.FirewallResourceTypeServer,\n\t\t\tServer: &hcloud.FirewallResourceServer{\n\t\t\t\tID: 42,\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, actions...)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Image.Action.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall, FirewallResource\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.firewalls.apply_to_resources(\n firewall=Firewall(id=123),\n resources=[\n FirewallResource(\n type=\"server\",\n server=Server(id=42),\n )\n ],\n)\n\nfor action in actions:\n action.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud firewall apply-to-resource $FIREWALL \\\n --type server \\\n --server $SERVER" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.images.actions.get_by_id(123)" } ] }, @@ -8796,101 +12391,100 @@ } ] }, - "/firewalls/{id}/actions/remove_from_resources": { - "post": { - "description": "Removes a [Firewall](#firewalls) from multiple resources.\n\nSupported resources:\n- [Servers](#servers) (with a public network interface)\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|---------------------------------------|---------------------------------------------------------------------------------------------------------|\n| `firewall_already_removed` | [Firewall](#firewalls) is already removed from the resource |\n| `firewall_resource_not_found` | The resource the [Firewall](#firewalls) should be removed from was not found |\n| `firewall_managed_by_label_selector` | [Firewall](#firewall) is applied via a [Label Selector](#label-selector) and cannot be removed manually |\n", - "operationId": "remove_from_resources", + "/isos": { + "get": { + "description": "Returns all available ISO objects.", + "operationId": "list_isos", "parameters": [ { - "description": "ID of the Firewall.", - "in": "path", - "name": "id", - "required": true, + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, "schema": { - "description": "ID of the Firewall.", - "example": 42, + "type": "string" + } + }, + { + "description": "Filter resources by cpu architecture. The response will only contain the resources\nwith the specified cpu architecture.\n", + "in": "query", + "name": "architecture", + "required": false, + "schema": { + "description": "CPU architecture of the Resource.", + "enum": [ + "x86", + "arm" + ], + "example": "x86", + "type": "string" + } + }, + { + "description": "Include Images with wildcard architecture (architecture is null). Works only if architecture filter is specified.", + "in": "query", + "name": "include_architecture_wildcard", + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, "format": "int64", - "maximum": 9007199254740991, "type": "integer" } - } - ], - "requestBody": { - "content": { - "application/json": { - "example": { - "remove_from": [ - { - "server": { - "id": 42 - }, - "type": "server" - } - ] - }, - "schema": { - "$ref": "#/components/schemas/remove_from_resources_request" - } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" } } - }, + ], "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "actions": [ - { - "command": "remove_firewall", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 14, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - }, - { - "id": 38, - "type": "firewall" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - ] - }, "schema": { - "$ref": "#/components/schemas/remove_from_resources_response" + "$ref": "#/components/schemas/list_isos_response" } } }, - "description": "The `actions` key contains multiple [Actions](#actions) with the `remove_firewall` command." + "description": "The `isos` key in the reply contains an array of iso objects with this structure." } }, - "summary": "Remove from Resources", + "summary": "List ISOs", "tags": [ - "firewalls" + "isos" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, _, err := client.Firewall.RemoveResources(ctx, &hcloud.Firewall{ID: 123}, []hcloud.FirewallResource{\n\t\t{\n\t\t\tType: hcloud.FirewallResourceTypeServer,\n\t\t\tServer: &hcloud.FirewallResourceServer{\n\t\t\t\tID: 42,\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, actions...)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tisos, err := client.ISO.All(ctx)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall, FirewallResource\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.firewalls.remove_from_resources(\n firewall=Firewall(id=123),\n resources=[\n FirewallResource(\n type=\"server\",\n server=Server(id=42),\n )\n ],\n)\n\nfor action in actions:\n action.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nisos = client.isos.get_all()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud firewall remove-from-resource $FIREWALL \\\n --type server \\\n --server $SERVER" + "source": "hcloud iso list" } ] }, @@ -8900,18 +12494,18 @@ } ] }, - "/firewalls/{id}/actions/set_rules": { - "post": { - "description": "Set the rules of a [Firewall](#firewalls).\n\nOverwrites the existing rules with the given ones. Pass an empty array to remove all rules.\n\nRules are limited to 50 entries per [Firewall](#firewalls) and [500 effective rules](https://docs.hetzner.com/cloud/firewalls/overview#limits).\n", - "operationId": "set_rules", + "/isos/{id}": { + "get": { + "description": "Returns a specific ISO object.", + "operationId": "get_iso", "parameters": [ { - "description": "ID of the Firewall.", + "description": "ID of the ISO.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Firewall.", + "description": "ID of the ISO.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -8919,105 +12513,37 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "example": { - "rules": [ - { - "description": "Allow port 80", - "direction": "in", - "port": "80", - "protocol": "tcp", - "source_ips": [ - "28.239.13.1/32", - "28.239.14.0/24", - "ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b/128" - ] - } - ] - }, - "schema": { - "$ref": "#/components/schemas/set_rules_request" - } - } - } - }, "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "actions": [ - { - "command": "set_firewall_rules", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 38, - "type": "firewall" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - }, - { - "command": "apply_firewall", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 14, - "progress": 100, - "resources": [ - { - "id": 38, - "type": "firewall" - }, - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - ] - }, "schema": { - "$ref": "#/components/schemas/set_rules_response" + "$ref": "#/components/schemas/get_iso_response" } } }, - "description": "The `action` key contains an [Action](#actions) with the `set_firewall_rules` command and additionally one with the `apply_firewall` command per resource of the [Firewall](#firewalls)." + "description": "The `iso` key in the reply contains an array of ISO objects with this structure." } }, - "summary": "Set Rules", + "summary": "Get an ISO", "tags": [ - "firewalls" + "isos" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, _, err := client.Firewall.SetRules(ctx, &hcloud.Firewall{ID: 123}, hcloud.FirewallSetRulesOpts{\n\t\tRules: []hcloud.FirewallRule{\n\t\t\t{\n\t\t\t\tDescription: hcloud.Ptr(\"Allow port 80\"),\n\t\t\t\tDirection: hcloud.FirewallRuleDirectionIn,\n\t\t\t\tPort: hcloud.Ptr(\"80\"),\n\t\t\t\tProtocol: hcloud.FirewallRuleProtocolTCP,\n\t\t\t\tSourceIPs: []net.IPNet{\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"28.239.13.1\"),\n\t\t\t\t\t\tMask: net.CIDRMask(32, 32),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"28.239.14.0\"),\n\t\t\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tIP: net.ParseIP(\"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b\"),\n\t\t\t\t\t\tMask: net.CIDRMask(128, 128),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, actions...)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tiso, _, err := client.ISO.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall, FirewallRule\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.firewalls.set_rules(\n firewall=Firewall(id=123),\n rules=[\n FirewallRule(\n description=\"Allow port 80\",\n direction=\"in\",\n port=\"80\",\n protocol=\"tcp\",\n source_ips=[\n \"28.239.13.1\",\n \"28.239.14.0/24\",\n \"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b\",\n ],\n )\n ],\n)\n\nfor action in actions:\n action.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\niso = client.isos.get_by_id(123)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud firewall replace-rules $FIREWALL --rules-file <(echo '[\n {\n \"description\": \"Allow port 80\",\n \"direction\": \"in\",\n \"port\": \"80\",\n \"protocol\": \"tcp\",\n \"source_ips\": [\n \"28.239.13.1/32\",\n \"28.239.14.0/24\",\n \"ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b/128\"\n ]\n }\n]')" + "source": "hcloud iso describe $ISO" } ] }, @@ -9027,72 +12553,18 @@ } ] }, - "/firewalls/actions": { + "/load_balancer_types": { "get": { - "description": "Returns all [Actions](#actions) for [Firewalls](#firewalls).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_firewall_actions", + "description": "Gets all Load Balancer type objects.", + "operationId": "list_load_balancer_types", "parameters": [ { - "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", - "in": "query", - "name": "id", - "required": false, - "schema": { - "items": { - "description": "ID of the Action.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - }, - "type": "array" - } - }, - { - "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "command", - "command:asc", - "command:desc", - "status", - "status:asc", - "status:desc", - "started", - "started:asc", - "started:desc", - "finished", - "finished:asc", - "finished:desc" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", "in": "query", - "name": "status", + "name": "name", "required": false, "schema": { - "items": { - "description": "Status of the Action.", - "enum": [ - "running", - "success", - "error" - ], - "type": "string" - }, - "type": "array" + "type": "string" } }, { @@ -9125,27 +12597,32 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/list_actions_response" + "$ref": "#/components/schemas/list_load_balancer_types_response" } } }, - "description": "The `actions` key contains a list of [Actions](#actions)." + "description": "The `load_balancer_types` key in the reply contains an array of Load Balancer type objects with this structure." } }, - "summary": "List Actions", + "summary": "List Load Balancer Types", "tags": [ - "firewalls" + "load_balancer_types" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Firewall.Action.All(ctx, hcloud.ActionListOpts{})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tloadBalancerTypes, err := client.LoadBalancerType.All(ctx)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.firewalls.actions.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nload_balancer_types = client.load_balancer_types.get_all()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud load-balancer-type list" } ] }, @@ -9155,18 +12632,18 @@ } ] }, - "/firewalls/actions/{id}": { + "/load_balancer_types/{id}": { "get": { - "description": "Returns the specific [Action](#actions).", - "operationId": "get_firewall_action", + "description": "Gets a specific Load Balancer type object.", + "operationId": "get_load_balancer_type", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Load Balancer Type.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Action.", + "description": "ID of the Load Balancer Type.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -9179,27 +12656,32 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/get_load_balancer_type_response" } } }, - "description": "The `action` key contains the [Action](#actions)." + "description": "The `load_balancer_type` key in the reply contains a Load Balancer type object with this structure." } }, - "summary": "Get an Action", + "summary": "Get a Load Balancer Type", "tags": [ - "firewalls" + "load_balancer_types" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Firewall.Action.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tloadBalancerType, _, err := client.LoadBalancerType.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.firewalls.actions.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nload_balancer_type = client.load_balancer_types.get_by_id(123)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud load-balancer-type describe $LOADBALANCERTYPE" } ] }, @@ -9209,29 +12691,11 @@ } ] }, - "/floating_ips": { + "/load_balancers": { "get": { - "description": "List multiple [Floating IPs](#floating-ips).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_floating_ips", + "description": "Gets all existing Load Balancers that you have available.", + "operationId": "list_load_balancers", "parameters": [ - { - "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", - "in": "query", - "name": "name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", - "in": "query", - "name": "label_selector", - "required": false, - "schema": { - "type": "string" - } - }, { "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", "in": "query", @@ -9243,6 +12707,9 @@ "id", "id:asc", "id:desc", + "name", + "name:asc", + "name:desc", "created", "created:asc", "created:desc" @@ -9252,6 +12719,24 @@ "type": "array" } }, + { + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "in": "query", + "name": "label_selector", + "required": false, + "schema": { + "type": "string" + } + }, { "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", "in": "query", @@ -9282,47 +12767,46 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/list_floating_ips_response" + "$ref": "#/components/schemas/list_load_balancers_response" } } }, - "description": "Response for listing [Floating IPs](#floating-ips)." + "description": "The `load_balancers` key contains a list of Load Balancers." } }, - "summary": "List Floating IPs", + "summary": "List Load Balancers", "tags": [ - "floating_ips" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfloatingIPs, err := client.FloatingIP.All(ctx)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tloadBalancers, err := client.LoadBalancer.All(ctx)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nfloating_ips = client.floating_ips.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nload_balancers = client.load_balancers.get_all()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud floating-ip list" + "source": "hcloud load-balancer list" } ] }, "post": { - "description": "Create a [Floating IP](#floating-ips).\n\nProvide the `server` attribute to assign the [Floating IP](#floating-ips) to that server or provide a `home_location` to locate the [Floating IP](#floating-ips) at. Note that the [Floating IP](#floating-ips) can be assigned to a [Server](#servers) in any [Location](#locations) later on. For optimal routing it is advised to use the [Floating IP](#floating-ips) in the same [Location](#locations) it was created in.\n", - "operationId": "create_floating_ip", + "description": "Creates a Load Balancer.\n\n#### Call specific error codes\n\n| Code | Description |\n|-----------------------------------------|-------------------------------------------------------------------------------------------------------|\n| `cloud_resource_ip_not_allowed` | The IP you are trying to add as a target belongs to a Hetzner Cloud resource |\n| `ip_not_owned` | The IP is not owned by the owner of the project of the Load Balancer |\n| `load_balancer_not_attached_to_network` | The Load Balancer is not attached to a network |\n| `robot_unavailable` | Robot was not available. The caller may retry the operation after a short delay. |\n| `server_not_attached_to_network` | The server you are trying to add as a target is not attached to the same network as the Load Balancer |\n| `source_port_already_used` | The source port you are trying to add is already in use |\n| `missing_ipv4` | The server that you are trying to add as a public target does not have a public IPv4 address |\n| `target_already_defined` | The Load Balancer target you are trying to define is already defined |\n", + "operationId": "create_load_balancer", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/create_floating_ip_request" + "$ref": "#/components/schemas/create_load_balancer_request" } } - }, - "description": "The `type` argument is required while `home_location` and `server` are mutually exclusive." + } }, "responses": { "201": { @@ -9330,34 +12814,63 @@ "application/json": { "example": { "action": { - "command": "create_floating_ip", + "command": "create_load_balancer", "error": { "code": "action_failed", "message": "Action failed" }, - "finished": null, + "finished": "2016-01-30T23:56:00+00:00", "id": 13, - "progress": 0, + "progress": 100, "resources": [ { - "id": 42, - "type": "server" + "id": 4711, + "type": "load_balancer" } ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" + "started": "2016-01-30T23:55:00+00:00", + "status": "success" }, - "floating_ip": { - "blocked": false, + "load_balancer": { + "algorithm": { + "type": "round_robin" + }, "created": "2016-01-30T23:50:00+00:00", - "description": "Web Frontend", - "dns_ptr": [ - { - "dns_ptr": "server.example.com", - "ip": "2001:db8::1" - } - ], - "home_location": { + "id": 4711, + "included_traffic": 654321, + "ingoing_traffic": 123456, + "labels": { + "key": "value" + }, + "load_balancer_type": { + "deprecated": "2016-01-30T23:50:00+00:00", + "description": "LB11", + "id": 1, + "max_assigned_certificates": 10, + "max_connections": 20000, + "max_services": 5, + "max_targets": 25, + "name": "lb11", + "prices": [ + { + "included_traffic": 654321, + "location": "fsn1", + "price_hourly": { + "gross": "1.1900000000000000", + "net": "1.0000000000" + }, + "price_monthly": { + "gross": "1.1900000000000000", + "net": "1.0000000000" + }, + "price_per_tb_traffic": { + "gross": "1.1900000000000000", + "net": "1.0000000000" + } + } + ] + }, + "location": { "city": "Falkenstein", "country": "DE", "description": "Falkenstein DC Park 1", @@ -9367,46 +12880,118 @@ "name": "fsn1", "network_zone": "eu-central" }, - "id": 4711, - "ip": "2001:db8::/64", - "labels": { - "key": "value" - }, "name": "Web Frontend", + "outgoing_traffic": 123456, + "private_net": [ + { + "ip": "10.0.0.2", + "network": 4711 + } + ], "protection": { "delete": false }, - "server": 42, - "type": "ipv6" + "public_net": { + "enabled": false, + "ipv4": { + "ip": "1.2.3.4" + }, + "ipv6": { + "ip": "2001:db8::1" + } + }, + "services": [ + { + "destination_port": 80, + "health_check": { + "http": { + "domain": "example.com", + "path": "/", + "response": "{\"status\": \"ok\"}", + "status_codes": [ + "2??,3??" + ], + "tls": false + }, + "interval": 15, + "port": 4711, + "protocol": "http", + "retries": 3, + "timeout": 10 + }, + "http": { + "certificates": [ + 897 + ], + "cookie_lifetime": 300, + "cookie_name": "HCLBSTICKY", + "redirect_http": true, + "sticky_sessions": true + }, + "listen_port": 443, + "protocol": "http", + "proxyprotocol": false + } + ], + "targets": [ + { + "health_status": [ + { + "listen_port": 443, + "status": "healthy" + } + ], + "server": { + "id": 80 + }, + "targets": [ + { + "health_status": [ + { + "listen_port": 443, + "status": "healthy" + } + ], + "server": { + "id": 80 + }, + "type": "server", + "use_private_ip": true + } + ], + "type": "server", + "use_private_ip": true + } + ] } }, "schema": { - "$ref": "#/components/schemas/create_floating_ip_response" + "$ref": "#/components/schemas/create_load_balancer_response" } } }, - "description": "Response for creating a [Floating IP](#floating-ips).\n\nContains the created IP.\n" + "description": "The `load_balancer` key contains the Load Balancer that was just created." } }, - "summary": "Create a Floating IP", + "summary": "Create a Load Balancer", "tags": [ - "floating_ips" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.FloatingIP.Create(ctx, hcloud.FloatingIPCreateOpts{\n\t\tDescription: hcloud.Ptr(\"This describes my resource\"),\n\t\tHomeLocation: &hcloud.Location{Name: \"fsn1\"},\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: hcloud.Ptr(\"my-resource\"),\n\t\tServer: &hcloud.Server{ID: 42},\n\t\tType: hcloud.FloatingIPTypeIPv4,\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tfloatingIP := result.FloatingIP\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.LoadBalancer.Create(ctx, hcloud.LoadBalancerCreateOpts{\n\t\tAlgorithm: &hcloud.LoadBalancerAlgorithm{\n\t\t\tType: hcloud.LoadBalancerAlgorithmTypeRoundRobin,\n\t\t},\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tLoadBalancerType: &hcloud.LoadBalancerType{Name: \"lb11\"},\n\t\tLocation: &hcloud.Location{Name: \"fsn1\"},\n\t\tName: \"Web Frontend\",\n\t\tNetwork: &hcloud.Network{ID: 123},\n\t\tNetworkZone: hcloud.NetworkZoneEUCentral,\n\t\tPublicInterface: hcloud.Ptr(true),\n\t\tServices: []hcloud.LoadBalancerCreateOptsService{\n\t\t\t{\n\t\t\t\tDestinationPort: hcloud.Ptr(80),\n\t\t\t\tHealthCheck: &hcloud.LoadBalancerCreateOptsServiceHealthCheck{\n\t\t\t\t\tHTTP: &hcloud.LoadBalancerCreateOptsServiceHealthCheckHTTP{\n\t\t\t\t\t\tDomain: hcloud.Ptr(\"example.com\"),\n\t\t\t\t\t\tPath: hcloud.Ptr(\"/\"),\n\t\t\t\t\t\tResponse: hcloud.Ptr(`{\"status\": \"ok\"}`),\n\t\t\t\t\t\tStatusCodes: []string{\"2??\", \"3??\"},\n\t\t\t\t\t\tTLS: hcloud.Ptr(false),\n\t\t\t\t\t},\n\t\t\t\t\tInterval: hcloud.Ptr(15 * time.Second),\n\t\t\t\t\tPort: hcloud.Ptr(4711),\n\t\t\t\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTP,\n\t\t\t\t\tRetries: hcloud.Ptr(3),\n\t\t\t\t\tTimeout: hcloud.Ptr(10 * time.Second),\n\t\t\t\t},\n\t\t\t\tHTTP: &hcloud.LoadBalancerCreateOptsServiceHTTP{\n\t\t\t\t\tCertificates: []*hcloud.Certificate{{ID: 897}},\n\t\t\t\t\tCookieLifetime: hcloud.Ptr(300 * time.Second),\n\t\t\t\t\tCookieName: hcloud.Ptr(\"HCLBSTICKY\"),\n\t\t\t\t\tRedirectHTTP: hcloud.Ptr(true),\n\t\t\t\t\tStickySessions: hcloud.Ptr(true),\n\t\t\t\t},\n\t\t\t\tListenPort: hcloud.Ptr(443),\n\t\t\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTPS,\n\t\t\t\tProxyprotocol: hcloud.Ptr(false),\n\t\t\t},\n\t\t},\n\t\tTargets: []hcloud.LoadBalancerCreateOptsTarget{\n\t\t\t{\n\t\t\t\tIP: hcloud.LoadBalancerCreateOptsTargetIP{\n\t\t\t\t\tIP: \"203.0.113.1\",\n\t\t\t\t},\n\t\t\t\tLabelSelector: hcloud.LoadBalancerCreateOptsTargetLabelSelector{\n\t\t\t\t\tSelector: \"env=prod\",\n\t\t\t\t},\n\t\t\t\tServer: hcloud.LoadBalancerCreateOptsTargetServer{\n\t\t\t\t\tServer: &hcloud.Server{ID: 80},\n\t\t\t\t},\n\t\t\t\tType: hcloud.LoadBalancerTargetTypeServer,\n\t\t\t\tUsePrivateIP: hcloud.Ptr(false),\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tloadBalancer := result.LoadBalancer\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.locations import Location\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.floating_ips.create(\n description=\"This describes my resource\",\n home_location=Location(name=\"fsn1\"),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-resource\",\n server=Server(id=42),\n type=\"ipv4\",\n)\n\nresponse.action.wait_until_finished()\n\nfloating_ip = response.floating_ip" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\nfrom hcloud.load_balancer_types import LoadBalancerType\nfrom hcloud.load_balancers import (\n LoadBalancerAlgorithm,\n LoadBalancerService,\n LoadBalancerHealthCheck,\n LoadBalancerHealtCheckHttp,\n LoadBalancerServiceHttp,\n LoadBalancerTarget,\n LoadBalancerTargetIP,\n LoadBalancerTargetLabelSelector,\n)\nfrom hcloud.locations import Location\nfrom hcloud.networks import Network\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.load_balancers.create(\n algorithm=LoadBalancerAlgorithm(type=\"round_robin\"),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n load_balancer_type=LoadBalancerType(name=\"lb11\"),\n location=Location(name=\"fsn1\"),\n name=\"Web Frontend\",\n network=Network(id=123),\n network_zone=\"eu-central\",\n public_interface=True,\n services=[\n LoadBalancerService(\n destination_port=80,\n health_check=LoadBalancerHealthCheck(\n http=LoadBalancerHealtCheckHttp(\n domain=\"example.com\",\n path=\"/\",\n response='{\"status\": \"ok\"}',\n status_codes=[\"2??\", \"3??\"],\n tls=False,\n ),\n interval=15,\n port=4711,\n protocol=\"http\",\n retries=3,\n timeout=10,\n ),\n http=LoadBalancerServiceHttp(\n certificates=[Certificate(id=897)],\n cookie_lifetime=300,\n cookie_name=\"HCLBSTICKY\",\n redirect_http=True,\n sticky_sessions=True,\n ),\n listen_port=443,\n protocol=\"https\",\n proxyprotocol=False,\n )\n ],\n targets=[\n LoadBalancerTarget(\n ip=LoadBalancerTargetIP(\n ip=\"203.0.113.1\",\n ),\n label_selector=LoadBalancerTargetLabelSelector(\n selector=\"env=prod\",\n ),\n server=Server(\n id=80,\n ),\n type=\"server\",\n use_private_ip=True,\n )\n ],\n)\n\nresponse.action.wait_until_finished()\n\nload_balancer = response.load_balancer" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud floating-ip create \\\n --description \"This describes my resource\" \\\n --home-location fsn1 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name my-resource \\\n --server 42 \\\n --type ipv4" + "source": "hcloud load-balancer create \\\n --algorithm-type round_robin \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --type lb11 \\\n --location fsn1 \\\n --name \"Web Frontend\"\n\nhcloud load-balancer enable-public-interface \"Web Frontend\"\n\nhcloud load-balancer add-service \"Web Frontend\" \\\n --destination-port 80 \\\n --health-check-http-domain example.com \\\n --health-check-http-path \"/\" \\\n --health-check-http-response '{\"status\": \"ok\"}' \\\n --health-check-http-status-codes \"2??,3??\" \\\n --health-check-http-tls=false \\\n --health-check-interval 15s \\\n --health-check-port 4711 \\\n --health-check-protocol http \\\n --health-check-retries 3 \\\n --health-check-timeout 10s \\\n --http-certificates 897 \\\n --http-cookie-lifetime 300s \\\n --http-cookie-name HCLBSTICKY \\\n --http-redirect-http=true \\\n --http-sticky-sessions=true \\\n --listen-port 443 \\\n --protocol https \\\n --proxy-protocol=false\n\nhcloud load-balancer add-target \"Web Frontend\" --ip 203.0.113.1\nhcloud load-balancer add-target \"Web Frontend\" --label-selector \"env=prod\"\nhcloud load-balancer add-target \"Web Frontend\" --server 80 --use-private-ip" } ] }, @@ -9416,18 +13001,18 @@ } ] }, - "/floating_ips/{id}": { + "/load_balancers/{id}": { "delete": { - "description": "Deletes a [Floating IP](#floating-ips).\n\nIf the IP is assigned to a resource it will be unassigned.\n", - "operationId": "delete_floating_ip", + "description": "Deletes a Load Balancer.", + "operationId": "delete_load_balancer", "parameters": [ { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -9437,42 +13022,42 @@ ], "responses": { "204": { - "description": "Floating IP deleted." + "description": "Load Balancer deleted." } }, - "summary": "Delete a Floating IP", + "summary": "Delete a Load Balancer", "tags": [ - "floating_ips" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.FloatingIP.Delete(ctx, &hcloud.FloatingIP{ID: 123})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.LoadBalancer.Delete(ctx, &hcloud.LoadBalancer{ID: 123})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.floating_ips.delete(floating_ip=FloatingIP(id=123))" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.load_balancers.delete(load_balancer=LoadBalancer(id=123))" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud floating-ip delete $FLOATINGIP" + "source": "hcloud load-balancer delete $LOADBALANCER" } ] }, "get": { - "description": "Returns a single [Floating IP](#floating-ips).", - "operationId": "get_floating_ip", + "description": "Gets a specific Load Balancer object.", + "operationId": "get_load_balancer", "parameters": [ { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -9485,46 +13070,46 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/get_floating_ip_response" + "$ref": "#/components/schemas/get_load_balancer_response" } } }, - "description": "Response for getting a single [Floating IP](#floating-ips)." + "description": "The `load_balancer` key contains the Load Balancer." } }, - "summary": "Get a Floating IP", + "summary": "Get a Load Balancer", "tags": [ - "floating_ips" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfloatingIP, _, err := client.FloatingIP.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tloadBalancer, _, err := client.LoadBalancer.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nfloating_ip = client.floating_ips.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nload_balancer = client.load_balancers.get_by_id(123)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud floating-ip describe $FLOATINGIP" + "source": "hcloud load-balancer describe $LOADBALANCER" } ] }, "put": { - "description": "Update a [Floating IP](#floating-ips).\n", - "operationId": "replace_floating_ip", + "description": "Updates a Load Balancer. You can update a Load Balancer’s name and a Load Balancer’s labels.\n\nNote: if the Load Balancer object changes during the request, the response will be a “conflict” error.\n", + "operationId": "replace_load_balancer", "parameters": [ { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -9536,7 +13121,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/replace_floating_ip_request" + "$ref": "#/components/schemas/replace_load_balancer_request" } } } @@ -9546,17 +13131,46 @@ "content": { "application/json": { "example": { - "floating_ip": { - "blocked": false, + "load_balancer": { + "algorithm": { + "type": "round_robin" + }, "created": "2016-01-30T23:50:00+00:00", - "description": "Web Frontend", - "dns_ptr": [ - { - "dns_ptr": "server.example.com", - "ip": "2001:db8::1" - } - ], - "home_location": { + "id": 4711, + "included_traffic": 654321, + "ingoing_traffic": 123456, + "labels": { + "key": "value" + }, + "load_balancer_type": { + "deprecated": "2016-01-30T23:50:00+00:00", + "description": "LB11", + "id": 1, + "max_assigned_certificates": 10, + "max_connections": 20000, + "max_services": 5, + "max_targets": 25, + "name": "lb11", + "prices": [ + { + "included_traffic": 654321, + "location": "fsn1", + "price_hourly": { + "gross": "1.1900000000000000", + "net": "1.0000000000" + }, + "price_monthly": { + "gross": "1.1900000000000000", + "net": "1.0000000000" + }, + "price_per_tb_traffic": { + "gross": "1.1900000000000000", + "net": "1.0000000000" + } + } + ] + }, + "location": { "city": "Falkenstein", "country": "DE", "description": "Falkenstein DC Park 1", @@ -9566,46 +13180,124 @@ "name": "fsn1", "network_zone": "eu-central" }, - "id": 4711, - "ip": "2001:db8::/64", - "labels": { - "key": "value" - }, - "name": "Web Frontend", + "name": "new-name", + "outgoing_traffic": 123456, + "private_net": [ + { + "ip": "10.0.0.2", + "network": 4711 + } + ], "protection": { "delete": false }, - "server": 42, - "type": "ipv6" + "public_net": { + "enabled": false, + "ipv4": { + "ip": "1.2.3.4" + }, + "ipv6": { + "ip": "2001:db8::1" + } + }, + "services": [ + { + "destination_port": 80, + "health_check": { + "http": { + "domain": "example.com", + "path": "/", + "response": "{\"status\": \"ok\"}", + "status_codes": [ + "2??,3??" + ], + "tls": false + }, + "interval": 15, + "port": 4711, + "protocol": "http", + "retries": 3, + "timeout": 10 + }, + "http": { + "certificates": [ + 897 + ], + "cookie_lifetime": 300, + "cookie_name": "HCLBSTICKY", + "redirect_http": true, + "sticky_sessions": true + }, + "listen_port": 443, + "protocol": "http", + "proxyprotocol": false + } + ], + "targets": [ + { + "health_status": [ + { + "listen_port": 443, + "status": "healthy" + } + ], + "ip": { + "ip": "203.0.113.1" + }, + "label_selector": { + "selector": "env=prod" + }, + "server": { + "id": 80 + }, + "targets": [ + { + "health_status": [ + { + "listen_port": 443, + "status": "healthy" + } + ], + "server": { + "id": 80 + }, + "type": "server", + "use_private_ip": true + } + ], + "type": "server", + "use_private_ip": true + } + ] } }, "schema": { - "$ref": "#/components/schemas/replace_floating_ip_response" + "$ref": "#/components/schemas/replace_load_balancer_response" } } }, - "description": "Response for updating a [Floating IP](#floating-ips).\n\nContains the updated [Floating IP](#floating-ips).\n" + "description": "The `load_balancer` key contains the updated Load Balancer." } }, - "summary": "Update a Floating IP", + "summary": "Update a Load Balancer", "tags": [ - "floating_ips" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tfloatingIP, _, err := client.FloatingIP.Update(ctx, &hcloud.FloatingIP{ID: 123}, hcloud.FloatingIPUpdateOpts{\n\t\tDescription: \"This describes my resource\",\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"my-resource\",\n\t})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tloadBalancer, _, err := client.LoadBalancer.Update(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"new-name\",\n\t})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.floating_ips.update(\n floating_ip=FloatingIP(id=123),\n description=\"This describes my resource\",\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-resource\",\n)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nload_balancer = client.load_balancers.update(\n load_balancer=LoadBalancer(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"new-name\",\n)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud floating-ip update $FLOATINGIP \\\n --description \"This describes my resource\" \\\n --name my-resource\nhcloud floating-ip add-label --overwrite $FLOATINGIP \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud floating-ip remove-label $FLOATINGIP \\\n \"environment\" \"example.com\" \"just-a-key\"" + "source": "hcloud load-balancer update $LOADBALANCER --name new-name\nhcloud load-balancer add-label --overwrite $LOADBALANCER \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud load-balancer remove-label $LOADBALANCER \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] }, @@ -9615,18 +13307,18 @@ } ] }, - "/floating_ips/{id}/actions": { + "/load_balancers/{id}/actions": { "get": { - "description": "Lists [Actions](#actions) for a [Floating IP](#floating-ips).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_actions_for_floating_ip", + "description": "Returns all Action objects for a Load Balancer. You can sort the results by using the `sort` URI parameter, and filter them with the `status` parameter.", + "operationId": "list_actions_for_load_balancer", "parameters": [ { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -9712,7 +13404,7 @@ "example": { "actions": [ { - "command": "assign_floating_ip", + "command": "add_service", "error": { "code": "action_failed", "message": "Action failed" @@ -9723,11 +13415,7 @@ "resources": [ { "id": 4711, - "type": "server" - }, - { - "id": 4712, - "type": "floating_ip" + "type": "load_balancer" } ], "started": "2016-01-30T23:55:00+00:00", @@ -9750,12 +13438,12 @@ } } }, - "description": "Response for listing [Actions](#actions)." + "description": "The `actions` key contains a list of Actions." } }, - "summary": "List Actions for a Floating IP", + "summary": "List Actions for a Load Balancer", "tags": [ - "floating_ips" + "load_balancers" ] }, "servers": [ @@ -9764,18 +13452,18 @@ } ] }, - "/floating_ips/{id}/actions/{action_id}": { + "/load_balancers/{id}/actions/{action_id}": { "get": { - "description": "Returns a specific [Action](#actions) for a [Floating IP](#floating-ips).", - "operationId": "get_action_for_floating_ip", + "description": "Returns a specific Action for a Load Balancer.", + "operationId": "get_action_for_load_balancer", "parameters": [ { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -9802,7 +13490,7 @@ "application/json": { "example": { "action": { - "command": "assign_floating_ip", + "command": "change_protection", "error": { "code": "action_failed", "message": "Action failed" @@ -9811,13 +13499,9 @@ "id": 13, "progress": 100, "resources": [ - { - "id": 42, - "type": "server" - }, { "id": 4711, - "type": "floating_ip" + "type": "load_balancer" } ], "started": "2016-01-30T23:55:00+00:00", @@ -9829,12 +13513,12 @@ } } }, - "description": "Response for getting an [Action](#actions)." + "description": "The `action` key contains the Load Balancer Action." } }, - "summary": "Get an Action for a Floating IP", + "summary": "Get an Action for a Load Balancer", "tags": [ - "floating_ips" + "load_balancers" ] }, "servers": [ @@ -9843,18 +13527,18 @@ } ] }, - "/floating_ips/{id}/actions/assign": { + "/load_balancers/{id}/actions/add_service": { "post": { - "description": "Assigns a [Floating IP](#floating-ips) to a [Server](#servers).", - "operationId": "assign_floating_ip_to_server", + "description": "Adds a service to a Load Balancer.\n\n#### Call specific error codes\n\n| Code | Description |\n|----------------------------|---------------------------------------------------------|\n| `source_port_already_used` | The source port you are trying to add is already in use |\n", + "operationId": "add_service", "parameters": [ { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -9866,7 +13550,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/assign_floating_ip_to_server_request" + "$ref": "#/components/schemas/add_service_request" } } } @@ -9877,7 +13561,7 @@ "application/json": { "example": { "action": { - "command": "assign_floating_ip", + "command": "add_service", "error": { "code": "action_failed", "message": "Action failed" @@ -9886,13 +13570,9 @@ "id": 13, "progress": 100, "resources": [ - { - "id": 42, - "type": "server" - }, { "id": 4711, - "type": "floating_ip" + "type": "load_balancer" } ], "started": "2016-01-30T23:55:00+00:00", @@ -9900,32 +13580,32 @@ } }, "schema": { - "$ref": "#/components/schemas/assign_floating_ip_to_server_response" + "$ref": "#/components/schemas/add_service_response" } } }, - "description": "Response for assigning a [Floating IP](#floating-ips).\n\nContains an [Action](#actions) of type `assign_floating_ip`.\n" + "description": "The `action` key contains the `add_service` Action." } }, - "summary": "Assign a Floating IP to a Server", + "summary": "Add Service", "tags": [ - "floating_ips" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.FloatingIP.Assign(ctx, &hcloud.FloatingIP{ID: 123}, &hcloud.Server{ID: 456})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.AddService(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerAddServiceOpts{\n\t\tDestinationPort: hcloud.Ptr(80),\n\t\tHealthCheck: &hcloud.LoadBalancerAddServiceOptsHealthCheck{\n\t\t\tHTTP: &hcloud.LoadBalancerAddServiceOptsHealthCheckHTTP{\n\t\t\t\tDomain: hcloud.Ptr(\"example.com\"),\n\t\t\t\tPath: hcloud.Ptr(\"/\"),\n\t\t\t\tResponse: hcloud.Ptr(`{\"status\": \"ok\"}`),\n\t\t\t\tStatusCodes: []string{\"2??\", \"3??\"},\n\t\t\t\tTLS: hcloud.Ptr(false),\n\t\t\t},\n\t\t\tInterval: hcloud.Ptr(15 * time.Second),\n\t\t\tPort: hcloud.Ptr(4711),\n\t\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTP,\n\t\t\tRetries: hcloud.Ptr(3),\n\t\t\tTimeout: hcloud.Ptr(10 * time.Second),\n\t\t},\n\t\tHTTP: &hcloud.LoadBalancerAddServiceOptsHTTP{\n\t\t\tCertificates: []*hcloud.Certificate{{ID: 897}},\n\t\t\tCookieLifetime: hcloud.Ptr(300 * time.Second),\n\t\t\tCookieName: hcloud.Ptr(\"HCLBSTICKY\"),\n\t\t\tRedirectHTTP: hcloud.Ptr(true),\n\t\t\tStickySessions: hcloud.Ptr(true),\n\t\t},\n\t\tListenPort: hcloud.Ptr(443),\n\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTPS,\n\t\tProxyprotocol: hcloud.Ptr(false),\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.floating_ips.assign(\n floating_ip=FloatingIP(id=123),\n server=Server(id=42),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\nfrom hcloud.load_balancers import (\n LoadBalancer,\n LoadBalancerService,\n LoadBalancerHealthCheck,\n LoadBalancerHealtCheckHttp,\n LoadBalancerServiceHttp,\n)\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.add_service(\n load_balancer=LoadBalancer(id=123),\n service=LoadBalancerService(\n destination_port=80,\n health_check=LoadBalancerHealthCheck(\n http=LoadBalancerHealtCheckHttp(\n domain=\"example.com\",\n path=\"/\",\n response='{\"status\": \"ok\"}',\n status_codes=[\"2??\", \"3??\"],\n tls=False,\n ),\n interval=15,\n port=4711,\n protocol=\"http\",\n retries=3,\n timeout=10,\n ),\n http=LoadBalancerServiceHttp(\n certificates=[Certificate(id=897)],\n cookie_lifetime=300,\n cookie_name=\"HCLBSTICKY\",\n redirect_http=True,\n sticky_sessions=True,\n ),\n listen_port=443,\n protocol=\"https\",\n proxyprotocol=False,\n ),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud floating-ip assign $FLOATINGIP $SERVER" + "source": "hcloud load-balancer add-service $LOADBALANCER \\\n --destination-port 80 \\\n --health-check-http-domain example.com \\\n --health-check-http-path \"/\" \\\n --health-check-http-response '{\"status\": \"ok\"}' \\\n --health-check-http-status-codes \"2??,3??\" \\\n --health-check-http-tls=false \\\n --health-check-interval 15s \\\n --health-check-port 4711 \\\n --health-check-protocol http \\\n --health-check-retries 3 \\\n --health-check-timeout 10s \\\n --http-certificates 897 \\\n --http-cookie-lifetime 300s \\\n --http-cookie-name HCLBSTICKY \\\n --http-redirect-http=true \\\n --http-sticky-sessions=true \\\n --listen-port 443 \\\n --protocol https \\\n --proxy-protocol=false" } ] }, @@ -9935,18 +13615,18 @@ } ] }, - "/floating_ips/{id}/actions/change_dns_ptr": { + "/load_balancers/{id}/actions/add_target": { "post": { - "description": "Change the reverse DNS records for this [Floating IP](#floating-ips).\n\nAllows to modify the PTR records set for the IP address.\n", - "operationId": "change_reverse_dns_records_for_floating_ip", + "description": "Adds a target to a Load Balancer.\n\n#### Call specific error codes\n\n| Code | Description |\n|-------------------------------------------|-------------------------------------------------------------------------------------------------------|\n| `cloud_resource_ip_not_allowed` | The IP you are trying to add as a target belongs to a Hetzner Cloud resource |\n| `ip_not_owned` | The IP you are trying to add as a target is not owned by the Project owner |\n| `load_balancer_public_interface_disabled` | The Load Balancer's public network interface is disabled |\n| `load_balancer_not_attached_to_network` | The Load Balancer is not attached to a network |\n| `robot_unavailable` | Robot was not available. The caller may retry the operation after a short delay. |\n| `server_not_attached_to_network` | The server you are trying to add as a target is not attached to the same network as the Load Balancer |\n| `missing_ipv4` | The server that you are trying to add as a public target does not have a public IPv4 address |\n| `target_already_defined` | The Load Balancer target you are trying to define is already defined |\n", + "operationId": "add_target", "parameters": [ { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -9958,11 +13638,10 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/change_reverse_dns_records_for_floating_ip_request" + "$ref": "#/components/schemas/add_target_request" } } - }, - "description": "The `ip` attributes specifies for which IP address the record is set. For IPv4 addresses this must be the exact address of the [Floating IP](#floating-ips). For IPv6 addresses this must be a single address within the `/64` subnet of the [Floating IP](#floating-ips).\n\nThe `dns_ptr` attribute specifies the hostname used for the IP address.\n\nFor IPv6 [Floating IPs](#floating-ips) up to 100 entries can be created.\n" + } }, "responses": { "201": { @@ -9970,7 +13649,7 @@ "application/json": { "example": { "action": { - "command": "change_dns_ptr", + "command": "add_target", "error": { "code": "action_failed", "message": "Action failed" @@ -9981,7 +13660,7 @@ "resources": [ { "id": 4711, - "type": "floating_ip" + "type": "load_balancer" } ], "started": "2016-01-30T23:55:00+00:00", @@ -9989,32 +13668,32 @@ } }, "schema": { - "$ref": "#/components/schemas/change_reverse_dns_records_for_floating_ip_response" + "$ref": "#/components/schemas/add_target_response" } } }, - "description": "Response for changing a [Floating IPs](#floating-ips) DNS pointer.\n\nContains an [Action](#actions) of type `change_dns_ptr`.\n" + "description": "The `action` key contains the `add_target` Action." } }, - "summary": "Change reverse DNS records for a Floating IP", + "summary": "Add Target", "tags": [ - "floating_ips" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.FloatingIP.ChangeDNSPtr(ctx, &hcloud.FloatingIP{ID: 123}, \"2001:db8::1\", hcloud.Ptr(\"server.example.com\"))\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction1, _, err := client.LoadBalancer.AddIPTarget(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerAddIPTargetOpts{\n\t\tIP: net.ParseIP(\"203.0.113.1\"),\n\t})\n\n\taction2, _, err := client.LoadBalancer.AddLabelSelectorTarget(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerAddLabelSelectorTargetOpts{\n\t\tSelector: \"env=prod\",\n\t})\n\n\taction3, _, err := client.LoadBalancer.AddServerTarget(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerAddServerTargetOpts{\n\t\tServer: &hcloud.Server{ID: 80},\n\t\tUsePrivateIP: hcloud.Ptr(true),\n\t})\n\n\terr = client.Action.WaitFor(ctx, action1, action2, action3)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.floating_ips.change_dns_ptr(\n floating_ip=FloatingIP(id=123),\n dns_ptr=\"server.example.com\",\n ip=\"2001:db8::1\",\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import (\n LoadBalancer,\n LoadBalancerTarget,\n LoadBalancerTargetIP,\n LoadBalancerTargetLabelSelector,\n)\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.add_target(\n load_balancer=LoadBalancer(id=123),\n target=LoadBalancerTarget(\n ip=LoadBalancerTargetIP(\n ip=\"203.0.113.1\",\n ),\n label_selector=LoadBalancerTargetLabelSelector(\n selector=\"env=prod\",\n ),\n server=Server(\n id=80,\n ),\n type=\"server\",\n use_private_ip=True,\n ),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud floating-ip set-rdns $FLOATINGIP \\\n --ip 2001:db8::1 \\\n --hostname server.example.com" + "source": "hcloud load-balancer add-target $LOADBALANCER --ip 203.0.113.1\nhcloud load-balancer add-target $LOADBALANCER --label-selector \"env=prod\"\nhcloud load-balancer add-target $LOADBALANCER --server 80 --use-private-ip" } ] }, @@ -10024,18 +13703,18 @@ } ] }, - "/floating_ips/{id}/actions/change_protection": { + "/load_balancers/{id}/actions/attach_to_network": { "post": { - "description": "Changes the protection settings configured for the [Floating IP](#floating-ips).", - "operationId": "change_floating_ip_protection", + "description": "Attach a Load Balancer to a Network.\n\n**Call specific error codes**\n\n| Code | Description |\n|----------------------------------|-----------------------------------------------------------------------|\n| `load_balancer_already_attached` | The Load Balancer is already attached to a network |\n| `ip_not_available` | The provided Network IP is not available |\n| `no_subnet_available` | No Subnet or IP is available for the Load Balancer within the network |\n", + "operationId": "attach_load_balancer_to_network", "parameters": [ { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -10047,7 +13726,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/change_floating_ip_protection_request" + "$ref": "#/components/schemas/attach_load_balancer_to_network_request" } } } @@ -10058,7 +13737,7 @@ "application/json": { "example": { "action": { - "command": "change_protection", + "command": "attach_to_network", "error": { "code": "action_failed", "message": "Action failed" @@ -10069,7 +13748,7 @@ "resources": [ { "id": 4711, - "type": "floating_ip" + "type": "load_balancer" } ], "started": "2016-01-30T23:55:00+00:00", @@ -10077,32 +13756,32 @@ } }, "schema": { - "$ref": "#/components/schemas/change_floating_ip_protection_response" + "$ref": "#/components/schemas/attach_load_balancer_to_network_response" } } }, - "description": "Response for changing a [Floating IPs](#floating-ips) protection settings.\n\nContains an [Action](#actions) of type `change_protection`.\n" + "description": "The `action` key contains the `attach_to_network` Action." } }, - "summary": "Change Floating IP Protection", + "summary": "Attach a Load Balancer to a Network", "tags": [ - "floating_ips" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.FloatingIP.ChangeProtection(ctx, &hcloud.FloatingIP{ID: 123},\n\t\thcloud.FloatingIPChangeProtectionOpts{Delete: hcloud.Ptr(false)})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.AttachToNetwork(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerAttachToNetworkOpts{\n\t\tIP: net.ParseIP(\"10.0.1.1\"),\n\t\tNetwork: &hcloud.Network{ID: 4711},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.floating_ips.change_protection(\n floating_ip=FloatingIP(id=123), delete=False\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.attach_to_network(\n load_balancer=LoadBalancer(id=123),\n ip=\"10.0.1.1\",\n network=Network(id=4711),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud floating-ip enable-protection $FLOATINGIP delete\nhcloud floating-ip disable-protection $FLOATINGIP delete" + "source": "hcloud load-balancer attach-to-network $LOADBALANCER \\\n --ip 10.0.1.1 \\\n --network 4711" } ] }, @@ -10112,18 +13791,18 @@ } ] }, - "/floating_ips/{id}/actions/unassign": { + "/load_balancers/{id}/actions/change_algorithm": { "post": { - "description": "Unassigns a [Floating IP](#floating-ips).\n\nResults in the IP being unreachable. Can be assigned to another resource again.\n", - "operationId": "unassign_floating_ip", + "description": "Change the algorithm that determines to which target new requests are sent.", + "operationId": "change_algorithm", "parameters": [ { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Floating IP.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -10131,13 +13810,22 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_algorithm_request" + } + } + } + }, "responses": { "201": { "content": { "application/json": { "example": { "action": { - "command": "unassign_floating_ip", + "command": "change_algorithm", "error": { "code": "action_failed", "message": "Action failed" @@ -10146,13 +13834,9 @@ "id": 13, "progress": 100, "resources": [ - { - "id": 42, - "type": "server" - }, { "id": 4711, - "type": "floating_ip" + "type": "load_balancer" } ], "started": "2016-01-30T23:55:00+00:00", @@ -10160,32 +13844,32 @@ } }, "schema": { - "$ref": "#/components/schemas/unassign_floating_ip_response" + "$ref": "#/components/schemas/change_algorithm_response" } } }, - "description": "Response for unassigning a [Floating IP](#floating-ips).\n\nContains an [Action](#actions) of type `unassign_floating_ip`.\n" + "description": "The `action` key contains the `change_algorithm` Action." } }, - "summary": "Unassign a Floating IP", + "summary": "Change Algorithm", "tags": [ - "floating_ips" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.FloatingIP.Unassign(ctx, &hcloud.FloatingIP{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.ChangeAlgorithm(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerChangeAlgorithmOpts{\n\t\tType: hcloud.LoadBalancerAlgorithmTypeRoundRobin,\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.floating_ips import FloatingIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.floating_ips.unassign(\n floating_ip=FloatingIP(id=123),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer, LoadBalancerAlgorithm\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.change_algorithm(\n load_balancer=LoadBalancer(id=123),\n algorithm=LoadBalancerAlgorithm(type=\"round_robin\"),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud floating-ip unassign $FLOATINGIP" + "source": "hcloud load-balancer change-algorithm $LOADBALANCER \\\n --algorithm-type round_robin" } ] }, @@ -10195,125 +13879,86 @@ } ] }, - "/floating_ips/actions": { - "get": { - "description": "Lists multiple [Actions](#actions).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_floating_ip_actions", + "/load_balancers/{id}/actions/change_dns_ptr": { + "post": { + "description": "Changes the hostname that will appear when getting the hostname belonging to the public IPs (IPv4 and IPv6) of this Load Balancer.\n\nFloating IPs assigned to the Server are not affected by this.\n", + "operationId": "change_reverse_dns_entry_for_this_load_balancer", "parameters": [ { - "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", - "in": "query", + "description": "ID of the Load Balancer.", + "in": "path", "name": "id", - "required": false, - "schema": { - "items": { - "description": "ID of the Action.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - }, - "type": "array" - } - }, - { - "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "command", - "command:asc", - "command:desc", - "status", - "status:asc", - "status:desc", - "started", - "started:asc", - "started:desc", - "finished", - "finished:asc", - "finished:desc" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", - "in": "query", - "name": "status", - "required": false, - "schema": { - "items": { - "description": "Status of the Action.", - "enum": [ - "running", - "success", - "error" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Load Balancer.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_load_balancer_request" + } + } + }, + "description": "Select the IP address for which to change the DNS entry by passing `ip`. It can be either IPv4 or IPv6. The target hostname is set by passing `dns_ptr`." + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "change_dns_ptr", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "load_balancer" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + }, "schema": { - "$ref": "#/components/schemas/list_actions_response" + "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_load_balancer_response" } } }, - "description": "Response for listing [Actions](#actions)." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "List Actions", + "summary": "Change reverse DNS entry for this Load Balancer", "tags": [ - "floating_ips" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.FloatingIP.Action.All(ctx, hcloud.ActionListOpts{})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.ChangeDNSPtr(ctx, &hcloud.LoadBalancer{ID: 123}, \"1.2.3.4\", hcloud.Ptr(\"lb1.example.com\"))\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.floating_ips.actions.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.change_dns_ptr(\n load_balancer=LoadBalancer(id=123),\n dns_ptr=\"lb1.example.com\",\n ip=\"1.2.3.4\",\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud load-balancer set-rdns $LOADBALANCER \\\n --ip 1.2.3.4 \\\n --hostname lb1.example.com" } ] }, @@ -10323,18 +13968,18 @@ } ] }, - "/floating_ips/actions/{id}": { - "get": { - "description": "Returns a single [Action](#actions).", - "operationId": "get_floating_ip_action", + "/load_balancers/{id}/actions/change_protection": { + "post": { + "description": "Changes the protection configuration of a Load Balancer.", + "operationId": "change_load_balancer_protection", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Action.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -10342,32 +13987,66 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_load_balancer_protection_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "change_protection", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 4711, + "type": "load_balancer" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/change_load_balancer_protection_response" } } }, - "description": "Response for getting a single [Action](#actions)." + "description": "The `action` key contains the `change_protection` Action." } }, - "summary": "Get an Action", + "summary": "Change Load Balancer Protection", "tags": [ - "floating_ips" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.FloatingIP.Action.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.ChangeProtection(ctx, &hcloud.LoadBalancer{ID: 123},\n\t\thcloud.LoadBalancerChangeProtectionOpts{Delete: hcloud.Ptr(true)})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.floating_ips.actions.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.change_protection(\n load_balancer=LoadBalancer(id=123),\n delete=True,\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud load-balancer enable-protection $LOADBALANCER delete\nhcloud load-balancer disable-protection $LOADBALANCER delete" } ] }, @@ -10377,183 +14056,85 @@ } ] }, - "/images": { - "get": { - "description": "Returns all Image objects. You can select specific Image types only and sort the results by using URI parameters.", - "operationId": "list_images", + "/load_balancers/{id}/actions/change_type": { + "post": { + "description": "Changes the type (Max Services, Max Targets and Max Connections) of a Load Balancer.\n\n**Call specific error codes**\n\n| Code | Description |\n|------------------------------|-----------------------------------------------------------------|\n| `invalid_load_balancer_type` | The Load Balancer type does not fit for the given Load Balancer |\n", + "operationId": "change_type_of_load_balancer", "parameters": [ { - "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "name", - "name:asc", - "name:desc", - "created", - "created:asc", - "created:desc" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter resources by type. Can be used multiple times. The response will only\ncontain the resources with the specified type.\n", - "in": "query", - "name": "type", - "required": false, - "schema": { - "items": { - "description": "Type of the Image.", - "enum": [ - "system", - "app", - "snapshot", - "backup" - ], - "example": "snapshot", - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter resources by status. Can be used multiple times. The response will only\ncontain the resources with the specified status.\n", - "in": "query", - "name": "status", - "required": false, - "schema": { - "items": { - "description": "Status of the Image.", - "enum": [ - "available", - "creating", - "unavailable" - ], - "example": "available", - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Can be used multiple times. Server ID linked to the Image. Only available for Images of type `backup`.", - "in": "query", - "name": "bound_to", - "required": false, - "schema": { - "items": { - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Can be used multiple times.", - "in": "query", - "name": "include_deprecated", - "required": false, - "schema": { - "type": "boolean" - } - }, - { - "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", - "in": "query", - "name": "name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", - "in": "query", - "name": "label_selector", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Filter resources by cpu architecture. The response will only contain the resources\nwith the specified cpu architecture.\n", - "in": "query", - "name": "architecture", - "required": false, - "schema": { - "description": "CPU architecture of the Resource.", - "enum": [ - "x86", - "arm" - ], - "example": "x86", - "type": "string" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "description": "ID of the Load Balancer.", + "in": "path", + "name": "id", + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Load Balancer.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_type_of_load_balancer_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "change_load_balancer_type", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + }, "schema": { - "$ref": "#/components/schemas/list_images_response" + "$ref": "#/components/schemas/change_type_of_load_balancer_response" } } }, - "description": "The `images` key in the reply contains an array of Image objects with this structure." + "description": "The `action` key contains the `change_load_balancer_type` Action." } }, - "summary": "List Images", + "summary": "Change the Type of a Load Balancer", "tags": [ - "images" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\timages, err := client.Image.All(ctx)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.ChangeType(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerChangeTypeOpts{\n\t\tLoadBalancerType: &hcloud.LoadBalancerType{Name: \"lb21\"},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nimages = client.images.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancer_types import LoadBalancerType\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.change_type(\n load_balancer=LoadBalancer(id=123),\n load_balancer_type=LoadBalancerType(name=\"lb21\"),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud image list" + "source": "hcloud load-balancer change-type $LOADBALANCER lb21" } ] }, @@ -10563,18 +14144,18 @@ } ] }, - "/images/{id}": { - "delete": { - "description": "Deletes an Image. Only Images of type `snapshot` and `backup` can be deleted.", - "operationId": "delete_image", + "/load_balancers/{id}/actions/delete_service": { + "post": { + "description": "Delete a service of a Load Balancer.", + "operationId": "delete_service", "parameters": [ { - "description": "ID of the Image.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Image.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -10582,44 +14163,87 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/delete_service_request" + } + } + } + }, "responses": { - "204": { - "description": "Image deleted." + "201": { + "content": { + "application/json": { + "example": { + "action": { + "command": "delete_service", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 4711, + "type": "load_balancer" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, + "schema": { + "$ref": "#/components/schemas/delete_service_response" + } + } + }, + "description": "The `action` key contains the `delete_service` Action." } }, - "summary": "Delete an Image", + "summary": "Delete Service", "tags": [ - "images" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.Image.Delete(ctx, &hcloud.Image{ID: 123})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.DeleteService(ctx, &hcloud.LoadBalancer{ID: 123}, 443)\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.images import Image\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nimage = client.images.delete(Image(id=123))" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer, LoadBalancerService\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.delete_service(\n load_balancer=LoadBalancer(id=123), service=LoadBalancerService(listen_port=443)\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud image delete $IMAGE" + "source": "hcloud load-balancer delete-service $LOADBALANCER \\\n --listen-port 443" } ] }, - "get": { - "description": "Returns a specific Image object.", - "operationId": "get_image", + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/load_balancers/{id}/actions/detach_from_network": { + "post": { + "description": "Detaches a Load Balancer from a network.", + "operationId": "detach_load_balancer_from_network", "parameters": [ { - "description": "ID of the Image.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Image.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -10627,51 +14251,91 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/detach_load_balancer_from_network_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "detach_from_network", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + }, + { + "id": 4711, + "type": "network" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + }, "schema": { - "$ref": "#/components/schemas/get_image_response" + "$ref": "#/components/schemas/detach_load_balancer_from_network_response" } } }, - "description": "The `image` key in the reply contains an Image object with this structure." + "description": "The `action` key contains the `detach_from_network` Action." } }, - "summary": "Get an Image", + "summary": "Detach a Load Balancer from a Network", "tags": [ - "images" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\timage, _, err := client.Image.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.DetachFromNetwork(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerDetachFromNetworkOpts{\n\t\tNetwork: &hcloud.Network{ID: 4711},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nimage = client.images.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.detach_from_network(\n load_balancer=LoadBalancer(id=123), network=Network(id=4711)\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud image describe $IMAGE" + "source": "hcloud load-balancer detach-from-network $LOADBALANCER \\\n --network $NETWORK" } ] }, - "put": { - "description": "Updates the Image. You may change the description, convert a Backup Image to a Snapshot Image or change the Image labels. Only Images of type `snapshot` and `backup` can be updated.\n", - "operationId": "replace_image", + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/load_balancers/{id}/actions/disable_public_interface": { + "post": { + "description": "Disable the public interface of a Load Balancer. The Load Balancer will be not accessible from the internet via its public IPs.\n\n#### Call specific error codes\n\n| Code | Description |\n|-------------------------------------------|--------------------------------------------------------------------------------|\n| `load_balancer_not_attached_to_network` | The Load Balancer is not attached to a network |\n| `targets_without_use_private_ip` | The Load Balancer has targets that use the public IP instead of the private IP |\n", + "operationId": "disable_public_interface_of_load_balancer", "parameters": [ { - "description": "ID of the Image.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Image.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -10679,75 +14343,61 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/replace_image_request" - } - } - } - }, "responses": { - "200": { + "201": { "content": { "application/json": { "example": { - "image": { - "architecture": "x86", - "bound_to": null, - "created": "2016-01-30T23:50:00+00:00", - "created_from": { - "id": 1, - "name": "Server" - }, - "deleted": null, - "deprecated": "2018-02-28T00:00:00+00:00", - "description": "My new Image description", - "disk_size": 10, - "id": 4711, - "image_size": 2.3, - "labels": { - "key": "value" - }, - "name": null, - "os_flavor": "ubuntu", - "os_version": "20.04", - "protection": { - "delete": false + "action": { + "command": "disable_public_interface", + "error": { + "code": "action_failed", + "message": "Action failed" }, - "rapid_deploy": false, - "status": "available", - "type": "snapshot" + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + }, + { + "id": 4711, + "type": "network" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/replace_image_response" + "$ref": "#/components/schemas/disable_public_interface_of_load_balancer_response" } } }, - "description": "The image key in the reply contains the modified Image object." + "description": "The `action` key contains the `disable_public_interface` Action." } }, - "summary": "Update an Image", + "summary": "Disable the public interface of a Load Balancer", "tags": [ - "images" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\timage, _, err := client.Image.Update(ctx, &hcloud.Image{ID: 123}, hcloud.ImageUpdateOpts{\n\t\tDescription: hcloud.Ptr(\"My new Image description\"),\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tType: hcloud.ImageTypeSnapshot,\n\t})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.DisablePublicInterface(ctx, &hcloud.LoadBalancer{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.images import Image\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nimage = client.images.update(\n image=Image(id=123),\n description=\"My new Image description\",\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n type=\"snapshot\",\n)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.disable_public_interface(\n load_balancer=LoadBalancer(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud image update $IMAGE --description \"My new Image description\"\nhcloud image add-label --overwrite $IMAGE \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud image remove-label $IMAGE \\\n \"environment\" \"example.com\" \"just-a-key\"" + "source": "hcloud load-balancer disable-public-interface $LOADBALANCER" } ] }, @@ -10757,143 +14407,81 @@ } ] }, - "/images/{id}/actions": { - "get": { - "description": "Returns all Action objects for an Image. You can sort the results by using the `sort` URI parameter, and filter them with the `status` parameter.", - "operationId": "list_actions_for_image", + "/load_balancers/{id}/actions/enable_public_interface": { + "post": { + "description": "Enable the public interface of a Load Balancer. The Load Balancer will be accessible from the internet via its public IPs.", + "operationId": "enable_public_interface_of_load_balancer", "parameters": [ { - "description": "ID of the Image.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, - "schema": { - "description": "ID of the Image.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - } - }, - { - "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "command", - "command:asc", - "command:desc", - "status", - "status:asc", - "status:desc", - "started", - "started:asc", - "started:desc", - "finished", - "finished:asc", - "finished:desc" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", - "in": "query", - "name": "status", - "required": false, - "schema": { - "items": { - "description": "Status of the Action.", - "enum": [ - "running", - "success", - "error" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, - "schema": { - "default": 25, - "example": 25, + "schema": { + "description": "ID of the Load Balancer.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], "responses": { - "200": { + "201": { "content": { "application/json": { "example": { - "actions": [ - { - "command": "change_protection", - "error": { - "code": "action_failed", - "message": "Action failed" + "action": { + "command": "enable_public_interface", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 4711, - "type": "image" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - ], - "meta": { - "pagination": { - "last_page": 1, - "next_page": null, - "page": 1, - "per_page": 25, - "previous_page": null, - "total_entries": 21 - } + { + "id": 4711, + "type": "network" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/list_actions_response" + "$ref": "#/components/schemas/enable_public_interface_of_load_balancer_response" } } }, - "description": "The `actions` key contains a list of Actions." + "description": "The `action` key contains the `enable_public_interface` Action." } }, - "summary": "List Actions for an Image", + "summary": "Enable the public interface of a Load Balancer", "tags": [ - "images" + "load_balancers" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.EnablePublicInterface(ctx, &hcloud.LoadBalancer{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.enable_public_interface(\n load_balancer=LoadBalancer(id=123),\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud load-balancer enable-public-interface $LOADBALANCER" + } ] }, "servers": [ @@ -10902,31 +14490,106 @@ } ] }, - "/images/{id}/actions/{action_id}": { - "get": { - "description": "Returns a specific Action for an Image.", - "operationId": "get_action_for_image", + "/load_balancers/{id}/actions/remove_target": { + "post": { + "description": "Removes a target from a Load Balancer.", + "operationId": "remove_target", "parameters": [ { - "description": "ID of the Image.", + "description": "ID of the Load Balancer.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Image.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/remove_target_request" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "example": { + "action": { + "command": "remove_target", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 4711, + "type": "load_balancer" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, + "schema": { + "$ref": "#/components/schemas/remove_target_response" + } + } + }, + "description": "The `action` key contains the `remove_target` Action." + } + }, + "summary": "Remove Target", + "tags": [ + "load_balancers" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction1, _, err := client.LoadBalancer.RemoveIPTarget(ctx, &hcloud.LoadBalancer{ID: 123}, net.ParseIP(\"203.0.113.1\"))\n\n\taction2, _, err := client.LoadBalancer.RemoveLabelSelectorTarget(ctx, &hcloud.LoadBalancer{ID: 123}, \"env=prod\")\n\n\taction3, _, err := client.LoadBalancer.RemoveServerTarget(ctx, &hcloud.LoadBalancer{ID: 123}, &hcloud.Server{ID: 80})\n\n\terr = client.Action.WaitFor(ctx, action1, action2, action3)\n}" }, { - "description": "ID of the Action.", + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import (\n LoadBalancer,\n LoadBalancerTarget,\n LoadBalancerTargetIP,\n LoadBalancerTargetLabelSelector,\n)\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.remove_target(\n load_balancer=LoadBalancer(id=123),\n target=LoadBalancerTarget(\n ip=LoadBalancerTargetIP(\n ip=\"203.0.113.1\",\n ),\n label_selector=LoadBalancerTargetLabelSelector(\n selector=\"env=prod\",\n ),\n server=Server(\n id=80,\n ),\n type=\"server\",\n ),\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud load-balancer remove-target $LOADBALANCER --ip 203.0.113.1\nhcloud load-balancer remove-target $LOADBALANCER --label-selector \"env=prod\"\nhcloud load-balancer remove-target $LOADBALANCER --server 80 --use-private-ip" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/load_balancers/{id}/actions/update_service": { + "post": { + "description": "Updates a Load Balancer Service.\n\n#### Call specific error codes\n\n| Code | Description |\n|----------------------------|---------------------------------------------------------|\n| `source_port_already_used` | The source port you are trying to add is already in use |\n", + "operationId": "update_service", + "parameters": [ + { + "description": "ID of the Load Balancer.", "in": "path", - "name": "action_id", + "name": "id", "required": true, "schema": { - "description": "ID of the Action.", + "description": "ID of the Load Balancer.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -10934,13 +14597,22 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/update_service_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { "example": { "action": { - "command": "change_protection", + "command": "update_service", "error": { "code": "action_failed", "message": "Action failed" @@ -10951,7 +14623,7 @@ "resources": [ { "id": 4711, - "type": "image" + "type": "load_balancer" } ], "started": "2016-01-30T23:55:00+00:00", @@ -10959,16 +14631,33 @@ } }, "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/update_service_response" } } }, - "description": "The `action` key contains the Image Action." + "description": "The `action` key contains the `update_service` Action." } }, - "summary": "Get an Action for an Image", + "summary": "Update Service", "tags": [ - "images" + "load_balancers" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.UpdateService(ctx, &hcloud.LoadBalancer{ID: 123}, 443, hcloud.LoadBalancerUpdateServiceOpts{\n\t\tDestinationPort: hcloud.Ptr(80),\n\t\tHealthCheck: &hcloud.LoadBalancerUpdateServiceOptsHealthCheck{\n\t\t\tHTTP: &hcloud.LoadBalancerUpdateServiceOptsHealthCheckHTTP{\n\t\t\t\tDomain: hcloud.Ptr(\"example.com\"),\n\t\t\t\tPath: hcloud.Ptr(\"/\"),\n\t\t\t\tResponse: hcloud.Ptr(`{\"status\": \"ok\"}`),\n\t\t\t\tStatusCodes: []string{\"2??\", \"3??\"},\n\t\t\t\tTLS: hcloud.Ptr(false),\n\t\t\t},\n\t\t\tInterval: hcloud.Ptr(15 * time.Second),\n\t\t\tPort: hcloud.Ptr(4711),\n\t\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTP,\n\t\t\tRetries: hcloud.Ptr(3),\n\t\t\tTimeout: hcloud.Ptr(10 * time.Second),\n\t\t},\n\t\tHTTP: &hcloud.LoadBalancerUpdateServiceOptsHTTP{\n\t\t\tCertificates: []*hcloud.Certificate{{ID: 897}},\n\t\t\tCookieLifetime: hcloud.Ptr(300 * time.Second),\n\t\t\tCookieName: hcloud.Ptr(\"HCLBSTICKY\"),\n\t\t\tRedirectHTTP: hcloud.Ptr(true),\n\t\t\tStickySessions: hcloud.Ptr(true),\n\t\t},\n\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTPS,\n\t\tProxyprotocol: hcloud.Ptr(false),\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\nfrom hcloud.load_balancers import (\n LoadBalancer,\n LoadBalancerService,\n LoadBalancerHealthCheck,\n LoadBalancerHealtCheckHttp,\n LoadBalancerServiceHttp,\n)\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.update_service(\n load_balancer=LoadBalancer(id=123),\n service=LoadBalancerService(\n destination_port=80,\n health_check=LoadBalancerHealthCheck(\n http=LoadBalancerHealtCheckHttp(\n domain=\"example.com\",\n path=\"/\",\n response='{\"status\": \"ok\"}',\n status_codes=[\"2??\", \"3??\"],\n tls=False,\n ),\n interval=15,\n port=4711,\n protocol=\"http\",\n retries=3,\n timeout=10,\n ),\n http=LoadBalancerServiceHttp(\n certificates=[Certificate(id=897)],\n cookie_lifetime=300,\n cookie_name=\"HCLBSTICKY\",\n redirect_http=True,\n sticky_sessions=True,\n ),\n listen_port=443,\n protocol=\"https\",\n proxyprotocol=False,\n ),\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud load-balancer update-service $LOADBALANCER \\\n --listen-port 443 \\\n --destination-port 80 \\\n --health-check-http-domain example.com \\\n --health-check-http-path \"/\" \\\n --health-check-http-response '{\"status\": \"ok\"}' \\\n --health-check-http-status-codes \"2??,3??\" \\\n --health-check-http-tls=false \\\n --health-check-interval 15s \\\n --health-check-port 4711 \\\n --health-check-protocol http \\\n --health-check-retries 3 \\\n --health-check-timeout 10s \\\n --http-certificates 897 \\\n --http-cookie-lifetime 300s \\\n --http-cookie-name HCLBSTICKY \\\n --http-redirect-http=true \\\n --http-sticky-sessions=true \\\n --protocol https \\\n --proxy-protocol=false" + } ] }, "servers": [ @@ -10977,85 +14666,98 @@ } ] }, - "/images/{id}/actions/change_protection": { - "post": { - "description": "Changes the protection configuration of the Image. Can only be used on snapshots.", - "operationId": "change_image_protection", + "/load_balancers/{id}/metrics": { + "get": { + "description": "You must specify the type of metric to get: `open_connections`, `connections_per_second`, `requests_per_second` or `bandwidth`. You can also specify more than one type by comma separation, e.g. `requests_per_second,bandwidth`.\n\nDepending on the type you will get different time series data:\n\n|Type | Timeseries | Unit | Description |\n|---- |------------|------|-------------|\n| open_connections | open_connections | number | Open connections |\n| connections_per_second | connections_per_second | connections/s | Connections per second |\n| requests_per_second | requests_per_second | requests/s | Requests per second |\n| bandwidth | bandwidth.in | bytes/s | Ingress bandwidth |\n|| bandwidth.out | bytes/s | Egress bandwidth |\n\nMetrics are available for the last 30 days only.\n\nIf you do not provide the step argument we will automatically adjust it so that 200 samples are returned.\n\nWe limit the number of samples to a maximum of 500 and will adjust the step parameter accordingly.\n", + "operationId": "get_metrics_for_loadbalancer", "parameters": [ { - "description": "ID of the Image.", - "in": "path", - "name": "id", + "description": "ID of the Load Balancer.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Load Balancer.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + { + "description": "Type of metrics to get.", + "in": "query", + "name": "type", + "required": true, + "schema": { + "enum": [ + "open_connections", + "connections_per_second", + "requests_per_second", + "bandwidth" + ], + "type": "string" + } + }, + { + "description": "Start of period to get Metrics for (in ISO-8601 format).", + "in": "query", + "name": "start", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "End of period to get Metrics for (in ISO-8601 format).", + "in": "query", + "name": "end", "required": true, "schema": { - "description": "ID of the Image.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" + "type": "string" } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/change_image_protection_request" - } + }, + { + "description": "Resolution of results in seconds.", + "in": "query", + "name": "step", + "required": false, + "schema": { + "type": "string" } } - }, + ], "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "change_protection", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 4711, - "type": "image" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - }, "schema": { - "$ref": "#/components/schemas/change_image_protection_response" + "$ref": "#/components/schemas/get_metrics_for_loadbalancer_response" } } }, - "description": "The `action` key contains the `change_protection` Action." + "description": "The `metrics` key in the reply contains a metrics object with this structure." } }, - "summary": "Change Image Protection", + "summary": "Get Metrics for a LoadBalancer", "tags": [ - "images" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Image.ChangeProtection(ctx, &hcloud.Image{ID: 123},\n\t\thcloud.ImageChangeProtectionOpts{Delete: hcloud.Ptr(true)})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tmetrics, _, err := client.LoadBalancer.GetMetrics(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerGetMetricsOpts{\n\t\tStart: time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC),\n\t\tEnd: time.Date(2017, 1, 1, 23, 0, 0, 0, time.UTC),\n\t\tStep: 60,\n\t\tTypes: []hcloud.LoadBalancerMetricType{\n\t\t\thcloud.LoadBalancerMetricBandwidth,\n\t\t\thcloud.LoadBalancerMetricOpenConnections,\n\t\t\thcloud.LoadBalancerMetricConnectionsPerSecond,\n\t\t\thcloud.LoadBalancerMetricRequestsPerSecond,\n\t\t},\n\t})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.images import Image\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.images.change_protection(image=Image(id=123), delete=True)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\nimport datetime\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.load_balancers.get_metrics(\n\tload_balancer=LoadBalancer(id=123),\n\tstart=datetime.datetime(2017, 1, 1, 0, 0, 0, 0, datetime.UTC),\n\tend=datetime.datetime(2017, 1, 1, 23, 0, 0, 0, datetime.UTC),\n\tstep=60,\n\ttype=[\n\t\t\"bandwidth\",\n\t\t\"open_connections\",\n\t\t\"connections_per_second\",\n\t\t\"requests_per_second\",\n\t]\n)\n\nresponse.action.wait_until_finished()\n\nmetrics = response.metrics" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud image enable-protection $IMAGE delete\nhcloud image disable-protection $IMAGE delete" + "source": "hcloud load-balancer metrics $LOADBALANCER \\\n --type open_connections,connections_per_second,requests_per_second,bandwidth \\\n --start 2017-01-01T00:00:00Z \\\n --end 2017-01-01T23:00:00Z" } ] }, @@ -11065,10 +14767,10 @@ } ] }, - "/images/actions": { + "/load_balancers/actions": { "get": { "description": "Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.", - "operationId": "list_image_actions", + "operationId": "list_load_balancer_actions", "parameters": [ { "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", @@ -11172,18 +14874,18 @@ }, "summary": "List Actions", "tags": [ - "images" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Image.Action.All(ctx, hcloud.ActionListOpts{})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.LoadBalancer.Action.All(ctx, hcloud.ActionListOpts{})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.images.actions.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.load_balancers.actions.get_all()" } ] }, @@ -11193,10 +14895,10 @@ } ] }, - "/images/actions/{id}": { + "/load_balancers/actions/{id}": { "get": { "description": "Returns a specific Action object.", - "operationId": "get_image_action", + "operationId": "get_load_balancer_action", "parameters": [ { "description": "ID of the Action", @@ -11226,18 +14928,18 @@ }, "summary": "Get an Action", "tags": [ - "images" + "load_balancers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Image.Action.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.Action.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.images.actions.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.actions.get_by_id(123)" } ] }, @@ -11247,10 +14949,10 @@ } ] }, - "/isos": { + "/locations": { "get": { - "description": "Returns all available ISO objects.", - "operationId": "list_isos", + "description": "Returns all [Locations](#locations).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_locations", "parameters": [ { "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", @@ -11262,165 +14964,23 @@ } }, { - "description": "Filter resources by cpu architecture. The response will only contain the resources\nwith the specified cpu architecture.\n", - "in": "query", - "name": "architecture", - "required": false, - "schema": { - "description": "CPU architecture of the Resource.", - "enum": [ - "x86", - "arm" - ], - "example": "x86", - "type": "string" - } - }, - { - "description": "Include Images with wildcard architecture (architecture is null). Works only if architecture filter is specified.", - "in": "query", - "name": "include_architecture_wildcard", - "required": false, - "schema": { - "type": "boolean" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, - "schema": { - "default": 25, - "example": 25, - "format": "int64", - "type": "integer" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/list_isos_response" - } - } - }, - "description": "The `isos` key in the reply contains an array of iso objects with this structure." - } - }, - "summary": "List ISOs", - "tags": [ - "isos" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tisos, err := client.ISO.All(ctx)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nisos = client.isos.get_all()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud iso list" - } - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/isos/{id}": { - "get": { - "description": "Returns a specific ISO object.", - "operationId": "get_iso", - "parameters": [ - { - "description": "ID of the ISO.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the ISO.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/get_iso_response" - } - } - }, - "description": "The `iso` key in the reply contains an array of ISO objects with this structure." - } - }, - "summary": "Get an ISO", - "tags": [ - "isos" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tiso, _, err := client.ISO.GetByID(ctx, 123)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\niso = client.isos.get_by_id(123)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud iso describe $ISO" - } - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/load_balancer_types": { - "get": { - "description": "Gets all Load Balancer type objects.", - "operationId": "list_load_balancer_types", - "parameters": [ - { - "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", "in": "query", - "name": "name", + "name": "sort", "required": false, "schema": { - "type": "string" + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "name", + "name:asc", + "name:desc" + ], + "type": "string" + }, + "type": "array" } }, { @@ -11453,32 +15013,32 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/list_load_balancer_types_response" + "$ref": "#/components/schemas/list_locations_response" } } }, - "description": "The `load_balancer_types` key in the reply contains an array of Load Balancer type objects with this structure." + "description": "Response with the [Locations](#locations)." } }, - "summary": "List Load Balancer Types", + "summary": "List Locations", "tags": [ - "load_balancer_types" + "locations" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tloadBalancerTypes, err := client.LoadBalancerType.All(ctx)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tlocations, err := client.Location.All(ctx)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nload_balancer_types = client.load_balancer_types.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nlocations = client.locations.get_all()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer-type list" + "source": "hcloud location list" } ] }, @@ -11488,18 +15048,18 @@ } ] }, - "/load_balancer_types/{id}": { + "/locations/{id}": { "get": { - "description": "Gets a specific Load Balancer type object.", - "operationId": "get_load_balancer_type", + "description": "Returns a [Location](#locations).", + "operationId": "get_location", "parameters": [ { - "description": "ID of the Load Balancer Type.", + "description": "ID of the Location.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer Type.", + "description": "ID of the Location.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -11512,32 +15072,32 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/get_load_balancer_type_response" + "$ref": "#/components/schemas/get_location_response" } } }, - "description": "The `load_balancer_type` key in the reply contains a Load Balancer type object with this structure." + "description": "Response with the [Location](#locations)." } }, - "summary": "Get a Load Balancer Type", + "summary": "Get a Location", "tags": [ - "load_balancer_types" + "locations" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tloadBalancerType, _, err := client.LoadBalancerType.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tlocation, _, err := client.Location.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nload_balancer_type = client.load_balancer_types.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nlocation = client.locations.get_by_id(123)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer-type describe $LOADBALANCERTYPE" + "source": "hcloud location describe $LOCATION" } ] }, @@ -11547,10 +15107,10 @@ } ] }, - "/load_balancers": { + "/networks": { "get": { - "description": "Gets all existing Load Balancers that you have available.", - "operationId": "list_load_balancers", + "description": "List multiple [Networks](#networks).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_networks", "parameters": [ { "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", @@ -11616,238 +15176,85 @@ "format": "int64", "type": "integer" } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/list_load_balancers_response" - } - } - }, - "description": "The `load_balancers` key contains a list of Load Balancers." - } - }, - "summary": "List Load Balancers", - "tags": [ - "load_balancers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tloadBalancers, err := client.LoadBalancer.All(ctx)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nload_balancers = client.load_balancers.get_all()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud load-balancer list" - } - ] - }, - "post": { - "description": "Creates a Load Balancer.\n\n#### Call specific error codes\n\n| Code | Description |\n|-----------------------------------------|-------------------------------------------------------------------------------------------------------|\n| `cloud_resource_ip_not_allowed` | The IP you are trying to add as a target belongs to a Hetzner Cloud resource |\n| `ip_not_owned` | The IP is not owned by the owner of the project of the Load Balancer |\n| `load_balancer_not_attached_to_network` | The Load Balancer is not attached to a network |\n| `robot_unavailable` | Robot was not available. The caller may retry the operation after a short delay. |\n| `server_not_attached_to_network` | The server you are trying to add as a target is not attached to the same network as the Load Balancer |\n| `source_port_already_used` | The source port you are trying to add is already in use |\n| `missing_ipv4` | The server that you are trying to add as a public target does not have a public IPv4 address |\n| `target_already_defined` | The Load Balancer target you are trying to define is already defined |\n", - "operationId": "create_load_balancer", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/create_load_balancer_request" - } - } - } - }, - "responses": { - "201": { - "content": { - "application/json": { - "example": { - "action": { - "command": "create_load_balancer", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 4711, - "type": "load_balancer" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - }, - "load_balancer": { - "algorithm": { - "type": "round_robin" - }, - "created": "2016-01-30T23:50:00+00:00", - "id": 4711, - "included_traffic": 654321, - "ingoing_traffic": 123456, - "labels": { - "key": "value" - }, - "load_balancer_type": { - "deprecated": "2016-01-30T23:50:00+00:00", - "description": "LB11", - "id": 1, - "max_assigned_certificates": 10, - "max_connections": 20000, - "max_services": 5, - "max_targets": 25, - "name": "lb11", - "prices": [ - { - "included_traffic": 654321, - "location": "fsn1", - "price_hourly": { - "gross": "1.1900000000000000", - "net": "1.0000000000" - }, - "price_monthly": { - "gross": "1.1900000000000000", - "net": "1.0000000000" - }, - "price_per_tb_traffic": { - "gross": "1.1900000000000000", - "net": "1.0000000000" - } - } - ] - }, - "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": "Web Frontend", - "outgoing_traffic": 123456, - "private_net": [ - { - "ip": "10.0.0.2", - "network": 4711 - } - ], - "protection": { - "delete": false - }, - "public_net": { - "enabled": false, - "ipv4": { - "ip": "1.2.3.4" - }, - "ipv6": { - "ip": "2001:db8::1" - } - }, - "services": [ - { - "destination_port": 80, - "health_check": { - "http": { - "domain": "example.com", - "path": "/", - "response": "{\"status\": \"ok\"}", - "status_codes": [ - "2??,3??" - ], - "tls": false - }, - "interval": 15, - "port": 4711, - "protocol": "http", - "retries": 3, - "timeout": 10 - }, - "http": { - "certificates": [ - 897 - ], - "cookie_lifetime": 300, - "cookie_name": "HCLBSTICKY", - "redirect_http": true, - "sticky_sessions": true - }, - "listen_port": 443, - "protocol": "http", - "proxyprotocol": false - } - ], - "targets": [ - { - "health_status": [ - { - "listen_port": 443, - "status": "healthy" - } - ], - "server": { - "id": 80 - }, - "targets": [ - { - "health_status": [ - { - "listen_port": 443, - "status": "healthy" - } - ], - "server": { - "id": 80 - }, - "type": "server", - "use_private_ip": true - } - ], - "type": "server", - "use_private_ip": true - } - ] - } - }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { "schema": { - "$ref": "#/components/schemas/create_load_balancer_response" + "$ref": "#/components/schemas/list_networks_response" } } }, - "description": "The `load_balancer` key contains the Load Balancer that was just created." + "description": "Response for listing [Networks](#networks)." } }, - "summary": "Create a Load Balancer", + "summary": "List Networks", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.LoadBalancer.Create(ctx, hcloud.LoadBalancerCreateOpts{\n\t\tAlgorithm: &hcloud.LoadBalancerAlgorithm{\n\t\t\tType: hcloud.LoadBalancerAlgorithmTypeRoundRobin,\n\t\t},\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tLoadBalancerType: &hcloud.LoadBalancerType{Name: \"lb11\"},\n\t\tLocation: &hcloud.Location{Name: \"fsn1\"},\n\t\tName: \"Web Frontend\",\n\t\tNetwork: &hcloud.Network{ID: 123},\n\t\tNetworkZone: hcloud.NetworkZoneEUCentral,\n\t\tPublicInterface: hcloud.Ptr(true),\n\t\tServices: []hcloud.LoadBalancerCreateOptsService{\n\t\t\t{\n\t\t\t\tDestinationPort: hcloud.Ptr(80),\n\t\t\t\tHealthCheck: &hcloud.LoadBalancerCreateOptsServiceHealthCheck{\n\t\t\t\t\tHTTP: &hcloud.LoadBalancerCreateOptsServiceHealthCheckHTTP{\n\t\t\t\t\t\tDomain: hcloud.Ptr(\"example.com\"),\n\t\t\t\t\t\tPath: hcloud.Ptr(\"/\"),\n\t\t\t\t\t\tResponse: hcloud.Ptr(`{\"status\": \"ok\"}`),\n\t\t\t\t\t\tStatusCodes: []string{\"2??\", \"3??\"},\n\t\t\t\t\t\tTLS: hcloud.Ptr(false),\n\t\t\t\t\t},\n\t\t\t\t\tInterval: hcloud.Ptr(15 * time.Second),\n\t\t\t\t\tPort: hcloud.Ptr(4711),\n\t\t\t\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTP,\n\t\t\t\t\tRetries: hcloud.Ptr(3),\n\t\t\t\t\tTimeout: hcloud.Ptr(10 * time.Second),\n\t\t\t\t},\n\t\t\t\tHTTP: &hcloud.LoadBalancerCreateOptsServiceHTTP{\n\t\t\t\t\tCertificates: []*hcloud.Certificate{{ID: 897}},\n\t\t\t\t\tCookieLifetime: hcloud.Ptr(300 * time.Second),\n\t\t\t\t\tCookieName: hcloud.Ptr(\"HCLBSTICKY\"),\n\t\t\t\t\tRedirectHTTP: hcloud.Ptr(true),\n\t\t\t\t\tStickySessions: hcloud.Ptr(true),\n\t\t\t\t},\n\t\t\t\tListenPort: hcloud.Ptr(443),\n\t\t\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTPS,\n\t\t\t\tProxyprotocol: hcloud.Ptr(false),\n\t\t\t},\n\t\t},\n\t\tTargets: []hcloud.LoadBalancerCreateOptsTarget{\n\t\t\t{\n\t\t\t\tIP: hcloud.LoadBalancerCreateOptsTargetIP{\n\t\t\t\t\tIP: \"203.0.113.1\",\n\t\t\t\t},\n\t\t\t\tLabelSelector: hcloud.LoadBalancerCreateOptsTargetLabelSelector{\n\t\t\t\t\tSelector: \"env=prod\",\n\t\t\t\t},\n\t\t\t\tServer: hcloud.LoadBalancerCreateOptsTargetServer{\n\t\t\t\t\tServer: &hcloud.Server{ID: 80},\n\t\t\t\t},\n\t\t\t\tType: hcloud.LoadBalancerTargetTypeServer,\n\t\t\t\tUsePrivateIP: hcloud.Ptr(false),\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tloadBalancer := result.LoadBalancer\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tnetworks, err := client.Network.All(ctx)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\nfrom hcloud.load_balancer_types import LoadBalancerType\nfrom hcloud.load_balancers import (\n LoadBalancerAlgorithm,\n LoadBalancerService,\n LoadBalancerHealthCheck,\n LoadBalancerHealtCheckHttp,\n LoadBalancerServiceHttp,\n LoadBalancerTarget,\n LoadBalancerTargetIP,\n LoadBalancerTargetLabelSelector,\n)\nfrom hcloud.locations import Location\nfrom hcloud.networks import Network\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.load_balancers.create(\n algorithm=LoadBalancerAlgorithm(type=\"round_robin\"),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n load_balancer_type=LoadBalancerType(name=\"lb11\"),\n location=Location(name=\"fsn1\"),\n name=\"Web Frontend\",\n network=Network(id=123),\n network_zone=\"eu-central\",\n public_interface=True,\n services=[\n LoadBalancerService(\n destination_port=80,\n health_check=LoadBalancerHealthCheck(\n http=LoadBalancerHealtCheckHttp(\n domain=\"example.com\",\n path=\"/\",\n response='{\"status\": \"ok\"}',\n status_codes=[\"2??\", \"3??\"],\n tls=False,\n ),\n interval=15,\n port=4711,\n protocol=\"http\",\n retries=3,\n timeout=10,\n ),\n http=LoadBalancerServiceHttp(\n certificates=[Certificate(id=897)],\n cookie_lifetime=300,\n cookie_name=\"HCLBSTICKY\",\n redirect_http=True,\n sticky_sessions=True,\n ),\n listen_port=443,\n protocol=\"https\",\n proxyprotocol=False,\n )\n ],\n targets=[\n LoadBalancerTarget(\n ip=LoadBalancerTargetIP(\n ip=\"203.0.113.1\",\n ),\n label_selector=LoadBalancerTargetLabelSelector(\n selector=\"env=prod\",\n ),\n server=Server(\n id=80,\n ),\n type=\"server\",\n use_private_ip=True,\n )\n ],\n)\n\nresponse.action.wait_until_finished()\n\nload_balancer = response.load_balancer" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nnetworks = client.networks.get_all()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer create \\\n --algorithm-type round_robin \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --type lb11 \\\n --location fsn1 \\\n --name \"Web Frontend\"\n\nhcloud load-balancer enable-public-interface \"Web Frontend\"\n\nhcloud load-balancer add-service \"Web Frontend\" \\\n --destination-port 80 \\\n --health-check-http-domain example.com \\\n --health-check-http-path \"/\" \\\n --health-check-http-response '{\"status\": \"ok\"}' \\\n --health-check-http-status-codes \"2??,3??\" \\\n --health-check-http-tls=false \\\n --health-check-interval 15s \\\n --health-check-port 4711 \\\n --health-check-protocol http \\\n --health-check-retries 3 \\\n --health-check-timeout 10s \\\n --http-certificates 897 \\\n --http-cookie-lifetime 300s \\\n --http-cookie-name HCLBSTICKY \\\n --http-redirect-http=true \\\n --http-sticky-sessions=true \\\n --listen-port 443 \\\n --protocol https \\\n --proxy-protocol=false\n\nhcloud load-balancer add-target \"Web Frontend\" --ip 203.0.113.1\nhcloud load-balancer add-target \"Web Frontend\" --label-selector \"env=prod\"\nhcloud load-balancer add-target \"Web Frontend\" --server 80 --use-private-ip" + "source": "hcloud network list" + } + ] + }, + "post": { + "description": "Creates a [Network](#networks).\n\nThe provided `ip_range` can only be extended later on, but not reduced.\n\nSubnets can be added now or later on using the [add subnet action](#network-actions-add-a-subnet-to-a-network). If you do not specify an `ip_range` for the subnet the first available /24 range will be used.\n\nRoutes can be added now or later by using the [add route action](#network-actions-add-a-route-to-a-network).\n", + "operationId": "create_network", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/create_network_request" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/create_network_response" + } + } + }, + "description": "Response for creating a [Network](#networks).\n\nContains the newly created [Network](#networks).\n" + } + }, + "summary": "Create a Network", + "tags": [ + "networks" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tnetwork, _, err := client.Network.Create(ctx, hcloud.NetworkCreateOpts{\n\t\tExposeRoutesToVSwitch: false,\n\t\tIPRange: &net.IPNet{\n\t\t\tIP: net.ParseIP(\"10.0.0.0\"),\n\t\t\tMask: net.CIDRMask(16, 32),\n\t\t},\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"mynet\",\n\t\tRoutes: []hcloud.NetworkRoute{\n\t\t\t{\n\t\t\t\tDestination: &net.IPNet{\n\t\t\t\t\tIP: net.ParseIP(\"10.100.1.0\"),\n\t\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t\t},\n\t\t\t\tGateway: net.ParseIP(\"10.0.1.1\"),\n\t\t\t},\n\t\t},\n\t\tSubnets: []hcloud.NetworkSubnet{\n\t\t\t{\n\t\t\t\tIPRange: &net.IPNet{\n\t\t\t\t\tIP: net.ParseIP(\"10.0.1.0\"),\n\t\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t\t},\n\t\t\t\tNetworkZone: hcloud.NetworkZoneEUCentral,\n\t\t\t\tType: hcloud.NetworkSubnetTypeCloud,\n\t\t\t\tVSwitchID: 1000,\n\t\t\t},\n\t\t},\n\t})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import NetworkRoute, NetworkSubnet\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nnetwork = client.networks.create(\n expose_routes_to_vswitch=False,\n ip_range=\"10.0.0.0/16\",\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"mynet\",\n routes=[\n NetworkRoute(\n destination=\"10.100.1.0/24\",\n gateway=\"10.0.1.1\",\n )\n ],\n subnets=[\n NetworkSubnet(\n ip_range=\"10.0.1.0/24\",\n network_zone=\"eu-central\",\n type=\"cloud\",\n vswitch_id=1000,\n )\n ],\n)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud network create \\\n --expose-routes-to-vswitch=false \\\n --ip-range 10.0.0.0/16 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name mynet\n\nhcloud network add-route mynet \\\n --destination 10.100.1.0/24 \\\n --gateway 10.0.1.1\n\nhcloud network add-subnet mynet \\\n --ip-range 10.0.1.0/24 \\\n --network-zone eu-central \\\n --type cloud \\\n --vswitch-id 1000" } ] }, @@ -11857,18 +15264,18 @@ } ] }, - "/load_balancers/{id}": { + "/networks/{id}": { "delete": { - "description": "Deletes a Load Balancer.", - "operationId": "delete_load_balancer", + "description": "Deletes a [Network](#networks).\n\nAttached resources will be detached automatically.\n", + "operationId": "delete_network", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -11878,42 +15285,42 @@ ], "responses": { "204": { - "description": "Load Balancer deleted." + "description": "Response for deleting a [Network](#networks)." } }, - "summary": "Delete a Load Balancer", + "summary": "Delete a Network", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.LoadBalancer.Delete(ctx, &hcloud.LoadBalancer{ID: 123})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.Network.Delete(ctx, &hcloud.Network{ID: 123})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.load_balancers.delete(load_balancer=LoadBalancer(id=123))" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.networks.delete(\n network=Network(id=123),\n)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer delete $LOADBALANCER" + "source": "hcloud network delete $NETWORK" } ] }, "get": { - "description": "Gets a specific Load Balancer object.", - "operationId": "get_load_balancer", + "description": "Get a specific [Network](#networks).", + "operationId": "get_network", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -11926,46 +15333,46 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/get_load_balancer_response" + "$ref": "#/components/schemas/get_network_response" } } }, - "description": "The `load_balancer` key contains the Load Balancer." + "description": "The `network` key contains the network." } }, - "summary": "Get a Load Balancer", + "summary": "Get a Network", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tloadBalancer, _, err := client.LoadBalancer.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tnetwork, _, err := client.Network.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nload_balancer = client.load_balancers.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nnetwork = client.networks.get_by_id(123)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer describe $LOADBALANCER" + "source": "hcloud network describe $NETWORK" } ] }, "put": { - "description": "Updates a Load Balancer. You can update a Load Balancer’s name and a Load Balancer’s labels.\n\nNote: if the Load Balancer object changes during the request, the response will be a “conflict” error.\n", - "operationId": "replace_load_balancer", + "description": "Update a [Network](#networks).\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", + "operationId": "replace_network", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -11977,7 +15384,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/replace_load_balancer_request" + "$ref": "#/components/schemas/replace_network_request" } } } @@ -11987,173 +15394,67 @@ "content": { "application/json": { "example": { - "load_balancer": { - "algorithm": { - "type": "round_robin" - }, + "network": { "created": "2016-01-30T23:50:00+00:00", + "expose_routes_to_vswitch": true, "id": 4711, - "included_traffic": 654321, - "ingoing_traffic": 123456, + "ip_range": "10.0.0.0/16", "labels": { "key": "value" }, - "load_balancer_type": { - "deprecated": "2016-01-30T23:50:00+00:00", - "description": "LB11", - "id": 1, - "max_assigned_certificates": 10, - "max_connections": 20000, - "max_services": 5, - "max_targets": 25, - "name": "lb11", - "prices": [ - { - "included_traffic": 654321, - "location": "fsn1", - "price_hourly": { - "gross": "1.1900000000000000", - "net": "1.0000000000" - }, - "price_monthly": { - "gross": "1.1900000000000000", - "net": "1.0000000000" - }, - "price_per_tb_traffic": { - "gross": "1.1900000000000000", - "net": "1.0000000000" - } - } - ] - }, - "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": "new-name", - "outgoing_traffic": 123456, - "private_net": [ - { - "ip": "10.0.0.2", - "network": 4711 - } + "load_balancers": [ + 42 ], + "name": "new-name", "protection": { "delete": false }, - "public_net": { - "enabled": false, - "ipv4": { - "ip": "1.2.3.4" - }, - "ipv6": { - "ip": "2001:db8::1" - } - }, - "services": [ + "routes": [ { - "destination_port": 80, - "health_check": { - "http": { - "domain": "example.com", - "path": "/", - "response": "{\"status\": \"ok\"}", - "status_codes": [ - "2??,3??" - ], - "tls": false - }, - "interval": 15, - "port": 4711, - "protocol": "http", - "retries": 3, - "timeout": 10 - }, - "http": { - "certificates": [ - 897 - ], - "cookie_lifetime": 300, - "cookie_name": "HCLBSTICKY", - "redirect_http": true, - "sticky_sessions": true - }, - "listen_port": 443, - "protocol": "http", - "proxyprotocol": false + "destination": "10.100.1.0/24", + "gateway": "10.0.1.1" } ], - "targets": [ + "servers": [ + 42 + ], + "subnets": [ { - "health_status": [ - { - "listen_port": 443, - "status": "healthy" - } - ], - "ip": { - "ip": "203.0.113.1" - }, - "label_selector": { - "selector": "env=prod" - }, - "server": { - "id": 80 - }, - "targets": [ - { - "health_status": [ - { - "listen_port": 443, - "status": "healthy" - } - ], - "server": { - "id": 80 - }, - "type": "server", - "use_private_ip": true - } - ], - "type": "server", - "use_private_ip": true + "gateway": "10.0.0.1", + "ip_range": "10.0.1.0/24", + "network_zone": "eu-central", + "type": "cloud" } ] } }, "schema": { - "$ref": "#/components/schemas/replace_load_balancer_response" + "$ref": "#/components/schemas/replace_network_response" } } }, - "description": "The `load_balancer` key contains the updated Load Balancer." + "description": "Response for updating a [Network](#networks).\n\nContains the updated [Network](#networks).\n" } }, - "summary": "Update a Load Balancer", + "summary": "Update a Network", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tloadBalancer, _, err := client.LoadBalancer.Update(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"new-name\",\n\t})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tnetwork, _, err := client.Network.Update(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkUpdateOpts{\n\t\tExposeRoutesToVSwitch: hcloud.Ptr(false),\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"new-name\",\n\t})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nload_balancer = client.load_balancers.update(\n load_balancer=LoadBalancer(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"new-name\",\n)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nnetwork = client.networks.update(\n network=Network(id=123),\n expose_routes_to_vswitch=False,\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"new-name\",\n)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer update $LOADBALANCER --name new-name\nhcloud load-balancer add-label --overwrite $LOADBALANCER \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud load-balancer remove-label $LOADBALANCER \\\n \"environment\" \"example.com\" \"just-a-key\"" + "source": "hcloud network update $NETWORK --name new-name\nhcloud network expose-routes-to-vswitch --disable $NETWORK\nhcloud network add-label --overwrite $NETWORK \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud network remove-label $NETWORK \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] }, @@ -12163,18 +15464,18 @@ } ] }, - "/load_balancers/{id}/actions": { + "/networks/{id}/actions": { "get": { - "description": "Returns all Action objects for a Load Balancer. You can sort the results by using the `sort` URI parameter, and filter them with the `status` parameter.", - "operationId": "list_actions_for_load_balancer", + "description": "Lists [Actions](#actions) for a [Network](#networks).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_actions_for_network", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -12260,7 +15561,7 @@ "example": { "actions": [ { - "command": "add_service", + "command": "add_subnet", "error": { "code": "action_failed", "message": "Action failed" @@ -12270,8 +15571,8 @@ "progress": 100, "resources": [ { - "id": 4711, - "type": "load_balancer" + "id": 42, + "type": "server" } ], "started": "2016-01-30T23:55:00+00:00", @@ -12294,12 +15595,12 @@ } } }, - "description": "The `actions` key contains a list of Actions." + "description": "Response for listing [Actions](#actions)." } }, - "summary": "List Actions for a Load Balancer", + "summary": "List Actions for a Network", "tags": [ - "load_balancers" + "networks" ] }, "servers": [ @@ -12308,18 +15609,18 @@ } ] }, - "/load_balancers/{id}/actions/{action_id}": { + "/networks/{id}/actions/{action_id}": { "get": { - "description": "Returns a specific Action for a Load Balancer.", - "operationId": "get_action_for_load_balancer", + "description": "Returns a specific [Action](#actions) for a [Network](#networks).", + "operationId": "get_action_for_network", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -12346,7 +15647,7 @@ "application/json": { "example": { "action": { - "command": "change_protection", + "command": "add_subnet", "error": { "code": "action_failed", "message": "Action failed" @@ -12357,7 +15658,7 @@ "resources": [ { "id": 4711, - "type": "load_balancer" + "type": "network" } ], "started": "2016-01-30T23:55:00+00:00", @@ -12369,188 +15670,12 @@ } } }, - "description": "The `action` key contains the Load Balancer Action." - } - }, - "summary": "Get an Action for a Load Balancer", - "tags": [ - "load_balancers" - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/load_balancers/{id}/actions/add_service": { - "post": { - "description": "Adds a service to a Load Balancer.\n\n#### Call specific error codes\n\n| Code | Description |\n|----------------------------|---------------------------------------------------------|\n| `source_port_already_used` | The source port you are trying to add is already in use |\n", - "operationId": "add_service", - "parameters": [ - { - "description": "ID of the Load Balancer.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the Load Balancer.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/add_service_request" - } - } - } - }, - "responses": { - "201": { - "content": { - "application/json": { - "example": { - "action": { - "command": "add_service", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 4711, - "type": "load_balancer" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - }, - "schema": { - "$ref": "#/components/schemas/add_service_response" - } - } - }, - "description": "The `action` key contains the `add_service` Action." - } - }, - "summary": "Add Service", - "tags": [ - "load_balancers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.AddService(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerAddServiceOpts{\n\t\tDestinationPort: hcloud.Ptr(80),\n\t\tHealthCheck: &hcloud.LoadBalancerAddServiceOptsHealthCheck{\n\t\t\tHTTP: &hcloud.LoadBalancerAddServiceOptsHealthCheckHTTP{\n\t\t\t\tDomain: hcloud.Ptr(\"example.com\"),\n\t\t\t\tPath: hcloud.Ptr(\"/\"),\n\t\t\t\tResponse: hcloud.Ptr(`{\"status\": \"ok\"}`),\n\t\t\t\tStatusCodes: []string{\"2??\", \"3??\"},\n\t\t\t\tTLS: hcloud.Ptr(false),\n\t\t\t},\n\t\t\tInterval: hcloud.Ptr(15 * time.Second),\n\t\t\tPort: hcloud.Ptr(4711),\n\t\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTP,\n\t\t\tRetries: hcloud.Ptr(3),\n\t\t\tTimeout: hcloud.Ptr(10 * time.Second),\n\t\t},\n\t\tHTTP: &hcloud.LoadBalancerAddServiceOptsHTTP{\n\t\t\tCertificates: []*hcloud.Certificate{{ID: 897}},\n\t\t\tCookieLifetime: hcloud.Ptr(300 * time.Second),\n\t\t\tCookieName: hcloud.Ptr(\"HCLBSTICKY\"),\n\t\t\tRedirectHTTP: hcloud.Ptr(true),\n\t\t\tStickySessions: hcloud.Ptr(true),\n\t\t},\n\t\tListenPort: hcloud.Ptr(443),\n\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTPS,\n\t\tProxyprotocol: hcloud.Ptr(false),\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\nfrom hcloud.load_balancers import (\n LoadBalancer,\n LoadBalancerService,\n LoadBalancerHealthCheck,\n LoadBalancerHealtCheckHttp,\n LoadBalancerServiceHttp,\n)\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.add_service(\n load_balancer=LoadBalancer(id=123),\n service=LoadBalancerService(\n destination_port=80,\n health_check=LoadBalancerHealthCheck(\n http=LoadBalancerHealtCheckHttp(\n domain=\"example.com\",\n path=\"/\",\n response='{\"status\": \"ok\"}',\n status_codes=[\"2??\", \"3??\"],\n tls=False,\n ),\n interval=15,\n port=4711,\n protocol=\"http\",\n retries=3,\n timeout=10,\n ),\n http=LoadBalancerServiceHttp(\n certificates=[Certificate(id=897)],\n cookie_lifetime=300,\n cookie_name=\"HCLBSTICKY\",\n redirect_http=True,\n sticky_sessions=True,\n ),\n listen_port=443,\n protocol=\"https\",\n proxyprotocol=False,\n ),\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud load-balancer add-service $LOADBALANCER \\\n --destination-port 80 \\\n --health-check-http-domain example.com \\\n --health-check-http-path \"/\" \\\n --health-check-http-response '{\"status\": \"ok\"}' \\\n --health-check-http-status-codes \"2??,3??\" \\\n --health-check-http-tls=false \\\n --health-check-interval 15s \\\n --health-check-port 4711 \\\n --health-check-protocol http \\\n --health-check-retries 3 \\\n --health-check-timeout 10s \\\n --http-certificates 897 \\\n --http-cookie-lifetime 300s \\\n --http-cookie-name HCLBSTICKY \\\n --http-redirect-http=true \\\n --http-sticky-sessions=true \\\n --listen-port 443 \\\n --protocol https \\\n --proxy-protocol=false" - } - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/load_balancers/{id}/actions/add_target": { - "post": { - "description": "Adds a target to a Load Balancer.\n\n#### Call specific error codes\n\n| Code | Description |\n|-------------------------------------------|-------------------------------------------------------------------------------------------------------|\n| `cloud_resource_ip_not_allowed` | The IP you are trying to add as a target belongs to a Hetzner Cloud resource |\n| `ip_not_owned` | The IP you are trying to add as a target is not owned by the Project owner |\n| `load_balancer_public_interface_disabled` | The Load Balancer's public network interface is disabled |\n| `load_balancer_not_attached_to_network` | The Load Balancer is not attached to a network |\n| `robot_unavailable` | Robot was not available. The caller may retry the operation after a short delay. |\n| `server_not_attached_to_network` | The server you are trying to add as a target is not attached to the same network as the Load Balancer |\n| `missing_ipv4` | The server that you are trying to add as a public target does not have a public IPv4 address |\n| `target_already_defined` | The Load Balancer target you are trying to define is already defined |\n", - "operationId": "add_target", - "parameters": [ - { - "description": "ID of the Load Balancer.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the Load Balancer.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/add_target_request" - } - } - } - }, - "responses": { - "201": { - "content": { - "application/json": { - "example": { - "action": { - "command": "add_target", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 4711, - "type": "load_balancer" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - }, - "schema": { - "$ref": "#/components/schemas/add_target_response" - } - } - }, - "description": "The `action` key contains the `add_target` Action." + "description": "Response for getting an [Action](#actions)." } }, - "summary": "Add Target", + "summary": "Get an Action for a Network", "tags": [ - "load_balancers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction1, _, err := client.LoadBalancer.AddIPTarget(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerAddIPTargetOpts{\n\t\tIP: net.ParseIP(\"203.0.113.1\"),\n\t})\n\n\taction2, _, err := client.LoadBalancer.AddLabelSelectorTarget(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerAddLabelSelectorTargetOpts{\n\t\tSelector: \"env=prod\",\n\t})\n\n\taction3, _, err := client.LoadBalancer.AddServerTarget(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerAddServerTargetOpts{\n\t\tServer: &hcloud.Server{ID: 80},\n\t\tUsePrivateIP: hcloud.Ptr(true),\n\t})\n\n\terr = client.Action.WaitFor(ctx, action1, action2, action3)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import (\n LoadBalancer,\n LoadBalancerTarget,\n LoadBalancerTargetIP,\n LoadBalancerTargetLabelSelector,\n)\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.add_target(\n load_balancer=LoadBalancer(id=123),\n target=LoadBalancerTarget(\n ip=LoadBalancerTargetIP(\n ip=\"203.0.113.1\",\n ),\n label_selector=LoadBalancerTargetLabelSelector(\n selector=\"env=prod\",\n ),\n server=Server(\n id=80,\n ),\n type=\"server\",\n use_private_ip=True,\n ),\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud load-balancer add-target $LOADBALANCER --ip 203.0.113.1\nhcloud load-balancer add-target $LOADBALANCER --label-selector \"env=prod\"\nhcloud load-balancer add-target $LOADBALANCER --server 80 --use-private-ip" - } + "networks" ] }, "servers": [ @@ -12559,18 +15684,18 @@ } ] }, - "/load_balancers/{id}/actions/attach_to_network": { + "/networks/{id}/actions/add_route": { "post": { - "description": "Attach a Load Balancer to a Network.\n\n**Call specific error codes**\n\n| Code | Description |\n|----------------------------------|-----------------------------------------------------------------------|\n| `load_balancer_already_attached` | The Load Balancer is already attached to a network |\n| `ip_not_available` | The provided Network IP is not available |\n| `no_subnet_available` | No Subnet or IP is available for the Load Balancer within the network |\n", - "operationId": "attach_load_balancer_to_network", + "description": "Adds a route entry to a [Network](#networks).\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", + "operationId": "add_route_to_network", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -12582,7 +15707,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/attach_load_balancer_to_network_request" + "$ref": "#/components/schemas/add_route_to_network_request" } } } @@ -12593,51 +15718,51 @@ "application/json": { "example": { "action": { - "command": "attach_to_network", + "command": "add_route", "error": { "code": "action_failed", "message": "Action failed" }, - "finished": "2016-01-30T23:56:00+00:00", + "finished": null, "id": 13, - "progress": 100, + "progress": 0, "resources": [ { "id": 4711, - "type": "load_balancer" + "type": "network" } ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/attach_load_balancer_to_network_response" + "$ref": "#/components/schemas/add_route_to_network_response" } } }, - "description": "The `action` key contains the `attach_to_network` Action." + "description": "Response for adding a route to a [Network](#networks).\n\nThe `action` key contains an [Action](#actions) with command `add_route`.\n" } }, - "summary": "Attach a Load Balancer to a Network", + "summary": "Add a route to a Network", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.AttachToNetwork(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerAttachToNetworkOpts{\n\t\tIP: net.ParseIP(\"10.0.1.1\"),\n\t\tNetwork: &hcloud.Network{ID: 4711},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.AddRoute(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkAddRouteOpts{\n\t\tRoute: hcloud.NetworkRoute{\n\t\t\tDestination: &net.IPNet{\n\t\t\t\tIP: net.ParseIP(\"10.100.1.0\"),\n\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t},\n\t\t\tGateway: net.ParseIP(\"10.0.1.1\"),\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.attach_to_network(\n load_balancer=LoadBalancer(id=123),\n ip=\"10.0.1.1\",\n network=Network(id=4711),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network, NetworkRoute\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.add_route(\n network=Network(id=123),\n route=NetworkRoute(\n destination=\"10.100.1.0/24\",\n gateway=\"10.0.1.1\",\n ),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer attach-to-network $LOADBALANCER \\\n --ip 10.0.1.1 \\\n --network 4711" + "source": "hcloud network add-route $NETWORK \\\n --destination 10.100.1.0/24 \\\n --gateway 10.0.1.1" } ] }, @@ -12647,18 +15772,18 @@ } ] }, - "/load_balancers/{id}/actions/change_algorithm": { + "/networks/{id}/actions/add_subnet": { "post": { - "description": "Change the algorithm that determines to which target new requests are sent.", - "operationId": "change_algorithm", + "description": "Adds a new subnet to the [Network](#networks).\n\nIf the subnet `ip_range` is not provided, the first available `/24` IP range will be used.\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", + "operationId": "add_subnet_to_network", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -12670,7 +15795,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/change_algorithm_request" + "$ref": "#/components/schemas/add_subnet_to_network_request" } } } @@ -12681,51 +15806,51 @@ "application/json": { "example": { "action": { - "command": "change_algorithm", + "command": "add_subnet", "error": { "code": "action_failed", "message": "Action failed" }, - "finished": "2016-01-30T23:56:00+00:00", + "finished": null, "id": 13, - "progress": 100, + "progress": 0, "resources": [ { "id": 4711, - "type": "load_balancer" + "type": "network" } ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/change_algorithm_response" + "$ref": "#/components/schemas/add_subnet_to_network_response" } } }, - "description": "The `action` key contains the `change_algorithm` Action." + "description": "Response for adding a subnet to a [Network](#networks).\n\nThe `action` key contains an [Action](#actions) with command `add_subnet`.\n" } }, - "summary": "Change Algorithm", + "summary": "Add a subnet to a Network", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.ChangeAlgorithm(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerChangeAlgorithmOpts{\n\t\tType: hcloud.LoadBalancerAlgorithmTypeRoundRobin,\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.AddSubnet(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkAddSubnetOpts{\n\t\tSubnet: hcloud.NetworkSubnet{\n\t\t\tIPRange: &net.IPNet{\n\t\t\t\tIP: net.ParseIP(\"10.0.1.0\"),\n\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t},\n\t\t\tNetworkZone: hcloud.NetworkZoneEUCentral,\n\t\t\tType: hcloud.NetworkSubnetTypeCloud,\n\t\t\tVSwitchID: 1000,\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer, LoadBalancerAlgorithm\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.change_algorithm(\n load_balancer=LoadBalancer(id=123),\n algorithm=LoadBalancerAlgorithm(type=\"round_robin\"),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network, NetworkSubnet\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.add_subnet(\n network=Network(id=123),\n subnet=NetworkSubnet(\n ip_range=\"10.0.1.0/24\",\n network_zone=\"eu-central\",\n type=\"cloud\",\n vswitch_id=1000,\n ),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer change-algorithm $LOADBALANCER \\\n --algorithm-type round_robin" + "source": "hcloud network add-subnet $NETWORK \\\n --ip-range 10.0.1.0/24 \\\n --network-zone eu-central \\\n --type cloud \\\n --vswitch-id 1000" } ] }, @@ -12735,18 +15860,18 @@ } ] }, - "/load_balancers/{id}/actions/change_dns_ptr": { + "/networks/{id}/actions/change_ip_range": { "post": { - "description": "Changes the hostname that will appear when getting the hostname belonging to the public IPs (IPv4 and IPv6) of this Load Balancer.\n\nFloating IPs assigned to the Server are not affected by this.\n", - "operationId": "change_reverse_dns_entry_for_this_load_balancer", + "description": "Changes the IP range of a [Network](#networks).\n\nThe following restrictions apply to changing the IP range:\n- IP ranges can only be extended and never shrunk.\n- IPs can only be added to the end of the existing range, therefore only the netmask is allowed to be changed.\n\nTo update the routes on the connected [Servers](#servers), they need to be rebooted or the routes to be updated manually.\n\nFor example if the [Network](#networks) has a range of `10.0.0.0/16` to extend it the new range has to start with the IP `10.0.0.0` as well. The netmask `/16` can be changed to a smaller one then `16` therefore increasing the IP range. A valid entry would be `10.0.0.0/15`, `10.0.0.0/14` or `10.0.0.0/13` and so on.\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", + "operationId": "change_ip_range_of_network", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -12758,11 +15883,10 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_load_balancer_request" + "$ref": "#/components/schemas/change_ip_range_of_network_request" } } - }, - "description": "Select the IP address for which to change the DNS entry by passing `ip`. It can be either IPv4 or IPv6. The target hostname is set by passing `dns_ptr`." + } }, "responses": { "201": { @@ -12770,51 +15894,51 @@ "application/json": { "example": { "action": { - "command": "change_dns_ptr", + "command": "change_ip_range", "error": { "code": "action_failed", "message": "Action failed" }, - "finished": null, + "finished": "2016-01-30T23:56:00+00:00", "id": 13, - "progress": 0, + "progress": 100, "resources": [ { - "id": 42, - "type": "load_balancer" + "id": 4711, + "type": "network" } ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" + "started": "2016-01-30T23:55:00+00:00", + "status": "success" } }, "schema": { - "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_load_balancer_response" + "$ref": "#/components/schemas/change_ip_range_of_network_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "Response for changing the [Networks](#networks) IP range.\n\nThe `action` key contains an [Action](#actions) with command `change_ip_range`.\n" } }, - "summary": "Change reverse DNS entry for this Load Balancer", + "summary": "Change IP range of a Network", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.ChangeDNSPtr(ctx, &hcloud.LoadBalancer{ID: 123}, \"1.2.3.4\", hcloud.Ptr(\"lb1.example.com\"))\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.ChangeIPRange(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkChangeIPRangeOpts{\n\t\tIPRange: &net.IPNet{\n\t\t\tIP: net.ParseIP(\"10.0.0.0\"),\n\t\t\tMask: net.CIDRMask(16, 32),\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.change_dns_ptr(\n load_balancer=LoadBalancer(id=123),\n dns_ptr=\"lb1.example.com\",\n ip=\"1.2.3.4\",\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.change_ip_range(\n network=Network(id=123), ip_range=\"10.0.0.0/16\"\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer set-rdns $LOADBALANCER \\\n --ip 1.2.3.4 \\\n --hostname lb1.example.com" + "source": "hcloud network change-ip-range $NETWORK \\\n --ip-range 10.0.0.0/16" } ] }, @@ -12824,18 +15948,18 @@ } ] }, - "/load_balancers/{id}/actions/change_protection": { + "/networks/{id}/actions/change_protection": { "post": { - "description": "Changes the protection configuration of a Load Balancer.", - "operationId": "change_load_balancer_protection", + "description": "Changes the protection settings of a [Network](#networks).\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", + "operationId": "change_network_protection", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -12847,7 +15971,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/change_load_balancer_protection_request" + "$ref": "#/components/schemas/change_network_protection_request" } } } @@ -12869,7 +15993,7 @@ "resources": [ { "id": 4711, - "type": "load_balancer" + "type": "network" } ], "started": "2016-01-30T23:55:00+00:00", @@ -12877,32 +16001,32 @@ } }, "schema": { - "$ref": "#/components/schemas/change_load_balancer_protection_response" + "$ref": "#/components/schemas/change_network_protection_response" } } }, - "description": "The `action` key contains the `change_protection` Action." + "description": "Response for changing the [Networks](#networks) protection.\n\nThe `action` key contains an [Action](#actions) with command `change_protection`.\n" } }, - "summary": "Change Load Balancer Protection", + "summary": "Change Network Protection", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.ChangeProtection(ctx, &hcloud.LoadBalancer{ID: 123},\n\t\thcloud.LoadBalancerChangeProtectionOpts{Delete: hcloud.Ptr(true)})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.ChangeProtection(ctx, &hcloud.Network{ID: 123},\n\t\thcloud.NetworkChangeProtectionOpts{Delete: hcloud.Ptr(true)})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.change_protection(\n load_balancer=LoadBalancer(id=123),\n delete=True,\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.change_protection(\n network=Network(id=123),\n delete=True,\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer enable-protection $LOADBALANCER delete\nhcloud load-balancer disable-protection $LOADBALANCER delete" + "source": "hcloud network enable-protection $NETWORK delete\nhcloud network disable-protection $NETWORK delete" } ] }, @@ -12912,18 +16036,18 @@ } ] }, - "/load_balancers/{id}/actions/change_type": { + "/networks/{id}/actions/delete_route": { "post": { - "description": "Changes the type (Max Services, Max Targets and Max Connections) of a Load Balancer.\n\n**Call specific error codes**\n\n| Code | Description |\n|------------------------------|-----------------------------------------------------------------|\n| `invalid_load_balancer_type` | The Load Balancer type does not fit for the given Load Balancer |\n", - "operationId": "change_type_of_load_balancer", + "description": "Delete a route entry from a [Network](#networks).\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", + "operationId": "delete_route_from_network", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -12935,7 +16059,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/change_type_of_load_balancer_request" + "$ref": "#/components/schemas/delete_route_from_network_request" } } } @@ -12946,7 +16070,7 @@ "application/json": { "example": { "action": { - "command": "change_load_balancer_type", + "command": "delete_route", "error": { "code": "action_failed", "message": "Action failed" @@ -12956,8 +16080,8 @@ "progress": 0, "resources": [ { - "id": 42, - "type": "server" + "id": 4711, + "type": "network" } ], "started": "2016-01-30T23:50:00+00:00", @@ -12965,32 +16089,32 @@ } }, "schema": { - "$ref": "#/components/schemas/change_type_of_load_balancer_response" + "$ref": "#/components/schemas/delete_route_from_network_response" } } }, - "description": "The `action` key contains the `change_load_balancer_type` Action." + "description": "Response for deleting a route from a [Network](#networks).\n\nThe `action` key contains an [Action](#actions) with command `delete_route`.\n" } }, - "summary": "Change the Type of a Load Balancer", + "summary": "Delete a route from a Network", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.ChangeType(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerChangeTypeOpts{\n\t\tLoadBalancerType: &hcloud.LoadBalancerType{Name: \"lb21\"},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.DeleteRoute(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkDeleteRouteOpts{\n\t\tRoute: hcloud.NetworkRoute{\n\t\t\tDestination: &net.IPNet{\n\t\t\t\tIP: net.ParseIP(\"10.100.1.0\"),\n\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t},\n\t\t\tGateway: net.ParseIP(\"10.0.1.1\"),\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancer_types import LoadBalancerType\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.change_type(\n load_balancer=LoadBalancer(id=123),\n load_balancer_type=LoadBalancerType(name=\"lb21\"),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network, NetworkRoute\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.delete_route(\n network=Network(id=123),\n route=NetworkRoute(\n destination=\"10.100.1.0/24\",\n gateway=\"10.0.1.1\",\n ),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer change-type $LOADBALANCER lb21" + "source": "hcloud network remove-route $NETWORK \\\n --destination 10.100.1.0/24 \\\n --gateway 10.0.1.1" } ] }, @@ -13000,18 +16124,18 @@ } ] }, - "/load_balancers/{id}/actions/delete_service": { + "/networks/{id}/actions/delete_subnet": { "post": { - "description": "Delete a service of a Load Balancer.", - "operationId": "delete_service", + "description": "Deletes a single subnet entry from a [Network](#networks).\n\nSubnets containing attached resources can not be deleted, they must be detached beforehand.\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", + "operationId": "delete_subnet_from_network", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Network.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -13023,7 +16147,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/delete_service_request" + "$ref": "#/components/schemas/delete_subnet_from_network_request" } } } @@ -13034,143 +16158,179 @@ "application/json": { "example": { "action": { - "command": "delete_service", + "command": "delete_subnet", "error": { "code": "action_failed", "message": "Action failed" }, - "finished": "2016-01-30T23:56:00+00:00", + "finished": null, "id": 13, - "progress": 100, + "progress": 0, "resources": [ { "id": 4711, - "type": "load_balancer" + "type": "network" } ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/delete_service_response" + "$ref": "#/components/schemas/delete_subnet_from_network_response" } } }, - "description": "The `action` key contains the `delete_service` Action." + "description": "Response for deleting a subnet from a [Network](#networks).\n\nThe `action` key contains an [Action](#actions) with command `delete_subnet`.\n" } }, - "summary": "Delete Service", + "summary": "Delete a subnet from a Network", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.DeleteService(ctx, &hcloud.LoadBalancer{ID: 123}, 443)\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.DeleteSubnet(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkDeleteSubnetOpts{\n\t\tSubnet: hcloud.NetworkSubnet{\n\t\t\tIPRange: &net.IPNet{\n\t\t\t\tIP: net.ParseIP(\"10.0.1.0\"),\n\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network, NetworkSubnet\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.delete_subnet(\n network=Network(id=123), subnet=NetworkSubnet(ip_range=\"10.0.1.0/24\")\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud network remove-subnet $NETWORK \\\n --ip-range 10.0.1.0/24" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/networks/actions": { + "get": { + "description": "Lists multiple [Actions](#actions).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_network_actions", + "parameters": [ + { + "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", + "in": "query", + "name": "id", + "required": false, + "schema": { + "items": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "type": "array" + } + }, + { + "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "command", + "command:asc", + "command:desc", + "status", + "status:asc", + "status:desc", + "started", + "started:asc", + "started:desc", + "finished", + "finished:asc", + "finished:desc" + ], + "type": "string" + }, + "type": "array" + } }, { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer, LoadBalancerService\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.delete_service(\n load_balancer=LoadBalancer(id=123), service=LoadBalancerService(listen_port=443)\n)\n\naction.wait_until_finished()" + "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Action.", + "enum": [ + "running", + "success", + "error" + ], + "type": "string" + }, + "type": "array" + } }, { - "label": "CLI", - "lang": "Shell", - "source": "hcloud load-balancer delete-service $LOADBALANCER \\\n --listen-port 443" - } - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/load_balancers/{id}/actions/detach_from_network": { - "post": { - "description": "Detaches a Load Balancer from a network.", - "operationId": "detach_load_balancer_from_network", - "parameters": [ + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, { - "description": "ID of the Load Balancer.", - "in": "path", - "name": "id", - "required": true, + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, "schema": { - "description": "ID of the Load Balancer.", - "example": 42, + "default": 25, + "example": 25, "format": "int64", - "maximum": 9007199254740991, "type": "integer" } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/detach_load_balancer_from_network_request" - } - } - } - }, "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "detach_from_network", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - }, - { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/detach_load_balancer_from_network_response" + "$ref": "#/components/schemas/list_actions_response" } } }, - "description": "The `action` key contains the `detach_from_network` Action." + "description": "Response for listing [Actions](#actions)." } }, - "summary": "Detach a Load Balancer from a Network", + "summary": "List Actions", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.DetachFromNetwork(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerDetachFromNetworkOpts{\n\t\tNetwork: &hcloud.Network{ID: 4711},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Network.Action.All(ctx, hcloud.ActionListOpts{})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.detach_from_network(\n load_balancer=LoadBalancer(id=123), network=Network(id=4711)\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud load-balancer detach-from-network $LOADBALANCER \\\n --network $NETWORK" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.networks.actions.get_all()" } ] }, @@ -13180,18 +16340,18 @@ } ] }, - "/load_balancers/{id}/actions/disable_public_interface": { - "post": { - "description": "Disable the public interface of a Load Balancer. The Load Balancer will be not accessible from the internet via its public IPs.\n\n#### Call specific error codes\n\n| Code | Description |\n|-------------------------------------------|--------------------------------------------------------------------------------|\n| `load_balancer_not_attached_to_network` | The Load Balancer is not attached to a network |\n| `targets_without_use_private_ip` | The Load Balancer has targets that use the public IP instead of the private IP |\n", - "operationId": "disable_public_interface_of_load_balancer", + "/networks/actions/{id}": { + "get": { + "description": "Returns a single [Action](#actions).", + "operationId": "get_network_action", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Action", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Action.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -13200,60 +16360,31 @@ } ], "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "disable_public_interface", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - }, - { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/disable_public_interface_of_load_balancer_response" + "$ref": "#/components/schemas/get_action_response" } } }, - "description": "The `action` key contains the `disable_public_interface` Action." + "description": "Response for getting a single [Action](#actions)." } }, - "summary": "Disable the public interface of a Load Balancer", + "summary": "Get an Action", "tags": [ - "load_balancers" + "networks" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.DisablePublicInterface(ctx, &hcloud.LoadBalancer{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.Action.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.disable_public_interface(\n load_balancer=LoadBalancer(id=123),\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud load-balancer disable-public-interface $LOADBALANCER" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.actions.get_by_id(123)" } ] }, @@ -13263,113 +16394,167 @@ } ] }, - "/load_balancers/{id}/actions/enable_public_interface": { - "post": { - "description": "Enable the public interface of a Load Balancer. The Load Balancer will be accessible from the internet via its public IPs.", - "operationId": "enable_public_interface_of_load_balancer", + "/placement_groups": { + "get": { + "description": "Returns all Placement Group objects.", + "operationId": "list_placement_groups", "parameters": [ { - "description": "ID of the Load Balancer.", - "in": "path", - "name": "id", - "required": true, + "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "name", + "name:asc", + "name:desc", + "created", + "created:asc", + "created:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "in": "query", + "name": "label_selector", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter resources by type. Can be used multiple times. The response will only\ncontain the resources with the specified type.\n", + "in": "query", + "name": "type", + "required": false, + "schema": { + "items": { + "description": "Type of Placement Group.\n", + "enum": [ + "spread" + ], + "example": "spread", + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, "schema": { - "description": "ID of the Load Balancer.", - "example": 42, + "default": 25, + "example": 25, "format": "int64", - "maximum": 9007199254740991, "type": "integer" } } ], "responses": { - "201": { + "200": { "content": { "application/json": { "example": { - "action": { - "command": "enable_public_interface", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" + "meta": { + "pagination": { + "last_page": 1, + "next_page": null, + "page": 1, + "per_page": 25, + "previous_page": null, + "total_entries": 21 + } + }, + "placement_groups": [ + { + "created": "2019-01-08T12:10:00+00:00", + "id": 897, + "labels": { + "key": "value" }, - { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } + "name": "my Placement Group", + "servers": [ + 4711, + 4712 + ], + "type": "spread" + } + ] }, "schema": { - "$ref": "#/components/schemas/enable_public_interface_of_load_balancer_response" + "$ref": "#/components/schemas/list_placement_groups_response" } } }, - "description": "The `action` key contains the `enable_public_interface` Action." + "description": "The `placement_groups` key contains an array of Placement Group objects." } }, - "summary": "Enable the public interface of a Load Balancer", + "summary": "List Placement Groups", "tags": [ - "load_balancers" + "placement_groups" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.EnablePublicInterface(ctx, &hcloud.LoadBalancer{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tplacementGroups, err := client.PlacementGroup.All(ctx)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.enable_public_interface(\n load_balancer=LoadBalancer(id=123),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nplacement_groups = client.placement_groups.get_all()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer enable-public-interface $LOADBALANCER" + "source": "hcloud placement-group list" } ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/load_balancers/{id}/actions/remove_target": { "post": { - "description": "Removes a target from a Load Balancer.", - "operationId": "remove_target", - "parameters": [ - { - "description": "ID of the Load Balancer.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the Load Balancer.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - } - } - ], + "description": "Creates a new Placement Group.\n", + "operationId": "create_placementgroup", "requestBody": { "content": { "application/json": { + "example": { + "name": "my Placement Group", + "type": "spread" + }, "schema": { - "$ref": "#/components/schemas/remove_target_request" + "$ref": "#/components/schemas/create_placementgroup_request" } } } @@ -13379,52 +16564,44 @@ "content": { "application/json": { "example": { - "action": { - "command": "remove_target", - "error": { - "code": "action_failed", - "message": "Action failed" + "placement_group": { + "created": "2019-01-08T12:10:00+00:00", + "id": 897, + "labels": { + "key": "value" }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 4711, - "type": "load_balancer" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" + "name": "my Placement Group", + "servers": [], + "type": "spread" } }, "schema": { - "$ref": "#/components/schemas/remove_target_response" + "$ref": "#/components/schemas/create_placementgroup_response" } } }, - "description": "The `action` key contains the `remove_target` Action." + "description": "The `PlacementGroup` key contains the Placement Group that was just created." } }, - "summary": "Remove Target", + "summary": "Create a PlacementGroup", "tags": [ - "load_balancers" + "placement_groups" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction1, _, err := client.LoadBalancer.RemoveIPTarget(ctx, &hcloud.LoadBalancer{ID: 123}, net.ParseIP(\"203.0.113.1\"))\n\n\taction2, _, err := client.LoadBalancer.RemoveLabelSelectorTarget(ctx, &hcloud.LoadBalancer{ID: 123}, \"env=prod\")\n\n\taction3, _, err := client.LoadBalancer.RemoveServerTarget(ctx, &hcloud.LoadBalancer{ID: 123}, &hcloud.Server{ID: 80})\n\n\terr = client.Action.WaitFor(ctx, action1, action2, action3)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.PlacementGroup.Create(ctx, hcloud.PlacementGroupCreateOpts{\n\t\tName: \"my Placement Group\",\n\t\tType: hcloud.PlacementGroupTypeSpread,\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tplacementGroup := result.PlacementGroup\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import (\n LoadBalancer,\n LoadBalancerTarget,\n LoadBalancerTargetIP,\n LoadBalancerTargetLabelSelector,\n)\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.remove_target(\n load_balancer=LoadBalancer(id=123),\n target=LoadBalancerTarget(\n ip=LoadBalancerTargetIP(\n ip=\"203.0.113.1\",\n ),\n label_selector=LoadBalancerTargetLabelSelector(\n selector=\"env=prod\",\n ),\n server=Server(\n id=80,\n ),\n type=\"server\",\n ),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.placement_groups.create(\n name=\"my Placement Group\",\n type=\"spread\",\n)\n\nresponse.action.wait_until_finished()\n\nplacement_group = response.placement_group" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer remove-target $LOADBALANCER --ip 203.0.113.1\nhcloud load-balancer remove-target $LOADBALANCER --label-selector \"env=prod\"\nhcloud load-balancer remove-target $LOADBALANCER --server 80 --use-private-ip" + "source": "hcloud placement-group create \\\n --name \"my Placement Group\" \\\n --type spread" } ] }, @@ -13434,18 +16611,18 @@ } ] }, - "/load_balancers/{id}/actions/update_service": { - "post": { - "description": "Updates a Load Balancer Service.\n\n#### Call specific error codes\n\n| Code | Description |\n|----------------------------|---------------------------------------------------------|\n| `source_port_already_used` | The source port you are trying to add is already in use |\n", - "operationId": "update_service", + "/placement_groups/{id}": { + "delete": { + "description": "Deletes a Placement Group.", + "operationId": "delete_placementgroup", "parameters": [ { - "description": "ID of the Load Balancer.", + "description": "ID of the Placement Group.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Load Balancer.", + "description": "ID of the Placement Group.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -13453,133 +16630,48 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/update_service_request" - } - } - } - }, "responses": { - "201": { - "content": { - "application/json": { - "example": { - "action": { - "command": "update_service", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 4711, - "type": "load_balancer" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - }, - "schema": { - "$ref": "#/components/schemas/update_service_response" - } - } - }, - "description": "The `action` key contains the `update_service` Action." + "204": { + "description": "Placement Group deleted." } }, - "summary": "Update Service", + "summary": "Delete a PlacementGroup", "tags": [ - "load_balancers" + "placement_groups" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.UpdateService(ctx, &hcloud.LoadBalancer{ID: 123}, 443, hcloud.LoadBalancerUpdateServiceOpts{\n\t\tDestinationPort: hcloud.Ptr(80),\n\t\tHealthCheck: &hcloud.LoadBalancerUpdateServiceOptsHealthCheck{\n\t\t\tHTTP: &hcloud.LoadBalancerUpdateServiceOptsHealthCheckHTTP{\n\t\t\t\tDomain: hcloud.Ptr(\"example.com\"),\n\t\t\t\tPath: hcloud.Ptr(\"/\"),\n\t\t\t\tResponse: hcloud.Ptr(`{\"status\": \"ok\"}`),\n\t\t\t\tStatusCodes: []string{\"2??\", \"3??\"},\n\t\t\t\tTLS: hcloud.Ptr(false),\n\t\t\t},\n\t\t\tInterval: hcloud.Ptr(15 * time.Second),\n\t\t\tPort: hcloud.Ptr(4711),\n\t\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTP,\n\t\t\tRetries: hcloud.Ptr(3),\n\t\t\tTimeout: hcloud.Ptr(10 * time.Second),\n\t\t},\n\t\tHTTP: &hcloud.LoadBalancerUpdateServiceOptsHTTP{\n\t\t\tCertificates: []*hcloud.Certificate{{ID: 897}},\n\t\t\tCookieLifetime: hcloud.Ptr(300 * time.Second),\n\t\t\tCookieName: hcloud.Ptr(\"HCLBSTICKY\"),\n\t\t\tRedirectHTTP: hcloud.Ptr(true),\n\t\t\tStickySessions: hcloud.Ptr(true),\n\t\t},\n\t\tProtocol: hcloud.LoadBalancerServiceProtocolHTTPS,\n\t\tProxyprotocol: hcloud.Ptr(false),\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.certificates import Certificate\nfrom hcloud.load_balancers import (\n LoadBalancer,\n LoadBalancerService,\n LoadBalancerHealthCheck,\n LoadBalancerHealtCheckHttp,\n LoadBalancerServiceHttp,\n)\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.update_service(\n load_balancer=LoadBalancer(id=123),\n service=LoadBalancerService(\n destination_port=80,\n health_check=LoadBalancerHealthCheck(\n http=LoadBalancerHealtCheckHttp(\n domain=\"example.com\",\n path=\"/\",\n response='{\"status\": \"ok\"}',\n status_codes=[\"2??\", \"3??\"],\n tls=False,\n ),\n interval=15,\n port=4711,\n protocol=\"http\",\n retries=3,\n timeout=10,\n ),\n http=LoadBalancerServiceHttp(\n certificates=[Certificate(id=897)],\n cookie_lifetime=300,\n cookie_name=\"HCLBSTICKY\",\n redirect_http=True,\n sticky_sessions=True,\n ),\n listen_port=443,\n protocol=\"https\",\n proxyprotocol=False,\n ),\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud load-balancer update-service $LOADBALANCER \\\n --listen-port 443 \\\n --destination-port 80 \\\n --health-check-http-domain example.com \\\n --health-check-http-path \"/\" \\\n --health-check-http-response '{\"status\": \"ok\"}' \\\n --health-check-http-status-codes \"2??,3??\" \\\n --health-check-http-tls=false \\\n --health-check-interval 15s \\\n --health-check-port 4711 \\\n --health-check-protocol http \\\n --health-check-retries 3 \\\n --health-check-timeout 10s \\\n --http-certificates 897 \\\n --http-cookie-lifetime 300s \\\n --http-cookie-name HCLBSTICKY \\\n --http-redirect-http=true \\\n --http-sticky-sessions=true \\\n --protocol https \\\n --proxy-protocol=false" - } - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/load_balancers/{id}/metrics": { - "get": { - "description": "You must specify the type of metric to get: `open_connections`, `connections_per_second`, `requests_per_second` or `bandwidth`. You can also specify more than one type by comma separation, e.g. `requests_per_second,bandwidth`.\n\nDepending on the type you will get different time series data:\n\n|Type | Timeseries | Unit | Description |\n|---- |------------|------|-------------|\n| open_connections | open_connections | number | Open connections |\n| connections_per_second | connections_per_second | connections/s | Connections per second |\n| requests_per_second | requests_per_second | requests/s | Requests per second |\n| bandwidth | bandwidth.in | bytes/s | Ingress bandwidth |\n|| bandwidth.out | bytes/s | Egress bandwidth |\n\nMetrics are available for the last 30 days only.\n\nIf you do not provide the step argument we will automatically adjust it so that 200 samples are returned.\n\nWe limit the number of samples to a maximum of 500 and will adjust the step parameter accordingly.\n", - "operationId": "get_metrics_for_loadbalancer", - "parameters": [ - { - "description": "ID of the Load Balancer.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the Load Balancer.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - } - }, - { - "description": "Type of metrics to get.", - "in": "query", - "name": "type", - "required": true, - "schema": { - "enum": [ - "open_connections", - "connections_per_second", - "requests_per_second", - "bandwidth" - ], - "type": "string" - } - }, - { - "description": "Start of period to get Metrics for (in ISO-8601 format).", - "in": "query", - "name": "start", - "required": true, - "schema": { - "type": "string" - } + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.PlacementGroup.Delete(ctx, &hcloud.PlacementGroup{ID: 123})\n}" }, { - "description": "End of period to get Metrics for (in ISO-8601 format).", - "in": "query", - "name": "end", - "required": true, - "schema": { - "type": "string" - } + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.placement_groups import PlacementGroup\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.placement_groups.delete(\n placement_group=PlacementGroup(id=123),\n)" }, { - "description": "Resolution of results in seconds.", - "in": "query", - "name": "step", - "required": false, + "label": "CLI", + "lang": "Shell", + "source": "hcloud placement-group delete $PLACEMENTGROUP" + } + ] + }, + "get": { + "description": "Gets a specific Placement Group object.", + "operationId": "get_placementgroup", + "parameters": [ + { + "description": "ID of the Placement Group.", + "in": "path", + "name": "id", + "required": true, "schema": { - "type": "string" + "description": "ID of the Placement Group.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" } } ], @@ -13587,161 +16679,124 @@ "200": { "content": { "application/json": { + "example": { + "placement_group": { + "created": "2019-01-08T12:10:00+00:00", + "id": 897, + "labels": { + "key": "value" + }, + "name": "my Placement Group", + "servers": [ + 4711, + 4712 + ], + "type": "spread" + } + }, "schema": { - "$ref": "#/components/schemas/get_metrics_for_loadbalancer_response" + "$ref": "#/components/schemas/get_placementgroup_response" } } }, - "description": "The `metrics` key in the reply contains a metrics object with this structure." + "description": "The `placement_group` key contains a Placement Group object." } }, - "summary": "Get Metrics for a LoadBalancer", + "summary": "Get a PlacementGroup", "tags": [ - "load_balancers" + "placement_groups" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tmetrics, _, err := client.LoadBalancer.GetMetrics(ctx, &hcloud.LoadBalancer{ID: 123}, hcloud.LoadBalancerGetMetricsOpts{\n\t\tStart: time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC),\n\t\tEnd: time.Date(2017, 1, 1, 23, 0, 0, 0, time.UTC),\n\t\tStep: 60,\n\t\tTypes: []hcloud.LoadBalancerMetricType{\n\t\t\thcloud.LoadBalancerMetricBandwidth,\n\t\t\thcloud.LoadBalancerMetricOpenConnections,\n\t\t\thcloud.LoadBalancerMetricConnectionsPerSecond,\n\t\t\thcloud.LoadBalancerMetricRequestsPerSecond,\n\t\t},\n\t})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tplacementGroups, _, err := client.PlacementGroup.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\nimport datetime\n\nfrom hcloud import Client\nfrom hcloud.load_balancers import LoadBalancer\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.load_balancers.get_metrics(\n\tload_balancer=LoadBalancer(id=123),\n\tstart=datetime.datetime(2017, 1, 1, 0, 0, 0, 0, datetime.UTC),\n\tend=datetime.datetime(2017, 1, 1, 23, 0, 0, 0, datetime.UTC),\n\tstep=60,\n\ttype=[\n\t\t\"bandwidth\",\n\t\t\"open_connections\",\n\t\t\"connections_per_second\",\n\t\t\"requests_per_second\",\n\t]\n)\n\nresponse.action.wait_until_finished()\n\nmetrics = response.metrics" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nplacement_group = client.placement_groups.get_by_id(123)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud load-balancer metrics $LOADBALANCER \\\n --type open_connections,connections_per_second,requests_per_second,bandwidth \\\n --start 2017-01-01T00:00:00Z \\\n --end 2017-01-01T23:00:00Z" + "source": "hcloud placement-group describe $PLACEMENTGROUP" } ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/load_balancers/actions": { - "get": { - "description": "Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.", - "operationId": "list_load_balancer_actions", + "put": { + "description": "Updates the Placement Group properties.\n\nNote: if the Placement Group object changes during the request, the response will be a “conflict” error.\n", + "operationId": "replace_placementgroup", "parameters": [ { - "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", - "in": "query", + "description": "ID of the Placement Group.", + "in": "path", "name": "id", - "required": false, - "schema": { - "items": { - "description": "ID of the Action.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - }, - "type": "array" - } - }, - { - "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "command", - "command:asc", - "command:desc", - "status", - "status:asc", - "status:desc", - "started", - "started:asc", - "started:desc", - "finished", - "finished:asc", - "finished:desc" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", - "in": "query", - "name": "status", - "required": false, - "schema": { - "items": { - "description": "Status of the Action.", - "enum": [ - "running", - "success", - "error" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Placement Group.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/replace_placementgroup_request" + } + } + } + }, "responses": { "200": { "content": { "application/json": { + "example": { + "placement_group": { + "created": "2019-01-08T12:10:00+00:00", + "id": 897, + "labels": { + "key": "value" + }, + "name": "my Placement Group", + "servers": [ + 4711, + 4712 + ], + "type": "spread" + } + }, "schema": { - "$ref": "#/components/schemas/list_actions_response" + "$ref": "#/components/schemas/replace_placementgroup_response" } } }, - "description": "The `actions` key contains a list of Actions." + "description": "The `certificate` key contains the Placement Group that was just updated." } }, - "summary": "List Actions", + "summary": "Update a PlacementGroup", "tags": [ - "load_balancers" + "placement_groups" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.LoadBalancer.Action.All(ctx, hcloud.ActionListOpts{})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tplacementGroup, _, err := client.PlacementGroup.Update(ctx, &hcloud.PlacementGroup{ID: 123}, hcloud.PlacementGroupUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"my Placement Group\",\n\t})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.load_balancers.actions.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.placement_groups import PlacementGroup\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nplacement_group = client.placement_groups.update(\n placement_group=PlacementGroup(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my Placement Group\",\n)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud placement-group update $PLACEMENTGROUP --name \"my Placement Group\"\nhcloud placement-group add-label --overwrite $PLACEMENTGROUP \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud placement-group remove-label $PLACEMENTGROUP \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] }, @@ -13751,51 +16806,31 @@ } ] }, - "/load_balancers/actions/{id}": { + "/pricing": { "get": { - "description": "Returns a specific Action object.", - "operationId": "get_load_balancer_action", - "parameters": [ - { - "description": "ID of the Action", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the Action.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - } - } - ], + "description": "Returns prices for all resources available on the platform. VAT and currency of the Project owner are used for calculations.\n\nBoth net and gross prices are included in the response.\n", + "operationId": "list_prices", "responses": { "200": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/list_prices_response" } } }, - "description": "The `action` key in the reply has this structure." + "description": "The `pricing` key in the reply contains an pricing object with this structure." } }, - "summary": "Get an Action", + "summary": "Get all prices", "tags": [ - "load_balancers" + "pricing" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.LoadBalancer.Action.GetByID(ctx, 123)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.actions.get_by_id(123)" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tpricing, _, err := client.Pricing.Get(ctx)\n}" } ] }, @@ -13805,10 +16840,10 @@ } ] }, - "/locations": { + "/primary_ips": { "get": { - "description": "Returns all [Locations](#locations).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_locations", + "description": "List multiple [Primary IPs](#primary-ips).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_primary_ips", "parameters": [ { "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", @@ -13820,23 +16855,22 @@ } }, { - "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "in": "query", + "name": "label_selector", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter results by IP address.", + "example": "127.0.0.1", "in": "query", - "name": "sort", + "name": "ip", "required": false, "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "name", - "name:asc", - "name:desc" - ], - "type": "string" - }, - "type": "array" + "type": "string" } }, { @@ -13862,6 +16896,26 @@ "format": "int64", "type": "integer" } + }, + { + "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "created", + "created:asc", + "created:desc" + ], + "type": "string" + }, + "type": "array" + } } ], "responses": { @@ -13869,91 +16923,154 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/list_locations_response" + "$ref": "#/components/schemas/list_primary_ips_response" } } }, - "description": "Response with the [Locations](#locations)." + "description": "Response for listing [Primary IPs](#primary-ips)." } }, - "summary": "List Locations", + "summary": "List Primary IPs", "tags": [ - "locations" + "primary_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tlocations, err := client.Location.All(ctx)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tprimaryIPs, err := client.PrimaryIP.All(ctx)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nlocations = client.locations.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nprimary_ips = client.primary_ips.get_all()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud location list" + "source": "hcloud primary-ip list" } ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/locations/{id}": { - "get": { - "description": "Returns a [Location](#locations).", - "operationId": "get_location", - "parameters": [ - { - "description": "ID of the Location.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the Location.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" + "post": { + "description": "Create a new [Primary IP](#primary-ips).\n\nCan optionally be assigned to a resource by providing an `assignee_id` and `assignee_type`.\n\nIf not assigned to a resource the `datacenter` key needs to be provided. This can be either the ID or the name of the [Datacenter](#datacenters) this [Primary IP](#primary-ips) shall be created in.\n\nA [Primary IP](#primary-ips) can only be assigned to resource in the same [Datacenter](#datacenters) later on.\n\n#### Call specific error codes\n\n| Code | Description |\n|------------------------------ |------------------------------------------------------------------------- |\n| `server_not_stopped` | The specified [Server](#servers) is running, but needs to be powered off |\n| `server_has_ipv4` | The [Server](#servers) already has an ipv4 address |\n| `server_has_ipv6` | The [Server](#servers) already has an ipv6 address |\n", + "operationId": "create_primary_ip", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/create_primary_ip_request" + } } - } - ], + }, + "description": "Request Body for creating a new [Primary IP](#primary-ips).\n\nThe `datacenter` and `assignee_id`/`assignee_type` attributes are mutually exclusive.\n" + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "create_primary_ip", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 17, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + }, + "primary_ip": { + "assignee_id": 17, + "assignee_type": "server", + "auto_delete": true, + "blocked": false, + "created": "2016-01-30T23:50:00+00:00", + "datacenter": { + "description": "Falkenstein DC Park 8", + "id": 42, + "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-dc8", + "server_types": { + "available": [ + 1, + 2, + 3 + ], + "available_for_migration": [ + 1, + 2, + 3 + ], + "supported": [ + 1, + 2, + 3 + ] + } + }, + "dns_ptr": [ + { + "dns_ptr": "server.example.com", + "ip": "2001:db8::1" + } + ], + "id": 42, + "ip": "2001:db8::/64", + "labels": { + "key": "value" + }, + "name": "my-ip", + "protection": { + "delete": false + }, + "type": "ipv6" + } + }, "schema": { - "$ref": "#/components/schemas/get_location_response" + "$ref": "#/components/schemas/create_primary_ip_response" } } }, - "description": "Response with the [Location](#locations)." + "description": "Response for creating a [Primary IP](#primary-ips).\n\nContains the newly created [Primary IP](#primary-ips).\n" } }, - "summary": "Get a Location", + "summary": "Create a Primary IP", "tags": [ - "locations" + "primary_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tlocation, _, err := client.Location.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.PrimaryIP.Create(ctx, hcloud.PrimaryIPCreateOpts{\n\t\tAssigneeID: hcloud.Ptr(int64(17)),\n\t\tAssigneeType: \"server\",\n\t\tAutoDelete: hcloud.Ptr(false),\n\t\tDatacenter: \"fsn1-dc8\",\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"my-ip\",\n\t\tType: \"ipv4\",\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tprimaryIP := result.PrimaryIP\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nlocation = client.locations.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.primary_ips.create(\n assignee_id=17,\n assignee_type=\"server\",\n auto_delete=False,\n datacenter=\"fsn1-dc8\",\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-resource\",\n type=\"ipv4\",\n)\n\nresponse.action.wait_until_finished()\n\nprimary_ip = response.primary_ip" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud location describe $LOCATION" + "source": "hcloud primary-ip create \\\n --assignee-id 17 \\\n --auto-delete=false \\\n --datacenter fsn1-dc8 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name my-ip \\\n --type ipv4" } ] }, @@ -13963,119 +17080,195 @@ } ] }, - "/networks": { - "get": { - "description": "List multiple [Networks](#networks).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_networks", + "/primary_ips/{id}": { + "delete": { + "description": "Deletes a [Primary IP](#primary-ips).\n\nIf assigned to a [Server](#servers) the [Primary IP](#primary-ips) will be unassigned automatically. The [Server](#servers) must be powered off (status `off`) in order for this operation to succeed.\n", + "operationId": "delete_primary_ip", "parameters": [ { - "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, + "description": "ID of the Primary IP.", + "in": "path", + "name": "id", + "required": true, "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "name", - "name:asc", - "name:desc", - "created", - "created:asc", - "created:desc" - ], - "type": "string" - }, - "type": "array" + "description": "ID of the Primary IP.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" } - }, + } + ], + "responses": { + "204": { + "description": "[Primary IP](#primary-ips) deletion succeeded." + } + }, + "summary": "Delete a Primary IP", + "tags": [ + "primary_ips" + ], + "x-codeSamples": [ { - "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", - "in": "query", - "name": "name", - "required": false, - "schema": { - "type": "string" - } + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.PrimaryIP.Delete(ctx, &hcloud.PrimaryIP{ID: 123})\n}" }, { - "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", - "in": "query", - "name": "label_selector", - "required": false, - "schema": { - "type": "string" - } + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.primary_ips.delete(\n primary_ip=PrimaryIP(id=123),\n)" }, { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, + "label": "CLI", + "lang": "Shell", + "source": "hcloud primary-ip delete $PRIMARYIP" + } + ] + }, + "get": { + "description": "Returns a [Primary IP](#primary-ips).", + "operationId": "get_primary_ip", + "parameters": [ + { + "description": "ID of the Primary IP.", + "in": "path", + "name": "id", + "required": true, "schema": { - "default": 1, - "example": 2, + "description": "ID of the Primary IP.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_primary_ip_response" + } + } + }, + "description": "The `primary_ip` key contains the [Primary IP](#primary-ips)." + } + }, + "summary": "Get a Primary IP", + "tags": [ + "primary_ips" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tprimaryIP, _, err := client.PrimaryIP.GetByID(ctx, 123)\n}" }, { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nprimary_ip = client.primary_ips.get_by_id(123)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud primary-ip describe $PRIMARYIP" + } + ] + }, + "put": { + "description": "Update a [Primary IP](#primary-ips).\n\nIf another change is concurrently performed on this [Primary IP](#primary-ips), a error response with code `conflict` will be returned.\n", + "operationId": "replace_primary_ip", + "parameters": [ + { + "description": "ID of the Primary IP.", + "in": "path", + "name": "id", + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Primary IP.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/replace_primary_ip_request" + } + } + } + }, "responses": { "200": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/list_networks_response" + "$ref": "#/components/schemas/replace_primary_ip_response" } } }, - "description": "Response for listing [Networks](#networks)." + "description": "The `primary_ip` key contains the updated [Primary IP](#primary-ips)." } }, - "summary": "List Networks", + "summary": "Update a Primary IP", "tags": [ - "networks" + "primary_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tnetworks, err := client.Network.All(ctx)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tprimaryIP, _, err := client.PrimaryIP.Update(ctx, &hcloud.PrimaryIP{ID: 123}, hcloud.PrimaryIPUpdateOpts{\n\t\tAutoDelete: hcloud.Ptr(true),\n\t\tLabels: hcloud.Ptr(map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t}),\n\t\tName: \"my-ip\",\n\t})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nnetworks = client.networks.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nprimary_ip = client.primary_ips.update(\n primary_ip=PrimaryIP(id=123),\n auto_delete=True,\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-resource\",\n)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud network list" + "source": "hcloud primary-ip update $PRIMARYIP \\\n --auto-delete=false \\\n --name \"new-name\"\nhcloud primary-ip add-label --overwrite $PRIMARYIP \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud primary-ip remove-label $PRIMARYIP \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/primary_ips/{id}/actions/assign": { "post": { - "description": "Creates a [Network](#networks).\n\nThe provided `ip_range` can only be extended later on, but not reduced.\n\nSubnets can be added now or later on using the [add subnet action](#network-actions-add-a-subnet-to-a-network). If you do not specify an `ip_range` for the subnet the first available /24 range will be used.\n\nRoutes can be added now or later by using the [add route action](#network-actions-add-a-route-to-a-network).\n", - "operationId": "create_network", + "description": "Assign a [Primary IP](#primary-ips) to a resource.\n\nA [Server](#servers) can only have one [Primary IP](#primary-ips) of type `ipv4` and one of type `ipv6` assigned. If you need more IPs use [Floating IPs](#floating-ips).\n\nA [Server](#servers) must be powered off (status `off`) in order for this operation to succeed.\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|------------------------------ |--------------------------------------------------------------------------------- |\n| `server_not_stopped` | The [Server](#servers) is running, but needs to be powered off |\n| `primary_ip_already_assigned` | [Primary IP](#primary-ips) is already assigned to a different [Server](#servers) |\n| `server_has_ipv4` | The [Server](#servers) already has an IPv4 address |\n| `server_has_ipv6` | The [Server](#servers) already has an IPv6 address |\n", + "operationId": "assign_primary_ip_to_resource", + "parameters": [ + { + "description": "ID of the Primary IP.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Primary IP.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/create_network_request" + "$ref": "#/components/schemas/assign_primary_ip_to_resource_request" } } } @@ -14084,33 +17277,57 @@ "201": { "content": { "application/json": { + "example": { + "action": { + "command": "assign_primary_ip", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + }, + { + "id": 4711, + "type": "primary_ip" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + }, "schema": { - "$ref": "#/components/schemas/create_network_response" + "$ref": "#/components/schemas/assign_primary_ip_to_resource_response" } } }, - "description": "Response for creating a [Network](#networks).\n\nContains the newly created [Network](#networks).\n" + "description": "Response for assigning a [Primary IP](#primary-ips).\n\nContains an [Action](#actions) of type `assign_primary_ip`.\n" } }, - "summary": "Create a Network", + "summary": "Assign a Primary IP to a resource", "tags": [ - "networks" + "primary_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tnetwork, _, err := client.Network.Create(ctx, hcloud.NetworkCreateOpts{\n\t\tExposeRoutesToVSwitch: false,\n\t\tIPRange: &net.IPNet{\n\t\t\tIP: net.ParseIP(\"10.0.0.0\"),\n\t\t\tMask: net.CIDRMask(16, 32),\n\t\t},\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"mynet\",\n\t\tRoutes: []hcloud.NetworkRoute{\n\t\t\t{\n\t\t\t\tDestination: &net.IPNet{\n\t\t\t\t\tIP: net.ParseIP(\"10.100.1.0\"),\n\t\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t\t},\n\t\t\t\tGateway: net.ParseIP(\"10.0.1.1\"),\n\t\t\t},\n\t\t},\n\t\tSubnets: []hcloud.NetworkSubnet{\n\t\t\t{\n\t\t\t\tIPRange: &net.IPNet{\n\t\t\t\t\tIP: net.ParseIP(\"10.0.1.0\"),\n\t\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t\t},\n\t\t\t\tNetworkZone: hcloud.NetworkZoneEUCentral,\n\t\t\t\tType: hcloud.NetworkSubnetTypeCloud,\n\t\t\t\tVSwitchID: 1000,\n\t\t\t},\n\t\t},\n\t})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.PrimaryIP.Assign(ctx, hcloud.PrimaryIPAssignOpts{\n\t\tID: 123,\n\t\tAssigneeID: 4711,\n\t\tAssigneeType: \"server\",\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import NetworkRoute, NetworkSubnet\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nnetwork = client.networks.create(\n expose_routes_to_vswitch=False,\n ip_range=\"10.0.0.0/16\",\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"mynet\",\n routes=[\n NetworkRoute(\n destination=\"10.100.1.0/24\",\n gateway=\"10.0.1.1\",\n )\n ],\n subnets=[\n NetworkSubnet(\n ip_range=\"10.0.1.0/24\",\n network_zone=\"eu-central\",\n type=\"cloud\",\n vswitch_id=1000,\n )\n ],\n)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.primary_ips.assign(\n primary_ip=PrimaryIP(id=123),\n assignee_id=4711,\n assignee_type=\"server\",\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud network create \\\n --expose-routes-to-vswitch=false \\\n --ip-range 10.0.0.0/16 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name mynet\n\nhcloud network add-route mynet \\\n --destination 10.100.1.0/24 \\\n --gateway 10.0.1.1\n\nhcloud network add-subnet mynet \\\n --ip-range 10.0.1.0/24 \\\n --network-zone eu-central \\\n --type cloud \\\n --vswitch-id 1000" + "source": "hcloud primary-ip assign --server 4711 $PRIMARYIP" } ] }, @@ -14120,18 +17337,18 @@ } ] }, - "/networks/{id}": { - "delete": { - "description": "Deletes a [Network](#networks).\n\nAttached resources will be detached automatically.\n", - "operationId": "delete_network", + "/primary_ips/{id}/actions/change_dns_ptr": { + "post": { + "description": "Change the reverse DNS records for this [Primary IP](#primary-ips).\n\nAllows to modify the PTR records set for the IP address.\n", + "operationId": "change_reverse_dns_records_for_primary_ip", "parameters": [ { - "description": "ID of the Network.", + "description": "ID of the Primary IP.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Network.", + "description": "ID of the Primary IP.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -14139,44 +17356,88 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_reverse_dns_records_for_primary_ip_request" + } + } + }, + "description": "The `ip` attributes specifies for which IP address the record is set. For IPv4 addresses this must be the exact address of the [Primary IP](#primary-ips). For IPv6 addresses this must be a single address within the `/64` subnet of the [Primary IP](#primary-ips).\n\nThe `dns_ptr` attribute specifies the hostname used for the IP address.\n\nFor IPv6 [Floating IPs](#floating-ips) up to 100 entries can be created.\n" + }, "responses": { - "204": { - "description": "Response for deleting a [Network](#networks)." + "201": { + "content": { + "application/json": { + "example": { + "action": { + "command": "change_dns_ptr", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 4711, + "type": "primary_ip" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, + "schema": { + "$ref": "#/components/schemas/change_reverse_dns_records_for_primary_ip_response" + } + } + }, + "description": "Response for changing a [Primary IPs](#primary-ips) DNS pointer.\n\nContains an [Action](#actions) of type `change_dns_ptr`.\n" } }, - "summary": "Delete a Network", + "summary": "Change reverse DNS records for a Primary IP", "tags": [ - "networks" + "primary_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.Network.Delete(ctx, &hcloud.Network{ID: 123})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.PrimaryIP.ChangeDNSPtr(ctx, hcloud.PrimaryIPChangeDNSPtrOpts{\n\t\tID: 123,\n\t\tDNSPtr: \"server02.example.com\",\n\t\tIP: \"1.2.3.4\",\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.networks.delete(\n network=Network(id=123),\n)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.primary_ips.change_dns_ptr(\n primary_ip=PrimaryIP(id=123),\n dns_ptr=\"server.example.com\",\n ip=\"2001:db8::1\",\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud network delete $NETWORK" + "source": "hcloud primary-ip set-rdns $PRIMARYIP \\\n --ip 1.2.3.4 \\\n --hostname server02.example.com" } ] }, - "get": { - "description": "Get a specific [Network](#networks).", - "operationId": "get_network", + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/primary_ips/{id}/actions/change_protection": { + "post": { + "description": "Changes the protection configuration of a [Primary IP](#primary-ips).\n\nA [Primary IPs](#primary-ips) deletion protection can only be enabled if its `auto_delete` property is set to `false`.\n", + "operationId": "change_primary_ip_protection", "parameters": [ { - "description": "ID of the Network.", + "description": "ID of the Primary IP.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Network.", + "description": "ID of the Primary IP.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -14184,51 +17445,87 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_primary_ip_protection_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "change_protection", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 4711, + "type": "primary_ip" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, "schema": { - "$ref": "#/components/schemas/get_network_response" + "$ref": "#/components/schemas/change_primary_ip_protection_response" } } }, - "description": "The `network` key contains the network." + "description": "Response for changing a [Primary IPs](#primary-ips) protection settings.\n\nContains an [Action](#actions) of type `change_protection`.\n" } }, - "summary": "Get a Network", + "summary": "Change Primary IP Protection", "tags": [ - "networks" + "primary_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tnetwork, _, err := client.Network.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.PrimaryIP.ChangeProtection(ctx, hcloud.PrimaryIPChangeProtectionOpts{\n\t\tID: 123,\n\t\tDelete: true,\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nnetwork = client.networks.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.primary_ips.change_protection(\n primary_ip=PrimaryIP(id=123),\n delete=False,\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud network describe $NETWORK" + "source": "hcloud primary-ip enable-protection $PRIMARYIP delete\nhcloud primary-ip disable-protection $PRIMARYIP delete" } ] }, - "put": { - "description": "Update a [Network](#networks).\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", - "operationId": "replace_network", + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/primary_ips/{id}/actions/unassign": { + "post": { + "description": "Unassign a [Primary IP](#primary-ips) from a resource.\n\nA [Server](#servers) must be powered off (status `off`) in order for this operation to succeed.\n\nA [Server](#server) requires at least one network interface (public or private) to be powered on.\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|---------------------------------- |-------------------------------------------------------------- |\n| `server_not_stopped` | The [Server](#server) is running, but needs to be powered off |\n| `server_is_load_balancer_target` | The [Server](#server) IPv4 address is a loadbalancer target |\n", + "operationId": "unassign_primary_ip_from_resource", "parameters": [ { - "description": "ID of the Network.", + "description": "ID of the Primary IP.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Network.", + "description": "ID of the Primary IP.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -14236,81 +17533,61 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/replace_network_request" - } - } - } - }, "responses": { - "200": { + "201": { "content": { "application/json": { "example": { - "network": { - "created": "2016-01-30T23:50:00+00:00", - "expose_routes_to_vswitch": true, - "id": 4711, - "ip_range": "10.0.0.0/16", - "labels": { - "key": "value" - }, - "load_balancers": [ - 42 - ], - "name": "new-name", - "protection": { - "delete": false + "action": { + "command": "unassign_primary_ip", + "error": { + "code": "action_failed", + "message": "Action failed" }, - "routes": [ + "finished": null, + "id": 13, + "progress": 0, + "resources": [ { - "destination": "10.100.1.0/24", - "gateway": "10.0.1.1" - } - ], - "servers": [ - 42 - ], - "subnets": [ + "id": 42, + "type": "server" + }, { - "gateway": "10.0.0.1", - "ip_range": "10.0.1.0/24", - "network_zone": "eu-central", - "type": "cloud" + "id": 4711, + "type": "primary_ip" } - ] + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/replace_network_response" + "$ref": "#/components/schemas/unassign_primary_ip_from_resource_response" } } }, - "description": "Response for updating a [Network](#networks).\n\nContains the updated [Network](#networks).\n" + "description": "Response for unassigning a [Primary IP](#primary-ips).\n\nContains an [Action](#actions) of type `unassign_primary_ip`.\n" } }, - "summary": "Update a Network", + "summary": "Unassign a Primary IP from a resource", "tags": [ - "networks" + "primary_ips" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tnetwork, _, err := client.Network.Update(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkUpdateOpts{\n\t\tExposeRoutesToVSwitch: hcloud.Ptr(false),\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"new-name\",\n\t})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.PrimaryIP.Unassign(ctx, 123)\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nnetwork = client.networks.update(\n network=Network(id=123),\n expose_routes_to_vswitch=False,\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"new-name\",\n)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.primary_ips.unassign(\n primary_ip=PrimaryIP(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud network update $NETWORK --name new-name\nhcloud network expose-routes-to-vswitch --disable $NETWORK\nhcloud network add-label --overwrite $NETWORK \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud network remove-label $NETWORK \\\n \"environment\" \"example.com\" \"just-a-key\"" + "source": "hcloud primary-ip unassign $PRIMARYIP" } ] }, @@ -14320,22 +17597,25 @@ } ] }, - "/networks/{id}/actions": { + "/primary_ips/actions": { "get": { - "description": "Lists [Actions](#actions) for a [Network](#networks).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_actions_for_network", + "description": "Lists multiple [Actions](#actions).\n\nUse the provided URI parameters to modify the result.\n", + "operationId": "list_primary_ip_actions", "parameters": [ { - "description": "ID of the Network.", - "in": "path", + "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", + "in": "query", "name": "id", - "required": true, + "required": false, "schema": { - "description": "ID of the Network.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" + "items": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "type": "array" } }, { @@ -14414,49 +17694,162 @@ "200": { "content": { "application/json": { - "example": { - "actions": [ - { - "command": "add_subnet", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - ], - "meta": { - "pagination": { - "last_page": 1, - "next_page": null, - "page": 1, - "per_page": 25, - "previous_page": null, - "total_entries": 21 - } - } - }, "schema": { - "$ref": "#/components/schemas/list_actions_response" + "$ref": "#/components/schemas/list_actions_response" + } + } + }, + "description": "Response for listing [Actions](#actions)." + } + }, + "summary": "List Actions", + "tags": [ + "primary_ips" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.PrimaryIP.Action.All(ctx, hcloud.ActionListOpts{})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.primary_ips.actions.get_all()" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/primary_ips/actions/{id}": { + "get": { + "description": "Returns a single [Action](#actions).", + "operationId": "get_primary_ip_action", + "parameters": [ + { + "description": "ID of the Action", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_action_response" + } + } + }, + "description": "Response for getting a single [Action](#actions)." + } + }, + "summary": "Get an Action", + "tags": [ + "primary_ips" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.PrimaryIP.Action.GetByID(ctx, 123)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.primary_ips.actions.get_by_id(123)" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/server_types": { + "get": { + "description": "Gets all Server type objects.", + "operationId": "list_server_types", + "parameters": [ + { + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/list_server_types_response" } } }, - "description": "Response for listing [Actions](#actions)." + "description": "The `server_types` key in the reply contains an array of Server type objects with this structure." } }, - "summary": "List Actions for a Network", + "summary": "List Server Types", "tags": [ - "networks" + "server_types" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tserverTypes, err := client.ServerType.All(ctx)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nserver_types = client.server_types.get_all()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud server-type list" + } ] }, "servers": [ @@ -14465,31 +17858,18 @@ } ] }, - "/networks/{id}/actions/{action_id}": { + "/server_types/{id}": { "get": { - "description": "Returns a specific [Action](#actions) for a [Network](#networks).", - "operationId": "get_action_for_network", + "description": "Gets a specific Server type object.", + "operationId": "get_server_type", "parameters": [ { - "description": "ID of the Network.", + "description": "ID of the Server Type.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Network.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - } - }, - { - "description": "ID of the Action.", - "in": "path", - "name": "action_id", - "required": true, - "schema": { - "description": "ID of the Action.", + "description": "ID of the Server Type.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -14501,37 +17881,34 @@ "200": { "content": { "application/json": { - "example": { - "action": { - "command": "add_subnet", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - }, "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/get_server_type_response" } } }, - "description": "Response for getting an [Action](#actions)." + "description": "The `server_type` key in the reply contains a Server type object with this structure." } }, - "summary": "Get an Action for a Network", + "summary": "Get a Server Type", "tags": [ - "networks" + "server_types" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tserverType, _, err := client.ServerType.GetByID(ctx, 123)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nserver_type = client.server_types.get_by_id(123)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud server-type describe $SERVERTYPE" + } ] }, "servers": [ @@ -14540,209 +17917,155 @@ } ] }, - "/networks/{id}/actions/add_route": { - "post": { - "description": "Adds a route entry to a [Network](#networks).\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", - "operationId": "add_route_to_network", + "/servers": { + "get": { + "description": "Returns all existing Server objects.", + "operationId": "list_servers", "parameters": [ { - "description": "ID of the Network.", - "in": "path", - "name": "id", - "required": true, + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, "schema": { - "description": "ID of the Network.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" + "type": "string" } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/add_route_to_network_request" - } + }, + { + "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "in": "query", + "name": "label_selector", + "required": false, + "schema": { + "type": "string" } - } - }, - "responses": { - "201": { - "content": { - "application/json": { - "example": { - "action": { - "command": "add_route", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, - "schema": { - "$ref": "#/components/schemas/add_route_to_network_response" - } - } - }, - "description": "Response for adding a route to a [Network](#networks).\n\nThe `action` key contains an [Action](#actions) with command `add_route`.\n" - } - }, - "summary": "Add a route to a Network", - "tags": [ - "networks" - ], - "x-codeSamples": [ + }, { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.AddRoute(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkAddRouteOpts{\n\t\tRoute: hcloud.NetworkRoute{\n\t\t\tDestination: &net.IPNet{\n\t\t\t\tIP: net.ParseIP(\"10.100.1.0\"),\n\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t},\n\t\t\tGateway: net.ParseIP(\"10.0.1.1\"),\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "name", + "name:asc", + "name:desc", + "created", + "created:asc", + "created:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter resources by status. Can be used multiple times. The response will only\ncontain the resources with the specified status.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Server.", + "enum": [ + "running", + "initializing", + "starting", + "stopping", + "off", + "deleting", + "migrating", + "rebuilding", + "unknown" + ], + "type": "string" + }, + "type": "array" + } }, { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network, NetworkRoute\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.add_route(\n network=Network(id=123),\n route=NetworkRoute(\n destination=\"10.100.1.0/24\",\n gateway=\"10.0.1.1\",\n ),\n)\n\naction.wait_until_finished()" + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } }, { - "label": "CLI", - "lang": "Shell", - "source": "hcloud network add-route $NETWORK \\\n --destination 10.100.1.0/24 \\\n --gateway 10.0.1.1" - } - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/networks/{id}/actions/add_subnet": { - "post": { - "description": "Adds a new subnet to the [Network](#networks).\n\nIf the subnet `ip_range` is not provided, the first available `/24` IP range will be used.\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", - "operationId": "add_subnet_to_network", - "parameters": [ - { - "description": "ID of the Network.", - "in": "path", - "name": "id", - "required": true, + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, "schema": { - "description": "ID of the Network.", - "example": 42, + "default": 25, + "example": 25, "format": "int64", - "maximum": 9007199254740991, "type": "integer" } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/add_subnet_to_network_request" - } - } - } - }, "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "add_subnet", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/add_subnet_to_network_response" + "$ref": "#/components/schemas/list_servers_response" } } }, - "description": "Response for adding a subnet to a [Network](#networks).\n\nThe `action` key contains an [Action](#actions) with command `add_subnet`.\n" + "description": "A paged array of servers.", + "headers": { + "x-next": { + "description": "A link to the next page of responses.", + "schema": { + "type": "string" + } + } + } } }, - "summary": "Add a subnet to a Network", + "summary": "List Servers", "tags": [ - "networks" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.AddSubnet(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkAddSubnetOpts{\n\t\tSubnet: hcloud.NetworkSubnet{\n\t\t\tIPRange: &net.IPNet{\n\t\t\t\tIP: net.ParseIP(\"10.0.1.0\"),\n\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t},\n\t\t\tNetworkZone: hcloud.NetworkZoneEUCentral,\n\t\t\tType: hcloud.NetworkSubnetTypeCloud,\n\t\t\tVSwitchID: 1000,\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tservers, err := client.Server.All(ctx)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network, NetworkSubnet\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.add_subnet(\n network=Network(id=123),\n subnet=NetworkSubnet(\n ip_range=\"10.0.1.0/24\",\n network_zone=\"eu-central\",\n type=\"cloud\",\n vswitch_id=1000,\n ),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nservers = client.servers.get_all()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud network add-subnet $NETWORK \\\n --ip-range 10.0.1.0/24 \\\n --network-zone eu-central \\\n --type cloud \\\n --vswitch-id 1000" + "source": "hcloud server list" } ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/networks/{id}/actions/change_ip_range": { "post": { - "description": "Changes the IP range of a [Network](#networks).\n\nThe following restrictions apply to changing the IP range:\n- IP ranges can only be extended and never shrunk.\n- IPs can only be added to the end of the existing range, therefore only the netmask is allowed to be changed.\n\nTo update the routes on the connected [Servers](#servers), they need to be rebooted or the routes to be updated manually.\n\nFor example if the [Network](#networks) has a range of `10.0.0.0/16` to extend it the new range has to start with the IP `10.0.0.0` as well. The netmask `/16` can be changed to a smaller one then `16` therefore increasing the IP range. A valid entry would be `10.0.0.0/15`, `10.0.0.0/14` or `10.0.0.0/13` and so on.\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", - "operationId": "change_ip_range_of_network", - "parameters": [ - { - "description": "ID of the Network.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the Network.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - } - } - ], + "description": "Creates a new Server. Returns preliminary information about the Server as well as an Action that covers progress of creation.", + "operationId": "create_server", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/change_ip_range_of_network_request" + "$ref": "#/components/schemas/create_server_request" } } - } + }, + "description": "Please note that Server names must be unique per Project and valid hostnames as per RFC 1123 (i.e. may only contain letters, digits, periods, and dashes).\n\nFor `server_type` you can either use the ID as listed in `/server_types` or its name.\n\nFor `image` you can either use the ID as listed in `/images` or its name.\n\nIf you want to create the Server in a Location, you must set `location` to the ID or name as listed in `/locations`. This is the recommended way. You can be even more specific by setting `datacenter` to the ID or name as listed in `/datacenters`. However we only recommend this if you want to assign a specific Primary IP to the Server which is located in the specified Datacenter.\n\nSome properties like `start_after_create` or `automount` will trigger Actions after the Server is created. Those Actions are listed in the `next_actions` field in the response.\n\nFor accessing your Server we strongly recommend to use SSH keys by passing the respective key IDs in `ssh_keys`. If you do not specify any `ssh_keys` we will generate a root password for you and return it in the response.\n\nPlease note that provided user-data is stored in our systems. While we take measures to protect it we highly recommend that you don’t use it to store passwords or other sensitive information.\n\n#### Call specific error codes\n\n| Code | Description |\n|----------------------------------|------------------------------------------------------------|\n| `placement_error` | An error during the placement occurred |\n| `primary_ip_assigned` | The specified Primary IP is already assigned to a server |\n| `primary_ip_datacenter_mismatch` | The specified Primary IP is in a different datacenter |\n| `primary_ip_version_mismatch` | The specified Primary IP has the wrong IP Version |\n" }, "responses": { "201": { @@ -14750,51 +18073,228 @@ "application/json": { "example": { "action": { - "command": "change_ip_range", + "command": "create_server", "error": { "code": "action_failed", "message": "Action failed" }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, + "finished": null, + "id": 1, + "progress": 0, "resources": [ { - "id": 4711, - "type": "network" + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + }, + "next_actions": [ + { + "command": "start_server", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + ], + "root_password": "YItygq1v3GYjjMomLaKc", + "server": { + "backup_window": "22-02", + "created": "2016-01-30T23:50:00+00:00", + "datacenter": { + "description": "Falkenstein 1 DC 8", + "id": 1, + "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-dc8", + "server_types": { + "available": [ + 1, + 2, + 3 + ], + "available_for_migration": [ + 1, + 2, + 3 + ], + "supported": [ + 1, + 2, + 3 + ] + } + }, + "id": 42, + "image": { + "architecture": "x86", + "bound_to": null, + "created": "2016-01-30T23:50:00+00:00", + "created_from": { + "id": 1, + "name": "Server" + }, + "deleted": null, + "deprecated": "2018-02-28T00:00:00+00:00", + "description": "Ubuntu 20.04 Standard 64 bit", + "disk_size": 10, + "id": 4711, + "image_size": 2.3, + "labels": { + "key": "value" + }, + "name": "ubuntu-20.04", + "os_flavor": "ubuntu", + "os_version": "20.04", + "protection": { + "delete": false + }, + "rapid_deploy": false, + "status": "available", + "type": "snapshot" + }, + "included_traffic": 654321, + "ingoing_traffic": 123456, + "iso": { + "architecture": "x86", + "deprecation": { + "announced": "2018-02-28T00:00:00+00:00", + "unavailable_after": "2018-05-31T00:00:00+00:00" + }, + "description": "FreeBSD 11.0 x64", + "id": 4711, + "name": "FreeBSD-11.0-RELEASE-amd64-dvd1", + "type": "public" + }, + "labels": { + "key": "value" + }, + "load_balancers": [], + "locked": false, + "name": "my-server", + "outgoing_traffic": 123456, + "primary_disk_size": 50, + "private_net": [ + { + "alias_ips": [], + "ip": "10.0.0.2", + "mac_address": "86:00:ff:2a:7d:e1", + "network": 4711 } ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" + "protection": { + "delete": false, + "rebuild": false + }, + "public_net": { + "firewalls": [ + { + "id": 38, + "status": "applied" + } + ], + "floating_ips": [ + 478 + ], + "ipv4": { + "blocked": false, + "dns_ptr": "server01.example.com", + "ip": "1.2.3.4" + }, + "ipv6": { + "blocked": false, + "dns_ptr": [ + { + "dns_ptr": "server.example.com", + "ip": "2001:db8::1" + } + ], + "ip": "2001:db8::/64" + } + }, + "rescue_enabled": false, + "server_type": { + "architecture": "x86", + "cores": 2, + "cpu_type": "shared", + "deprecated": true, + "description": "CPX11", + "disk": 40, + "id": 1, + "memory": 2, + "name": "cpx11", + "prices": [ + { + "included_traffic": 21990232555520, + "location": "fsn1", + "price_hourly": { + "gross": "1.1900000000000000", + "net": "1.0000000000" + }, + "price_monthly": { + "gross": "1.1900000000000000", + "net": "1.0000000000" + }, + "price_per_tb_traffic": { + "gross": "1.1900000000000000", + "net": "1.0000000000" + } + } + ], + "storage_type": "local" + }, + "status": "initializing", + "volumes": [] } }, "schema": { - "$ref": "#/components/schemas/change_ip_range_of_network_response" + "$ref": "#/components/schemas/create_server_response" } } }, - "description": "Response for changing the [Networks](#networks) IP range.\n\nThe `action` key contains an [Action](#actions) with command `change_ip_range`.\n" + "description": "The `server` key in the reply contains a Server object with this structure." } }, - "summary": "Change IP range of a Network", + "summary": "Create a Server", "tags": [ - "networks" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.ChangeIPRange(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkChangeIPRangeOpts{\n\t\tIPRange: &net.IPNet{\n\t\t\tIP: net.ParseIP(\"10.0.0.0\"),\n\t\t\tMask: net.CIDRMask(16, 32),\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.Create(ctx, hcloud.ServerCreateOpts{\n\t\tAutomount: hcloud.Ptr(false),\n\t\tDatacenter: &hcloud.Datacenter{Name: \"nbg1-dc3\"},\n\t\tFirewalls: []*hcloud.ServerCreateFirewall{\n\t\t\t{\n\t\t\t\tFirewall: hcloud.Firewall{ID: 38},\n\t\t\t},\n\t\t},\n\t\tImage: &hcloud.Image{Name: \"ubuntu-20.04\"},\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tLocation: &hcloud.Location{Name: \"nbg1\"},\n\t\tName: \"my-server\",\n\t\tNetworks: []*hcloud.Network{\n\t\t\t{\n\t\t\t\tID: 456,\n\t\t\t},\n\t\t},\n\t\tPlacementGroup: &hcloud.PlacementGroup{ID: 1},\n\t\tPublicNet: &hcloud.ServerCreatePublicNet{\n\t\t\tEnableIPv4: false,\n\t\t\tEnableIPv6: false,\n\t\t\tIPv4: nil,\n\t\t\tIPv6: nil,\n\t\t},\n\t\tServerType: &hcloud.ServerType{Name: \"cx22\"},\n\t\tSSHKeys: []*hcloud.SSHKey{\n\t\t\t{\n\t\t\t\tName: \"my-ssh-key\",\n\t\t\t},\n\t\t},\n\t\tStartAfterCreate: hcloud.Ptr(true),\n\t\tUserData: \"#cloud-config\\nruncmd:\\n- [touch, /root/cloud-init-worked]\\n\",\n\t\tVolumes: []*hcloud.Volume{\n\t\t\t{\n\t\t\t\tID: 123,\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tserver := result.Server\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.change_ip_range(\n network=Network(id=123), ip_range=\"10.0.0.0/16\"\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall\nfrom hcloud.images import Image\nfrom hcloud.locations import Location\nfrom hcloud.networks import Network\nfrom hcloud.placement_groups import PlacementGroup\nfrom hcloud.server_types import ServerType\nfrom hcloud.servers import ServerCreatePublicNetwork\nfrom hcloud.ssh_keys import SSHKey\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.servers.create(\n automount=False,\n datacenter=\"nbg1-dc3\",\n firewalls=[Firewall(id=38)],\n image=Image(name=\"ubuntu-20.04\"),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n location=Location(name=\"nbg1\"),\n name=\"my-server\",\n networks=[Network(id=456)],\n placement_group=PlacementGroup(id=1),\n public_net=ServerCreatePublicNetwork(\n enable_ipv4=False,\n enable_ipv6=False,\n ipv4=None,\n ipv6=None,\n ),\n server_type=ServerType(name=\"cpx11\"),\n ssh_keys=[SSHKey(name=\"my-ssh-key\")],\n start_after_create=True,\n user_data=\"#cloud-config\\nruncmd:\\n- [touch, /root/cloud-init-worked]\\n\",\n volumes=[Volume(id=123)],\n)\n\nresponse.action.wait_until_finished()\n\nserver = response.server" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud network change-ip-range $NETWORK \\\n --ip-range 10.0.0.0/16" + "source": "hcloud server create \\\n --automount=false \\\n --datacenter nbg1-dc3 \\\n --firewall 38 \\\n --image ubuntu-20.04 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --location nbg1 \\\n --name my-server \\\n --network 456 \\\n --placement-group 1 \\\n --without-ipv4 \\\n --without-ipv6 \\\n --type cx22 \\\n --ssh-key my-ssh-key \\\n --start-after-create \\\n --volume 123 \\\n --user-data-from-file <(printf '#cloud-config\\nruncmd:\\n- [touch, /root/cloud-init-worked]\\n')" } ] }, @@ -14804,18 +18304,18 @@ } ] }, - "/networks/{id}/actions/change_protection": { - "post": { - "description": "Changes the protection settings of a [Network](#networks).\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", - "operationId": "change_network_protection", + "/servers/{id}": { + "delete": { + "description": "Deletes a Server.\n\nThis immediately removes the Server from your account, and it is no longer\naccessible. Any resources attached to the server (like Volumes, Primary IPs,\nFloating IPs, Firewalls, Placement Groups) are detached while the server is deleted.\n", + "operationId": "delete_server", "parameters": [ { - "description": "ID of the Network.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Network.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -14823,87 +18323,51 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/change_network_protection_request" - } - } - } - }, "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "change_protection", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - }, "schema": { - "$ref": "#/components/schemas/change_network_protection_response" + "$ref": "#/components/schemas/delete_server_response" } } }, - "description": "Response for changing the [Networks](#networks) protection.\n\nThe `action` key contains an [Action](#actions) with command `change_protection`.\n" + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Change Network Protection", + "summary": "Delete a Server", "tags": [ - "networks" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.ChangeProtection(ctx, &hcloud.Network{ID: 123},\n\t\thcloud.NetworkChangeProtectionOpts{Delete: hcloud.Ptr(true)})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.DeleteWithResult(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.change_protection(\n network=Network(id=123),\n delete=True,\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.delete(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud network enable-protection $NETWORK delete\nhcloud network disable-protection $NETWORK delete" + "source": "hcloud server delete $SERVER" } ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/networks/{id}/actions/delete_route": { - "post": { - "description": "Delete a route entry from a [Network](#networks).\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", - "operationId": "delete_route_from_network", + "get": { + "description": "Returns a specific Server object. The Server must exist inside the Project.", + "operationId": "get_server", "parameters": [ { - "description": "ID of the Network.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Network.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -14911,154 +18375,98 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/delete_route_from_network_request" - } - } - } - }, "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "delete_route", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/delete_route_from_network_response" + "$ref": "#/components/schemas/get_server_response" } } }, - "description": "Response for deleting a route from a [Network](#networks).\n\nThe `action` key contains an [Action](#actions) with command `delete_route`.\n" + "description": "The `server` key in the reply contains a Server object with this structure." } }, - "summary": "Delete a route from a Network", + "summary": "Get a Server", "tags": [ - "networks" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.DeleteRoute(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkDeleteRouteOpts{\n\t\tRoute: hcloud.NetworkRoute{\n\t\t\tDestination: &net.IPNet{\n\t\t\t\tIP: net.ParseIP(\"10.100.1.0\"),\n\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t},\n\t\t\tGateway: net.ParseIP(\"10.0.1.1\"),\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tserver, _, err := client.Server.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network, NetworkRoute\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.delete_route(\n network=Network(id=123),\n route=NetworkRoute(\n destination=\"10.100.1.0/24\",\n gateway=\"10.0.1.1\",\n ),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nserver = client.servers.get_by_id(123)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud network remove-route $NETWORK \\\n --destination 10.100.1.0/24 \\\n --gateway 10.0.1.1" + "source": "hcloud server describe $SERVER" } ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/networks/{id}/actions/delete_subnet": { - "post": { - "description": "Deletes a single subnet entry from a [Network](#networks).\n\nSubnets containing attached resources can not be deleted, they must be detached beforehand.\n\nIf a change is currently being performed on this [Network](#networks), a error response with code `conflict` will be returned.\n", - "operationId": "delete_subnet_from_network", + "put": { + "description": "Updates a Server. You can update a Server’s name and a Server’s labels.\n\nPlease note that Server names must be unique per Project and valid hostnames as per RFC 1123 (i.e. may only contain letters, digits, periods, and dashes).\n", + "operationId": "replace_server", "parameters": [ { - "description": "ID of the Network.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Network.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, - "type": "integer" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/delete_subnet_from_network_request" - } - } - } - }, - "responses": { - "201": { - "content": { - "application/json": { - "example": { - "action": { - "command": "delete_subnet", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/replace_server_request" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { "schema": { - "$ref": "#/components/schemas/delete_subnet_from_network_response" + "$ref": "#/components/schemas/replace_server_response" } } }, - "description": "Response for deleting a subnet from a [Network](#networks).\n\nThe `action` key contains an [Action](#actions) with command `delete_subnet`.\n" + "description": "The `server` key in the reply contains the updated Server." } }, - "summary": "Delete a subnet from a Network", + "summary": "Update a Server", "tags": [ - "networks" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.DeleteSubnet(ctx, &hcloud.Network{ID: 123}, hcloud.NetworkDeleteSubnetOpts{\n\t\tSubnet: hcloud.NetworkSubnet{\n\t\t\tIPRange: &net.IPNet{\n\t\t\t\tIP: net.ParseIP(\"10.0.1.0\"),\n\t\t\t\tMask: net.CIDRMask(24, 32),\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tserver, _, err := client.Server.Update(ctx, &hcloud.Server{ID: 123}, hcloud.ServerUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"my-server\",\n\t})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network, NetworkSubnet\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.delete_subnet(\n network=Network(id=123), subnet=NetworkSubnet(ip_range=\"10.0.1.0/24\")\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nserver = client.servers.update(\n server=Server(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-server\",\n)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud network remove-subnet $NETWORK \\\n --ip-range 10.0.1.0/24" + "source": "hcloud server update $SERVER --name \"my-server\"\nhcloud server add-label --overwrite $SERVER \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud server remove-label $SERVER \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] }, @@ -15068,25 +18476,23 @@ } ] }, - "/networks/actions": { + "/servers/{id}/actions": { "get": { - "description": "Lists multiple [Actions](#actions).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_network_actions", + "description": "Returns all Action objects for a Server. You can `sort` the results by using the sort URI parameter, and filter them with the `status` parameter.", + "operationId": "list_actions_for_server", "parameters": [ { - "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", - "in": "query", + "description": "ID of the Server", + "in": "path", "name": "id", - "required": false, + "required": true, "schema": { - "items": { - "description": "ID of the Action.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - }, - "type": "array" + "description": "ID of the Server. Limited to 52 bits to ensure compatability with JSON double precision floats.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "title": "Server ID", + "type": "integer" } }, { @@ -15165,28 +18571,211 @@ "200": { "content": { "application/json": { + "example": { + "actions": [ + { + "command": "start_server", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + ], + "meta": { + "pagination": { + "last_page": 1, + "next_page": null, + "page": 1, + "per_page": 25, + "previous_page": null, + "total_entries": 21 + } + } + }, "schema": { "$ref": "#/components/schemas/list_actions_response" } } }, - "description": "Response for listing [Actions](#actions)." + "description": "The `actions` key contains a list of Actions." } }, - "summary": "List Actions", + "summary": "List Actions for a Server", "tags": [ - "networks" + "servers" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/{id}/actions/{action_id}": { + "get": { + "description": "Returns a specific Action object for a Server.", + "operationId": "get_action_for_server", + "parameters": [ + { + "description": "ID of the Server.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Server.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + { + "description": "ID of the Action.", + "in": "path", + "name": "action_id", + "required": true, + "schema": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "action": { + "command": "start_server", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, + "schema": { + "$ref": "#/components/schemas/get_action_response" + } + } + }, + "description": "The `action` key in the reply has this structure." + } + }, + "summary": "Get an Action for a Server", + "tags": [ + "servers" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/{id}/actions/add_to_placement_group": { + "post": { + "description": "Adds a Server to a Placement Group.\n\nServer must be powered off for this command to succeed.\n\n#### Call specific error codes\n\n| Code | Description |\n|-------------------------------|----------------------------------------------------------------------|\n| `server_not_stopped` | The action requires a stopped server |\n", + "operationId": "add_server_to_placement_group", + "parameters": [ + { + "description": "ID of the Server.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Server.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/add_server_to_placement_group_request" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "example": { + "action": { + "command": "add_to_placement_group", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + }, + "schema": { + "$ref": "#/components/schemas/add_server_to_placement_group_response" + } + } + }, + "description": "The `action` key in the reply contains an Action object with this structure." + } + }, + "summary": "Add a Server to a Placement Group", + "tags": [ + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Network.Action.All(ctx, hcloud.ActionListOpts{})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.AddToPlacementGroup(ctx, &hcloud.Server{ID: 123}, &hcloud.PlacementGroup{ID: 1})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.networks.actions.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.placement_groups import PlacementGroup\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.add_to_placement_group(\n server=Server(id=123), placement_group=PlacementGroup(id=1)\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud server add-to-placement-group --placement-group 1 $SERVER" } ] }, @@ -15196,18 +18785,18 @@ } ] }, - "/networks/actions/{id}": { - "get": { - "description": "Returns a single [Action](#actions).", - "operationId": "get_network_action", + "/servers/{id}/actions/attach_iso": { + "post": { + "description": "Attaches an ISO to a Server. The Server will immediately see it as a new disk. An already attached ISO will automatically be detached before the new ISO is attached.\n\nServers with attached ISOs have a modified boot order: They will try to boot from the ISO first before falling back to hard disk.\n", + "operationId": "attach_iso_to_server", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Action.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -15215,32 +18804,66 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/attach_iso_to_server_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "attach_iso", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + }, "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/attach_iso_to_server_response" } } }, - "description": "Response for getting a single [Action](#actions)." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Get an Action", + "summary": "Attach an ISO to a Server", "tags": [ - "networks" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Network.Action.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.AttachISO(ctx, &hcloud.Server{ID: 123}, &hcloud.ISO{\n\t\tName: \"FreeBSD-11.0-RELEASE-amd64-dvd1\",\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.networks.actions.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.isos import Iso\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.attach_iso(\n server=Server(id=123), iso=Iso(name=\"FreeBSD-11.0-RELEASE-amd64-dvd1\")\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud server attach-iso $SERVER \"FreeBSD-11.0-RELEASE-amd64-dvd1\"" } ] }, @@ -15250,167 +18873,122 @@ } ] }, - "/placement_groups": { - "get": { - "description": "Returns all Placement Group objects.", - "operationId": "list_placement_groups", + "/servers/{id}/actions/attach_to_network": { + "post": { + "description": "Attaches a Server to a network. This will complement the fixed public Server interface by adding an additional ethernet interface to the Server which is connected to the specified network.\n\nThe Server will get an IP auto assigned from a subnet of type `server` in the same `network_zone`.\n\nUsing the `alias_ips` attribute you can also define one or more additional IPs to the Servers. Please note that you will have to configure these IPs by hand on your Server since only the primary IP will be given out by DHCP.\n\n**Call specific error codes**\n\n| Code | Description |\n|----------------------------------|-----------------------------------------------------------------------|\n| `server_already_attached` | The server is already attached to the network |\n| `ip_not_available` | The provided Network IP is not available |\n| `no_subnet_available` | No Subnet or IP is available for the Server within the network |\n| `networks_overlap` | The network IP range overlaps with one of the server networks |\n", + "operationId": "attach_server_to_network", "parameters": [ { - "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "name", - "name:asc", - "name:desc", - "created", - "created:asc", - "created:desc" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", - "in": "query", - "name": "name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", - "in": "query", - "name": "label_selector", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Filter resources by type. Can be used multiple times. The response will only\ncontain the resources with the specified type.\n", - "in": "query", - "name": "type", - "required": false, - "schema": { - "items": { - "description": "Type of Placement Group.\n", - "enum": [ - "spread" - ], - "example": "spread", - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "description": "ID of the Server.", + "in": "path", + "name": "id", + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Server.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/attach_server_to_network_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { "example": { - "meta": { - "pagination": { - "last_page": 1, - "next_page": null, - "page": 1, - "per_page": 25, - "previous_page": null, - "total_entries": 21 - } - }, - "placement_groups": [ - { - "created": "2019-01-08T12:10:00+00:00", - "id": 897, - "labels": { - "key": "value" + "action": { + "command": "attach_to_network", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" }, - "name": "my Placement Group", - "servers": [ - 4711, - 4712 - ], - "type": "spread" - } - ] + { + "id": 4711, + "type": "network" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } }, "schema": { - "$ref": "#/components/schemas/list_placement_groups_response" + "$ref": "#/components/schemas/attach_server_to_network_response" } } }, - "description": "The `placement_groups` key contains an array of Placement Group objects." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "List Placement Groups", + "summary": "Attach a Server to a Network", "tags": [ - "placement_groups" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tplacementGroups, err := client.PlacementGroup.All(ctx)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.AttachToNetwork(ctx, &hcloud.Server{ID: 123}, hcloud.ServerAttachToNetworkOpts{\n\t\tAliasIPs: []net.IP{\n\t\t\tnet.ParseIP(\"10.0.1.2\"),\n\t\t},\n\t\tIP: net.ParseIP(\"10.0.1.1\"),\n\t\tNetwork: &hcloud.Network{\n\t\t\tID: 4711,\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nplacement_groups = client.placement_groups.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.attach_to_network(\n server=Server(id=123),\n alias_ips=[\"10.0.1.2\"],\n ip=\"10.0.1.1\",\n network=Network(id=4711),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud placement-group list" + "source": "hcloud server attach-to-network $SERVER \\\n --alias-ips 10.0.1.2 \\\n --ip 10.0.1.1 \\\n --network 4711" } ] }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/{id}/actions/change_alias_ips": { "post": { - "description": "Creates a new Placement Group.\n", - "operationId": "create_placementgroup", + "description": "Changes the alias IPs of an already attached Network. Note that the existing aliases for the specified Network will be replaced with these provided in the request body. So if you want to add an alias IP, you have to provide the existing ones from the Network plus the new alias IP in the request body.", + "operationId": "change_alias_ips_of_network", + "parameters": [ + { + "description": "ID of the Server.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Server.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], "requestBody": { "content": { "application/json": { - "example": { - "name": "my Placement Group", - "type": "spread" - }, "schema": { - "$ref": "#/components/schemas/create_placementgroup_request" + "$ref": "#/components/schemas/change_alias_ips_of_network_request" } } } @@ -15420,44 +18998,56 @@ "content": { "application/json": { "example": { - "placement_group": { - "created": "2019-01-08T12:10:00+00:00", - "id": 897, - "labels": { - "key": "value" + "action": { + "command": "change_alias_ips", + "error": { + "code": "action_failed", + "message": "Action failed" }, - "name": "my Placement Group", - "servers": [], - "type": "spread" + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + }, + { + "id": 4711, + "type": "network" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/create_placementgroup_response" + "$ref": "#/components/schemas/change_alias_ips_of_network_response" } } }, - "description": "The `PlacementGroup` key contains the Placement Group that was just created." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Create a PlacementGroup", + "summary": "Change alias IPs of a Network", "tags": [ - "placement_groups" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.PlacementGroup.Create(ctx, hcloud.PlacementGroupCreateOpts{\n\t\tName: \"my Placement Group\",\n\t\tType: hcloud.PlacementGroupTypeSpread,\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tplacementGroup := result.PlacementGroup\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.ChangeAliasIPs(ctx, &hcloud.Server{ID: 123}, hcloud.ServerChangeAliasIPsOpts{\n\t\tAliasIPs: []net.IP{\n\t\t\tnet.ParseIP(\"10.0.1.2\"),\n\t\t},\n\t\tNetwork: &hcloud.Network{\n\t\t\tID: 4711,\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.placement_groups.create(\n name=\"my Placement Group\",\n type=\"spread\",\n)\n\nresponse.action.wait_until_finished()\n\nplacement_group = response.placement_group" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.change_alias_ips(\n server=Server(id=123),\n alias_ips=[\"10.0.1.2\"],\n network=Network(id=4711),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud placement-group create \\\n --name \"my Placement Group\" \\\n --type spread" + "source": "hcloud server change-alias-ips $SERVER \\\n --alias-ips 10.0.1.2 \\\n --network 4711" } ] }, @@ -15467,18 +19057,18 @@ } ] }, - "/placement_groups/{id}": { - "delete": { - "description": "Deletes a Placement Group.", - "operationId": "delete_placementgroup", + "/servers/{id}/actions/change_dns_ptr": { + "post": { + "description": "Changes the hostname that will appear when getting the hostname belonging to the primary IPs (IPv4 and IPv6) of this Server.\n\nFloating IPs assigned to the Server are not affected by this.\n", + "operationId": "change_reverse_dns_entry_for_this_server", "parameters": [ { - "description": "ID of the Placement Group.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Placement Group.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -15486,44 +19076,88 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_server_request" + } + } + }, + "description": "Select the IP address for which to change the DNS entry by passing `ip`. It can be either IPv4 or IPv6. The target hostname is set by passing `dns_ptr`." + }, "responses": { - "204": { - "description": "Placement Group deleted." + "201": { + "content": { + "application/json": { + "example": { + "action": { + "command": "change_dns_ptr", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + }, + "schema": { + "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_server_response" + } + } + }, + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Delete a PlacementGroup", + "summary": "Change reverse DNS entry for this Server", "tags": [ - "placement_groups" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.PlacementGroup.Delete(ctx, &hcloud.PlacementGroup{ID: 123})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.ChangeDNSPtr(ctx, &hcloud.Server{ID: 123}, \"1.2.3.4\", hcloud.Ptr(\"server01.example.com\"))\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.placement_groups import PlacementGroup\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.placement_groups.delete(\n placement_group=PlacementGroup(id=123),\n)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.change_dns_ptr(\n server=Server(id=123), dns_ptr=\"server01.example.com\", ip=\"1.2.3.4\"\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud placement-group delete $PLACEMENTGROUP" + "source": "hcloud server set-rdns $SERVER \\\n --ip 1.2.3.4 \\\n --hostname server01.example.com" } ] }, - "get": { - "description": "Gets a specific Placement Group object.", - "operationId": "get_placementgroup", + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/{id}/actions/change_protection": { + "post": { + "description": "Changes the protection configuration of the Server.", + "operationId": "change_server_protection", "parameters": [ { - "description": "ID of the Placement Group.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Placement Group.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -15531,66 +19165,87 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_server_protection_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { "example": { - "placement_group": { - "created": "2019-01-08T12:10:00+00:00", - "id": 897, - "labels": { - "key": "value" + "action": { + "command": "change_protection", + "error": { + "code": "action_failed", + "message": "Action failed" }, - "name": "my Placement Group", - "servers": [ - 4711, - 4712 + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" + } ], - "type": "spread" + "started": "2016-01-30T23:55:00+00:00", + "status": "success" } }, "schema": { - "$ref": "#/components/schemas/get_placementgroup_response" + "$ref": "#/components/schemas/change_server_protection_response" } } }, - "description": "The `placement_group` key contains a Placement Group object." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Get a PlacementGroup", + "summary": "Change Server Protection", "tags": [ - "placement_groups" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tplacementGroups, _, err := client.PlacementGroup.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.ChangeProtection(ctx, &hcloud.Server{ID: 123}, hcloud.ServerChangeProtectionOpts{\n\t\tDelete: hcloud.Ptr(true),\n\t\tRebuild: hcloud.Ptr(true),\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nplacement_group = client.placement_groups.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.change_dns_ptr(\n server=Server(id=123), dns_ptr=\"server01.example.com\", ip=\"1.2.3.4\"\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud placement-group describe $PLACEMENTGROUP" + "source": "hcloud server enable-protection $SERVER delete rebuild\nhcloud server disable-protection $SERVER delete rebuild" } ] }, - "put": { - "description": "Updates the Placement Group properties.\n\nNote: if the Placement Group object changes during the request, the response will be a “conflict” error.\n", - "operationId": "replace_placementgroup", + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/{id}/actions/change_type": { + "post": { + "description": "Changes the type (Cores, RAM and disk sizes) of a Server.\n\nServer must be powered off for this command to succeed.\n\nThis copies the content of its disk, and starts it again.\n\nYou can only migrate to Server types with the same `storage_type` and equal or bigger disks. Shrinking disks is not possible as it might destroy data.\n\nIf the disk gets upgraded, the Server type can not be downgraded any more. If you plan to downgrade the Server type, set `upgrade_disk` to `false`.\n\n#### Call specific error codes\n\n| Code | Description |\n|-------------------------------|----------------------------------------------------------------------|\n| `invalid_server_type` | The server type does not fit for the given server or is deprecated |\n| `server_not_stopped` | The action requires a stopped server |\n", + "operationId": "change_type_of_server", "parameters": [ { - "description": "ID of the Placement Group.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Placement Group.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -15602,91 +19257,62 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/replace_placementgroup_request" + "$ref": "#/components/schemas/change_type_of_server_request" } } } }, "responses": { - "200": { + "201": { "content": { "application/json": { "example": { - "placement_group": { - "created": "2019-01-08T12:10:00+00:00", - "id": 897, - "labels": { - "key": "value" + "action": { + "command": "change_server_type", + "error": { + "code": "action_failed", + "message": "Action failed" }, - "name": "my Placement Group", - "servers": [ - 4711, - 4712 + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + } ], - "type": "spread" + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/replace_placementgroup_response" + "$ref": "#/components/schemas/change_type_of_server_response" } } }, - "description": "The `certificate` key contains the Placement Group that was just updated." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Update a PlacementGroup", + "summary": "Change the Type of a Server", "tags": [ - "placement_groups" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tplacementGroup, _, err := client.PlacementGroup.Update(ctx, &hcloud.PlacementGroup{ID: 123}, hcloud.PlacementGroupUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"my Placement Group\",\n\t})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.ChangeType(ctx, &hcloud.Server{ID: 123}, hcloud.ServerChangeTypeOpts{\n\t\tServerType: &hcloud.ServerType{Name: \"cx22\"},\n\t\tUpgradeDisk: true,\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.placement_groups import PlacementGroup\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nplacement_group = client.placement_groups.update(\n placement_group=PlacementGroup(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my Placement Group\",\n)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud placement-group update $PLACEMENTGROUP --name \"my Placement Group\"\nhcloud placement-group add-label --overwrite $PLACEMENTGROUP \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud placement-group remove-label $PLACEMENTGROUP \\\n \"environment\" \"example.com\" \"just-a-key\"" - } - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/pricing": { - "get": { - "description": "Returns prices for all resources available on the platform. VAT and currency of the Project owner are used for calculations.\n\nBoth net and gross prices are included in the response.\n", - "operationId": "list_prices", - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/list_prices_response" - } - } - }, - "description": "The `pricing` key in the reply contains an pricing object with this structure." - } - }, - "summary": "Get all prices", - "tags": [ - "pricing" - ], - "x-codeSamples": [ + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.server_types import ServerType\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.change_type(\n server=Server(id=123),\n server_type=ServerType(name=\"cpx11\"),\n upgrade_disk=True,\n)\n\naction.wait_until_finished()" + }, { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tpricing, _, err := client.Pricing.Get(ctx)\n}" + "label": "CLI", + "lang": "Shell", + "source": "hcloud server change-type --keep-disk $SERVER cx22" } ] }, @@ -15696,130 +19322,148 @@ } ] }, - "/primary_ips": { - "get": { - "description": "List multiple [Primary IPs](#primary-ips).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_primary_ips", + "/servers/{id}/actions/create_image": { + "post": { + "description": "Creates an Image (snapshot) from a Server by copying the contents of its disks. This creates a snapshot of the current state of the disk and copies it into an Image. If the Server is currently running you must make sure that its disk content is consistent. Otherwise, the created Image may not be readable.\n\nTo make sure disk content is consistent, we recommend to shut down the Server prior to creating an Image.\n\nYou can either create a `backup` Image that is bound to the Server and therefore will be deleted when the Server is deleted, or you can create a `snapshot` Image which is completely independent of the Server it was created from and will survive Server deletion. Backup Images are only available when the backup option is enabled for the Server. Snapshot Images are billed on a per GB basis.\n", + "operationId": "create_image_from_server", "parameters": [ { - "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", - "in": "query", - "name": "name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", - "in": "query", - "name": "label_selector", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Filter results by IP address.", - "example": "127.0.0.1", - "in": "query", - "name": "ip", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "description": "ID of the Server.", + "in": "path", + "name": "id", + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Server.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } - }, - { - "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "created", - "created:asc", - "created:desc" - ], - "type": "string" - }, - "type": "array" - } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/create_image_from_server_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "create_image", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + }, + "image": { + "architecture": "x86", + "bound_to": null, + "created": "2016-01-30T23:50:00+00:00", + "created_from": { + "id": 1, + "name": "Server" + }, + "deleted": null, + "deprecated": "2018-02-28T00:00:00+00:00", + "description": "my image", + "disk_size": 10, + "id": 4711, + "image_size": 2.3, + "labels": { + "key": "value" + }, + "name": null, + "os_flavor": "ubuntu", + "os_version": "20.04", + "protection": { + "delete": false + }, + "rapid_deploy": false, + "status": "creating", + "type": "snapshot" + } + }, "schema": { - "$ref": "#/components/schemas/list_primary_ips_response" + "$ref": "#/components/schemas/create_image_from_server_response" } } }, - "description": "Response for listing [Primary IPs](#primary-ips)." + "description": "The `image` key in the reply contains an the created Image, which is an object with this structure.\n\nThe `action` key in the reply contains an Action object with this structure.\n" } }, - "summary": "List Primary IPs", + "summary": "Create Image from a Server", "tags": [ - "primary_ips" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tprimaryIPs, err := client.PrimaryIP.All(ctx)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.CreateImage(ctx, &hcloud.Server{ID: 123}, &hcloud.ServerCreateImageOpts{\n\t\tDescription: hcloud.Ptr(\"my image\"),\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tType: hcloud.ImageTypeSnapshot,\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\timage := result.Image\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nprimary_ips = client.primary_ips.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.create_image(\n server=Server(id=123),\n description=\"my image\",\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n type=\"snapshot\",\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud primary-ip list" + "source": "hcloud server create-image $SERVER \\\n --description \"my image\" \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --type snapshot" } ] }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/{id}/actions/detach_from_network": { "post": { - "description": "Create a new [Primary IP](#primary-ips).\n\nCan optionally be assigned to a resource by providing an `assignee_id` and `assignee_type`.\n\nIf not assigned to a resource the `datacenter` key needs to be provided. This can be either the ID or the name of the [Datacenter](#datacenters) this [Primary IP](#primary-ips) shall be created in.\n\nA [Primary IP](#primary-ips) can only be assigned to resource in the same [Datacenter](#datacenters) later on.\n\n#### Call specific error codes\n\n| Code | Description |\n|------------------------------ |------------------------------------------------------------------------- |\n| `server_not_stopped` | The specified [Server](#servers) is running, but needs to be powered off |\n| `server_has_ipv4` | The [Server](#servers) already has an ipv4 address |\n| `server_has_ipv6` | The [Server](#servers) already has an ipv6 address |\n", - "operationId": "create_primary_ip", + "description": "Detaches a Server from a network. The interface for this network will vanish.", + "operationId": "detach_server_from_network", + "parameters": [ + { + "description": "ID of the Server.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Server.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/create_primary_ip_request" + "$ref": "#/components/schemas/detach_server_from_network_request" } } - }, - "description": "Request Body for creating a new [Primary IP](#primary-ips).\n\nThe `datacenter` and `assignee_id`/`assignee_type` attributes are mutually exclusive.\n" + } }, "responses": { "201": { @@ -15827,7 +19471,7 @@ "application/json": { "example": { "action": { - "command": "create_primary_ip", + "command": "detach_from_network", "error": { "code": "action_failed", "message": "Action failed" @@ -15837,96 +19481,45 @@ "progress": 0, "resources": [ { - "id": 17, + "id": 42, "type": "server" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - }, - "primary_ip": { - "assignee_id": 17, - "assignee_type": "server", - "auto_delete": true, - "blocked": false, - "created": "2016-01-30T23:50:00+00:00", - "datacenter": { - "description": "Falkenstein DC Park 8", - "id": 42, - "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-dc8", - "server_types": { - "available": [ - 1, - 2, - 3 - ], - "available_for_migration": [ - 1, - 2, - 3 - ], - "supported": [ - 1, - 2, - 3 - ] - } - }, - "dns_ptr": [ - { - "dns_ptr": "server.example.com", - "ip": "2001:db8::1" - } - ], - "id": 42, - "ip": "2001:db8::/64", - "labels": { - "key": "value" - }, - "name": "my-ip", - "protection": { - "delete": false - }, - "type": "ipv6" + }, + { + "id": 4711, + "type": "network" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/create_primary_ip_response" + "$ref": "#/components/schemas/detach_server_from_network_response" } } }, - "description": "Response for creating a [Primary IP](#primary-ips).\n\nContains the newly created [Primary IP](#primary-ips).\n" + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Create a Primary IP", + "summary": "Detach a Server from a Network", "tags": [ - "primary_ips" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.PrimaryIP.Create(ctx, hcloud.PrimaryIPCreateOpts{\n\t\tAssigneeID: hcloud.Ptr(int64(17)),\n\t\tAssigneeType: \"server\",\n\t\tAutoDelete: hcloud.Ptr(false),\n\t\tDatacenter: \"fsn1-dc8\",\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"my-ip\",\n\t\tType: \"ipv4\",\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tprimaryIP := result.PrimaryIP\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.DetachFromNetwork(ctx, &hcloud.Server{ID: 123}, hcloud.ServerDetachFromNetworkOpts{\n\t\tNetwork: &hcloud.Network{ID: 4711},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.primary_ips.create(\n assignee_id=17,\n assignee_type=\"server\",\n auto_delete=False,\n datacenter=\"fsn1-dc8\",\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-resource\",\n type=\"ipv4\",\n)\n\nresponse.action.wait_until_finished()\n\nprimary_ip = response.primary_ip" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.detach_from_network(\n server=Server(id=123), network=Network(id=4711)\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud primary-ip create \\\n --assignee-id 17 \\\n --auto-delete=false \\\n --datacenter fsn1-dc8 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name my-ip \\\n --type ipv4" + "source": "hcloud server detach-from-network --network 4711 $SERVER" } ] }, @@ -15936,18 +19529,18 @@ } ] }, - "/primary_ips/{id}": { - "delete": { - "description": "Deletes a [Primary IP](#primary-ips).\n\nIf assigned to a [Server](#servers) the [Primary IP](#primary-ips) will be unassigned automatically. The [Server](#servers) must be powered off (status `off`) in order for this operation to succeed.\n", - "operationId": "delete_primary_ip", + "/servers/{id}/actions/detach_iso": { + "post": { + "description": "Detaches an ISO from a Server. In case no ISO Image is attached to the Server, the status of the returned Action is immediately set to `success`.", + "operationId": "detach_iso_from_server", "parameters": [ { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -15956,43 +19549,77 @@ } ], "responses": { - "204": { - "description": "[Primary IP](#primary-ips) deletion succeeded." + "201": { + "content": { + "application/json": { + "example": { + "action": { + "command": "detach_iso", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + }, + "schema": { + "$ref": "#/components/schemas/detach_iso_from_server_response" + } + } + }, + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Delete a Primary IP", + "summary": "Detach an ISO from a Server", "tags": [ - "primary_ips" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.PrimaryIP.Delete(ctx, &hcloud.PrimaryIP{ID: 123})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.DetachISO(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.primary_ips.delete(\n primary_ip=PrimaryIP(id=123),\n)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.detach_iso(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud primary-ip delete $PRIMARYIP" + "source": "hcloud server detach-iso $SERVER" } ] }, - "get": { - "description": "Returns a [Primary IP](#primary-ips).", - "operationId": "get_primary_ip", + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/{id}/actions/disable_backup": { + "post": { + "description": "Disables the automatic backup option and deletes all existing Backups for a Server. No more additional charges for backups will be made.\n\nCaution: This immediately removes all existing backups for the Server!\n", + "operationId": "disable_backups_for_server", "parameters": [ { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -16001,50 +19628,77 @@ } ], "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "disable_backup", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, "schema": { - "$ref": "#/components/schemas/get_primary_ip_response" + "$ref": "#/components/schemas/disable_backups_for_server_response" } } }, - "description": "The `primary_ip` key contains the [Primary IP](#primary-ips)." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Get a Primary IP", + "summary": "Disable Backups for a Server", "tags": [ - "primary_ips" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tprimaryIP, _, err := client.PrimaryIP.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.DisableBackup(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nprimary_ip = client.primary_ips.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.disable_backup(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud primary-ip describe $PRIMARYIP" + "source": "hcloud server disable-backup $SERVER" } ] }, - "put": { - "description": "Update a [Primary IP](#primary-ips).\n\nIf another change is concurrently performed on this [Primary IP](#primary-ips), a error response with code `conflict` will be returned.\n", - "operationId": "replace_primary_ip", + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/{id}/actions/disable_rescue": { + "post": { + "description": "Disables the Hetzner Rescue System for a Server. This makes a Server start from its disks on next reboot.\n\nRescue Mode is automatically disabled when you first boot into it or if you do not use it for 60 minutes.\n\nDisabling rescue mode will not reboot your Server — you will have to do this yourself.\n", + "operationId": "disable_rescue_mode_for_server", "parameters": [ { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -16052,46 +19706,57 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/replace_primary_ip_request" - } - } - } - }, "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "disable_rescue", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + }, "schema": { - "$ref": "#/components/schemas/replace_primary_ip_response" + "$ref": "#/components/schemas/disable_rescue_mode_for_server_response" } } }, - "description": "The `primary_ip` key contains the updated [Primary IP](#primary-ips)." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Update a Primary IP", + "summary": "Disable Rescue Mode for a Server", "tags": [ - "primary_ips" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tprimaryIP, _, err := client.PrimaryIP.Update(ctx, &hcloud.PrimaryIP{ID: 123}, hcloud.PrimaryIPUpdateOpts{\n\t\tAutoDelete: hcloud.Ptr(true),\n\t\tLabels: hcloud.Ptr(map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t}),\n\t\tName: \"my-ip\",\n\t})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.DisableRescue(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nprimary_ip = client.primary_ips.update(\n primary_ip=PrimaryIP(id=123),\n auto_delete=True,\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-resource\",\n)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.disable_rescue(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud primary-ip update $PRIMARYIP \\\n --auto-delete=false \\\n --name \"new-name\"\nhcloud primary-ip add-label --overwrite $PRIMARYIP \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud primary-ip remove-label $PRIMARYIP \\\n \"environment\" \"example.com\" \"just-a-key\"" + "source": "hcloud server disable-rescue $SERVER" } ] }, @@ -16101,18 +19766,18 @@ } ] }, - "/primary_ips/{id}/actions/assign": { + "/servers/{id}/actions/enable_backup": { "post": { - "description": "Assign a [Primary IP](#primary-ips) to a resource.\n\nA [Server](#servers) can only have one [Primary IP](#primary-ips) of type `ipv4` and one of type `ipv6` assigned. If you need more IPs use [Floating IPs](#floating-ips).\n\nA [Server](#servers) must be powered off (status `off`) in order for this operation to succeed.\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|------------------------------ |--------------------------------------------------------------------------------- |\n| `server_not_stopped` | The [Server](#servers) is running, but needs to be powered off |\n| `primary_ip_already_assigned` | [Primary IP](#primary-ips) is already assigned to a different [Server](#servers) |\n| `server_has_ipv4` | The [Server](#servers) already has an IPv4 address |\n| `server_has_ipv6` | The [Server](#servers) already has an IPv6 address |\n", - "operationId": "assign_primary_ip_to_resource", + "description": "Enables and configures the automatic daily backup option for the Server. Enabling automatic backups will increase the price of the Server by 20%. In return, you will get seven slots where Images of type backup can be stored.\n\nBackups are automatically created daily.\n", + "operationId": "enable_and_configure_backups_for_server", "parameters": [ { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -16120,70 +19785,57 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/assign_primary_ip_to_resource_request" - } - } - } - }, "responses": { "201": { "content": { "application/json": { "example": { "action": { - "command": "assign_primary_ip", + "command": "enable_backup", "error": { "code": "action_failed", "message": "Action failed" }, - "finished": null, + "finished": "2016-01-30T23:56:00+00:00", "id": 13, - "progress": 0, + "progress": 100, "resources": [ { "id": 42, "type": "server" - }, - { - "id": 4711, - "type": "primary_ip" } ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" + "started": "2016-01-30T23:55:00+00:00", + "status": "success" } }, "schema": { - "$ref": "#/components/schemas/assign_primary_ip_to_resource_response" + "$ref": "#/components/schemas/enable_and_configure_backups_for_server_response" } } }, - "description": "Response for assigning a [Primary IP](#primary-ips).\n\nContains an [Action](#actions) of type `assign_primary_ip`.\n" + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Assign a Primary IP to a resource", + "summary": "Enable and Configure Backups for a Server", "tags": [ - "primary_ips" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.PrimaryIP.Assign(ctx, hcloud.PrimaryIPAssignOpts{\n\t\tID: 123,\n\t\tAssigneeID: 4711,\n\t\tAssigneeType: \"server\",\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.EnableBackup(ctx, &hcloud.Server{ID: 123}, \"\")\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.primary_ips.assign(\n primary_ip=PrimaryIP(id=123),\n assignee_id=4711,\n assignee_type=\"server\",\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.enable_backup(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud primary-ip assign --server 4711 $PRIMARYIP" + "source": "hcloud server enable-backup $SERVER" } ] }, @@ -16193,18 +19845,18 @@ } ] }, - "/primary_ips/{id}/actions/change_dns_ptr": { + "/servers/{id}/actions/enable_rescue": { "post": { - "description": "Change the reverse DNS records for this [Primary IP](#primary-ips).\n\nAllows to modify the PTR records set for the IP address.\n", - "operationId": "change_reverse_dns_records_for_primary_ip", + "description": "Enable the Hetzner Rescue System for this Server. The next time a Server with enabled rescue mode boots it will start a special minimal Linux distribution designed for repair and reinstall.\n\nIn case a Server cannot boot on its own you can use this to access a Server’s disks.\n\nRescue Mode is automatically disabled when you first boot into it or if you do not use it for 60 minutes.\n\nEnabling rescue mode will not [reboot](https://docs.hetzner.cloud/#server-actions-soft-reboot-a-server) your Server — you will have to do this yourself.\n", + "operationId": "enable_rescue_mode_for_server", "parameters": [ { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -16216,11 +19868,10 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/change_reverse_dns_records_for_primary_ip_request" + "$ref": "#/components/schemas/enable_rescue_mode_for_server_request" } } - }, - "description": "The `ip` attributes specifies for which IP address the record is set. For IPv4 addresses this must be the exact address of the [Primary IP](#primary-ips). For IPv6 addresses this must be a single address within the `/64` subnet of the [Primary IP](#primary-ips).\n\nThe `dns_ptr` attribute specifies the hostname used for the IP address.\n\nFor IPv6 [Floating IPs](#floating-ips) up to 100 entries can be created.\n" + } }, "responses": { "201": { @@ -16228,7 +19879,7 @@ "application/json": { "example": { "action": { - "command": "change_dns_ptr", + "command": "enable_rescue", "error": { "code": "action_failed", "message": "Action failed" @@ -16238,41 +19889,42 @@ "progress": 100, "resources": [ { - "id": 4711, - "type": "primary_ip" + "id": 42, + "type": "server" } ], "started": "2016-01-30T23:55:00+00:00", "status": "success" - } + }, + "root_password": "zCWbFhnu950dUTko5f40" }, "schema": { - "$ref": "#/components/schemas/change_reverse_dns_records_for_primary_ip_response" + "$ref": "#/components/schemas/enable_rescue_mode_for_server_response" } } }, - "description": "Response for changing a [Primary IPs](#primary-ips) DNS pointer.\n\nContains an [Action](#actions) of type `change_dns_ptr`.\n" + "description": "The `root_password` key in the reply contains the root password that can be used to access the booted rescue system.\n\nThe `action` key in the reply contains an Action object with this structure.\n" } }, - "summary": "Change reverse DNS records for a Primary IP", + "summary": "Enable Rescue Mode for a Server", "tags": [ - "primary_ips" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.PrimaryIP.ChangeDNSPtr(ctx, hcloud.PrimaryIPChangeDNSPtrOpts{\n\t\tID: 123,\n\t\tDNSPtr: \"server02.example.com\",\n\t\tIP: \"1.2.3.4\",\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.EnableRescue(ctx, &hcloud.Server{ID: 123}, hcloud.ServerEnableRescueOpts{\n\t\tSSHKeys: []*hcloud.SSHKey{{\n\t\t\tID: 2323,\n\t\t}},\n\t\tType: hcloud.ServerRescueTypeLinux64,\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\trootPassword := result.RootPassword\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.primary_ips.change_dns_ptr(\n primary_ip=PrimaryIP(id=123),\n dns_ptr=\"server.example.com\",\n ip=\"2001:db8::1\",\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\nfrom hcloud.ssh_keys import SSHKey\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.enable_rescue(\n server=Server(id=123),\n ssh_keys=[SSHKey(id=2323)],\n type=\"linux64\",\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud primary-ip set-rdns $PRIMARYIP \\\n --ip 1.2.3.4 \\\n --hostname server02.example.com" + "source": "hcloud server enable-rescue $SERVER" } ] }, @@ -16282,18 +19934,18 @@ } ] }, - "/primary_ips/{id}/actions/change_protection": { + "/servers/{id}/actions/poweroff": { "post": { - "description": "Changes the protection configuration of a [Primary IP](#primary-ips).\n\nA [Primary IPs](#primary-ips) deletion protection can only be enabled if its `auto_delete` property is set to `false`.\n", - "operationId": "change_primary_ip_protection", + "description": "Cuts power to the Server. This forcefully stops it without giving the Server operating system time to gracefully stop. May lead to data loss, equivalent to pulling the power cord. Power off should only be used when shutdown does not work.", + "operationId": "power_off_server", "parameters": [ { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -16301,66 +19953,57 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/change_primary_ip_protection_request" - } - } - } - }, "responses": { "201": { "content": { "application/json": { "example": { "action": { - "command": "change_protection", + "command": "stop_server", "error": { "code": "action_failed", "message": "Action failed" }, - "finished": "2016-01-30T23:56:00+00:00", + "finished": null, "id": 13, - "progress": 100, + "progress": 0, "resources": [ { - "id": 4711, - "type": "primary_ip" + "id": 42, + "type": "server" } ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/change_primary_ip_protection_response" + "$ref": "#/components/schemas/power_off_server_response" } } }, - "description": "Response for changing a [Primary IPs](#primary-ips) protection settings.\n\nContains an [Action](#actions) of type `change_protection`.\n" + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Change Primary IP Protection", + "summary": "Power off a Server", "tags": [ - "primary_ips" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.PrimaryIP.ChangeProtection(ctx, hcloud.PrimaryIPChangeProtectionOpts{\n\t\tID: 123,\n\t\tDelete: true,\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Poweroff(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.primary_ips.change_protection(\n primary_ip=PrimaryIP(id=123),\n delete=False,\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.power_off(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud primary-ip enable-protection $PRIMARYIP delete\nhcloud primary-ip disable-protection $PRIMARYIP delete" + "source": "hcloud server poweroff $SERVER" } ] }, @@ -16370,18 +20013,18 @@ } ] }, - "/primary_ips/{id}/actions/unassign": { + "/servers/{id}/actions/poweron": { "post": { - "description": "Unassign a [Primary IP](#primary-ips) from a resource.\n\nA [Server](#servers) must be powered off (status `off`) in order for this operation to succeed.\n\nA [Server](#server) requires at least one network interface (public or private) to be powered on.\n\n#### Error Codes specific to this Call\n\n| Code | Description |\n|---------------------------------- |-------------------------------------------------------------- |\n| `server_not_stopped` | The [Server](#server) is running, but needs to be powered off |\n| `server_is_load_balancer_target` | The [Server](#server) IPv4 address is a loadbalancer target |\n", - "operationId": "unassign_primary_ip_from_resource", + "description": "Starts a Server by turning its power on.", + "operationId": "power_on_server", "parameters": [ { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Primary IP.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -16395,7 +20038,7 @@ "application/json": { "example": { "action": { - "command": "unassign_primary_ip", + "command": "start_server", "error": { "code": "action_failed", "message": "Action failed" @@ -16407,10 +20050,6 @@ { "id": 42, "type": "server" - }, - { - "id": 4711, - "type": "primary_ip" } ], "started": "2016-01-30T23:50:00+00:00", @@ -16418,32 +20057,32 @@ } }, "schema": { - "$ref": "#/components/schemas/unassign_primary_ip_from_resource_response" + "$ref": "#/components/schemas/power_on_server_response" } } }, - "description": "Response for unassigning a [Primary IP](#primary-ips).\n\nContains an [Action](#actions) of type `unassign_primary_ip`.\n" + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Unassign a Primary IP from a resource", + "summary": "Power on a Server", "tags": [ - "primary_ips" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.PrimaryIP.Unassign(ctx, 123)\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Poweron(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.primary_ips.unassign(\n primary_ip=PrimaryIP(id=123),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.power_on(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud primary-ip unassign $PRIMARYIP" + "source": "hcloud server poweron $SERVER" } ] }, @@ -16453,125 +20092,76 @@ } ] }, - "/primary_ips/actions": { - "get": { - "description": "Lists multiple [Actions](#actions).\n\nUse the provided URI parameters to modify the result.\n", - "operationId": "list_primary_ip_actions", + "/servers/{id}/actions/reboot": { + "post": { + "description": "Reboots a Server gracefully by sending an ACPI request. The Server operating system must support ACPI and react to the request, otherwise the Server will not reboot.", + "operationId": "soft_reboot_server", "parameters": [ { - "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", - "in": "query", + "description": "ID of the Server.", + "in": "path", "name": "id", - "required": false, - "schema": { - "items": { - "description": "ID of the Action.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - }, - "type": "array" - } - }, - { - "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "command", - "command:asc", - "command:desc", - "status", - "status:asc", - "status:desc", - "started", - "started:asc", - "started:desc", - "finished", - "finished:asc", - "finished:desc" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", - "in": "query", - "name": "status", - "required": false, - "schema": { - "items": { - "description": "Status of the Action.", - "enum": [ - "running", - "success", - "error" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Server.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "reboot_server", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + }, "schema": { - "$ref": "#/components/schemas/list_actions_response" + "$ref": "#/components/schemas/soft_reboot_server_response" } } }, - "description": "Response for listing [Actions](#actions)." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "List Actions", + "summary": "Soft-reboot a Server", "tags": [ - "primary_ips" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.PrimaryIP.Action.All(ctx, hcloud.ActionListOpts{})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Reboot(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.primary_ips.actions.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.reboot(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud server reboot $SERVER" } ] }, @@ -16581,18 +20171,18 @@ } ] }, - "/primary_ips/actions/{id}": { - "get": { - "description": "Returns a single [Action](#actions).", - "operationId": "get_primary_ip_action", + "/servers/{id}/actions/rebuild": { + "post": { + "description": "Rebuilds a Server overwriting its disk with the content of an Image, thereby **destroying all data** on the target Server\n\nThe Image can either be one you have created earlier (`backup` or `snapshot` Image) or it can be a completely fresh `system` Image provided by us. You can get a list of all available Images with `GET /images`.\n\nYour Server will automatically be powered off before the rebuild command executes.\n", + "operationId": "rebuild_server_from_image", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Action.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -16600,32 +20190,68 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/rebuild_server_from_image_request" + } + } + }, + "description": "To select which Image to rebuild from you can either pass an ID or a name as the `image` argument. Passing a name only works for `system` Images since the other Image types do not have a name set." + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "rebuild_server", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + }, + "root_password": null + }, "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/rebuild_server_from_image_response" } } }, - "description": "Response for getting a single [Action](#actions)." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Get an Action", + "summary": "Rebuild a Server from an Image", "tags": [ - "primary_ips" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.PrimaryIP.Action.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.RebuildWithResult(ctx, &hcloud.Server{ID: 123}, hcloud.ServerRebuildOpts{\n\t\tImage: &hcloud.Image{Name: \"ubuntu-20.04\"},\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\trootPassword := result.RootPassword\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.primary_ips.actions.get_by_id(123)" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.images import Image\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.rebuild(server=Server(id=123), image=Image(name=\"ubuntu-20.04\"))\n\naction.wait_until_finished()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud server rebuild --image ubuntu-20.04 $SERVER" } ] }, @@ -16635,76 +20261,76 @@ } ] }, - "/server_types": { - "get": { - "description": "Gets all Server type objects.", - "operationId": "list_server_types", + "/servers/{id}/actions/remove_from_placement_group": { + "post": { + "description": "Removes a Server from a Placement Group.\n", + "operationId": "remove_from_placement_group", "parameters": [ { - "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", - "in": "query", - "name": "name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "description": "ID of the Server.", + "in": "path", + "name": "id", + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Server.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "remove_from_placement_group", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + }, "schema": { - "$ref": "#/components/schemas/list_server_types_response" + "$ref": "#/components/schemas/remove_from_placement_group_response" } } }, - "description": "The `server_types` key in the reply contains an array of Server type objects with this structure." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "List Server Types", + "summary": "Remove from Placement Group", "tags": [ - "server_types" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tserverTypes, err := client.ServerType.All(ctx)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.RemoveFromPlacementGroup(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nserver_types = client.server_types.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.remove_from_placement_group(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server-type list" + "source": "hcloud server remove-from-placement-group $SERVER" } ] }, @@ -16714,18 +20340,18 @@ } ] }, - "/server_types/{id}": { - "get": { - "description": "Gets a specific Server type object.", - "operationId": "get_server_type", + "/servers/{id}/actions/request_console": { + "post": { + "description": "Requests credentials for remote access via VNC over websocket to keyboard, monitor, and mouse for a Server. The provided URL is valid for 1 minute, after this period a new url needs to be created to connect to the Server. How long the connection is open after the initial connect is not subject to this timeout.", + "operationId": "request_console_for_server", "parameters": [ { - "description": "ID of the Server Type.", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server Type.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -16734,161 +20360,119 @@ } ], "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "request_console", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + }, + "password": "9MQaTg2VAGI0FIpc10k3UpRXcHj2wQ6x", + "wss_url": "wss://console.hetzner.cloud/?server_id=1&token=3db32d15-af2f-459c-8bf8-dee1fd05f49c" + }, "schema": { - "$ref": "#/components/schemas/get_server_type_response" + "$ref": "#/components/schemas/request_console_for_server_response" } } }, - "description": "The `server_type` key in the reply contains a Server type object with this structure." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Get a Server Type", + "summary": "Request Console for a Server", "tags": [ - "server_types" + "servers" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tserverType, _, err := client.ServerType.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.RequestConsole(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\twssUrl, password := result.WSSURL, result.Password\n}" }, { "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nserver_type = client.server_types.get_by_id(123)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server-type describe $SERVERTYPE" - } - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/servers": { - "get": { - "description": "Returns all existing Server objects.", - "operationId": "list_servers", - "parameters": [ - { - "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", - "in": "query", - "name": "name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", - "in": "query", - "name": "label_selector", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "name", - "name:asc", - "name:desc", - "created", - "created:asc", - "created:desc" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter resources by status. Can be used multiple times. The response will only\ncontain the resources with the specified status.\n", - "in": "query", - "name": "status", - "required": false, - "schema": { - "items": { - "description": "Status of the Server.", - "enum": [ - "running", - "initializing", - "starting", - "stopping", - "off", - "deleting", - "migrating", - "rebuilding", - "unknown" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.servers.request_console(\n server=Server(id=123),\n)\n\nresponse.action.wait_until_finished()\n\nwss_url, password = response.wss_url, response.password" }, { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "label": "CLI", + "lang": "Shell", + "source": "hcloud server request-console $SERVER" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/{id}/actions/reset": { + "post": { + "description": "Cuts power to a Server and starts it again. This forcefully stops it without giving the Server operating system time to gracefully stop. This may lead to data loss, it’s equivalent to pulling the power cord and plugging it in again. Reset should only be used when reboot does not work.", + "operationId": "reset_server", + "parameters": [ + { + "description": "ID of the Server.", + "in": "path", + "name": "id", + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Server.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], "responses": { - "200": { + "201": { "content": { "application/json": { + "example": { + "action": { + "command": "reset_server", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + }, "schema": { - "$ref": "#/components/schemas/list_servers_response" + "$ref": "#/components/schemas/reset_server_response" } } }, - "description": "A paged array of servers.", - "headers": { - "x-next": { - "description": "A link to the next page of responses.", - "schema": { - "type": "string" - } - } - } + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "List Servers", + "summary": "Reset a Server", "tags": [ "servers" ], @@ -16896,46 +20480,58 @@ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tservers, err := client.Server.All(ctx)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Reset(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nservers = client.servers.get_all()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.reset(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server list" + "source": "hcloud server reset $SERVER" } ] }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/{id}/actions/reset_password": { "post": { - "description": "Creates a new Server. Returns preliminary information about the Server as well as an Action that covers progress of creation.", - "operationId": "create_server", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/create_server_request" - } + "description": "Resets the root password. Only works for Linux systems that are running the qemu guest agent. Server must be powered on (status `running`) in order for this operation to succeed.\n\nThis will generate a new password for this Server and return it.\n\nIf this does not succeed you can use the rescue system to netboot the Server and manually change your Server password by hand.\n", + "operationId": "reset_root_password_of_server", + "parameters": [ + { + "description": "ID of the Server.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Server.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" } - }, - "description": "Please note that Server names must be unique per Project and valid hostnames as per RFC 1123 (i.e. may only contain letters, digits, periods, and dashes).\n\nFor `server_type` you can either use the ID as listed in `/server_types` or its name.\n\nFor `image` you can either use the ID as listed in `/images` or its name.\n\nIf you want to create the Server in a Location, you must set `location` to the ID or name as listed in `/locations`. This is the recommended way. You can be even more specific by setting `datacenter` to the ID or name as listed in `/datacenters`. However we only recommend this if you want to assign a specific Primary IP to the Server which is located in the specified Datacenter.\n\nSome properties like `start_after_create` or `automount` will trigger Actions after the Server is created. Those Actions are listed in the `next_actions` field in the response.\n\nFor accessing your Server we strongly recommend to use SSH keys by passing the respective key IDs in `ssh_keys`. If you do not specify any `ssh_keys` we will generate a root password for you and return it in the response.\n\nPlease note that provided user-data is stored in our systems. While we take measures to protect it we highly recommend that you don’t use it to store passwords or other sensitive information.\n\n#### Call specific error codes\n\n| Code | Description |\n|----------------------------------|------------------------------------------------------------|\n| `placement_error` | An error during the placement occurred |\n| `primary_ip_assigned` | The specified Primary IP is already assigned to a server |\n| `primary_ip_datacenter_mismatch` | The specified Primary IP is in a different datacenter |\n| `primary_ip_version_mismatch` | The specified Primary IP has the wrong IP Version |\n" - }, + } + ], "responses": { "201": { "content": { "application/json": { "example": { "action": { - "command": "create_server", + "command": "reset_password", "error": { "code": "action_failed", "message": "Action failed" }, "finished": null, - "id": 1, + "id": 13, "progress": 0, "resources": [ { @@ -16946,193 +20542,96 @@ "started": "2016-01-30T23:50:00+00:00", "status": "running" }, - "next_actions": [ - { - "command": "start_server", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - ], - "root_password": "YItygq1v3GYjjMomLaKc", - "server": { - "backup_window": "22-02", - "created": "2016-01-30T23:50:00+00:00", - "datacenter": { - "description": "Falkenstein 1 DC 8", - "id": 1, - "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-dc8", - "server_types": { - "available": [ - 1, - 2, - 3 - ], - "available_for_migration": [ - 1, - 2, - 3 - ], - "supported": [ - 1, - 2, - 3 - ] - } - }, - "id": 42, - "image": { - "architecture": "x86", - "bound_to": null, - "created": "2016-01-30T23:50:00+00:00", - "created_from": { - "id": 1, - "name": "Server" - }, - "deleted": null, - "deprecated": "2018-02-28T00:00:00+00:00", - "description": "Ubuntu 20.04 Standard 64 bit", - "disk_size": 10, - "id": 4711, - "image_size": 2.3, - "labels": { - "key": "value" - }, - "name": "ubuntu-20.04", - "os_flavor": "ubuntu", - "os_version": "20.04", - "protection": { - "delete": false - }, - "rapid_deploy": false, - "status": "available", - "type": "snapshot" - }, - "included_traffic": 654321, - "ingoing_traffic": 123456, - "iso": { - "architecture": "x86", - "deprecation": { - "announced": "2018-02-28T00:00:00+00:00", - "unavailable_after": "2018-05-31T00:00:00+00:00" - }, - "description": "FreeBSD 11.0 x64", - "id": 4711, - "name": "FreeBSD-11.0-RELEASE-amd64-dvd1", - "type": "public" - }, - "labels": { - "key": "value" + "root_password": "zCWbFhnu950dUTko5f40" + }, + "schema": { + "$ref": "#/components/schemas/reset_root_password_of_server_response" + } + } + }, + "description": "The `root_password` key in the reply contains the new root password that will be active if the Action succeeds.\n\nThe `action` key in the reply contains an Action object with this structure.\n" + } + }, + "summary": "Reset root Password of a Server", + "tags": [ + "servers" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.ResetPassword(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\trootPassword := result.RootPassword\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.servers.reset_password(\n server=Server(id=123),\n)\n\nresponse.action.wait_until_finished()\n\nroot_password = response.root_password" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud server reset-password $SERVER" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/{id}/actions/shutdown": { + "post": { + "description": "Shuts down a Server gracefully by sending an ACPI shutdown request. The Server operating system must support ACPI\nand react to the request, otherwise the Server will not shut down. Please note that the `action` status in this case\nonly reflects whether the action was sent to the server. It does not mean that the server actually shut down\nsuccessfully. If you need to ensure that the server is off, use the `poweroff` action.\n", + "operationId": "shutdown_server", + "parameters": [ + { + "description": "ID of the Server.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Server.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "201": { + "content": { + "application/json": { + "example": { + "action": { + "command": "shutdown_server", + "error": { + "code": "action_failed", + "message": "Action failed" }, - "load_balancers": [], - "locked": false, - "name": "my-server", - "outgoing_traffic": 123456, - "primary_disk_size": 50, - "private_net": [ + "finished": null, + "id": 13, + "progress": 0, + "resources": [ { - "alias_ips": [], - "ip": "10.0.0.2", - "mac_address": "86:00:ff:2a:7d:e1", - "network": 4711 + "id": 42, + "type": "server" } ], - "protection": { - "delete": false, - "rebuild": false - }, - "public_net": { - "firewalls": [ - { - "id": 38, - "status": "applied" - } - ], - "floating_ips": [ - 478 - ], - "ipv4": { - "blocked": false, - "dns_ptr": "server01.example.com", - "ip": "1.2.3.4" - }, - "ipv6": { - "blocked": false, - "dns_ptr": [ - { - "dns_ptr": "server.example.com", - "ip": "2001:db8::1" - } - ], - "ip": "2001:db8::/64" - } - }, - "rescue_enabled": false, - "server_type": { - "architecture": "x86", - "cores": 2, - "cpu_type": "shared", - "deprecated": true, - "description": "CPX11", - "disk": 40, - "id": 1, - "memory": 2, - "name": "cpx11", - "prices": [ - { - "included_traffic": 21990232555520, - "location": "fsn1", - "price_hourly": { - "gross": "1.1900000000000000", - "net": "1.0000000000" - }, - "price_monthly": { - "gross": "1.1900000000000000", - "net": "1.0000000000" - }, - "price_per_tb_traffic": { - "gross": "1.1900000000000000", - "net": "1.0000000000" - } - } - ], - "storage_type": "local" - }, - "status": "initializing", - "volumes": [] + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/create_server_response" + "$ref": "#/components/schemas/shutdown_server_response" } } }, - "description": "The `server` key in the reply contains a Server object with this structure." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Create a Server", + "summary": "Shutdown a Server", "tags": [ "servers" ], @@ -17140,17 +20639,17 @@ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.Create(ctx, hcloud.ServerCreateOpts{\n\t\tAutomount: hcloud.Ptr(false),\n\t\tDatacenter: &hcloud.Datacenter{Name: \"nbg1-dc3\"},\n\t\tFirewalls: []*hcloud.ServerCreateFirewall{\n\t\t\t{\n\t\t\t\tFirewall: hcloud.Firewall{ID: 38},\n\t\t\t},\n\t\t},\n\t\tImage: &hcloud.Image{Name: \"ubuntu-20.04\"},\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tLocation: &hcloud.Location{Name: \"nbg1\"},\n\t\tName: \"my-server\",\n\t\tNetworks: []*hcloud.Network{\n\t\t\t{\n\t\t\t\tID: 456,\n\t\t\t},\n\t\t},\n\t\tPlacementGroup: &hcloud.PlacementGroup{ID: 1},\n\t\tPublicNet: &hcloud.ServerCreatePublicNet{\n\t\t\tEnableIPv4: false,\n\t\t\tEnableIPv6: false,\n\t\t\tIPv4: nil,\n\t\t\tIPv6: nil,\n\t\t},\n\t\tServerType: &hcloud.ServerType{Name: \"cx22\"},\n\t\tSSHKeys: []*hcloud.SSHKey{\n\t\t\t{\n\t\t\t\tName: \"my-ssh-key\",\n\t\t\t},\n\t\t},\n\t\tStartAfterCreate: hcloud.Ptr(true),\n\t\tUserData: \"#cloud-config\\nruncmd:\\n- [touch, /root/cloud-init-worked]\\n\",\n\t\tVolumes: []*hcloud.Volume{\n\t\t\t{\n\t\t\t\tID: 123,\n\t\t\t},\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tserver := result.Server\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Shutdown(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.firewalls import Firewall\nfrom hcloud.images import Image\nfrom hcloud.locations import Location\nfrom hcloud.networks import Network\nfrom hcloud.placement_groups import PlacementGroup\nfrom hcloud.server_types import ServerType\nfrom hcloud.servers import ServerCreatePublicNetwork\nfrom hcloud.ssh_keys import SSHKey\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.servers.create(\n automount=False,\n datacenter=\"nbg1-dc3\",\n firewalls=[Firewall(id=38)],\n image=Image(name=\"ubuntu-20.04\"),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n location=Location(name=\"nbg1\"),\n name=\"my-server\",\n networks=[Network(id=456)],\n placement_group=PlacementGroup(id=1),\n public_net=ServerCreatePublicNetwork(\n enable_ipv4=False,\n enable_ipv6=False,\n ipv4=None,\n ipv6=None,\n ),\n server_type=ServerType(name=\"cpx11\"),\n ssh_keys=[SSHKey(name=\"my-ssh-key\")],\n start_after_create=True,\n user_data=\"#cloud-config\\nruncmd:\\n- [touch, /root/cloud-init-worked]\\n\",\n volumes=[Volume(id=123)],\n)\n\nresponse.action.wait_until_finished()\n\nserver = response.server" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.shutdown(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server create \\\n --automount=false \\\n --datacenter nbg1-dc3 \\\n --firewall 38 \\\n --image ubuntu-20.04 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --location nbg1 \\\n --name my-server \\\n --network 456 \\\n --placement-group 1 \\\n --without-ipv4 \\\n --without-ipv6 \\\n --type cx22 \\\n --ssh-key my-ssh-key \\\n --start-after-create \\\n --volume 123 \\\n --user-data-from-file <(printf '#cloud-config\\nruncmd:\\n- [touch, /root/cloud-init-worked]\\n')" + "source": "hcloud server shutdown $SERVER" } ] }, @@ -17160,10 +20659,10 @@ } ] }, - "/servers/{id}": { - "delete": { - "description": "Deletes a Server.\n\nThis immediately removes the Server from your account, and it is no longer\naccessible. Any resources attached to the server (like Volumes, Primary IPs,\nFloating IPs, Firewalls, Placement Groups) are detached while the server is deleted.\n", - "operationId": "delete_server", + "/servers/{id}/metrics": { + "get": { + "description": "Get Metrics for specified Server.\n\nYou must specify the type of metric to get: cpu, disk or network. You can also specify more than one type by comma separation, e.g. cpu,disk.\n\nDepending on the type you will get different time series data\n\n| Type | Timeseries | Unit | Description |\n|---------|-------------------------|-----------|------------------------------------------------------|\n| cpu | cpu | percent | Percent CPU usage |\n| disk | disk.0.iops.read | iop/s | Number of read IO operations per second |\n| | disk.0.iops.write | iop/s | Number of write IO operations per second |\n| | disk.0.bandwidth.read | bytes/s | Bytes read per second |\n| | disk.0.bandwidth.write | bytes/s | Bytes written per second |\n| network | network.0.pps.in | packets/s | Public Network interface packets per second received |\n| | network.0.pps.out | packets/s | Public Network interface packets per second sent |\n| | network.0.bandwidth.in | bytes/s | Public Network interface bytes/s received |\n| | network.0.bandwidth.out | bytes/s | Public Network interface bytes/s sent |\n\nMetrics are available for the last 30 days only.\n\nIf you do not provide the step argument we will automatically adjust it so that a maximum of 200 samples are returned.\n\nWe limit the number of samples returned to a maximum of 500 and will adjust the step parameter accordingly.\n", + "operationId": "get_metrics_for_server", "parameters": [ { "description": "ID of the Server.", @@ -17177,6 +20676,47 @@ "maximum": 9007199254740991, "type": "integer" } + }, + { + "description": "Type of metrics to get.", + "in": "query", + "name": "type", + "required": true, + "schema": { + "enum": [ + "cpu", + "disk", + "network" + ], + "type": "string" + } + }, + { + "description": "Start of period to get Metrics for (in ISO-8601 format).", + "in": "query", + "name": "start", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "End of period to get Metrics for (in ISO-8601 format).", + "in": "query", + "name": "end", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Resolution of results in seconds.", + "in": "query", + "name": "step", + "required": false, + "schema": { + "type": "string" + } } ], "responses": { @@ -17184,14 +20724,14 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/delete_server_response" + "$ref": "#/components/schemas/get_metrics_for_server_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `metrics` key in the reply contains a metrics object with this structure." } }, - "summary": "Delete a Server", + "summary": "Get Metrics for a Server", "tags": [ "servers" ], @@ -17199,34 +20739,115 @@ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.DeleteWithResult(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tmetrics, _, err := client.Server.GetMetrics(ctx, &hcloud.Server{ID: 123}, hcloud.ServerGetMetricsOpts{\n\t\tStart: time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC),\n\t\tEnd: time.Date(2017, 1, 1, 23, 0, 0, 0, time.UTC),\n\t\tStep: 60,\n\t\tTypes: []hcloud.ServerMetricType{\n\t\t\thcloud.ServerMetricCPU,\n\t\t\thcloud.ServerMetricNetwork,\n\t\t\thcloud.ServerMetricDisk,\n\t\t},\n\t})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.delete(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\nimport datetime\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.servers.get_metrics(\n\tserver=Server(id=123),\n\tstart=datetime.datetime(2017, 1, 1, 0, 0, 0, 0, datetime.UTC),\n\tend=datetime.datetime(2017, 1, 1, 23, 0, 0, 0, datetime.UTC),\n\tstep=60,\n\ttype=[\n\t\t\"cpu\",\n\t\t\"network\",\n\t\t\"disk\",\n\t]\n)\n\nresponse.action.wait_until_finished()\n\nmetrics = response.metrics" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server delete $SERVER" + "source": "hcloud server metrics $SERVER \\\n --type cpu,network,disk \\\n --start 2017-01-01T00:00:00Z \\\n --end 2017-01-01T23:00:00Z" } ] }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/actions": { "get": { - "description": "Returns a specific Server object. The Server must exist inside the Project.", - "operationId": "get_server", + "description": "Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.", + "operationId": "list_server_actions", "parameters": [ { - "description": "ID of the Server.", - "in": "path", - "name": "id", - "required": true, + "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", + "in": "query", + "name": "id", + "required": false, + "schema": { + "items": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "type": "array" + } + }, + { + "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "command", + "command:asc", + "command:desc", + "status", + "status:asc", + "status:desc", + "started", + "started:asc", + "started:desc", + "finished", + "finished:asc", + "finished:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Action.", + "enum": [ + "running", + "success", + "error" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, "schema": { - "description": "ID of the Server.", - "example": 42, + "default": 25, + "example": 25, "format": "int64", - "maximum": 9007199254740991, "type": "integer" } } @@ -17236,14 +20857,14 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/get_server_response" + "$ref": "#/components/schemas/list_actions_response" } } }, - "description": "The `server` key in the reply contains a Server object with this structure." + "description": "The `actions` key contains a list of Actions." } }, - "summary": "Get a Server", + "summary": "List Actions", "tags": [ "servers" ], @@ -17251,31 +20872,33 @@ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tserver, _, err := client.Server.GetByID(ctx, 123)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Server.Action.All(ctx, hcloud.ActionListOpts{})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nserver = client.servers.get_by_id(123)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server describe $SERVER" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.servers.actions.get_all()" } ] }, - "put": { - "description": "Updates a Server. You can update a Server’s name and a Server’s labels.\n\nPlease note that Server names must be unique per Project and valid hostnames as per RFC 1123 (i.e. may only contain letters, digits, periods, and dashes).\n", - "operationId": "replace_server", + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/servers/actions/{id}": { + "get": { + "description": "Returns a specific Action object.", + "operationId": "get_server_action", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Action", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Action.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -17283,28 +20906,19 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/replace_server_request" - } - } - } - }, "responses": { "200": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/replace_server_response" + "$ref": "#/components/schemas/get_action_response" } } }, - "description": "The `server` key in the reply contains the updated Server." + "description": "The `action` key in the reply has this structure." } }, - "summary": "Update a Server", + "summary": "Get an Action", "tags": [ "servers" ], @@ -17312,17 +20926,12 @@ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tserver, _, err := client.Server.Update(ctx, &hcloud.Server{ID: 123}, hcloud.ServerUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"my-server\",\n\t})\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Action.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nserver = client.servers.update(\n server=Server(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-server\",\n)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server update $SERVER --name \"my-server\"\nhcloud server add-label --overwrite $SERVER \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud server remove-label $SERVER \\\n \"environment\" \"example.com\" \"just-a-key\"" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.actions.get_by_id(123)" } ] }, @@ -17332,27 +20941,13 @@ } ] }, - "/servers/{id}/actions": { + "/ssh_keys": { "get": { - "description": "Returns all Action objects for a Server. You can `sort` the results by using the sort URI parameter, and filter them with the `status` parameter.", - "operationId": "list_actions_for_server", + "description": "Returns all SSH key objects.", + "operationId": "list_ssh_keys", "parameters": [ { - "description": "ID of the Server", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the Server. Limited to 52 bits to ensure compatability with JSON double precision floats.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "title": "Server ID", - "type": "integer" - } - }, - { - "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", "in": "query", "name": "sort", "required": false, @@ -17362,18 +20957,9 @@ "id", "id:asc", "id:desc", - "command", - "command:asc", - "command:desc", - "status", - "status:asc", - "status:desc", - "started", - "started:asc", - "started:desc", - "finished", - "finished:asc", - "finished:desc" + "name", + "name:asc", + "name:desc" ], "type": "string" }, @@ -17381,21 +20967,30 @@ } }, { - "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", "in": "query", - "name": "status", + "name": "name", "required": false, "schema": { - "items": { - "description": "Status of the Action.", - "enum": [ - "running", - "success", - "error" - ], - "type": "string" - }, - "type": "array" + "type": "string" + } + }, + { + "description": "Can be used to filter SSH keys by their fingerprint. The response will only contain the SSH key matching the specified fingerprint.", + "in": "query", + "name": "fingerprint", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "in": "query", + "name": "label_selector", + "required": false, + "schema": { + "type": "string" } }, { @@ -17427,82 +21022,145 @@ "200": { "content": { "application/json": { - "example": { - "actions": [ - { - "command": "start_server", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - ], - "meta": { - "pagination": { - "last_page": 1, - "next_page": null, - "page": 1, - "per_page": 25, - "previous_page": null, - "total_entries": 21 - } - } - }, "schema": { - "$ref": "#/components/schemas/list_actions_response" + "$ref": "#/components/schemas/list_ssh_keys_response" } } }, - "description": "The `actions` key contains a list of Actions." + "description": "The `ssh_keys` key in the reply contains an array of SSH key objects with this structure." } }, - "summary": "List Actions for a Server", + "summary": "List SSH keys", "tags": [ - "servers" + "ssh_keys" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tsshKeys, err := client.SSHKey.All(ctx)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nssh_keys = client.ssh_keys.get_all()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud ssh-key list" + } + ] + }, + "post": { + "description": "Creates a new SSH key with the given `name` and `public_key`. Once an SSH key is created, it can be used in other calls such as creating Servers.", + "operationId": "create_ssh_key", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/create_ssh_key_request" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/create_ssh_key_response" + } + } + }, + "description": "The `ssh_key` key in the reply contains the object that was just created." + } + }, + "summary": "Create an SSH key", + "tags": [ + "ssh_keys" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tsshKey, _, err := client.SSHKey.Create(ctx, hcloud.SSHKeyCreateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"My ssh key\",\n\t\tPublicKey: \"ssh-rsa AAAjjk76kgf...Xt\",\n\t})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nssh_key = client.ssh_keys.create(\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"My ssh key\",\n public_key=\"ssh-rsa AAAjjk76kgf...Xt\",\n)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud ssh-key create \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name \"My ssh key\" \\\n --public-key \"ssh-rsa AAAjjk76kgf...Xt\"\n# --public-key-from-file ~/.ssh/id_rsa.pub" + } ] }, "servers": [ { "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/servers/{id}/actions/{action_id}": { - "get": { - "description": "Returns a specific Action object for a Server.", - "operationId": "get_action_for_server", + } + ] + }, + "/ssh_keys/{id}": { + "delete": { + "description": "Deletes an SSH key. It cannot be used anymore.", + "operationId": "delete_ssh_key", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the SSH Key.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the SSH Key.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } + } + ], + "responses": { + "204": { + "description": "SSH key deleted." + } + }, + "summary": "Delete an SSH key", + "tags": [ + "ssh_keys" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.SSHKey.Delete(ctx, &hcloud.SSHKey{ID: 123})\n}" }, { - "description": "ID of the Action.", + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.ssh_keys import SSHKey\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.ssh_keys.delete(\n ssh_key=SSHKey(id=123),\n)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud ssh-key delete $SSHKEY" + } + ] + }, + "get": { + "description": "Returns a specific SSH key object.", + "operationId": "get_ssh_key", + "parameters": [ + { + "description": "ID of the SSH Key.", "in": "path", - "name": "action_id", + "name": "id", "required": true, "schema": { - "description": "ID of the Action.", + "description": "ID of the SSH Key.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -17514,57 +21172,47 @@ "200": { "content": { "application/json": { - "example": { - "action": { - "command": "start_server", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - }, "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/get_ssh_key_response" } } }, - "description": "The `action` key in the reply has this structure." + "description": "The `ssh_key` key in the reply contains an SSH key object with this structure." } }, - "summary": "Get an Action for a Server", + "summary": "Get a SSH key", "tags": [ - "servers" + "ssh_keys" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tsshKey, _, err := client.SSHKey.GetByID(ctx, 123)\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nssh_key = client.ssh_keys.get_by_id(123)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud ssh-key describe $SSHKEY" + } ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/servers/{id}/actions/add_to_placement_group": { - "post": { - "description": "Adds a Server to a Placement Group.\n\nServer must be powered off for this command to succeed.\n\n#### Call specific error codes\n\n| Code | Description |\n|-------------------------------|----------------------------------------------------------------------|\n| `server_not_stopped` | The action requires a stopped server |\n", - "operationId": "add_server_to_placement_group", + "put": { + "description": "Updates an SSH key. You can update an SSH key name and an SSH key labels.\n", + "operationId": "replace_ssh_key", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the SSH Key.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the SSH Key.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -17576,95 +21224,204 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/add_server_to_placement_group_request" + "$ref": "#/components/schemas/replace_ssh_key_request" } } } }, "responses": { - "201": { + "200": { "content": { "application/json": { "example": { - "action": { - "command": "add_to_placement_group", - "error": { - "code": "action_failed", - "message": "Action failed" + "ssh_key": { + "created": "2016-01-30T23:50:00+00:00", + "fingerprint": "b7:2f:30:a0:2f:6c:58:6c:21:04:58:61:ba:06:3b:2f", + "id": 2323, + "labels": { + "key": "value" }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" + "name": "My ssh key", + "public_key": "ssh-rsa AAAjjk76kgf...Xt" } }, "schema": { - "$ref": "#/components/schemas/add_server_to_placement_group_response" + "$ref": "#/components/schemas/replace_ssh_key_response" + } + } + }, + "description": "The `ssh_key` key in the reply contains the modified SSH key object with the new description." + } + }, + "summary": "Update an SSH key", + "tags": [ + "ssh_keys" + ], + "x-codeSamples": [ + { + "label": "Go", + "lang": "Go", + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tsshKey, _, err := client.SSHKey.Update(ctx, &hcloud.SSHKey{ID: 123}, hcloud.SSHKeyUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"My ssh key\",\n\t})\n}" + }, + { + "label": "Python", + "lang": "Python", + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.ssh_keys import SSHKey\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nssh_key = client.ssh_keys.update(\n ssh_key=SSHKey(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"My ssh key\",\n)" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "hcloud ssh-key update $SSHKEY --name \"My ssh key\"\nhcloud ssh-key add-label --overwrite $SSHKEY \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud ssh-key remove-label $SSHKEY \\\n \"environment\" \"example.com\" \"just-a-key\"" + } + ] + }, + "servers": [ + { + "url": "https://api.hetzner.cloud/v1" + } + ] + }, + "/volumes": { + "get": { + "description": "Gets all existing Volumes that you have available.", + "operationId": "list_volumes", + "parameters": [ + { + "description": "Filter resources by status. Can be used multiple times. The response will only\ncontain the resources with the specified status.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Volume.", + "enum": [ + "available", + "creating" + ], + "example": "available", + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "name", + "name:asc", + "name:desc", + "created", + "created:asc", + "created:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "in": "query", + "name": "label_selector", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/list_volumes_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `volumes` key contains a list of volumes." } }, - "summary": "Add a Server to a Placement Group", + "summary": "List Volumes", "tags": [ - "servers" + "volumes" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.AddToPlacementGroup(ctx, &hcloud.Server{ID: 123}, &hcloud.PlacementGroup{ID: 1})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tvolumes, err := client.Volume.All(ctx)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.placement_groups import PlacementGroup\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.add_to_placement_group(\n server=Server(id=123), placement_group=PlacementGroup(id=1)\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nvolumes = client.volumes.get_all()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server add-to-placement-group --placement-group 1 $SERVER" + "source": "hcloud volume list" } ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/servers/{id}/actions/attach_iso": { "post": { - "description": "Attaches an ISO to a Server. The Server will immediately see it as a new disk. An already attached ISO will automatically be detached before the new ISO is attached.\n\nServers with attached ISOs have a modified boot order: They will try to boot from the ISO first before falling back to hard disk.\n", - "operationId": "attach_iso_to_server", - "parameters": [ - { - "description": "ID of the Server.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the Server.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - } - } - ], + "description": "Creates a new Volume attached to a Server. If you want to create a Volume that is not attached to a Server, you need to provide the `location` key instead of `server`. This can be either the ID or the name of the Location this Volume will be created in. Note that a Volume can be attached to a Server only in the same Location as the Volume itself.\n\nSpecifying the Server during Volume creation will automatically attach the Volume to that Server after it has been initialized. In that case, the `next_actions` key in the response is an array which contains a single `attach_volume` action.\n\nThe minimum Volume size is 10GB and the maximum size is 10TB (10240GB).\n\nA volume’s name can consist of alphanumeric characters, dashes, underscores, and dots, but has to start and end with an alphanumeric character. The total length is limited to 64 characters. Volume names must be unique per Project.\n\n#### Call specific error codes\n\n| Code | Description |\n|-------------------------------------|-----------------------------------------------------|\n| `no_space_left_in_location` | There is no volume space left in the given location |\n", + "operationId": "create_volume", "requestBody": { "content": { "application/json": { + "example": { + "automount": false, + "format": "xfs", + "labels": { + "key": "value" + }, + "location": "nbg1", + "name": "test-database", + "size": 42 + }, "schema": { - "$ref": "#/components/schemas/attach_iso_to_server_request" + "$ref": "#/components/schemas/create_volume_request" } } } @@ -17675,7 +21432,7 @@ "application/json": { "example": { "action": { - "command": "attach_iso", + "command": "create_volume", "error": { "code": "action_failed", "message": "Action failed" @@ -17687,39 +21444,93 @@ { "id": 42, "type": "server" + }, + { + "id": 554, + "type": "volume" } ], "started": "2016-01-30T23:50:00+00:00", "status": "running" + }, + "next_actions": [ + { + "command": "attach_volume", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "server" + }, + { + "id": 554, + "type": "volume" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + ], + "volume": { + "created": "2016-01-30T23:50:11+00:00", + "format": "xfs", + "id": 4711, + "labels": { + "key": "value" + }, + "linux_device": "/dev/disk/by-id/scsi-0HC_Volume_4711", + "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": "database-storage", + "protection": { + "delete": false + }, + "server": 12, + "size": 42, + "status": "available" } }, "schema": { - "$ref": "#/components/schemas/attach_iso_to_server_response" + "$ref": "#/components/schemas/create_volume_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `volume` key contains the Volume that was just created.\n\nThe `action` key contains the Action tracking Volume creation.\n" } }, - "summary": "Attach an ISO to a Server", + "summary": "Create a Volume", "tags": [ - "servers" + "volumes" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.AttachISO(ctx, &hcloud.Server{ID: 123}, &hcloud.ISO{\n\t\tName: \"FreeBSD-11.0-RELEASE-amd64-dvd1\",\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Volume.Create(ctx, hcloud.VolumeCreateOpts{\n\t\tAutomount: hcloud.Ptr(false),\n\t\tFormat: hcloud.Ptr(hcloud.VolumeFormatXFS),\n\t\tLabels: map[string]string{\n\t\t\t\"key\": \"value\",\n\t\t},\n\t\tLocation: &hcloud.Location{Name: \"nbg1\"},\n\t\tName: \"test-database\",\n\t\tSize: 42,\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tvolume := result.Volume\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.isos import Iso\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.attach_iso(\n server=Server(id=123), iso=Iso(name=\"FreeBSD-11.0-RELEASE-amd64-dvd1\")\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.locations import Location\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.volumes.create(\n automount=False,\n format=\"xfs\",\n labels={\"key\": \"value\"},\n location=Location(name=\"nbg1\"),\n name=\"test-database\",\n size=42,\n)\n\nresponse.action.wait_until_finished()\n\nvolume = response.volume" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server attach-iso $SERVER \"FreeBSD-11.0-RELEASE-amd64-dvd1\"" + "source": "hcloud volume create \\\n --automount=false \\\n --format xfs \\\n --label \"key=value\" \\\n --location nbg1 \\\n --name test-database \\\n --size 42" } ] }, @@ -17729,18 +21540,18 @@ } ] }, - "/servers/{id}/actions/attach_to_network": { - "post": { - "description": "Attaches a Server to a network. This will complement the fixed public Server interface by adding an additional ethernet interface to the Server which is connected to the specified network.\n\nThe Server will get an IP auto assigned from a subnet of type `server` in the same `network_zone`.\n\nUsing the `alias_ips` attribute you can also define one or more additional IPs to the Servers. Please note that you will have to configure these IPs by hand on your Server since only the primary IP will be given out by DHCP.\n\n**Call specific error codes**\n\n| Code | Description |\n|----------------------------------|-----------------------------------------------------------------------|\n| `server_already_attached` | The server is already attached to the network |\n| `ip_not_available` | The provided Network IP is not available |\n| `no_subnet_available` | No Subnet or IP is available for the Server within the network |\n| `networks_overlap` | The network IP range overlaps with one of the server networks |\n", - "operationId": "attach_server_to_network", + "/volumes/{id}": { + "delete": { + "description": "Deletes a volume. All Volume data is irreversibly destroyed. The Volume must not be attached to a Server and it must not have delete protection enabled.", + "operationId": "delete_volume", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Volume.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Volume.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -17748,91 +21559,44 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/attach_server_to_network_request" - } - } - } - }, "responses": { - "201": { - "content": { - "application/json": { - "example": { - "action": { - "command": "attach_to_network", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - }, - { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, - "schema": { - "$ref": "#/components/schemas/attach_server_to_network_response" - } - } - }, - "description": "The `action` key in the reply contains an Action object with this structure." + "204": { + "description": "Volume deleted." } }, - "summary": "Attach a Server to a Network", + "summary": "Delete a Volume", "tags": [ - "servers" + "volumes" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.AttachToNetwork(ctx, &hcloud.Server{ID: 123}, hcloud.ServerAttachToNetworkOpts{\n\t\tAliasIPs: []net.IP{\n\t\t\tnet.ParseIP(\"10.0.1.2\"),\n\t\t},\n\t\tIP: net.ParseIP(\"10.0.1.1\"),\n\t\tNetwork: &hcloud.Network{\n\t\t\tID: 4711,\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.Volume.Delete(ctx, &hcloud.Volume{ID: 123})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.attach_to_network(\n server=Server(id=123),\n alias_ips=[\"10.0.1.2\"],\n ip=\"10.0.1.1\",\n network=Network(id=4711),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.volumes.delete(\n volume=Volume(id=123),\n)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server attach-to-network $SERVER \\\n --alias-ips 10.0.1.2 \\\n --ip 10.0.1.1 \\\n --network 4711" + "source": "hcloud volume delete $VOLUME" } ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/servers/{id}/actions/change_alias_ips": { - "post": { - "description": "Changes the alias IPs of an already attached Network. Note that the existing aliases for the specified Network will be replaced with these provided in the request body. So if you want to add an alias IP, you have to provide the existing ones from the Network plus the new alias IP in the request body.", - "operationId": "change_alias_ips_of_network", + "get": { + "description": "Gets a specific Volume object.", + "operationId": "get_volume", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Volume.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Volume.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -17840,91 +21604,51 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/change_alias_ips_of_network_request" - } - } - } - }, "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "change_alias_ips", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - }, - { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/change_alias_ips_of_network_response" + "$ref": "#/components/schemas/get_volume_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `volume` key contains the volume." } }, - "summary": "Change alias IPs of a Network", + "summary": "Get a Volume", "tags": [ - "servers" + "volumes" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.ChangeAliasIPs(ctx, &hcloud.Server{ID: 123}, hcloud.ServerChangeAliasIPsOpts{\n\t\tAliasIPs: []net.IP{\n\t\t\tnet.ParseIP(\"10.0.1.2\"),\n\t\t},\n\t\tNetwork: &hcloud.Network{\n\t\t\tID: 4711,\n\t\t},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tvolume, _, err := client.Volume.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.change_alias_ips(\n server=Server(id=123),\n alias_ips=[\"10.0.1.2\"],\n network=Network(id=4711),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nvolume = client.volumes.get_by_id(123)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server change-alias-ips $SERVER \\\n --alias-ips 10.0.1.2 \\\n --network 4711" + "source": "hcloud volume describe $VOLUME" } ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/servers/{id}/actions/change_dns_ptr": { - "post": { - "description": "Changes the hostname that will appear when getting the hostname belonging to the primary IPs (IPv4 and IPv6) of this Server.\n\nFloating IPs assigned to the Server are not affected by this.\n", - "operationId": "change_reverse_dns_entry_for_this_server", + "put": { + "description": "Updates the Volume properties.\n", + "operationId": "replace_volume", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Volume.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Volume.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -17936,63 +21660,70 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_server_request" + "$ref": "#/components/schemas/replace_volume_request" } } - }, - "description": "Select the IP address for which to change the DNS entry by passing `ip`. It can be either IPv4 or IPv6. The target hostname is set by passing `dns_ptr`." + } }, "responses": { - "201": { + "200": { "content": { "application/json": { "example": { - "action": { - "command": "change_dns_ptr", - "error": { - "code": "action_failed", - "message": "Action failed" + "volume": { + "created": "2016-01-30T23:50:11+00:00", + "format": "xfs", + "id": 4711, + "labels": { + "key": "value" }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" + "linux_device": "/dev/disk/by-id/scsi-0HC_Volume_4711", + "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": "database-storage", + "protection": { + "delete": false + }, + "server": 12, + "size": 42, + "status": "available" } }, "schema": { - "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_server_response" + "$ref": "#/components/schemas/replace_volume_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `volume` key contains the updated volume." } }, - "summary": "Change reverse DNS entry for this Server", + "summary": "Update a Volume", "tags": [ - "servers" + "volumes" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.ChangeDNSPtr(ctx, &hcloud.Server{ID: 123}, \"1.2.3.4\", hcloud.Ptr(\"server01.example.com\"))\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tvolume, _, err := client.Volume.Update(ctx, &hcloud.Volume{ID: 123}, hcloud.VolumeUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"database-storage\",\n\t})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.change_dns_ptr(\n server=Server(id=123), dns_ptr=\"server01.example.com\", ip=\"1.2.3.4\"\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nvolume = client.volumes.update(\n volume=Volume(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"database-storage\",\n)" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server set-rdns $SERVER \\\n --ip 1.2.3.4 \\\n --hostname server01.example.com" + "source": "hcloud volume update $VOLUME --name \"database-storage\"\nhcloud volume add-label --overwrite $VOLUME \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud volume remove-label $VOLUME \\\n \"environment\" \"example.com\" \"just-a-key\"" } ] }, @@ -18002,86 +21733,147 @@ } ] }, - "/servers/{id}/actions/change_protection": { - "post": { - "description": "Changes the protection configuration of the Server.", - "operationId": "change_server_protection", + "/volumes/{id}/actions": { + "get": { + "description": "Returns all Action objects for a Volume. You can `sort` the results by using the sort URI parameter, and filter them with the `status` parameter.", + "operationId": "list_actions_for_volume", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Volume.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Volume.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/change_server_protection_request" - } + }, + { + "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "command", + "command:asc", + "command:desc", + "status", + "status:asc", + "status:desc", + "started", + "started:asc", + "started:desc", + "finished", + "finished:asc", + "finished:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Action.", + "enum": [ + "running", + "success", + "error" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" } } - }, + ], "responses": { - "201": { + "200": { "content": { "application/json": { "example": { - "action": { - "command": "change_protection", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" + "actions": [ + { + "command": "attach_volume", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": "2016-01-30T23:56:00+00:00", + "id": 13, + "progress": 100, + "resources": [ + { + "id": 42, + "type": "server" + }, + { + "id": 13, + "type": "volume" + } + ], + "started": "2016-01-30T23:55:00+00:00", + "status": "success" + } + ], + "meta": { + "pagination": { + "last_page": 1, + "next_page": null, + "page": 1, + "per_page": 25, + "previous_page": null, + "total_entries": 21 + } } }, "schema": { - "$ref": "#/components/schemas/change_server_protection_response" + "$ref": "#/components/schemas/list_actions_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `actions` key contains a list of Actions." } }, - "summary": "Change Server Protection", + "summary": "List Actions for a Volume", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.ChangeProtection(ctx, &hcloud.Server{ID: 123}, hcloud.ServerChangeProtectionOpts{\n\t\tDelete: hcloud.Ptr(true),\n\t\tRebuild: hcloud.Ptr(true),\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.change_dns_ptr(\n server=Server(id=123), dns_ptr=\"server01.example.com\", ip=\"1.2.3.4\"\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server enable-protection $SERVER delete rebuild\nhcloud server disable-protection $SERVER delete rebuild" - } + "volumes" ] }, "servers": [ @@ -18090,106 +21882,31 @@ } ] }, - "/servers/{id}/actions/change_type": { - "post": { - "description": "Changes the type (Cores, RAM and disk sizes) of a Server.\n\nServer must be powered off for this command to succeed.\n\nThis copies the content of its disk, and starts it again.\n\nYou can only migrate to Server types with the same `storage_type` and equal or bigger disks. Shrinking disks is not possible as it might destroy data.\n\nIf the disk gets upgraded, the Server type can not be downgraded any more. If you plan to downgrade the Server type, set `upgrade_disk` to `false`.\n\n#### Call specific error codes\n\n| Code | Description |\n|-------------------------------|----------------------------------------------------------------------|\n| `invalid_server_type` | The server type does not fit for the given server or is deprecated |\n| `server_not_stopped` | The action requires a stopped server |\n", - "operationId": "change_type_of_server", + "/volumes/{id}/actions/{action_id}": { + "get": { + "description": "Returns a specific Action for a Volume.", + "operationId": "get_action_for_volume", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Volume.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Volume.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/change_type_of_server_request" - } - } - } - }, - "responses": { - "201": { - "content": { - "application/json": { - "example": { - "action": { - "command": "change_server_type", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, - "schema": { - "$ref": "#/components/schemas/change_type_of_server_response" - } - } - }, - "description": "The `action` key in the reply contains an Action object with this structure." - } - }, - "summary": "Change the Type of a Server", - "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.ChangeType(ctx, &hcloud.Server{ID: 123}, hcloud.ServerChangeTypeOpts{\n\t\tServerType: &hcloud.ServerType{Name: \"cx22\"},\n\t\tUpgradeDisk: true,\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.server_types import ServerType\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.change_type(\n server=Server(id=123),\n server_type=ServerType(name=\"cpx11\"),\n upgrade_disk=True,\n)\n\naction.wait_until_finished()" }, { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server change-type --keep-disk $SERVER cx22" - } - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/servers/{id}/actions/create_image": { - "post": { - "description": "Creates an Image (snapshot) from a Server by copying the contents of its disks. This creates a snapshot of the current state of the disk and copies it into an Image. If the Server is currently running you must make sure that its disk content is consistent. Otherwise, the created Image may not be readable.\n\nTo make sure disk content is consistent, we recommend to shut down the Server prior to creating an Image.\n\nYou can either create a `backup` Image that is bound to the Server and therefore will be deleted when the Server is deleted, or you can create a `snapshot` Image which is completely independent of the Server it was created from and will survive Server deletion. Backup Images are only available when the backup option is enabled for the Server. Snapshot Images are billed on a per GB basis.\n", - "operationId": "create_image_from_server", - "parameters": [ - { - "description": "ID of the Server.", + "description": "ID of the Action.", "in": "path", - "name": "id", + "name": "action_id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Action.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -18197,22 +21914,13 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/create_image_from_server_request" - } - } - } - }, "responses": { - "201": { + "200": { "content": { "application/json": { "example": { "action": { - "command": "create_image", + "command": "attach_volume", "error": { "code": "action_failed", "message": "Action failed" @@ -18228,63 +21936,19 @@ ], "started": "2016-01-30T23:55:00+00:00", "status": "success" - }, - "image": { - "architecture": "x86", - "bound_to": null, - "created": "2016-01-30T23:50:00+00:00", - "created_from": { - "id": 1, - "name": "Server" - }, - "deleted": null, - "deprecated": "2018-02-28T00:00:00+00:00", - "description": "my image", - "disk_size": 10, - "id": 4711, - "image_size": 2.3, - "labels": { - "key": "value" - }, - "name": null, - "os_flavor": "ubuntu", - "os_version": "20.04", - "protection": { - "delete": false - }, - "rapid_deploy": false, - "status": "creating", - "type": "snapshot" } }, "schema": { - "$ref": "#/components/schemas/create_image_from_server_response" + "$ref": "#/components/schemas/get_action_response" } } }, - "description": "The `image` key in the reply contains an the created Image, which is an object with this structure.\n\nThe `action` key in the reply contains an Action object with this structure.\n" + "description": "The `action` key contains the Volume Action." } }, - "summary": "Create Image from a Server", + "summary": "Get an Action for a Volume", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.CreateImage(ctx, &hcloud.Server{ID: 123}, &hcloud.ServerCreateImageOpts{\n\t\tDescription: hcloud.Ptr(\"my image\"),\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tType: hcloud.ImageTypeSnapshot,\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\timage := result.Image\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.create_image(\n server=Server(id=123),\n description=\"my image\",\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n type=\"snapshot\",\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server create-image $SERVER \\\n --description \"my image\" \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --type snapshot" - } + "volumes" ] }, "servers": [ @@ -18293,18 +21957,18 @@ } ] }, - "/servers/{id}/actions/detach_from_network": { + "/volumes/{id}/actions/attach": { "post": { - "description": "Detaches a Server from a network. The interface for this network will vanish.", - "operationId": "detach_server_from_network", + "description": "Attaches a Volume to a Server. Works only if the Server is in the same Location as the Volume.", + "operationId": "attach_volume_to_server", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Volume.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Volume.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -18316,7 +21980,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/detach_server_from_network_request" + "$ref": "#/components/schemas/attach_volume_to_server_request" } } } @@ -18327,7 +21991,7 @@ "application/json": { "example": { "action": { - "command": "detach_from_network", + "command": "attach_volume", "error": { "code": "action_failed", "message": "Action failed" @@ -18337,91 +22001,12 @@ "progress": 0, "resources": [ { - "id": 42, + "id": 43, "type": "server" }, { - "id": 4711, - "type": "network" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, - "schema": { - "$ref": "#/components/schemas/detach_server_from_network_response" - } - } - }, - "description": "The `action` key in the reply contains an Action object with this structure." - } - }, - "summary": "Detach a Server from a Network", - "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.DetachFromNetwork(ctx, &hcloud.Server{ID: 123}, hcloud.ServerDetachFromNetworkOpts{\n\t\tNetwork: &hcloud.Network{ID: 4711},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.networks import Network\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.detach_from_network(\n server=Server(id=123), network=Network(id=4711)\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server detach-from-network --network 4711 $SERVER" - } - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/servers/{id}/actions/detach_iso": { - "post": { - "description": "Detaches an ISO from a Server. In case no ISO Image is attached to the Server, the status of the returned Action is immediately set to `success`.", - "operationId": "detach_iso_from_server", - "parameters": [ - { - "description": "ID of the Server.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "description": "ID of the Server.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - } - } - ], - "responses": { - "201": { - "content": { - "application/json": { - "example": { - "action": { - "command": "detach_iso", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" + "id": 554, + "type": "volume" } ], "started": "2016-01-30T23:50:00+00:00", @@ -18429,32 +22014,32 @@ } }, "schema": { - "$ref": "#/components/schemas/detach_iso_from_server_response" + "$ref": "#/components/schemas/attach_volume_to_server_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `action` key contains the `attach_volume` Action." } }, - "summary": "Detach an ISO from a Server", + "summary": "Attach Volume to a Server", "tags": [ - "servers" + "volumes" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.DetachISO(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Volume.AttachWithOpts(ctx, &hcloud.Volume{ID: 123}, hcloud.VolumeAttachOpts{\n\t\tAutomount: hcloud.Ptr(false),\n\t\tServer: &hcloud.Server{ID: 43},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.detach_iso(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.volumes.attach(\n volume=Volume(id=123),\n automount=False,\n server=Server(id=43),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server detach-iso $SERVER" + "source": "hcloud volume attach $VOLUME \\\n --automount=false \\\n --server 43" } ] }, @@ -18464,18 +22049,18 @@ } ] }, - "/servers/{id}/actions/disable_backup": { + "/volumes/{id}/actions/change_protection": { "post": { - "description": "Disables the automatic backup option and deletes all existing Backups for a Server. No more additional charges for backups will be made.\n\nCaution: This immediately removes all existing backups for the Server!\n", - "operationId": "disable_backups_for_server", + "description": "Changes the protection configuration of a Volume.", + "operationId": "change_volume_protection", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Volume.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Volume.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -18483,13 +22068,22 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_volume_protection_request" + } + } + } + }, "responses": { "201": { "content": { "application/json": { "example": { "action": { - "command": "disable_backup", + "command": "change_protection", "error": { "code": "action_failed", "message": "Action failed" @@ -18501,6 +22095,10 @@ { "id": 42, "type": "server" + }, + { + "id": 554, + "type": "volume" } ], "started": "2016-01-30T23:55:00+00:00", @@ -18508,32 +22106,32 @@ } }, "schema": { - "$ref": "#/components/schemas/disable_backups_for_server_response" + "$ref": "#/components/schemas/change_volume_protection_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `action` key contains the `change_protection` Action." } }, - "summary": "Disable Backups for a Server", + "summary": "Change Volume Protection", "tags": [ - "servers" + "volumes" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.DisableBackup(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Volume.ChangeProtection(ctx, &hcloud.Volume{ID: 123}, hcloud.VolumeChangeProtectionOpts{\n\t\tDelete: hcloud.Ptr(true),\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.disable_backup(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.volumes.change_protection(\n volume=Volume(id=123),\n delete=True,\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server disable-backup $SERVER" + "source": "hcloud volume enable-protection $VOLUME delete\nhcloud volume disable-protection $VOLUME delete" } ] }, @@ -18543,18 +22141,18 @@ } ] }, - "/servers/{id}/actions/disable_rescue": { + "/volumes/{id}/actions/detach": { "post": { - "description": "Disables the Hetzner Rescue System for a Server. This makes a Server start from its disks on next reboot.\n\nRescue Mode is automatically disabled when you first boot into it or if you do not use it for 60 minutes.\n\nDisabling rescue mode will not reboot your Server — you will have to do this yourself.\n", - "operationId": "disable_rescue_mode_for_server", + "description": "Detaches a Volume from the Server it’s attached to. You may attach it to a Server again at a later time.", + "operationId": "detach_volume", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Volume.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Volume.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -18568,7 +22166,7 @@ "application/json": { "example": { "action": { - "command": "disable_rescue", + "command": "detach_volume", "error": { "code": "action_failed", "message": "Action failed" @@ -18587,32 +22185,32 @@ } }, "schema": { - "$ref": "#/components/schemas/disable_rescue_mode_for_server_response" + "$ref": "#/components/schemas/detach_volume_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `action` key contains the `detach_volume` Action." } }, - "summary": "Disable Rescue Mode for a Server", + "summary": "Detach Volume", "tags": [ - "servers" + "volumes" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.DisableRescue(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Volume.Detach(ctx, &hcloud.Volume{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.disable_rescue(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.volumes.detach(\n volume=Volume(id=123),\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server disable-rescue $SERVER" + "source": "hcloud volume detach $VOLUME" } ] }, @@ -18622,18 +22220,18 @@ } ] }, - "/servers/{id}/actions/enable_backup": { + "/volumes/{id}/actions/resize": { "post": { - "description": "Enables and configures the automatic daily backup option for the Server. Enabling automatic backups will increase the price of the Server by 20%. In return, you will get seven slots where Images of type backup can be stored.\n\nBackups are automatically created daily.\n", - "operationId": "enable_and_configure_backups_for_server", + "description": "Changes the size of a Volume. Note that downsizing a Volume is not possible.", + "operationId": "resize_volume", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Volume.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Volume.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -18641,57 +22239,66 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/resize_volume_request" + } + } + } + }, "responses": { "201": { "content": { "application/json": { "example": { "action": { - "command": "enable_backup", + "command": "resize_volume", "error": { "code": "action_failed", "message": "Action failed" }, - "finished": "2016-01-30T23:56:00+00:00", + "finished": null, "id": 13, - "progress": 100, + "progress": 0, "resources": [ { - "id": 42, - "type": "server" + "id": 554, + "type": "volume" } ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } }, "schema": { - "$ref": "#/components/schemas/enable_and_configure_backups_for_server_response" + "$ref": "#/components/schemas/resize_volume_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `action` key contains the `resize_volume` Action." } }, - "summary": "Enable and Configure Backups for a Server", + "summary": "Resize Volume", "tags": [ - "servers" + "volumes" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.EnableBackup(ctx, &hcloud.Server{ID: 123}, \"\")\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Volume.Resize(ctx, &hcloud.Volume{ID: 123}, 50)\n\n\terr = client.Action.WaitFor(ctx, action)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.enable_backup(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.volumes.resize(\n volume=Volume(id=123),\n size=50,\n)\n\naction.wait_until_finished()" }, { "label": "CLI", "lang": "Shell", - "source": "hcloud server enable-backup $SERVER" + "source": "hcloud volume resize --size 50 $VOLUME" } ] }, @@ -18701,86 +22308,125 @@ } ] }, - "/servers/{id}/actions/enable_rescue": { - "post": { - "description": "Enable the Hetzner Rescue System for this Server. The next time a Server with enabled rescue mode boots it will start a special minimal Linux distribution designed for repair and reinstall.\n\nIn case a Server cannot boot on its own you can use this to access a Server’s disks.\n\nRescue Mode is automatically disabled when you first boot into it or if you do not use it for 60 minutes.\n\nEnabling rescue mode will not [reboot](https://docs.hetzner.cloud/#server-actions-soft-reboot-a-server) your Server — you will have to do this yourself.\n", - "operationId": "enable_rescue_mode_for_server", + "/volumes/actions": { + "get": { + "description": "Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.", + "operationId": "list_volume_actions", "parameters": [ { - "description": "ID of the Server.", - "in": "path", + "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", + "in": "query", "name": "id", - "required": true, + "required": false, "schema": { - "description": "ID of the Server.", - "example": 42, + "items": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "type": "array" + } + }, + { + "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "command", + "command:asc", + "command:desc", + "status", + "status:asc", + "status:desc", + "started", + "started:asc", + "started:desc", + "finished", + "finished:asc", + "finished:desc" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Action.", + "enum": [ + "running", + "success", + "error" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, "format": "int64", - "maximum": 9007199254740991, "type": "integer" } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/enable_rescue_mode_for_server_request" - } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" } - } - }, - "responses": { - "201": { - "content": { - "application/json": { - "example": { - "action": { - "command": "enable_rescue", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - }, - "root_password": "zCWbFhnu950dUTko5f40" - }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { "schema": { - "$ref": "#/components/schemas/enable_rescue_mode_for_server_response" + "$ref": "#/components/schemas/list_actions_response" } } }, - "description": "The `root_password` key in the reply contains the root password that can be used to access the booted rescue system.\n\nThe `action` key in the reply contains an Action object with this structure.\n" + "description": "The `actions` key contains a list of Actions." } }, - "summary": "Enable Rescue Mode for a Server", + "summary": "List Actions", "tags": [ - "servers" + "volumes" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.EnableRescue(ctx, &hcloud.Server{ID: 123}, hcloud.ServerEnableRescueOpts{\n\t\tSSHKeys: []*hcloud.SSHKey{{\n\t\t\tID: 2323,\n\t\t}},\n\t\tType: hcloud.ServerRescueTypeLinux64,\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\trootPassword := result.RootPassword\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Volume.Action.All(ctx, hcloud.ActionListOpts{})\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\nfrom hcloud.ssh_keys import SSHKey\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.enable_rescue(\n server=Server(id=123),\n ssh_keys=[SSHKey(id=2323)],\n type=\"linux64\",\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server enable-rescue $SERVER" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.volumes.actions.get_all()" } ] }, @@ -18790,18 +22436,18 @@ } ] }, - "/servers/{id}/actions/poweroff": { - "post": { - "description": "Cuts power to the Server. This forcefully stops it without giving the Server operating system time to gracefully stop. May lead to data loss, equivalent to pulling the power cord. Power off should only be used when shutdown does not work.", - "operationId": "power_off_server", + "/volumes/actions/{id}": { + "get": { + "description": "Returns a specific Action object.", + "operationId": "get_volume_action", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Action", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Action.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -18810,56 +22456,31 @@ } ], "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "stop_server", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/power_off_server_response" + "$ref": "#/components/schemas/get_action_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `action` key in the reply has this structure." } }, - "summary": "Power off a Server", + "summary": "Get an Action", "tags": [ - "servers" + "volumes" ], "x-codeSamples": [ { "label": "Go", "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Poweroff(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Volume.Action.GetByID(ctx, 123)\n}" }, { "label": "Python", "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.power_off(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server poweroff $SERVER" + "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.volumes.actions.get_by_id(123)" } ] }, @@ -18869,97 +22490,80 @@ } ] }, - "/servers/{id}/actions/poweron": { - "post": { - "description": "Starts a Server by turning its power on.", - "operationId": "power_on_server", + "/storage_box_types": { + "get": { + "description": "Gets all Storage Box type objects.", + "operationId": "list_storage_box_types", "parameters": [ { - "description": "ID of the Server.", - "in": "path", - "name": "id", - "required": true, + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, "schema": { - "description": "ID of the Server.", - "example": 42, + "type": "string" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, "format": "int64", - "maximum": 9007199254740991, "type": "integer" } } ], "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "start_server", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/power_on_server_response" + "$ref": "#/components/schemas/list_storage_box_types_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `storage_box_types` key in the reply contains an array of Storage Box type objects with this structure." } }, - "summary": "Power on a Server", + "summary": "List Storage Box Types", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Poweron(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.power_on(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server poweron $SERVER" - } + "storage_box_types" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/servers/{id}/actions/reboot": { - "post": { - "description": "Reboots a Server gracefully by sending an ACPI request. The Server operating system must support ACPI and react to the request, otherwise the Server will not reboot.", - "operationId": "soft_reboot_server", + "/storage_box_types/{id}": { + "get": { + "description": "Gets a specific Storage Box type object.", + "operationId": "get_storage_box_type", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Storage Box Type.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Storage Box Type.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -18968,327 +22572,339 @@ } ], "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "reboot_server", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/soft_reboot_server_response" + "$ref": "#/components/schemas/get_storage_box_type_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `storage_box_type` key in the reply contains a Storage Box type object with this structure." } }, - "summary": "Soft-reboot a Server", + "summary": "Get a Storage Box Type", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Reboot(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.reboot(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server reboot $SERVER" - } + "storage_box_types" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/servers/{id}/actions/rebuild": { - "post": { - "description": "Rebuilds a Server overwriting its disk with the content of an Image, thereby **destroying all data** on the target Server\n\nThe Image can either be one you have created earlier (`backup` or `snapshot` Image) or it can be a completely fresh `system` Image provided by us. You can get a list of all available Images with `GET /images`.\n\nYour Server will automatically be powered off before the rebuild command executes.\n", - "operationId": "rebuild_server_from_image", + "/storage_boxes": { + "get": { + "description": "Returns all existing Storage Box objects.\n", + "operationId": "list_storage_boxes", "parameters": [ { - "description": "ID of the Server.", - "in": "path", - "name": "id", - "required": true, + "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "in": "query", + "name": "label_selector", + "required": false, "schema": { - "description": "ID of the Server.", - "example": 42, + "type": "string" + } + }, + { + "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", + "in": "query", + "name": "name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, + { + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, "format": "int64", - "maximum": 9007199254740991, "type": "integer" } } ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/list_storage_boxes_response" + } + } + }, + "description": "The `storage_box` key in the reply contains a Storage Box object with this structure." + } + }, + "summary": "List Storage Boxes", + "tags": [ + "storage_boxes" + ] + }, + "post": { + "description": "Creates a new Storage Box. Returns an Action that covers progress of creation.", + "operationId": "create_storage_box", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/rebuild_server_from_image_request" + "$ref": "#/components/schemas/create_storage_box_request" } } }, - "description": "To select which Image to rebuild from you can either pass an ID or a name as the `image` argument. Passing a name only works for `system` Images since the other Image types do not have a name set." + "required": true }, "responses": { "201": { "content": { "application/json": { - "example": { - "action": { - "command": "rebuild_server", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "create", + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + } + ], + "started": "2016-01-30T23:50:00Z", + "status": "running" + }, + "storage_box": { + "access_settings": { + "reachable_externally": false, + "samba_enabled": false, + "ssh_enabled": false, + "webdav_enabled": false, + "zfs_enabled": false + }, + "created": "2016-01-30T23:50:00Z", "id": 42, - "type": "server" + "labels": { + "environment": "prod", + "example.com/my": "label", + "just-a-key": "" + }, + "location": { + "city": "Falkenstein", + "country": "DE", + "description": "Falkenstein DC Park 1", + "id": 1, + "latitude": 50.476119, + "longitude": 12.370071, + "name": "fsn1", + "network_zone": "eu-central" + }, + "name": "my-resource", + "protection": { + "delete": false + }, + "server": null, + "snapshot_plan": null, + "stats": null, + "status": "initializing", + "storage_box_type": { + "automatic_snapshot_limit": 10, + "description": "BX20", + "id": 1, + "name": "bx20", + "prices": [ + { + "location": "fsn1", + "price_hourly": { + "gross": "0.0061", + "net": "0.0051" + }, + "price_monthly": { + "gross": "3.8080", + "net": "3.2000" + }, + "setup_fee": { + "gross": "0.0000", + "net": "0.0000" + } + } + ], + "size": 1073741824, + "snapshot_limit": 10, + "subaccounts_limit": 100 + }, + "system": null } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - }, - "root_password": null + } + } }, "schema": { - "$ref": "#/components/schemas/rebuild_server_from_image_response" + "$ref": "#/components/schemas/create_storage_box_response" } } }, "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Rebuild a Server from an Image", + "summary": "Create a Storage Box", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.RebuildWithResult(ctx, &hcloud.Server{ID: 123}, hcloud.ServerRebuildOpts{\n\t\tImage: &hcloud.Image{Name: \"ubuntu-20.04\"},\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\trootPassword := result.RootPassword\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.images import Image\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.rebuild(server=Server(id=123), image=Image(name=\"ubuntu-20.04\"))\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server rebuild --image ubuntu-20.04 $SERVER" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/servers/{id}/actions/remove_from_placement_group": { - "post": { - "description": "Removes a Server from a Placement Group.\n", - "operationId": "remove_from_placement_group", + "/storage_boxes/actions": { + "get": { + "description": "Returns all Action objects.", + "operationId": "list_storage_box_actions", "parameters": [ { - "description": "ID of the Server.", - "in": "path", + "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", + "in": "query", "name": "id", - "required": true, + "required": false, "schema": { - "description": "ID of the Server.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" + "items": { + "description": "ID of the Action.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + }, + "type": "array" } - } - ], - "responses": { - "201": { - "content": { - "application/json": { - "example": { - "action": { - "command": "remove_from_placement_group", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - }, - "schema": { - "$ref": "#/components/schemas/remove_from_placement_group_response" - } - } - }, - "description": "The `action` key in the reply contains an Action object with this structure." - } - }, - "summary": "Remove from Placement Group", - "tags": [ - "servers" - ], - "x-codeSamples": [ + }, { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.RemoveFromPlacementGroup(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" + "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", + "in": "query", + "name": "sort", + "required": false, + "schema": { + "items": { + "enum": [ + "id", + "id:asc", + "id:desc", + "command", + "command:asc", + "command:desc", + "status", + "status:asc", + "status:desc", + "started", + "started:asc", + "started:desc", + "finished", + "finished:asc", + "finished:desc" + ], + "type": "string" + }, + "type": "array" + } }, { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.remove_from_placement_group(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" + "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", + "in": "query", + "name": "status", + "required": false, + "schema": { + "items": { + "description": "Status of the Action.", + "enum": [ + "running", + "success", + "error" + ], + "type": "string" + }, + "type": "array" + } }, { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server remove-from-placement-group $SERVER" - } - ] - }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/servers/{id}/actions/request_console": { - "post": { - "description": "Requests credentials for remote access via VNC over websocket to keyboard, monitor, and mouse for a Server. The provided URL is valid for 1 minute, after this period a new url needs to be created to connect to the Server. How long the connection is open after the initial connect is not subject to this timeout.", - "operationId": "request_console_for_server", - "parameters": [ + "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "example": 2, + "format": "int64", + "type": "integer" + } + }, { - "description": "ID of the Server.", - "in": "path", - "name": "id", - "required": true, + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, "schema": { - "description": "ID of the Server.", - "example": 42, + "default": 25, + "example": 25, "format": "int64", - "maximum": 9007199254740991, "type": "integer" } } ], "responses": { - "201": { + "200": { "content": { - "application/json": { - "example": { - "action": { - "command": "request_console", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - }, - "password": "9MQaTg2VAGI0FIpc10k3UpRXcHj2wQ6x", - "wss_url": "wss://console.hetzner.cloud/?server_id=1&token=3db32d15-af2f-459c-8bf8-dee1fd05f49c" - }, + "application/json": { "schema": { - "$ref": "#/components/schemas/request_console_for_server_response" + "$ref": "#/components/schemas/list_actions_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `actions` key contains a list of Actions." } }, - "summary": "Request Console for a Server", + "summary": "List Actions", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.RequestConsole(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\twssUrl, password := result.WSSURL, result.Password\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.servers.request_console(\n server=Server(id=123),\n)\n\nresponse.action.wait_until_finished()\n\nwss_url, password = response.wss_url, response.password" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server request-console $SERVER" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/servers/{id}/actions/reset": { - "post": { - "description": "Cuts power to a Server and starts it again. This forcefully stops it without giving the Server operating system time to gracefully stop. This may lead to data loss, it’s equivalent to pulling the power cord and plugging it in again. Reset should only be used when reboot does not work.", - "operationId": "reset_server", + "/storage_boxes/actions/{id}": { + "get": { + "description": "Returns a specific Action object.", + "operationId": "get_storage_box_action", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Action.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Action.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -19297,77 +22913,40 @@ } ], "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "reset_server", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/reset_server_response" + "$ref": "#/components/schemas/get_action_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `action` key in the reply has this structure." } }, - "summary": "Reset a Server", + "summary": "Get an Action", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Reset(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.reset(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server reset $SERVER" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/servers/{id}/actions/reset_password": { - "post": { - "description": "Resets the root password. Only works for Linux systems that are running the qemu guest agent. Server must be powered on (status `running`) in order for this operation to succeed.\n\nThis will generate a new password for this Server and return it.\n\nIf this does not succeed you can use the rescue system to netboot the Server and manually change your Server password by hand.\n", - "operationId": "reset_root_password_of_server", + "/storage_boxes/{id}": { + "delete": { + "description": "Deletes an existing Storage Box.", + "operationId": "delete_storage_box", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -19379,75 +22958,52 @@ "201": { "content": { "application/json": { - "example": { - "action": { - "command": "reset_password", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "delete", + "error": null, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "success" } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - }, - "root_password": "zCWbFhnu950dUTko5f40" + } + } }, "schema": { - "$ref": "#/components/schemas/reset_root_password_of_server_response" + "$ref": "#/components/schemas/delete_storage_box_response" } } }, - "description": "The `root_password` key in the reply contains the new root password that will be active if the Action succeeds.\n\nThe `action` key in the reply contains an Action object with this structure.\n" + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Reset root Password of a Server", + "summary": "Delete Storage Box", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Server.ResetPassword(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\trootPassword := result.RootPassword\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.servers.reset_password(\n server=Server(id=123),\n)\n\nresponse.action.wait_until_finished()\n\nroot_password = response.root_password" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server reset-password $SERVER" - } + "storage_boxes" ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/servers/{id}/actions/shutdown": { - "post": { - "description": "Shuts down a Server gracefully by sending an ACPI shutdown request. The Server operating system must support ACPI\nand react to the request, otherwise the Server will not shut down. Please note that the `action` status in this case\nonly reflects whether the action was sent to the server. It does not mean that the server actually shut down\nsuccessfully. If you need to ensure that the server is off, use the `poweroff` action.\n", - "operationId": "shutdown_server", + "get": { + "description": "Returns a specific Storage Box object. The Storage Box must exist inside the Project.\n", + "operationId": "get_storage_box", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -19456,186 +23012,78 @@ } ], "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "shutdown_server", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/shutdown_server_response" + "$ref": "#/components/schemas/get_storage_box_response" } } }, - "description": "The `action` key in the reply contains an Action object with this structure." + "description": "The `storage_box` key in the reply contains a Storage Box object with this structure." } }, - "summary": "Shutdown a Server", + "summary": "Get a Storage Box", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Shutdown(ctx, &hcloud.Server{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.shutdown(\n server=Server(id=123),\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server shutdown $SERVER" - } + "storage_boxes" ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/servers/{id}/metrics": { - "get": { - "description": "Get Metrics for specified Server.\n\nYou must specify the type of metric to get: cpu, disk or network. You can also specify more than one type by comma separation, e.g. cpu,disk.\n\nDepending on the type you will get different time series data\n\n| Type | Timeseries | Unit | Description |\n|---------|-------------------------|-----------|------------------------------------------------------|\n| cpu | cpu | percent | Percent CPU usage |\n| disk | disk.0.iops.read | iop/s | Number of read IO operations per second |\n| | disk.0.iops.write | iop/s | Number of write IO operations per second |\n| | disk.0.bandwidth.read | bytes/s | Bytes read per second |\n| | disk.0.bandwidth.write | bytes/s | Bytes written per second |\n| network | network.0.pps.in | packets/s | Public Network interface packets per second received |\n| | network.0.pps.out | packets/s | Public Network interface packets per second sent |\n| | network.0.bandwidth.in | bytes/s | Public Network interface bytes/s received |\n| | network.0.bandwidth.out | bytes/s | Public Network interface bytes/s sent |\n\nMetrics are available for the last 30 days only.\n\nIf you do not provide the step argument we will automatically adjust it so that a maximum of 200 samples are returned.\n\nWe limit the number of samples returned to a maximum of 500 and will adjust the step parameter accordingly.\n", - "operationId": "get_metrics_for_server", + "put": { + "description": "Updates a Storage Box. You can update a Storage Boxes' name and labels.\n", + "operationId": "replace_storage_box", "parameters": [ { - "description": "ID of the Server.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } - }, - { - "description": "Type of metrics to get.", - "in": "query", - "name": "type", - "required": true, - "schema": { - "enum": [ - "cpu", - "disk", - "network" - ], - "type": "string" - } - }, - { - "description": "Start of period to get Metrics for (in ISO-8601 format).", - "in": "query", - "name": "start", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "End of period to get Metrics for (in ISO-8601 format).", - "in": "query", - "name": "end", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "Resolution of results in seconds.", - "in": "query", - "name": "step", - "required": false, - "schema": { - "type": "string" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/replace_storage_box_request" + } } - } - ], + }, + "required": true + }, "responses": { "200": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/get_metrics_for_server_response" + "$ref": "#/components/schemas/replace_storage_box_response" } } }, - "description": "The `metrics` key in the reply contains a metrics object with this structure." + "description": "The `storage_box` key in the reply contains the updated Storage Box object with this structure." } }, - "summary": "Get Metrics for a Server", + "summary": "Update a Storage Box", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tmetrics, _, err := client.Server.GetMetrics(ctx, &hcloud.Server{ID: 123}, hcloud.ServerGetMetricsOpts{\n\t\tStart: time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC),\n\t\tEnd: time.Date(2017, 1, 1, 23, 0, 0, 0, time.UTC),\n\t\tStep: 60,\n\t\tTypes: []hcloud.ServerMetricType{\n\t\t\thcloud.ServerMetricCPU,\n\t\t\thcloud.ServerMetricNetwork,\n\t\t\thcloud.ServerMetricDisk,\n\t\t},\n\t})\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\nimport datetime\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.servers.get_metrics(\n\tserver=Server(id=123),\n\tstart=datetime.datetime(2017, 1, 1, 0, 0, 0, 0, datetime.UTC),\n\tend=datetime.datetime(2017, 1, 1, 23, 0, 0, 0, datetime.UTC),\n\tstep=60,\n\ttype=[\n\t\t\"cpu\",\n\t\t\"network\",\n\t\t\"disk\",\n\t]\n)\n\nresponse.action.wait_until_finished()\n\nmetrics = response.metrics" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud server metrics $SERVER \\\n --type cpu,network,disk \\\n --start 2017-01-01T00:00:00Z \\\n --end 2017-01-01T23:00:00Z" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/servers/actions": { + "/storage_boxes/{id}/actions": { "get": { - "description": "Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.", - "operationId": "list_server_actions", + "description": "List all Actions related to a specific Storage Box.", + "operationId": "list_actions_for_storage_box", "parameters": [ - { - "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", - "in": "query", - "name": "id", - "required": false, - "schema": { - "items": { - "description": "ID of the Action.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - }, - "type": "array" - } - }, { "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", "in": "query", @@ -19683,6 +23131,19 @@ "type": "array" } }, + { + "description": "ID of the Storage Box.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, { "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", "in": "query", @@ -19696,65 +23157,345 @@ } }, { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", + "in": "query", + "name": "per_page", + "required": false, + "schema": { + "default": 25, + "example": 25, + "format": "int64", + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/list_actions_response" + } + } + }, + "description": "The `actions` key contains a list of Actions." + } + }, + "summary": "List Actions for a Storage Box", + "tags": [ + "storage_boxes" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.com/v1" + } + ] + }, + "/storage_boxes/{id}/actions/change_protection": { + "post": { + "description": "Changes the protection configuration of the Storage Box.", + "operationId": "change_storage_box_protection", + "parameters": [ + { + "description": "ID of the Storage Box.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_storage_box_protection_request" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "change_protection", + "error": null, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "success" + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/change_storage_box_protection_response" + } + } + }, + "description": "The `action` key in the reply contains an Action object with this structure." + } + }, + "summary": "Change Storage Box Protection", + "tags": [ + "storage_boxes" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.com/v1" + } + ] + }, + "/storage_boxes/{id}/actions/change_type": { + "post": { + "description": "Requests a Storage Box to be upgraded or downgraded to another Storage Box Type.\n\nPlease note that it is not possible to downgrade to a Storage Box Type that offers less disk space than you are currently using.\n", + "operationId": "change_type_of_storage_box", + "parameters": [ + { + "description": "ID of the Storage Box.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/change_type_of_storage_box_request" + } + } + } + }, + "responses": { + "201": { + "content": { + "application/json": { + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "change_type", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/change_type_of_storage_box_response" + } + } + }, + "description": "The `action` key in the reply contains an Action object with this structure." + } + }, + "summary": "Change the Type of a Storage Box", + "tags": [ + "storage_boxes" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.com/v1" + } + ] + }, + "/storage_boxes/{id}/actions/disable_snapshot_plan": { + "post": { + "description": "Disables the active Snapshot Plan.\n\nThis action doesn't result in the deletion of the Snapshots created by the Snapshot Plan. They must be removed manually.\n", + "operationId": "disable_snapshot_plan", + "parameters": [ + { + "description": "ID of the Storage Box.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], + "responses": { + "201": { + "content": { + "application/json": { + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "disable_snapshot_plan", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/disable_snapshot_plan_response" + } + } + }, + "description": "The `action` key in the reply contains an Action object with this structure." + } + }, + "summary": "Disable Snapshot Plan", + "tags": [ + "storage_boxes" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.com/v1" + } + ] + }, + "/storage_boxes/{id}/actions/enable_snapshot_plan": { + "post": { + "description": "Enables a Snapshot Plan for a given StorageBox. Once enabled, a Snapshot Plan will create Snapshots at predefined intervals.\nThere can only ever be one Snapshot Plan. The existing Snapshot Plan will be deleted before a new one is set up.\n\nAutomatic Snapshots are retained until explicitly deleted by the user or the maximum snapshot count for the plan (\"max_snapshots\") is exceeded.\n\nYou can choose the specific time (UTC timezone), day of the week, and day of the month. The time-related options are cron like. Some typical use cases include:\n\n| Interval | Request body |\n| ------------------------------------------ | ------------------------------------------------------------- |\n| Every day at 3 o'clock | `{\"max_snapshots\":10,\"minute\":0,\"hour\":3}` |\n| Every Friday at 3 o'clock | `{\"max_snapshots\":10,\"minute\":0,\"hour\":3,\"day_of_week\": 5}` |\n| On the first of every month at half past 6 | `{\"max_snapshots\":10,\"minute\":30,\"hour\":6,\"day_of_month\": 1}` |\n", + "operationId": "enable_snapshot_plan", + "parameters": [ + { + "description": "ID of the Storage Box.", + "in": "path", + "name": "id", + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Storage Box.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/enable_snapshot_plan_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "enable_snapshot_plan", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + } + } + }, "schema": { - "$ref": "#/components/schemas/list_actions_response" + "$ref": "#/components/schemas/enable_snapshot_plan_response" } } }, - "description": "The `actions` key contains a list of Actions." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "List Actions", + "summary": "Enable Snapshot Plan", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Server.Action.All(ctx, hcloud.ActionListOpts{})\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.servers.actions.get_all()" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/servers/actions/{id}": { - "get": { - "description": "Returns a specific Action object.", - "operationId": "get_server_action", + "/storage_boxes/{id}/actions/reset_password": { + "post": { + "description": "Reset the password of the given Storage Box.\n", + "operationId": "reset_storage_box_password", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Action.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -19762,160 +23503,167 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/reset_password_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "reset_password", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + } + } + }, "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/reset_password_response" } } }, - "description": "The `action` key in the reply has this structure." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Get an Action", + "summary": "Reset Password", "tags": [ - "servers" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Server.Action.GetByID(ctx, 123)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.servers.actions.get_by_id(123)" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/ssh_keys": { - "get": { - "description": "Returns all SSH key objects.", - "operationId": "list_ssh_keys", + "/storage_boxes/{id}/actions/rollback_snapshot": { + "post": { + "description": "Rolls back the Storage Box to the given Snapshot.\n\nThis action will remove all newer Snapshots and irrevocably delete all data that was since written to the Storage Box.\n", + "operationId": "rollback_snapshot", "parameters": [ { - "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "name", - "name:asc", - "name:desc" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n", - "in": "query", - "name": "name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Can be used to filter SSH keys by their fingerprint. The response will only contain the SSH key matching the specified fingerprint.", - "in": "query", - "name": "fingerprint", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", - "in": "query", - "name": "label_selector", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "description": "ID of the Storage Box.", + "in": "path", + "name": "id", + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Storage Box.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/rollback_snapshot_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "rollback_snapshot", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + }, + { + "id": 42, + "type": "snapshot" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + } + } + }, "schema": { - "$ref": "#/components/schemas/list_ssh_keys_response" + "$ref": "#/components/schemas/rollback_snapshot_response" } } }, - "description": "The `ssh_keys` key in the reply contains an array of SSH key objects with this structure." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "List SSH keys", + "summary": "Rollback Snapshot", "tags": [ - "ssh_keys" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tsshKeys, err := client.SSHKey.All(ctx)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nssh_keys = client.ssh_keys.get_all()" - }, + "storage_boxes" + ] + }, + "servers": [ + { + "url": "https://api.hetzner.com/v1" + } + ] + }, + "/storage_boxes/{id}/actions/update_access_settings": { + "post": { + "description": "Update access settings of the primary Storage Box account.\n\nThis endpoints supports partial updates. Omitted optional parameters do not result in any changes to the respective properties.\n", + "operationId": "update_storage_box_access_settings", + "parameters": [ { - "label": "CLI", - "lang": "Shell", - "source": "hcloud ssh-key list" + "description": "ID of the Storage Box.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } } - ] - }, - "post": { - "description": "Creates a new SSH key with the given `name` and `public_key`. Once an SSH key is created, it can be used in other calls such as creating Servers.", - "operationId": "create_ssh_key", + ], "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/create_ssh_key_request" + "$ref": "#/components/schemas/update_access_settings_request" } } } @@ -19924,99 +23672,75 @@ "201": { "content": { "application/json": { + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "update_access_settings", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + } + } + }, "schema": { - "$ref": "#/components/schemas/create_ssh_key_response" + "$ref": "#/components/schemas/update_access_settings_response" } } }, - "description": "The `ssh_key` key in the reply contains the object that was just created." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Create an SSH key", + "summary": "Update access settings", "tags": [ - "ssh_keys" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tsshKey, _, err := client.SSHKey.Create(ctx, hcloud.SSHKeyCreateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"My ssh key\",\n\t\tPublicKey: \"ssh-rsa AAAjjk76kgf...Xt\",\n\t})\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nssh_key = client.ssh_keys.create(\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"My ssh key\",\n public_key=\"ssh-rsa AAAjjk76kgf...Xt\",\n)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud ssh-key create \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name \"My ssh key\" \\\n --public-key \"ssh-rsa AAAjjk76kgf...Xt\"\n# --public-key-from-file ~/.ssh/id_rsa.pub" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/ssh_keys/{id}": { - "delete": { - "description": "Deletes an SSH key. It cannot be used anymore.", - "operationId": "delete_ssh_key", + "/storage_boxes/{id}/actions/{action_id}": { + "get": { + "description": "Returns a specific Action object for a Storage Box.", + "operationId": "get_action_for_storage_box", "parameters": [ { - "description": "ID of the SSH Key.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the SSH Key.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } - } - ], - "responses": { - "204": { - "description": "SSH key deleted." - } - }, - "summary": "Delete an SSH key", - "tags": [ - "ssh_keys" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.SSHKey.Delete(ctx, &hcloud.SSHKey{ID: 123})\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.ssh_keys import SSHKey\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.ssh_keys.delete(\n ssh_key=SSHKey(id=123),\n)" }, { - "label": "CLI", - "lang": "Shell", - "source": "hcloud ssh-key delete $SSHKEY" - } - ] - }, - "get": { - "description": "Returns a specific SSH key object.", - "operationId": "get_ssh_key", - "parameters": [ - { - "description": "ID of the SSH Key.", + "description": "ID of the Action.", "in": "path", - "name": "id", + "name": "action_id", "required": true, "schema": { - "description": "ID of the SSH Key.", + "description": "ID of the Action.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -20029,158 +23753,103 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/get_ssh_key_response" + "$ref": "#/components/schemas/get_action_response" } } }, - "description": "The `ssh_key` key in the reply contains an SSH key object with this structure." + "description": "The `action` key in the reply has this structure." } }, - "summary": "Get a SSH key", + "summary": "Get an Action for a Storage Box", "tags": [ - "ssh_keys" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tsshKey, _, err := client.SSHKey.GetByID(ctx, 123)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nssh_key = client.ssh_keys.get_by_id(123)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud ssh-key describe $SSHKEY" - } + "storage_boxes" ] }, - "put": { - "description": "Updates an SSH key. You can update an SSH key name and an SSH key labels.\n", - "operationId": "replace_ssh_key", + "servers": [ + { + "url": "https://api.hetzner.com/v1" + } + ] + }, + "/storage_boxes/{id}/folders": { + "get": { + "description": "Lists the (sub)folders contained in a Storage Box at the location specified by the path. Files are not part of the response.", + "operationId": "list_content_of_storage_box", "parameters": [ { - "description": "ID of the SSH Key.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the SSH Key.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/replace_ssh_key_request" - } + }, + { + "description": "Relative path for which the listing is to be made.", + "in": "query", + "name": "path", + "required": false, + "schema": { + "default": "", + "type": "string" } } - }, + ], "responses": { "200": { "content": { "application/json": { - "example": { - "ssh_key": { - "created": "2016-01-30T23:50:00+00:00", - "fingerprint": "b7:2f:30:a0:2f:6c:58:6c:21:04:58:61:ba:06:3b:2f", - "id": 2323, - "labels": { - "key": "value" - }, - "name": "My ssh key", - "public_key": "ssh-rsa AAAjjk76kgf...Xt" + "examples": { + "200": { + "description": "A list of directories the Storage Box contains.", + "value": { + "folders": [ + "offsite-backup", + "photos" + ] + } } }, "schema": { - "$ref": "#/components/schemas/replace_ssh_key_response" + "$ref": "#/components/schemas/list_content_of_storage_box_response" } } }, - "description": "The `ssh_key` key in the reply contains the modified SSH key object with the new description." + "description": "The `folders` key lists the directories the Storage Box contains at the specified path." } }, - "summary": "Update an SSH key", + "summary": "List content of Storage Box", "tags": [ - "ssh_keys" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tsshKey, _, err := client.SSHKey.Update(ctx, &hcloud.SSHKey{ID: 123}, hcloud.SSHKeyUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"My ssh key\",\n\t})\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.ssh_keys import SSHKey\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nssh_key = client.ssh_keys.update(\n ssh_key=SSHKey(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"My ssh key\",\n)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud ssh-key update $SSHKEY --name \"My ssh key\"\nhcloud ssh-key add-label --overwrite $SSHKEY \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud ssh-key remove-label $SSHKEY \\\n \"environment\" \"example.com\" \"just-a-key\"" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/volumes": { + "/storage_boxes/{id}/snapshots": { "get": { - "description": "Gets all existing Volumes that you have available.", - "operationId": "list_volumes", + "description": "Get all Snapshots created both manually and through the Snapshot Plan.", + "operationId": "list_snapshots_for_storage_box", "parameters": [ { - "description": "Filter resources by status. Can be used multiple times. The response will only\ncontain the resources with the specified status.\n", - "in": "query", - "name": "status", - "required": false, - "schema": { - "items": { - "description": "Status of the Volume.", - "enum": [ - "available", - "creating" - ], - "example": "available", - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, + "description": "ID of the Storage Box.", + "in": "path", + "name": "id", + "required": true, "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "name", - "name:asc", - "name:desc", - "created", - "created:asc", - "created:desc" - ], - "type": "string" - }, - "type": "array" + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" } }, { @@ -20200,84 +23869,90 @@ "schema": { "type": "string" } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, - "schema": { - "default": 25, - "example": 25, - "format": "int64", - "type": "integer" - } } ], "responses": { "200": { "content": { "application/json": { + "examples": { + "200": { + "value": { + "snapshots": [ + { + "created": "2025-02-12T11:35:19.000Z", + "description": "my-description", + "id": 1, + "is_automatic": false, + "labels": { + "environment": "prod", + "example.com/my": "label", + "just-a-key": null + }, + "name": "2025-02-12T11-35-19", + "stats": { + "size": 2097152, + "size_filesystem": 1048576 + }, + "storage_box": 42 + }, + { + "created": "2025-02-22:00:02.000Z", + "description": "", + "id": 2, + "is_automatic": true, + "labels": { + "environment": "prod", + "example.com/my": "label", + "just-a-key": null + }, + "name": "snapshot-daily--2025-02-12T22-00-02", + "stats": { + "size": 2097152, + "size_filesystem": 1048576 + }, + "storage_box": 42 + } + ] + } + } + }, "schema": { - "$ref": "#/components/schemas/list_volumes_response" + "$ref": "#/components/schemas/list_snapshots_for_storage_box_response" } } }, - "description": "The `volumes` key contains a list of volumes." + "description": "The `snapshots` key contains a list of Snapshots." } }, - "summary": "List Volumes", + "summary": "List Snapshots for a Storage Box", "tags": [ - "volumes" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tvolumes, err := client.Volume.All(ctx)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nvolumes = client.volumes.get_all()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud volume list" - } + "storage_boxes" ] }, "post": { - "description": "Creates a new Volume attached to a Server. If you want to create a Volume that is not attached to a Server, you need to provide the `location` key instead of `server`. This can be either the ID or the name of the Location this Volume will be created in. Note that a Volume can be attached to a Server only in the same Location as the Volume itself.\n\nSpecifying the Server during Volume creation will automatically attach the Volume to that Server after it has been initialized. In that case, the `next_actions` key in the response is an array which contains a single `attach_volume` action.\n\nThe minimum Volume size is 10GB and the maximum size is 10TB (10240GB).\n\nA volume’s name can consist of alphanumeric characters, dashes, underscores, and dots, but has to start and end with an alphanumeric character. The total length is limited to 64 characters. Volume names must be unique per Project.\n\n#### Call specific error codes\n\n| Code | Description |\n|-------------------------------------|-----------------------------------------------------|\n| `no_space_left_in_location` | There is no volume space left in the given location |\n", - "operationId": "create_volume", + "description": "Creates a new Snapshot.\n", + "operationId": "create_snapshot", + "parameters": [ + { + "description": "ID of the Storage Box.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + } + ], "requestBody": { "content": { "application/json": { - "example": { - "automount": false, - "format": "xfs", - "labels": { - "key": "value" - }, - "location": "nbg1", - "name": "test-database", - "size": 42 - }, "schema": { - "$ref": "#/components/schemas/create_volume_request" + "$ref": "#/components/schemas/create_snapshot_request" } } } @@ -20286,173 +23961,83 @@ "201": { "content": { "application/json": { - "example": { - "action": { - "command": "create_volume", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "create_snapshot", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + }, + { + "id": 43, + "type": "storage_box_snapshot" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" }, - { - "id": 554, - "type": "volume" + "snapshot": { + "id": 42, + "storage_box": 43 } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - }, - "next_actions": [ - { - "command": "attach_volume", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - }, - { - "id": 554, - "type": "volume" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" } - ], - "volume": { - "created": "2016-01-30T23:50:11+00:00", - "format": "xfs", - "id": 4711, - "labels": { - "key": "value" - }, - "linux_device": "/dev/disk/by-id/scsi-0HC_Volume_4711", - "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": "database-storage", - "protection": { - "delete": false - }, - "server": 12, - "size": 42, - "status": "available" } }, "schema": { - "$ref": "#/components/schemas/create_volume_response" + "$ref": "#/components/schemas/create_snapshot_response" } } }, - "description": "The `volume` key contains the Volume that was just created.\n\nThe `action` key contains the Action tracking Volume creation.\n" + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Create a Volume", + "summary": "Create a Snapshot", "tags": [ - "volumes" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.Volume.Create(ctx, hcloud.VolumeCreateOpts{\n\t\tAutomount: hcloud.Ptr(false),\n\t\tFormat: hcloud.Ptr(hcloud.VolumeFormatXFS),\n\t\tLabels: map[string]string{\n\t\t\t\"key\": \"value\",\n\t\t},\n\t\tLocation: &hcloud.Location{Name: \"nbg1\"},\n\t\tName: \"test-database\",\n\t\tSize: 42,\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tvolume := result.Volume\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.locations import Location\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.volumes.create(\n automount=False,\n format=\"xfs\",\n labels={\"key\": \"value\"},\n location=Location(name=\"nbg1\"),\n name=\"test-database\",\n size=42,\n)\n\nresponse.action.wait_until_finished()\n\nvolume = response.volume" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud volume create \\\n --automount=false \\\n --format xfs \\\n --label \"key=value\" \\\n --location nbg1 \\\n --name test-database \\\n --size 42" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/volumes/{id}": { + "/storage_boxes/{id}/snapshots/{snapshot_id}": { "delete": { - "description": "Deletes a volume. All Volume data is irreversibly destroyed. The Volume must not be attached to a Server and it must not have delete protection enabled.", - "operationId": "delete_volume", + "description": "Delete the given Snapshot.", + "operationId": "delete_snapshot", "parameters": [ { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } - } - ], - "responses": { - "204": { - "description": "Volume deleted." - } - }, - "summary": "Delete a Volume", - "tags": [ - "volumes" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.Volume.Delete(ctx, &hcloud.Volume{ID: 123})\n}" }, { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.volumes.delete(\n volume=Volume(id=123),\n)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud volume delete $VOLUME" - } - ] - }, - "get": { - "description": "Gets a specific Volume object.", - "operationId": "get_volume", - "parameters": [ - { - "description": "ID of the Volume.", + "description": "ID of the Storage Box Snapshot.", "in": "path", - "name": "id", + "name": "snapshot_id", "required": true, "schema": { - "description": "ID of the Volume.", + "description": "ID of the Storage Box Snapshot.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -20461,146 +24046,110 @@ } ], "responses": { - "200": { + "201": { "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/get_volume_response" - } - } - }, - "description": "The `volume` key contains the volume." - } - }, - "summary": "Get a Volume", - "tags": [ - "volumes" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tvolume, _, err := client.Volume.GetByID(ctx, 123)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nvolume = client.volumes.get_by_id(123)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud volume describe $VOLUME" + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "delete_snapshot", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + }, + { + "id": 42, + "type": "storage_box_snapshot" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/delete_snapshot_response" + } + } + }, + "description": "The `action` key in the reply contains an Action object with this structure." } + }, + "summary": "Delete a Snapshot", + "tags": [ + "storage_boxes" ] }, - "put": { - "description": "Updates the Volume properties.\n", - "operationId": "replace_volume", + "get": { + "description": "Returns a specific Snapshot object.", + "operationId": "get_snapshot", "parameters": [ { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/replace_volume_request" - } + }, + { + "description": "ID of the Storage Box Snapshot.", + "in": "path", + "name": "snapshot_id", + "required": true, + "schema": { + "description": "ID of the Storage Box Snapshot.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" } } - }, + ], "responses": { "200": { "content": { "application/json": { - "example": { - "volume": { - "created": "2016-01-30T23:50:11+00:00", - "format": "xfs", - "id": 4711, - "labels": { - "key": "value" - }, - "linux_device": "/dev/disk/by-id/scsi-0HC_Volume_4711", - "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": "database-storage", - "protection": { - "delete": false - }, - "server": 12, - "size": 42, - "status": "available" - } - }, "schema": { - "$ref": "#/components/schemas/replace_volume_response" + "$ref": "#/components/schemas/get_snapshot_response" } } }, - "description": "The `volume` key contains the updated volume." + "description": "The `snapshot` key in the reply contains a Snapshot object with this structure." } }, - "summary": "Update a Volume", + "summary": "Get a Snapshot", "tags": [ - "volumes" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tvolume, _, err := client.Volume.Update(ctx, &hcloud.Volume{ID: 123}, hcloud.VolumeUpdateOpts{\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"database-storage\",\n\t})\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nvolume = client.volumes.update(\n volume=Volume(id=123),\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"database-storage\",\n)" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud volume update $VOLUME --name \"database-storage\"\nhcloud volume add-label --overwrite $VOLUME \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud volume remove-label $VOLUME \\\n \"environment\" \"example.com\" \"just-a-key\"" - } + "storage_boxes" ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/volumes/{id}/actions": { - "get": { - "description": "Returns all Action objects for a Volume. You can `sort` the results by using the sort URI parameter, and filter them with the `status` parameter.", - "operationId": "list_actions_for_volume", + "put": { + "description": "Updates the name and labels of a Snapshot.", + "operationId": "replace_snapshot", "parameters": [ { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -20608,148 +24157,64 @@ } }, { - "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "command", - "command:asc", - "command:desc", - "status", - "status:asc", - "status:desc", - "started", - "started:asc", - "started:desc", - "finished", - "finished:asc", - "finished:desc" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", - "in": "query", - "name": "status", - "required": false, - "schema": { - "items": { - "description": "Status of the Action.", - "enum": [ - "running", - "success", - "error" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "example": 2, - "format": "int64", - "type": "integer" - } - }, - { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "description": "ID of the Storage Box Snapshot.", + "in": "path", + "name": "snapshot_id", + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Storage Box Snapshot.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/replace_snapshot_request" + } + } + }, + "required": true + }, "responses": { "200": { "content": { "application/json": { - "example": { - "actions": [ - { - "command": "attach_volume", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - }, - { - "id": 13, - "type": "volume" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" - } - ], - "meta": { - "pagination": { - "last_page": 1, - "next_page": null, - "page": 1, - "per_page": 25, - "previous_page": null, - "total_entries": 21 - } - } - }, "schema": { - "$ref": "#/components/schemas/list_actions_response" + "$ref": "#/components/schemas/replace_snapshot_response" } } }, - "description": "The `actions` key contains a list of Actions." + "description": "The `snapshot` key contains the updated Snapshot." } }, - "summary": "List Actions for a Volume", + "summary": "Update a Snapshot", "tags": [ - "volumes" + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/volumes/{id}/actions/{action_id}": { + "/storage_boxes/{id}/subaccounts": { "get": { - "description": "Returns a specific Action for a Volume.", - "operationId": "get_action_for_volume", + "description": "Get a list of all available Subaccounts.", + "operationId": "list_subaccounts_for_storage_box", "parameters": [ { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -20757,16 +24222,12 @@ } }, { - "description": "ID of the Action.", - "in": "path", - "name": "action_id", - "required": true, + "description": "Filter resources by labels. The response will only contain resources matching the\nlabel selector. For more information, see \"[Label Selector](#label-selector)\".\n", + "in": "query", + "name": "label_selector", + "required": false, "schema": { - "description": "ID of the Action.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" + "type": "string" } } ], @@ -20774,57 +24235,59 @@ "200": { "content": { "application/json": { - "example": { - "action": { - "command": "attach_volume", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" + "examples": { + "200": { + "value": { + "subaccounts": [ + { + "access_settings": { + "reachable_externally": true, + "readonly": false, + "samba_enabled": false, + "ssh_enabled": true, + "webdav_enabled": false + }, + "created": "2025-02-22:00:02.000Z", + "description": "host01 backup", + "home_directory": "my_backups/host01.my.company", + "id": 42, + "labels": { + "environment": "prod", + "example.com/my": "label", + "just-a-key": null + }, + "server": "u1337-sub1.your-storagebox.de", + "storage_box": 42, + "username": "u1337-sub1" + } + ] + } } }, "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/list_subaccounts_for_storage_box_response" } } }, - "description": "The `action` key contains the Volume Action." + "description": "The `subaccounts` key contains a list of Subaccounts." } }, - "summary": "Get an Action for a Volume", + "summary": "List Subaccounts for a Storage Box", "tags": [ - "volumes" + "storage_boxes" ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/volumes/{id}/actions/attach": { "post": { - "description": "Attaches a Volume to a Server. Works only if the Server is in the same Location as the Volume.", - "operationId": "attach_volume_to_server", + "description": "Creates a new Subaccount with a separate home directory.", + "operationId": "create_subaccount", "parameters": [ { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -20836,7 +24299,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/attach_volume_to_server_request" + "$ref": "#/components/schemas/create_subaccount_request" } } } @@ -20845,170 +24308,160 @@ "201": { "content": { "application/json": { - "example": { - "action": { - "command": "attach_volume", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 43, - "type": "server" + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "create_subaccount", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + }, + { + "id": 43, + "type": "storage_box_subaccount" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" }, - { - "id": 554, - "type": "volume" + "subaccount": { + "id": 42, + "storage_box": 43 } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" + } } }, "schema": { - "$ref": "#/components/schemas/attach_volume_to_server_response" + "$ref": "#/components/schemas/create_subaccount_response" } } }, - "description": "The `action` key contains the `attach_volume` Action." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Attach Volume to a Server", + "summary": "Create Subaccount", "tags": [ - "volumes" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Volume.AttachWithOpts(ctx, &hcloud.Volume{ID: 123}, hcloud.VolumeAttachOpts{\n\t\tAutomount: hcloud.Ptr(false),\n\t\tServer: &hcloud.Server{ID: 43},\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.servers import Server\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.volumes.attach(\n volume=Volume(id=123),\n automount=False,\n server=Server(id=43),\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud volume attach $VOLUME \\\n --automount=false \\\n --server 43" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/volumes/{id}/actions/change_protection": { - "post": { - "description": "Changes the protection configuration of a Volume.", - "operationId": "change_volume_protection", + "/storage_boxes/{id}/subaccounts/{subaccount_id}": { + "delete": { + "description": "Deletes an existing subaccount.", + "operationId": "delete_subaccount", "parameters": [ { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "example": 42, "format": "int64", "maximum": 9007199254740991, "type": "integer" } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/change_volume_protection_request" - } + }, + { + "description": "ID of the Storage Box Subaccount.", + "in": "path", + "name": "subaccount_id", + "required": true, + "schema": { + "description": "ID of the Storage Box Subaccount.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" } } - }, + ], "responses": { "201": { "content": { "application/json": { - "example": { - "action": { - "command": "change_protection", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": "2016-01-30T23:56:00+00:00", - "id": 13, - "progress": 100, - "resources": [ - { - "id": 42, - "type": "server" - }, - { - "id": 554, - "type": "volume" + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "delete_subaccount", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + }, + { + "id": 42, + "type": "storage_box_subaccount" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" } - ], - "started": "2016-01-30T23:55:00+00:00", - "status": "success" + } } }, "schema": { - "$ref": "#/components/schemas/change_volume_protection_response" + "$ref": "#/components/schemas/delete_subaccount_response" } } }, - "description": "The `action` key contains the `change_protection` Action." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Change Volume Protection", + "summary": "Delete Subaccount", "tags": [ - "volumes" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Volume.ChangeProtection(ctx, &hcloud.Volume{ID: 123}, hcloud.VolumeChangeProtectionOpts{\n\t\tDelete: hcloud.Ptr(true),\n\t})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.volumes.change_protection(\n volume=Volume(id=123),\n delete=True,\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud volume enable-protection $VOLUME delete\nhcloud volume disable-protection $VOLUME delete" - } + "storage_boxes" ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/volumes/{id}/actions/detach": { - "post": { - "description": "Detaches a Volume from the Server it’s attached to. You may attach it to a Server again at a later time.", - "operationId": "detach_volume", + "get": { + "description": "Returns a specific Subaccount object.", + "operationId": "get_subaccount", "parameters": [ { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + { + "description": "ID of the Storage Box Subaccount.", + "in": "path", + "name": "subaccount_id", + "required": true, + "schema": { + "description": "ID of the Storage Box Subaccount.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -21017,77 +24470,46 @@ } ], "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "detach_volume", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 42, - "type": "server" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/detach_volume_response" + "$ref": "#/components/schemas/get_subaccount_response" } } }, - "description": "The `action` key contains the `detach_volume` Action." + "description": "The `subaccount` key in the reply contains a Subaccount object with this structure." } }, - "summary": "Detach Volume", + "summary": "Get a Subaccount", "tags": [ - "volumes" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Volume.Detach(ctx, &hcloud.Volume{ID: 123})\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.volumes.detach(\n volume=Volume(id=123),\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud volume detach $VOLUME" - } + "storage_boxes" ] }, - "servers": [ - { - "url": "https://api.hetzner.cloud/v1" - } - ] - }, - "/volumes/{id}/actions/resize": { - "post": { - "description": "Changes the size of a Volume. Note that downsizing a Volume is not possible.", - "operationId": "resize_volume", + "put": { + "description": "Updates the description and the labels of a Subaccount.", + "operationId": "replace_subaccount", "parameters": [ { - "description": "ID of the Volume.", + "description": "ID of the Storage Box.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + { + "description": "ID of the Storage Box Subaccount.", "in": "path", - "name": "id", + "name": "subaccount_id", "required": true, "schema": { - "description": "ID of the Volume.", + "description": "ID of the Storage Box Subaccount.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -21099,211 +24521,153 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/resize_volume_request" + "$ref": "#/components/schemas/replace_subaccount_request" } } - } + }, + "required": true }, "responses": { - "201": { + "200": { "content": { "application/json": { - "example": { - "action": { - "command": "resize_volume", - "error": { - "code": "action_failed", - "message": "Action failed" - }, - "finished": null, - "id": 13, - "progress": 0, - "resources": [ - { - "id": 554, - "type": "volume" - } - ], - "started": "2016-01-30T23:50:00+00:00", - "status": "running" - } - }, "schema": { - "$ref": "#/components/schemas/resize_volume_response" + "$ref": "#/components/schemas/replace_subaccount_response" } } }, - "description": "The `action` key contains the `resize_volume` Action." + "description": "The `subaccount` key contains the updated Subaccount." } }, - "summary": "Resize Volume", + "summary": "Update Subaccount", "tags": [ - "volumes" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Volume.Resize(ctx, &hcloud.Volume{ID: 123}, 50)\n\n\terr = client.Action.WaitFor(ctx, action)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.volumes import Volume\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.volumes.resize(\n volume=Volume(id=123),\n size=50,\n)\n\naction.wait_until_finished()" - }, - { - "label": "CLI", - "lang": "Shell", - "source": "hcloud volume resize --size 50 $VOLUME" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/volumes/actions": { - "get": { - "description": "Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter.", - "operationId": "list_volume_actions", + "/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/reset_subaccount_password": { + "post": { + "description": "Reset the password of the given Subaccount.\n", + "operationId": "reset_storage_box_subaccount_password", "parameters": [ { - "description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n", - "in": "query", + "description": "ID of the Storage Box.", + "in": "path", "name": "id", - "required": false, - "schema": { - "items": { - "description": "ID of the Action.", - "example": 42, - "format": "int64", - "maximum": 9007199254740991, - "type": "integer" - }, - "type": "array" - } - }, - { - "description": "Sort actions by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n", - "in": "query", - "name": "sort", - "required": false, - "schema": { - "items": { - "enum": [ - "id", - "id:asc", - "id:desc", - "command", - "command:asc", - "command:desc", - "status", - "status:asc", - "status:desc", - "started", - "started:asc", - "started:desc", - "finished", - "finished:asc", - "finished:desc" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n", - "in": "query", - "name": "status", - "required": false, - "schema": { - "items": { - "description": "Status of the Action.", - "enum": [ - "running", - "success", - "error" - ], - "type": "string" - }, - "type": "array" - } - }, - { - "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "page", - "required": false, + "required": true, "schema": { - "default": 1, - "example": 2, + "description": "ID of the Storage Box.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } }, { - "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".", - "in": "query", - "name": "per_page", - "required": false, + "description": "ID of the Storage Box Subaccount.", + "in": "path", + "name": "subaccount_id", + "required": true, "schema": { - "default": 25, - "example": 25, + "description": "ID of the Storage Box Subaccount.", + "example": 42, "format": "int64", + "maximum": 9007199254740991, "type": "integer" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/reset_password_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "reset_subaccount_password", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + }, + { + "id": 42, + "type": "storage_box_subaccount" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + } + } + }, "schema": { - "$ref": "#/components/schemas/list_actions_response" + "$ref": "#/components/schemas/reset_password_response" } } }, - "description": "The `actions` key contains a list of Actions." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "List Actions", + "summary": "Reset Password", "tags": [ - "volumes" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tactions, err := client.Volume.Action.All(ctx, hcloud.ActionListOpts{})\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.volumes.actions.get_all()" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] }, - "/volumes/actions/{id}": { - "get": { - "description": "Returns a specific Action object.", - "operationId": "get_volume_action", + "/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/update_access_settings": { + "post": { + "description": "Updates the access settings of a Subaccount.\n\nThis endpoints supports partial updates. Omitted optional parameters do not result in any changes to the respective properties.\n", + "operationId": "update_storage_box_subaccount_access_settings", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Storage Box.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Action.", + "description": "ID of the Storage Box.", + "example": 42, + "format": "int64", + "maximum": 9007199254740991, + "type": "integer" + } + }, + { + "description": "ID of the Storage Box Subaccount.", + "in": "path", + "name": "subaccount_id", + "required": true, + "schema": { + "description": "ID of the Storage Box Subaccount.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -21311,38 +24675,64 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/update_access_settings_request" + } + } + } + }, "responses": { - "200": { + "201": { "content": { "application/json": { + "examples": { + "201": { + "description": "Action successfully created.", + "value": { + "action": { + "command": "update_access_settings", + "error": { + "code": "action_failed", + "message": "Action failed" + }, + "finished": null, + "id": 13, + "progress": 0, + "resources": [ + { + "id": 42, + "type": "storage_box" + }, + { + "id": 42, + "type": "storage_box_subaccount" + } + ], + "started": "2016-01-30T23:50:00+00:00", + "status": "running" + } + } + } + }, "schema": { - "$ref": "#/components/schemas/get_action_response" + "$ref": "#/components/schemas/update_access_settings_response" } } }, - "description": "The `action` key in the reply has this structure." + "description": "The `action` key in the reply contains an Action object with this structure." } }, - "summary": "Get an Action", + "summary": "Update access settings", "tags": [ - "volumes" - ], - "x-codeSamples": [ - { - "label": "Go", - "lang": "Go", - "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\taction, _, err := client.Volume.Action.GetByID(ctx, 123)\n}" - }, - { - "label": "Python", - "lang": "Python", - "source": "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.volumes.actions.get_by_id(123)" - } + "storage_boxes" ] }, "servers": [ { - "url": "https://api.hetzner.cloud/v1" + "url": "https://api.hetzner.com/v1" } ] } diff --git a/resources/document_transformations.json b/resources/document_transformations.json index c7823b4..73e7bcb 100644 --- a/resources/document_transformations.json +++ b/resources/document_transformations.json @@ -6,43 +6,104 @@ } }, { - "path": ["components", "schemas", "metrics", "properties", "time_series", "additionalProperties", "properties", "values", "items", "items"], + "path": [ + "components", + "schemas", + "metrics", + "properties", + "time_series", + "additionalProperties", + "properties", + "values", + "items", + "items" + ], "set": { "title": "MetricsTimeSeriesValue" } }, { - "path": ["components", "schemas", "create_server_request", "properties", "firewalls", "items"], + "path": [ + "components", + "schemas", + "create_server_request", + "properties", + "firewalls", + "items" + ], "set": { "title": "CreateServerRequestFirewalls" } }, { - "path": ["components", "schemas", "firewall_resource_id", "properties", "applied_to_resources", "items"], + "path": [ + "components", + "schemas", + "firewall_resource_id", + "properties", + "applied_to_resources", + "items" + ], "set": { "title": "FirewallResourceIdAppliedToResources" } }, { - "path": ["components", "schemas", "list_prices_response", "properties", "pricing", "properties", "floating_ips", "items"], + "path": [ + "components", + "schemas", + "list_prices_response", + "properties", + "pricing", + "properties", + "floating_ips", + "items" + ], "set": { "title": "ListPricesResponsePricingFloatingIps" } }, { - "path": ["components", "schemas", "list_prices_response", "properties", "pricing", "properties", "load_balancer_types", "items"], + "path": [ + "components", + "schemas", + "list_prices_response", + "properties", + "pricing", + "properties", + "load_balancer_types", + "items" + ], "set": { "title": "ListPricesResponsePricingLoadBalancerTypes" } }, { - "path": ["components", "schemas", "list_prices_response", "properties", "pricing", "properties", "primary_ips", "items"], + "path": [ + "components", + "schemas", + "list_prices_response", + "properties", + "pricing", + "properties", + "primary_ips", + "items" + ], "set": { "title": "ListPricesResponsePricingPrimaryIps" } }, { - "path": ["components", "schemas", "list_prices_response", "properties", "pricing", "properties", "server_types", "items"], + "path": [ + "components", + "schemas", + "list_prices_response", + "properties", + "pricing", + "properties", + "server_types", + "items" + ], "set": { "title": "ListPricesResponsePricingServerTypes" } @@ -219,6 +280,55 @@ } }, + { + "path": ["paths", "/storage_boxes/actions", "get"], + "set": { + "operationId": "list_storage_box_actions" + } + }, + { + "path": ["paths", "/storage_boxes/actions/{id}", "get"], + "set": { + "operationId": "get_storage_box_action" + } + }, + { + "path": [ + "paths", + "/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/reset_subaccount_password", + "post" + ], + "set": { + "operationId": "reset_storage_box_subaccount_password" + } + }, + { + "path": ["paths", "/storage_boxes/{id}/actions/reset_password", "post"], + "set": { + "operationId": "reset_storage_box_password" + } + }, + { + "path": [ + "paths", + "/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/update_access_settings", + "post" + ], + "set": { + "operationId": "update_storage_box_subaccount_access_settings" + } + }, + { + "path": [ + "paths", + "/storage_boxes/{id}/actions/update_access_settings", + "post" + ], + "set": { + "operationId": "update_storage_box_access_settings" + } + }, + { "path": ["components", "schemas", "list_actions_response"], "set": { @@ -258,13 +368,27 @@ } }, { - "path": ["paths", "/firewalls/{id}/actions", "get", "parameters", 0, "schema"], + "path": [ + "paths", + "/firewalls/{id}/actions", + "get", + "parameters", + 0, + "schema" + ], "set": { "description": "ID of the Firewall. Limited to 52 bits to ensure compatability with JSON double precision floats." } }, { - "path": ["paths", "/firewalls/{id}/actions", "get", "parameters", 0, "schema"], + "path": [ + "paths", + "/firewalls/{id}/actions", + "get", + "parameters", + 0, + "schema" + ], "set": { "title": "Firewall ID" } @@ -277,13 +401,27 @@ } }, { - "path": ["paths", "/certificates/{id}/actions", "get", "parameters", 0, "schema"], + "path": [ + "paths", + "/certificates/{id}/actions", + "get", + "parameters", + 0, + "schema" + ], "set": { "description": "ID of the Certificate. Limited to 52 bits to ensure compatability with JSON double precision floats." } }, { - "path": ["paths", "/certificates/{id}/actions", "get", "parameters", 0, "schema"], + "path": [ + "paths", + "/certificates/{id}/actions", + "get", + "parameters", + 0, + "schema" + ], "set": { "title": "Certificate ID" } @@ -296,51 +434,78 @@ } }, { - "path": ["paths", "/servers/{id}/actions", "get", "parameters", 0, "schema"], + "path": [ + "paths", + "/servers/{id}/actions", + "get", + "parameters", + 0, + "schema" + ], "set": { "description": "ID of the Server. Limited to 52 bits to ensure compatability with JSON double precision floats." } }, { - "path": ["paths", "/servers/{id}/actions", "get", "parameters", 0, "schema"], + "path": [ + "paths", + "/servers/{id}/actions", + "get", + "parameters", + 0, + "schema" + ], "set": { "title": "Server ID" } }, { - "path": ["components", "schemas", "delete_service_request", "properties", "listen_port"], + "path": [ + "components", + "schemas", + "delete_service_request", + "properties", + "listen_port" + ], "remove": ["format"] }, { "path": ["components", "schemas", "load_balancer", "properties"], "set": { - "algorithm": {"$ref": "#/components/schemas/load_balancer_algorithm"} + "algorithm": { "$ref": "#/components/schemas/load_balancer_algorithm" } } }, { "path": ["components", "schemas"], "set": { - "change_algorithm_request": {"$ref": "#/components/schemas/load_balancer_algorithm"} + "change_algorithm_request": { + "$ref": "#/components/schemas/load_balancer_algorithm" + } } }, { - "path": ["components", "schemas", "update_load_balancer_service", "properties"], + "path": [ + "components", + "schemas", + "update_load_balancer_service", + "properties" + ], "set": { - "http": {"$ref": "#/components/schemas/http"} + "http": { "$ref": "#/components/schemas/http" } } }, { "path": ["components", "schemas", "load_balancer_add_target", "properties"], "set": { - "server": {"$ref": "#/components/schemas/resource_id"} + "server": { "$ref": "#/components/schemas/resource_id" } } }, { "path": ["components", "schemas", "remove_target_request", "properties"], "set": { - "server": {"$ref": "#/components/schemas/resource_id"} + "server": { "$ref": "#/components/schemas/resource_id" } } } ] diff --git a/resources/paths.json b/resources/paths.json index c2a33a8..a0826fb 100644 --- a/resources/paths.json +++ b/resources/paths.json @@ -128,5 +128,27 @@ "/volumes/{id}/actions/detach", "/volumes/{id}/actions/resize", "/volumes/actions", - "/volumes/actions/{id}" + "/volumes/actions/{id}", + "/storage_box_types", + "/storage_box_types/{id}", + "/storage_boxes", + "/storage_boxes/actions", + "/storage_boxes/actions/{id}", + "/storage_boxes/{id}", + "/storage_boxes/{id}/actions", + "/storage_boxes/{id}/actions/change_protection", + "/storage_boxes/{id}/actions/change_type", + "/storage_boxes/{id}/actions/disable_snapshot_plan", + "/storage_boxes/{id}/actions/enable_snapshot_plan", + "/storage_boxes/{id}/actions/reset_password", + "/storage_boxes/{id}/actions/rollback_snapshot", + "/storage_boxes/{id}/actions/update_access_settings", + "/storage_boxes/{id}/actions/{action_id}", + "/storage_boxes/{id}/folders", + "/storage_boxes/{id}/snapshots", + "/storage_boxes/{id}/snapshots/{snapshot_id}", + "/storage_boxes/{id}/subaccounts", + "/storage_boxes/{id}/subaccounts/{subaccount_id}", + "/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/reset_subaccount_password", + "/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/update_access_settings" ] \ No newline at end of file diff --git a/resources/schema_types.json b/resources/schema_types.json index 814bc08..b1bc0ca 100644 --- a/resources/schema_types.json +++ b/resources/schema_types.json @@ -434,6 +434,29 @@ "server_types" ] }, + { + "name": "snapshot", + "path": [ + "list_snapshots_for_storage_box_response", + "snapshots" + ] + }, + { + "name": "snapshot_plan", + "path": [ + "list_storage_boxes_response", + "storage_boxes", + "snapshot_plan" + ] + }, + { + "name": "snapshot_stats", + "path": [ + "list_snapshots_for_storage_box_response", + "snapshots", + "stats" + ] + }, { "description": "SSH keys are public keys you provide to the cloud system. They can be injected into Servers at creation time. We highly recommend that you use keys instead of passwords to manage your Servers.", "name": "ssh_key", @@ -442,6 +465,51 @@ "ssh_keys" ] }, + { + "name": "storage_box", + "path": [ + "list_storage_boxes_response", + "storage_boxes" + ] + }, + { + "name": "storage_box_access_setting", + "path": [ + "list_storage_boxes_response", + "storage_boxes", + "access_settings" + ] + }, + { + "name": "storage_box_stats", + "path": [ + "list_storage_boxes_response", + "storage_boxes", + "stats" + ] + }, + { + "name": "storage_box_type", + "path": [ + "list_storage_box_types_response", + "storage_box_types" + ] + }, + { + "name": "subaccount", + "path": [ + "list_subaccounts_for_storage_box_response", + "subaccounts" + ] + }, + { + "name": "subaccount_access_setting", + "path": [ + "list_subaccounts_for_storage_box_response", + "subaccounts", + "access_settings" + ] + }, { "description": "Subnets divide the ip_range from the parent Network object into multiple Subnetworks that you can use for different specific purposes.", "name": "subnet", diff --git a/src/index.ts b/src/index.ts index 277627a..9f73ce1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,7 @@ import { deduplicateSchemas, fixSchema } from "./schema/transformation"; import { OpenApiDocumentFragment } from "./types"; interface Arguments { - source: string; + sources: string[]; output?: string; schema_version?: string; list_paths?: boolean; @@ -28,10 +28,13 @@ function parseArgs(): Arguments { "Convert Hetzner OpenAPI spec to better OpenAPI document" ) .options({ - source: { - type: "string", + sources: { + type: "array", describe: "URL or local file with OpenAPI spec in JSON", - default: "https://docs.hetzner.cloud/cloud.spec.json", + default: [ + "https://docs.hetzner.cloud/cloud.spec.json", + "https://docs.hetzner.cloud/hetzner.spec.json", + ], }, output: { alias: "o", @@ -51,7 +54,7 @@ function parseArgs(): Arguments { .strict().argv; } -async function getContents(source: string): Promise { +async function getContents(source: string): Promise { console.log(`Loading JSON from ${source}`); if (validUrl.isWebUri(source)) { return (await needle("get", source)).body; @@ -174,12 +177,12 @@ function isVerb(verb: string) { async function createComponents(document: OpenApiDocumentFragment) { const paths = document.paths as OpenApiDocumentFragment; - const base_url = "https://api.hetzner.cloud/v1"; // TODO // const schemas = document.components.schemas ?? {}; const schemas = {}; // all components in the original spec are currently not referenced for (const [path, path_obj] of Object.entries(paths)) { + const base_url = path_obj.servers[0].url; for (const [verb, verb_obj] of Object.entries(path_obj)) { if (!isVerb(verb)) { continue; @@ -325,26 +328,6 @@ async function validateOpenApiDocument(document: OpenApiDocumentFragment) { console.log(`Found ${warnings.length} warnings and ${errors.length} errors`); } -function overWriteMetadata( - document: OpenApiDocumentFragment, - version?: string -) { - document.openapi = "3.0.3"; - document.info = { - title: "Hetzner Cloud API", - description: - "Copied from the official API documentation for the Public Hetzner Cloud.", - contact: { url: "https://docs.hetzner.cloud/" }, - version: version === undefined ? getVersion() : version, - }; - document.servers = [ - { - url: "https://api.hetzner.cloud/v1", - description: "Official production server", - }, - ]; -} - function overWriteTagList(document: OpenApiDocumentFragment) { const paths = document.paths as OpenApiDocumentFragment; const usedTags = new Set(Object.keys(paths).map(tagFromPath)); @@ -376,13 +359,62 @@ async function outputDocument( } } +function mergeDocuments( + target: OpenApiDocumentFragment, + source: OpenApiDocumentFragment +): OpenApiDocumentFragment { + // Merge the paths + target.paths = { ...(target.paths ?? {}), ...source.paths }; + + // Merge the components + target.components = { + ...(target.components ?? {}), + ...source.components, + }; + + // Merge the tags + target.tags = [...(target.tags ?? []), ...source.tags]; + + return target; +} + +function defaultDocument(version?: string) { + return { + openapi: "3.0.3", + info: { + title: "Hetzner Cloud API", + description: + "Copied from the official API documentation for the Public Hetzner Cloud.", + contact: { url: "https://docs.hetzner.cloud/" }, + version: version === undefined ? getVersion() : version, + }, + servers: [ + { + url: "https://api.hetzner.cloud/v1", + description: "API for cloud services", + }, + { + url: "https://api.hetzner.com/v1", + description: "API for storage boxes", + }, + ], + security: [ + { + APIToken: [], + }, + ], + } as OpenApiDocumentFragment; +} + async function main() { const args = parseArgs(); - try { - // load document from source - let document = (await getContents(args.source)) as OpenApiDocumentFragment; - await addServersToPaths(document); + let document = defaultDocument(args.schema_version); + for (const source of args.sources) { + let documentPart = await getContents(source); + await addServersToPaths(documentPart); + document = mergeDocuments(document, documentPart); + } await preTransformDocument(document); @@ -393,8 +425,6 @@ async function main() { // apply transformations from `resources/document_transformations.json` await transformDocument(document); - // overwrite various spec parts - overWriteMetadata(document, args.schema_version); overWriteTagList(document); // keep order of paths stable @@ -427,7 +457,7 @@ async function main() { if (args.list_paths) { Object.keys(document.paths).forEach((path) => { - const verbs = Object.keys(document.paths[path]); + const verbs = Object.keys(document.paths[path]).filter(isVerb); console.log( `${path} (${verbs.map((verb) => verb.toUpperCase()).join(", ")})` ); From 8f2227be6bb1b7ea7cc588a9dcffaac00c6b1695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6stler?= Date: Mon, 25 Aug 2025 01:06:15 +0200 Subject: [PATCH 3/8] Tools: Remove workaround for ID descriptions --- openapi/hcloud.json | 38 +++---- resources/document_transformations.json | 131 ------------------------ 2 files changed, 19 insertions(+), 150 deletions(-) diff --git a/openapi/hcloud.json b/openapi/hcloud.json index 19b6ae9..09681d0 100644 --- a/openapi/hcloud.json +++ b/openapi/hcloud.json @@ -6,7 +6,7 @@ }, "description": "Copied from the official API documentation for the Public Hetzner Cloud.", "title": "Hetzner Cloud API", - "version": "e80474a-dirty" + "version": "63a312e-dirty" }, "servers": [ { @@ -119,7 +119,7 @@ "type": "string" }, "id": { - "description": "ID of the Action", + "description": "ID of the Action.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -185,7 +185,7 @@ "type": "string" }, "id": { - "description": "ID of the Action", + "description": "ID of the Action.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -8022,7 +8022,7 @@ "operationId": "get_action", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Action.", "in": "path", "name": "id", "required": true, @@ -8632,12 +8632,12 @@ "operationId": "list_actions_for_certificate", "parameters": [ { - "description": "ID of the Certificate", + "description": "ID of the Certificate.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Certificate. Limited to 52 bits to ensure compatability with JSON double precision floats.", + "description": "ID of the Certificate.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -9060,7 +9060,7 @@ "operationId": "get_certificate_action", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Action.", "in": "path", "name": "id", "required": true, @@ -9621,12 +9621,12 @@ "operationId": "list_actions_for_firewall", "parameters": [ { - "description": "ID of the Firewall", + "description": "ID of the Firewall.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Firewall. Limited to 52 bits to ensure compatability with JSON double precision floats.", + "description": "ID of the Firewall.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -10305,7 +10305,7 @@ "operationId": "get_firewall_action", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Action.", "in": "path", "name": "id", "required": true, @@ -11473,7 +11473,7 @@ "operationId": "get_floating_ip_action", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Action.", "in": "path", "name": "id", "required": true, @@ -12343,7 +12343,7 @@ "operationId": "get_image_action", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Action.", "in": "path", "name": "id", "required": true, @@ -14901,7 +14901,7 @@ "operationId": "get_load_balancer_action", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Action.", "in": "path", "name": "id", "required": true, @@ -16346,7 +16346,7 @@ "operationId": "get_network_action", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Action.", "in": "path", "name": "id", "required": true, @@ -17731,7 +17731,7 @@ "operationId": "get_primary_ip_action", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Action.", "in": "path", "name": "id", "required": true, @@ -18482,12 +18482,12 @@ "operationId": "list_actions_for_server", "parameters": [ { - "description": "ID of the Server", + "description": "ID of the Server.", "in": "path", "name": "id", "required": true, "schema": { - "description": "ID of the Server. Limited to 52 bits to ensure compatability with JSON double precision floats.", + "description": "ID of the Server.", "example": 42, "format": "int64", "maximum": 9007199254740991, @@ -20893,7 +20893,7 @@ "operationId": "get_server_action", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Action.", "in": "path", "name": "id", "required": true, @@ -22442,7 +22442,7 @@ "operationId": "get_volume_action", "parameters": [ { - "description": "ID of the Action", + "description": "ID of the Action.", "in": "path", "name": "id", "required": true, diff --git a/resources/document_transformations.json b/resources/document_transformations.json index 73e7bcb..5307737 100644 --- a/resources/document_transformations.json +++ b/resources/document_transformations.json @@ -121,12 +121,6 @@ "operationId": "get_primary_ip_action" } }, - { - "path": ["paths", "/primary_ips/actions/{id}", "get", "parameters", 0], - "set": { - "description": "ID of the Action" - } - }, { "path": ["paths", "/certificates/actions", "get"], @@ -140,12 +134,6 @@ "operationId": "get_certificate_action" } }, - { - "path": ["paths", "/certificates/actions/{id}", "get", "parameters", 0], - "set": { - "description": "ID of the Action" - } - }, { "path": ["paths", "/firewalls/actions", "get"], @@ -159,12 +147,6 @@ "operationId": "get_firewall_action" } }, - { - "path": ["paths", "/firewalls/actions/{id}", "get", "parameters", 0], - "set": { - "description": "ID of the Action" - } - }, { "path": ["paths", "/images/actions", "get"], @@ -178,12 +160,6 @@ "operationId": "get_image_action" } }, - { - "path": ["paths", "/images/actions/{id}", "get", "parameters", 0], - "set": { - "description": "ID of the Action" - } - }, { "path": ["paths", "/load_balancers/actions", "get"], @@ -197,12 +173,6 @@ "operationId": "get_load_balancer_action" } }, - { - "path": ["paths", "/load_balancers/actions/{id}", "get", "parameters", 0], - "set": { - "description": "ID of the Action" - } - }, { "path": ["paths", "/floating_ips/actions", "get"], @@ -216,12 +186,6 @@ "operationId": "get_floating_ip_action" } }, - { - "path": ["paths", "/floating_ips/actions/{id}", "get", "parameters", 0], - "set": { - "description": "ID of the Action" - } - }, { "path": ["paths", "/networks/actions", "get"], @@ -235,12 +199,6 @@ "operationId": "get_network_action" } }, - { - "path": ["paths", "/networks/actions/{id}", "get", "parameters", 0], - "set": { - "description": "ID of the Action" - } - }, { "path": ["paths", "/servers/actions", "get"], @@ -254,12 +212,6 @@ "operationId": "get_server_action" } }, - { - "path": ["paths", "/servers/actions/{id}", "get", "parameters", 0], - "set": { - "description": "ID of the Action" - } - }, { "path": ["paths", "/volumes/actions", "get"], @@ -273,12 +225,6 @@ "operationId": "get_volume_action" } }, - { - "path": ["paths", "/volumes/actions/{id}", "get", "parameters", 0], - "set": { - "description": "ID of the Action" - } - }, { "path": ["paths", "/storage_boxes/actions", "get"], @@ -341,45 +287,6 @@ "description": "Response to GET https://api.hetzner.cloud/v1/{resource}/actions" } }, - - { - "path": ["paths", "/actions/{id}", "get", "parameters", 0], - "set": { - "description": "ID of the Action" - } - }, - { - "path": ["components", "schemas", "action", "properties", "id"], - "set": { - "description": "ID of the Action" - } - }, - { - "path": ["components", "schemas", "action_optional", "properties", "id"], - "set": { - "description": "ID of the Action" - } - }, - - { - "path": ["paths", "/firewalls/{id}/actions", "get", "parameters", 0], - "set": { - "description": "ID of the Firewall" - } - }, - { - "path": [ - "paths", - "/firewalls/{id}/actions", - "get", - "parameters", - 0, - "schema" - ], - "set": { - "description": "ID of the Firewall. Limited to 52 bits to ensure compatability with JSON double precision floats." - } - }, { "path": [ "paths", @@ -394,25 +301,6 @@ } }, - { - "path": ["paths", "/certificates/{id}/actions", "get", "parameters", 0], - "set": { - "description": "ID of the Certificate" - } - }, - { - "path": [ - "paths", - "/certificates/{id}/actions", - "get", - "parameters", - 0, - "schema" - ], - "set": { - "description": "ID of the Certificate. Limited to 52 bits to ensure compatability with JSON double precision floats." - } - }, { "path": [ "paths", @@ -427,25 +315,6 @@ } }, - { - "path": ["paths", "/servers/{id}/actions", "get", "parameters", 0], - "set": { - "description": "ID of the Server" - } - }, - { - "path": [ - "paths", - "/servers/{id}/actions", - "get", - "parameters", - 0, - "schema" - ], - "set": { - "description": "ID of the Server. Limited to 52 bits to ensure compatability with JSON double precision floats." - } - }, { "path": [ "paths", From 820e00f4e3cd9ba7dfa189ef46b9ad9105c10433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6stler?= Date: Tue, 26 Aug 2025 18:02:46 +0200 Subject: [PATCH 4/8] Doc: Rename APIs in description --- README.md | 6 +++--- openapi/hcloud.json | 6 +++--- src/index.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 61f1b57..d296320 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This is an attempt to improve Hetzner's own OpenAPI specification to make it usable in code generation. When this project was started, Hetzner had not published their own OpenAPI specification for their cloud API, so I decided to build my own based on the HTML documentation on their website. -By now, Hetzner has actually published an [OpenAPI spec for their API](https://docs.hetzner.cloud/cloud.spec.json) and recently also [a new API for Storage Boxes](https://docs.hetzner.cloud/hetzner.spec.json) However, I think this project still adds some value. +By now, Hetzner has actually published an [OpenAPI spec for their Cloud API](https://docs.hetzner.cloud/cloud.spec.json) and recently also [the Hetzner API](https://docs.hetzner.cloud/hetzner.spec.json) However, I think this project still adds some value. While Hetzner now appears to generate their documentation website from the OpenAPI spec, the spec is not very useful for automatic code generation. This project aims to convert the official specs to an improved version with the following main features: @@ -21,8 +21,8 @@ As an added benefit, mainly from use of common components, the improved spec is - [Link to the generated openAPI document](openapi/hcloud.json) - [Official API documentation](https://docs.hetzner.cloud/) -- [OpenAPI spec document provided by Hetzner for cloud services](https://docs.hetzner.cloud/cloud.spec.json) -- [OpenAPI spec document provided by Hetzner for storage boxes](https://docs.hetzner.cloud/hetzner.spec.json) +- [OpenAPI spec document provided by Hetzner for the Hetzner Cloud API](https://docs.hetzner.cloud/cloud.spec.json) +- [OpenAPI spec document provided by Hetzner for the Hetzner API](https://docs.hetzner.cloud/hetzner.spec.json) - [OpenAPI standard](https://swagger.io/specification/) ## Use Cases diff --git a/openapi/hcloud.json b/openapi/hcloud.json index 09681d0..9e6bb41 100644 --- a/openapi/hcloud.json +++ b/openapi/hcloud.json @@ -6,15 +6,15 @@ }, "description": "Copied from the official API documentation for the Public Hetzner Cloud.", "title": "Hetzner Cloud API", - "version": "63a312e-dirty" + "version": "8f2227b-dirty" }, "servers": [ { - "description": "API for cloud services", + "description": "Hetzner Cloud API", "url": "https://api.hetzner.cloud/v1" }, { - "description": "API for storage boxes", + "description": "Hetzner API", "url": "https://api.hetzner.com/v1" } ], diff --git a/src/index.ts b/src/index.ts index 9f73ce1..2698ddc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -391,11 +391,11 @@ function defaultDocument(version?: string) { servers: [ { url: "https://api.hetzner.cloud/v1", - description: "API for cloud services", + description: "Hetzner Cloud API", }, { url: "https://api.hetzner.com/v1", - description: "API for storage boxes", + description: "Hetzner API", }, ], security: [ From ca06c22fcfc59534549d64bf814ef828cd9b37f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6stler?= Date: Tue, 26 Aug 2025 18:06:21 +0200 Subject: [PATCH 5/8] Schema!: Fix format of storage box size to be int64 --- openapi/hcloud.json | 3 ++- resources/document_transformations.json | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/openapi/hcloud.json b/openapi/hcloud.json index 9e6bb41..7e0d9c4 100644 --- a/openapi/hcloud.json +++ b/openapi/hcloud.json @@ -6,7 +6,7 @@ }, "description": "Copied from the official API documentation for the Public Hetzner Cloud.", "title": "Hetzner Cloud API", - "version": "8f2227b-dirty" + "version": "820e00f-dirty" }, "servers": [ { @@ -7470,6 +7470,7 @@ "size": { "description": "Available storage in bytes.", "example": 1073741824, + "format": "int64", "type": "integer" }, "snapshot_limit": { diff --git a/resources/document_transformations.json b/resources/document_transformations.json index 5307737..638d9c0 100644 --- a/resources/document_transformations.json +++ b/resources/document_transformations.json @@ -376,5 +376,12 @@ "set": { "server": { "$ref": "#/components/schemas/resource_id" } } + }, + + { + "path": ["components", "schemas", "storage_box_type", "properties", "size"], + "set": { + "format": "int64" + } } ] From ed82782892579092d20075951c980ca41417ea0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6stler?= Date: Thu, 28 Aug 2025 21:31:18 +0200 Subject: [PATCH 6/8] Schema!: Update required fields of snapshot_plan --- openapi/hcloud.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openapi/hcloud.json b/openapi/hcloud.json index 7e0d9c4..48a40c7 100644 --- a/openapi/hcloud.json +++ b/openapi/hcloud.json @@ -6,7 +6,7 @@ }, "description": "Copied from the official API documentation for the Public Hetzner Cloud.", "title": "Hetzner Cloud API", - "version": "820e00f-dirty" + "version": "ca06c22" }, "servers": [ { @@ -7193,7 +7193,11 @@ } }, "required": [ - "max_snapshots" + "max_snapshots", + "minute", + "hour", + "day_of_week", + "day_of_month" ], "type": "object" }, From 7cfb4a95b99f17a44dc03b102bfa1195279b17ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6stler?= Date: Thu, 28 Aug 2025 21:32:58 +0200 Subject: [PATCH 7/8] Schema!: Make "access_settings" of "subaccount" required --- openapi/hcloud.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openapi/hcloud.json b/openapi/hcloud.json index 48a40c7..9b158bb 100644 --- a/openapi/hcloud.json +++ b/openapi/hcloud.json @@ -6,7 +6,7 @@ }, "description": "Copied from the official API documentation for the Public Hetzner Cloud.", "title": "Hetzner Cloud API", - "version": "ca06c22" + "version": "ed82782" }, "servers": [ { @@ -7556,6 +7556,7 @@ "username", "home_directory", "server", + "access_settings", "description", "labels", "created", From f4fd313d2988d0613838310109d69d222db539d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6stler?= Date: Thu, 28 Aug 2025 21:33:57 +0200 Subject: [PATCH 8/8] Doc: Update descriptions from upstream --- openapi/hcloud.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi/hcloud.json b/openapi/hcloud.json index 9b158bb..976e692 100644 --- a/openapi/hcloud.json +++ b/openapi/hcloud.json @@ -6,7 +6,7 @@ }, "description": "Copied from the official API documentation for the Public Hetzner Cloud.", "title": "Hetzner Cloud API", - "version": "ed82782" + "version": "7cfb4a9" }, "servers": [ { @@ -4916,7 +4916,7 @@ }, "use_private_ip": { "default": false, - "description": "Use the private network IP instead of the public IP of the Server, requires the Server and Load Balancer to be in the same network.", + "description": "Use the private network IP instead of the public IP of the Server, requires the Server and Load Balancer to be in the same network. Only valid for target types `server` and `label_selector`.", "example": true, "type": "boolean" }