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 proxy_url = Url::parse("http://proxy.internal:3128")
.expect("hard-coded proxy URL is valid");
let client = NifiClientBuilder::new("https://nifi.example.com:8443")?
.timeout(Duration::from_secs(60))
.connect_timeout(Duration::from_secs(10))
.proxy(proxy_url)
.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 auth_provider(self, provider: impl AuthProvider + 'static) -> Self
pub fn auth_provider(self, provider: impl AuthProvider + 'static) -> Self
Configure an AuthProvider for authentication and automatic token refresh.
When set, the client will automatically re-authenticate on 401 responses by calling the provider and then re-issuing the failed request.
Sourcepub fn client_identity_pem(self, pem: &[u8]) -> Result<Self, NifiError>
pub fn client_identity_pem(self, pem: &[u8]) -> Result<Self, NifiError>
Attach a PEM-encoded client identity for mTLS.
The pem bytes should contain the concatenated PEM-encoded private key
and certificate chain. The private key must be in RSA, SEC1 Elliptic
Curve, or PKCS#8 format.
Sourcepub fn proxied_entities_chain(self, chain: impl Into<String>) -> Self
pub fn proxied_entities_chain(self, chain: impl Into<String>) -> Self
Set the X-ProxiedEntitiesChain header sent with every request.
This header is used in NiFi proxy deployments to propagate the end-user identity through one or more reverse proxies.
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 request_id_header(self, name: Option<impl Into<String>>) -> Self
pub fn request_id_header(self, name: Option<impl Into<String>>) -> Self
Enable per-request correlation IDs.
When Some(name), every outgoing request carries a fresh UUIDv4
in the given header, and the same id is attached to the per-request
tracing span as the request_id field.
Example: .request_id_header(Some("X-Request-Id")).
When None (default), no header is sent and no request_id field
is recorded.
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?;