如何使用rest-api更改Nifi变量注册表 [英] How to change Nifi variable registry using rest-api

查看:95
本文介绍了如何使用rest-api更改Nifi变量注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道可以使用rest-api检索变量注册表中的值,但是有没有办法设置变量值?当我更改变量时,我看到发送了以下POST:

  http://localhost:8080/nifi-api/process-groups/{ID}/variable-registry/update-requests 

但是我不太了解VariableRegistryEntity在哪里发挥作用,或者我将如何处理变量.

更广泛地讲,我想做的是从另一个程序中操作自定义Nifi处理器中的变量,因此,欢迎您提供任何指导或想法.

解决方案

所有变量(键,值)都存储在变量注册表中,并且在我们更新/创建变量,然后在后端进行更新请求rest api调用.

如果您要构建自定义处理器以使用变量,则需要创建处理器启用表达式语言,然后可以引用变量通过使用 nifi表达式语言$ {variable_name} 将在运行时替换为 variable_value .

请参阅

  • 如果尚未定义变量,则使用定义的值创建新变量.
  • 如何获取ClientID?

    您可以进行以下Get Rest api调用:

      curl -X GET< URL>/nifi-api/process-groups/< process-group-id>/variable-registry 

    从响应中,您可以获取clientID详细信息.

    I know it's possible to use the rest-api to retrieve the values in the variable registry, but is there a way to set the variable values? When I change a variable I see that the following POST gets sent:

    http://localhost:8080/nifi-api/process-groups/{ID}/variable-registry/update-requests
    

    but I don't really understand where the VariableRegistryEntity comes into play or how I might go about manipulating the variables.

    More broadly, what I'm trying to do is manipulate variables inside a custom Nifi processor from another program, so any guidance or ideas on how to do that would be welcome.

    解决方案

    All the variables(key,values) are stored in variable registry and when we are updating/creating the variables then we are going to have update-requests rest api call in the back end.

    If you are building custom processor to use the variables then you need to create processor to enable expression language then you can refer the variables by using nifi expression language ${variable_name} will replace with the variable_value at run time.

    Refer to this link for more details regards to variable registry in NiFi

    If you need to update/create any variable in the Nifi you can use below rest api call:

    bash$ curl -i -H 'Content-Type: application/json' -X POST -d '{\
        "processGroupRevision": {\
            "clientId": "<ClientId>",\
            "version": 0\
        },\
        "variableRegistry": {\
            "processGroupId": "<process-group-id>",\
            "variables": [{\
                "variable": {\
                    "name": "<variable-name>",\
                    "value": "<variable-value>"\
                }\
            }]\
        }\
    }' <URL>/nifi-api/process-groups/<process-group-id>/variable-registry/update-requests
    

    This curl call will update the value

    • if variable is already defined and the value got changed and stop and starts all the effected controller services and processor.
    • If the variable is not defined yet then creates new variable with the defined value.

    How to get ClientID?

    you can make the below Get Rest api call:

    curl -X GET <URL>/nifi-api/process-groups/<process-group-id>/variable-registry
    

    from the response you can get the clientID details.

    这篇关于如何使用rest-api更改Nifi变量注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆