pub struct OneBuilder { /* private fields */ }Expand description
Builder for One.
Implementations§
Source§impl OneBuilder
impl OneBuilder
Sourcepub fn credential(self, credential: Credential) -> Self
pub fn credential(self, credential: Credential) -> Self
Sets the credential directly, for callers that already have one in
hand. Self::secret and Self::access_token are the usual doors.
Sourcepub fn organization(self, organization_id: impl Into<String>) -> Self
pub fn organization(self, organization_id: impl Into<String>) -> Self
Acts within an organization the caller has access to.
Required to reach an organization’s connections with an access token. A token can hold grants on several organizations, so the API decides which one a request means from this - and a request that omits it means the user’s personal scope, where an organization-owned connection simply is not present. A secret key already carries its tenant, so setting this alongside one changes nothing.
Sourcepub fn project(self, project_id: impl Into<String>) -> Self
pub fn project(self, project_id: impl Into<String>) -> Self
Narrows Self::organization to one of its projects.
A project is always qualified by its organization, so this is only meaningful beside one; on its own the request still resolves to the personal scope.
Sourcepub fn access_token(self, token: impl Into<String>) -> Self
pub fn access_token(self, token: impl Into<String>) -> Self
Authenticates with an OAuth access token instead of a secret key.
The reachable surface is whatever the end user consented to for this
app, not the whole account. Calling this after Self::secret (or the
reverse) replaces the credential rather than adding one: a request
carries exactly one.
Sourcepub fn base_url(self, base_url: impl Into<String>) -> Self
pub fn base_url(self, base_url: impl Into<String>) -> Self
Overrides the base URL (e.g. a self-hosted or local instance).
Sourcepub fn retry(self, schedule: RetrySchedule) -> Self
pub fn retry(self, schedule: RetrySchedule) -> Self
Sets the default retry schedule, applied to operations that don’t declare their own.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Sets the default per-request timeout, applied to operations that don’t declare their own.
Sourcepub fn on_success<F: Fn(&CallResponse) + Send + Sync + 'static>(
self,
hook: F,
) -> Self
pub fn on_success<F: Fn(&CallResponse) + Send + Sync + 'static>( self, hook: F, ) -> Self
Registers a global hook invoked after every successful call.
Sourcepub fn on_error<F: Fn(&Error) + Send + Sync + 'static>(self, hook: F) -> Self
pub fn on_error<F: Fn(&Error) + Send + Sync + 'static>(self, hook: F) -> Self
Registers a global hook invoked after every failed call.
Sourcepub fn build(self) -> Result<One, Error>
pub fn build(self) -> Result<One, Error>
Builds the client, applying defaults for any unset field.
Fails fast with Error::MissingSecret when no credential was
configured, rather than deferring the misconfiguration to a runtime auth
failure. Either credential satisfies it - a secret key from
Self::secret or an OAuth access token from Self::access_token -
and a configured-but-empty one counts as absent, since an empty header
would fail at the API rather than here.