Skip to main content

CloudClient

Struct CloudClient 

Source
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: RetryConfig

Retry 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

Source

pub fn new_aws<I, K, V>(options: I, runtime: Option<&Handle>) -> Result<Self>
where I: IntoIterator<Item = (K, V)>, K: AsRef<str>, V: Into<String>,

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.

Source

pub fn new_google<I, K, V>(options: I, runtime: Option<&Handle>) -> Result<Self>
where I: IntoIterator<Item = (K, V)>, K: AsRef<str>, V: Into<String>,

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.

Source

pub fn new_azure<I, K, V>(options: I, runtime: Option<&Handle>) -> Result<Self>
where I: IntoIterator<Item = (K, V)>, K: AsRef<str>, V: Into<String>,

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.

Source

pub fn new_databricks<I, K, V>( options: I, runtime: Option<&Handle>, ) -> Result<Self>
where I: IntoIterator<Item = (K, V)>, K: AsRef<str>, V: Into<String>,

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.

Source

pub fn new_with_token(token: impl ToString) -> Self

Create a new client with a personal access token.

Source

pub fn new_unauthenticated() -> Self

Create a new unauthenticated client.

Source

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.

Source

pub fn with_http_service(self, service: Arc<dyn HttpService>) -> Self

Replace the HttpService used for request execution.

Source

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.

Source

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.

Source

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.

Source

pub fn get<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder

Start building a GET request for url. Shortcut for request.

Source

pub fn post<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder

Start building a POST request for url. Shortcut for request.

Source

pub fn put<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder

Start building a PUT request for url. Shortcut for request.

Source

pub fn delete<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder

Start building a DELETE request for url. Shortcut for request.

Source

pub fn head<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder

Start building a HEAD request for url. Shortcut for request.

Source

pub fn patch<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder

Start building a PATCH request for url. Shortcut for request.

Source

pub fn options<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder

Start building an OPTIONS request for url. Shortcut for request.

Source

pub fn trace<U: IntoUrl>(&self, url: U) -> CloudRequestBuilder

Start building a TRACE request for url. Shortcut for request.

Source

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

Source§

fn clone(&self) -> CloudClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more