Skip to main content

NifiClientBuilder

Struct NifiClientBuilder 

Source
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

Source

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.

Source

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.

Source

pub fn connect_timeout(self, duration: Duration) -> Self

Set the TCP connection timeout.

Source

pub fn proxy(self, url: Url) -> Self

Route all traffic (HTTP and HTTPS) through the given proxy.

Source

pub fn http_proxy(self, url: Url) -> Self

Route HTTP traffic through the given proxy.

Source

pub fn https_proxy(self, url: Url) -> Self

Route HTTPS traffic through the given proxy.

Source

pub fn danger_accept_invalid_certs(self, accept: bool) -> Self

Skip TLS certificate verification.

Only use this in development against self-signed certificates.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn build(self) -> Result<NifiClient, NifiError>

Build the NifiClient.

Source

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?;

Trait Implementations§

Source§

impl Debug for NifiClientBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> 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: 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: 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, 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<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