diff --git a/README.md b/README.md
index 03a9f89..d296320 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 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 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 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
+
This API description is currently being used by the following projects:
+
- [hcloud-rust](https://github.com/HenningHolmDE/hcloud-rust)
[](https://crates.io/crates/hcloud)
[](https://docs.rs/hcloud/)
## Supported Endpoints
-
-
- | actions |
- certificates |
- datacenters |
-
-
- | floating_ips |
- images |
- isos |
-
-
- | load_balancer_types |
- load_balancers |
- locations |
-
-
- | networks |
- pricing |
- server_types |
-
-
- | servers |
- ssh_keys |
- volumes |
-
-
- | firewalls |
- placement_groups |
- primary_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 7543a8e..976e692 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": "4f5630d-dirty"
+ "version": "7cfb4a9"
},
"servers": [
{
- "description": "Official production server",
+ "description": "Hetzner Cloud API",
"url": "https://api.hetzner.cloud/v1"
+ },
+ {
+ "description": "Hetzner API",
+ "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"
@@ -107,7 +119,7 @@
"type": "string"
},
"id": {
- "description": "ID of the Action",
+ "description": "ID of the Action.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -173,7 +185,7 @@
"type": "string"
},
"id": {
- "description": "ID of the Action",
+ "description": "ID of the Action.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -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,13 +2773,72 @@
},
"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",
+ "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": {
@@ -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": {
@@ -4388,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"
}
@@ -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,87 @@
"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",
+ "minute",
+ "hour",
+ "day_of_week",
+ "day_of_month"
],
"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 +7232,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 +7296,1652 @@
"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": "integer"
+ "type": "string"
},
- "size": {
- "description": "Size in GB of the Volume.",
- "example": 42,
- "type": "number"
+ "snapshot_plan": {
+ "$ref": "#/components/schemas/snapshot_plan"
+ },
+ "stats": {
+ "$ref": "#/components/schemas/storage_box_stats"
},
"status": {
- "description": "Status of the Volume.",
"enum": [
- "available",
- "creating"
+ "active",
+ "initializing",
+ "locked"
],
- "example": "available",
+ "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",
- "created",
+ "status",
"name",
- "server",
+ "storage_box_type",
"location",
- "size",
- "linux_device",
+ "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": "Available storage in bytes.",
+ "example": 1073741824,
+ "format": "int64",
+ "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,
+ "format": "int64",
+ "maximum": 9007199254740991,
+ "type": "integer"
+ },
+ "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",
+ "access_settings",
+ "description",
"labels",
- "status",
- "format"
+ "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": [
+ "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"
+ ],
+ "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.",
+ "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"
+ }
+ ]
},
- "securitySchemes": {
- "APIToken": {
- "scheme": "bearer",
- "type": "http"
- }
- }
- },
- "paths": {
- "/actions": {
+ "/certificates/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 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": true,
+ "required": false,
"schema": {
"items": {
"description": "ID of the Action.",
@@ -6840,6 +8952,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,33 +9030,43 @@
"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."
}
},
- "summary": "Get multiple Actions",
+ "summary": "List Actions",
"tags": [
- "actions"
+ "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.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.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"
+ }
+ ]
},
- "/actions/{id}": {
+ "/certificates/actions/{id}": {
"get": {
"description": "Returns a specific Action object.",
- "operationId": "get_action",
+ "operationId": "get_certificate_action",
"parameters": [
{
- "description": "ID of the Action",
+ "description": "ID of the Action.",
"in": "path",
"name": "id",
"required": true,
@@ -6895,31 +9088,194 @@
}
}
},
- "description": "Response for getting an [Action](#actions)."
+ "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 an Action",
+ "summary": "Get a Datacenter",
"tags": [
- "actions"
+ "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\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\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\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\ndatacenter = client.datacenters.get_by_id(123)"
+ },
+ {
+ "label": "CLI",
+ "lang": "Shell",
+ "source": "hcloud datacenter describe $DATACENTER"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/certificates": {
+ "/firewalls": {
"get": {
- "description": "Returns all Certificate objects.",
- "operationId": "list_certificates",
+ "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",
@@ -6962,24 +9318,6 @@
"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",
@@ -7009,106 +9347,71 @@
"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_firewalls_response"
}
}
},
- "description": "The `certificates` key contains an array of Certificate objects."
+ "description": "The `firewalls` key contains the [Firewalls](#firewalls)."
}
},
- "summary": "List Certificates",
+ "summary": "List Firewalls",
"tags": [
- "certificates"
+ "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\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\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\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\nfirewalls = client.firewalls.get_all()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud certificate list"
+ "source": "hcloud firewall 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 [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": {
- "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"
+ "example": {
+ "apply_to": [
+ {
+ "server": {
+ "id": 42
+ },
+ "type": "server"
}
+ ],
+ "labels": {
+ "key": "value"
},
- "uploaded": {
- "summary": "Creating a type `uploaded` Certificate",
- "value": {
- "certificate": "-----BEGIN CERTIFICATE-----\n...",
- "name": "my website cert",
- "private_key": "-----BEGIN PRIVATE KEY-----\n...",
- "type": "uploaded"
+ "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_certificate_request"
+ "$ref": "#/components/schemas/create_firewall_request"
}
}
}
@@ -7117,149 +9420,54 @@
"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"
+ "$ref": "#/components/schemas/create_firewall_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": "The `firewall` key contains the created [Firewall](#firewalls)."
}
},
- "summary": "Create a Certificate",
+ "summary": "Create a Firewall",
"tags": [
- "certificates"
+ "firewalls"
],
"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\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 (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.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 (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 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"
+ }
+ ]
},
- "/certificates/{id}": {
+ "/firewalls/{id}": {
"delete": {
- "description": "Deletes a Certificate.",
- "operationId": "delete_certificate",
+ "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 Certificate.",
+ "description": "ID of the Firewall.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Certificate.",
+ "description": "ID of the Firewall.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -7269,42 +9477,42 @@
],
"responses": {
"204": {
- "description": "Certificate deleted."
+ "description": "Firewall deleted."
}
},
- "summary": "Delete a Certificate",
+ "summary": "Delete a Firewall",
"tags": [
- "certificates"
+ "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.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.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.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.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 certificate delete $CERTIFICATE"
+ "source": "hcloud firewall delete $FIREWALL"
}
]
},
"get": {
- "description": "Gets a specific Certificate object.",
- "operationId": "get_certificate",
+ "description": "Returns a single [Firewall](#firewalls).",
+ "operationId": "get_firewall",
"parameters": [
{
- "description": "ID of the Certificate.",
+ "description": "ID of the Firewall.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Certificate.",
+ "description": "ID of the Firewall.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -7316,74 +9524,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_firewall_response"
}
}
},
- "description": "The `certificate` key contains a Certificate object."
+ "description": "The `firewall` key contains the [Firewall](#firewalls)."
}
},
- "summary": "Get a Certificate",
+ "summary": "Get a Firewall",
"tags": [
- "certificates"
+ "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\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\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\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\nfirewall = client.firewalls.get_by_id(123)"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud certificate describe $CERTIFICATE"
+ "source": "hcloud firewall describe $FIREWALL"
}
]
},
"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 [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 Certificate.",
+ "description": "ID of the Firewall.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Certificate.",
+ "description": "ID of the Firewall.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -7395,7 +9576,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/replace_certificate_request"
+ "$ref": "#/components/schemas/replace_firewall_request"
}
}
}
@@ -7404,80 +9585,58 @@
"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"
+ "$ref": "#/components/schemas/replace_firewall_response"
}
}
},
- "description": "The `certificate` key contains the Certificate that was just updated."
+ "description": "The `firewall` key contains the updated [Firewall](#firewalls)."
}
},
- "summary": "Update a Certificate",
+ "summary": "Update a Firewall",
"tags": [
- "certificates"
+ "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\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\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.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.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 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 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"
+ }
+ ]
},
- "/certificates/{id}/actions": {
+ "/firewalls/{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": "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 Certificate",
+ "description": "ID of the Firewall.",
"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 Firewall.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
- "title": "Certificate ID",
+ "title": "Firewall ID",
"type": "integer"
}
},
@@ -7541,93 +9700,264 @@
}
},
{
- "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": {
+ "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": {
- "default": 25,
- "example": 25,
+ "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": {
- "200": {
+ "201": {
"content": {
"application/json": {
"example": {
"actions": [
{
- "command": "issue_certificate",
+ "command": "apply_firewall",
"error": {
"code": "action_failed",
"message": "Action failed"
},
- "finished": "2021-01-30T23:57:00+00:00",
+ "finished": "2016-01-30T23:56:00+00:00",
"id": 14,
"progress": 100,
"resources": [
{
- "id": 896,
- "type": "certificate"
+ "id": 42,
+ "type": "server"
+ },
+ {
+ "id": 38,
+ "type": "firewall"
}
],
- "started": "2021-01-30T23:55:00+00:00",
+ "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/apply_to_resources_response"
}
}
},
- "description": "The `actions` key contains a list of Actions."
+ "description": "The `actions` key contains multiple [Actions](#actions) with the `apply_firewall` command."
}
},
- "summary": "List Actions for a Certificate",
+ "summary": "Apply to Resources",
"tags": [
- "certificates"
+ "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"
+ }
+ ]
},
- "/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",
+ "/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 Certificate.",
+ "description": "ID of the Firewall.",
"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.",
+ "description": "ID of the Firewall.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -7635,122 +9965,222 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "example": {
+ "remove_from": [
+ {
+ "server": {
+ "id": 42
+ },
+ "type": "server"
+ }
+ ]
+ },
+ "schema": {
+ "$ref": "#/components/schemas/remove_from_resources_request"
+ }
+ }
+ }
+ },
"responses": {
- "200": {
+ "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"
- }
+ "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/get_action_response"
+ "$ref": "#/components/schemas/remove_from_resources_response"
}
}
},
- "description": "The `action` key contains the Certificate Action."
+ "description": "The `actions` key contains multiple [Actions](#actions) with the `remove_firewall` command."
}
},
- "summary": "Get an Action for a Certificate",
+ "summary": "Remove from Resources",
"tags": [
- "certificates"
+ "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"
+ }
+ ]
},
- "/certificates/{id}/actions/retry": {
+ "/firewalls/{id}/actions/set_rules": {
"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": "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 Certificate.",
+ "description": "ID of the Firewall.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Certificate.",
+ "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": {
- "action": {
- "command": "issue_certificate",
- "error": {
- "code": "action_failed",
- "message": "Action failed"
+ "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"
},
- "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"
- }
+ {
+ "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/retry_issuance_or_renewal_response"
+ "$ref": "#/components/schemas/set_rules_response"
}
}
},
- "description": "The `action` key contains the resulting Action."
+ "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)."
}
},
- "summary": "Retry Issuance or Renewal",
+ "summary": "Set Rules",
"tags": [
- "certificates"
+ "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.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\"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.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.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 certificate retry $CERTIFICATE"
+ "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"
+ }
+ ]
},
- "/certificates/actions": {
+ "/firewalls/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": "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",
@@ -7849,34 +10279,39 @@
}
}
},
- "description": "The `actions` key contains a list of Actions."
+ "description": "The `actions` key contains a list of [Actions](#actions)."
}
},
"summary": "List Actions",
"tags": [
- "certificates"
+ "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.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.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.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.firewalls.actions.get_all()"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/certificates/actions/{id}": {
+ "/firewalls/actions/{id}": {
"get": {
- "description": "Returns a specific Action object.",
- "operationId": "get_certificate_action",
+ "description": "Returns the specific [Action](#actions).",
+ "operationId": "get_firewall_action",
"parameters": [
{
- "description": "ID of the Action",
+ "description": "ID of the Action.",
"in": "path",
"name": "id",
"required": true,
@@ -7898,31 +10333,36 @@
}
}
},
- "description": "The `action` key in the reply has this structure."
+ "description": "The `action` key contains the [Action](#actions)."
}
},
"summary": "Get an Action",
"tags": [
- "certificates"
+ "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.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.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.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.firewalls.actions.get_by_id(123)"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/datacenters": {
+ "/floating_ips": {
"get": {
- "description": "Returns all [Datacenters](#datacenters).",
- "operationId": "list_datacenters",
+ "description": "List multiple [Floating IPs](#floating-ips).\n\nUse the provided URI parameters to modify the result.\n",
+ "operationId": "list_floating_ips",
"parameters": [
{
"description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n",
@@ -7934,144 +10374,14 @@
}
},
{
- "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)\".",
+ "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": "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"
- }
- ]
- }
- },
- "/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"
- }
- ]
- }
- },
- "/firewalls": {
- "get": {
- "description": "Returns all [Firewalls](#firewalls).\n\nUse the provided URI parameters to modify the result.\n",
- "operationId": "list_firewalls",
- "parameters": [
+ "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",
@@ -8083,9 +10393,6 @@
"id",
"id:asc",
"id:desc",
- "name",
- "name:asc",
- "name:desc",
"created",
"created:asc",
"created:desc"
@@ -8095,24 +10402,6 @@
"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",
@@ -8143,121 +10432,152 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/list_firewalls_response"
+ "$ref": "#/components/schemas/list_floating_ips_response"
}
}
},
- "description": "The `firewalls` key contains the [Firewalls](#firewalls)."
+ "description": "Response for listing [Floating IPs](#floating-ips)."
}
},
- "summary": "List Firewalls",
+ "summary": "List Floating IPs",
"tags": [
- "firewalls"
+ "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\tfirewalls, err := client.Firewall.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\nfirewalls = client.firewalls.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 firewall list"
+ "source": "hcloud floating-ip 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",
+ "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": {
- "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"
+ "$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": {
+ "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"
+ },
+ "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_firewall_response"
+ "$ref": "#/components/schemas/create_floating_ip_response"
}
}
},
- "description": "The `firewall` key contains the created [Firewall](#firewalls)."
+ "description": "Response for creating a [Floating IP](#floating-ips).\n\nContains the created IP.\n"
}
},
- "summary": "Create a Firewall",
+ "summary": "Create a Floating IP",
"tags": [
- "firewalls"
+ "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\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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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",
"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"
+ "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",
"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]')"
+ "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"
+ }
+ ]
},
- "/firewalls/{id}": {
+ "/floating_ips/{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",
+ "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 Firewall.",
+ "description": "ID of the Floating IP.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Firewall.",
+ "description": "ID of the Floating IP.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -8267,42 +10587,42 @@
],
"responses": {
"204": {
- "description": "Firewall deleted."
+ "description": "Floating IP deleted."
}
},
- "summary": "Delete a Firewall",
+ "summary": "Delete a Floating IP",
"tags": [
- "firewalls"
+ "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.Firewall.Delete(ctx, &hcloud.Firewall{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.firewalls import Firewall\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.firewalls.delete(firewall=Firewall(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 firewall delete $FIREWALL"
+ "source": "hcloud floating-ip delete $FLOATINGIP"
}
]
},
"get": {
- "description": "Returns a single [Firewall](#firewalls).",
- "operationId": "get_firewall",
+ "description": "Returns a single [Floating IP](#floating-ips).",
+ "operationId": "get_floating_ip",
"parameters": [
{
- "description": "ID of the Firewall.",
+ "description": "ID of the Floating IP.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Firewall.",
+ "description": "ID of the Floating IP.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -8315,46 +10635,46 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/get_firewall_response"
+ "$ref": "#/components/schemas/get_floating_ip_response"
}
}
},
- "description": "The `firewall` key contains the [Firewall](#firewalls)."
+ "description": "Response for getting a single [Floating IP](#floating-ips)."
}
},
- "summary": "Get a Firewall",
+ "summary": "Get a Floating IP",
"tags": [
- "firewalls"
+ "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\tfirewall, _, err := client.Firewall.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\nfirewall = client.firewalls.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 firewall describe $FIREWALL"
+ "source": "hcloud floating-ip describe $FLOATINGIP"
}
]
},
"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",
+ "description": "Update a [Floating IP](#floating-ips).\n",
+ "operationId": "replace_floating_ip",
"parameters": [
{
- "description": "ID of the Firewall.",
+ "description": "ID of the Floating IP.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Firewall.",
+ "description": "ID of the Floating IP.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -8366,7 +10686,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/replace_firewall_request"
+ "$ref": "#/components/schemas/replace_floating_ip_request"
}
}
}
@@ -8375,53 +10695,91 @@
"200": {
"content": {
"application/json": {
+ "example": {
+ "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/replace_firewall_response"
+ "$ref": "#/components/schemas/replace_floating_ip_response"
}
}
},
- "description": "The `firewall` key contains the updated [Firewall](#firewalls)."
+ "description": "Response for updating a [Floating IP](#floating-ips).\n\nContains the updated [Floating IP](#floating-ips).\n"
}
},
- "summary": "Update a Firewall",
+ "summary": "Update a Floating IP",
"tags": [
- "firewalls"
+ "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\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\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.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.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 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 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"
+ }
+ ]
},
- "/firewalls/{id}/actions": {
+ "/floating_ips/{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",
+ "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 Firewall",
+ "description": "ID of the Floating IP.",
"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 Floating IP.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
- "title": "Firewall ID",
"type": "integer"
}
},
@@ -8504,7 +10862,7 @@
"example": {
"actions": [
{
- "command": "set_firewall_rules",
+ "command": "assign_floating_ip",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -8514,8 +10872,12 @@
"progress": 100,
"resources": [
{
- "id": 38,
- "type": "firewall"
+ "id": 4711,
+ "type": "server"
+ },
+ {
+ "id": 4712,
+ "type": "floating_ip"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -8538,27 +10900,32 @@
}
}
},
- "description": "The `actions` key contains a list of [Actions](#actions)."
+ "description": "Response for listing [Actions](#actions)."
}
},
- "summary": "List Actions for a Firewall",
+ "summary": "List Actions for a Floating IP",
"tags": [
- "firewalls"
+ "floating_ips"
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/firewalls/{id}/actions/{action_id}": {
+ "/floating_ips/{id}/actions/{action_id}": {
"get": {
- "description": "Returns a specific [Action](#actions) for a [Firewall](#firewalls).",
- "operationId": "get_action_for_firewall",
+ "description": "Returns a specific [Action](#actions) for a [Floating IP](#floating-ips).",
+ "operationId": "get_action_for_floating_ip",
"parameters": [
{
- "description": "ID of the Firewall.",
+ "description": "ID of the Floating IP.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Firewall.",
+ "description": "ID of the Floating IP.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -8585,7 +10952,7 @@
"application/json": {
"example": {
"action": {
- "command": "set_firewall_rules",
+ "command": "assign_floating_ip",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -8595,8 +10962,12 @@
"progress": 100,
"resources": [
{
- "id": 38,
- "type": "firewall"
+ "id": 42,
+ "type": "server"
+ },
+ {
+ "id": 4711,
+ "type": "floating_ip"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -8608,27 +10979,32 @@
}
}
},
- "description": "The `action` key contains the [Firewall](#firewalls) [Action](#actions)."
+ "description": "Response for getting an [Action](#actions)."
}
},
- "summary": "Get an Action for a Firewall",
+ "summary": "Get an Action for a Floating IP",
"tags": [
- "firewalls"
+ "floating_ips"
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/firewalls/{id}/actions/apply_to_resources": {
+ "/floating_ips/{id}/actions/assign": {
"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",
+ "description": "Assigns a [Floating IP](#floating-ips) to a [Server](#servers).",
+ "operationId": "assign_floating_ip_to_server",
"parameters": [
{
- "description": "ID of the Firewall.",
+ "description": "ID of the Floating IP.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Firewall.",
+ "description": "ID of the Floating IP.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -8639,18 +11015,8 @@
"requestBody": {
"content": {
"application/json": {
- "example": {
- "apply_to": [
- {
- "server": {
- "id": 42
- },
- "type": "server"
- }
- ]
- },
"schema": {
- "$ref": "#/components/schemas/apply_to_resources_request"
+ "$ref": "#/components/schemas/assign_floating_ip_to_server_request"
}
}
}
@@ -8660,74 +11026,77 @@
"content": {
"application/json": {
"example": {
- "actions": [
- {
- "command": "apply_firewall",
- "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": "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"
- }
- ]
+ {
+ "id": 4711,
+ "type": "floating_ip"
+ }
+ ],
+ "started": "2016-01-30T23:55:00+00:00",
+ "status": "success"
+ }
},
"schema": {
- "$ref": "#/components/schemas/apply_to_resources_response"
+ "$ref": "#/components/schemas/assign_floating_ip_to_server_response"
}
}
},
- "description": "The `actions` key contains multiple [Actions](#actions) with the `apply_firewall` command."
+ "description": "Response for assigning a [Floating IP](#floating-ips).\n\nContains an [Action](#actions) of type `assign_floating_ip`.\n"
}
},
- "summary": "Apply to Resources",
+ "summary": "Assign a Floating IP to a Server",
"tags": [
- "firewalls"
+ "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.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.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.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()"
+ "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 firewall apply-to-resource $FIREWALL \\\n --type server \\\n --server $SERVER"
+ "source": "hcloud floating-ip assign $FLOATINGIP $SERVER"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/firewalls/{id}/actions/remove_from_resources": {
+ "/floating_ips/{id}/actions/change_dns_ptr": {
"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",
+ "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 Firewall.",
+ "description": "ID of the Floating IP.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Firewall.",
+ "description": "ID of the Floating IP.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -8738,18 +11107,97 @@
"requestBody": {
"content": {
"application/json": {
- "example": {
- "remove_from": [
- {
- "server": {
- "id": 42
+ "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"
},
- "type": "server"
+ "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}"
+ },
+ {
+ "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": "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/remove_from_resources_request"
+ "$ref": "#/components/schemas/change_floating_ip_protection_request"
}
}
}
@@ -8758,75 +11206,74 @@
"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"
- }
- ]
+ "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": "floating_ip"
+ }
+ ],
+ "started": "2016-01-30T23:55:00+00:00",
+ "status": "success"
+ }
},
"schema": {
- "$ref": "#/components/schemas/remove_from_resources_response"
+ "$ref": "#/components/schemas/change_floating_ip_protection_response"
}
}
},
- "description": "The `actions` key contains multiple [Actions](#actions) with the `remove_firewall` command."
+ "description": "Response for changing a [Floating IPs](#floating-ips) protection settings.\n\nContains an [Action](#actions) of type `change_protection`.\n"
}
},
- "summary": "Remove from Resources",
+ "summary": "Change Floating IP Protection",
"tags": [
- "firewalls"
+ "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.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\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.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\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 firewall remove-from-resource $FIREWALL \\\n --type server \\\n --server $SERVER"
+ "source": "hcloud floating-ip enable-protection $FLOATINGIP delete\nhcloud floating-ip disable-protection $FLOATINGIP delete"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/firewalls/{id}/actions/set_rules": {
+ "/floating_ips/{id}/actions/unassign": {
"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",
+ "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 Firewall.",
+ "description": "ID of the Floating IP.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Firewall.",
+ "description": "ID of the Floating IP.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -8834,113 +11281,74 @@
}
}
],
- "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"
+ "action": {
+ "command": "unassign_floating_ip",
+ "error": {
+ "code": "action_failed",
+ "message": "Action failed"
},
- {
- "command": "apply_firewall",
- "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": "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"
- }
- ]
+ {
+ "id": 4711,
+ "type": "floating_ip"
+ }
+ ],
+ "started": "2016-01-30T23:55:00+00:00",
+ "status": "success"
+ }
},
"schema": {
- "$ref": "#/components/schemas/set_rules_response"
+ "$ref": "#/components/schemas/unassign_floating_ip_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": "Response for unassigning a [Floating IP](#floating-ips).\n\nContains an [Action](#actions) of type `unassign_floating_ip`.\n"
}
},
- "summary": "Set Rules",
+ "summary": "Unassign a Floating IP",
"tags": [
- "firewalls"
+ "floating_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\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\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.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\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 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 floating-ip unassign $FLOATINGIP"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/firewalls/actions": {
+ "/floating_ips/actions": {
"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": "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",
@@ -9039,81 +11447,174 @@
}
}
},
- "description": "The `actions` key contains a list of [Actions](#actions)."
+ "description": "Response for listing [Actions](#actions)."
}
},
"summary": "List Actions",
"tags": [
- "firewalls"
+ "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.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\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.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\nactions = client.floating_ips.actions.get_all()"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/firewalls/actions/{id}": {
+ "/floating_ips/actions/{id}": {
"get": {
- "description": "Returns the specific [Action](#actions).",
- "operationId": "get_firewall_action",
+ "description": "Returns a single [Action](#actions).",
+ "operationId": "get_floating_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": [
+ "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.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.floating_ips.actions.get_by_id(123)"
+ }
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/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",
"parameters": [
{
- "description": "ID of the Action",
- "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 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": {
- "description": "ID of the Action.",
- "example": 42,
- "format": "int64",
- "maximum": 9007199254740991,
- "type": "integer"
+ "items": {
+ "description": "Status of the Image.",
+ "enum": [
+ "available",
+ "creating",
+ "unavailable"
+ ],
+ "example": "available",
+ "type": "string"
+ },
+ "type": "array"
}
- }
- ],
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/get_action_response"
- }
- }
- },
- "description": "The `action` key contains the [Action](#actions)."
- }
- },
- "summary": "Get an Action",
- "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\taction, _, err := client.Firewall.Action.GetByID(ctx, 123)\n}"
+ "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"
+ }
},
{
- "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)"
- }
- ]
- }
- },
- "/floating_ips": {
- "get": {
- "description": "List multiple [Floating IPs](#floating-ips).\n\nUse the provided URI parameters to modify the result.\n",
- "operationId": "list_floating_ips",
- "parameters": [
+ "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",
@@ -9133,23 +11634,18 @@
}
},
{
- "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n",
+ "description": "Filter resources by cpu architecture. The response will only contain the resources\nwith the specified cpu architecture.\n",
"in": "query",
- "name": "sort",
+ "name": "architecture",
"required": false,
"schema": {
- "items": {
- "enum": [
- "id",
- "id:asc",
- "id:desc",
- "created",
- "created:asc",
- "created:desc"
- ],
- "type": "string"
- },
- "type": "array"
+ "description": "CPU architecture of the Resource.",
+ "enum": [
+ "x86",
+ "arm"
+ ],
+ "example": "x86",
+ "type": "string"
}
},
{
@@ -9182,147 +11678,53 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/list_floating_ips_response"
+ "$ref": "#/components/schemas/list_images_response"
}
}
},
- "description": "Response for listing [Floating IPs](#floating-ips)."
+ "description": "The `images` key in the reply contains an array of Image objects with this structure."
}
},
- "summary": "List Floating IPs",
+ "summary": "List Images",
"tags": [
- "floating_ips"
+ "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\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\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\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\nimages = client.images.get_all()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud floating-ip list"
+ "source": "hcloud image 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",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$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": {
- "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"
- },
- "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_floating_ip_response"
- }
- }
- },
- "description": "Response for creating a [Floating IP](#floating-ips).\n\nContains the created IP.\n"
- }
- },
- "summary": "Create 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\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",
- "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"
- },
- {
- "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"
- }
- ]
- }
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/floating_ips/{id}": {
+ "/images/{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 an Image. Only Images of type `snapshot` and `backup` can be deleted.",
+ "operationId": "delete_image",
"parameters": [
{
- "description": "ID of the Floating IP.",
+ "description": "ID of the Image.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Floating IP.",
+ "description": "ID of the Image.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -9332,42 +11734,42 @@
],
"responses": {
"204": {
- "description": "Floating IP deleted."
+ "description": "Image deleted."
}
},
- "summary": "Delete a Floating IP",
+ "summary": "Delete an Image",
"tags": [
- "floating_ips"
+ "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.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.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.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.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 floating-ip delete $FLOATINGIP"
+ "source": "hcloud image delete $IMAGE"
}
]
},
"get": {
- "description": "Returns a single [Floating IP](#floating-ips).",
- "operationId": "get_floating_ip",
+ "description": "Returns a specific Image object.",
+ "operationId": "get_image",
"parameters": [
{
- "description": "ID of the Floating IP.",
+ "description": "ID of the Image.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Floating IP.",
+ "description": "ID of the Image.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -9380,46 +11782,46 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/get_floating_ip_response"
+ "$ref": "#/components/schemas/get_image_response"
}
}
},
- "description": "Response for getting a single [Floating IP](#floating-ips)."
+ "description": "The `image` key in the reply contains an Image object with this structure."
}
},
- "summary": "Get a Floating IP",
+ "summary": "Get an Image",
"tags": [
- "floating_ips"
+ "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\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\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\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\nimage = client.images.get_by_id(123)"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud floating-ip describe $FLOATINGIP"
+ "source": "hcloud image describe $IMAGE"
}
]
},
"put": {
- "description": "Update a [Floating IP](#floating-ips).\n",
- "operationId": "replace_floating_ip",
+ "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 Floating IP.",
+ "description": "ID of the Image.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Floating IP.",
+ "description": "ID of the Image.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -9431,7 +11833,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/replace_floating_ip_request"
+ "$ref": "#/components/schemas/replace_image_request"
}
}
}
@@ -9441,82 +11843,82 @@
"content": {
"application/json": {
"example": {
- "floating_ip": {
- "blocked": false,
+ "image": {
+ "architecture": "x86",
+ "bound_to": null,
"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",
+ "created_from": {
"id": 1,
- "latitude": 50.47612,
- "longitude": 12.370071,
- "name": "fsn1",
- "network_zone": "eu-central"
+ "name": "Server"
},
+ "deleted": null,
+ "deprecated": "2018-02-28T00:00:00+00:00",
+ "description": "My new Image description",
+ "disk_size": 10,
"id": 4711,
- "ip": "2001:db8::/64",
+ "image_size": 2.3,
"labels": {
"key": "value"
},
- "name": "Web Frontend",
+ "name": null,
+ "os_flavor": "ubuntu",
+ "os_version": "20.04",
"protection": {
"delete": false
},
- "server": 42,
- "type": "ipv6"
+ "rapid_deploy": false,
+ "status": "available",
+ "type": "snapshot"
}
},
"schema": {
- "$ref": "#/components/schemas/replace_floating_ip_response"
+ "$ref": "#/components/schemas/replace_image_response"
}
}
},
- "description": "Response for updating a [Floating IP](#floating-ips).\n\nContains the updated [Floating IP](#floating-ips).\n"
+ "description": "The image key in the reply contains the modified Image object."
}
},
- "summary": "Update a Floating IP",
+ "summary": "Update an Image",
"tags": [
- "floating_ips"
+ "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\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\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\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.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 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 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"
+ }
+ ]
},
- "/floating_ips/{id}/actions": {
+ "/images/{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 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": "ID of the Floating IP.",
+ "description": "ID of the Image.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Floating IP.",
+ "description": "ID of the Image.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -9602,7 +12004,7 @@
"example": {
"actions": [
{
- "command": "assign_floating_ip",
+ "command": "change_protection",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -9613,11 +12015,7 @@
"resources": [
{
"id": 4711,
- "type": "server"
- },
- {
- "id": 4712,
- "type": "floating_ip"
+ "type": "image"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -9640,27 +12038,32 @@
}
}
},
- "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 an Image",
"tags": [
- "floating_ips"
+ "images"
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/floating_ips/{id}/actions/{action_id}": {
+ "/images/{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 an Image.",
+ "operationId": "get_action_for_image",
"parameters": [
{
- "description": "ID of the Floating IP.",
+ "description": "ID of the Image.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Floating IP.",
+ "description": "ID of the Image.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -9687,7 +12090,7 @@
"application/json": {
"example": {
"action": {
- "command": "assign_floating_ip",
+ "command": "change_protection",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -9696,13 +12099,9 @@
"id": 13,
"progress": 100,
"resources": [
- {
- "id": 42,
- "type": "server"
- },
{
"id": 4711,
- "type": "floating_ip"
+ "type": "image"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -9714,27 +12113,32 @@
}
}
},
- "description": "Response for getting an [Action](#actions)."
+ "description": "The `action` key contains the Image Action."
}
},
- "summary": "Get an Action for a Floating IP",
+ "summary": "Get an Action for an Image",
"tags": [
- "floating_ips"
+ "images"
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/floating_ips/{id}/actions/assign": {
+ "/images/{id}/actions/change_protection": {
"post": {
- "description": "Assigns a [Floating IP](#floating-ips) to a [Server](#servers).",
- "operationId": "assign_floating_ip_to_server",
+ "description": "Changes the protection configuration of the Image. Can only be used on snapshots.",
+ "operationId": "change_image_protection",
"parameters": [
{
- "description": "ID of the Floating IP.",
+ "description": "ID of the Image.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Floating IP.",
+ "description": "ID of the Image.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -9746,7 +12150,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/assign_floating_ip_to_server_request"
+ "$ref": "#/components/schemas/change_image_protection_request"
}
}
}
@@ -9757,7 +12161,7 @@
"application/json": {
"example": {
"action": {
- "command": "assign_floating_ip",
+ "command": "change_protection",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -9766,13 +12170,9 @@
"id": 13,
"progress": 100,
"resources": [
- {
- "id": 42,
- "type": "server"
- },
{
"id": 4711,
- "type": "floating_ip"
+ "type": "image"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -9780,48 +12180,181 @@
}
},
"schema": {
- "$ref": "#/components/schemas/assign_floating_ip_to_server_response"
+ "$ref": "#/components/schemas/change_image_protection_response"
+ }
+ }
+ },
+ "description": "The `action` key contains the `change_protection` Action."
+ }
+ },
+ "summary": "Change Image Protection",
+ "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\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.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 image enable-protection $IMAGE delete\nhcloud image disable-protection $IMAGE delete"
+ }
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/images/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",
+ "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": "Response for assigning a [Floating IP](#floating-ips).\n\nContains an [Action](#actions) of type `assign_floating_ip`.\n"
+ "description": "The `actions` key contains a list of Actions."
}
},
- "summary": "Assign a Floating IP to a Server",
+ "summary": "List Actions",
"tags": [
- "floating_ips"
+ "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\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\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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"
+ "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"
+ }
+ ]
},
- "/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",
+ "/images/actions/{id}": {
+ "get": {
+ "description": "Returns a specific Action object.",
+ "operationId": "get_image_action",
"parameters": [
{
- "description": "ID of the Floating IP.",
+ "description": "ID of the Action.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Floating IP.",
+ "description": "ID of the Action.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -9829,298 +12362,215 @@
}
}
],
- "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": {
+ "200": {
"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"
+ "$ref": "#/components/schemas/get_action_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 in the reply has this structure."
}
},
- "summary": "Change reverse DNS records for a Floating IP",
+ "summary": "Get an Action",
"tags": [
- "floating_ips"
+ "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\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\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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.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"
+ "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"
+ }
+ ]
},
- "/floating_ips/{id}/actions/change_protection": {
- "post": {
- "description": "Changes the protection settings configured for the [Floating IP](#floating-ips).",
- "operationId": "change_floating_ip_protection",
+ "/isos": {
+ "get": {
+ "description": "Returns all available ISO objects.",
+ "operationId": "list_isos",
"parameters": [
{
- "description": "ID of the Floating IP.",
- "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 Floating IP.",
- "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": {
- "schema": {
- "$ref": "#/components/schemas/change_floating_ip_protection_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": {
- "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": "floating_ip"
- }
- ],
- "started": "2016-01-30T23:55:00+00:00",
- "status": "success"
- }
- },
"schema": {
- "$ref": "#/components/schemas/change_floating_ip_protection_response"
+ "$ref": "#/components/schemas/list_isos_response"
}
}
},
- "description": "Response for changing a [Floating IPs](#floating-ips) protection settings.\n\nContains an [Action](#actions) of type `change_protection`.\n"
+ "description": "The `isos` key in the reply contains an array of iso objects with this structure."
}
},
- "summary": "Change Floating IP Protection",
+ "summary": "List ISOs",
"tags": [
- "floating_ips"
+ "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\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\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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.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\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nisos = client.isos.get_all()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud floating-ip enable-protection $FLOATINGIP delete\nhcloud floating-ip disable-protection $FLOATINGIP delete"
+ "source": "hcloud iso list"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/floating_ips/{id}/actions/unassign": {
- "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",
- "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"
- }
- }
- ],
- "responses": {
- "201": {
- "content": {
- "application/json": {
- "example": {
- "action": {
- "command": "unassign_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"
- }
- },
+ "/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/unassign_floating_ip_response"
+ "$ref": "#/components/schemas/get_iso_response"
}
}
},
- "description": "Response for unassigning a [Floating IP](#floating-ips).\n\nContains an [Action](#actions) of type `unassign_floating_ip`.\n"
+ "description": "The `iso` key in the reply contains an array of ISO objects with this structure."
}
},
- "summary": "Unassign a Floating IP",
+ "summary": "Get an ISO",
"tags": [
- "floating_ips"
+ "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\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\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.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\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\niso = client.isos.get_by_id(123)"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud floating-ip unassign $FLOATINGIP"
+ "source": "hcloud iso describe $ISO"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/floating_ips/actions": {
+ "/load_balancer_types": {
"get": {
- "description": "Lists multiple [Actions](#actions).\n\nUse the provided URI parameters to modify the result.\n",
- "operationId": "list_floating_ip_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"
}
},
{
@@ -10153,43 +12603,53 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/list_actions_response"
+ "$ref": "#/components/schemas/list_load_balancer_types_response"
}
}
},
- "description": "Response for listing [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": [
- "floating_ips"
+ "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.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\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.floating_ips.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"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/floating_ips/actions/{id}": {
+ "/load_balancer_types/{id}": {
"get": {
- "description": "Returns a single [Action](#actions).",
- "operationId": "get_floating_ip_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,
@@ -10202,35 +12662,45 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/get_action_response"
+ "$ref": "#/components/schemas/get_load_balancer_type_response"
}
}
},
- "description": "Response for getting a single [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": [
- "floating_ips"
+ "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.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\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.floating_ips.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"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/images": {
+ "/load_balancers": {
"get": {
- "description": "Returns all Image objects. You can select specific Image types only and sort the results by using URI parameters.",
- "operationId": "list_images",
+ "description": "Gets all existing Load Balancers that you have available.",
+ "operationId": "list_load_balancers",
"parameters": [
{
"description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n",
@@ -10255,66 +12725,6 @@
"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",
@@ -10334,92 +12744,281 @@
}
},
{
- "description": "Filter resources by cpu architecture. The response will only contain the resources\nwith the specified cpu architecture.\n",
+ "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".",
"in": "query",
- "name": "architecture",
+ "name": "page",
"required": false,
"schema": {
- "description": "CPU architecture of the Resource.",
- "enum": [
- "x86",
- "arm"
- ],
- "example": "x86",
- "type": "string"
+ "default": 1,
+ "example": 2,
+ "format": "int64",
+ "type": "integer"
}
},
{
- "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".",
+ "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".",
"in": "query",
- "name": "page",
+ "name": "per_page",
"required": false,
"schema": {
- "default": 1,
- "example": 2,
+ "default": 25,
+ "example": 25,
"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}"
},
{
- "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"
+ "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": {
- "200": {
+ "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
+ }
+ ]
+ }
+ },
"schema": {
- "$ref": "#/components/schemas/list_images_response"
+ "$ref": "#/components/schemas/create_load_balancer_response"
}
}
},
- "description": "The `images` key in the reply contains an array of Image objects with this structure."
+ "description": "The `load_balancer` key contains the Load Balancer that was just created."
}
},
- "summary": "List Images",
+ "summary": "Create 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\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\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.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 image list"
+ "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"
+ }
+ ]
},
- "/images/{id}": {
+ "/load_balancers/{id}": {
"delete": {
- "description": "Deletes an Image. Only Images of type `snapshot` and `backup` can be deleted.",
- "operationId": "delete_image",
+ "description": "Deletes a Load Balancer.",
+ "operationId": "delete_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,
@@ -10429,42 +13028,42 @@
],
"responses": {
"204": {
- "description": "Image deleted."
+ "description": "Load Balancer deleted."
}
},
- "summary": "Delete an Image",
+ "summary": "Delete 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\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\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.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\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 image delete $IMAGE"
+ "source": "hcloud load-balancer delete $LOADBALANCER"
}
]
},
"get": {
- "description": "Returns a specific Image object.",
- "operationId": "get_image",
+ "description": "Gets a specific Load Balancer object.",
+ "operationId": "get_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,
@@ -10477,46 +13076,46 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/get_image_response"
+ "$ref": "#/components/schemas/get_load_balancer_response"
}
}
},
- "description": "The `image` key in the reply contains an Image object with this structure."
+ "description": "The `load_balancer` key contains the Load Balancer."
}
},
- "summary": "Get an Image",
+ "summary": "Get 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.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\nimage = client.images.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 image describe $IMAGE"
+ "source": "hcloud load-balancer describe $LOADBALANCER"
}
]
},
"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",
+ "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 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,
@@ -10528,7 +13127,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/replace_image_request"
+ "$ref": "#/components/schemas/replace_load_balancer_request"
}
}
}
@@ -10538,77 +13137,194 @@
"content": {
"application/json": {
"example": {
- "image": {
- "architecture": "x86",
- "bound_to": null,
- "created": "2016-01-30T23:50:00+00:00",
- "created_from": {
- "id": 1,
- "name": "Server"
+ "load_balancer": {
+ "algorithm": {
+ "type": "round_robin"
},
- "deleted": null,
- "deprecated": "2018-02-28T00:00:00+00:00",
- "description": "My new Image description",
- "disk_size": 10,
+ "created": "2016-01-30T23:50:00+00:00",
"id": 4711,
- "image_size": 2.3,
+ "included_traffic": 654321,
+ "ingoing_traffic": 123456,
"labels": {
"key": "value"
},
- "name": null,
- "os_flavor": "ubuntu",
- "os_version": "20.04",
+ "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
+ }
+ ],
"protection": {
"delete": false
},
- "rapid_deploy": false,
- "status": "available",
- "type": "snapshot"
+ "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_image_response"
+ "$ref": "#/components/schemas/replace_load_balancer_response"
}
}
},
- "description": "The image key in the reply contains the modified Image object."
+ "description": "The `load_balancer` key contains the updated Load Balancer."
}
},
- "summary": "Update an Image",
+ "summary": "Update 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\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.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\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 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 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"
+ }
+ ]
},
- "/images/{id}/actions": {
+ "/load_balancers/{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",
+ "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 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,
@@ -10694,7 +13410,7 @@
"example": {
"actions": [
{
- "command": "change_protection",
+ "command": "add_service",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -10705,7 +13421,7 @@
"resources": [
{
"id": 4711,
- "type": "image"
+ "type": "load_balancer"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -10731,37 +13447,192 @@
"description": "The `actions` key contains a list of Actions."
}
},
- "summary": "List Actions for an Image",
+ "summary": "List Actions for a Load Balancer",
"tags": [
- "images"
+ "load_balancers"
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/load_balancers/{id}/actions/{action_id}": {
+ "get": {
+ "description": "Returns a specific Action for a Load Balancer.",
+ "operationId": "get_action_for_load_balancer",
+ "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": "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": "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"
+ }
+ }
+ },
+ "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"
+ }
+ ]
},
- "/images/{id}/actions/{action_id}": {
- "get": {
- "description": "Returns a specific Action for an Image.",
- "operationId": "get_action_for_image",
+ "/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 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/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}"
},
{
- "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.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": "action_id",
+ "name": "id",
"required": true,
"schema": {
- "description": "ID of the Action.",
+ "description": "ID of the Load Balancer.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -10769,13 +13640,22 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/add_target_request"
+ }
+ }
+ }
+ },
"responses": {
- "200": {
+ "201": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "change_protection",
+ "command": "add_target",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -10786,7 +13666,7 @@
"resources": [
{
"id": 4711,
- "type": "image"
+ "type": "load_balancer"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -10794,31 +13674,53 @@
}
},
"schema": {
- "$ref": "#/components/schemas/get_action_response"
+ "$ref": "#/components/schemas/add_target_response"
}
}
},
- "description": "The `action` key contains the Image Action."
+ "description": "The `action` key contains the `add_target` Action."
}
},
- "summary": "Get an Action for an Image",
+ "summary": "Add Target",
"tags": [
- "images"
+ "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"
+ }
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/images/{id}/actions/change_protection": {
+ "/load_balancers/{id}/actions/attach_to_network": {
"post": {
- "description": "Changes the protection configuration of the Image. Can only be used on snapshots.",
- "operationId": "change_image_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 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,
@@ -10830,7 +13732,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/change_image_protection_request"
+ "$ref": "#/components/schemas/attach_load_balancer_to_network_request"
}
}
}
@@ -10841,7 +13743,7 @@
"application/json": {
"example": {
"action": {
- "command": "change_protection",
+ "command": "attach_to_network",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -10852,7 +13754,7 @@
"resources": [
{
"id": 4711,
- "type": "image"
+ "type": "load_balancer"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -10860,171 +13762,141 @@
}
},
"schema": {
- "$ref": "#/components/schemas/change_image_protection_response"
+ "$ref": "#/components/schemas/attach_load_balancer_to_network_response"
}
}
},
- "description": "The `action` key contains the `change_protection` Action."
+ "description": "The `action` key contains the `attach_to_network` Action."
}
},
- "summary": "Change Image Protection",
+ "summary": "Attach a Load Balancer to 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\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\"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.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\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 image enable-protection $IMAGE delete\nhcloud image disable-protection $IMAGE delete"
+ "source": "hcloud load-balancer attach-to-network $LOADBALANCER \\\n --ip 10.0.1.1 \\\n --network 4711"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/images/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",
+ "/load_balancers/{id}/actions/change_algorithm": {
+ "post": {
+ "description": "Change the algorithm that determines to which target new requests are sent.",
+ "operationId": "change_algorithm",
"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_algorithm_request"
+ }
+ }
+ }
+ },
"responses": {
- "200": {
+ "201": {
"content": {
"application/json": {
+ "example": {
+ "action": {
+ "command": "change_algorithm",
+ "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/list_actions_response"
+ "$ref": "#/components/schemas/change_algorithm_response"
}
}
},
- "description": "The `actions` key contains a list of Actions."
+ "description": "The `action` key contains the `change_algorithm` Action."
}
},
- "summary": "List Actions",
+ "summary": "Change Algorithm",
"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\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\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\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 load-balancer change-algorithm $LOADBALANCER \\\n --algorithm-type round_robin"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/images/actions/{id}": {
- "get": {
- "description": "Returns a specific Action object.",
- "operationId": "get_image_action",
+ "/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": "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,
@@ -11032,146 +13904,176 @@
}
}
],
+ "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/get_action_response"
+ "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_load_balancer_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": "Change reverse DNS entry for this 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.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.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\naction = client.images.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_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"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/isos": {
- "get": {
- "description": "Returns all available ISO objects.",
- "operationId": "list_isos",
+ "/load_balancers/{id}/actions/change_protection": {
+ "post": {
+ "description": "Changes the protection configuration of a Load Balancer.",
+ "operationId": "change_load_balancer_protection",
"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 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,
+ "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_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/list_isos_response"
+ "$ref": "#/components/schemas/change_load_balancer_protection_response"
}
}
},
- "description": "The `isos` key in the reply contains an array of iso objects with this structure."
+ "description": "The `action` key contains the `change_protection` Action."
}
},
- "summary": "List ISOs",
+ "summary": "Change Load Balancer Protection",
"tags": [
- "isos"
+ "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\tisos, err := client.ISO.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.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\nisos = client.isos.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_protection(\n load_balancer=LoadBalancer(id=123),\n delete=True,\n)\n\naction.wait_until_finished()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud iso list"
+ "source": "hcloud load-balancer enable-protection $LOADBALANCER delete\nhcloud load-balancer disable-protection $LOADBALANCER delete"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/isos/{id}": {
- "get": {
- "description": "Returns a specific ISO object.",
- "operationId": "get_iso",
+ "/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": "ID of the ISO.",
+ "description": "ID of the Load Balancer.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the ISO.",
+ "description": "ID of the Load Balancer.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -11179,127 +14081,175 @@
}
}
],
+ "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/get_iso_response"
+ "$ref": "#/components/schemas/change_type_of_load_balancer_response"
}
}
},
- "description": "The `iso` key in the reply contains an array of ISO objects with this structure."
+ "description": "The `action` key contains the `change_load_balancer_type` Action."
}
},
- "summary": "Get an ISO",
+ "summary": "Change the Type of a Load Balancer",
"tags": [
- "isos"
+ "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\tiso, _, err := client.ISO.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.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\niso = client.isos.get_by_id(123)"
+ "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 iso describe $ISO"
+ "source": "hcloud load-balancer change-type $LOADBALANCER lb21"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/load_balancer_types": {
- "get": {
- "description": "Gets all Load Balancer type objects.",
- "operationId": "list_load_balancer_types",
+ "/load_balancers/{id}/actions/delete_service": {
+ "post": {
+ "description": "Delete a service of a Load Balancer.",
+ "operationId": "delete_service",
"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 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/delete_service_request"
+ }
+ }
+ }
+ },
"responses": {
- "200": {
+ "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/list_load_balancer_types_response"
+ "$ref": "#/components/schemas/delete_service_response"
}
}
},
- "description": "The `load_balancer_types` key in the reply contains an array of Load Balancer type objects with this structure."
+ "description": "The `action` key contains the `delete_service` Action."
}
},
- "summary": "List Load Balancer Types",
+ "summary": "Delete Service",
"tags": [
- "load_balancer_types"
+ "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\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\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\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\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 load-balancer-type list"
+ "source": "hcloud load-balancer delete-service $LOADBALANCER \\\n --listen-port 443"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/load_balancer_types/{id}": {
- "get": {
- "description": "Gets a specific Load Balancer type object.",
- "operationId": "get_load_balancer_type",
+ "/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 Load Balancer Type.",
+ "description": "ID of the Load Balancer.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Load Balancer Type.",
+ "description": "ID of the Load Balancer.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -11307,125 +14257,135 @@
}
}
],
+ "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_load_balancer_type_response"
+ "$ref": "#/components/schemas/detach_load_balancer_from_network_response"
}
}
},
- "description": "The `load_balancer_type` key in the reply contains a Load Balancer type object with this structure."
+ "description": "The `action` key contains the `detach_from_network` Action."
}
},
- "summary": "Get a Load Balancer Type",
+ "summary": "Detach a Load Balancer from a Network",
"tags": [
- "load_balancer_types"
+ "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\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\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\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\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-type describe $LOADBALANCERTYPE"
+ "source": "hcloud load-balancer detach-from-network $LOADBALANCER \\\n --network $NETWORK"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/load_balancers": {
- "get": {
- "description": "Gets all existing Load Balancers that you have available.",
- "operationId": "list_load_balancers",
+ "/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": "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,
+ "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"
}
}
],
"responses": {
- "200": {
+ "201": {
"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/list_load_balancers_response"
+ "$ref": "#/components/schemas/disable_public_interface_of_load_balancer_response"
}
}
},
- "description": "The `load_balancers` key contains a list of Load Balancers."
+ "description": "The `action` key contains the `disable_public_interface` Action."
}
},
- "summary": "List Load Balancers",
+ "summary": "Disable the public interface of a Load Balancer",
"tags": [
"load_balancers"
],
@@ -11433,198 +14393,82 @@
{
"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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nload_balancers = client.load_balancers.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.disable_public_interface(\n load_balancer=LoadBalancer(id=123),\n)\n\naction.wait_until_finished()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud load-balancer list"
+ "source": "hcloud load-balancer disable-public-interface $LOADBALANCER"
}
]
},
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/load_balancers/{id}/actions/enable_public_interface": {
"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"
- }
+ "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 Load Balancer.",
+ "in": "path",
+ "name": "id",
+ "required": true,
+ "schema": {
+ "description": "ID of the Load Balancer.",
+ "example": 42,
+ "format": "int64",
+ "maximum": 9007199254740991,
+ "type": "integer"
}
}
- },
+ ],
"responses": {
"201": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "create_load_balancer",
+ "command": "enable_public_interface",
"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"
- }
- ],
- "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"
+ "id": 42,
+ "type": "server"
},
- "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
+ "id": 4711,
+ "type": "network"
}
],
- "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
- }
- ]
+ "started": "2016-01-30T23:50:00+00:00",
+ "status": "running"
}
},
"schema": {
- "$ref": "#/components/schemas/create_load_balancer_response"
+ "$ref": "#/components/schemas/enable_public_interface_of_load_balancer_response"
}
}
},
- "description": "The `load_balancer` key contains the Load Balancer that was just created."
+ "description": "The `action` key contains the `enable_public_interface` Action."
}
},
- "summary": "Create a Load Balancer",
+ "summary": "Enable the public interface of a Load Balancer",
"tags": [
"load_balancers"
],
@@ -11632,25 +14476,30 @@
{
"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\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.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\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 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 load-balancer enable-public-interface $LOADBALANCER"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/load_balancers/{id}": {
- "delete": {
- "description": "Deletes a Load Balancer.",
- "operationId": "delete_load_balancer",
+ "/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.",
@@ -11666,12 +14515,48 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/remove_target_request"
+ }
+ }
+ }
+ },
"responses": {
- "204": {
- "description": "Load Balancer deleted."
+ "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": "Delete a Load Balancer",
+ "summary": "Remove Target",
"tags": [
"load_balancers"
],
@@ -11679,23 +14564,30 @@
{
"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\"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}"
},
{
"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.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 delete $LOADBALANCER"
+ "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"
}
]
},
- "get": {
- "description": "Gets a specific Load Balancer object.",
- "operationId": "get_load_balancer",
+ "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.",
@@ -11711,19 +14603,48 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/update_service_request"
+ }
+ }
+ }
+ },
"responses": {
- "200": {
+ "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/get_load_balancer_response"
+ "$ref": "#/components/schemas/update_service_response"
}
}
},
- "description": "The `load_balancer` key contains the Load Balancer."
+ "description": "The `action` key contains the `update_service` Action."
}
},
- "summary": "Get a Load Balancer",
+ "summary": "Update Service",
"tags": [
"load_balancers"
],
@@ -11731,23 +14652,30 @@
{
"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\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\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\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 describe $LOADBALANCER"
+ "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"
}
]
},
- "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",
+ "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.",
@@ -11761,171 +14689,63 @@
"maximum": 9007199254740991,
"type": "integer"
}
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/replace_load_balancer_request"
- }
+ },
+ {
+ "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"
}
- }
- },
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "example": {
- "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": "new-name",
- "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"
- }
- ],
- "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
- }
- ]
- }
- },
+ },
+ {
+ "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": {
+ "200": {
+ "content": {
+ "application/json": {
"schema": {
- "$ref": "#/components/schemas/replace_load_balancer_response"
+ "$ref": "#/components/schemas/get_metrics_for_loadbalancer_response"
}
}
},
- "description": "The `load_balancer` key contains the updated Load Balancer."
+ "description": "The `metrics` key in the reply contains a metrics object with this structure."
}
},
- "summary": "Update a Load Balancer",
+ "summary": "Get Metrics for a LoadBalancer",
"tags": [
"load_balancers"
],
@@ -11933,37 +14753,45 @@
{
"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\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.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\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 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 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/{id}/actions": {
+ "/load_balancers/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": "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",
"parameters": [
{
- "description": "ID of the Load Balancer.",
- "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 Load Balancer.",
- "example": 42,
- "format": "int64",
- "maximum": 9007199254740991,
- "type": "integer"
+ "items": {
+ "description": "ID of the Action.",
+ "example": 42,
+ "format": "int64",
+ "maximum": 9007199254740991,
+ "type": "integer"
+ },
+ "type": "array"
}
},
{
@@ -12042,38 +14870,6 @@
"200": {
"content": {
"application/json": {
- "example": {
- "actions": [
- {
- "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"
- }
- ],
- "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"
}
@@ -12082,40 +14878,138 @@
"description": "The `actions` key contains a list of Actions."
}
},
- "summary": "List Actions for a Load Balancer",
+ "summary": "List Actions",
"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\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.load_balancers.actions.get_all()"
+ }
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/load_balancers/{id}/actions/{action_id}": {
+ "/load_balancers/actions/{id}": {
"get": {
- "description": "Returns a specific Action for a Load Balancer.",
- "operationId": "get_action_for_load_balancer",
+ "description": "Returns a specific Action object.",
+ "operationId": "get_load_balancer_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,
"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": [
+ "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.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)"
+ }
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/locations": {
+ "get": {
+ "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",
+ "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": "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"
}
}
@@ -12124,52 +15018,54 @@
"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": "load_balancer"
- }
- ],
- "started": "2016-01-30T23:55:00+00:00",
- "status": "success"
- }
- },
"schema": {
- "$ref": "#/components/schemas/get_action_response"
+ "$ref": "#/components/schemas/list_locations_response"
}
}
},
- "description": "The `action` key contains the Load Balancer Action."
+ "description": "Response with the [Locations](#locations)."
+ }
+ },
+ "summary": "List Locations",
+ "tags": [
+ "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\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\nlocations = client.locations.get_all()"
+ },
+ {
+ "label": "CLI",
+ "lang": "Shell",
+ "source": "hcloud location list"
}
- },
- "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",
+ "/locations/{id}": {
+ "get": {
+ "description": "Returns a [Location](#locations).",
+ "operationId": "get_location",
"parameters": [
{
- "description": "ID of the Load Balancer.",
+ "description": "ID of the Location.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Load Balancer.",
+ "description": "ID of the Location.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -12177,177 +15073,159 @@
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/add_service_request"
- }
- }
- }
- },
"responses": {
- "201": {
+ "200": {
"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"
+ "$ref": "#/components/schemas/get_location_response"
}
}
},
- "description": "The `action` key contains the `add_service` Action."
+ "description": "Response with the [Location](#locations)."
}
},
- "summary": "Add Service",
+ "summary": "Get a Location",
"tags": [
- "load_balancers"
+ "locations"
],
"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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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()"
+ "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 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"
+ "source": "hcloud location describe $LOCATION"
}
]
- }
+ },
+ "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",
+ "/networks": {
+ "get": {
+ "description": "List multiple [Networks](#networks).\n\nUse the provided URI parameters to modify the result.\n",
+ "operationId": "list_networks",
"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": {
- "description": "ID of the Load Balancer.",
- "example": 42,
+ "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",
- "maximum": 9007199254740991,
"type": "integer"
}
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/add_target_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": {
- "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"
+ "$ref": "#/components/schemas/list_networks_response"
}
}
},
- "description": "The `action` key contains the `add_target` Action."
+ "description": "Response for listing [Networks](#networks)."
}
},
- "summary": "Add Target",
+ "summary": "List Networks",
"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\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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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.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()"
+ "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 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"
+ "source": "hcloud network list"
}
]
- }
- },
- "/load_balancers/{id}/actions/attach_to_network": {
+ },
"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",
- "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 [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/attach_load_balancer_to_network_request"
+ "$ref": "#/components/schemas/create_network_request"
}
}
}
@@ -12356,69 +15234,99 @@
"201": {
"content": {
"application/json": {
- "example": {
- "action": {
- "command": "attach_to_network",
- "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/attach_load_balancer_to_network_response"
+ "$ref": "#/components/schemas/create_network_response"
}
}
},
- "description": "The `action` key contains the `attach_to_network` Action."
+ "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"
+ }
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/networks/{id}": {
+ "delete": {
+ "description": "Deletes a [Network](#networks).\n\nAttached resources will be detached automatically.\n",
+ "operationId": "delete_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"
+ }
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "Response for deleting a [Network](#networks)."
}
},
- "summary": "Attach a Load Balancer to a Network",
+ "summary": "Delete 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\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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\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 attach-to-network $LOADBALANCER \\\n --ip 10.0.1.1 \\\n --network 4711"
+ "source": "hcloud network delete $NETWORK"
}
]
- }
- },
- "/load_balancers/{id}/actions/change_algorithm": {
- "post": {
- "description": "Change the algorithm that determines to which target new requests are sent.",
- "operationId": "change_algorithm",
+ },
+ "get": {
+ "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,
@@ -12426,82 +15334,51 @@
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/change_algorithm_request"
- }
- }
- }
- },
"responses": {
- "201": {
+ "200": {
"content": {
"application/json": {
- "example": {
- "action": {
- "command": "change_algorithm",
- "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/change_algorithm_response"
+ "$ref": "#/components/schemas/get_network_response"
}
}
},
- "description": "The `action` key contains the `change_algorithm` Action."
+ "description": "The `network` key contains the network."
}
},
- "summary": "Change Algorithm",
+ "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\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\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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\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 change-algorithm $LOADBALANCER \\\n --algorithm-type round_robin"
+ "source": "hcloud network describe $NETWORK"
}
]
- }
- },
- "/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",
+ },
+ "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",
"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,
@@ -12513,245 +15390,256 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_load_balancer_request"
+ "$ref": "#/components/schemas/replace_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": {
+ "200": {
"content": {
"application/json": {
"example": {
- "action": {
- "command": "change_dns_ptr",
- "error": {
- "code": "action_failed",
- "message": "Action failed"
+ "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"
},
- "finished": null,
- "id": 13,
- "progress": 0,
- "resources": [
+ "load_balancers": [
+ 42
+ ],
+ "name": "new-name",
+ "protection": {
+ "delete": false
+ },
+ "routes": [
{
- "id": 42,
- "type": "load_balancer"
+ "destination": "10.100.1.0/24",
+ "gateway": "10.0.1.1"
}
],
- "started": "2016-01-30T23:50:00+00:00",
- "status": "running"
+ "servers": [
+ 42
+ ],
+ "subnets": [
+ {
+ "gateway": "10.0.0.1",
+ "ip_range": "10.0.1.0/24",
+ "network_zone": "eu-central",
+ "type": "cloud"
+ }
+ ]
}
},
"schema": {
- "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_load_balancer_response"
+ "$ref": "#/components/schemas/replace_network_response"
}
}
},
- "description": "The `action` key in the reply contains an Action object with this structure."
+ "description": "Response for updating a [Network](#networks).\n\nContains the updated [Network](#networks).\n"
}
},
- "summary": "Change reverse DNS entry for this 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\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\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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\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 set-rdns $LOADBALANCER \\\n --ip 1.2.3.4 \\\n --hostname lb1.example.com"
+ "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"
+ }
+ ]
},
- "/load_balancers/{id}/actions/change_protection": {
- "post": {
- "description": "Changes the protection configuration of a Load Balancer.",
- "operationId": "change_load_balancer_protection",
+ "/networks/{id}/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",
"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.",
- "example": 42,
+ "description": "ID of the Network.",
+ "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,
"format": "int64",
- "maximum": 9007199254740991,
"type": "integer"
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/change_load_balancer_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": "load_balancer"
- }
- ],
- "started": "2016-01-30T23:55:00+00:00",
- "status": "success"
+ "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/change_load_balancer_protection_response"
+ "$ref": "#/components/schemas/list_actions_response"
}
}
},
- "description": "The `action` key contains the `change_protection` Action."
+ "description": "Response for listing [Actions](#actions)."
}
},
- "summary": "Change Load Balancer Protection",
+ "summary": "List Actions for a Network",
"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\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\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"
- }
+ "networks"
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/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",
+ "/networks/{id}/actions/{action_id}": {
+ "get": {
+ "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,
"type": "integer"
}
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/change_type_of_load_balancer_request"
- }
- }
- }
- },
- "responses": {
- "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/change_type_of_load_balancer_response"
- }
- }
- },
- "description": "The `action` key contains the `change_load_balancer_type` Action."
- }
- },
- "summary": "Change the Type of a Load Balancer",
- "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\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\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 load-balancer change-type $LOADBALANCER lb21"
- }
- ]
- }
- },
- "/load_balancers/{id}/actions/delete_service": {
- "post": {
- "description": "Delete a service of a Load Balancer.",
- "operationId": "delete_service",
- "parameters": [
- {
- "description": "ID of the Load Balancer.",
+ "description": "ID of the Action.",
"in": "path",
- "name": "id",
+ "name": "action_id",
"required": true,
"schema": {
- "description": "ID of the Load Balancer.",
+ "description": "ID of the Action.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -12759,22 +15647,13 @@
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/delete_service_request"
- }
- }
- }
- },
"responses": {
- "201": {
+ "200": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "delete_service",
+ "command": "add_subnet",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -12785,7 +15664,7 @@
"resources": [
{
"id": 4711,
- "type": "load_balancer"
+ "type": "network"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -12793,48 +15672,36 @@
}
},
"schema": {
- "$ref": "#/components/schemas/delete_service_response"
+ "$ref": "#/components/schemas/get_action_response"
}
}
},
- "description": "The `action` key contains the `delete_service` Action."
+ "description": "Response for getting an [Action](#actions)."
}
},
- "summary": "Delete Service",
+ "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\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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.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 load-balancer delete-service $LOADBALANCER \\\n --listen-port 443"
- }
+ "networks"
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/load_balancers/{id}/actions/detach_from_network": {
+ "/networks/{id}/actions/add_route": {
"post": {
- "description": "Detaches a Load Balancer from a network.",
- "operationId": "detach_load_balancer_from_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,
@@ -12846,7 +15713,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/detach_load_balancer_from_network_request"
+ "$ref": "#/components/schemas/add_route_to_network_request"
}
}
}
@@ -12857,7 +15724,7 @@
"application/json": {
"example": {
"action": {
- "command": "detach_from_network",
+ "command": "add_route",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -12866,10 +15733,6 @@
"id": 13,
"progress": 0,
"resources": [
- {
- "id": 42,
- "type": "server"
- },
{
"id": 4711,
"type": "network"
@@ -12880,48 +15743,53 @@
}
},
"schema": {
- "$ref": "#/components/schemas/detach_load_balancer_from_network_response"
+ "$ref": "#/components/schemas/add_route_to_network_response"
}
}
},
- "description": "The `action` key contains the `detach_from_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": "Detach a Load Balancer from 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\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\"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.detach_from_network(\n load_balancer=LoadBalancer(id=123), 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 detach-from-network $LOADBALANCER \\\n --network $NETWORK"
+ "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"
+ }
+ ]
},
- "/load_balancers/{id}/actions/disable_public_interface": {
+ "/networks/{id}/actions/add_subnet": {
"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",
+ "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,
@@ -12929,13 +15797,22 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/add_subnet_to_network_request"
+ }
+ }
+ }
+ },
"responses": {
"201": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "disable_public_interface",
+ "command": "add_subnet",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -12944,10 +15821,6 @@
"id": 13,
"progress": 0,
"resources": [
- {
- "id": 42,
- "type": "server"
- },
{
"id": 4711,
"type": "network"
@@ -12958,48 +15831,53 @@
}
},
"schema": {
- "$ref": "#/components/schemas/disable_public_interface_of_load_balancer_response"
+ "$ref": "#/components/schemas/add_subnet_to_network_response"
}
}
},
- "description": "The `action` key contains the `disable_public_interface` 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": "Disable the public interface of a Load Balancer",
+ "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.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\"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\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()"
+ "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 disable-public-interface $LOADBALANCER"
+ "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"
+ }
+ ]
},
- "/load_balancers/{id}/actions/enable_public_interface": {
+ "/networks/{id}/actions/change_ip_range": {
"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",
+ "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,
@@ -13007,77 +15885,87 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/change_ip_range_of_network_request"
+ }
+ }
+ }
+ },
"responses": {
"201": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "enable_public_interface",
+ "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": "server"
- },
{
"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/enable_public_interface_of_load_balancer_response"
+ "$ref": "#/components/schemas/change_ip_range_of_network_response"
}
}
},
- "description": "The `action` key contains the `enable_public_interface` Action."
+ "description": "Response for changing the [Networks](#networks) IP range.\n\nThe `action` key contains an [Action](#actions) with command `change_ip_range`.\n"
}
},
- "summary": "Enable the public interface of a 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.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\"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.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\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 enable-public-interface $LOADBALANCER"
+ "source": "hcloud network change-ip-range $NETWORK \\\n --ip-range 10.0.0.0/16"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/load_balancers/{id}/actions/remove_target": {
+ "/networks/{id}/actions/change_protection": {
"post": {
- "description": "Removes a target from a Load Balancer.",
- "operationId": "remove_target",
+ "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,
@@ -13089,7 +15977,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/remove_target_request"
+ "$ref": "#/components/schemas/change_network_protection_request"
}
}
}
@@ -13100,7 +15988,7 @@
"application/json": {
"example": {
"action": {
- "command": "remove_target",
+ "command": "change_protection",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -13111,7 +15999,7 @@
"resources": [
{
"id": 4711,
- "type": "load_balancer"
+ "type": "network"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -13119,48 +16007,53 @@
}
},
"schema": {
- "$ref": "#/components/schemas/remove_target_response"
+ "$ref": "#/components/schemas/change_network_protection_response"
}
}
},
- "description": "The `action` key contains the `remove_target` Action."
+ "description": "Response for changing the [Networks](#networks) protection.\n\nThe `action` key contains an [Action](#actions) with command `change_protection`.\n"
}
},
- "summary": "Remove Target",
+ "summary": "Change Network Protection",
"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\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\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 (\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\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 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 network enable-protection $NETWORK delete\nhcloud network disable-protection $NETWORK delete"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/load_balancers/{id}/actions/update_service": {
+ "/networks/{id}/actions/delete_route": {
"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",
+ "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,
@@ -13172,7 +16065,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/update_service_request"
+ "$ref": "#/components/schemas/delete_route_from_network_request"
}
}
}
@@ -13183,155 +16076,152 @@
"application/json": {
"example": {
"action": {
- "command": "update_service",
+ "command": "delete_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/update_service_response"
+ "$ref": "#/components/schemas/delete_route_from_network_response"
}
}
},
- "description": "The `action` key contains the `update_service` 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": "Update Service",
+ "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\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}"
+ "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.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()"
+ "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 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"
+ "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"
+ }
+ ]
},
- "/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",
+ "/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",
"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,
"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": {
- "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/delete_subnet_from_network_request"
+ }
+ }
+ }
+ },
"responses": {
- "200": {
+ "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"
+ }
+ },
"schema": {
- "$ref": "#/components/schemas/get_metrics_for_loadbalancer_response"
+ "$ref": "#/components/schemas/delete_subnet_from_network_response"
}
}
},
- "description": "The `metrics` key in the reply contains a metrics object with this structure."
+ "description": "Response for deleting a subnet from a [Network](#networks).\n\nThe `action` key contains an [Action](#actions) with command `delete_subnet`.\n"
}
},
- "summary": "Get Metrics for a LoadBalancer",
+ "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\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\"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\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\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 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 network remove-subnet $NETWORK \\\n --ip-range 10.0.1.0/24"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/load_balancers/actions": {
+ "/networks/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",
+ "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",
@@ -13430,34 +16320,39 @@
}
}
},
- "description": "The `actions` key contains a list of Actions."
+ "description": "Response for listing [Actions](#actions)."
}
},
"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\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\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\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\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nactions = client.networks.actions.get_all()"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/load_balancers/actions/{id}": {
+ "/networks/actions/{id}": {
"get": {
- "description": "Returns a specific Action object.",
- "operationId": "get_load_balancer_action",
+ "description": "Returns a single [Action](#actions).",
+ "operationId": "get_network_action",
"parameters": [
{
- "description": "ID of the Action",
+ "description": "ID of the Action.",
"in": "path",
"name": "id",
"required": true,
@@ -13479,41 +16374,37 @@
}
}
},
- "description": "The `action` key in the reply has this structure."
+ "description": "Response for getting a single [Action](#actions)."
}
},
"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.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.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\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\naction = client.load_balancers.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.networks.actions.get_by_id(123)"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/locations": {
+ "/placement_groups": {
"get": {
- "description": "Returns all [Locations](#locations).\n\nUse the provided URI parameters to modify the result.\n",
- "operationId": "list_locations",
+ "description": "Returns all Placement Group objects.",
+ "operationId": "list_placement_groups",
"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",
@@ -13527,7 +16418,10 @@
"id:desc",
"name",
"name:asc",
- "name:desc"
+ "name:desc",
+ "created",
+ "created:asc",
+ "created:desc"
],
"type": "string"
},
@@ -13535,165 +16429,40 @@
}
},
{
- "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".",
+ "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n",
"in": "query",
- "name": "page",
+ "name": "name",
"required": false,
"schema": {
- "default": 1,
- "example": 2,
- "format": "int64",
- "type": "integer"
+ "type": "string"
}
},
{
- "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".",
+ "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": "per_page",
+ "name": "label_selector",
"required": false,
"schema": {
- "default": 25,
- "example": 25,
- "format": "int64",
- "type": "integer"
- }
- }
- ],
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/list_locations_response"
- }
- }
- },
- "description": "Response with the [Locations](#locations)."
- }
- },
- "summary": "List Locations",
- "tags": [
- "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\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\nlocations = client.locations.get_all()"
- },
- {
- "label": "CLI",
- "lang": "Shell",
- "source": "hcloud location list"
- }
- ]
- }
- },
- "/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"
+ "type": "string"
}
- }
- ],
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/get_location_response"
- }
- }
- },
- "description": "Response with the [Location](#locations)."
- }
- },
- "summary": "Get a Location",
- "tags": [
- "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\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\nlocation = client.locations.get_by_id(123)"
},
{
- "label": "CLI",
- "lang": "Shell",
- "source": "hcloud location describe $LOCATION"
- }
- ]
- }
- },
- "/networks": {
- "get": {
- "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",
+ "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": "sort",
+ "name": "type",
"required": false,
"schema": {
"items": {
+ "description": "Type of Placement Group.\n",
"enum": [
- "id",
- "id:asc",
- "id:desc",
- "name",
- "name:asc",
- "name:desc",
- "created",
- "created:asc",
- "created:desc"
+ "spread"
],
+ "example": "spread",
"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",
@@ -13723,44 +16492,75 @@
"200": {
"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"
+ },
+ "name": "my Placement Group",
+ "servers": [
+ 4711,
+ 4712
+ ],
+ "type": "spread"
+ }
+ ]
+ },
"schema": {
- "$ref": "#/components/schemas/list_networks_response"
+ "$ref": "#/components/schemas/list_placement_groups_response"
}
}
},
- "description": "Response for listing [Networks](#networks)."
+ "description": "The `placement_groups` key contains an array of Placement Group objects."
}
},
- "summary": "List Networks",
+ "summary": "List Placement Groups",
"tags": [
- "networks"
+ "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\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\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\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\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nplacement_groups = client.placement_groups.get_all()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud network list"
+ "source": "hcloud placement-group 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",
+ "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/create_network_request"
+ "$ref": "#/components/schemas/create_placementgroup_request"
}
}
}
@@ -13769,49 +16569,66 @@
"201": {
"content": {
"application/json": {
+ "example": {
+ "placement_group": {
+ "created": "2019-01-08T12:10:00+00:00",
+ "id": 897,
+ "labels": {
+ "key": "value"
+ },
+ "name": "my Placement Group",
+ "servers": [],
+ "type": "spread"
+ }
+ },
"schema": {
- "$ref": "#/components/schemas/create_network_response"
+ "$ref": "#/components/schemas/create_placementgroup_response"
}
}
},
- "description": "Response for creating a [Network](#networks).\n\nContains the newly created [Network](#networks).\n"
+ "description": "The `PlacementGroup` key contains the Placement Group that was just created."
}
},
- "summary": "Create a Network",
+ "summary": "Create a PlacementGroup",
"tags": [
- "networks"
+ "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\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\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.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\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 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 placement-group create \\\n --name \"my Placement Group\" \\\n --type spread"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/networks/{id}": {
+ "/placement_groups/{id}": {
"delete": {
- "description": "Deletes a [Network](#networks).\n\nAttached resources will be detached automatically.\n",
- "operationId": "delete_network",
+ "description": "Deletes a Placement Group.",
+ "operationId": "delete_placementgroup",
"parameters": [
{
- "description": "ID of the Network.",
+ "description": "ID of the Placement Group.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Network.",
+ "description": "ID of the Placement Group.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -13821,42 +16638,42 @@
],
"responses": {
"204": {
- "description": "Response for deleting a [Network](#networks)."
+ "description": "Placement Group deleted."
}
},
- "summary": "Delete a Network",
+ "summary": "Delete a PlacementGroup",
"tags": [
- "networks"
+ "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\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\t_, err := client.PlacementGroup.Delete(ctx, &hcloud.PlacementGroup{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\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.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)"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud network delete $NETWORK"
+ "source": "hcloud placement-group delete $PLACEMENTGROUP"
}
]
},
"get": {
- "description": "Get a specific [Network](#networks).",
- "operationId": "get_network",
+ "description": "Gets a specific Placement Group object.",
+ "operationId": "get_placementgroup",
"parameters": [
{
- "description": "ID of the Network.",
+ "description": "ID of the Placement Group.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Network.",
+ "description": "ID of the Placement Group.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -13868,47 +16685,62 @@
"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_network_response"
+ "$ref": "#/components/schemas/get_placementgroup_response"
}
}
},
- "description": "The `network` key contains the network."
+ "description": "The `placement_group` key contains a Placement Group object."
}
},
- "summary": "Get a Network",
+ "summary": "Get a PlacementGroup",
"tags": [
- "networks"
+ "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\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\tplacementGroups, _, err := client.PlacementGroup.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\nnetwork = client.networks.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\nplacement_group = client.placement_groups.get_by_id(123)"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud network describe $NETWORK"
+ "source": "hcloud placement-group describe $PLACEMENTGROUP"
}
]
},
"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",
+ "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": "ID of the Network.",
+ "description": "ID of the Placement Group.",
"in": "path",
"name": "id",
"required": true,
"schema": {
- "description": "ID of the Network.",
+ "description": "ID of the Placement Group.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -13920,7 +16752,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/replace_network_request"
+ "$ref": "#/components/schemas/replace_placementgroup_request"
}
}
}
@@ -13930,134 +16762,121 @@
"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",
+ "placement_group": {
+ "created": "2019-01-08T12:10:00+00:00",
+ "id": 897,
"labels": {
"key": "value"
},
- "load_balancers": [
- 42
- ],
- "name": "new-name",
- "protection": {
- "delete": false
- },
- "routes": [
- {
- "destination": "10.100.1.0/24",
- "gateway": "10.0.1.1"
- }
- ],
+ "name": "my Placement Group",
"servers": [
- 42
+ 4711,
+ 4712
],
- "subnets": [
- {
- "gateway": "10.0.0.1",
- "ip_range": "10.0.1.0/24",
- "network_zone": "eu-central",
- "type": "cloud"
- }
- ]
+ "type": "spread"
}
},
"schema": {
- "$ref": "#/components/schemas/replace_network_response"
+ "$ref": "#/components/schemas/replace_placementgroup_response"
}
}
},
- "description": "Response for updating a [Network](#networks).\n\nContains the updated [Network](#networks).\n"
+ "description": "The `certificate` key contains the Placement Group that was just updated."
}
},
- "summary": "Update a Network",
+ "summary": "Update a PlacementGroup",
"tags": [
- "networks"
+ "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\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\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\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.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 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 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"
+ }
+ ]
},
- "/networks/{id}/actions": {
+ "/pricing": {
"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": "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": [
+ {
+ "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}"
+ }
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/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",
"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"
}
},
{
- "description": "Sort actions 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": "sort",
+ "name": "label_selector",
"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"
+ "type": "string"
}
},
{
- "description": "Filter the actions by status. Can be used multiple times. The response will only\ncontain actions matching the specified statuses.\n",
+ "description": "Filter results by IP address.",
+ "example": "127.0.0.1",
"in": "query",
- "name": "status",
+ "name": "ip",
"required": false,
"schema": {
- "items": {
- "description": "Status of the Action.",
- "enum": [
- "running",
- "success",
- "error"
- ],
- "type": "string"
- },
- "type": "array"
+ "type": "string"
}
},
{
@@ -14083,140 +16902,202 @@
"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": {
"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_primary_ips_response"
}
}
},
- "description": "Response for listing [Actions](#actions)."
+ "description": "Response for listing [Primary IPs](#primary-ips)."
}
},
- "summary": "List Actions for a Network",
+ "summary": "List Primary IPs",
"tags": [
- "networks"
- ]
- }
- },
- "/networks/{id}/actions/{action_id}": {
- "get": {
- "description": "Returns a specific [Action](#actions) for a [Network](#networks).",
- "operationId": "get_action_for_network",
- "parameters": [
+ "primary_ips"
+ ],
+ "x-codeSamples": [
{
- "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"
- }
+ "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}"
},
{
- "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"
- }
+ "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()"
+ },
+ {
+ "label": "CLI",
+ "lang": "Shell",
+ "source": "hcloud primary-ip list"
}
- ],
+ ]
+ },
+ "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": "add_subnet",
+ "command": "create_primary_ip",
"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": "network"
+ "id": 17,
+ "type": "server"
}
],
- "started": "2016-01-30T23:55:00+00:00",
- "status": "success"
+ "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_action_response"
+ "$ref": "#/components/schemas/create_primary_ip_response"
}
}
},
- "description": "Response for getting an [Action](#actions)."
+ "description": "Response for creating a [Primary IP](#primary-ips).\n\nContains the newly created [Primary IP](#primary-ips).\n"
}
},
- "summary": "Get an Action for a Network",
+ "summary": "Create 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\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\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 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"
+ }
+ ]
},
- "/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",
+ "/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": "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,
@@ -14224,82 +17105,96 @@
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/add_route_to_network_request"
- }
+ "responses": {
+ "204": {
+ "description": "[Primary IP](#primary-ips) deletion succeeded."
+ }
+ },
+ "summary": "Delete 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\t_, err := client.PrimaryIP.Delete(ctx, &hcloud.PrimaryIP{ID: 123})\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)"
+ },
+ {
+ "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": {
+ "description": "ID of the Primary IP.",
+ "example": 42,
+ "format": "int64",
+ "maximum": 9007199254740991,
+ "type": "integer"
}
}
- },
+ ],
"responses": {
- "201": {
+ "200": {
"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"
+ "$ref": "#/components/schemas/get_primary_ip_response"
}
}
},
- "description": "Response for adding a route to a [Network](#networks).\n\nThe `action` key contains an [Action](#actions) with command `add_route`.\n"
+ "description": "The `primary_ip` key contains the [Primary IP](#primary-ips)."
}
},
- "summary": "Add a route to a Network",
+ "summary": "Get a Primary IP",
"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\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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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}"
},
{
"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()"
+ "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 network add-route $NETWORK \\\n --destination 10.100.1.0/24 \\\n --gateway 10.0.1.1"
+ "source": "hcloud primary-ip describe $PRIMARYIP"
}
]
- }
- },
- "/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",
+ },
+ "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 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,
@@ -14311,78 +17206,63 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/add_subnet_to_network_request"
+ "$ref": "#/components/schemas/replace_primary_ip_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/replace_primary_ip_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": "The `primary_ip` key contains the updated [Primary IP](#primary-ips)."
}
},
- "summary": "Add a subnet to a Network",
+ "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\"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\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\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\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 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 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"
+ }
+ ]
},
- "/networks/{id}/actions/change_ip_range": {
+ "/primary_ips/{id}/actions/assign": {
"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",
+ "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 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,
@@ -14394,7 +17274,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/change_ip_range_of_network_request"
+ "$ref": "#/components/schemas/assign_primary_ip_to_resource_request"
}
}
}
@@ -14405,67 +17285,76 @@
"application/json": {
"example": {
"action": {
- "command": "change_ip_range",
+ "command": "assign_primary_ip",
"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": 4711,
- "type": "network"
+ "type": "primary_ip"
}
],
- "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_ip_range_of_network_response"
+ "$ref": "#/components/schemas/assign_primary_ip_to_resource_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": "Response for assigning a [Primary IP](#primary-ips).\n\nContains an [Action](#actions) of type `assign_primary_ip`.\n"
}
},
- "summary": "Change IP range of 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\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\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 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.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 change-ip-range $NETWORK \\\n --ip-range 10.0.0.0/16"
+ "source": "hcloud primary-ip assign --server 4711 $PRIMARYIP"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/networks/{id}/actions/change_protection": {
+ "/primary_ips/{id}/actions/change_dns_ptr": {
"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",
+ "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,
@@ -14477,10 +17366,11 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/change_network_protection_request"
+ "$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": {
"201": {
@@ -14488,7 +17378,7 @@
"application/json": {
"example": {
"action": {
- "command": "change_protection",
+ "command": "change_dns_ptr",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -14499,7 +17389,7 @@
"resources": [
{
"id": 4711,
- "type": "network"
+ "type": "primary_ip"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -14507,48 +17397,53 @@
}
},
"schema": {
- "$ref": "#/components/schemas/change_network_protection_response"
+ "$ref": "#/components/schemas/change_reverse_dns_records_for_primary_ip_response"
}
}
},
- "description": "Response for changing the [Networks](#networks) protection.\n\nThe `action` key contains an [Action](#actions) with command `change_protection`.\n"
+ "description": "Response for changing a [Primary IPs](#primary-ips) DNS pointer.\n\nContains an [Action](#actions) of type `change_dns_ptr`.\n"
}
},
- "summary": "Change Network Protection",
+ "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\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\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\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.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 enable-protection $NETWORK delete\nhcloud network disable-protection $NETWORK delete"
+ "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"
+ }
+ ]
},
- "/networks/{id}/actions/delete_route": {
+ "/primary_ips/{id}/actions/change_protection": {
"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",
+ "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,
@@ -14560,7 +17455,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/delete_route_from_network_request"
+ "$ref": "#/components/schemas/change_primary_ip_protection_request"
}
}
}
@@ -14571,67 +17466,72 @@
"application/json": {
"example": {
"action": {
- "command": "delete_route",
+ "command": "change_protection",
"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": 4711,
- "type": "network"
+ "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/delete_route_from_network_response"
+ "$ref": "#/components/schemas/change_primary_ip_protection_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": "Response for changing a [Primary IPs](#primary-ips) protection settings.\n\nContains an [Action](#actions) of type `change_protection`.\n"
}
},
- "summary": "Delete a route from 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\"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\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\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\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 remove-route $NETWORK \\\n --destination 10.100.1.0/24 \\\n --gateway 10.0.1.1"
+ "source": "hcloud primary-ip enable-protection $PRIMARYIP delete\nhcloud primary-ip disable-protection $PRIMARYIP delete"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/networks/{id}/actions/delete_subnet": {
+ "/primary_ips/{id}/actions/unassign": {
"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",
+ "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,
@@ -14639,22 +17539,13 @@
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/delete_subnet_from_network_request"
- }
- }
- }
- },
"responses": {
"201": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "delete_subnet",
+ "command": "unassign_primary_ip",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -14663,9 +17554,13 @@
"id": 13,
"progress": 0,
"resources": [
+ {
+ "id": 42,
+ "type": "server"
+ },
{
"id": 4711,
- "type": "network"
+ "type": "primary_ip"
}
],
"started": "2016-01-30T23:50:00+00:00",
@@ -14673,40 +17568,45 @@
}
},
"schema": {
- "$ref": "#/components/schemas/delete_subnet_from_network_response"
+ "$ref": "#/components/schemas/unassign_primary_ip_from_resource_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": "Response for unassigning a [Primary IP](#primary-ips).\n\nContains an [Action](#actions) of type `unassign_primary_ip`.\n"
}
},
- "summary": "Delete a subnet from 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\"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\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, 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.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 remove-subnet $NETWORK \\\n --ip-range 10.0.1.0/24"
+ "source": "hcloud primary-ip unassign $PRIMARYIP"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/networks/actions": {
+ "/primary_ips/actions": {
"get": {
"description": "Lists multiple [Actions](#actions).\n\nUse the provided URI parameters to modify the result.\n",
- "operationId": "list_network_actions",
+ "operationId": "list_primary_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",
@@ -14810,29 +17710,34 @@
},
"summary": "List Actions",
"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\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\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.networks.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.primary_ips.actions.get_all()"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/networks/actions/{id}": {
+ "/primary_ips/actions/{id}": {
"get": {
"description": "Returns a single [Action](#actions).",
- "operationId": "get_network_action",
+ "operationId": "get_primary_ip_action",
"parameters": [
{
- "description": "ID of the Action",
+ "description": "ID of the Action.",
"in": "path",
"name": "id",
"required": true,
@@ -14859,50 +17764,170 @@
},
"summary": "Get an Action",
"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\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.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.networks.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.primary_ips.actions.get_by_id(123)"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/placement_groups": {
+ "/server_types": {
"get": {
- "description": "Returns all Placement Group objects.",
- "operationId": "list_placement_groups",
+ "description": "Gets all Server type objects.",
+ "operationId": "list_server_types",
"parameters": [
{
- "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\n",
+ "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n",
"in": "query",
- "name": "sort",
+ "name": "name",
"required": false,
"schema": {
- "items": {
- "enum": [
- "id",
- "id:asc",
- "id:desc",
- "name",
- "name:asc",
- "name:desc",
- "created",
- "created:asc",
- "created:desc"
- ],
- "type": "string"
- },
- "type": "array"
+ "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": "The `server_types` key in the reply contains an array of Server type objects with this structure."
+ }
+ },
+ "summary": "List Server Types",
+ "tags": [
+ "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": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/server_types/{id}": {
+ "get": {
+ "description": "Gets a specific Server type object.",
+ "operationId": "get_server_type",
+ "parameters": [
+ {
+ "description": "ID of the Server Type.",
+ "in": "path",
+ "name": "id",
+ "required": true,
+ "schema": {
+ "description": "ID of the Server Type.",
+ "example": 42,
+ "format": "int64",
+ "maximum": 9007199254740991,
+ "type": "integer"
}
+ }
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/get_server_type_response"
+ }
+ }
+ },
+ "description": "The `server_type` key in the reply contains a Server type object with this structure."
+ }
+ },
+ "summary": "Get a Server Type",
+ "tags": [
+ "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": [
+ {
+ "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",
@@ -14922,17 +17947,47 @@
}
},
{
- "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 Placement Group.\n",
"enum": [
- "spread"
+ "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"
],
- "example": "spread",
"type": "string"
},
"type": "array"
@@ -14967,138 +18022,306 @@
"200": {
"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"
- },
- "name": "my Placement Group",
- "servers": [
- 4711,
- 4712
- ],
- "type": "spread"
- }
- ]
- },
"schema": {
- "$ref": "#/components/schemas/list_placement_groups_response"
+ "$ref": "#/components/schemas/list_servers_response"
}
}
},
- "description": "The `placement_groups` key contains an array of Placement Group objects."
+ "description": "A paged array of servers.",
+ "headers": {
+ "x-next": {
+ "description": "A link to the next page of responses.",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
}
},
- "summary": "List Placement Groups",
+ "summary": "List Servers",
"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\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nservers = client.servers.get_all()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud placement-group list"
+ "source": "hcloud server list"
}
]
},
"post": {
- "description": "Creates a new Placement Group.\n",
- "operationId": "create_placementgroup",
+ "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": {
- "example": {
- "name": "my Placement Group",
- "type": "spread"
- },
"schema": {
- "$ref": "#/components/schemas/create_placementgroup_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": {
"content": {
"application/json": {
"example": {
- "placement_group": {
- "created": "2019-01-08T12:10:00+00:00",
- "id": 897,
+ "action": {
+ "command": "create_server",
+ "error": {
+ "code": "action_failed",
+ "message": "Action failed"
+ },
+ "finished": null,
+ "id": 1,
+ "progress": 0,
+ "resources": [
+ {
+ "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"
},
- "name": "my Placement Group",
- "servers": [],
- "type": "spread"
+ "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
+ }
+ ],
+ "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/create_placementgroup_response"
+ "$ref": "#/components/schemas/create_server_response"
}
}
},
- "description": "The `PlacementGroup` key contains the Placement Group that was just created."
+ "description": "The `server` key in the reply contains a Server object with this structure."
}
},
- "summary": "Create a PlacementGroup",
+ "summary": "Create 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\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\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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.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 placement-group create \\\n --name \"my Placement Group\" \\\n --type spread"
+ "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"
+ }
+ ]
},
- "/placement_groups/{id}": {
+ "/servers/{id}": {
"delete": {
- "description": "Deletes a Placement Group.",
- "operationId": "delete_placementgroup",
+ "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 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,
@@ -15107,43 +18330,50 @@
}
],
"responses": {
- "204": {
- "description": "Placement Group deleted."
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/delete_server_response"
+ }
+ }
+ },
+ "description": "The `action` key in the reply contains an Action object with this structure."
}
},
- "summary": "Delete a PlacementGroup",
+ "summary": "Delete 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\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\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.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.delete(\n server=Server(id=123),\n)\n\naction.wait_until_finished()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud placement-group delete $PLACEMENTGROUP"
+ "source": "hcloud server delete $SERVER"
}
]
},
"get": {
- "description": "Gets a specific Placement Group object.",
- "operationId": "get_placementgroup",
+ "description": "Returns a specific Server object. The Server must exist inside the Project.",
+ "operationId": "get_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,
@@ -15155,62 +18385,47 @@
"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_placementgroup_response"
+ "$ref": "#/components/schemas/get_server_response"
}
}
},
- "description": "The `placement_group` key contains a Placement Group object."
+ "description": "The `server` key in the reply contains a Server object with this structure."
}
},
- "summary": "Get a PlacementGroup",
+ "summary": "Get 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\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\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\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\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nserver = client.servers.get_by_id(123)"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud placement-group describe $PLACEMENTGROUP"
+ "source": "hcloud server describe $SERVER"
}
]
},
"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",
+ "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 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,
@@ -15222,7 +18437,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/replace_placementgroup_request"
+ "$ref": "#/components/schemas/replace_server_request"
}
}
}
@@ -15231,205 +18446,378 @@
"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/replace_placementgroup_response"
+ "$ref": "#/components/schemas/replace_server_response"
}
}
},
- "description": "The `certificate` key contains the Placement Group that was just updated."
+ "description": "The `server` key in the reply contains the updated Server."
}
},
- "summary": "Update a PlacementGroup",
+ "summary": "Update 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\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.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)"
+ "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 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\""
+ "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"
+ }
+ ]
},
- "/pricing": {
+ "/servers/{id}/actions": {
"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",
+ "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": "ID of the Server.",
+ "in": "path",
+ "name": "id",
+ "required": true,
+ "schema": {
+ "description": "ID of the Server.",
+ "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",
+ "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": "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": "The `actions` key contains a list of Actions."
+ }
+ },
+ "summary": "List Actions for a Server",
+ "tags": [
+ "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/list_prices_response"
+ "$ref": "#/components/schemas/get_action_response"
}
}
},
- "description": "The `pricing` key in the reply contains an pricing object with this structure."
+ "description": "The `action` key in the reply has this structure."
}
},
- "summary": "Get all prices",
+ "summary": "Get an Action for a Server",
"tags": [
- "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\tpricing, _, err := client.Pricing.Get(ctx)\n}"
- }
+ "servers"
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/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/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": "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/add_server_to_placement_group_request"
+ }
+ }
+ }
+ },
"responses": {
- "200": {
+ "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/list_primary_ips_response"
+ "$ref": "#/components/schemas/add_server_to_placement_group_response"
}
}
},
- "description": "Response for listing [Primary IPs](#primary-ips)."
+ "description": "The `action` key in the reply contains an Action object with this structure."
}
},
- "summary": "List Primary IPs",
+ "summary": "Add a Server to a Placement Group",
"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\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\nprimary_ips = client.primary_ips.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 primary-ip list"
+ "source": "hcloud server add-to-placement-group --placement-group 1 $SERVER"
}
]
},
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/servers/{id}/actions/attach_iso": {
"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": "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"
+ }
+ }
+ ],
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/create_primary_ip_request"
+ "$ref": "#/components/schemas/attach_iso_to_server_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": {
@@ -15437,7 +18825,7 @@
"application/json": {
"example": {
"action": {
- "command": "create_primary_ip",
+ "command": "attach_iso",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -15447,112 +18835,62 @@
"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"
}
},
"schema": {
- "$ref": "#/components/schemas/create_primary_ip_response"
+ "$ref": "#/components/schemas/attach_iso_to_server_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": "Attach an ISO to 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\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.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\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.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 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 attach-iso $SERVER \"FreeBSD-11.0-RELEASE-amd64-dvd1\""
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/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/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": "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,
@@ -15560,44 +18898,91 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/attach_server_to_network_request"
+ }
+ }
+ }
+ },
"responses": {
- "204": {
- "description": "[Primary IP](#primary-ips) deletion succeeded."
+ "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."
}
},
- "summary": "Delete a Primary IP",
+ "summary": "Attach a Server to 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\t_, err := client.PrimaryIP.Delete(ctx, &hcloud.PrimaryIP{ID: 123})\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\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.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 primary-ip delete $PRIMARYIP"
+ "source": "hcloud server attach-to-network $SERVER \\\n --alias-ips 10.0.1.2 \\\n --ip 10.0.1.1 \\\n --network 4711"
}
]
},
- "get": {
- "description": "Returns a [Primary IP](#primary-ips).",
- "operationId": "get_primary_ip",
+ "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",
"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,
@@ -15605,51 +18990,91 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/change_alias_ips_of_network_request"
+ }
+ }
+ }
+ },
"responses": {
- "200": {
+ "201": {
"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/get_primary_ip_response"
+ "$ref": "#/components/schemas/change_alias_ips_of_network_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": "Change alias IPs of 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\tprimaryIP, _, err := client.PrimaryIP.GetByID(ctx, 123)\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\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.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 primary-ip describe $PRIMARYIP"
+ "source": "hcloud server change-alias-ips $SERVER \\\n --alias-ips 10.0.1.2 \\\n --network 4711"
}
]
},
- "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/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 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,
@@ -15661,58 +19086,84 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/replace_primary_ip_request"
+ "$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": {
- "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": "server"
+ }
+ ],
+ "started": "2016-01-30T23:50:00+00:00",
+ "status": "running"
+ }
+ },
"schema": {
- "$ref": "#/components/schemas/replace_primary_ip_response"
+ "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_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": "Change reverse DNS entry for this 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.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.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.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 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 set-rdns $SERVER \\\n --ip 1.2.3.4 \\\n --hostname server01.example.com"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/primary_ips/{id}/actions/assign": {
+ "/servers/{id}/actions/change_protection": {
"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": "Changes the protection configuration of the Server.",
+ "operationId": "change_server_protection",
"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,
@@ -15724,7 +19175,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/assign_primary_ip_to_resource_request"
+ "$ref": "#/components/schemas/change_server_protection_request"
}
}
}
@@ -15735,71 +19186,72 @@
"application/json": {
"example": {
"action": {
- "command": "assign_primary_ip",
+ "command": "change_protection",
"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/change_server_protection_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": "Change Server Protection",
"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.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.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.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 primary-ip assign --server 4711 $PRIMARYIP"
+ "source": "hcloud server enable-protection $SERVER delete rebuild\nhcloud server disable-protection $SERVER delete rebuild"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/primary_ips/{id}/actions/change_dns_ptr": {
+ "/servers/{id}/actions/change_type": {
"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": "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 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,
@@ -15811,11 +19263,10 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/change_reverse_dns_records_for_primary_ip_request"
+ "$ref": "#/components/schemas/change_type_of_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": {
@@ -15823,67 +19274,72 @@
"application/json": {
"example": {
"action": {
- "command": "change_dns_ptr",
+ "command": "change_server_type",
"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_reverse_dns_records_for_primary_ip_response"
+ "$ref": "#/components/schemas/change_type_of_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 `action` key in the reply contains an Action object with this structure."
}
},
- "summary": "Change reverse DNS records for a Primary IP",
+ "summary": "Change the Type of 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\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.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.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 primary-ip set-rdns $PRIMARYIP \\\n --ip 1.2.3.4 \\\n --hostname server02.example.com"
+ "source": "hcloud server change-type --keep-disk $SERVER cx22"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/primary_ips/{id}/actions/change_protection": {
+ "/servers/{id}/actions/create_image": {
"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": "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 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,
@@ -15895,7 +19351,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/change_primary_ip_protection_request"
+ "$ref": "#/components/schemas/create_image_from_server_request"
}
}
}
@@ -15906,7 +19362,7 @@
"application/json": {
"example": {
"action": {
- "command": "change_protection",
+ "command": "create_image",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -15916,57 +19372,89 @@
"progress": 100,
"resources": [
{
- "id": 4711,
- "type": "primary_ip"
+ "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/change_primary_ip_protection_response"
+ "$ref": "#/components/schemas/create_image_from_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 `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": "Change Primary IP Protection",
+ "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\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\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.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.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 enable-protection $PRIMARYIP delete\nhcloud primary-ip disable-protection $PRIMARYIP delete"
+ "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"
+ }
+ ]
},
- "/primary_ips/{id}/actions/unassign": {
+ "/servers/{id}/actions/detach_from_network": {
"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": "Detaches a Server from a network. The interface for this network will vanish.",
+ "operationId": "detach_server_from_network",
"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,
@@ -15974,13 +19462,22 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/detach_server_from_network_request"
+ }
+ }
+ }
+ },
"responses": {
"201": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "unassign_primary_ip",
+ "command": "detach_from_network",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -15995,7 +19492,7 @@
},
{
"id": 4711,
- "type": "primary_ip"
+ "type": "network"
}
],
"started": "2016-01-30T23:50:00+00:00",
@@ -16003,171 +19500,53 @@
}
},
"schema": {
- "$ref": "#/components/schemas/unassign_primary_ip_from_resource_response"
+ "$ref": "#/components/schemas/detach_server_from_network_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": "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\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.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.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.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 unassign $PRIMARYIP"
- }
- ]
- }
- },
- "/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",
- "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": "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()"
+ "source": "hcloud server detach-from-network --network 4711 $SERVER"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/primary_ips/actions/{id}": {
- "get": {
- "description": "Returns a single [Action](#actions).",
- "operationId": "get_primary_ip_action",
+ "/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 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,
@@ -16176,121 +19555,156 @@
}
],
"responses": {
- "200": {
+ "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/get_action_response"
+ "$ref": "#/components/schemas/detach_iso_from_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": "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\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\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\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.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 server detach-iso $SERVER"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/server_types": {
- "get": {
- "description": "Gets all Server type objects.",
- "operationId": "list_server_types",
+ "/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": "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": "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/list_server_types_response"
+ "$ref": "#/components/schemas/disable_backups_for_server_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": "Disable Backups 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\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.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\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.disable_backup(\n server=Server(id=123),\n)\n\naction.wait_until_finished()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud server-type list"
+ "source": "hcloud server disable-backup $SERVER"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/server_types/{id}": {
- "get": {
- "description": "Gets a specific Server type object.",
- "operationId": "get_server_type",
+ "/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 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,
@@ -16299,156 +19713,117 @@
}
],
"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/get_server_type_response"
+ "$ref": "#/components/schemas/disable_rescue_mode_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": "Disable Rescue Mode 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\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\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nserver_type = client.server_types.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_rescue(\n server=Server(id=123),\n)\n\naction.wait_until_finished()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud server-type describe $SERVERTYPE"
+ "source": "hcloud server disable-rescue $SERVER"
}
]
- }
+ },
+ "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"
- }
- },
+ "/servers/{id}/actions/enable_backup": {
+ "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",
+ "parameters": [
{
- "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": "enable_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/list_servers_response"
+ "$ref": "#/components/schemas/enable_and_configure_backups_for_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": "Enable and Configure Backups for a Server",
"tags": [
"servers"
],
@@ -16456,32 +19831,53 @@
{
"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.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\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.enable_backup(\n server=Server(id=123),\n)\n\naction.wait_until_finished()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud server list"
+ "source": "hcloud server enable-backup $SERVER"
}
]
},
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/servers/{id}/actions/enable_rescue": {
"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",
+ "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 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_server_request"
+ "$ref": "#/components/schemas/enable_rescue_mode_for_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": {
@@ -16489,210 +19885,192 @@
"application/json": {
"example": {
"action": {
- "command": "create_server",
+ "command": "enable_rescue",
"error": {
"code": "action_failed",
"message": "Action failed"
},
- "finished": null,
- "id": 1,
- "progress": 0,
+ "finished": "2016-01-30T23:56:00+00:00",
+ "id": 13,
+ "progress": 100,
"resources": [
{
"id": 42,
"type": "server"
}
],
- "started": "2016-01-30T23:50:00+00:00",
- "status": "running"
+ "started": "2016-01-30T23:55:00+00:00",
+ "status": "success"
},
- "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/enable_rescue_mode_for_server_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"
+ }
+ },
+ "summary": "Enable Rescue Mode for 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.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.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"
+ }
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/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",
+ "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": "stop_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
+ "started": "2016-01-30T23:50:00+00:00",
+ "status": "running"
+ }
+ },
+ "schema": {
+ "$ref": "#/components/schemas/power_off_server_response"
+ }
+ }
+ },
+ "description": "The `action` key in the reply contains an Action object with this structure."
+ }
+ },
+ "summary": "Power off 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.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.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"
+ }
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/servers/{id}/actions/poweron": {
+ "post": {
+ "description": "Starts a Server by turning its power on.",
+ "operationId": "power_on_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": "start_server",
+ "error": {
+ "code": "action_failed",
+ "message": "Action failed"
},
- "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"
+ "finished": null,
+ "id": 13,
+ "progress": 0,
+ "resources": [
+ {
+ "id": 42,
+ "type": "server"
}
- },
- "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/power_on_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": "Power on a Server",
"tags": [
"servers"
],
@@ -16700,25 +20078,30 @@
{
"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.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.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.power_on(\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 poweron $SERVER"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/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}/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": "ID of the Server.",
@@ -16735,18 +20118,38 @@
}
],
"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/delete_server_response"
+ "$ref": "#/components/schemas/soft_reboot_server_response"
}
}
},
"description": "The `action` key in the reply contains an Action object with this structure."
}
},
- "summary": "Delete a Server",
+ "summary": "Soft-reboot a Server",
"tags": [
"servers"
],
@@ -16754,23 +20157,30 @@
{
"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\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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.delete(\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\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 delete $SERVER"
+ "source": "hcloud server reboot $SERVER"
}
]
},
- "get": {
- "description": "Returns a specific Server object. The Server must exist inside the Project.",
- "operationId": "get_server",
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/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",
"parameters": [
{
"description": "ID of the Server.",
@@ -16786,19 +20196,50 @@
}
}
],
+ "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_server_response"
+ "$ref": "#/components/schemas/rebuild_server_from_image_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": "Get a Server",
+ "summary": "Rebuild a Server from an Image",
"tags": [
"servers"
],
@@ -16806,23 +20247,30 @@
{
"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\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\nserver = client.servers.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 describe $SERVER"
+ "source": "hcloud server rebuild --image ubuntu-20.04 $SERVER"
}
]
},
- "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/{id}/actions/remove_from_placement_group": {
+ "post": {
+ "description": "Removes a Server from a Placement Group.\n",
+ "operationId": "remove_from_placement_group",
"parameters": [
{
"description": "ID of the Server.",
@@ -16838,28 +20286,39 @@
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/replace_server_request"
- }
- }
- }
- },
"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/replace_server_response"
+ "$ref": "#/components/schemas/remove_from_placement_group_response"
}
}
},
- "description": "The `server` key in the reply contains the updated Server."
+ "description": "The `action` key in the reply contains an Action object with this structure."
}
},
- "summary": "Update a Server",
+ "summary": "Remove from Placement Group",
"tags": [
"servers"
],
@@ -16867,166 +20326,111 @@
{
"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.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\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)"
+ "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 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": "hcloud server remove-from-placement-group $SERVER"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/servers/{id}/actions": {
- "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",
+ "/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",
+ "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,
- "title": "Server 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": {
+ "201": {
"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
- }
- }
+ "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/list_actions_response"
+ "$ref": "#/components/schemas/request_console_for_server_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 for a Server",
+ "summary": "Request Console for 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.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"
+ }
]
- }
+ },
+ "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",
+ "/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.",
@@ -17040,63 +20444,72 @@
"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": {
+ "201": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "start_server",
+ "command": "reset_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": 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/get_action_response"
+ "$ref": "#/components/schemas/reset_server_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 for a Server",
+ "summary": "Reset 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.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"
+ }
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/servers/{id}/actions/add_to_placement_group": {
+ "/servers/{id}/actions/reset_password": {
"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",
+ "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.",
@@ -17112,22 +20525,13 @@
}
}
],
- "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",
+ "command": "reset_password",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -17143,17 +20547,18 @@
],
"started": "2016-01-30T23:50:00+00:00",
"status": "running"
- }
+ },
+ "root_password": "zCWbFhnu950dUTko5f40"
},
"schema": {
- "$ref": "#/components/schemas/add_server_to_placement_group_response"
+ "$ref": "#/components/schemas/reset_root_password_of_server_response"
}
}
},
- "description": "The `action` key in the reply contains an Action object with this structure."
+ "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": "Add a Server to a Placement Group",
+ "summary": "Reset root Password of a Server",
"tags": [
"servers"
],
@@ -17161,25 +20566,30 @@
{
"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\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.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\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 add-to-placement-group --placement-group 1 $SERVER"
+ "source": "hcloud server reset-password $SERVER"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/servers/{id}/actions/attach_iso": {
+ "/servers/{id}/actions/shutdown": {
"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",
+ "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.",
@@ -17195,22 +20605,13 @@
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/attach_iso_to_server_request"
- }
- }
- }
- },
"responses": {
"201": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "attach_iso",
+ "command": "shutdown_server",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -17229,14 +20630,14 @@
}
},
"schema": {
- "$ref": "#/components/schemas/attach_iso_to_server_response"
+ "$ref": "#/components/schemas/shutdown_server_response"
}
}
},
"description": "The `action` key in the reply contains an Action object with this structure."
}
},
- "summary": "Attach an ISO to a Server",
+ "summary": "Shutdown a Server",
"tags": [
"servers"
],
@@ -17244,25 +20645,30 @@
{
"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\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.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.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 attach-iso $SERVER \"FreeBSD-11.0-RELEASE-amd64-dvd1\""
+ "source": "hcloud server shutdown $SERVER"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/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",
+ "/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.",
@@ -17276,54 +20682,195 @@
"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/attach_server_to_network_request"
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/get_metrics_for_server_response"
+ }
}
+ },
+ "description": "The `metrics` key in the reply contains a metrics object with this structure."
+ }
+ },
+ "summary": "Get Metrics for a Server",
+ "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"
+ }
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
+ },
+ "/servers/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",
+ "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": {
- "201": {
+ "200": {
"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"
+ "$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": "Attach a Server to a Network",
+ "summary": "List Actions",
"tags": [
"servers"
],
@@ -17331,33 +20878,33 @@
{
"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\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\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 server attach-to-network $SERVER \\\n --alias-ips 10.0.1.2 \\\n --ip 10.0.1.1 \\\n --network 4711"
+ "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/{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",
+ "/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,
@@ -17365,52 +20912,19 @@
}
}
],
- "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_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": "Change alias IPs of a Network",
+ "summary": "Get an Action",
"tags": [
"servers"
],
@@ -17418,212 +20932,140 @@
{
"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\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.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 server change-alias-ips $SERVER \\\n --alias-ips 10.0.1.2 \\\n --network 4711"
+ "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"
+ }
+ ]
},
- "/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",
+ "/ssh_keys": {
+ "get": {
+ "description": "Returns all SSH key objects.",
+ "operationId": "list_ssh_keys",
"parameters": [
{
- "description": "ID of the Server.",
- "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": {
- "description": "ID of the Server.",
- "example": 42,
- "format": "int64",
- "maximum": 9007199254740991,
- "type": "integer"
+ "items": {
+ "enum": [
+ "id",
+ "id:asc",
+ "id:desc",
+ "name",
+ "name:asc",
+ "name:desc"
+ ],
+ "type": "string"
+ },
+ "type": "array"
}
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/change_reverse_dns_entry_for_this_server_request"
- }
+ },
+ {
+ "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": "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": {
- "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": "Change reverse DNS entry for this 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.ChangeDNSPtr(ctx, &hcloud.Server{ID: 123}, \"1.2.3.4\", hcloud.Ptr(\"server01.example.com\"))\n\n\terr = client.Action.WaitFor(ctx, action)\n}"
+ "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"
+ }
},
{
- "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()"
+ "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": "CLI",
- "lang": "Shell",
- "source": "hcloud server set-rdns $SERVER \\\n --ip 1.2.3.4 \\\n --hostname server01.example.com"
- }
- ]
- }
- },
- "/servers/{id}/actions/change_protection": {
- "post": {
- "description": "Changes the protection configuration of the Server.",
- "operationId": "change_server_protection",
- "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"
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/change_server_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": 42,
- "type": "server"
- }
- ],
- "started": "2016-01-30T23:55:00+00:00",
- "status": "success"
- }
- },
"schema": {
- "$ref": "#/components/schemas/change_server_protection_response"
+ "$ref": "#/components/schemas/list_ssh_keys_response"
}
}
},
- "description": "The `action` key in the reply contains an Action object with this structure."
+ "description": "The `ssh_keys` key in the reply contains an array of SSH key objects with this structure."
}
},
- "summary": "Change Server Protection",
+ "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\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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nssh_keys = client.ssh_keys.get_all()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud server enable-protection $SERVER delete rebuild\nhcloud server disable-protection $SERVER delete rebuild"
+ "source": "hcloud ssh-key list"
}
]
- }
- },
- "/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 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 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/change_type_of_server_request"
+ "$ref": "#/components/schemas/create_ssh_key_request"
}
}
}
@@ -17632,69 +21074,54 @@
"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"
+ "$ref": "#/components/schemas/create_ssh_key_response"
}
}
},
- "description": "The `action` key in the reply contains an Action object with this structure."
+ "description": "The `ssh_key` key in the reply contains the object that was just created."
}
},
- "summary": "Change the Type of a Server",
+ "summary": "Create an 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\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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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()"
+ "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 server change-type --keep-disk $SERVER cx22"
+ "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/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",
+ "/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,
@@ -17702,196 +21129,96 @@
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/create_image_from_server_request"
- }
- }
- }
- },
"responses": {
- "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/create_image_from_server_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"
+ "204": {
+ "description": "SSH key deleted."
}
},
- "summary": "Create Image from a Server",
+ "summary": "Delete an 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\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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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.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()"
+ "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 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"
+ "source": "hcloud ssh-key delete $SSHKEY"
}
]
- }
- },
- "/servers/{id}/actions/detach_from_network": {
- "post": {
- "description": "Detaches a Server from a network. The interface for this network will vanish.",
- "operationId": "detach_server_from_network",
+ },
+ "get": {
+ "description": "Returns a specific SSH key object.",
+ "operationId": "get_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.",
- "example": 42,
- "format": "int64",
- "maximum": 9007199254740991,
- "type": "integer"
- }
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/detach_server_from_network_request"
- }
- }
- }
- },
- "responses": {
- "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"
- }
- },
+ "name": "id",
+ "required": true,
+ "schema": {
+ "description": "ID of the SSH Key.",
+ "example": 42,
+ "format": "int64",
+ "maximum": 9007199254740991,
+ "type": "integer"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
"schema": {
- "$ref": "#/components/schemas/detach_server_from_network_response"
+ "$ref": "#/components/schemas/get_ssh_key_response"
}
}
},
- "description": "The `action` key in the reply contains an Action object with this structure."
+ "description": "The `ssh_key` key in the reply contains an SSH key object with this structure."
}
},
- "summary": "Detach a Server from a Network",
+ "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\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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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()"
+ "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 server detach-from-network --network 4711 $SERVER"
+ "source": "hcloud ssh-key describe $SSHKEY"
}
]
- }
- },
- "/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",
+ },
+ "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,
@@ -17899,161 +21226,219 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/replace_ssh_key_request"
+ }
+ }
+ }
+ },
"responses": {
- "201": {
+ "200": {
"content": {
"application/json": {
"example": {
- "action": {
- "command": "detach_iso",
- "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/detach_iso_from_server_response"
+ "$ref": "#/components/schemas/replace_ssh_key_response"
}
}
},
- "description": "The `action` key in the reply contains an Action object with this structure."
+ "description": "The `ssh_key` key in the reply contains the modified SSH key object with the new description."
}
},
- "summary": "Detach an ISO from a Server",
+ "summary": "Update an 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\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\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.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.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 server detach-iso $SERVER"
+ "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"
+ }
+ ]
},
- "/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",
+ "/volumes": {
+ "get": {
+ "description": "Gets all existing Volumes that you have available.",
+ "operationId": "list_volumes",
"parameters": [
{
- "description": "ID of the Server.",
- "in": "path",
- "name": "id",
- "required": true,
+ "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": {
- "description": "ID of the Server.",
- "example": 42,
+ "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",
- "maximum": 9007199254740991,
"type": "integer"
}
}
],
"responses": {
- "201": {
+ "200": {
"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/disable_backups_for_server_response"
+ "$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": "Disable Backups for a Server",
+ "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.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\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.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\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nvolumes = client.volumes.get_all()"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud server disable-backup $SERVER"
+ "source": "hcloud volume list"
}
]
- }
- },
- "/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 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/create_volume_request"
+ }
}
}
- ],
+ },
"responses": {
"201": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "disable_rescue",
+ "command": "create_volume",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -18065,55 +21450,114 @@
{
"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/disable_rescue_mode_for_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": "Disable Rescue Mode for 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.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\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.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.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 disable-rescue $SERVER"
+ "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"
+ }
+ ]
},
- "/servers/{id}/actions/enable_backup": {
- "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",
+ "/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,
@@ -18122,72 +21566,43 @@
}
],
"responses": {
- "201": {
- "content": {
- "application/json": {
- "example": {
- "action": {
- "command": "enable_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/enable_and_configure_backups_for_server_response"
- }
- }
- },
- "description": "The `action` key in the reply contains an Action object with this structure."
+ "204": {
+ "description": "Volume deleted."
}
},
- "summary": "Enable and Configure Backups for a Server",
+ "summary": "Delete 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.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\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.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\nclient.volumes.delete(\n volume=Volume(id=123),\n)"
},
{
"label": "CLI",
"lang": "Shell",
- "source": "hcloud server enable-backup $SERVER"
+ "source": "hcloud volume delete $VOLUME"
}
]
- }
- },
- "/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",
+ },
+ "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,
@@ -18195,83 +21610,51 @@
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/enable_rescue_mode_for_server_request"
- }
- }
- }
- },
"responses": {
- "201": {
+ "200": {
"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"
- },
"schema": {
- "$ref": "#/components/schemas/enable_rescue_mode_for_server_response"
+ "$ref": "#/components/schemas/get_volume_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 `volume` key contains the volume."
}
},
- "summary": "Enable Rescue Mode for a Server",
+ "summary": "Get 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\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\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.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()"
+ "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 enable-rescue $SERVER"
+ "source": "hcloud volume describe $VOLUME"
}
]
- }
- },
- "/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",
+ },
+ "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,
@@ -18279,147 +21662,257 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/replace_volume_request"
+ }
+ }
+ }
+ },
"responses": {
- "201": {
+ "200": {
"content": {
"application/json": {
"example": {
- "action": {
- "command": "stop_server",
- "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/power_off_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": "Power off a 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.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\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.power_off(\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\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 poweroff $SERVER"
+ "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"
+ }
+ ]
},
- "/servers/{id}/actions/poweron": {
- "post": {
- "description": "Starts a Server by turning its power on.",
- "operationId": "power_on_server",
+ "/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"
}
+ },
+ {
+ "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": "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"
+ "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/power_on_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": "Power on a Server",
+ "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.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"
- }
+ "volumes"
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/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",
+ "/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"
+ }
+ },
+ {
+ "description": "ID of the Action.",
+ "in": "path",
+ "name": "action_id",
+ "required": true,
+ "schema": {
+ "description": "ID of the Action.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -18428,72 +21921,60 @@
}
],
"responses": {
- "201": {
+ "200": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "reboot_server",
+ "command": "attach_volume",
"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"
}
],
- "started": "2016-01-30T23:50:00+00:00",
- "status": "running"
+ "started": "2016-01-30T23:55:00+00:00",
+ "status": "success"
}
},
"schema": {
- "$ref": "#/components/schemas/soft_reboot_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 contains the Volume Action."
}
},
- "summary": "Soft-reboot 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\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"
- }
+ "volumes"
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/servers/{id}/actions/rebuild": {
+ "/volumes/{id}/actions/attach": {
"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",
+ "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,
@@ -18505,11 +21986,10 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/rebuild_server_from_image_request"
+ "$ref": "#/components/schemas/attach_volume_to_server_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": {
"201": {
@@ -18517,7 +21997,7 @@
"application/json": {
"example": {
"action": {
- "command": "rebuild_server",
+ "command": "attach_volume",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -18527,58 +22007,66 @@
"progress": 0,
"resources": [
{
- "id": 42,
+ "id": 43,
"type": "server"
+ },
+ {
+ "id": 554,
+ "type": "volume"
}
],
"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/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": "Rebuild a Server from an Image",
+ "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\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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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.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()"
+ "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 rebuild --image ubuntu-20.04 $SERVER"
+ "source": "hcloud volume attach $VOLUME \\\n --automount=false \\\n --server 43"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/servers/{id}/actions/remove_from_placement_group": {
+ "/volumes/{id}/actions/change_protection": {
"post": {
- "description": "Removes a Server from a Placement Group.\n",
- "operationId": "remove_from_placement_group",
+ "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,
@@ -18586,13 +22074,22 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/change_volume_protection_request"
+ }
+ }
+ }
+ },
"responses": {
"201": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "remove_from_placement_group",
+ "command": "change_protection",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -18604,6 +22101,10 @@
{
"id": 42,
"type": "server"
+ },
+ {
+ "id": 554,
+ "type": "volume"
}
],
"started": "2016-01-30T23:55:00+00:00",
@@ -18611,48 +22112,53 @@
}
},
"schema": {
- "$ref": "#/components/schemas/remove_from_placement_group_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": "Remove from Placement Group",
+ "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.RemoveFromPlacementGroup(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.remove_from_placement_group(\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 remove-from-placement-group $SERVER"
+ "source": "hcloud volume enable-protection $VOLUME delete\nhcloud volume disable-protection $VOLUME delete"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/servers/{id}/actions/request_console": {
+ "/volumes/{id}/actions/detach": {
"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",
+ "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,
@@ -18666,69 +22172,72 @@
"application/json": {
"example": {
"action": {
- "command": "request_console",
+ "command": "detach_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"
}
],
- "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"
+ "started": "2016-01-30T23:50:00+00:00",
+ "status": "running"
+ }
},
"schema": {
- "$ref": "#/components/schemas/request_console_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": "Request Console 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\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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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"
+ "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 request-console $SERVER"
+ "source": "hcloud volume detach $VOLUME"
}
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/v1"
+ }
+ ]
},
- "/servers/{id}/actions/reset": {
+ "/volumes/{id}/actions/resize": {
"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",
+ "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,
@@ -18736,13 +22245,22 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/resize_volume_request"
+ }
+ }
+ }
+ },
"responses": {
"201": {
"content": {
"application/json": {
"example": {
"action": {
- "command": "reset_server",
+ "command": "resize_volume",
"error": {
"code": "action_failed",
"message": "Action failed"
@@ -18752,8 +22270,8 @@
"progress": 0,
"resources": [
{
- "id": 42,
- "type": "server"
+ "id": 554,
+ "type": "volume"
}
],
"started": "2016-01-30T23:50:00+00:00",
@@ -18761,48 +22279,181 @@
}
},
"schema": {
- "$ref": "#/components/schemas/reset_server_response"
+ "$ref": "#/components/schemas/resize_volume_response"
+ }
+ }
+ },
+ "description": "The `action` key contains the `resize_volume` Action."
+ }
+ },
+ "summary": "Resize 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\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"
+ }
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.cloud/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",
+ "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 `action` key in the reply contains an Action object with this structure."
+ "description": "The `actions` key contains a list of Actions."
}
},
- "summary": "Reset 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\taction, _, err := client.Server.Reset(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\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\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"
+ "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"
+ }
+ ]
},
- "/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",
+ "/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,
@@ -18811,192 +22462,189 @@
}
],
"responses": {
- "201": {
+ "200": {
"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"
- }
- ],
- "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/get_action_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 has this structure."
}
},
- "summary": "Reset root Password of 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\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}"
+ "source": "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\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\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"
+ "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"
+ }
+ ]
},
- "/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",
+ "/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": "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/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": "Shutdown 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.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_box_types"
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.com/v1"
+ }
+ ]
},
- "/servers/{id}/metrics": {
+ "/storage_box_types/{id}": {
"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",
+ "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,
"type": "integer"
}
- },
+ }
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/get_storage_box_type_response"
+ }
+ }
+ },
+ "description": "The `storage_box_type` key in the reply contains a Storage Box type object with this structure."
+ }
+ },
+ "summary": "Get a Storage Box Type",
+ "tags": [
+ "storage_box_types"
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.com/v1"
+ }
+ ]
+ },
+ "/storage_boxes": {
+ "get": {
+ "description": "Returns all existing Storage Box objects.\n",
+ "operationId": "list_storage_boxes",
+ "parameters": [
{
- "description": "Type of metrics to get.",
+ "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": "type",
- "required": true,
+ "name": "label_selector",
+ "required": false,
"schema": {
- "enum": [
- "cpu",
- "disk",
- "network"
- ],
"type": "string"
}
},
{
- "description": "Start of period to get Metrics for (in ISO-8601 format).",
+ "description": "Filter resources by their name. The response will only contain the resources\nmatching exactly the specified name.\n",
"in": "query",
- "name": "start",
- "required": true,
+ "name": "name",
+ "required": false,
"schema": {
"type": "string"
}
},
{
- "description": "End of period to get Metrics for (in ISO-8601 format).",
+ "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".",
"in": "query",
- "name": "end",
- "required": true,
+ "name": "page",
+ "required": false,
"schema": {
- "type": "string"
+ "default": 1,
+ "example": 2,
+ "format": "int64",
+ "type": "integer"
}
},
{
- "description": "Resolution of results in seconds.",
+ "description": "Maximum number of entries returned per page. For more information, see \"[Pagination](#pagination)\".",
"in": "query",
- "name": "step",
+ "name": "per_page",
"required": false,
"schema": {
- "type": "string"
+ "default": 25,
+ "example": 25,
+ "format": "int64",
+ "type": "integer"
}
}
],
@@ -19005,40 +22653,140 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/get_metrics_for_server_response"
+ "$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/create_storage_box_request"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "201": {
+ "content": {
+ "application/json": {
+ "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,
+ "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
+ }
+ }
+ }
+ },
+ "schema": {
+ "$ref": "#/components/schemas/create_storage_box_response"
}
}
},
- "description": "The `metrics` key in the reply contains a metrics object with this structure."
+ "description": "The `action` key in the reply contains an Action object with this structure."
}
},
- "summary": "Get Metrics for a Server",
+ "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\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.com/v1"
+ }
+ ]
},
- "/servers/actions": {
+ "/storage_boxes/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": "Returns all Action objects.",
+ "operationId": "list_storage_box_actions",
"parameters": [
{
"description": "Filter the actions by ID. Can be used multiple times. The response will only contain\nactions matching the specified IDs.\n",
@@ -19142,29 +22890,22 @@
},
"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\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.com/v1"
+ }
+ ]
},
- "/servers/actions/{id}": {
+ "/storage_boxes/actions/{id}": {
"get": {
"description": "Returns a specific Action object.",
- "operationId": "get_server_action",
+ "operationId": "get_storage_box_action",
"parameters": [
{
- "description": "ID of the Action",
+ "description": "ID of the Action.",
"in": "path",
"name": "id",
"required": true,
@@ -19191,29 +22932,166 @@
},
"summary": "Get an Action",
"tags": [
- "servers"
+ "storage_boxes"
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.com/v1"
+ }
+ ]
+ },
+ "/storage_boxes/{id}": {
+ "delete": {
+ "description": "Deletes an existing Storage Box.",
+ "operationId": "delete_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"
+ }
+ }
],
- "x-codeSamples": [
+ "responses": {
+ "201": {
+ "content": {
+ "application/json": {
+ "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"
+ }
+ }
+ }
+ },
+ "schema": {
+ "$ref": "#/components/schemas/delete_storage_box_response"
+ }
+ }
+ },
+ "description": "The `action` key in the reply contains an Action object with this structure."
+ }
+ },
+ "summary": "Delete Storage Box",
+ "tags": [
+ "storage_boxes"
+ ]
+ },
+ "get": {
+ "description": "Returns a specific Storage Box object. The Storage Box must exist inside the Project.\n",
+ "operationId": "get_storage_box",
+ "parameters": [
{
- "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}"
- },
+ "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": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/get_storage_box_response"
+ }
+ }
+ },
+ "description": "The `storage_box` key in the reply contains a Storage Box object with this structure."
+ }
+ },
+ "summary": "Get a Storage Box",
+ "tags": [
+ "storage_boxes"
+ ]
+ },
+ "put": {
+ "description": "Updates a Storage Box. You can update a Storage Boxes' name and labels.\n",
+ "operationId": "replace_storage_box",
+ "parameters": [
{
- "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)"
+ "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/replace_storage_box_request"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/replace_storage_box_response"
+ }
+ }
+ },
+ "description": "The `storage_box` key in the reply contains the updated Storage Box object with this structure."
}
+ },
+ "summary": "Update a Storage Box",
+ "tags": [
+ "storage_boxes"
]
- }
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.com/v1"
+ }
+ ]
},
- "/ssh_keys": {
+ "/storage_boxes/{id}/actions": {
"get": {
- "description": "Returns all SSH key objects.",
- "operationId": "list_ssh_keys",
+ "description": "List all Actions related to a specific Storage Box.",
+ "operationId": "list_actions_for_storage_box",
"parameters": [
{
- "description": "Sort resources by field and direction. Can be used multiple times. For more\ninformation, see \"[Sorting](#sorting)\".\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,
@@ -19223,9 +23101,18 @@
"id",
"id:asc",
"id:desc",
- "name",
- "name:asc",
- "name:desc"
+ "command",
+ "command:asc",
+ "command:desc",
+ "status",
+ "status:asc",
+ "status:desc",
+ "started",
+ "started:asc",
+ "started:desc",
+ "finished",
+ "finished:asc",
+ "finished:desc"
],
"type": "string"
},
@@ -19233,30 +23120,34 @@
}
},
{
- "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.",
+ "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": "fingerprint",
+ "name": "status",
"required": false,
"schema": {
- "type": "string"
+ "items": {
+ "description": "Status of the Action.",
+ "enum": [
+ "running",
+ "success",
+ "error"
+ ],
+ "type": "string"
+ },
+ "type": "array"
}
},
{
- "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,
+ "description": "ID of the Storage Box.",
+ "in": "path",
+ "name": "id",
+ "required": true,
"schema": {
- "type": "string"
+ "description": "ID of the Storage Box.",
+ "example": 42,
+ "format": "int64",
+ "maximum": 9007199254740991,
+ "type": "integer"
}
},
{
@@ -19285,47 +23176,125 @@
}
],
"responses": {
- "200": {
+ "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/list_ssh_keys_response"
+ "$ref": "#/components/schemas/change_storage_box_protection_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": "Change Storage Box Protection",
"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()"
- },
- {
- "label": "CLI",
- "lang": "Shell",
- "source": "hcloud ssh-key list"
- }
+ "storage_boxes"
]
},
+ "servers": [
+ {
+ "url": "https://api.hetzner.com/v1"
+ }
+ ]
+ },
+ "/storage_boxes/{id}/actions/change_type": {
"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",
+ "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/create_ssh_key_request"
+ "$ref": "#/components/schemas/change_type_of_storage_box_request"
}
}
}
@@ -19334,49 +23303,62 @@
"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/create_ssh_key_response"
+ "$ref": "#/components/schemas/change_type_of_storage_box_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": "Change the Type of 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.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.com/v1"
+ }
+ ]
},
- "/ssh_keys/{id}": {
- "delete": {
- "description": "Deletes an SSH key. It cannot be used anymore.",
- "operationId": "delete_ssh_key",
+ "/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 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,
@@ -19385,43 +23367,65 @@
}
],
"responses": {
- "204": {
- "description": "SSH key deleted."
+ "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": "Delete an SSH key",
+ "summary": "Disable Snapshot Plan",
"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"
- }
+ "storage_boxes"
]
},
- "get": {
- "description": "Returns a specific SSH key object.",
- "operationId": "get_ssh_key",
+ "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 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,
@@ -19429,51 +23433,151 @@
}
}
],
+ "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/get_ssh_key_response"
+ "$ref": "#/components/schemas/enable_snapshot_plan_response"
}
}
},
- "description": "The `ssh_key` key in the reply contains an SSH key object with this structure."
+ "description": "The `action` key in the reply contains an Action object with this structure."
}
},
- "summary": "Get a SSH key",
+ "summary": "Enable Snapshot Plan",
"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)"
- },
+ "storage_boxes"
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.com/v1"
+ }
+ ]
+ },
+ "/storage_boxes/{id}/actions/reset_password": {
+ "post": {
+ "description": "Reset the password of the given Storage Box.\n",
+ "operationId": "reset_storage_box_password",
+ "parameters": [
{
- "label": "CLI",
- "lang": "Shell",
- "source": "hcloud ssh-key describe $SSHKEY"
+ "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/reset_password_request"
+ }
+ }
+ }
+ },
+ "responses": {
+ "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/reset_password_response"
+ }
+ }
+ },
+ "description": "The `action` key in the reply contains an Action object with this structure."
}
+ },
+ "summary": "Reset Password",
+ "tags": [
+ "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}/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": "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,
@@ -19485,199 +23589,87 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/replace_ssh_key_request"
+ "$ref": "#/components/schemas/rollback_snapshot_request"
}
}
}
},
"responses": {
- "200": {
+ "201": {
"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": {
+ "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/replace_ssh_key_response"
+ "$ref": "#/components/schemas/rollback_snapshot_response"
}
}
},
- "description": "The `ssh_key` key in the reply contains the modified SSH key object with the new description."
+ "description": "The `action` key in the reply contains an Action object with this structure."
}
},
- "summary": "Update an SSH key",
+ "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\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.com/v1"
+ }
+ ]
},
- "/volumes": {
- "get": {
- "description": "Gets all existing Volumes that you have available.",
- "operationId": "list_volumes",
+ "/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": [
{
- "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,
+ "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"
}
}
],
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/list_volumes_response"
- }
- }
- },
- "description": "The `volumes` key contains a list of volumes."
- }
- },
- "summary": "List Volumes",
- "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"
- }
- ]
- },
- "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",
"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/update_access_settings_request"
}
}
}
@@ -19686,123 +23678,75 @@
"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"
- },
- {
- "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"
+ "examples": {
+ "201": {
+ "description": "Action successfully created.",
+ "value": {
+ "action": {
+ "command": "update_access_settings",
+ "error": {
+ "code": "action_failed",
+ "message": "Action failed"
},
- {
- "id": 554,
- "type": "volume"
- }
- ],
- "started": "2016-01-30T23:50:00+00:00",
- "status": "running"
+ "finished": null,
+ "id": 13,
+ "progress": 0,
+ "resources": [
+ {
+ "id": 42,
+ "type": "storage_box"
+ }
+ ],
+ "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/update_access_settings_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": "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\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.com/v1"
+ }
+ ]
},
- "/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",
+ "/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 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 Action.",
+ "in": "path",
+ "name": "action_id",
+ "required": true,
+ "schema": {
+ "description": "ID of the Action.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -19811,95 +23755,198 @@
}
],
"responses": {
- "204": {
- "description": "Volume deleted."
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/get_action_response"
+ }
+ }
+ },
+ "description": "The `action` key in the reply has this structure."
}
},
- "summary": "Delete a Volume",
+ "summary": "Get an Action 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\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"
- }
+ "storage_boxes"
]
},
+ "servers": [
+ {
+ "url": "https://api.hetzner.com/v1"
+ }
+ ]
+ },
+ "/storage_boxes/{id}/folders": {
"get": {
- "description": "Gets a specific Volume object.",
- "operationId": "get_volume",
+ "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 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": "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": {
+ "examples": {
+ "200": {
+ "description": "A list of directories the Storage Box contains.",
+ "value": {
+ "folders": [
+ "offsite-backup",
+ "photos"
+ ]
+ }
+ }
+ },
"schema": {
- "$ref": "#/components/schemas/get_volume_response"
+ "$ref": "#/components/schemas/list_content_of_storage_box_response"
}
}
},
- "description": "The `volume` key contains the volume."
+ "description": "The `folders` key lists the directories the Storage Box contains at the specified path."
}
},
- "summary": "Get a Volume",
+ "summary": "List content of Storage Box",
"tags": [
- "volumes"
- ],
- "x-codeSamples": [
+ "storage_boxes"
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.com/v1"
+ }
+ ]
+ },
+ "/storage_boxes/{id}/snapshots": {
+ "get": {
+ "description": "Get all Snapshots created both manually and through the Snapshot Plan.",
+ "operationId": "list_snapshots_for_storage_box",
+ "parameters": [
{
- "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}"
+ "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"
+ }
},
{
- "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)"
+ "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": "CLI",
- "lang": "Shell",
- "source": "hcloud volume describe $VOLUME"
+ "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": {
+ "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_snapshots_for_storage_box_response"
+ }
+ }
+ },
+ "description": "The `snapshots` key contains a list of Snapshots."
}
+ },
+ "summary": "List Snapshots for a Storage Box",
+ "tags": [
+ "storage_boxes"
]
},
- "put": {
- "description": "Updates the Volume properties.\n",
- "operationId": "replace_volume",
+ "post": {
+ "description": "Creates a new Snapshot.\n",
+ "operationId": "create_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,
@@ -19911,86 +23958,79 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/replace_volume_request"
+ "$ref": "#/components/schemas/create_snapshot_request"
}
}
}
},
"responses": {
- "200": {
+ "201": {
"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"
+ "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"
+ },
+ "snapshot": {
+ "id": 42,
+ "storage_box": 43
+ }
+ }
}
},
"schema": {
- "$ref": "#/components/schemas/replace_volume_response"
+ "$ref": "#/components/schemas/create_snapshot_response"
}
}
},
- "description": "The `volume` key contains the updated volume."
+ "description": "The `action` key in the reply contains an Action object with this structure."
}
},
- "summary": "Update 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\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.com/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",
+ "/storage_boxes/{id}/snapshots/{snapshot_id}": {
+ "delete": {
+ "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,
@@ -19998,73 +24038,92 @@
}
},
{
- "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,
+ "description": "ID of the Storage Box Snapshot.",
+ "in": "path",
+ "name": "snapshot_id",
+ "required": true,
"schema": {
- "items": {
- "description": "Status of the Action.",
- "enum": [
- "running",
- "success",
- "error"
- ],
- "type": "string"
- },
- "type": "array"
+ "description": "ID of the Storage Box Snapshot.",
+ "example": 42,
+ "format": "int64",
+ "maximum": 9007199254740991,
+ "type": "integer"
}
- },
+ }
+ ],
+ "responses": {
+ "201": {
+ "content": {
+ "application/json": {
+ "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"
+ ]
+ },
+ "get": {
+ "description": "Returns a specific Snapshot object.",
+ "operationId": "get_snapshot",
+ "parameters": [
{
- "description": "Page number to return. For more information, see \"[Pagination](#pagination)\".",
- "in": "query",
- "name": "page",
- "required": false,
+ "description": "ID of the Storage Box.",
+ "in": "path",
+ "name": "id",
+ "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 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"
}
}
@@ -20073,68 +24132,30 @@
"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/get_snapshot_response"
}
}
},
- "description": "The `actions` key contains a list of Actions."
+ "description": "The `snapshot` key in the reply contains a Snapshot object with this structure."
}
},
- "summary": "List Actions for a Volume",
+ "summary": "Get a Snapshot",
"tags": [
- "volumes"
+ "storage_boxes"
]
- }
- },
- "/volumes/{id}/actions/{action_id}": {
- "get": {
- "description": "Returns a specific Action for a Volume.",
- "operationId": "get_action_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,
@@ -20142,12 +24163,12 @@
}
},
{
- "description": "ID of the Action.",
+ "description": "ID of the Storage Box Snapshot.",
"in": "path",
- "name": "action_id",
+ "name": "snapshot_id",
"required": true,
"schema": {
- "description": "ID of the Action.",
+ "description": "ID of the Storage Box Snapshot.",
"example": 42,
"format": "int64",
"maximum": 9007199254740991,
@@ -20155,56 +24176,124 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/replace_snapshot_request"
+ }
+ }
+ },
+ "required": true
+ },
"responses": {
"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"
+ "schema": {
+ "$ref": "#/components/schemas/replace_snapshot_response"
+ }
+ }
+ },
+ "description": "The `snapshot` key contains the updated Snapshot."
+ }
+ },
+ "summary": "Update a Snapshot",
+ "tags": [
+ "storage_boxes"
+ ]
+ },
+ "servers": [
+ {
+ "url": "https://api.hetzner.com/v1"
+ }
+ ]
+ },
+ "/storage_boxes/{id}/subaccounts": {
+ "get": {
+ "description": "Get a list of all available Subaccounts.",
+ "operationId": "list_subaccounts_for_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"
+ }
+ },
+ {
+ "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": {
+ "200": {
+ "content": {
+ "application/json": {
+ "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"
]
- }
- },
- "/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,
@@ -20216,7 +24305,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/attach_volume_to_server_request"
+ "$ref": "#/components/schemas/create_subaccount_request"
}
}
}
@@ -20225,160 +24314,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.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"
]
- }
- },
- "/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,
@@ -20387,72 +24476,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"
]
- }
- },
- "/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,
@@ -20464,201 +24527,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.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.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,
@@ -20666,35 +24681,66 @@
}
}
],
+ "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.com/v1"
+ }
+ ]
}
},
"security": [
diff --git a/resources/document_transformations.json b/resources/document_transformations.json
index c7823b4..638d9c0 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"
}
@@ -60,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"],
@@ -79,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"],
@@ -98,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"],
@@ -117,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"],
@@ -136,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"],
@@ -155,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"],
@@ -174,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"],
@@ -193,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"],
@@ -212,135 +225,163 @@
"operationId": "get_volume_action"
}
},
+
{
- "path": ["paths", "/volumes/actions/{id}", "get", "parameters", 0],
+ "path": ["paths", "/storage_boxes/actions", "get"],
"set": {
- "description": "ID of the Action"
+ "operationId": "list_storage_box_actions"
}
},
-
{
- "path": ["components", "schemas", "list_actions_response"],
+ "path": ["paths", "/storage_boxes/actions/{id}", "get"],
"set": {
- "description": "Response to GET https://api.hetzner.cloud/v1/{resource}/actions/{id}"
+ "operationId": "get_storage_box_action"
}
},
{
- "path": ["components", "schemas", "get_action_response"],
+ "path": [
+ "paths",
+ "/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/reset_subaccount_password",
+ "post"
+ ],
"set": {
- "description": "Response to GET https://api.hetzner.cloud/v1/{resource}/actions"
+ "operationId": "reset_storage_box_subaccount_password"
}
},
-
{
- "path": ["paths", "/actions/{id}", "get", "parameters", 0],
+ "path": ["paths", "/storage_boxes/{id}/actions/reset_password", "post"],
"set": {
- "description": "ID of the Action"
+ "operationId": "reset_storage_box_password"
}
},
{
- "path": ["components", "schemas", "action", "properties", "id"],
+ "path": [
+ "paths",
+ "/storage_boxes/{id}/subaccounts/{subaccount_id}/actions/update_access_settings",
+ "post"
+ ],
"set": {
- "description": "ID of the Action"
+ "operationId": "update_storage_box_subaccount_access_settings"
}
},
{
- "path": ["components", "schemas", "action_optional", "properties", "id"],
+ "path": [
+ "paths",
+ "/storage_boxes/{id}/actions/update_access_settings",
+ "post"
+ ],
"set": {
- "description": "ID of the Action"
+ "operationId": "update_storage_box_access_settings"
}
},
{
- "path": ["paths", "/firewalls/{id}/actions", "get", "parameters", 0],
+ "path": ["components", "schemas", "list_actions_response"],
"set": {
- "description": "ID of the Firewall"
+ "description": "Response to GET https://api.hetzner.cloud/v1/{resource}/actions/{id}"
}
},
{
- "path": ["paths", "/firewalls/{id}/actions", "get", "parameters", 0, "schema"],
+ "path": ["components", "schemas", "get_action_response"],
"set": {
- "description": "ID of the Firewall. Limited to 52 bits to ensure compatability with JSON double precision floats."
+ "description": "Response to GET https://api.hetzner.cloud/v1/{resource}/actions"
}
},
{
- "path": ["paths", "/firewalls/{id}/actions", "get", "parameters", 0, "schema"],
+ "path": [
+ "paths",
+ "/firewalls/{id}/actions",
+ "get",
+ "parameters",
+ 0,
+ "schema"
+ ],
"set": {
"title": "Firewall ID"
}
},
{
- "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", "/certificates/{id}/actions", "get", "parameters", 0, "schema"],
+ "path": [
+ "paths",
+ "/certificates/{id}/actions",
+ "get",
+ "parameters",
+ 0,
+ "schema"
+ ],
"set": {
"title": "Certificate ID"
}
},
{
- "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", "/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" }
+ }
+ },
+
+ {
+ "path": ["components", "schemas", "storage_box_type", "properties", "size"],
+ "set": {
+ "format": "int64"
}
}
]
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 2ce7017..2698ddc 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;
@@ -159,15 +162,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 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;
+ }
+
const verb_data = verb_obj as OpenApiDocumentFragment;
const id = toSchemaName("request", verb, verb_data.summary);
@@ -233,11 +253,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);
}
}
@@ -293,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));
@@ -344,12 +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: "Hetzner Cloud API",
+ },
+ {
+ url: "https://api.hetzner.com/v1",
+ description: "Hetzner API",
+ },
+ ],
+ security: [
+ {
+ APIToken: [],
+ },
+ ],
+ } as OpenApiDocumentFragment;
+}
+
async function main() {
const args = parseArgs();
-
try {
- // load document from source
- let document = (await getContents(args.source)) as OpenApiDocumentFragment;
+ 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);
@@ -360,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
@@ -394,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(", ")})`
);