Class HttpClientWrapper

java.lang.Object
com.dtsx.astra.sdk.utils.HttpClientWrapper

public class HttpClientWrapper extends Object
Helper to forge Http Requests to interact with Devops API.
  • Field Details

    • httpClient

      protected org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient
      HttpComponent5.
    • requestConfig

      protected static org.apache.hc.client5.http.config.RequestConfig requestConfig
      Default request configuration.
  • Method Details

    • getInstance

      public static HttpClientWrapper getInstance()
      Singleton Pattern.
      Returns:
      singleton for the class
    • GET

      public ApiResponseHttp GET(String url, String token)
      Helper to build the HTTP request.
      Parameters:
      url - target url
      token - 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 url
      token - authentication token
      pulsarCluster - pulsar cluster
      organizationId - 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 url
      token - authentication token
      body - request body
      pulsarCluster - pulsar cluster
      organizationId - 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 url
      token - authentication token
      body - request body
      pulsarCluster - pulsar cluster
      organizationId - organization identifier
      Returns:
      http request
    • HEAD

      public ApiResponseHttp HEAD(String url, String token)
      Helper to build the HTTP request.
      Parameters:
      url - target url
      token - authentication token
      Returns:
      http request
    • POST

      public ApiResponseHttp POST(String url, String token)
      Helper to build the HTTP request.
      Parameters:
      url - target url
      token - authentication token
      Returns:
      http request
    • POST

      public ApiResponseHttp POST(String url, String token, String body)
      Helper to build the HTTP request.
      Parameters:
      url - target url
      token - authentication token
      body - request body
      Returns:
      http request
    • DELETE

      public void DELETE(String url, String token)
      Helper to build the HTTP request.
      Parameters:
      url - target url
      token - authentication token
    • PUT

      public void PUT(String url, String token, String body)
      Helper to build the HTTP request.
      Parameters:
      url - target url
      token - authentication token
      body - request body
    • PATCH

      public void PATCH(String url, String token, String body)
      Helper to build the HTTP request.
      Parameters:
      url - target url
      token - authentication token
      body - 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 method
      url - url
      token - authentication token
      contentType - request content type
      reqBody - request body
      mandatory - 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 request
      mandatory - mandatory
      Returns:
      api response