Package org.azd.utils

Class BaseRestClient

java.lang.Object
org.azd.utils.BaseRestClient
Direct Known Subclasses:
RestClientProvider

@Deprecated(since="v6.0") public abstract class BaseRestClient extends Object
Deprecated.
BaseRestClient that encapsulates the logic for managing request and response for REST API.
  • Constructor Details

    • BaseRestClient

      public BaseRestClient()
      Deprecated.
  • Method Details

    • getRedirectPolicy

      public static HttpClient.Redirect getRedirectPolicy()
      Deprecated.
      Get the current redirect policy.
      Returns:
      HttpClient.Redirect policy.
    • setRedirectPolicy

      public static void setRedirectPolicy(HttpClient.Redirect redirectPolicy)
      Deprecated.
      Set the current redirect policy.
      Parameters:
      redirectPolicy - HttpClient.Redirect policy.
    • get

      public static <T> CompletableFuture<HttpResponse<T>> get(String requestUrl, String token, HttpResponse.BodyHandler<T> handler, CustomHeader contentType, boolean callback)
      Deprecated.
      Sends a GET request to REST API with basic authentication
      Parameters:
      requestUrl - pass the request url
      token - pass the personal access token
      handler - HttpResponse body handler
      contentType - specify the content type
      callback - If true client will be built with redirect policy
      Returns:
      response string from the API
    • post

      public static <T> CompletableFuture<HttpResponse<T>> post(String requestUrl, String token, HttpRequest.BodyPublisher publisher, HttpResponse.BodyHandler<T> handler, CustomHeader contentType, boolean callback) throws AzDException
      Deprecated.
      Sends a POST request to REST API with oauth authentication, content length of the request and request body
      Parameters:
      requestUrl - pass the request url
      token - pass the personal access token
      publisher - BodyPublisher with request body
      handler - HttpResponse body handlers
      contentType - Content type for setting headers
      callback - If true client will be built with redirect policy
      Returns:
      response string from the API if any
      Throws:
      AzDException - throws user friendly error message with error code from API
    • patch

      public static <T> CompletableFuture<HttpResponse<T>> patch(String requestUrl, String token, HttpRequest.BodyPublisher publisher, HttpResponse.BodyHandler<T> handler, CustomHeader contentType, boolean callback) throws AzDException
      Deprecated.
      Sends a PATCH request to REST API with basic authentication and request body
      Parameters:
      requestUrl - pass the request url
      token - pass the personal access token
      publisher - BodyPublisher with request body
      handler - HttpResponse body handlers
      contentType - Content type for setting headers
      callback - If true client will be built with redirect policy
      Returns:
      response string from the API if any
      Throws:
      AzDException - throws user friendly error message with error code from API
    • put

      public static <T> CompletableFuture<HttpResponse<T>> put(String requestUrl, String token, HttpRequest.BodyPublisher publisher, HttpResponse.BodyHandler<T> handler, CustomHeader contentType, boolean callback) throws AzDException
      Deprecated.
      Sends a PUT request to REST API with basic authentication and request body
      Parameters:
      requestUrl - pass the request url
      token - pass the personal access token
      publisher - BodyPublisher with request body
      handler - HttpResponse body handlers
      contentType - Content type for setting headers
      callback - If true client will be built with redirect policy
      Returns:
      response string from the API if any
      Throws:
      AzDException - throws user friendly error message with error code from API
    • delete

      public static <T> CompletableFuture<HttpResponse<T>> delete(String requestUrl, String token, HttpResponse.BodyHandler<T> handler)
      Deprecated.
      Sends a DELETE request to REST API with basic authentication
      Parameters:
      requestUrl - pass the request url
      token - pass the personal access token
      Returns:
      response string from the API if any
    • response

      public static <T> CompletableFuture<HttpResponse<T>> response(RequestMethod requestMethod, String requestUrl, String token, HttpRequest.BodyPublisher publisher, HttpResponse.BodyHandler<T> handler, CustomHeader contentType, boolean callback) throws AzDException
      Deprecated.
      Manages the request method and response from REST API.
      Parameters:
      requestMethod - Type of request to send. Such as GET, POST, PUT, PATCH and DELETE.
      requestUrl - Request url to call the Api.
      token - Personal access token.
      publisher - HttpRequest body publisher type
      handler - HttpResponse body type
      contentType - Custom headers for sending the request
      callback - If true default redirect policy will be applied
      Returns:
      Completable future object.
      Throws:
      AzDException - Default Api exception handler.
    • getBuilder

      protected static HttpRequest.Builder getBuilder(String requestUrl, String token)
      Deprecated.
      Helper method to create the request with request url and access token.
      Parameters:
      requestUrl - Pass the request url.
      token - Pass the access token. Base64 encoding will be taken care when building the request.
      Returns:
      HttpRequest builder object.
    • getResponse

      protected static <T> CompletableFuture<HttpResponse<T>> getResponse(HttpRequest r, HttpResponse.BodyHandler<T> handler, boolean callback)
      Deprecated.
      Helper method to get the response based on built http request.
      Type Parameters:
      T - Generic response type object.
      Parameters:
      r - Http request object.
      handler - Handlers for accepting the response content as. Example string or input stream etc.
      callback - If true follows redirects.
      Returns:
      generic type of future of http response.