Skip to content

Commit

Permalink
Merge pull request #1158 from SanojPunchihewa/variable
Browse files Browse the repository at this point in the history
Add variable mediator docs
  • Loading branch information
DinithiDiaz authored Dec 12, 2024
2 parents 967595f + aa3139e commit 019b988
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 1 deletion.
8 changes: 7 additions & 1 deletion en/docs/reference/mediators/about-mediators.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ WSO2 Micro Integrator includes a comprehensive catalog of mediators that provide
<th>Content aware/unaware</th>
</tr>
<tr>
<td rowspan="11">Generic mediators</td>
<td rowspan="12">Generic mediators</td>
<td>
<a href="{{base_path}}/reference/mediators/call-mediator">Call mediator</a>
</td>
<td>Conditionally content-aware</td>
</tr>
<tr>
<td>
<a href="{{base_path}}/reference/mediators/variable-mediator">Variable mediator</a>
</td>
<td>Conditionally content-aware</td>
</tr>
<tr>
<td>
<a href="{{base_path}}/reference/mediators/property-mediator">Property mediator</a>
Expand Down
88 changes: 88 additions & 0 deletions en/docs/reference/mediators/variable-mediator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Variable mediator

The Variable mediator is used to manage variables within a mediation flow. The Variable mediator allows you to set or remove variables, which can then be used later in the mediation flow.

## Syntax

```xml
<variable name="string" [action="set"|"remove"] [type="STRING"|"INTEGER"|"BOOLEAN"|"DOUBLE"|"FLOAT"|"LONG"|"SHORT"|"OM"|"JSON"]
(value="string" | expression="expression") />
```

## Configuration

The parameters available to configure the Variable mediator are as follows:

<table>
<thead>
<tr class="header">
<th>Parameter Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><strong>Action</strong></td>
<td><p>The action to perform on the variable.</p>
<ul>
<li><strong>set</strong>: If this is selected, the variable will be set in the message.</li>
<li><strong>remove</strong>: If this is selected, the variable will be removed from the message.</li>
</ul></td>
</tr>
<tr class="even">
<td><strong>Name</strong></td>
<td><div class="content-wrapper">
<p>The name of the variable. This name uniquely identifies the variable in the mediation flow.</p>
</div></td>
</tr>
<tr class="odd">
<td><strong>Data Type</strong></td>
<td><div class="content-wrapper">
<p>The data type of the variable. Available types are as follows:</p>
<ul>
<li><strong>STRING</strong></li>
<li><strong>INTEGER</strong></li>
<li><strong>BOOLEAN</strong></li>
<li><strong>DOUBLE</strong></li>
<li><strong>FLOAT</strong></li>
<li><strong>LONG</strong></li>
<li><strong>SHORT</strong></li>
<li><p><strong>OM</strong></p></li>
<li><p><strong>JSON</strong></p></li>
</ul>
</td>
</tr>
<tr class="even">
<td><strong>Value</strong></td>
<td>You can give either a static value or a <a href="{{base_path}}/reference/synapse-properties/synapse-expressions">Synapse expression</a>.
</td>
</tr>
</tbody>
</table>

## Examples

### Set a variable with a static value

This example demonstrates setting a variable with a static value.

```xml
<variable name="username" action="set" value="JohnDoe" type="STRING"/>
```

### Set a variable with an expression

This example demonstrates dynamically setting a variable using an expression.

```xml
<variable name="userDataObject" action="set" expression="${payload.user.data}" type="JSON"/>
<variable name="userId" action="set" expression="${payload.user.id}" type="INTEGER"/>
```

### Remove a variable

This example demonstrates removing a variable from the message.

```xml
<variable name="sessionToken" action="remove"/>
```
1 change: 1 addition & 0 deletions en/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ nav:
- Transaction Mediator: reference/mediators/transaction-mediator.md
- URLRewrite Mediator: reference/mediators/urlrewrite-mediator.md
- Validate Mediator: reference/mediators/validate-mediator.md
- Variable Mediator: reference/mediators/variable-mediator.md
- XQuery Mediator: reference/mediators/xquery-mediator.md
- XSLT Mediator: reference/mediators/xslt-mediator.md
- Property Catalog:
Expand Down

0 comments on commit 019b988

Please sign in to comment.