Cloud Managed Network (Meraki) - Transformation
  • 18 Oct 2024
  • Dark
    Light
  • PDF

Cloud Managed Network (Meraki) - Transformation

  • Dark
    Light
  • PDF

Article summary


Next, we’ll take the sample data from our JSON Form and use it to build a Transformation that will break out the individual variables that the child job task will need in our workflow.

Transformation Video

Step 1

From Automation Studio, click the + to open the Create window.

 Step 2

From the dropdown, select Transformation.  Enter the name Lab – Meraki – XX and click Create.

Step 3

The canvas loads with a lot of empty space.  If you would like to remove extra space from your canvas, you can do so by hovering your cursor near the top of the canvas and selecting the trash can icon.   You can also add space to your canvas by hovering your cursor near the top of the canvas and selecting the plus icon.  To zoom in or zoom out, use the Canvas Controls.

Step 4

As you can see, we have an Incoming Schema and and Outgoing Schema.  These schemas will define how data will look before and after it is manipulated.  Let’s start by creating our Incoming Schema.  Hover your cursor over the Add+ button under Incoming Schema and select Incoming Schema.  The Add Incoming Schema window opens.

Step 5

Our Incoming Schema will be created using the sample data from our JSON Form.  Paste the copied data into the window on the right.  The data is also provided below If you do not have your data copied.

 {
 "organizationName": "Itential Workshops",
 "tags": [
 {
 "tag": "tag1"
 },
 {
 "tag": "tag2"
 }
 ],
 "productTypes": [
 "appliance",
 "switch",
 "wireless"
 ],
 "serials": [
 "Q3AL-NE8E-R4K6",
 "Q4AB-J4J8-6BJR"
 ],
 "merakiAdapter": "Meraki",
 "networkName": "my-network",
 "notes": "network notes for me",
 "timeZone": "America/Chicago"
}

Step 6

Because the tags field is optional on our JSON Form, we would like to remove the tags from our data so that they can be handled separately if they are used.  Highlight the tags and delete the data.  Once deleted, click Infer Schema From Example JSON.

Step 7

IAP will digest the sample JSON data, determine the appropriate data types, and create a JSON Schema for it, we just need to add an ID.  In line 2 in the “$id” field, enter formData between the double quotes.  Click Save.  The Incoming Schema has been created.

Step 8

To handle any that are submitted in our form, we will use several methods to extract and format the data.  Methods are low-code drag-and-drop representations of JavaScript methods.   The first method we will use is the getProperty method.  Search for the method and then drag and drop the method onto the canvas.  For information about a method, click the i icon next to the method name to open the JavaScript documentation.  Here you will find a description of the method, as well as its parameters and example configurations.

Step 9

Connect the formData object of the Incoming Schema to the object parameter of the getProperty method by clicking the half circle to the right of the formData object and dragging a line to the half circle to the left of the object parameter.

Step 10

Set the property string of the getProperty method to tags.

Transformation Video - Part 2

Step 11

Add a nullish method to the canvas.

Step 12 

Connect the return of the getProperty method to the a parameter of the nullish method.

Step 13

Set the b parameter of the nullish method to an empty array.

Step 14

Add a map method to the canvas.

Step 15

Connect the return of the nullish method to the array parameter of the map method.

Step 16

The map method requires a callback function, which will execute for each element in the array.   Its return value is added as a single element in the new array.  Click +New Function to edit the callback function on the map method.  The callback function will open in a new tab.

Step 17

Hover your cursor over the three vertical dots next to the function name and select Rename.  Name the callback function extractTags and click Save.

 Step 18

The current value of the incoming schema is the element that is currently being processed, which in our example is the return of the nullish method.  To transform this value, add a getProperty method to the canvas.

Step 19

Connect the currentValue of the Incoming Schema to the object parameter of the getProperty method.

 Step 20

Set the property string of the getProperty method to tag.

 Step 21

Connect the return of the getProperty method to the newValue Outgoing Schema.  

Step 22 

Our callback function is complete, click Save.

 Step 23

To return to the parent Transformation, click on the Lab – Meraki – XX tab. Here you can see that the callback function was added to the map method.

Step 24 

We are ready to build our Outgoing Schema.  Hover your cursor over the Add+ button under Outgoing Schema and select Outgoing Schema

Step 25 

In the Add Outgoing Schema window, enter tags for the “$id” value and array for the “type”.  Click Save.

Step 26 

Connect the return of the map method to the tags Outgoing Schema.

Step 27 

We also need to create Outgoing Schemas for the remaining keys of the formData Incoming Schema.  Select the half circle to the right of the organizationName string of the Incoming schema and drag a line towards the Outgoing schema.  Hover your cursor over the Add+ button under Outgoing Schema and select Outgoing Schema.  An appropriate Outgoing Schema will be generated and connected to the Incoming Schema.

Step 28

Repeat this process to create Outgoing Schemas for the remaining keys of the Incoming Schema.   

Step 29 

Once all Outgoing Schemas have been created, click Save.

Step 30

To preview the format of the outgoing data, click the Run button.

Step 31

The Run Transformation window is populated with the example data used to create the Incoming Schema.  Notice, this schema does not include tag values.  Click the Run button.

Step 32 

The output will display at the bottom of the screen and is what will be passed into our pre-built workflow.  Use the scroll bar to review the output.

 Step 33

We would like to run the Transformation again, this time with data that includes tags.  Copy and paste the data into the Run Transformation window and click the Run button.

{
 "formData": {
 "organizationName": "Itential Workshops",
 "tags": [
 {
 "tag": "tag1"
 },
 {
 "tag": "tag2"
 }
 ],
 "productTypes": [
 "appliance"
 ],
 "serials": [
 "Q3AL-NE8E-R4K6"
 ],
 "merakiAdapter": "Meraki",
 "networkName": "my-network",
 "notes": "network notes for me",
 "timeZone": "America/Chicago"
 }
}

 Step 34

Use the scroll bar to review the output.

 


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.