Interface HetznerApi


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

      • 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.
      • 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.
      • 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
      • 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
      • 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
      • 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