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
impl DynamicClient
Sourcepub fn new(client: NifiClient) -> Self
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.
Sourcepub fn with_strategy(
client: NifiClient,
strategy: VersionResolutionStrategy,
) -> Self
pub fn with_strategy( client: NifiClient, strategy: VersionResolutionStrategy, ) -> Self
Create a new DynamicClient with a specific version resolution strategy.
See VersionResolutionStrategy for available strategies.
Sourcepub async fn from_client(client: NifiClient) -> Result<Self, NifiError>
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.
Sourcepub async fn detect_version(&self) -> Result<DetectedVersion, NifiError>
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.
Sourcepub fn detected_version(&self) -> DetectedVersion
pub fn detected_version(&self) -> DetectedVersion
Returns the detected NiFi server version, or None if not yet detected.
Sourcepub fn version(&self) -> Option<DetectedVersion>
pub fn version(&self) -> Option<DetectedVersion>
Returns the detected version if available, or None.
Sourcepub fn inner(&self) -> &NifiClient
pub fn inner(&self) -> &NifiClient
Returns a reference to the underlying NifiClient.
Sourcepub fn strategy(&self) -> VersionResolutionStrategy
pub fn strategy(&self) -> VersionResolutionStrategy
Returns the configured version resolution strategy.
Sourcepub async fn login(
&self,
username: &str,
password: &str,
) -> Result<(), NifiError>
pub async fn login( &self, username: &str, password: &str, ) -> Result<(), NifiError>
Authenticate with the NiFi instance and detect the server version.
Sourcepub fn access_api(&self) -> AccessApiDispatch<'_>
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.
Sourcepub fn authentication_api(&self) -> AuthenticationApiDispatch<'_>
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.
Sourcepub fn connections_api(&self) -> ConnectionsApiDispatch<'_>
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.
Sourcepub fn controller_api(&self) -> ControllerApiDispatch<'_>
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.
Sourcepub fn controller_services_api(&self) -> ControllerServicesApiDispatch<'_>
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.
Sourcepub fn counters_api(&self) -> CountersApiDispatch<'_>
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.
Sourcepub fn datatransfer_api(&self) -> DataTransferApiDispatch<'_>
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.
Sourcepub fn flow_api(&self) -> FlowApiDispatch<'_>
pub fn flow_api(&self) -> FlowApiDispatch<'_>
Sourcepub fn flowfilequeues_api(&self) -> FlowFileQueuesApiDispatch<'_>
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.
Sourcepub fn funnels_api(&self) -> FunnelsApiDispatch<'_>
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.
Sourcepub fn inputports_api(&self) -> InputPortsApiDispatch<'_>
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.
Sourcepub fn labels_api(&self) -> LabelsApiDispatch<'_>
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.
Sourcepub fn outputports_api(&self) -> OutputPortsApiDispatch<'_>
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.
Sourcepub fn parametercontexts_api(&self) -> ParameterContextsApiDispatch<'_>
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.
Sourcepub fn parameterproviders_api(&self) -> ParameterProvidersApiDispatch<'_>
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.
Sourcepub fn policies_api(&self) -> PoliciesApiDispatch<'_>
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.
Sourcepub fn processgroups_api(&self) -> ProcessGroupsApiDispatch<'_>
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.
Sourcepub fn processors_api(&self) -> ProcessorsApiDispatch<'_>
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.
Sourcepub fn provenance_api(&self) -> ProvenanceApiDispatch<'_>
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.
Sourcepub fn provenanceevents_api(&self) -> ProvenanceEventsApiDispatch<'_>
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.
Sourcepub fn remoteprocessgroups_api(&self) -> RemoteProcessGroupsApiDispatch<'_>
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.
Sourcepub fn reportingtasks_api(&self) -> ReportingTasksApiDispatch<'_>
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.
Sourcepub fn resources_api(&self) -> ResourcesApiDispatch<'_>
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.
Sourcepub fn sitetosite_api(&self) -> SiteToSiteApiDispatch<'_>
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.
Sourcepub fn snippets_api(&self) -> SnippetsApiDispatch<'_>
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.
Sourcepub fn systemdiagnostics_api(&self) -> SystemDiagnosticsApiDispatch<'_>
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.
Sourcepub fn tenants_api(&self) -> TenantsApiDispatch<'_>
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.
Sourcepub fn versions_api(&self) -> VersionsApiDispatch<'_>
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>§
Sourcepub async fn token(&self) -> Option<String>
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.
Sourcepub async fn set_token(&self, token: String)
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.
Sourcepub async fn logout(&self) -> Result<(), NifiError>
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.
Sourcepub async fn login(
&self,
username: &str,
password: &str,
) -> Result<(), NifiError>
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.
Sourcepub async fn login_with_provider(&self) -> Result<(), NifiError>
pub async fn login_with_provider(&self) -> Result<(), NifiError>
Authenticate using the configured CredentialProvider.
Returns NifiError::Auth if no credential provider has been configured.