Package com.dtsx.astra.sdk.utils
Class HttpClientWrapper
java.lang.Object
com.dtsx.astra.sdk.utils.HttpClientWrapper
Helper to forge Http Requests to interact with Devops API.
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.apache.hc.client5.http.impl.classic.CloseableHttpClient
HttpComponent5.protected static org.apache.hc.client5.http.config.RequestConfig
Default request configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Helper to build the HTTP request.Helper to build the HTTP request.executeHttp
(org.apache.hc.client5.http.classic.methods.HttpUriRequestBase req, boolean mandatory) Execute a request coming from elsewhere.executeHttp
(org.apache.hc.core5.http.Method method, String url, String token, String reqBody, String contentType, boolean mandatory) Main Method executing HTTP Request.Helper to build the HTTP request.GET_PULSAR
(String url, String token, String pulsarCluster, String organizationId) Helper to build the HTTP request.static HttpClientWrapper
Singleton Pattern.Helper to build the HTTP request.void
Helper to build the HTTP request.Helper to build the HTTP request.Helper to build the HTTP request.Helper to build the HTTP request.void
Helper to build the HTTP request.
-
Field Details
-
httpClient
protected org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClientHttpComponent5. -
requestConfig
protected static org.apache.hc.client5.http.config.RequestConfig requestConfigDefault request configuration.
-
-
Method Details
-
getInstance
Singleton Pattern.- Returns:
- singleton for the class
-
GET
Helper to build the HTTP request.- Parameters:
url
- target urltoken
- authentication token- Returns:
- http request
-
GET_PULSAR
public ApiResponseHttp GET_PULSAR(String url, String token, String pulsarCluster, String organizationId) Helper to build the HTTP request.- Parameters:
url
- target urltoken
- authentication tokenpulsarCluster
- pulsar clusterorganizationId
- organization identifier- Returns:
- http request
-
POST_PULSAR
public ApiResponseHttp POST_PULSAR(String url, String token, String body, String pulsarCluster, String organizationId) Helper to build the HTTP request.- Parameters:
url
- target urltoken
- authentication tokenbody
- request bodypulsarCluster
- pulsar clusterorganizationId
- organization identifier- Returns:
- http request
-
DELETE_PULSAR
public ApiResponseHttp DELETE_PULSAR(String url, String token, String body, String pulsarCluster, String organizationId) Helper to build the HTTP request.- Parameters:
url
- target urltoken
- authentication tokenbody
- request bodypulsarCluster
- pulsar clusterorganizationId
- organization identifier- Returns:
- http request
-
HEAD
Helper to build the HTTP request.- Parameters:
url
- target urltoken
- authentication token- Returns:
- http request
-
POST
Helper to build the HTTP request.- Parameters:
url
- target urltoken
- authentication token- Returns:
- http request
-
POST
Helper to build the HTTP request.- Parameters:
url
- target urltoken
- authentication tokenbody
- request body- Returns:
- http request
-
DELETE
Helper to build the HTTP request.- Parameters:
url
- target urltoken
- authentication token
-
PUT
Helper to build the HTTP request.- Parameters:
url
- target urltoken
- authentication tokenbody
- request body
-
PATCH
Helper to build the HTTP request.- Parameters:
url
- target urltoken
- authentication tokenbody
- request body
-
executeHttp
public ApiResponseHttp executeHttp(org.apache.hc.core5.http.Method method, String url, String token, String reqBody, String contentType, boolean mandatory) Main Method executing HTTP Request.- Parameters:
method
- http methodurl
- urltoken
- authentication tokencontentType
- request content typereqBody
- request bodymandatory
- allow 404 errors- Returns:
- basic request
-
executeHttp
public ApiResponseHttp executeHttp(org.apache.hc.client5.http.classic.methods.HttpUriRequestBase req, boolean mandatory) Execute a request coming from elsewhere.- Parameters:
req
- current requestmandatory
- mandatory- Returns:
- api response
-