Class BitbucketRequestExecutor

java.lang.Object
com.atlassian.bitbucket.jenkins.internal.client.BitbucketRequestExecutor

public class BitbucketRequestExecutor extends Object
  • Constructor Details

  • Method Details

    • getBaseUrl

      public okhttp3.HttpUrl getBaseUrl()
      Returns the root URL of Bitbucket server.
      Returns:
      the base url
    • getCoreRestPath

      public okhttp3.HttpUrl getCoreRestPath()
      Provide the base Rest path
      Returns:
      HttpUrl of the core rest path;
    • makeDeleteRequest

      public void makeDeleteRequest(okhttp3.HttpUrl url)
      Make a DELETE request to given URL.
      Parameters:
      url - , the delete URL
    • makeGetRequest

      public <T> BitbucketResponse<T> makeGetRequest(okhttp3.HttpUrl url, com.fasterxml.jackson.core.type.TypeReference<T> returnType, RequestConfiguration... additionalConfig)
      Make a GET request to the url given. This method will add authentication headers as needed. If the requested resource is paged, or the return type is generified use this method, otherwise the makeGetRequest(HttpUrl, Class, RequestConfiguration...) is most likely a better choice.
      Type Parameters:
      T - type to return
      Parameters:
      url - url to connect to
      returnType - type reference used when getting generified objects (such as pages)
      Returns:
      a deserialized object of type T
      See Also:
    • makeGetRequest

      public <T> BitbucketResponse<T> makeGetRequest(okhttp3.HttpUrl url, Class<T> returnType, RequestConfiguration... additionalConfig)
      Make a GET request to the url given. This method will add authentication headers as needed. Note! this method cannot be used to retrieve entities that makes use of generics (such as BitbucketPage) for that use makeGetRequest(HttpUrl, TypeReference, RequestConfiguration...) instead.
      Type Parameters:
      T - type to return
      Parameters:
      url - url to connect to
      returnType - class of the desired return type. Do note that if the type is generified this method will not work
      Returns:
      a deserialized object of type T
      See Also:
    • makeStreamingGetRequest

      public InputStream makeStreamingGetRequest(okhttp3.HttpUrl url)
      Make a GET request to the url given. This method will add authentication headers as needed.
      Parameters:
      url - url to connect to
      Returns:
      a serialised input stream of bytes.
    • makePostRequest

      public <T, R> BitbucketResponse<R> makePostRequest(okhttp3.HttpUrl url, T requestPayload, Class<R> returnType, RequestConfiguration... additionalConfig)
      Makes a POST request to the given URL with given request payload.
      Type Parameters:
      T - type of Request payload
      R - return type
      Parameters:
      url - the URL to make the request to
      requestPayload - , JSON payload which will be marshalled to send it with POST
      returnType - , class of expected return type
      Returns:
      the result
    • makePostRequest

      public <T> void makePostRequest(okhttp3.HttpUrl url, T requestPayload, RequestConfiguration... additionalConfig)
      Makes a POST request to the given URL with given request payload.
      Type Parameters:
      T - Type of Request payload
      Parameters:
      url - the URL to make the request to
      requestPayload - JSON payload which will be marshalled to send it with POST
    • makePutRequest

      public <T, R> BitbucketResponse<R> makePutRequest(okhttp3.HttpUrl url, T requestPayload, Class<R> returnType, RequestConfiguration... additionalConfig)
      Makes a PUT request to the the given URL with given request payload
      Type Parameters:
      T - Type of result
      R - Type of return
      Parameters:
      url - the URL to make the request to
      requestPayload - JSON payload which will be marshalled to send it with PUT
      returnType - , Class of expected return type
      Returns:
      the result