Double Braces and Input Data

Know the new way of sending information to the components.

Erick Rubiales avatar
Written by Erick Rubiales
Updated over a week ago

IMPORTANT: This documentation has been discontinued. Read the updated Double Braces and Input Data documentation on our new documentation portal.

Nowadays, when it's necessary to send parameters to the components in a dinamic way, you can use the Transformer before each step. But it's with the Double Braces that you have direct access to the JSON object elements ou resend the entire object.

Access to the JSON element

See the following example, that demonstrates how the parameter "zip" passage happens in a default call of REST.

If you have a { "cep": "" }, an object with “url” as base must be created:

{ "url" :  { "cep": "" } }  

Given that, it's necessary to add the Transformer:

On top of using the Transformer, you also must know the syntax of each component, as well as “url.cep”, “body.cep” or “parameters.cep”.

If using the Double Braces resource when the form field indicates support to this resource, what you need to do is simply insert the description of the wanted element for the data to be sent forward:

In this case it wasn't necessary to use the Transformer and that decreased the quantity of steps for the building of your pipeline.

Take a look at the JSON examples below, that show how to access the wanted element with the new resource:

JSON A

{
"cliente": {
"endereco": {
"cep": "04547-130"
}
}
}

Double Braces

https://viacep.com.br/ws/{{ message.cliente.endereco.cep }}/json/

JSON B

{
"clientes": [
{
"nome": "João",
"endereco": {
"cep": "04547-130"
},
{
"nome": "Pedro",
"endereco": {
"cep": "04547-130"
}
}
]
}

Double Braces

https://viacep.com.br/ws/{{ message.clientes[0].endereco.cep }}/json/

Access to the JSON object

With this example, you'll be able to understand the current dispatch of the parameter “body” (object) in a standard call of REST.

Let's say you have { "nome": "", "endereco": { "cep": ""} and must create the new object { "body" : { "nome": "", "endereco": { "cep": ""} } . For that, you have to add the Transformer. Check it out:

Now see how it looks if you use Double Braces when form field indicates support to this resource. All you have to do is describe the wanted element for the data to be sent forward:

Use of functions in elements

Now you know the advantages of using Double Braces, here's another tip: this resource can be combined with the use of functions.

Follow this simple example:

{
"cep": " 04547-130 "
}

You can apply a function to remove the spaces:

https://viacep.com.br/ws/{{ TRIM(message.cep) }}/json/

Click here to know all our functions.

Scopes of Double Braces

Until now you've seen the main scope of the use of Double Braces, applicable to the messages and that solves specific expressions. Know other contexts in which expressions with Double Braces can be used.

  • Account

In the scope of “account” it's possible to access the vault of the Digibee credentials through expressions with Double Braces.

The component accesses the vaults and obtain, in a safe way, the informed values for the credentials during the configuration phase. Many components already have a preprogrammed logic that allows not inly the access, but also the use of the credentials.

Examples:

The database component DB V2 always receives basic-type credentials, accessing the username and password used to authenticate in the database instance.

On the other hand, the component REST V2 uses a set of credentials for application in the API call to be executed. If a basic-type credential is informed to REST V2, then the API call will be made with “basic” authentication. It means that user and password will be informed in a header field (header) with value as base64.

However, there're scenaiors in which the API call requires the custom dispatch of credentials. When that happens, Double Braces expressions with account can be used. Check how the structure looks like:

{{ account.<account label key>.<campo> }}

In the example above, <account label key> is the place where the key must be informed for the wanted account label and <field> is the place where you must inform the field of the credential you want to use.

Currently there're only 2 components that support thys type of expression: REST V2 and Soap V2. It happens because the access to the vault must be done safely, avoiding the leak of credentials. The components were prepared for that and restrict the access to the vault of credentials only in 2 configurable properties - “body” and "headers".

In the example above, REST V2 adds 2 new configurable accounts, denominated “Custom Account #1” and “Custom Account #2”. They can be accessed through the account label keys "custom-1" and "custom-2". That way, the expression with Double Braces to access the field “username” inside the credential informed in “Custom 1” is:

{{ account.custom-1.username }}

To avoid leaking, only the fields "body" and "headers" of the components support access through expressions with Double Braces in Account. If you use these expressions in other fields, an error message will be informed during the pipeline execution.

  • Metadata

The metadata scope allows access to the pipeline metadata.

These are the pieces of information of the pipeline metadata currently supported:

Information about the pipeline

- pipeline.name: name of the pipeline

- pipeline.versionMajor: version major

- pipeline.versionMinor: version minor

- pipeline.realm: name of the Realm

- pipeline.description: description of the pipeline

- pipeline.id: unique ID of the pipeline

Information about the execution configuration

- runtime.consumers: quantity of concurrent executions according to the size of the pipeline

- runtime.actualConsumers: quantity of concurrent executions efectively configurated

- runtime.environment: name of the environment where the pipeline is under execution

Information about the execution environment

- execution.key: unique ID for this pipeline execution

- execution.timeout: configurated timeout for the pipeline

- execution.startTimestamp: time to initiate the pipeline execution (in milliseconds, in "UNIX Epoch" format)

- execution.redelivery: boolean that specifies if it's a new execution or a new try (click here to access the article about Pipeline Engine and understand it better)

Use an expression with Double Braces and metadata to access the necessary information. See this example:

{{ metadata.pipeline.name }}

The name of the pipeline will be solved as a string.

To know which are the functions associated to Double Braces and how to use them, click here to access our other article.

Did this answer your question?