Interface HttpRequestExecutor
-
- All Known Implementing Classes:
HttpRequestExecutorImpl
public interface HttpRequestExecutor
Responsible for making remote HTTP calls to the given URL using passed in credentials. The implementation is tightly bound with OkHttpClient library. Methods also takesHttpRequestExecutor.ResponseConsumer
instead of returning response in order to have better handle on cleaning of resources.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
HttpRequestExecutor.ResponseConsumer<T>
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
executeDelete(okhttp3.HttpUrl url, RequestConfiguration... additionalConfig)
Executes a delete call.<T> T
executeGet(okhttp3.HttpUrl url, HttpRequestExecutor.ResponseConsumer<T> consumer, RequestConfiguration... additionalConfig)
Executes a Get call to a given URL.<T> T
executePost(okhttp3.HttpUrl url, String requestBodyAsJson, HttpRequestExecutor.ResponseConsumer<T> consumer, RequestConfiguration... additionalConfig)
Executes a POST with a given URL and request payload, with any custom headers.<T> T
executePut(okhttp3.HttpUrl url, String requestBodyAsJson, HttpRequestExecutor.ResponseConsumer<T> consumer, RequestConfiguration... additionalConfig)
Executes a PUT with a given URL and request payload.InputStream
executeStreamingGet(okhttp3.HttpUrl url, HttpRequestExecutor.ResponseConsumer<InputStream> consumer, RequestConfiguration... additionalConfig)
Executes a streaming get call to a given URL.
-
-
-
Method Detail
-
executeDelete
void executeDelete(okhttp3.HttpUrl url, RequestConfiguration... additionalConfig)
Executes a delete call.- Parameters:
url
- the delete urladditionalConfig
- additional configuration, such as credentials, to use for deletion- Throws:
AuthorizationException
- if the credentials did not allow access to the given urlConnectionFailureException
- if the server did not respondNotFoundException
- if the requested url does not existBadRequestException
- if the request was malformed and thus rejected by the serverServerErrorException
- if the server failed to process the requestBitbucketClientException
- for all errors not already captured
-
executeGet
<T> T executeGet(okhttp3.HttpUrl url, HttpRequestExecutor.ResponseConsumer<T> consumer, RequestConfiguration... additionalConfig)
Executes a Get call to a given URL.- Type Parameters:
T
- result that consumer wish to return- Parameters:
url
- The URL to hit on bitbucket server endadditionalConfig
- additional configuration, such as credentials, that will be used in making callsconsumer
- on successful execution,Response
will be passed to consumer- Returns:
- result
- Throws:
AuthorizationException
- if the credentials did not allow access to the given urlConnectionFailureException
- if the server did not respondNotFoundException
- if the requested url does not existBadRequestException
- if the request was malformed and thus rejected by the serverServerErrorException
- if the server failed to process the requestBitbucketClientException
- for all errors not already captured
-
executeStreamingGet
InputStream executeStreamingGet(okhttp3.HttpUrl url, HttpRequestExecutor.ResponseConsumer<InputStream> consumer, RequestConfiguration... additionalConfig)
Executes a streaming get call to a given URL.- Parameters:
url
- The URL to hit on bitbucket server endadditionalConfig
- additional configuration, such as credentials, that will be used in making callsconsumer
- on successful execution,Response
will be passed to consumer- Returns:
- result
- Throws:
AuthorizationException
- if the credentials did not allow access to the given urlConnectionFailureException
- if the server did not respondNotFoundException
- if the requested url does not existBadRequestException
- if the request was malformed and thus rejected by the serverServerErrorException
- if the server failed to process the requestBitbucketClientException
- for all errors not already captured- Since:
- 3.3.3
-
executePost
<T> T executePost(okhttp3.HttpUrl url, String requestBodyAsJson, HttpRequestExecutor.ResponseConsumer<T> consumer, RequestConfiguration... additionalConfig)
Executes a POST with a given URL and request payload, with any custom headers.- Type Parameters:
T
- result that consumer wish to return- Parameters:
url
- The URL to hit on bitbucket server endadditionalConfig
- additional configuration, such as credentials, that will be used in making callsrequestBodyAsJson
- the request payload to send in JSON formatconsumer
- on successful execution,Response
will be passed to consumer- Returns:
- result computed by consumer
- Throws:
AuthorizationException
- if the credentials did not allow access to the given urlConnectionFailureException
- if the server did not respondNotFoundException
- if the requested url does not existBadRequestException
- if the request was malformed and thus rejected by the serverServerErrorException
- if the server failed to process the requestBitbucketClientException
- for all errors not already captured
-
executePut
<T> T executePut(okhttp3.HttpUrl url, String requestBodyAsJson, HttpRequestExecutor.ResponseConsumer<T> consumer, RequestConfiguration... additionalConfig)
Executes a PUT with a given URL and request payload.- Type Parameters:
T
- Type of result- Parameters:
url
- The URL to hit on bitbucket server endadditionalConfig
- additional configuration, such as credentials, that will be used in making callsrequestBodyAsJson
- the request payload to send in JSON formatconsumer
- on successful execution,Response
will be passed to consumer- Returns:
- result computed by consumer
- Throws:
AuthorizationException
- if the credentials did not allow access to the given urlConnectionFailureException
- if the server did not respondNotFoundException
- if the requested url does not existBadRequestException
- if the request was malformed and thus rejected by the serverServerErrorException
- if the server failed to process the requestBitbucketClientException
- for all errors not already captured
-
-