Class RestValueService
-
Method Summary
Modifier and TypeMethodDescriptionstatic FormValidationdoBasicValidation(String restEndpoint, com.cloudbees.plugins.credentials.common.StandardCredentials credentials, MimeType mimeType) A basic validation method usable for configuration validation.static ResultContainer<List<ValueItem>> get(String restEndpoint, com.cloudbees.plugins.credentials.common.StandardCredentials credentials, MimeType mimeType, Integer cacheTime, String valueExpression, String displayExpression, String filter, ValueOrder order) Returns aResultContainercapsuling a optional String error message and a list of parsed string values.static ResultContainer<List<ValueItem>> get(String restEndpoint, com.cloudbees.plugins.credentials.common.StandardCredentials credentials, MimeType mimeType, Integer cacheTime, String valueExpression, String displayExpression, String filter, ValueOrder order, Map<String, String> customHeaders) static ResultContainer<List<ValueItem>> get(String restEndpoint, com.cloudbees.plugins.credentials.common.StandardCredentials credentials, MimeType mimeType, Integer cacheTime, String valueExpression, String displayExpression, String filter, ValueOrder order, Map<String, String> customHeaders, Pagination pagination) Likeget(String, StandardCredentials, MimeType, Integer, String, String, String, ValueOrder), but sendscustomHeaderswith every request and, whenpaginationis set, follows the endpoint's pages.static ResultContainer<List<ValueItem>> get(String restEndpoint, com.cloudbees.plugins.credentials.common.StandardCredentials credentials, MimeType mimeType, Integer cacheTime, String valueExpression, String displayExpression, String filter, ValueOrder order, Map<String, String> customHeaders, Pagination pagination, FetchOptions options)
-
Method Details
-
get
public static ResultContainer<List<ValueItem>> get(String restEndpoint, com.cloudbees.plugins.credentials.common.StandardCredentials credentials, MimeType mimeType, Integer cacheTime, String valueExpression, String displayExpression, String filter, ValueOrder order) Returns aResultContainercapsuling a optional String error message and a list of parsed string values.This method uses its parameters to query a REST/Web endpoint to receive a
MimeTyperesponse, which then gets parsed with a supported Path expression to extract a list of string values.- Parameters:
restEndpoint- A http/https web address to the REST/Web endpointcredentials- The credentials required to access said endpointmimeType- The MIME type of the expected REST/Web responsecacheTime- Time for how long the REST response gets cached for in minutesvalueExpression- The Json-Path or xPath expression to filter the valuesdisplayExpression- The Json-Path or xPath expression to filter the display valuesfilter- additional regex filter on any parsed valuesorder- Set aValueOrderto optionally reorder the values- Returns:
- A
ResultContainerthat capsules either the desired values or a user friendly error message.
-
get
public static ResultContainer<List<ValueItem>> get(String restEndpoint, com.cloudbees.plugins.credentials.common.StandardCredentials credentials, MimeType mimeType, Integer cacheTime, String valueExpression, String displayExpression, String filter, ValueOrder order, Map<String, String> customHeaders) -
get
public static ResultContainer<List<ValueItem>> get(String restEndpoint, com.cloudbees.plugins.credentials.common.StandardCredentials credentials, MimeType mimeType, Integer cacheTime, String valueExpression, String displayExpression, String filter, ValueOrder order, Map<String, String> customHeaders, Pagination pagination) Likeget(String, StandardCredentials, MimeType, Integer, String, String, String, ValueOrder), but sendscustomHeaderswith every request and, whenpaginationis set, follows the endpoint's pages.The value and display expressions are applied to each page on its own, the entries are joined in page order, and the filter and order are applied once to the combined list. A failure on any page fails the whole fetch.
- Parameters:
customHeaders- Additional headers sent with every requestpagination- How to find the next page, ornullto send a single request- Returns:
- A
ResultContainerwith the values or a user friendly error message, and the number of pages fetched and whether the page limit was reached
-
get
public static ResultContainer<List<ValueItem>> get(String restEndpoint, com.cloudbees.plugins.credentials.common.StandardCredentials credentials, MimeType mimeType, Integer cacheTime, String valueExpression, String displayExpression, String filter, ValueOrder order, Map<String, String> customHeaders, Pagination pagination, FetchOptions options) Likeget(String, StandardCredentials, MimeType, Integer, String, String, String, ValueOrder, Map, Pagination), with explicitFetchOptions.The whole fetch, across all pages, is limited to the options' timeout. When it runs out, the entries of the pages already fetched are discarded and the error names the timeout. A forced fetch sends
Cache-Control: no-cachewith every page request, so the HTTP response cache is bypassed.- Parameters:
options- The time limit and whether the fetch is forced- Returns:
- A
ResultContainerwith the values or a user friendly error message and, for a failed fetch, the request metadata of the failure
-
doBasicValidation
public static FormValidation doBasicValidation(String restEndpoint, com.cloudbees.plugins.credentials.common.StandardCredentials credentials, MimeType mimeType) A basic validation method usable for configuration validation.Sends the same
Acceptand credential headers as a build, but no custom headers. A 401 or 403 is therefore reported as a warning pointing at Test Configuration.- Parameters:
restEndpoint- A http/https web address to the REST/Web endpointcredentials- The credentials required to access said endpointmimeType- The MIME type of the expected REST/Web response- Returns:
- A
FormValidationto be used in the Jenkins configuration UI
-