Parameters
Parameter context management
For Managing NiFi Parameter Contexts
- nipyapi.parameters.assign_context_to_process_group(pg, context_id, cascade=False)[source]
Assigns a given Parameter Context to a specific Process Group Optionally cascades down to direct children Process Groups
- Parameters:
pg (ProcessGroupEntity) – The Process Group to target
context_id (str) – The ID of the Parameter Context
cascade (bool) – Cascade Parameter Context down to child Process Groups?
- Returns:
The updated Process Group
- Return type:
- nipyapi.parameters.create_parameter_context(name, description=None, parameters=None, inherited_contexts=None)[source]
- Create a new Parameter Context with optional description and
initial Parameters
- Parameters:
name (str) – The Name for the new Context
description (str) – An optional description
parameters (list[ParameterEntity]) – A list of prepared Parameters
inherited_contexts (list[ParameterContextEntity]) – A list of inherited Parameter Contexts
- Returns:
The New Parameter Context
- Return type:
- nipyapi.parameters.delete_asset(context_id, asset_id)[source]
Delete an asset from a parameter context.
- Parameters:
- Returns:
Deleted asset info with keys: id, name
- Return type:
- Raises:
ApiException – If asset not found or delete fails
Example:
>>> result = delete_asset(context_id, asset_id) >>> print(f"Deleted: {result['name']}")
- nipyapi.parameters.delete_parameter_context(context, refresh=True)[source]
Removes a Parameter Context
- Parameters:
context (ParameterContextEntity) – Parameter Context to be deleted
refresh (bool) – Whether to refresh the Context before Deletion
- Returns:
The removed Parameter Context
- Return type:
- nipyapi.parameters.delete_parameter_from_context(context, parameter_name)[source]
Delete a specific Parameter from a Parameter Context :param context: The Parameter Context to Update :type context: ParameterContextEntity :param parameter_name: The Parameter to delete :type parameter_name: str
- Returns:
The updated Parameter Context
- Return type:
- nipyapi.parameters.get_parameter_context(identifier, identifier_type='name', greedy=True)[source]
Gets one or more Parameter Contexts matching a given identifier
- nipyapi.parameters.get_parameter_context_hierarchy(context_id, include_bindings=False, include_parameters=True)[source]
Get the full parameter context inheritance hierarchy.
Traverses from the given context through all inherited contexts, returning a nested structure showing the full hierarchy.
- Parameters:
context_id (str) – The ID of the root parameter context
include_bindings (bool) – If True, include bound_process_groups for each context showing which process groups are using it. Useful for determining cleanup safety. Default: False
include_parameters (bool) – If True, include parameter details for each context. Set to False for a lightweight structure-only view. Default: True (backwards compatible)
- Returns:
- Hierarchy with keys:
id: Context ID
name: Context name
- parameters: List of parameter info dicts (if include_parameters=True)
Each parameter dict contains: name, description, sensitive, value, has_asset, asset_name
inherited: List of child hierarchy dicts (recursive)
bound_process_groups: List of {id, name} dicts (if include_bindings=True)
- Return type:
Example:
>>> # Get full hierarchy with parameters >>> hierarchy = get_parameter_context_hierarchy(context_id) >>> print(hierarchy['name']) # "PostgreSQL Ingestion Parameters" >>> print(hierarchy['inherited'][0]['name']) # "PostgreSQL Destination Parameters" >>> # Get structure with bindings for cleanup analysis >>> hierarchy = get_parameter_context_hierarchy( ... context_id, include_bindings=True, include_parameters=False ... ) >>> for ctx in [hierarchy] + hierarchy['inherited']: ... bindings = len(ctx.get('bound_process_groups', [])) ... print(f"{ctx['name']}: {bindings} bindings")
- nipyapi.parameters.get_parameter_ownership_map(context_id)[source]
Build a map of parameter names to their owning context.
Traverses the inheritance hierarchy and returns information about where each parameter is defined (its “owner”), including metadata needed for safe updates.
- Parameters:
context_id (str) – The ID of the root parameter context
- Returns:
dict mapping parameter names to ownership info dicts. Each ownership dict has: context_id, context_name, sensitive, has_asset, asset_name, and current_value (None if sensitive).
Example:
>>> ownership = get_parameter_ownership_map(context_id) >>> print(ownership["PostgreSQL Username"]) {'context_id': '...', 'context_name': 'PostgreSQL Source Parameters', ...}
- nipyapi.parameters.list_all_parameter_contexts()[source]
Lists all Parameter Contexts available on the Canvas
- Returns:
list(ParameterContextEntity)
- nipyapi.parameters.list_assets(context_id)[source]
List all assets in a parameter context.
- Parameters:
context_id (str) – The parameter context ID
- Returns:
List of asset info dicts with keys: id, name, digest, missing_content
- Return type:
Example:
>>> assets = list_assets(context_id) >>> for asset in assets: ... print(f"{asset['name']} ({asset['id']})")
- nipyapi.parameters.list_orphaned_contexts()[source]
Lists Parameter Contexts that are not bound to any Process Groups.
An orphaned context is one that exists but has no process groups referencing it. These may be safe to delete after cleanup operations.
- Returns:
Contexts with no bound process groups
- Return type:
- nipyapi.parameters.prepare_parameter(name, value, description=None, sensitive=False)[source]
Parses basic inputs into a Parameter object ready for submission
- Parameters:
- Returns:
The ParameterEntity ready for use
- Return type:
- nipyapi.parameters.prepare_parameter_with_asset(name, asset_id, asset_name, description=None)[source]
Prepare a parameter that references an asset.
Use this to update a parameter to point to an uploaded asset.
- Parameters:
- Returns:
- ParameterEntity ready for
use with update_parameter_context or upsert_parameter_to_context
- Return type:
Example:
>>> # Upload asset first >>> asset = upload_asset(context_id, file_path="/path/to/driver.jar") >>> # Then prepare parameter to reference it >>> param = prepare_parameter_with_asset( ... name="JDBC Driver", ... asset_id=asset['id'], ... asset_name=asset['name'] ... ) >>> # Update the parameter context >>> upsert_parameter_to_context(context, param)
- nipyapi.parameters.remove_context_from_process_group(pg)[source]
Clears any Parameter Context from the given Process Group
- Parameters:
pg (ProcessGroupEntity) – The Process Group to target
- Returns:
The updated Process Group
- Return type:
- nipyapi.parameters.update_parameter_context(context)[source]
Update an already existing Parameter Context
- Parameters:
context (ParameterContextEntity) – Parameter Context updated to be applied
refresh (bool) – Whether to refresh the object before Updating
- Returns:
The updated Parameter Context
- Return type:
- nipyapi.parameters.update_parameter_in_context(context_id, param_name, value, create_if_missing=False)[source]
Update a parameter in a specific context, with safety checks.
By default, this function will only update a parameter that already exists in the specified context. This prevents accidental creation of shadowing parameters in inherited hierarchies.
- Parameters:
- Returns:
Updated context
- Return type:
- Raises:
ValueError – If parameter not found and create_if_missing=False
ValueError – If context not found
Example:
>>> # Safe update - only if param exists in this context >>> update_parameter_in_context(ctx_id, "Username", "newuser") >>> # Create if missing (use with caution - may shadow inherited params) >>> update_parameter_in_context(ctx_id, "NewParam", "value", create_if_missing=True)
- nipyapi.parameters.upload_asset(context_id, file_path=None, file_bytes=None, filename=None)[source]
Upload an asset to a parameter context.
- Parameters:
- Returns:
Asset info with keys: id, name, digest
- Return type:
- Raises:
ValueError – If neither file_path nor file_bytes provided
ValueError – If filename not provided when using file_bytes
Example:
>>> # Upload from file path >>> asset = upload_asset(context_id, file_path="/path/to/driver.jar") >>> # Upload from bytes with explicit filename >>> asset = upload_asset(context_id, file_bytes=data, filename="driver.jar")
- nipyapi.parameters.upsert_parameter_to_context(context, parameter)[source]
Insert or Update Parameter within a Parameter Context
- Parameters:
context (ParameterContextEntity) – The Parameter Context to Modify
parameter (ParameterEntity) – The ParameterEntity to insert or update
- Returns:
The updated Parameter Context
- Return type: