My Python is not great but I would look at NiPyAPI as an example and the NiFi REST API [1] to see how objects are nested. The ProcessorConfigDTO [2] contains a dict of str: PropertyDescriptorDTO at descriptors, so you could iterate over that as you’re asking. For example, the list_sensitive_processors function [3] operates very similarly.
def list_sensitive_processors(pg_id='root', summary=False): """ Returns a flattened list of all Processors on the canvas which have sensitive properties that would need to be managed during deployment Args: pg_id (str): The UUID of the Process Group to start from, defaults to the Canvas root summary (bool): True to return just the list of relevant properties per Processor, False for the full listing Returns: list[ProcessorEntity] or list(dict) """ assert isinstance(pg_id, six.string_types), "pg_id should be a string" assert isinstance(summary, bool) cache = nipyapi.config.cache.get('list_sensitive_processors') if not cache: cache = [] matches = [] proc_list = list_all_processors(pg_id) for proc in proc_list: if proc.component.type in cache: matches.append(proc) else: sensitive_test = False for _, detail in proc.component.config.descriptors.items(): if detail.sensitive is True: sensitive_test = True break if sensitive_test: matches.append(proc) cache.append(str(proc.component.type)) if cache: nipyapi.config.cache['list_sensitive_processors'] = cache if summary: return [ {x.id: [ p for p, q in x.component.config.descriptors.items() if q.sensitive is True]} for x in matches ] return matches [1] https://nifi.apache.org/docs/nifi-docs/rest-api/index.html <https://nifi.apache.org/docs/nifi-docs/rest-api/index.html> [2] https://github.com/Chaffelson/nipyapi/blob/master/nipyapi/nifi/models/processor_config_dto.py <https://github.com/Chaffelson/nipyapi/blob/master/nipyapi/nifi/models/processor_config_dto.py> [3] https://github.com/Chaffelson/nipyapi/blob/master/nipyapi/canvas.py#L225 <https://github.com/Chaffelson/nipyapi/blob/master/nipyapi/canvas.py#L225> Andy LoPresto alopre...@apache.org alopresto.apa...@gmail.com He/Him PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 > On Mar 18, 2020, at 12:12 PM, Eric Chaves <e...@uolet.com> wrote: > > Hi folks, > > I'm trying to write a quick python InvokeProcessorScript where I need to > iterate over all Dynamic Properties from the processor to select just a few > and I'm having some difficulties with the class types between Jython and Java. > > Can someone show me how to iterate over "context.properties" to get each > PropertyDescriptor? > > I'd like do something like this: > for prop in context.properties: > name = prop.name <http://prop.name/> > value = > context.getProperty(prop).evaluateAttributeExpressions(flowFile).getValue() > self.log.info <http://self.log.info/>("attr {name}: > {value}".format(name=name, value=value)) > if prop.dynamic: > if name in lista and re.search(value, filename): > attrMap['TipoArquivo'] = name > else: > attrMap[name] = value > > Cheers