Hamza bekkouri
Hamza bekkouri

Reputation: 21

Remove property from processor with nipyapi

Nipyapi version: lastest

NiFi version: 1.11

NiFi-Registry version

Python version: 3.7

Operating System: ubuntu

Description

I want to delete specific props inside RouteOnAttribute by nipyapi, please how I can do it, what is the solution to delete properties inside the config of the processor.

What I Did

PropertyValue

Routing Strategy                                       Route to Property name
p10001                                                 ${project_id:matches('p10001')}
p11012                                                 ${project_id:matches('p11012')}

I want to delete for example all this :

Instead of clicking on the remove, do it with nipyapi !!

p11012                                                 ${project_id:matches('p11012')}  [remove]

Upvotes: 0

Views: 370

Answers (1)

Chaffelson
Chaffelson

Reputation: 1269

Here is the answer I provided on the Github issue against future need:

from nipyapi import canvas, nifi
# Test adding a custom Property
test_prop = {conftest.test_basename: 'test'}
_ = r1.component.config.properties.update(test_prop)
r2 = canvas.update_processor(
    r1,
    nifi.ProcessorConfigDTO(properties=r1.component.config.properties)
)
assert conftest.test_basename in r2.component.config.properties.keys()
# Test removing a property
r3 = canvas.update_processor(
    r2,
    nifi.ProcessorConfigDTO(properties={conftest.test_basename: None})
)
assert conftest.test_basename not in r3.component.config.properties.keys()

Upvotes: 0

Related Questions