Interface HetznerApi


public interface HetznerApi
Trimmed-down version of Hetzner public cloud API. For full version, check official documentation
  • Method Details

    • 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 ImageDetail wrapped in GetImagesBySelectorResponse
    • getImageById

      @GET("/v1/images/{id}") retrofit2.Call<GetImageByIdResponse> getImageById(@Path("id") Long id)
      Get single image by providing image ID.
      Parameters:
      id - image ID to get
      Returns:
      ImageDetail object wrapped in GetImageByIdResponse
      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 DatacenterDetail wrapped in GetDatacentersResponse.
    • getAllDatacenters

      @GET("/v1/datacenters") retrofit2.Call<GetDatacentersResponse> getAllDatacenters()
      Get all datacenters.
      Returns:
      list of datacenters in form of DatacenterDetail wrapped in GetDatacentersResponse.
    • 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 LocationDetail wrapped in GetLocationsResponse.
    • 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 ServerType wrapped in GetServerTypesResponse.
    • deleteServer

      @DELETE("/v1/servers/{id}") retrofit2.Call<ActionResponse> deleteServer(@Path("id") long id)
      Delete sever instance.
      Parameters:
      id - ID of server to delete
      Returns:
      ActionResponse inner object ActionDetail can be used to get result of action.
    • getServer

      @GET("/v1/servers/{id}") retrofit2.Call<GetServerByIdResponse> getServer(@Path("id") long id)
      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:
      ActionResponse inner object ActionDetail can 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 objects ServerDetail and ActionDetail can 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:
      CreateSshKeyResponse with details
    • deleteSshKey

      @DELETE("/v1/ssh_keys/{id}") retrofit2.Call<ErrorDetail> deleteSshKey(@Path("id") long id)
      Delete existing SSH key.
      Parameters:
      id - ID of SSH key to delete
      Returns:
      ErrorDetail in 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 servers
      page - page index
      perPage - 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 networks
      page - page index
      perPage - 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 index
      perPage - 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("/v1/volumes/{id}") retrofit2.Call<GetVolumeByIdResponse> getVolumeById(@Path("id") long id)
      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 index
      perPage - 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.