Package cloud.dnation.hetznerclient
Class PagedResourceHelper
java.lang.Object
cloud.dnation.hetznerclient.PagedResourceHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends IdentifiableResource,X extends AbstractSearchResponse>
List<T>fetchItems(String labelSelector, BiFunction<Integer, String, retrofit2.Call<X>> pageSupplier, Function<X, List<T>> itemsGetter) Consume all items from paginated REST endpoint.static List<PrimaryIpDetail>getAllPrimaryIps(HetznerApi api, String labelSelector) static List<ServerDetail>getAllServers(HetznerApi api, String labelSelector)
-
Constructor Details
-
PagedResourceHelper
public PagedResourceHelper()
-
-
Method Details
-
fetchItems
public static <T extends IdentifiableResource,X extends AbstractSearchResponse> List<T> fetchItems(String labelSelector, BiFunction<Integer, String, throws IOExceptionretrofit2.Call<X>> pageSupplier, Function<X, List<T>> itemsGetter) Consume all items from paginated REST endpoint.- Type Parameters:
T- item typeX- REST endpoint response type- Parameters:
labelSelector- label selector to restrict items only to those that match selectorpageSupplier-BiFunctionthat takes page index (zero based) and selector and producesResponseitemsGetter-Functionthat takes response from pageSupplier and extracts list of items- Returns:
- all items combined to single list
- Throws:
IOException
-
getAllPrimaryIps
public static List<PrimaryIpDetail> getAllPrimaryIps(HetznerApi api, String labelSelector) throws IOException - Throws:
IOException
-
getAllServers
public static List<ServerDetail> getAllServers(HetznerApi api, String labelSelector) throws IOException - Throws:
IOException
-