In the Onesait Platform, there is you have the posibility possibility to create our your own custom configurations. Lets In this example, we will see how to do so create a custom configuration and how to use them it in the FlowEngine. This will allow us allows you to have everything related with to configuration centraliced just in one placecentralized in a single point.
Instructions
Create a custom configuration
...
:
...
In 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
...
the configuration from the FlowEngine
...
: To read the configuration
...
, use the Onesait
...
Platform Management API. The FlowEngine already has a node
...
that will facilitate the calls to that API, and you only have to select
...
the operation
...
that you want to execute. You are going to create a subflow that will be in charge of reloading the configuration to global variables
...
within your flows.
Create a subflow:
This will open a new tab.
...
If you double
...
click on it,
...
you can change
...
the name to “Load Config”.
After
...
this, you are going to define
...
an input and
...
an output:
...
These represent the input and output pins of
...
your subflow node.
Get a valid
...
OAuth token:
...
You are going to use an “http request” call to your IM to get it. For more information
...
related to the Identity Manager, take a look at how to use
...
...
, you need to set the request headers and body
...
, using a “function” node
...
like the following:
...
Next, create an “http request” node with the call to the IM:
In this specific case
...
, you are
...
using KeyCloak as
...
IM. The
...
username and password in the authentication are “onesaitplatform” in both cases.
...
After this, you can parse
...
the response into a “function" node and get
...
your OAuth token ready to use in the next call:
Get the configuration
...
:
Once
...
you have
...
the OAuth token,
...
you can retrieve the configuration
...
using
...
your “onesaitplatform-management-Rest-API-
...
invoker” node. Add
...
this node
...
from the palette to the subflow and double click on it to edit it:
Select “Configuration management service“
...
as the API.
Select “getByIdentificationUsingGET” as the
...
operation.
Fill in the
...
required fields of the request. These parameters correspond to the values defined in the configuration that you created in step 1:
The “onesaitplatform-management-Rest-API-
...
invoker” node has
...
several outputs. By hovering the cursor over each one,
...
you will get a tooltip with the description of each
...
one. For simplicity, the top output is the one that will contain the correct answer, and the rest are different types of errors.
...
Add a “function” node
...
in which you can process errors if necessary.
Load
...
configuration into global variables.
Now
...
you are going to process the response from the API
...
to convert it into an object
...
that is
...
easier to use. The
...
management API invocation node will return the configuration
...
in the message,
...
specifically in the
...
“msg.payload.yml
...
" field. The next step
...
is to parse
...
the yaml
...
intto a
...
JSON object.
To do
...
this,
...
add a
...
“yaml" node to the subflow and
...
indicate the field to parse:
The parsed configuration should look like this:
Finally, in a “function” node
...
, read the configuration object and
...
create the global variables you need:
Deploy the changes by clicking on the
...
“deploy” button:
Use the subflow and test the results.
...
Simply create a simple flow
...
that executes the “Load
...
Config” subflow and a “function” node
...
that reads all the global variables to display them:
...
...
Related articles
Filter by label (Content by label) | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
hidden | true |
---|