Variables are usually defined to hold the parameters to be passed to a microservice. For instance, the port and IP address variables to block for a firewall policy. Variables can also be used to display user information that is not meant to be used for configuring the managed entity.
Setting variables is done from the section "Variables" on the microservice editor screen.
When you create a new microservice, the variable object_id, which is mandatory, will be set and cannot be deleted. It can be edited to set its type and other advanced properties.
All variables are referenced with the prefix $params
which is automatically set in the variable editor screen and when a variable has to be referenced in one of the microservice functions, you need to use the syntax {$params.your_variable}
(see below for more examples).
By default the type of a variable is String but other types are supported such as Integer, Boolean, Password, IpAddress, ObjectRef,…
Overview
The variables are usually defined to hold the parameters to be passed to the microservice. For instance, the port and IP address variables to block for a firewall policy. Variables can also be used to display user information that is not meant to be used for configuring the managed entity.
Setting different types for variables will affect the way the microservice end user form, for creating or updating it, will render.
For instance, the type boolean will render the variable with true/false radio buttons.
Default settings
When creating or editing a variable, there are some information that need to be provided in the "Default" section.
Variable
Name of the variable to use in the implementation of the microservice or when calling the REST API.
Type
The type of the variable should be one from the list below
String
The default type for a variable, it will accepts any value and the UI renders it as a input field without any specific validation with regards to the value set.
Boolean
Accepts a value of true or false, the UI will render it as a checkbox.
Integer
Represents a numerical value, the UI will render it as an input field restricted to integer.
Password
This data type represents a multi-character value that is hidden from plain sight (i.e. the value is represented as asterisks instead of clear text).
IP address and IP mask, IPv6 address
not supported yet |
This data type will enforce data validation against IP address formats.
Composite
Provide the means to add control over the behavior of the microservice user form.
It can be used, for instance, to show/hide part of the form based on the value of another component of the form.
Link
Display a URL in the user form, for instance to link to some documentation on a web server.
It is usually used in read-only mode with the URL set as the default value of the variable
Auto Increment
Maintains an incremental counter within the instances of a microservice for a managed entity. This is useful for managing the object_id.
Increment |
an integer to define the increment step |
Start Increment |
the initial value for the variable |
Microservices sharing the same increment |
a list of microservices that are also using the same variable and need to share a common value. |
Device
This type is used to allow the user to select a managed entity and pass it’s identifier to the implementation of the microservice.
Index
not supported yet |
Microservice Reference
Reference an other microservice from a microservice and use the referenced microservice variable value.
By default the value used from the referenced microservice is the object_id.
The referenced microservice should be configured in the "Advanced" section:
"Microservice Reference" field: enter the name of the microservice to reference. The form field will provide the list of possible microservice to choose from based on the the input value. It is possible to select more that one microservice in order to import values from different part of the configuration imported by the referenced microservice.
Filtering with remote and local variables
You can optionnaly controle the values that matches between the local microservice and the remote one (the one which is referenced).
This works as filtering: it searches the value for local variable and shows the rows which match to the remote.
This is useful if the values to be selected from the referenced microservices have to match the local variables.
Example:
As an example, let’s consider 2 microservices, the first one to configure addresses and the second one to configure group of addresses. The group of addresses will be referencing the addresses.
An address is composed of an IP and a mask and is associated to an interface. A group of addresses will be composed to multiple addresses but the group of address is also associated to an interface.
In this use case, when a group of address is associated to an interface, each addresses selected must be associated to the same interface.
In the screenshot below we can see that "grp1" is associated to interface "port1" and "grp2" is associated to "port2"
The address group microservice variable "Member" is typed as a "Microservice Reference" that points to the address microservice:
In this case, when creating an address group instance, the values available for the variable "$params.members.0.member" will be filtered so that the only one available are the ones with a match between the local variable value and the remote variable value.
If "port1" is selected for the "Associated Interface" then only "addr_port1" will be listed
If not filtering is used (by default):
Display Name
The display value for the variable name.
Description
An optional description of this variable.
Advanced settings
Depending on the selected type, some advanced parameters may be differ.
Setting | Description |
---|---|
Default Value |
the default value that will be used when creating a new microservice instance |
Values for Drop-down |
a list of possible value the user can choose from |
Allow adding free value |
available if some value(s) were provided for drop-down |
Mandatory |
a value has to be provided for this variable |
Read only variable |
the value cannot be edited |
Section Header |
group some variables in the microservice console (see below) |
Group variable |
group some variables in the auto-rendered UI for creating or editing a microservice (see below |
Show only in edit view |
hide the variable from the microservice console |
Group Variables
You can group the variables in the microservice console by setting a section header name. The UI will gather the columns under a common header
It is also possible to group variables to provide a better user experience when creating or editing a microservice and go from a flat view
To a more organized view
Array settings
When you are dealing with variable arrays, these options will let you control the possible actions a user can have over the array.
Variable arrays
To create a variable array, you need to follow a precise naming convention: $params.<ARRAY NAME>.0.<ELEMENT NAME>
. The 0, is the separator that will allow the UI and the configuration engine that this variable is an array.
This type of variables should be used when extracting configuration with an array variable extractor in the Import function of the microservice.