<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adinarayana Pulaparthi on Medium]]></title>
        <description><![CDATA[Stories by Adinarayana Pulaparthi on Medium]]></description>
        <link>https://medium.com/@adi.narayana.bits.iisc?source=rss-3ca49c715785------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FY51CGmBBJkv6DqUqJjwaw.jpeg</url>
            <title>Stories by Adinarayana Pulaparthi on Medium</title>
            <link>https://medium.com/@adi.narayana.bits.iisc?source=rss-3ca49c715785------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 10:49:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adi.narayana.bits.iisc/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[DataWeave and some basic functions: part 1]]></title>
            <link>https://medium.com/@adi.narayana.bits.iisc/dataweave-and-some-basic-functions-413dcff0305e?source=rss-3ca49c715785------2</link>
            <guid isPermaLink="false">https://medium.com/p/413dcff0305e</guid>
            <category><![CDATA[data-formats]]></category>
            <category><![CDATA[data-transformation]]></category>
            <category><![CDATA[filter-function]]></category>
            <category><![CDATA[dataweave]]></category>
            <category><![CDATA[map-function]]></category>
            <dc:creator><![CDATA[Adinarayana Pulaparthi]]></dc:creator>
            <pubDate>Thu, 14 Dec 2023 12:21:39 GMT</pubDate>
            <atom:updated>2023-12-15T12:19:59.025Z</atom:updated>
            <content:encoded><![CDATA[<p>DataWeave is a programming language which is mainly used for transforming data. It is also used as the Mule Expression Language to configure various connectors and relevant components while implementing any Mule Application. DataWeave can be used to do transformations on various Data formats like JSON, XML and CSV.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*D1LWHztAs8hTUzhRWphOGw.jpeg" /><figcaption>DataWeave Transformation</figcaption></figure><blockquote>Some basic transformation functions in DataWeave are as follows:</blockquote><h4>1. filter:</h4><p><em>filter </em>function takes an Array of records as input and filters that array based on an particular <em>Boolean</em> condition. Only records which satisfy that particular <em>Boolean</em> condition will be returned as an Array.</p><p><em>filter </em>function is the part of the Core(<em>dw::Core</em>) module in DataWeave, therefore it is automatically imported in the DataWeave scripts.</p><p><strong>Example:</strong></p><p><em>Input:</em></p><pre>[<br>    {<br>        &quot;name&quot;: &quot;Adi&quot;,<br>        &quot;age&quot;: 35<br>    },<br>    {<br>        &quot;name&quot;: &quot;Baba&quot;,<br>        &quot;age&quot;: 25<br>    },<br>    {<br>        &quot;name&quot;: &quot;Sai&quot;,<br>        &quot;age&quot;: 30<br>    },<br>    {<br>        &quot;name&quot;: &quot;Suresh&quot;,<br>        &quot;age&quot;: 27<br>    }  <br>]</pre><p><em>Output:</em></p><pre>[<br>  {<br>    &quot;name&quot;: &quot;Baba&quot;,<br>    &quot;age&quot;: 25<br>  },<br>  {<br>    &quot;name&quot;: &quot;Sai&quot;,<br>    &quot;age&quot;: 30<br>  },<br>  {<br>    &quot;name&quot;: &quot;Suresh&quot;,<br>    &quot;age&quot;: 27<br>  }<br>]</pre><p><em>DataWeave Script:</em></p><pre>%dw 2.0<br>output application/json<br>---<br>payload filter ((item, index) -&gt; (item.age&lt; 31))</pre><p><em>Explanation:</em></p><p>The above DataWeave script will filter records from the input and returns an array of records which has “age” less than 31.</p><h4><em>2. map:</em></h4><p><em>map </em>function takes an Array of records as input and iterates over each record. Each iteration will modify a particular records and finally returns an Array of modified records. Here, input and output, both are Array of records.</p><p><em>map </em>function is the part of the Core(<em>dw::Core</em>) module in DataWeave, therefore it is automatically imported in the DataWeave scripts.</p><p><strong>Example:</strong></p><p><em>Input:</em></p><pre>[<br>    {<br>        &quot;name&quot;: &quot;Adi&quot;,<br>        &quot;age&quot;: 35<br>    },<br>    {<br>        &quot;name&quot;: &quot;Baba&quot;,<br>        &quot;age&quot;: 25<br>    },<br>    {<br>        &quot;name&quot;: &quot;Sai&quot;,<br>        &quot;age&quot;: 30<br>    },<br>    {<br>        &quot;name&quot;: &quot;Suresh&quot;,<br>        &quot;age&quot;: 27<br>    }  <br>]</pre><p><em>Output:</em></p><pre>[<br>  {<br>    &quot;name-age&quot;: &quot;Adi35&quot;<br>  },<br>  {<br>    &quot;name-age&quot;: &quot;Baba25&quot;<br>  },<br>  {<br>    &quot;name-age&quot;: &quot;Sai30&quot;<br>  },<br>  {<br>    &quot;name-age&quot;: &quot;Suresh27&quot;<br>  }<br>]</pre><p><em>DataWeave Script:</em></p><pre>%dw 2.0<br>output application/json<br>---<br>payload map ((item, index) -&gt; {&quot;name-age&quot;: item.name ++ item.age})</pre><p><em>Explanation:</em></p><p>The above DataWeave script will iterate over each object in the input and create a new object which concatenates name and age fields.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*zhoLJzJtwIgsUIIvY7fFWA.jpeg" /><figcaption>DataWeave functions discussed here</figcaption></figure><h4>3. filterObject</h4><p><em>filterObject </em>function takes an Object of key-value pairs as input and filters them using a <em>Boolean </em>expression. It finally returns a new object with key-value pairs which satisfy the given <em>Boolean </em>condition. Both, input and output, are objects.</p><p><em>filterObject </em>function is the part of the Core(<em>dw::Core</em>) module in DataWeave, therefore it is automatically imported in the DataWeave scripts.</p><p><strong>Example:</strong></p><p><em>Input:</em></p><pre>{<br>    &quot;name&quot;: &quot;Adi&quot;,<br>    &quot;age&quot;: 35,<br>    &quot;height&quot;: 176,<br>    &quot;speed&quot;: &quot;100 kmph&quot;,<br>    &quot;power&quot;: &quot;magic-resistance&quot;,<br>    &quot;alias&quot;: &quot;anti-mage&quot;<br>}</pre><p><em>Output:</em></p><pre>{<br>  &quot;name&quot;: &quot;Adi&quot;,<br>  &quot;age&quot;: 35,<br>  &quot;height&quot;: 176<br>}</pre><p><em>DataWeave Script:</em></p><pre>%dw 2.0<br>output application/json<br>---<br>payload filterObject ((value, key, index) -&gt; index &lt;3)</pre><p><em>Explanation:</em></p><p>The above DataWeave script will iterate over each key-value pair in the input and create a new object of key-value pairs based on the given <em>Boolean </em>condition i.e. key-value pairs having index less than 3.</p><h4>4. mapObject</h4><p><em>mapObject </em>function takes an Object of key-value pairs as input and iterates over each key-value pair. Each iteration will modify that key-value pair and finally returns a new object with new key-value pairs. Both, input and output, are objects.</p><p><em>mapObject </em>function is the part of the Core(<em>dw::Core</em>) module in DataWeave, therefore it is automatically imported in the DataWeave scripts.</p><p><strong>Example:</strong></p><p><em>Input:</em></p><pre>{<br>    &quot;name&quot;: &quot;Adi&quot;,<br>    &quot;age&quot;: 35,<br>    &quot;height&quot;: 176,<br>    &quot;speed&quot;: &quot;100 kmph&quot;,<br>    &quot;power&quot;: &quot;magic-resistance&quot;,<br>    &quot;alias&quot;: &quot;anti-mage&quot;<br>}</pre><p><em>Output:</em></p><pre>{<br>  &quot;Adi&quot;: &quot;name&quot;,<br>  &quot;35&quot;: &quot;age&quot;,<br>  &quot;176&quot;: &quot;height&quot;,<br>  &quot;100 kmph&quot;: &quot;speed&quot;,<br>  &quot;magic-resistance&quot;: &quot;power&quot;,<br>  &quot;anti-mage&quot;: &quot;alias&quot;<br>}</pre><p><em>DataWeave Script:</em></p><pre>%dw 2.0<br>output application/json<br>---<br>payload mapObject ((value, key, index) -&gt; {(value): (key)})</pre><p><em>Explanation:</em></p><p>The above DataWeave script will iterate over each key-value pair in the input and map them to create a new object of key-value pairs where the <em>key </em>and <em>value </em>are swapped.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=413dcff0305e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[API gateway]]></title>
            <link>https://medium.com/@adi.narayana.bits.iisc/api-gateway-fbf40e359146?source=rss-3ca49c715785------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbf40e359146</guid>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[flex-gateway]]></category>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[mulesoft]]></category>
            <dc:creator><![CDATA[Adinarayana Pulaparthi]]></dc:creator>
            <pubDate>Thu, 14 Dec 2023 11:45:07 GMT</pubDate>
            <atom:updated>2023-12-20T15:19:54.849Z</atom:updated>
            <content:encoded><![CDATA[<h3>API gateway: Mule Gateway and Flex Gateway</h3><p>An API Gateway intermediates between a client application and a set of microservices, or backend APIs. The API gateway hides all the abstract details from the consumer. Some examples include the Amazon API Gateway, Kong, and Envoy.</p><p>Gateway can impose various restrictions and policies on the back-end APIs to ensure they are well-managed and secured. Some of the responsibilities of a Gateway include request routing, rate limiting, caching, authentication, authorization, traffic management, security, monitoring, and logging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*j-Xva50YWainaVMXISgY3Q.jpeg" /><figcaption>API Gateway</figcaption></figure><p>Mulesoft provides two types of Gateways. They are Mule Gateway and Flex Gateway. Mule Gateway is provided by MuleSoft as an in-built service. However, the Flex Gateway has to be configured externally.</p><blockquote><strong><em>Mule Gateway:</em></strong></blockquote><p>Mule Gateway is integrated into the Mule runtime engine. To assist you in separating orchestration from implementation, Mule Gateway enables you to install a specialized orchestration layer on top of your backend APIs and services. Throttling, rate limitation, caching, authentication, authorization, security, monitoring, and logging are just a few of the features you may use API Manager’s governance capabilities for.</p><blockquote><strong><em>Flex Gateway:</em></strong></blockquote><p>Anypoint Flex Gateway is a high-speed and lightweight Envoy-based API gateway built to manage and secure APIs accessible from any location. Flex Gateway is a gateway similar to the Mule Gateway. Anypoint Flex Gateway delivers the performance needed for the most demanding applications and microservices while ensuring enterprise security and manageability in any environment. It is designed to connect to DevOps and CI/CD workflows easily.</p><p>Flex Gateway can be deployed in two ways, as follows(click on the below link for set up page):</p><ol><li><a href="https://medium.com/@schalla_7574/anypoint-flex-gateway-in-connected-mode-f8778ba3d238">Connected mode</a></li><li><a href="https://medium.com/@adi.narayana.bits.iisc/flex-gateway-in-local-mode-and-its-set-up-using-docker-container-249936091c82">Local mode</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbf40e359146" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flex Gateway in Local mode using Docker container with Security Policies]]></title>
            <link>https://medium.com/@adi.narayana.bits.iisc/flex-gateway-in-local-mode-and-its-set-up-using-docker-container-249936091c82?source=rss-3ca49c715785------2</link>
            <guid isPermaLink="false">https://medium.com/p/249936091c82</guid>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[security-policy]]></category>
            <category><![CDATA[mulesoft]]></category>
            <category><![CDATA[flex-gateway]]></category>
            <dc:creator><![CDATA[Adinarayana Pulaparthi]]></dc:creator>
            <pubDate>Thu, 14 Dec 2023 09:35:22 GMT</pubDate>
            <atom:updated>2023-12-14T11:44:04.897Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>Flex Gateway in Local mode:</em></strong></blockquote><p>Flex Gateway in Local Mode is mainly managed through a configuration file i.e an YAML file. Using this file we can manage the API instances and associated security policies. Flex Gateway in Local Mode can be used to manage non-Mule APIs independently of the Anypoint control plane. However, we need to register Flex Gateway Local Mode instances with the Anypoint Platform.</p><blockquote><strong>Steps to setup Flex Gateway in Local Mode using Docker container:</strong></blockquote><ol><li>Download the Flex Gateway Docker image using the following command in the command prompt:</li></ol><pre>docker pull mulesoft/flex-gateway:latest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wWf9QAMv1dcxu2yK" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O1aeguHR_6H3sYPi" /></figure><p>2. Since the docker image is downloaded, register the Flex Gateway using Anypoint Platform credentials. Here we can use two ways to register i.e through Connected App or Auth Token.</p><p><em>Using Connected App:</em> Here, we will register the Flex Gateway using the Connected app credentials. Before connecting using the Connected App, make sure that the necessary scopes are added to it. These scopes include View Organisation(General), Profile(OpenId), Manage Servers(Runtime Manager) and Read Servers(Runtime Manager).</p><p>The following command is used to register:</p><pre>docker run --entrypoint flexctl -v &quot;CURRENT-DIRECTORY-PATH&quot;:/registration <br>mulesoft/flex-gateway register <br>--organization=BUSINESS-GROUP-ID <br>--environment=ENVIRONMENT-ID <br>--client-id=CONNECTED-APP-CLIENT-ID <br>--client-secret=CONNECTED-APP-CLIENT-SECRET <br>--output-directory=/registration  FLEX-GATEWAY-NAME</pre><p><em>CURRENT-DIRECTORY-PATH</em> is the path in which the configuration file will be created. <em>BUSINESS-GROUP-ID </em>is the Business group Id of the Anypoint Platform Account that is being used to register the Flex Gateway. <em>ENVIRONMENT-ID </em>is the specific Id that exists for each of the environments where we are registering the Flex Gateway. Since we are using a Connected App to register we need to use the associated client id i.e <em>CONNECTED-APP-CLIENT-ID </em>and client secret i.e <em>CONNECTED-APP-CLIENT-SECRET. FLEX-GATEWAY-NAME </em>is the name of the Flex Gateway with which we are registering it in the Anypoint Platform.</p><p>After completing this step, registration.yaml file will be created in the same folder in which we have executed the above command i.e <em>CURRENT-DIRECTORY-PATH. CURRENT-DIRECTORY-PATH </em>is <em>D:\bnb\Flex-Gateway\Local mode </em>as seen from the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ppgbxpHoRFlvIQ7X" /></figure><p>3. In the <em>CURRENT-DIRECTORY-PATH </em>folder, we need to set up the configuration YAML file. Lets say its <em>config.yaml</em> for this demo. This configuration file is used to set up the properties of the Flex Gateway and also various policies that can be set up. We will discuss how to set up the config.yaml file in the subsequent steps.</p><p>4. Since the registration is completed, we need to start the Flex gateway in the local mode. For that purpose, the following command has to be executed in the command prompt under the same folder where we have installed the Flex gateway i.e <em>CURRENT-DIRECTORY-PATH:</em></p><pre>docker run --rm -v &quot;CURRENT-DIRECTORY-PATH&quot;:/usr/local/share/mulesoft/flex-gateway/conf.d -p 8081:8081 mulesoft/flex-gateway</pre><p>The above command will install the Flex Gateway in the local mode with the port 8081 allocated to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YQAyb00fke_8inmk" /></figure><p>Once the Flex Gateway starts running, it will automatically take the config.yaml file and it will run accordingly. Any changes that are made to the config.yaml will also get reflected in the Flex Gateway automatically.</p><p>5. Basic config.yaml file consists of the following:</p><pre>apiVersion: gateway.mulesoft.com/v1alpha1<br>kind: ApiInstance<br>metadata:<br>  name: flex-proxy-local<br>spec:<br>  address: http://0.0.0.0:8081<br>  services:<br>    api-service:<br>      address: https://&lt;API-SERVICE-URL&gt;/</pre><p>API-SERVICE-URL is the api on which proxy is applied using the Flex Gateway in local mode.</p><p>If we use jsonplaceholder for testing the flex gateway, the config.yaml will look like:</p><pre>apiVersion: gateway.mulesoft.com/v1alpha1<br>kind: ApiInstance<br>metadata:<br>  name: flex-proxy-local<br>spec:<br>  address: http://0.0.0.0:8081<br>  services:<br>    json-place-holder:<br>      address: https://jsonplaceholder.typicode.com/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5li2Y6uKXxcsfrRw" /></figure><p>Using the above code in the config.yaml, we will be adding the new API to the existing Flex gateway. The above snippet will ensure that the Flex Gateway in local mode will act as proxy to the jsonplaceholder website.</p><p>6. As the config.yaml is updated, the Flex gateway in local mode is set up. The following is the direct call to the jsonplaceholder using Postman:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8--7SkhEztHDZ5sm" /></figure><p>Same url can be triggered using the proxy in flex gateway in the local mode:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bP6hVK510sw2hU4N" /></figure><p>Here, the above port 8081 used is set in <em>config.yaml</em> as the part of creating the flex gateway in local mode. So from the above images the record with id equal to 2 is triggered using local proxy, which was created using the Flex Gateway.</p><p>7. Managing multiple APIs using the Flex Gateway in local mode can create conflict because of using the same base uri i.e<em> </em><a href="http://localhost:8081/"><em>http://localhost:8081/</em>.</a> So, to ensure that the proxy is triggering the expected API, we need to add a specific base path to each of the API. The updated config.yaml will look like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZF3_7M5BPAQbFiEC" /></figure><p>In the above image, -path is the base path for all the jsonplaceholder API calls. A successful call to the jsonplaceholder service can be seen below using the /json-api basepath through the proxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tSE5M9js7K1Rj_3M" /></figure><p>This will ensure that there won’t be any conflicts between two API service calls, thus making one instance of Flex Gateway enough for multiple API services as proxy.</p><p><em>8. Adding a policy to the API: </em>The policy can be applied to the API using the Flex Gateway in the local mode using the <em>config.yaml</em> file. For example, lets add basic authentication to the API Specified in the config.yaml. For this purpose, we need to add the following to the config.yaml:</p><pre>  policies:<br>    - policyRef:<br>        name: http-basic-authentication-flex<br>      config:<br>        username: flex-user<br>        password: flex-local-pswd</pre><p>The config.yaml looks like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gK01hMHasdmBpvcL" /></figure><p>To trigger the jsonplaceholder API service in Postman, we need to set the basic authentication using the above credentials. The below image shows setting the basic authentication credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-0i9vo_UO9Qgkw9W" /></figure><p>If we trigger the API service using the local proxy using the basic authentication, the following results can be seen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KyRUKNQ_y90aRfmf" /></figure><p>In this way, the basic authentication can be applied on an API service which is using the Flex Gateway in local mode.</p><p><strong><em>References:</em></strong></p><ol><li><a href="https://docs.mulesoft.com/gateway/1.2/flex-local-manage">Managing Flex Gateway in Local Mode</a></li><li><a href="https://developer.mulesoft.com/tutorials-and-howtos/anypoint-flex-gateway-local-mode-docker-container/">How to install Anypoint Flex Gateway in local mode as a Docker container</a></li><li><a href="https://developer.mulesoft.com/tutorials-and-howtos/anypoint-flex-gateway-local-mode-config-file/">Secure your APIs with Anypoint Flex Gateway in local mode (config file)</a></li><li><a href="https://docs.mulesoft.com/gateway/1.1/flex-local-reg-run-app">Registering and Running in Local Mode with a Connected App</a></li><li><a href="https://docs.mulesoft.com/gateway/1.5/flex-review-prerequisites">Reviewing Prerequisites</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=249936091c82" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>