Class DiscoApiClient
java.lang.Object
com.dua3.gradle.jdkprovider.disco.DiscoApiClient
DiscoAPI client to discover Disco packages.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance of DiscoApiClient with the default base URL.DiscoApiClient(String baseUrl) Constructs a new instance of DiscoApiClient with the specified base URL. -
Method Summary
Modifier and TypeMethodDescriptionfindPackage(JdkQuery jdkQuery) Finds a suitableDiscoPackagebased on the providedJdkQuery.findPackages(JdkQuery jdkQuery) Finds all suitableDiscoPackages based on the providedJdkQuery, sorted from most preferred to least preferred.getPackagesQueryUrl(JdkQuery query) Builds and returns the DiscoAPI packages query URL for the provided JDK query.
-
Constructor Details
-
DiscoApiClient
public DiscoApiClient()Constructs a new instance of DiscoApiClient with the default base URL. The default base URL points to the Disco API's package query endpoint. This constructor is designed for quick initialization using the preset configuration. -
DiscoApiClient
Constructs a new instance of DiscoApiClient with the specified base URL. The base URL is used as the root for building query URLs for the Disco API.This constructor is used in unit tests.
- Parameters:
baseUrl- the base URL to use for API queries, must not be null- Throws:
NullPointerException- if the provided base URL is null
-
-
Method Details
-
getPackagesQueryUrl
Builds and returns the DiscoAPI packages query URL for the provided JDK query.- Parameters:
query- JDK selection query- Returns:
- fully qualified packages query URI
-
findPackage
Finds a suitableDiscoPackagebased on the providedJdkQuery.This method queries the Disco API using parameters derived from the given JdkQuery to retrieve matching JDK package details. If a package compatible with the specified operating system and other criteria is found, it is returned as an
Optional. If no matching package is found or an error occurs during the API query, an emptyOptionalis returned.- Parameters:
jdkQuery- theJdkQueryinstance containing parameters used to query the Disco API. This includes fields like operating system, architecture, version preferences, and vendor specifications.- Returns:
- an
Optionalcontaining the selectedDiscoPackageif a matching package is found; otherwise, an emptyOptional.
-
findPackages
Finds all suitableDiscoPackages based on the providedJdkQuery, sorted from most preferred to least preferred.- Parameters:
jdkQuery- theJdkQueryinstance containing parameters used to query the Disco API.- Returns:
- a list of matching packages in preference order, or an empty list on query failure.
-