pub struct CloudClient {
pub retry_config: RetryConfig,
/* private fields */
}Expand description
An authenticated HTTP client for cloud provider APIs.
Created via the provider-specific constructors CloudClient::new_aws,
CloudClient::new_azure, CloudClient::new_google, or
CloudClient::new_databricks, or the simpler CloudClient::new_with_token
and CloudClient::new_unauthenticated.
Fields§
§retry_config: RetryConfigRetry configuration applied to requests sent through this client.
Used both by credential providers (token refresh) and by user-initiated
requests via CloudRequestBuilder::send and
CloudClient::sign_and_send. Override with
CloudClient::with_retry_config.
Implementations§
Source§impl CloudClient
impl CloudClient
Sourcepub fn new_aws<I, K, V>(options: I, runtime: Option<&Handle>) -> Result<Self>
pub fn new_aws<I, K, V>(options: I, runtime: Option<&Handle>) -> Result<Self>
Create a new client with AWS credentials.
If runtime is provided, all HTTP I/O (including credential refresh)
will be spawned on the given runtime handle.
Sourcepub fn new_google<I, K, V>(options: I, runtime: Option<&Handle>) -> Result<Self>
pub fn new_google<I, K, V>(options: I, runtime: Option<&Handle>) -> Result<Self>
Create a new client with Google Cloud credentials.
If runtime is provided, all HTTP I/O (including credential refresh)
will be spawned on the given runtime handle.
Sourcepub fn new_azure<I, K, V>(options: I, runtime: Option<&Handle>) -> Result<Self>
pub fn new_azure<I, K, V>(options: I, runtime: Option<&Handle>) -> Result<Self>
Create a new client with Azure credentials.
If runtime is provided, all HTTP I/O (including credential refresh)
will be spawned on the given runtime handle.
Sourcepub fn new_databricks<I, K, V>(
options: I,
runtime: Option<&Handle>,
) -> Result<Self>
pub fn new_databricks<I, K, V>( options: I, runtime: Option<&Handle>, ) -> Result<Self>
Create a new client with Databricks credentials.
If runtime is provided, all HTTP I/O (including credential refresh)
will be spawned on the given runtime handle.
Sourcepub fn new_with_token(token: impl ToString) -> Self
pub fn new_with_token(token: impl ToString) -> Self
Create a new client with a personal access token.
Sourcepub fn new_unauthenticated() -> Self
pub fn new_unauthenticated() -> Self
Create a new unauthenticated client.
Sourcepub fn with_runtime(self, handle: Handle) -> Self
pub fn with_runtime(self, handle: Handle) -> Self
Route all HTTP I/O through the given runtime handle.
This is useful for simple constructors (new_with_token, new_unauthenticated)
where no credential providers need to perform HTTP I/O. For cloud provider
constructors, pass the handle at construction time instead.
Sourcepub fn with_http_service(self, service: Arc<dyn HttpService>) -> Self
pub fn with_http_service(self, service: Arc<dyn HttpService>) -> Self
Replace the HttpService used for request execution.
Sourcepub fn with_retry_config(self, retry_config: RetryConfig) -> Self
pub fn with_retry_config(self, retry_config: RetryConfig) -> Self
Override the RetryConfig applied to requests sent through this client.
Requests issued via CloudRequestBuilder::send and
sign_and_send are retried per this config
(exponential backoff with jitter; safe/idempotent requests are also
retried on timeout). The default allows up to 10
retries — lower it for latency-sensitive interactive calls.
Sourcepub async fn sign_and_send(&self, request: Request) -> Result<Response>
pub async fn sign_and_send(&self, request: Request) -> Result<Response>
Sign an already-built reqwest::Request and dispatch it, with retries.
This is the request-level counterpart to the CloudRequestBuilder
flow: it applies the client’s RequestSigner (refreshing credentials
as needed) and sends the request through the configured HttpService,
retrying transient failures per the client’s RetryConfig. It is
useful when the request is produced elsewhere (for example by a protocol
stack such as ConnectRPC) and only needs authentication and transport.
The request body must be in memory (not a stream): retries clone the request, and provider signers such as AWS SigV4 hash the body to sign it.
§Errors
Returns an Error if signing fails or if the request ultimately fails
after exhausting retries. A non-success HTTP status code is not itself an
error; inspect reqwest::Response::status on the returned response.
Sourcepub fn request<U: IntoUrl>(&self, method: Method, url: U) -> CloudRequestBuilder
pub fn request<U: IntoUrl>(&self, method: Method, url: U) -> CloudRequestBuilder
Start building a request for the given HTTP method and url.
The returned CloudRequestBuilder borrows this client’s signer, so the
request is signed for the configured provider when
CloudRequestBuilder::send is called.
Sourcepub fn get<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
pub fn get<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
Start building a GET request for url. Shortcut for request.
Sourcepub fn post<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
pub fn post<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
Start building a POST request for url. Shortcut for request.
Sourcepub fn put<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
pub fn put<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
Start building a PUT request for url. Shortcut for request.
Sourcepub fn delete<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
pub fn delete<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
Start building a DELETE request for url. Shortcut for request.
Sourcepub fn head<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
pub fn head<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
Start building a HEAD request for url. Shortcut for request.
Sourcepub fn patch<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
pub fn patch<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
Start building a PATCH request for url. Shortcut for request.
Sourcepub fn options<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
pub fn options<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
Start building an OPTIONS request for url. Shortcut for request.
Sourcepub fn trace<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
pub fn trace<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
Start building a TRACE request for url. Shortcut for request.
Sourcepub fn connect<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
pub fn connect<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder
Start building a CONNECT request for url. Shortcut for request.
Trait Implementations§
Source§impl Clone for CloudClient
impl Clone for CloudClient
Source§fn clone(&self) -> CloudClient
fn clone(&self) -> CloudClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more