About FlowFileSourceResult
Class
nifiapi.flowfilesource.FlowFileSourceResult
The FlowFileSourceResult
class provides an interface for defining relationship, attributes and content of a FlowFile to be created.
Parameters
Name | Type | Description |
---|---|---|
relationship | String | Name of the relationship the FlowFile should be routed to |
attributes | Dictionary; Default None | A key-value pairs representing FlowFile attributes |
contents | Byte Array or String; Default None | Content of the FlowFile |
e.g.:
from nifiapi.flowfilesource import FlowFileSourceResult
return FlowFileSourceResult(
'success',
attributes={},
contents=None
)
If attributes
keyword argument is not provided, a standard set of attributes (filename
, path
and uuid
) will be created regardless. Any additional defined attribute will be appended to that list.
If contents
is not provided, a FlowFile with no contents will be created.
Defining FlowFile attributes
The FlowFileSourceResult
provides an interface to define FlowFile attributes.
Note that all attributes must be represented as strings.
from nifiapi.flowfilesource import (
FlowFileSource,
FlowFileSourceResult,
)
from nifiapi.properties import ProcessContext
class Processor(FlowFileSource):
(...)
def create(self, context: ProcessContext) -> FlowFileSourceResult:
'''
Parameters:
context (ProcessContext)
Returns:
FlowFileSourceResult
'''
return FlowFileSourceResult('success', attributes={
"new_attribute": str(1234)
})
Defining FlowFile content
You define the content of a FlowFile through the FlowFileSourceResult
. Simply pass new value as contents
parameter:
Note that content must be either Byte Array or String type.
from nifiapi.flowfilesource import (
FlowFileSource,
FlowFileSourceResult,
)
from nifiapi.properties import ProcessContext
class Processor(FlowFileSource):
(...)
def create(self, context: ProcessContext) -> FlowFileSourceResult:
'''
Parameters:
context (ProcessContext)
Returns:
FlowFileSourceResult
'''
return FlowFileSourceResult('success', contents="New content")