Package com.atlan.net

Class HttpClient

java.lang.Object
com.atlan.net.HttpClient
Direct Known Subclasses:
HttpURLConnectionClient

public abstract class HttpClient extends Object
Base abstract class for HTTP clients used to send requests to Atlan's API.
  • Field Details

    • maxNetworkRetriesDelay

      public static final Duration maxNetworkRetriesDelay
      Maximum sleep time between tries to send HTTP requests after network failure.
    • minNetworkRetriesDelay

      public static final Duration minNetworkRetriesDelay
      Minimum sleep time between tries to send HTTP requests after network failure.
  • Constructor Details

    • HttpClient

      protected HttpClient()
      Initializes a new instance of the HttpClient class.
  • Method Details

    • request

      public abstract AtlanResponse request(AtlanRequest request) throws AtlanException
      Sends the given request to Atlan's API, buffering the response body into memory.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      AtlanException - If the request fails for any reason
    • requestES

      public abstract AtlanEventStreamResponse requestES(AtlanRequest request) throws AtlanException
      Sends the given request to Atlan's API, and returns a buffered response.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      ApiConnectionException - if an error occurs when sending or receiving
      AtlanException
    • requestStream

      public AtlanResponseStream requestStream(AtlanRequest request) throws AtlanException
      Sends the given request to Atlan's API, streaming the response body.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      AtlanException - If the request fails for any reason
    • requestWithTelemetry

      public AtlanResponse requestWithTelemetry(AtlanRequest request) throws AtlanException
      Sends the given request to Atlan's API, handling telemetry if not disabled.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      AtlanException - If the request fails for any reason
    • sendWithRetries

      public <T extends com.atlan.net.AbstractAtlanResponse<?>> T sendWithRetries(AtlanRequest request, com.atlan.net.HttpClient.RequestSendFunction<T> send) throws AtlanException
      Sends the given request to Atlan's API, retrying if it encounters certain problems.
      Type Parameters:
      T - the type of the response
      Parameters:
      request - the request
      send - the function to use for sending the request (e.g. with or without telemetry)
      Returns:
      the response
      Throws:
      AtlanException - if the request fails for any reason, even after retries
    • requestWithRetries

      public AtlanResponse requestWithRetries(AtlanRequest request) throws AtlanException
      Sends the given request to Atlan's API, retrying the request in cases of intermittent problems.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      AtlanException - If the request fails for any reason
    • requestEventStream

      public AtlanEventStreamResponse requestEventStream(AtlanRequest request) throws AtlanException
      Sends the given request to Atlan's API, retrying the request in cases of intermittent problems.
      Parameters:
      request - the request
      Returns:
      the response
      Throws:
      AtlanException - If the request fails for any reason
    • buildUserAgentString

      protected static String buildUserAgentString(AtlanClient client)
      Builds the value of the User-Agent header.
      Parameters:
      client - through which to connect to Atlan
      Returns:
      a string containing the value of the User-Agent header
    • buildXAtlanClientUserAgentString

      protected static String buildXAtlanClientUserAgentString(AtlanClient client)
      Builds the value of the X-Atlan-Client-User-Agent header.
      Parameters:
      client - through which to connect to Atlan
      Returns:
      a string containing the value of the X-Atlan-Client-User-Agent header
    • waitTime

      public static Duration waitTime(int attempt)
      Calculate an exponential-backoff time to wait, with a jitter.
      Parameters:
      attempt - the retry attempt (count)
      Returns:
      a duration giving the time to wait (sleep)