Package com.atlan.net
Class HttpClient
java.lang.Object
com.atlan.net.HttpClient
- Direct Known Subclasses:
HttpURLConnectionClient
Base abstract class for HTTP clients used to send requests to Atlan's API.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static String
buildUserAgentString
(AtlanClient client) Builds the value of theUser-Agent
header.protected static String
Builds the value of theX-Atlan-Client-User-Agent
header.abstract AtlanResponse
request
(AtlanRequest request) Sends the given request to Atlan's API, buffering the response body into memory.abstract AtlanEventStreamResponse
requestES
(AtlanRequest request) Sends the given request to Atlan's API, and returns a buffered response.requestEventStream
(AtlanRequest request) Sends the given request to Atlan's API, retrying the request in cases of intermittent problems.requestStream
(AtlanRequest request) Sends the given request to Atlan's API, streaming the response body.requestWithRetries
(AtlanRequest request) Sends the given request to Atlan's API, retrying the request in cases of intermittent problems.requestWithTelemetry
(AtlanRequest request) Sends the given request to Atlan's API, handling telemetry if not disabled.<T extends com.atlan.net.AbstractAtlanResponse<?>>
TsendWithRetries
(AtlanRequest request, com.atlan.net.HttpClient.RequestSendFunction<T> send) Sends the given request to Atlan's API, retrying if it encounters certain problems.static Duration
waitTime
(int attempt) Calculate an exponential-backoff time to wait, with a jitter.
-
Field Details
-
maxNetworkRetriesDelay
Maximum sleep time between tries to send HTTP requests after network failure. -
minNetworkRetriesDelay
Minimum sleep time between tries to send HTTP requests after network failure.
-
-
Constructor Details
-
HttpClient
protected HttpClient()Initializes a new instance of theHttpClient
class.
-
-
Method Details
-
request
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
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 receivingAtlanException
-
requestStream
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
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 requestsend
- 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
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
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
Builds the value of theUser-Agent
header.- Parameters:
client
- through which to connect to Atlan- Returns:
- a string containing the value of the
User-Agent
header
-
buildXAtlanClientUserAgentString
Builds the value of theX-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
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)
-