Skip to main content

DynamicClient

Struct DynamicClient 

Source
pub struct DynamicClient { /* private fields */ }
Expand description

A dynamic NiFi client that detects the server version lazily and dispatches API calls to the correct version’s generated code.

Version detection happens automatically on login(), or can be triggered explicitly via detect_version() or from_client().

Implementations§

Source§

impl DynamicClient

Source

pub fn new(client: NifiClient) -> Self

Create a new DynamicClient without detecting the server version yet. Version detection will happen automatically on login() or can be triggered explicitly via detect_version().

Uses VersionResolutionStrategy::Strict by default. Use with_strategy to configure fallback behavior.

Source

pub fn with_strategy( client: NifiClient, strategy: VersionResolutionStrategy, ) -> Self

Create a new DynamicClient with a specific version resolution strategy.

See VersionResolutionStrategy for available strategies.

Source

pub async fn from_client(client: NifiClient) -> Result<Self, NifiError>

Wrap an existing NifiClient and detect the NiFi server version immediately via GET /flow/about.

The client must already be authenticated if the NiFi instance requires it. For unauthenticated setup, use new() + login() instead — login triggers version detection automatically.

Uses VersionResolutionStrategy::Strict. To configure fallback, use with_strategy + detect_version instead.

Source

pub async fn detect_version(&self) -> Result<DetectedVersion, NifiError>

Detect the NiFi server version via GET /flow/about. Returns the cached version if already detected.

Resolution behavior depends on the configured VersionResolutionStrategy.

Source

pub fn detected_version(&self) -> DetectedVersion

Returns the detected NiFi server version, or None if not yet detected.

Source

pub fn version(&self) -> Option<DetectedVersion>

Returns the detected version if available, or None.

Source

pub fn inner(&self) -> &NifiClient

Returns a reference to the underlying NifiClient.

Source

pub fn strategy(&self) -> VersionResolutionStrategy

Returns the configured version resolution strategy.

Source

pub async fn login( &self, username: &str, password: &str, ) -> Result<(), NifiError>

Authenticate with the NiFi instance and detect the server version.

Source

pub async fn logout(&self) -> Result<(), NifiError>

Log out from the NiFi instance.

Source

pub fn access_api(&self) -> AccessApiDispatch<'_>

Access the Access API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn authentication_api(&self) -> AuthenticationApiDispatch<'_>

Access the Authentication API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn connections_api(&self) -> ConnectionsApiDispatch<'_>

Access the Connections API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn controller_api(&self) -> ControllerApiDispatch<'_>

Access the Controller API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn controller_services_api(&self) -> ControllerServicesApiDispatch<'_>

Access the Controller Services API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn counters_api(&self) -> CountersApiDispatch<'_>

Access the Counters API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn datatransfer_api(&self) -> DataTransferApiDispatch<'_>

Access the DataTransfer API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn flow_api(&self) -> FlowApiDispatch<'_>

Access the Flow API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn flowfilequeues_api(&self) -> FlowFileQueuesApiDispatch<'_>

Access the FlowFileQueues API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn funnels_api(&self) -> FunnelsApiDispatch<'_>

Access the Funnels API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn inputports_api(&self) -> InputPortsApiDispatch<'_>

Access the InputPorts API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn labels_api(&self) -> LabelsApiDispatch<'_>

Access the Labels API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn outputports_api(&self) -> OutputPortsApiDispatch<'_>

Access the OutputPorts API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn parametercontexts_api(&self) -> ParameterContextsApiDispatch<'_>

Access the ParameterContexts API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn parameterproviders_api(&self) -> ParameterProvidersApiDispatch<'_>

Access the ParameterProviders API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn policies_api(&self) -> PoliciesApiDispatch<'_>

Access the Policies API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn processgroups_api(&self) -> ProcessGroupsApiDispatch<'_>

Access the ProcessGroups API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn processors_api(&self) -> ProcessorsApiDispatch<'_>

Access the Processors API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn provenance_api(&self) -> ProvenanceApiDispatch<'_>

Access the Provenance API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn provenanceevents_api(&self) -> ProvenanceEventsApiDispatch<'_>

Access the ProvenanceEvents API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn remoteprocessgroups_api(&self) -> RemoteProcessGroupsApiDispatch<'_>

Access the RemoteProcessGroups API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn reportingtasks_api(&self) -> ReportingTasksApiDispatch<'_>

Access the ReportingTasks API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn resources_api(&self) -> ResourcesApiDispatch<'_>

Access the Resources API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn sitetosite_api(&self) -> SiteToSiteApiDispatch<'_>

Access the SiteToSite API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn snippets_api(&self) -> SnippetsApiDispatch<'_>

Access the Snippets API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn systemdiagnostics_api(&self) -> SystemDiagnosticsApiDispatch<'_>

Access the SystemDiagnostics API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn tenants_api(&self) -> TenantsApiDispatch<'_>

Access the Tenants API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Source

pub fn versions_api(&self) -> VersionsApiDispatch<'_>

Access the Versions API with dynamic dispatch.

§Panics

Panics if the NiFi version has not been detected yet. Call login() or detect_version() first.

Methods from Deref<Target = NifiClient>§

Source

pub async fn token(&self) -> Option<String>

Return the current bearer token, if one has been set.

The token is a NiFi-issued JWT. You can persist it between process restarts and restore it with set_token to avoid re-authenticating. The token will eventually expire (NiFi default: 12 hours); when it does, any API call returns NifiError::Unauthorized. Re-call login to obtain a fresh token.

Source

pub async fn set_token(&self, token: String)

Restore a previously obtained bearer token.

Useful for CLI tools that persist the token in a file between sessions. If the token has expired, the next API call will return NifiError::Unauthorized; re-call login to obtain a fresh one.

Source

pub async fn logout(&self) -> Result<(), NifiError>

Invalidate the current bearer token and clear it from the client.

Sends DELETE /nifi-api/access/logout to invalidate the token server-side, then clears the local token unconditionally so that subsequent requests are not sent with a stale credential.

If the server returns an error (e.g. 401 because the token had already expired) the local token is still cleared and the error is returned to the caller.

Source

pub async fn login( &self, username: &str, password: &str, ) -> Result<(), NifiError>

Authenticate with NiFi using single-user credentials.

Obtains a JWT token from /nifi-api/access/token and stores it on the client for all subsequent requests.

§Token lifetime and expiry

NiFi JWTs expire after 12 hours by default (configurable server-side via nifi.security.user.login.identity.provider.expiration). Once expired, any API call returns NifiError::Unauthorized. Configure a CredentialProvider on the builder to enable automatic token refresh on 401 responses.

Source

pub async fn login_with_provider(&self) -> Result<(), NifiError>

Authenticate using the configured CredentialProvider.

Returns NifiError::Auth if no credential provider has been configured.

Trait Implementations§

Source§

impl Debug for DynamicClient

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deref for DynamicClient

Source§

type Target = NifiClient

The resulting type after dereferencing.
Source§

fn deref(&self) -> &NifiClient

Dereferences the value.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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