UNPKG

hetzner-ts

Version:

A TypeScript SDK for the Hetzner Cloud API

1,958 lines (1,932 loc) 83.2 kB
interface APIErrorDetails { code: string; message: string; fields?: Array<{ name: string; messages: string[]; }>; } interface APIError { error: APIErrorDetails; } interface MetaPagination { page: number; per_page: number; previous_page: number | null; next_page: number | null; last_page: number | null; total_entries: number; } interface Meta { pagination?: MetaPagination; } interface ActionError$1 { code: string; message: string; } interface ActionResource$1 { id: number; type: string; } interface BaseAction { id: number; command: string; status: "running" | "success" | "error"; progress: number; started: string; finished: string | null; resources: ActionResource$1[]; error: ActionError$1 | null; } declare class BaseAPI { protected token: string; protected baseUrl: string; constructor(token: string, baseUrl?: string); request<T>(endpoint: string, options?: RequestInit): Promise<{ success: true; response: T; } | { success: false; response: APIError; }>; } interface PriceValue { net: string; gross: string; } interface LocationPriceEntry { location: string; price_hourly?: PriceValue; price_monthly: PriceValue; included_traffic?: number; price_per_tb_traffic?: PriceValue; } interface TypedLocationPrice { type: string; prices: LocationPriceEntry[]; } interface ImagePrice { price_per_gb_month: PriceValue; } interface VolumePrice { price_per_gb_month: PriceValue; } interface ServerBackupPrice { percentage: string; } interface ServerTypePriceEntry { id: number; name: string; prices: LocationPriceEntry[]; } interface LoadBalancerTypePriceEntry { id: number; name: string; prices: LocationPriceEntry[]; } interface PricingData { currency: string; vat_rate: string; primary_ips: TypedLocationPrice[]; floating_ips: TypedLocationPrice[]; image: ImagePrice; volume: VolumePrice; server_backup: ServerBackupPrice; server_types: ServerTypePriceEntry[]; load_balancer_types: LoadBalancerTypePriceEntry[]; } interface PricingResponse { pricing: PricingData; } /** * Billing API * * Returns prices for resources. * https://docs.hetzner.cloud/#billing * */ declare class Billing extends BaseAPI { /** * Get all prices for resources * VAT and currency of the Project owner are used for calculations. * Both net and gross prices are included in the response. */ get(): Promise<{ success: true; response: PricingResponse; } | { success: false; response: APIError; }>; } type Protocol = "tcp" | "udp" | "icmp" | "esp" | "gre"; type Direction = "in" | "out"; type ActionStatus = "running" | "success" | "error"; interface FirewallRule { description?: string | null; direction: Direction; source_ips: string[]; destination_ips?: string[]; protocol: Protocol; port?: string; } interface FirewallResource { type: "server" | "label_selector"; server?: { id: number; }; label_selector?: { selector: string; }; } interface FirewallResourceResult extends FirewallResource { applied_to_resources?: { type: "server"; server: { id: number; }; }[]; } interface Firewall { id: number; name: string; labels?: Record<string, string>; created: string; rules: FirewallRule[]; applied_to: FirewallResourceResult[]; } interface FirewallsResponse { firewalls: Firewall[]; meta: Meta; } interface FirewallCreateResponse { firewall: Firewall; actions: FirewallAction[]; } interface FirewallAction { id: number; command: string; status: ActionStatus; started: string; finished: string | null; progress: number; resources: { id: number; type: string; }[]; error: { code: string; message: string; } | null; } interface FirewallActionsResponse { actions: FirewallAction[]; meta: Meta; } type SortOrder = "asc" | "desc"; type SortField = "id" | "command" | "status" | "started" | "finished"; type SortOption = SortField | `${SortField}:${SortOrder}`; /** * Firewall Actions API * * Returns all Actions for Firewalls. * https://docs.hetzner.cloud/#firewalls-actions * */ declare class FirewallActions extends BaseAPI { /** * List all actions for firewalls * @param params Optional parameters for filtering and pagination */ getAll(params?: { id?: number; sort?: SortOption; status?: ActionStatus; page?: number; per_page?: number; }): Promise<{ success: true; response: FirewallActionsResponse; } | { success: false; response: APIError; }>; /** * Get a specific action for a firewall */ get(firewallId: number, actionId: number): Promise<{ success: true; response: { action: FirewallAction; }; } | { success: false; response: APIError; }>; /** * Apply firewall to resources */ applyToResources(firewallId: number, resources: FirewallResource[]): Promise<{ success: true; response: { action: FirewallAction; }; } | { success: false; response: APIError; }>; /** * Remove firewall from resources */ removeFromResources(firewallId: number, resources: FirewallResource[]): Promise<{ success: true; response: { action: FirewallAction; }; } | { success: false; response: APIError; }>; /** * Set firewall rules */ setRules(firewallId: number, rules: FirewallRule[] | []): Promise<{ success: true; response: { action: FirewallAction; }; } | { success: false; response: APIError; }>; /** * Get all actions for a specific firewall */ getFirewallActions(firewallId: number, params?: { sort?: SortOption; status?: ActionStatus; page?: number; per_page?: number; }): Promise<{ success: true; response: FirewallActionsResponse; } | { success: false; response: APIError; }>; /** * Returns a specific Action for a Firewall. */ getFirewallAction(firewallId: number, actionId: number): Promise<{ success: true; response: { action: FirewallAction; }; } | { success: false; response: APIError; }>; } interface ListFirewallsParams { name?: string; label_selector?: string; sort?: "id" | "id:asc" | "id:desc" | "name" | "name:asc" | "name:desc" | "created" | "created:asc" | "created:desc"; page?: number; per_page?: number; } interface CreateFirewallParams { name: string; labels?: Record<string, string>; rules?: FirewallRule[]; apply_to?: FirewallResource[]; } interface UpdateFirewallParams { name?: string; labels?: Record<string, string>; } /** * Firewalls API * * Firewalls can limit the network access to or from your resources. * https://docs.hetzner.cloud/#firewalls * */ declare class Firewalls extends BaseAPI { private _actions; /** * Get the actions instance for managing firewall actions */ get actions(): FirewallActions; /** * List all firewalls with optional filtering and pagination * @param params Optional parameters for filtering and pagination */ getAll(params?: ListFirewallsParams): Promise<{ success: true; response: FirewallsResponse; } | { success: false; response: APIError; }>; /** * Create a new firewall * @param params Parameters for creating the firewall */ create(params: CreateFirewallParams): Promise<{ success: true; response: FirewallCreateResponse; } | { success: false; response: APIError; }>; /** * Get a specific firewall by ID * @param id The firewall ID */ get(id: number): Promise<{ success: true; response: { firewall: Firewall; }; } | { success: false; response: APIError; }>; /** * Update a firewall's properties * @param id The firewall ID * @param params Parameters to update */ update(id: number, params: UpdateFirewallParams): Promise<{ success: true; response: { firewall: Firewall; }; } | { success: false; response: APIError; }>; /** * Delete a firewall * @param id The firewall ID */ delete(id: number): Promise<{ success: true; response: null; } | { success: false; response: APIError; }>; } interface FloatingIP { id: number; name: string; description: string | null; ip: string; type: "ipv4" | "ipv6"; server: number | null; dns_ptr: { [ip: string]: string; }[]; home_location: { id: number; name: string; description: string; country: string; city: string; latitude: number; longitude: number; network_zone: string; }; blocked: boolean; created: string; labels: Record<string, string>; protection: { delete: boolean; }; } interface FloatingIPsResponse { floating_ips: FloatingIP[]; meta?: Meta; } interface ListFloatingIPsParams { name?: string; label_selector?: string; sort?: "id" | "id:asc" | "id:desc" | "name" | "name:asc" | "name:desc" | "created" | "created:asc" | "created:desc"; page?: number; per_page?: number; } interface CreateFloatingIPParams { type: "ipv4" | "ipv6"; server?: number; home_location?: string; description?: string; name?: string; labels?: Record<string, string>; } interface UpdateFloatingIPParams { description?: string; name?: string; labels?: Record<string, string>; } interface FloatingIPAction extends BaseAction { } interface FloatingIPActionsResponse { actions: FloatingIPAction[]; meta?: Meta; } interface ListFloatingIPActionsParams { id?: number; sort?: "id" | "id:asc" | "id:desc" | "command" | "command:asc" | "command:desc" | "status" | "status:asc" | "status:desc" | "progress" | "progress:asc" | "progress:desc" | "started" | "started:asc" | "started:desc" | "finished" | "finished:asc" | "finished:desc"; status?: "running" | "success" | "error"; page?: number; per_page?: number; } interface AssignFloatingIPParams { server: number; } interface ChangeDNSPTRParams { ip: string; dns_ptr: string; } interface ChangeProtectionParams { delete: boolean; } declare class FloatingIPActions extends BaseAPI { /** * List all actions for Floating IPs * @param params Optional parameters for filtering and pagination */ getAll(params?: ListFloatingIPActionsParams): Promise<{ success: true; response: FloatingIPActionsResponse; } | { success: false; response: APIError; }>; /** * Get a specific action for Floating IPs * @param actionId The action ID */ get(actionId: number): Promise<{ success: true; response: FloatingIPAction; } | { success: false; response: APIError; }>; /** * List actions for a specific Floating IP * @param floatingIpId The Floating IP ID * @param params Optional parameters for filtering and pagination */ listForFloatingIP(floatingIpId: number, params?: ListFloatingIPActionsParams): Promise<{ success: true; response: FloatingIPActionsResponse; } | { success: false; response: APIError; }>; /** * Assign a Floating IP to a Server * @param floatingIpId The Floating IP ID * @param params Parameters for assigning the Floating IP */ assign(floatingIpId: number, params: AssignFloatingIPParams): Promise<{ success: true; response: FloatingIPAction; } | { success: false; response: APIError; }>; /** * Unassign a Floating IP * @param floatingIpId The Floating IP ID */ unassign(floatingIpId: number): Promise<{ success: true; response: FloatingIPAction; } | { success: false; response: APIError; }>; /** * Change Reverse DNS (PTR) for a Floating IP * @param floatingIpId The Floating IP ID * @param params Parameters for changing the DNS PTR record */ changeDNSPTR(floatingIpId: number, params: ChangeDNSPTRParams): Promise<{ success: true; response: FloatingIPAction; } | { success: false; response: APIError; }>; /** * Change Floating IP Protection * @param floatingIpId The Floating IP ID * @param params Parameters for changing the protection status */ changeProtection(floatingIpId: number, params: ChangeProtectionParams): Promise<{ success: true; response: FloatingIPAction; } | { success: false; response: APIError; }>; /** * Get a specific action for a specific Floating IP * @param floatingIpId The Floating IP ID * @param actionId The action ID */ getForFloatingIP(floatingIpId: number, actionId: number): Promise<{ success: true; response: FloatingIPAction; } | { success: false; response: APIError; }>; } declare class FloatingIPs extends BaseAPI { private _actions; /** * List all Floating IPs with optional filtering and pagination * @param params Optional parameters for filtering and pagination */ getAll(params?: ListFloatingIPsParams): Promise<{ success: true; response: FloatingIPsResponse; } | { success: false; response: APIError; }>; /** * Get a specific Floating IP by ID * @param id The Floating IP ID */ get(id: number): Promise<{ success: true; response: FloatingIP; } | { success: false; response: APIError; }>; /** * Create a new Floating IP * @param params Parameters for creating the Floating IP */ create(params: CreateFloatingIPParams): Promise<{ success: true; response: { floating_ip: FloatingIP; }; } | { success: false; response: APIError; }>; /** * Update a Floating IP's properties * @param id The Floating IP ID * @param params Parameters to update */ update(id: number, params: UpdateFloatingIPParams): Promise<{ success: true; response: { floating_ip: FloatingIP; }; } | { success: false; response: APIError; }>; /** * Delete a Floating IP * @param id The Floating IP ID */ delete(id: number): Promise<{ success: true; response: null; } | { success: false; response: APIError; }>; get actions(): FloatingIPActions; } interface Location$1 { id: number name: string description: string country: string city: string latitude: number longitude: number network_zone: string } interface LocationsResponse { locations: Location$1[] meta: Meta } interface Datacenter$2 { id: number name: string description: string location: Location$1 server_types: { supported: number[] available: number[] available_for_migration: number[] } } interface DatacentersResponse { datacenters: Datacenter$2[] recommendation: number meta: Meta } type SortableLocationField = "id" | "id:asc" | "id:desc" | "name" | "name:asc" | "name:desc"; interface ListLocationsParams { name?: string; sort?: SortableLocationField; page?: number; per_page?: number; } /** * Locations API * * Datacenters are organized by Locations. Datacenters in the same Location are connected with very low latency links. * https://docs.hetzner.cloud/#locations * */ declare class Locations extends BaseAPI { /** * List all locations with optional filtering and pagination * @param params Optional parameters for filtering and pagination */ getAll(params?: ListLocationsParams): Promise<{ success: true; response: LocationsResponse; } | { success: false; response: APIError; }>; /** * Get a specific location by ID * @param id The location ID */ get(id: number): Promise<{ success: true; response: Location$1; } | { success: false; response: APIError; }>; } declare class Datacenters extends BaseAPI { /** * List all datacenters with optional filtering and pagination * @param params Optional parameters for filtering and pagination */ getAll(params?: ListLocationsParams): Promise<{ success: true; response: DatacentersResponse; } | { success: false; response: APIError; }>; /** * Get a specific datacenter by ID * @param id The datacenter ID */ get(id: number): Promise<{ success: true; response: Datacenter$2; } | { success: false; response: APIError; }>; } interface NetworkSubnet { type: "cloud" | "vswitch" | "server"; ip_range: string; network_zone: string; gateway: string; vswitch_id?: number | null; } interface NetworkRoute { destination: string; gateway: string; } interface NetworkProtection { delete: boolean; } interface Network { id: number; name: string; ip_range: string; subnets: NetworkSubnet[]; network_zone: string; routes: NetworkRoute[]; servers: number[]; load_balancers: number[]; protection: NetworkProtection; labels: Record<string, string>; created: string; expose_routes_to_vswitch?: boolean; } interface NetworksResponse { networks: Network[]; meta?: Meta; } interface ListNetworksParams { name?: string; label_selector?: string; sort?: "id" | "id:asc" | "id:desc" | "name" | "name:asc" | "name:desc" | "created" | "created:asc" | "created:desc"; page?: number; per_page?: number; } interface CreateNetworkParams { name: string; ip_range: string; labels?: Record<string, string>; subnets?: NetworkSubnet[]; routes?: NetworkRoute[]; expose_routes_to_vswitch?: boolean; } interface UpdateNetworkParams { name?: string; labels?: Record<string, string>; expose_routes_to_vswitch?: boolean; } interface NetworkActionsResponse { actions: BaseAction[]; meta?: Meta; } interface ListNetworkActionsParams { id?: number; sort?: "id" | "command" | "status" | "progress" | "started" | "finished" | "id:asc" | "id:desc"; status?: "running" | "success" | "error"; page?: number; per_page?: number; } interface AddRouteNetworkParams { destination: string; gateway: string; } interface DeleteRouteNetworkParams { destination: string; gateway: string; } interface AddSubnetNetworkParams { type: "cloud" | "vswitch" | "server"; ip_range?: string; network_zone: string; vswitch_id?: number; } interface DeleteSubnetNetworkParams { ip_range: string; } interface ChangeIPRangeNetworkParams { ip_range: string; } interface ChangeProtectionNetworkParams { delete: boolean; } /** * Network Actions API * * Network actions are used to manage networks. * https://docs.hetzner.cloud/#networks-actions * */ declare class NetworkActions extends BaseAPI { /** * List all actions for Networks * @param params Optional parameters for filtering and pagination */ getAll(params?: ListNetworkActionsParams): Promise<{ success: true; response: NetworkActionsResponse; } | { success: false; response: APIError; }>; /** * Get a specific action for Networks * @param actionId The action ID */ get(actionId: number): Promise<{ success: true; response: { actions: BaseAction; }; } | { success: false; response: APIError; }>; /** * List actions for a specific Network * @param networkId The Network ID * @param params Optional parameters for filtering and pagination */ listForNetwork(networkId: number, params?: ListNetworkActionsParams): Promise<{ success: true; response: NetworkActionsResponse; } | { success: false; response: APIError; }>; /** * Get a specific action for a specific Network * @param networkId The Network ID * @param actionId The action ID */ getForNetwork(networkId: number, actionId: number): Promise<{ success: true; response: { actions: BaseAction; }; } | { success: false; response: APIError; }>; /** * Add a route to a Network * @param networkId The Network ID * @param params Parameters for adding the route */ addRoute(networkId: number, params: AddRouteNetworkParams): Promise<{ success: true; response: { actions: BaseAction; }; } | { success: false; response: APIError; }>; /** * Delete a route from a Network * @param networkId The Network ID * @param params Parameters for deleting the route */ deleteRoute(networkId: number, params: DeleteRouteNetworkParams): Promise<{ success: true; response: { actions: BaseAction; }; } | { success: false; response: APIError; }>; /** * Add a subnet to a Network * @param networkId The Network ID * @param params Parameters for adding the subnet */ addSubnet(networkId: number, params: AddSubnetNetworkParams): Promise<{ success: true; response: { actions: BaseAction; }; } | { success: false; response: APIError; }>; /** * Delete a subnet from a Network * @param networkId The Network ID * @param params Parameters for deleting the subnet */ deleteSubnet(networkId: number, params: DeleteSubnetNetworkParams): Promise<{ success: true; response: { actions: BaseAction; }; } | { success: false; response: APIError; }>; /** * Change the IP range of a Network * @param networkId The Network ID * @param params Parameters for changing the IP range */ changeIPRange(networkId: number, params: ChangeIPRangeNetworkParams): Promise<{ success: true; response: { actions: BaseAction; }; } | { success: false; response: APIError; }>; /** * Change the protection status of a Network * @param networkId The Network ID * @param params Parameters for changing the protection status */ changeProtection(networkId: number, params: ChangeProtectionNetworkParams): Promise<{ success: true; response: { actions: BaseAction; }; } | { success: false; response: APIError; }>; } /** * Networks API * * Networks is a private networks feature. These Networks are optional and they coexist with the public network that every Server has by default. * https://docs.hetzner.cloud/#networks * */ declare class Networks extends BaseAPI { private _actions; /** * List all Networks with optional filtering and pagination * @param params Optional parameters for filtering and pagination */ getAll(params?: ListNetworksParams): Promise<{ success: true; response: NetworksResponse; } | { success: false; response: APIError; }>; /** * Create a new Network * @param params Parameters for creating the Network */ create(params: CreateNetworkParams): Promise<{ success: true; response: { network: Network; }; } | { success: false; response: APIError; }>; /** * Get a specific Network by ID * @param id The Network ID */ get(id: number): Promise<{ success: true; response: { network: Network; }; } | { success: false; response: APIError; }>; /** * Update a Network's properties * @param id The Network ID * @param params Parameters to update */ update(id: number, params: UpdateNetworkParams): Promise<{ success: true; response: { network: Network; }; } | { success: false; response: APIError; }>; /** * Delete a Network * @param id The Network ID */ delete(id: number): Promise<{ success: true; response: null; } | { success: false; response: APIError; }>; get actions(): NetworkActions; } interface SSHKey { id: number; name: string; fingerprint: string; public_key: string; labels: Record<string, string>; created: string; } interface SSHKeysResponse { ssh_keys: SSHKey[]; meta?: Meta; } interface CreateSSHKeyParams { name: string; public_key: string; labels?: Record<string, string>; } interface UpdateSSHKeyParams { name?: string; labels?: Record<string, string>; } interface Certificate { id: number; name: string; certificate: string; created: string; domain_names: string[]; fingerprint: string; labels: Record<string, string>; not_valid_after: string; not_valid_before: string; status: CertificateStatus; type: CertificateType; } type CertificateStatus = "pending" | "failed" | "completed"; type CertificateType = "uploaded" | "managed"; interface CertificatesResponse { certificates: Certificate[]; meta?: { pagination?: { page: number; per_page: number; total_entries: number; last_page: number; }; }; } interface CreateCertificateParams { name: string; certificate: string; private_key: string; labels?: Record<string, string>; } interface UpdateCertificateParams { name?: string; labels?: Record<string, string>; } interface CertificateAction { id: number; command: string; status: "running" | "success" | "error"; progress: number; started: string; finished: string | null; resources: Array<{ id: number; type: string; }>; error?: { code: string; message: string; }; } interface CertificateActionsResponse { actions: CertificateAction[]; meta?: Meta; } interface CertificateActionResponse { action: CertificateAction; } interface ListCertificateActionsParams { id?: number[]; sort?: Array<"id" | "command" | "status" | "started" | "finished" | "id:asc" | "id:desc" | "command:asc" | "command:desc" | "status:asc" | "status:desc" | "started:asc" | "started:desc" | "finished:asc" | "finished:desc">; status?: Array<"running" | "success" | "error">; page?: number; per_page?: number; } /** * Certificate Actions API * * Actions are the individual operations that can be performed on a certificate. * https://docs.hetzner.cloud/#certificate-actions * */ declare class CertificateActions extends BaseAPI { /** * Get all actions for all certificates * @param params Optional parameters for filtering and pagination */ getAll(params?: ListCertificateActionsParams): Promise<{ success: true; response: CertificateActionsResponse; } | { success: false; response: APIError; }>; /** * Get a specific action * @param actionId The action ID */ get(actionId: number): Promise<{ success: true; response: CertificateActionResponse; } | { success: false; response: APIError; }>; /** * Get all actions for a specific certificate * @param certificateId The certificate ID * @param params Optional parameters for filtering and pagination */ listForCertificate(certificateId: number, params?: Omit<ListCertificateActionsParams, "id">): Promise<{ success: true; response: CertificateActionsResponse; } | { success: false; response: APIError; }>; /** * Get a specific action for a certificate * @param certificateId The certificate ID * @param actionId The action ID */ getForCertificate(certificateId: number, actionId: number): Promise<{ success: true; response: CertificateActionResponse; } | { success: false; response: APIError; }>; /** * Retry issuance or renewal of a certificate * @param certificateId The certificate ID */ retry(certificateId: number): Promise<{ success: true; response: CertificateActionResponse; } | { success: false; response: APIError; }>; } interface ListCertificatesParams { name?: string; label_selector?: string; sort?: "id" | "id:asc" | "id:desc" | "name" | "name:asc" | "name:desc"; page?: number; per_page?: number; } declare class Certificates extends BaseAPI { private _actions; /** * List all certificates with optional filtering and pagination * @param params Optional parameters for filtering and pagination */ getAll(params?: ListCertificatesParams): Promise<{ success: true; response: CertificatesResponse; } | { success: false; response: APIError; }>; /** * Get a specific certificate by ID * @param id The certificate ID */ get(id: number): Promise<{ success: true; response: Certificate; } | { success: false; response: APIError; }>; /** * Create a new certificate * @param params Parameters for creating the certificate */ create(params: CreateCertificateParams): Promise<{ success: true; response: Certificate; } | { success: false; response: APIError; }>; /** * Update a certificate's properties * @param id The certificate ID * @param params Parameters to update */ update(id: number, params: UpdateCertificateParams): Promise<{ success: true; response: Certificate; } | { success: false; response: APIError; }>; /** * Delete a certificate * @param id The certificate ID */ delete(id: number): Promise<{ success: true; response: null; } | { success: false; response: APIError; }>; get actions(): CertificateActions; } interface ListSSHKeysParams { name?: string; fingerprint?: string; label_selector?: string; sort?: "id" | "id:asc" | "id:desc" | "name" | "name:asc" | "name:desc"; page?: number; per_page?: number; } /** * SSH Keys API * * SSH keys are used to authenticate with the server. * https://docs.hetzner.cloud/#ssh-keys * */ declare class SSHKeys extends BaseAPI { /** * List all SSH keys with optional filtering and pagination * @param params Optional parameters for filtering and pagination */ getAll(params?: ListSSHKeysParams): Promise<{ success: true; response: SSHKeysResponse; } | { success: false; response: APIError; }>; /** * Get a specific SSH key by ID * @param id The SSH key ID */ get(id: number): Promise<{ success: true; response: { ssh_key: SSHKey; }; } | { success: false; response: APIError; }>; /** * Create a new SSH key * @param params Parameters for creating the SSH key */ create(params: CreateSSHKeyParams): Promise<{ success: true; response: { ssh_key: SSHKey; }; } | { success: false; response: APIError; }>; /** * Update an SSH key's properties * @param id The SSH key ID * @param params Parameters to update */ update(id: number, params: UpdateSSHKeyParams): Promise<{ success: true; response: { ssh_key: SSHKey; }; } | { success: false; response: APIError; }>; /** * Delete an SSH key * @param id The SSH key ID */ delete(id: number): Promise<{ success: true; response: null; } | { success: false; response: APIError; }>; } interface VolumeLocation { id: number; name: string; description: string; country: string; city: string; latitude: number; longitude: number; network_zone: string; } interface VolumeProtection { delete: boolean; } interface VolumeStatus { value: "available" | "creating"; } interface Volume { id: number; created: string; name: string; server: number | null; location: VolumeLocation; size: number; linux_device: string; protection: VolumeProtection; labels: Record<string, string>; status: VolumeStatus["value"]; format?: string; } interface VolumesResponse { volumes: Volume[]; meta?: Meta; } interface ListVolumesParams { name?: string; label_selector?: string; sort?: "id" | "id:asc" | "id:desc" | "name" | "name:asc" | "name:desc" | "created" | "created:asc" | "created:desc"; page?: number; per_page?: number; status?: VolumeStatus["value"][]; } interface CreateVolumeParams { name: string; size: number; location?: string; server?: number; format?: string; labels?: Record<string, string>; automount?: boolean; } interface UpdateVolumeParams { name?: string; labels?: Record<string, string>; } interface AttachVolumeParams { server: number; automount?: boolean; } interface ResizeVolumeParams { size: number; } interface ChangeVolumeProtectionParams { delete: boolean; } interface VolumeActionsResponse { actions: BaseAction[]; meta?: Meta; } interface ListVolumeActionsParams { sort?: "id" | "id:asc" | "id:desc" | "command" | "command:asc" | "command:desc" | "status" | "status:asc" | "status:desc" | "progress" | "progress:asc" | "progress:desc" | "started" | "started:asc" | "started:desc" | "finished" | "finished:asc" | "finished:desc"; status?: "available" | "creating"; name?: string; label_selector?: string; page?: number; per_page?: number; } declare class VolumeActions extends BaseAPI { /** * List all actions for Volumes (globally, not for a specific volume) * @param params Optional parameters for filtering and pagination */ getAll(params?: ListVolumeActionsParams): Promise<{ success: true; response: VolumeActionsResponse; } | { success: false; response: APIError; }>; /** * Get a specific action for Volumes (globally) * @param actionId The action ID */ getGlobalAction(actionId: number): Promise<{ success: true; response: { action: BaseAction; }; } | { success: false; response: APIError; }>; /** * List actions for a specific Volume * @param volumeId The Volume ID * @param params Optional parameters for filtering and pagination */ listForVolume(volumeId: number, params?: ListVolumeActionsParams): Promise<{ success: true; response: VolumeActionsResponse; } | { success: false; response: APIError; }>; /** * Get a specific action for a specific Volume * @param volumeId The Volume ID * @param actionId The action ID */ getAction(volumeId: number, actionId: number): Promise<{ success: true; response: { action: BaseAction; }; } | { success: false; response: APIError; }>; /** * Attach a Volume to a Server * @param volumeId The Volume ID * @param params Parameters for attaching the volume */ attach(volumeId: number, params: AttachVolumeParams): Promise<{ success: true; response: { action: BaseAction; }; } | { success: false; response: APIError; }>; /** * Detach a Volume from a Server * @param volumeId The Volume ID */ detach(volumeId: number): Promise<{ success: true; response: { action: BaseAction; }; } | { success: false; response: APIError; }>; /** * Resize a Volume * @param volumeId The Volume ID * @param params Parameters for resizing the volume */ resize(volumeId: number, params: ResizeVolumeParams): Promise<{ success: true; response: { action: BaseAction; }; } | { success: false; response: APIError; }>; /** * Change Volume Protection * @param volumeId The Volume ID * @param params Parameters for changing the protection status */ changeProtection(volumeId: number, params: ChangeVolumeProtectionParams): Promise<{ success: true; response: { action: BaseAction; }; } | { success: false; response: APIError; }>; } /** * Volumes API * * Volumes can be used to store data on a server. * https://docs.hetzner.cloud/#volumes * */ declare class Volumes extends BaseAPI { private _actions; /** * List all Volumes with optional filtering and pagination * @param params Optional parameters for filtering and pagination */ getAll(params?: ListVolumesParams): Promise<{ success: true; response: VolumesResponse; } | { success: false; response: APIError; }>; /** * Get a specific Volume by ID * @param id The Volume ID */ get(id: number): Promise<{ success: true; response: { volume: Volume; }; } | { success: false; response: APIError; }>; /** * Create a new Volume * @param params Parameters for creating the Volume */ create(params: CreateVolumeParams): Promise<{ success: true; response: { volume: Volume; action?: BaseAction; }; } | { success: false; response: APIError; }>; /** * Update a Volume's properties * @param id The Volume ID * @param params Parameters to update */ update(id: number, params: UpdateVolumeParams): Promise<{ success: true; response: { volume: Volume; }; } | { success: false; response: APIError; }>; /** * Delete a Volume * @param id The Volume ID */ delete(id: number): Promise<{ success: true; response: null; } | { success: false; response: APIError; }>; get actions(): VolumeActions; } interface LoadBalancerLocation { id: number; name: string; description: string; country: string; city: string; latitude: number; longitude: number; network_zone: string; } interface LoadBalancerProtection { delete: boolean; } interface LoadBalancerIPDetail { ip: string; dns_ptr?: string | null; } interface LoadBalancerPublicNet { enabled: boolean; ipv4: LoadBalancerIPDetail; ipv6: LoadBalancerIPDetail; } interface LoadBalancerPrivateNet { network: number; ip: string; } interface LoadBalancerAlgorithm { type: "round_robin" | "least_connections"; } interface LoadBalancerHealthCheckHTTPConfig { domain: string | null; path: string; response: string | null; status_codes: string[]; tls: boolean; } interface LoadBalancerHealthCheck { protocol: "tcp" | "http" | "https"; port: number; interval: number; timeout: number; retries: number; http: LoadBalancerHealthCheckHTTPConfig | null; } interface LoadBalancerServiceHTTPConfig { cookie_name: string | null; cookie_lifetime: number | null; certificates: number[]; redirect_http: boolean | null; sticky_sessions: boolean | null; } interface LoadBalancerService { protocol: "tcp" | "http" | "https"; listen_port: number; destination_port: number; proxyprotocol: boolean; health_check: LoadBalancerHealthCheck; http: LoadBalancerServiceHTTPConfig | null; } interface LoadBalancerTargetServer { id: number; } interface LoadBalancerTargetLabelSelector { selector: string; } interface LoadBalancerTargetIP { ip: string; } interface LoadBalancerTargetHealthStatusEntry { listen_port: number; status: "healthy" | "unhealthy" | "unknown"; } interface LoadBalancerResolvedTarget { type: "server"; server: LoadBalancerTargetServer; health_status: LoadBalancerTargetHealthStatusEntry[] | null; use_private_ip: boolean; } interface LoadBalancerTarget { type: "server" | "label_selector" | "ip"; server?: LoadBalancerTargetServer; label_selector?: LoadBalancerTargetLabelSelector; ip?: LoadBalancerTargetIP; health_status?: LoadBalancerTargetHealthStatusEntry[] | null; use_private_ip: boolean; targets?: LoadBalancerResolvedTarget[]; } interface LoadBalancer { id: number; name: string; public_net: LoadBalancerPublicNet; private_net: LoadBalancerPrivateNet[]; location: LoadBalancerLocation; load_balancer_type: LoadBalancerType; protection: LoadBalancerProtection; labels: Record<string, string>; created: string; services: LoadBalancerService[]; targets: LoadBalancerTarget[]; algorithm: LoadBalancerAlgorithm; outgoing_traffic: number | null; ingoing_traffic: number | null; included_traffic: number; } interface LoadBalancersResponse { load_balancers: LoadBalancer[]; meta?: Meta; } interface ListLoadBalancersParams { name?: string; label_selector?: string; sort?: string; page?: number; per_page?: number; } interface CreateLoadBalancerParams { name: string; load_balancer_type: string | number; algorithm?: LoadBalancerAlgorithm; services?: LoadBalancerService[]; targets?: LoadBalancerTarget[]; labels?: Record<string, string>; public_interface?: boolean; network?: number; network_zone?: string; location?: string | number; } interface UpdateLoadBalancerParams { name?: string; labels?: Record<string, string>; } interface LoadBalancerTimeSeries { [metric_name: string]: { values: Array<[number, string]>; }; } interface LoadBalancerMetricsResponse { metrics: { start: string; end: string; step: number; time_series: LoadBalancerTimeSeries; }; } interface GetLoadBalancerMetricsParams { type: string; start: string; end: string; step?: string; } interface LoadBalancerAction extends BaseAction { } interface LoadBalancerActionsResponse { actions: LoadBalancerAction[]; meta?: Meta; } interface ListLoadBalancerActionsParams { id?: number[]; sort?: string; status?: ("running" | "success" | "error")[]; page?: number; per_page?: number; } interface AddServiceLoadBalancerParams extends LoadBalancerService { } interface UpdateServiceLoadBalancerParams { listen_port: number; protocol?: "tcp" | "http" | "https"; destination_port?: number; proxyprotocol?: boolean; health_check?: LoadBalancerHealthCheck; http?: LoadBalancerServiceHTTPConfig | null; } interface DeleteServiceLoadBalancerParams { listen_port: number; } interface AddTargetLoadBalancerParams { type: "server" | "label_selector" | "ip"; server?: LoadBalancerTargetServer; use_private_ip?: boolean; label_selector?: LoadBalancerTargetLabelSelector; ip?: LoadBalancerTargetIP; } interface RemoveTargetLoadBalancerParams extends AddTargetLoadBalancerParams { } interface AttachToNetworkLoadBalancerParams { network: number; ip?: string; } interface DetachFromNetworkLoadBalancerParams { network: number; } interface ChangeAlgorithmLoadBalancerParams { type: "round_robin" | "least_connections"; } interface ChangeDNSPTRLoadBalancerParams { ip: string; dns_ptr: string | null; } interface ChangeProtectionLoadBalancerParams { delete?: boolean; } interface ChangeTypeLoadBalancerParams { load_balancer_type: string | number; } interface ListLoadBalancerTypesParams { name?: string; page?: number; per_page?: number; } interface LoadBalancerResponse { load_balancer: LoadBalancer; } interface LoadBalancerActionResponse { action: LoadBalancerAction; } interface CreateLoadBalancerResponse { load_balancer: LoadBalancer; action: LoadBalancerAction; } interface LoadBalancerType { id: number; name: string; description: string; max_connections: number; max_services: number; max_targets: number; max_assigned_certificates: number; deprecated: string; prices: { location: string; price_hourly: { net: string; gross: string; }; price_monthly: { net: string; gross: string; }; included_traffic: number; price_per_tb_traffic: { net: string; gross: string; }; }[]; } interface LoadBalancerTypesResponse { load_balancer_types: LoadBalancerType[]; meta?: Meta; } /** * Load Balancer Actions API * * Load balancer actions are used to manage load balancers. * https://docs.hetzner.cloud/#load-balancers-actions * */ declare class LoadBalancerActions extends BaseAPI { /** * List all global actions for Load Balancers * @param params Optional parameters for filtering and pagination */ getAllGlobal(params?: ListLoadBalancerActionsParams): Promise<{ success: true; response: LoadBalancerActionsResponse; } | { success: false; response: APIError; }>; /** * Get a specific global action for Load Balancers * @param actionId The action ID */ getGlobalAction(actionId: number): Promise<{ success: true; response: LoadBalancerActionResponse; } | { success: false; response: APIError; }>; /** * List actions for a specific Load Balancer * @param loadBalancerId The Load Balancer ID * @param params Optional parameters for filtering and pagination */ listForLoadBalancer(loadBalancerId: number, params?: ListLoadBalancerActionsParams): Promise<{ success: true; response: LoadBalancerActionsResponse; } | { success: false; response: APIError; }>; /** * Get a specific action for a specific Load Balancer * @param loadBalancerId The Load Balancer ID * @param actionId The action ID */ getAction(loadBalancerId: number, actionId: number): Promise<{ success: true; response: LoadBalancerActionResponse; } | { success: false; response: APIError; }>; addService(loadBalancerId: number, params: AddServiceLoadBalancerParams): Promise<{ success: true; response: LoadBalancerActionResponse; } | { success: false; response: APIError; }>; updateService(loadBalancerId: number, params: UpdateServiceLoadBalancerParams): Promise<{ success: true; response: LoadBalancerActionResponse; } | { success: false; response: APIError; }>; deleteService(loadBalancerId: number, params: DeleteServiceLoadBalancerParams): Promise<{ success: true; response: LoadBalancerActionResponse; } | { success: false; response: APIError; }>; addTarget(loadBalancerId: number, params: AddTargetLoadBalancerParams): Promise<{ success: true; response: LoadBalancerActionResponse; } | { success: false; response: APIError; }>; removeTarget(loadBalancerId: number, params: RemoveTargetLoadBalancerParams): Promise<{ success: true; response: LoadBalancerActionResponse; } | { success: false; response: APIError; }>; attachToNetwork(loadBalancerId: number, params: AttachToNetworkLoadBalancerParams): Promise<{ success: true; response: LoadBalancerActionResponse; } | { success: false; response: APIError; }>; detachFromNetwork(loadBalancerId: number, params: DetachFromNetworkLoadBalancerParams): Promise<{ success: true; response: LoadBalancerActionResponse; } | { success: false; response: APIError; }>; changeAlgorithm(loadBalancerId: number, params: ChangeAlgorithmLoadBalancerParams): Promise<{ success: true; response: LoadBalancerActionResponse; } | { success: false; response: APIError; }>; changeDNSPTR(loadBalancerId: number, params: ChangeDNSPTRLoadBalancerParams): Promise<{ success: true; response: LoadBalancerActionResponse; } | { success: false; response: APIError; }>; changeProtection(loadBalancerId: number, params: ChangeProtectionLoadBalancerParams): Promise<{ success: tru