Class RestValueService

java.lang.Object
io.jenkins.plugins.restlistparam.logic.RestValueService

public class RestValueService extends Object
  • 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 a ResultContainer capsuling 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 MimeType response, 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 endpoint
      credentials - The credentials required to access said endpoint
      mimeType - The MIME type of the expected REST/Web response
      cacheTime - Time for how long the REST response gets cached for in minutes
      valueExpression - The Json-Path or xPath expression to filter the values
      displayExpression - The Json-Path or xPath expression to filter the display values
      filter - additional regex filter on any parsed values
      order - Set a ValueOrder to optionally reorder the values
      Returns:
      A ResultContainer that 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)
      Like get(String, StandardCredentials, MimeType, Integer, String, String, String, ValueOrder), but sends customHeaders with every request and, when pagination is 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 request
      pagination - How to find the next page, or null to send a single request
      Returns:
      A ResultContainer with 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)
      Like get(String, StandardCredentials, MimeType, Integer, String, String, String, ValueOrder, Map, Pagination), with explicit FetchOptions.

      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-cache with every page request, so the HTTP response cache is bypassed.

      Parameters:
      options - The time limit and whether the fetch is forced
      Returns:
      A ResultContainer with 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 Accept and 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 endpoint
      credentials - The credentials required to access said endpoint
      mimeType - The MIME type of the expected REST/Web response
      Returns:
      A FormValidation to be used in the Jenkins configuration UI