Package co.cryptoservice.sdk
Class CryptoServiceClient.Builder
java.lang.Object
co.cryptoservice.sdk.CryptoServiceClient.Builder
- Enclosing class:
CryptoServiceClient
Builds a
CryptoServiceClient. Not thread-safe; the client it builds is.-
Method Summary
Modifier and TypeMethodDescriptionAn API key, sent asx-api-key; null sends none.autoTraceparent(boolean enabled) Sends a freshly generated W3Ctraceparentwith every request (true), or none (false).The server's base URL, for examplehttp://127.0.0.1:3101: http or https, with a host, and no user info, query or fragment; a path prefix is kept and a trailing slash dropped.build()Builds the client.The limit on a whole call, retries and waits included; none when not set.httpClient(HttpClient httpClient) AnHttpClientto send through instead of the client's own, for tests or a custom proxy or executor.responseListener(ResponseListener listener) Observes every response's status and headers; null for none.retry(RetryOptions retry) Retries of transient failures;RetryOptions.NONE(the default) sends every call once.The timeout of each attempt (connect and response headers); 30 seconds when not set.A JWT, sent asAuthorization: Bearer <token>; null sends none.toString()Names the settings; the credentials are redacted.traceparent(String traceparent) A fixed W3Ctraceparentsent with every request; null sends none.
-
Method Details
-
baseUrl
The server's base URL, for examplehttp://127.0.0.1:3101: http or https, with a host, and no user info, query or fragment; a path prefix is kept and a trailing slash dropped.- Parameters:
baseUrl- the base URL- Returns:
- this builder
-
apiKey
An API key, sent asx-api-key; null sends none.- Parameters:
apiKey- the key, or null- Returns:
- this builder
-
token
A JWT, sent asAuthorization: Bearer <token>; null sends none.- Parameters:
token- the token, or null- Returns:
- this builder
-
timeout
The timeout of each attempt (connect and response headers); 30 seconds when not set.- Parameters:
timeout- a positive duration- Returns:
- this builder
-
deadline
The limit on a whole call, retries and waits included; none when not set. When it passes, the call fails with aTransportErrorwhosetimedOut()is true.- Parameters:
deadline- a positive duration, or null for none- Returns:
- this builder
-
retry
Retries of transient failures;RetryOptions.NONE(the default) sends every call once.- Parameters:
retry- the retry options- Returns:
- this builder
-
traceparent
A fixed W3Ctraceparentsent with every request; null sends none.- Parameters:
traceparent- aversion-traceid-parentid-flagsvalue, or null- Returns:
- this builder
- Throws:
IllegalArgumentException- when the value is not a traceparent
-
autoTraceparent
Sends a freshly generated W3Ctraceparentwith every request (true), or none (false).- Parameters:
enabled- whether to generate one per request- Returns:
- this builder
-
responseListener
Observes every response's status and headers; null for none.- Parameters:
listener- the listener, or null- Returns:
- this builder
-
httpClient
AnHttpClientto send through instead of the client's own, for tests or a custom proxy or executor. It must not follow redirects. Its TLS settings are the caller's responsibility, andCryptoServiceClient.close()leaves it open.- Parameters:
httpClient- the HTTP client, or null for the client's own- Returns:
- this builder
-
build
Builds the client.- Returns:
- the client, thread-safe
- Throws:
IllegalArgumentException- when the base URL is missing or malformed, a duration is not positive, a credential is not a valid header value, or the injected HTTP client follows redirects
-
toString
Names the settings; the credentials are redacted.
-