pub struct NifiClientBuilder { /* private fields */ }Expand description
Builder for NifiClient.
Use this when you need to configure timeouts, proxies, or TLS options beyond the defaults provided by the convenience constructors.
§Example
use std::time::Duration;
use nifi_rust_client::NifiClientBuilder;
use url::Url;
let client = NifiClientBuilder::new("https://nifi.example.com:8443")?
.timeout(Duration::from_secs(60))
.connect_timeout(Duration::from_secs(10))
.proxy(Url::parse("http://proxy.internal:3128").unwrap())
.build()?;Implementations§
Source§impl NifiClientBuilder
impl NifiClientBuilder
Sourcepub fn new(base_url: &str) -> Result<Self, NifiError>
pub fn new(base_url: &str) -> Result<Self, NifiError>
Create a new builder targeting the given NiFi base URL.
Returns an error if base_url cannot be parsed.
Sourcepub fn timeout(self, duration: Duration) -> Self
pub fn timeout(self, duration: Duration) -> Self
Set the total request timeout.
The timeout applies from when the request starts connecting until the response body is fully received.
Sourcepub fn connect_timeout(self, duration: Duration) -> Self
pub fn connect_timeout(self, duration: Duration) -> Self
Set the TCP connection timeout.
Sourcepub fn proxy(self, url: Url) -> Self
pub fn proxy(self, url: Url) -> Self
Route all traffic (HTTP and HTTPS) through the given proxy.
Sourcepub fn http_proxy(self, url: Url) -> Self
pub fn http_proxy(self, url: Url) -> Self
Route HTTP traffic through the given proxy.
Sourcepub fn https_proxy(self, url: Url) -> Self
pub fn https_proxy(self, url: Url) -> Self
Route HTTPS traffic through the given proxy.
Sourcepub fn danger_accept_invalid_certs(self, accept: bool) -> Self
pub fn danger_accept_invalid_certs(self, accept: bool) -> Self
Skip TLS certificate verification.
Only use this in development against self-signed certificates.
Sourcepub fn add_root_certificate(self, pem: &[u8]) -> Self
pub fn add_root_certificate(self, pem: &[u8]) -> Self
Trust an additional PEM-encoded CA certificate.
May be called multiple times to add more than one certificate.
Sourcepub fn credential_provider(
self,
provider: impl CredentialProvider + 'static,
) -> Self
pub fn credential_provider( self, provider: impl CredentialProvider + 'static, ) -> Self
Configure a CredentialProvider for automatic token refresh.
When set, the client will automatically re-authenticate on 401 responses by calling the provider to obtain fresh credentials and then re-issuing the failed request.
Sourcepub fn retry_policy(self, policy: RetryPolicy) -> Self
pub fn retry_policy(self, policy: RetryPolicy) -> Self
Configure a RetryPolicy for transient error retry.
When set, HTTP helpers automatically retry retryable errors using exponential backoff.
Sourcepub fn version_strategy(self, strategy: VersionResolutionStrategy) -> Self
pub fn version_strategy(self, strategy: VersionResolutionStrategy) -> Self
Configure a VersionResolutionStrategy
for the dynamic client.
Controls how the client resolves a detected NiFi version to a supported
client version. Default is Strict.
Sourcepub fn build(self) -> Result<NifiClient, NifiError>
pub fn build(self) -> Result<NifiClient, NifiError>
Build the NifiClient.
Sourcepub fn build_dynamic(self) -> Result<DynamicClient, NifiError>
pub fn build_dynamic(self) -> Result<DynamicClient, NifiError>
Build a DynamicClient that auto-detects the NiFi version.
Version detection happens lazily — either when login() is called
(recommended) or when detect_version() is called explicitly.
Uses the configured VersionResolutionStrategy
(default: Strict). Set via .version_strategy().
§Example
use nifi_rust_client::NifiClientBuilder;
use nifi_rust_client::dynamic::VersionResolutionStrategy;
let client = NifiClientBuilder::new("https://nifi.example.com:8443")?
.danger_accept_invalid_certs(true)
.version_strategy(VersionResolutionStrategy::Closest)
.build_dynamic()?;
// login() authenticates AND detects the NiFi version automatically.
client.login("admin", "password").await?;