Package cloud.dnation.hetznerclient
Interface HetznerApi
public interface HetznerApi
Trimmed-down version of Hetzner public cloud API.
For full version, check official documentation
-
Method Summary
Modifier and TypeMethodDescriptionretrofit2.Call<CreateServerResponse>createServer(CreateServerRequest request) Create new server instance.retrofit2.Call<CreateSshKeyResponse>createSshKey(CreateSshKeyRequest request) Create new SSH key.retrofit2.Call<ActionResponse>deleteServer(long id) Delete sever instance.retrofit2.Call<ErrorDetail>deleteSshKey(long id) Delete existing SSH key.retrofit2.Call<ActionResponse>getActionById(Long actionId) Get/poll the status of an asynchronous API on the Hetzner Cloud.retrofit2.Call<GetDatacentersResponse>Get all datacenters.retrofit2.Call<GetDatacentersResponse>Get datacenters matching provided string.retrofit2.Call<GetLocationsResponse>Get locations matching provided string.retrofit2.Call<GetAllPrimaryIpsResponse>getAllPrimaryIps(String selector) Get all Primary IP objects.retrofit2.Call<GetServerTypesResponse>Get server types whose name is matching provided string.retrofit2.Call<GetFirewallByIdResponse>getFirewallById(long id) Get single firewall by ID.retrofit2.Call<GetFirewallsBySelectorResponse>getFirewallsBySelector(String selector) Get all firewalls matching given label selector.retrofit2.Call<GetImageByIdResponse>getImageById(Long id) Get single image by providing image ID.retrofit2.Call<GetImagesBySelectorResponse>getImagesBySelector(String selector) Get all images that matches given label expression.retrofit2.Call<GetNetworkByIdResponse>getNetworkById(long id) Get network detail based on provided network ID.retrofit2.Call<GetNetworksBySelectorResponse>getNetworkBySelector(String selector) Get all networks matching given label selector.retrofit2.Call<GetNetworksBySelectorResponse>getNetworksBySelector(String selector, int page, int perPage) Get all networks matching given label selector.retrofit2.Call<GetPlacementGroupByIdResponse>getPlacementGroupById(long id) Get placement group detail based on provided placement group ID.retrofit2.Call<GetPlacementGroupsResponse>getPlacementGroups(String selector) Get placement groups, optionally filtered using label expression.retrofit2.Call<GetAllPrimaryIpsResponse>getPrimaryIpsBySelector(String selector, int page, int perPage) Get all Primary IP objects matching given selector.retrofit2.Call<GetActionsResponse>getResourceActions(String resource, List<Long> ids, int page, int perPage) Get actions for given resource type (servers/networks/load_balancers/floating_ips/firewalls/volumes).retrofit2.Call<GetServerByIdResponse>getServer(long id) Get server detail for given ID.retrofit2.Call<GetServersBySelectorResponse>getServersBySelector(String selector, int page, int perPage) Get all server matching given label selector.retrofit2.Call<GetSshKeysBySelectorResponse>getSshKeysBySelector(String selector) Find SSH keys matching given label selectorretrofit2.Call<GetVolumeByIdResponse>getVolumeById(long id) Get volume detail based on ID.retrofit2.Call<GetVolumesResponse>getVolumes(String selector) Get all volumes.retrofit2.Call<GetVolumesResponse>getVolumes(String selector, int page, int perPage) Get all volumes.retrofit2.Call<ActionResponse>powerOffServer(long id) Power-off server instance.
-
Method Details
-
getActionById
Get/poll the status of an asynchronous API on the Hetzner Cloud.Normally, the rate limit of this API is higher and separate from the other API calls, as it is preferred to poll the /actions endpoint to wait for an asynchronous action to complete.
- Parameters:
actionId- the ID of the action whose status you want to poll- Returns:
- the full Action object, including its current status
-
getImagesBySelector
@GET("/v1/images?type=snapshot&status=available") retrofit2.Call<GetImagesBySelectorResponse> getImagesBySelector(@Query("label_selector") String selector) Get all images that matches given label expression.- Parameters:
selector- label expression to match- Returns:
- list of
ImageDetailwrapped inGetImagesBySelectorResponse
-
getImageById
Get single image by providing image ID.- Parameters:
id- image ID to get- Returns:
ImageDetailobject wrapped inGetImageByIdResponse- See Also:
-
getAllDatacentersWithName
@GET("/v1/datacenters") retrofit2.Call<GetDatacentersResponse> getAllDatacentersWithName(@Query("name") String name) Get datacenters matching provided string.- Parameters:
name- name of datacenter to match against- Returns:
- list of matching datacenters in form of
DatacenterDetailwrapped inGetDatacentersResponse.
-
getAllDatacenters
Get all datacenters.- Returns:
- list of datacenters in form of
DatacenterDetailwrapped inGetDatacentersResponse.
-
getAllLocationsWithName
@GET("/v1/locations") retrofit2.Call<GetLocationsResponse> getAllLocationsWithName(@Query("name") String name) Get locations matching provided string.- Parameters:
name- name of location to match against- Returns:
- list of matching locations in form of
LocationDetailwrapped inGetLocationsResponse.
-
getAllServerTypesWithName
@GET("/v1/server_types") retrofit2.Call<GetServerTypesResponse> getAllServerTypesWithName(@Query("name") String name) Get server types whose name is matching provided string.- Parameters:
name- name of server type to match against- Returns:
- list of matching server types in form of
ServerTypewrapped inGetServerTypesResponse.
-
deleteServer
Delete sever instance.- Parameters:
id- ID of server to delete- Returns:
ActionResponseinner objectActionDetailcan be used to get result of action.
-
getServer
Get server detail for given ID.- Parameters:
id- ID of server to retrieve details for- Returns:
- GetServerByIdResponse
-
powerOffServer
@POST("/v1/servers/{id}/actions/poweroff") retrofit2.Call<ActionResponse> powerOffServer(@Path("id") long id) Power-off server instance.- Parameters:
id- ID of server to power-off- Returns:
ActionResponseinner objectActionDetailcan be used to get result of action.
-
createServer
@POST("/v1/servers") retrofit2.Call<CreateServerResponse> createServer(@Body CreateServerRequest request) Create new server instance.- Parameters:
request- new server details- Returns:
CreateServerResponse. Inner objectsServerDetailandActionDetailcan be used to retrieve server details and operation result.
-
createSshKey
@POST("/v1/ssh_keys") retrofit2.Call<CreateSshKeyResponse> createSshKey(@Body CreateSshKeyRequest request) Create new SSH key.- Parameters:
request- new SSH key details- Returns:
CreateSshKeyResponsewith details
-
deleteSshKey
Delete existing SSH key.- Parameters:
id- ID of SSH key to delete- Returns:
ErrorDetailin case of error, empty response otherwise See API reference
-
getSshKeysBySelector
@GET("/v1/ssh_keys") retrofit2.Call<GetSshKeysBySelectorResponse> getSshKeysBySelector(@Query("label_selector") String selector) Find SSH keys matching given label selector- Parameters:
selector- label selector used to match keys- Returns:
- list of matched SSH keys See API reference
-
getServersBySelector
@GET("/v1/servers") retrofit2.Call<GetServersBySelectorResponse> getServersBySelector(@Query("label_selector") String selector, @Query("page") int page, @Query("per_page") int perPage) Get all server matching given label selector.- Parameters:
selector- label selector used to match serverspage- page indexperPage- number of records per page- Returns:
- paged list of servers
-
getNetworkBySelector
@GET("/v1/networks") retrofit2.Call<GetNetworksBySelectorResponse> getNetworkBySelector(@Query("label_selector") String selector) Get all networks matching given label selector.- Parameters:
selector- label selector used to match servers- Returns:
- list of networks see API reference
-
getNetworksBySelector
@GET("/v1/networks") retrofit2.Call<GetNetworksBySelectorResponse> getNetworksBySelector(@Query("label_selector") String selector, @Query("page") int page, @Query("per_page") int perPage) Get all networks matching given label selector.- Parameters:
selector- label selector used to match networkspage- page indexperPage- number of items per page. API imposes limit on top of this value.- Returns:
- list of networks see API reference
-
getNetworkById
@GET("/v1/networks/{id}") retrofit2.Call<GetNetworkByIdResponse> getNetworkById(@Path("id") long id) Get network detail based on provided network ID.- Parameters:
id- network ID- Returns:
- details of network see API reference
-
getFirewallsBySelector
@GET("/v1/firewalls") retrofit2.Call<GetFirewallsBySelectorResponse> getFirewallsBySelector(@Query("label_selector") String selector) Get all firewalls matching given label selector.- Parameters:
selector- label selector used to match firewalls- Returns:
- list of firewalls see API reference
-
getFirewallById
@GET("/v1/firewalls/{id}") retrofit2.Call<GetFirewallByIdResponse> getFirewallById(@Path("id") long id) Get single firewall by ID.- Parameters:
id- firewall ID- Returns:
- firewall detail see API reference
-
getPlacementGroups
@GET("/v1/placement_groups") retrofit2.Call<GetPlacementGroupsResponse> getPlacementGroups(@Query("label_selector") String selector) Get placement groups, optionally filtered using label expression.- Parameters:
selector- Can be used to filter resources by labels. The response will only contain resources matching the label selector.- Returns:
- returns matching placement groups. see API reference
-
getPlacementGroupById
@GET("/v1/placement_groups/{id}") retrofit2.Call<GetPlacementGroupByIdResponse> getPlacementGroupById(@Path("id") long id) Get placement group detail based on provided placement group ID.- Parameters:
id- placement group ID- Returns:
- details of placement group see API reference
-
getPrimaryIpsBySelector
@GET("/v1/primary_ips") retrofit2.Call<GetAllPrimaryIpsResponse> getPrimaryIpsBySelector(@Query("label_selector") String selector, @Query("page") int page, @Query("per_page") int perPage) Get all Primary IP objects matching given selector.- Parameters:
selector- Can be used to filter resources by labels. The response will only contain resources matching the label selector.page- page indexperPage- number of items per page. API imposes limit on top of this value.- Returns:
- returns all Primary IP objects. see API reference
-
getAllPrimaryIps
@GET("/v1/primary_ips") retrofit2.Call<GetAllPrimaryIpsResponse> getAllPrimaryIps(@Query("label_selector") String selector) Get all Primary IP objects.- Parameters:
selector- Can be used to filter resources by labels. The response will only contain resources matching the label selector.- Returns:
- returns all Primary IP objects. see API reference
-
getVolumeById
Get volume detail based on ID.- Parameters:
id- volume ID- Returns:
- volume detail see API reference
-
getVolumes
@GET("/v1/volumes") retrofit2.Call<GetVolumesResponse> getVolumes(@Query("label_selector") String selector) Get all volumes.- Parameters:
selector- Can be used to filter resources by labels. The response will only contain resources matching the label selector.- Returns:
- list of volumes see API reference
-
getVolumes
@GET("/v1/volumes") retrofit2.Call<GetVolumesResponse> getVolumes(@Query("label_selector") String selector, @Query("page") int page, @Query("per_page") int perPage) Get all volumes.- Parameters:
selector- Can be used to filter resources by labels. The response will only contain resources matching the label selector.page- page indexperPage- number of items per page. API imposes limit on top of this value.- Returns:
- list of volumes see API reference
-
getResourceActions
@GET("/v1/{resource}/actions") retrofit2.Call<GetActionsResponse> getResourceActions(@Path("resource") String resource, @Query("id") List<Long> ids, @Query("page") int page, @Query("per_page") int perPage) Get actions for given resource type (servers/networks/load_balancers/floating_ips/firewalls/volumes).- Parameters:
resource- type of resource.ids- The response will only contain actions matching the specified IDs.page- page index.perPage- number of items per page. API imposes limit on top of this value.- Returns:
- paged list of actions for given resource type.
-