In Onesait Platform, there is the posibility to create our own custom configurations. Lets see how to do so and how to use them in the FlowEngine. This will allow us to have everything related with configuration centraliced just in one place.
Instructions
Create a custom configuration.
On the menu, go to “Dev Tools” → “Centralized configuration”
Create a custom configuration
and fill it with the values you need, following a yaml format:
Read it from the FlowEngine
To read the configuration we can use Onesait Platform’s management API. FlowEngine already has a node that allow us to select which operation to use from the API.
We will rceate a subflow that wil reload al the configuration to global variables in our flows.Create a subflow:
This will open a new tab. By double clicking it, we can change it’s name to “Load Config”
After that, we need to define one input and one outputThis represents the input and output pins of our subflow node.
Get a valid Oauth token: For this purpose we will use a http request to our IM. For more information on this regard, you can check how to use Oauth2 tokens in Platform
First we will need to set the headers and body of the request in a “function” node as follows:Then set up the “http request” node
In this case we are usin KeyCloak as our IM. The authentication user and pasword are “onesaitplatform”.
And after that, we can parse de response and get our Oaut token in an other “function” node:Get the configuration yml.
Once we have our Oauth token, we can retrieve the configuration by using our “onesaitplatform-management-Rest-API-invoker“ node. Add one node form the palette to the subflow and double click on it to edit:Select “Configuration management service“ api
Select the “getByIdentificationUsingGET“ operation
Fill the request params as follows. This parameter values are the ones defined in our previous configuration:
The “onesaitplatform-management-Rest-API-invoker“ node has many outputs. By hovering the cursor over each one, you’ll get a tooltip with the description of each. Simplifying we will consider the top first to be the one were the Oauth token will be retrieved. The rest represent different errors.
We will ad a “function” node to the error output pins, were you can trear the error as needed.
Load the configuration into global variables.
Now it is time to parse the API request response to an object, so it is easy to use. The Manage API node will return the configuration on the message, inside the msg.payload.yml, so next step will be to parse taht yaml into a json object.
To do so, just add a “yml” node to the subflow and set the field to parse:
The parsed configuration should look like this:
Finally, in a “function” node we will read the configuration object and set some global variables:Deploy changes by clicking the “deploy”” button:
Use the subflow and test results.
Just create a simple flow to execute the “Load Config“ subflow and a “function” node to read all global variables:
Artículos Relacionados
Filter by label
There are no items with the selected labels at this time.