Test Case Title |
TC2.25 - Creating a MicroService for IOT App by Exploiting RestCall APIs services |
Goal |
I can: Register an external service as a Rest Call Create a microservice starting from a rest call of an external MicroService build IoT applications using Microservices performing RestCall in simple manner |
Prerequisites |
Using a PC or Mobile with a web browser. Simple skill on use IotBlocks on Nodered. The following functionalities are available only for specific Snap4city users with specific privileges. |
Expected successful result |
Being able to implement your IoT application quickly and easily |
Example 1: Create a Microservice from an external Rest Call (Method Get No Authorization)
- For this example we use the Rest Call https://servicemap.disit.org/WebAppGrafo/api/v1/feedback/last/, a Smart City API to request the last feedback sent by the users to service map.
- The Rest Call needs as parameters the format of the response and the language of the user.
- To create the microservice, make the login on the snap4city portal
- Click on the ‘Resource Manager: Process Loader > MicroServices fot IOT Applications’ menu to view all own resources and the related metadata
- Click on the Button (‘Add Microservice') button
Fig: Upload button.
- A pop up will open: fill the fields and press the ‘Confirm’ button. For example, if you want to create a Microservice:
- App Type: Microservice
- Description: Retrieve last feedback sent by the user
- Nature: Services
- Sub-Nature: Feedback
- Micro Service Title: last-feeback
- Help: Retrieve last feedback sent by the user
- url: https://servicemap.disit.org/WebAppGrafo/api/v1/feedback/last/
- parameter1: format
- parameter2: lang
- Method: GET
- Authentication: No
- When the confirm button is clicked the Microservices is created and a Final User can publish it and then import it directly into an IoT App:
- For the publication of the microservice it is necessary that the license given is public and this can be done by writing Public in the field of the license.
- You can then press the button that says NO in the Published column. A confirmation will be requested and the user will have to press the Confirm button.
- Once the user has published the service, he can import it autonomously into his own Iot Application, through the Import External Microservices menu.
- Click on the name of your microservice and next to install
- After the correct installation message has been shown at the top of the page, you can search for the node in the left side menu to use it.
- And in this example we create a simple flow to show the functionalities offers by this microservice. Inserting these configurations:
- And create this simple flow:
- Pressing on the button of the node labelled as timestamp, in the debug tab it is possible to see the result of the Rest Call:
Example 2: Create a Microservice from a Rest Call (Method Get WITH AUTHORIZATION)
- Follow the previous example until the point 5.
- A pop up will open: fill the fields and press the ‘Confirm’ button. For example, if you want to create a Microservice:
- App Type: Microservice
- Description: Retrieve last tweet and retweet related to a channel
- Nature: Services
- Sub-Nature: Social Media
- Micro Service Title: twitter-last-channel
- Help: Retrieve last tweet and retweet related to a channel
- url: https://www.disit.org/rttv/query/select.php
- parameter: TwRtwChannel
- Method: GET
- Authentication: Yes
- When the confirm button is clicked the Microservices is created and a Final User can publish it and then import it directly into an IoT App:
- For the publication of the microservice it is necessary that the license given is public and this can be done by writing Public in the field of the license.
- You can then press the button that says NO in the Published column. A confirmation will be requested and the user will have to press the Confirm button.
- Once the user has published the service, he can import it autonomously into his own Iot Application, through the Import External Microservices menu.
- Click on the name of your microservice and next to install
- After the correct installation message has been shown at the top of the page, you can search for the node in the left side menu to use it.
- Differently to the previous node in this case in the configuration tab must be inserted also the username and the password to allow the access to the rest call
- Creating a simple flow like the previous:
- Pressing on the button of the node labelled as timestamp, in the debug tab it is possible to see the result of the Rest Call:
Comments
How to use Micro service data
neeraj.negi - Fri, 11/01/2019 - 10:26Hi,
I would like to know how we can use data returned by Micro service inside the dashboard. Which node we should we use inside IOT application flow for that. I want to simply dispaly all the data returend by micro service into the snap4city dashboard. can you guys share a sample node-red flow for the same.
Thanks & Regards
you have to use the
roottooladmin1 - Fri, 11/01/2019 - 20:15you have to use the microseerevices of the group "S4C Dashboard".
Input nodes with PIN on rights are for collecting data from dashboard to the IOT App.
Output nodes with PIN on left are for rendering data from the IOT App to the Dashboard.