π₯οΈ Servers
Servers are virtual machines that can be provisioned.
Get all Servers
Returns all existing Server objects
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient("apiKey");
// Get All
List<Server> list = await hetznerCloudClient.Server.Get();Get a Server
Returns a specific Server object. The Server must exist inside the Project
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient("apiKey");
long serverId = 39447794;
// Get One
Server server = await hetznerCloudClient.Server.Get(serverId);Create a Server (Simple)
Creates a new Server. Returns preliminary information about the Server as well as an Action that covers progress of creation.
Creating a server is pretty straightforward. We can specify the basics like name, image, location, or get more detailed, indicating whether we'll enable IPv4, IPv6, or specifying if it'll be within a private network. We can set SSH keys, decide if it should be associated with a volume, or even kick off a startup script using Cloud config.
The minimum required to create the server is the location, the image, the server name, and the server type
In this example, we'll specify the minimum to create a server.
Additionally, the eDataCenter enum has been created, aiming to standardize resource creation throughout the Hetzner environment. It can be used for server creation as follows
Create a Server (Complete)
In addition to creating a server (simple), we can specify every detail of the server's resources. This includes indicating whether to enable IPv4, IPv6, passing a list of network IDs, SSH key IDs, specifying the volumes to mount, and even including it in a "placement group." We can also indicate the startup script with Cloud-Init scripts
And just like in the simple creation, here you can also replace LocationId with eDataCenter to make the creation process simpler
Update a Server
Updates a Server. You can update a Serverβs name.
Note:
Person asking: Can you only modify the name in the api.hetzner.cloud/v1/servers/{id} endpoint?
Person answering: Yes!
Person asking: π
All other actions that affect or interact with the server can be found in Servers Actions.
Delete a Server
Deletes a Server. This immediately removes the Server from your account, and it is no longer accessible. Any resources attached to the server (like Volumes, Primary IPs, Floating IPs, Firewalls, Placement Groups) are detached while the server is deleted.
You can also delete by passing the Server ID instead of the Server object
JSON
Last updated
Was this helpful?