Call Python Script
#
IntroductionNow that we have created the Jetlet "Python Sink" in the last lesson we will use it in this lesson and see what can be done with it, namely manipulate incoming string data with the function we declared, which is to convert said string data to UPPERCASE. This is a small example of what can be done with Jetlets but it serves as an introduction into the world of encapsulation within the Jetic platform.
#
VisionsCorp’s requestAs we learned in the last lesson, VisionsCorp has a need to change incoming string data using Python with one of Python's native functions. VisionsCorp has tasked us to find a way to do such a thing and thereby the creation of a Jetlet (that we did in the last lesson) has enabled us with the tooling to accomplish such a task.
- Timer
- Set Body
- Log
- POST (REST API)
#
Step 1: Creating the first route- Add a Timer to the first route lane
- For the period add 60000 and a delay of 1000. This declares the timer to fire every minute with a delay of a second each time.
- After the timer component add a Set Body component. In the EXPRESSION body add UPPERCASE
- After Set Body add out Jetlet: Python Sink
- Add a Log after with the Message Python script returned: ${body}
#
Step 2: Creating the POST API- Click on APIs in the left sidebar
- Create a new API titles pythontransform
- For the host add python.devdemo.jetic.io
- For the route add a /process POST Process
- Click on Traits in the left sidebar
- Find the Ingress section and open it with the arrow
- Check Enabled and Host and for the Host add python.devdemo.jetic.io
#
Step 3: Use the POST API and create the second routeGo back to the APIs section and drag the Rest API POST that we just created into the second swing lane
Make sure the ENDPOINT is /process
For the operation name add Process
For both Consumes and Produces add text/html
Check the box next to route-2 to activate the lane
Drag the Jetlet Python Sink under the POST request
Testing the integration
>
🎉 Congratulations you have successfully created your integration with a Jetlet you created. You may decide to test the POST with some service such as Postman and see what the output of your string will be. As you continue creating Jetlets and making new routes you will start to discover novel and interesting things you can do with Jetic. 🎉