#[non_exhaustive]pub struct OpenApiConfig { /* private fields */ }Expand description
How OpenApiToolset calls the API. Start from
OpenApiConfig::new (the same as Default) and chain the builder methods.
Implementations§
Source§impl OpenApiConfig
impl OpenApiConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
The default configuration: the document’s server URL, no credentials, no prefix or
filter, RequireConfirmation::Mutating, a 30 s timeout and a 256 KiB response cap.
Sourcepub fn base_url(self, url: impl Into<String>) -> Self
pub fn base_url(self, url: impl Into<String>) -> Self
The base URL of every request, instead of the document’s servers[0].url. It must be
absolute, without a query or fragment, or OpenApiToolset::new fails with
Error::NoBaseUrl.
Sourcepub fn auth(self, provider: Arc<dyn CredentialProvider>) -> Self
pub fn auth(self, provider: Arc<dyn CredentialProvider>) -> Self
Sends every request through gadk_auth::client with provider, which writes the
credential’s headers. A 401 or 403 is retried once with a refreshed credential only when
the provider is a refreshing provider (such as gadk_auth::gcp::new_provider, or your own
RefreshingProvider); static_token, api_key, token_source, adc and
service_account are not retried (adc and service_account renew their tokens before
they expire).
Sourcepub fn query_api_key(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn query_api_key( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Appends name=value to every request’s query string.
Sourcepub fn prefix(self, prefix: impl Into<String>) -> Self
pub fn prefix(self, prefix: impl Into<String>) -> Self
Exposes each tool as <prefix>_<name>. Empty (the default) keeps the names.
Sourcepub fn tool_filter(self, filter: ToolPredicate) -> Self
pub fn tool_filter(self, filter: ToolPredicate) -> Self
Keeps only the tools filter accepts. The filter sees each tool under its unprefixed
name.
Sourcepub fn require_confirmation(self, mode: RequireConfirmation) -> Self
pub fn require_confirmation(self, mode: RequireConfirmation) -> Self
Which calls need confirmation (default RequireConfirmation::Mutating).
Sourcepub fn confirmation_provider(self, provider: ConfirmationProvider) -> Self
pub fn confirmation_provider(self, provider: ConfirmationProvider) -> Self
Decides per call whether confirmation is needed, instead of
require_confirmation. It is called with the
exposed tool name and the call’s arguments.
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Adds a header to every request.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
The limit on one whole call, from sending the request to reading the body (default 30 s).
Sourcepub fn max_response_bytes(self, max: usize) -> Self
pub fn max_response_bytes(self, max: usize) -> Self
The largest response body kept in a result (default 262,144 bytes); a longer body is
cut and the result gains "truncated": true.