-
-
Notifications
You must be signed in to change notification settings - Fork 8
server
Returns all server in the project on the first page.
// returns all server for the first page.
List<lkcode.hetznercloudapi.Api.Server> serverList = await lkcode.hetznercloudapi.Api.Server.GetAsync();
Returns all server in the project on the third page.
// returns all server for the third page.
int page = 3;
List<lkcode.hetznercloudapi.Api.Server> serverList = await lkcode.hetznercloudapi.Api.Server.GetAsync(page);
Returns all server filtered by the given filter-value for the first page.
string nameToFilter = "server-name";
List<lkcode.hetznercloudapi.Api.Server> serverList = await lkcode.hetznercloudapi.Api.Server.GetAsync(nameToFilter);
Returns all server filtered by the given filter-value for the second page.
string nameToFilter = "server-name";
int page = 2;
List<lkcode.hetznercloudapi.Api.Server> serverList = await lkcode.hetznercloudapi.Api.Server.GetAsync(nameToFilter, page);
Returns a server by the given id.
long serverId = 9583;
lkcode.hetznercloudapi.Api.Server server = await lkcode.hetznercloudapi.Api.Server.GetAsync(serverId);
Returns a server by the given id.
int serverId = 9583;
lkcode.hetznercloudapi.Api.Server server = await lkcode.hetznercloudapi.Api.Server.GetByIdAsync(serverId);
Returns a server by the given id.
long serverId = 9583;
lkcode.hetznercloudapi.Api.Server server = await lkcode.hetznercloudapi.Api.Server.GetByIdAsync(serverId);
Shuts down a server gracefully by sending an ACPI shutdown request. The server operating system must support ACPI and react to the request, otherwise the server will not shut down.
long serverId = 9583;
lkcode.hetznercloudapi.Api.Server server = await lkcode.hetznercloudapi.Api.Server.GetAsync(serverId);
lkcode.hetznercloudapi.Api.ServerActionResponse action = server.Shutdown();
Starts a server by turning its power on.
long serverId = 9583;
lkcode.hetznercloudapi.Api.Server server = await lkcode.hetznercloudapi.Api.Server.GetAsync(serverId);
lkcode.hetznercloudapi.Api.ServerActionResponse action = server.PowerOn();
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.
long serverId = 9583;
lkcode.hetznercloudapi.Api.Server server = await lkcode.hetznercloudapi.Api.Server.GetAsync(serverId);
lkcode.hetznercloudapi.Api.ServerActionResponse action = server.PowerOff();
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.
long serverId = 9583;
lkcode.hetznercloudapi.Api.Server server = await lkcode.hetznercloudapi.Api.Server.GetAsync(serverId);
lkcode.hetznercloudapi.Api.ServerActionResponse action = server.Reboot();
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.
long serverId = 9583;
lkcode.hetznercloudapi.Api.Server server = await lkcode.hetznercloudapi.Api.Server.GetAsync(serverId);
lkcode.hetznercloudapi.Api.ServerActionResponse action = server.Reset();
Resets the root password. Only works for Linux systems that are running the qemu guest agent. Server must be powered on (state on) in order for this operation to succeed.
This will generate a new password for this server and return it.
If this does not succeed you can use the rescue system to netboot the server and manually change your server password by hand.
long serverId = 9583;
lkcode.hetznercloudapi.Api.Server server = await lkcode.hetznercloudapi.Api.Server.GetAsync(serverId);
lkcode.hetznercloudapi.Api.ServerActionResponse action = server.ResetPassword();
string generatedPassword = action.AdditionalActionContent;
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.
To make sure disk content is consistent, we recommend to shut down the server prior to creating an image.
You 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 an 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.
long serverId = 9583;
lkcode.hetznercloudapi.Api.Server server = await lkcode.hetznercloudapi.Api.Server.GetAsync(serverId);
string imageName = "todays-backup-image";
string imageType = lkcode.hetznercloudapi.Components.ServerImageType.BACKUP; // BACKUP or SNAPSHOT
lkcode.hetznercloudapi.Api.ServerActionResponse action = server.CreateImage(imageName, imageType);
Rebuilds a server overwriting its disk with the content of an image, thereby destroying all data on the target server.
The 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.
Your server will automatically be powered off before the rebuild command executes.
long serverId = 9583;
lkcode.hetznercloudapi.Api.Server server = await lkcode.hetznercloudapi.Api.Server.GetAsync(serverId);
lkcode.hetznercloudapi.Api.ServerActionResponse actionResponse = await server.RebuildImage("test-snapshot");
ID of server.
ID of server.
ID of server.
Name of the server (must be unique per project and a valid hostname as per RFC 1123).
Status of the server.
Point in time when the server was created (in ISO-8601 format) as a System.DateTimeOffset.
Network Network
Public network information.