Class BitbucketRequestExecutor
- java.lang.Object
-
- com.atlassian.bitbucket.jenkins.internal.client.BitbucketRequestExecutor
-
public class BitbucketRequestExecutor extends Object
-
-
Constructor Summary
Constructors Constructor Description BitbucketRequestExecutor(String bitbucketBaseUrl, HttpRequestExecutor httpRequestExecutor, com.fasterxml.jackson.databind.ObjectMapper objectMapper, BitbucketCredentials credentials)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description okhttp3.HttpUrl
getBaseUrl()
Returns the root URL of Bitbucket server.okhttp3.HttpUrl
getCoreRestPath()
Provide the base Rest pathvoid
makeDeleteRequest(okhttp3.HttpUrl url)
Make a DELETE request to given URL.<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.<T> BitbucketResponse<T>
makeGetRequest(okhttp3.HttpUrl url, Class<T> returnType, RequestConfiguration... additionalConfig)
Make a GET request to the url given.<T> void
makePostRequest(okhttp3.HttpUrl url, T requestPayload, RequestConfiguration... additionalConfig)
Makes a POST request to the given URL with given request payload.<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.<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 payloadInputStream
makeStreamingGetRequest(okhttp3.HttpUrl url)
Make a GET request to the url given.
-
-
-
Constructor Detail
-
BitbucketRequestExecutor
public BitbucketRequestExecutor(String bitbucketBaseUrl, HttpRequestExecutor httpRequestExecutor, com.fasterxml.jackson.databind.ObjectMapper objectMapper, BitbucketCredentials credentials)
-
-
Method Detail
-
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 themakeGetRequest(HttpUrl, Class, RequestConfiguration...)
is most likely a better choice.- Type Parameters:
T
- type to return- Parameters:
url
- url to connect toreturnType
- type reference used when getting generified objects (such as pages)- Returns:
- a deserialized object of type T
- See Also:
makeGetRequest(HttpUrl, Class, RequestConfiguration...)
-
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 asBitbucketPage
) for that usemakeGetRequest(HttpUrl, TypeReference, RequestConfiguration...)
instead.- Type Parameters:
T
- type to return- Parameters:
url
- url to connect toreturnType
- 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:
makeGetRequest(HttpUrl, TypeReference, RequestConfiguration...)
-
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 payloadR
- return type- Parameters:
url
- the URL to make the request torequestPayload
- , JSON payload which will be marshalled to send it with POSTreturnType
- , 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 torequestPayload
- 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 resultR
- Type of return- Parameters:
url
- the URL to make the request torequestPayload
- JSON payload which will be marshalled to send it with PUTreturnType
- , Class of expected return type- Returns:
- the result
-
-