Geração de Código de Cliente em Test & Doc APIS

54

Este novo utilitário consiste em um editor de código de cliente para as APIs das Ontologias nas principais linguagens de programação, assim só teremos que copiar o código que ele gera e inseri-lo em nossos aplicativos.

Para isso devemos acessar a API da Ontologia que queremos invocar. Neste exemplo, será “APARCAMIENTOSPUBLICOSMADRIDES”. Então vamos acessar o menu “API MANAGER” e o submenu “APIs”:

Image 002

Uma vez aqui, vamos para a guia “Minhas inscrições”:Image 005

E nós escolhemos a API que queremos testar. E clique no botão “Test & Doc”:Image 008Aqui temos informações sobre a API e as funções que ela expõe para o seu consumo. Vamos escolher a função “getAll”:Image 011

Em seguida, mostramos as informações referentes a essa função, e na parte direita aparecerá um menu suspenso chamado “Invocação para a API”, no qual escolheremos o idioma que queremos usar para invocar a função:Image 014

E isso gerará o código necessário para invocar a função. Teremos apenas que completar este código usando o token do usuário com o qual estamos logados na parte “x-sofia2-apikey”:Image 017

Criei uma página de exemplo em HTML usando JQuery, para inserir o código que nos gera o método da API, o código HTML usado para o exemplo seria:

<code>

<!DOCTYPE html>
<html>

<head>
<meta charset=”UTF-8″>
<title>Test API</title>
http://code.jquery.com/jquery-2.2.3.min.js

$(document).ready(function() {
$(“#myButton”).click(function() {

var settings = {
“async”: true,
“crossDomain”: true,
“url”: “https://sofia2.com/sib-api/api/v1/aparcamientospublicosmadrides/getAll&#8221;,
“method”: “GET”,
“headers”: {
“x-sofia2-apikey”: “********************”
}
}

$.ajax(settings).done(function (response) {
console.log(response);
var num = response.data.length;
$(“#helloWorldDiv”).html(“Request URL: https://sofia2.com/sib-api/api/v1/aparcamientospublicosmadrides/getAll
Num Result: ” + num);

});

});
});

</head>

<body>
<button id=”myButton”>Test API</button>
</br>
</br>

</body>

</html>

</code>

O resultado pode ser algo assim:

Image 028

Geração de Código de Cliente em Test & Doc APIS

Sofia2 participates in the SESIAD Virtual Laboratory

labVirtual

 

The Virtual Laboratory of the Secretary of State for the Information Society and Digital Agenda (SESIAD) was born under the standard UNE 178104 “Integrated management systems of the smart city” with the aim of becoming a benchmark for national and international platforms, being a place of experimentation in which companies and developers can evaluate the compatibility of their products with different Smart Cities platforms.

 

labVirtual

 

Currently, platforms that participate in the Virtual Laboratory are Sofia2, from Minsait by Indra, SmartBrain from Cellnex and Thinking City from Telefónica. They collaborate with SESIAD contributing their expertise and participating in the improvement of interoperability between platforms.

 

plataformas

 

As we saw in IoT Data Models: Initiatives and Sofia2 Data Model, there are different Initiatives of standardization of a Data Model in IoT. A Data Model represents the structure of your data and relationships, and therefore, organizes the elements and standardizes how they relate to each other.

 

gsma1

 

GSMA and FIWARE Data Models are defined in JSON, so their representation as Sofia2’s Ontology is immediate. We saw how they are supported and how easy it is to work with these entities in Sofia2

 

To achieve better interoperability between platforms, NGSI 9/10 v2 was selected as a common protocol for the Interoperability Layer. We saw in this document how they are supported and how to consume APIS modeled according to the semantic FIWARE Data Model and published in Sofia2 following the NGSI 9/10 v2 protocol.

 

In our experience with the Virtual Laboratory, in addition to making recommendations for new attributes and modifications in the Data Model, we had the opportunity to perform a Proof of Concept (PoC) by creating a connection  and transformation flow of real data from Smart City A Coruña to GSMA/FIWARE Data Model on Sofia2’s Platform.

 

In this example, Smart Coruña parking data is collected and is ingested in an Ontology on the Sofia2’s platform. Each time an instance of this ontology is received, a Script is launched and transforms this data adapting them to the Data Model and, consulting them, we see how, effectively, the Data Models are fulfilled.

 

dataingestGSMA

 

Also in this Proof of Concept we could publish this data through the API MANAGER of Sofia2 to later see that anyone with the proper permits can access this data via API, Curl or through the Virtual Laboratory portal.

 

consumptionGSMA

 

 

All this process is explained in the post Acquisition, transformation and consumption of data with GSMA/FIWARE Data Model, and has been captured in the demonstrator, which, in addition to parking data, collects data from beaches and museums.

 

demostrador

 

You can find all the information related to the SESIAD Virtual Laboratory here, as well as all the necessary tools (Data Model, APIs, Security tokens, examples …) to develop on the platforms complying with this interoperability model here

 

 

 

 

Sofia2 participates in the SESIAD Virtual Laboratory

Beijing Institute of Technology (BIT) meets Sofia2

IMG_20180123_153430862

 

En el marco de colaboración “Winter School” entre la Universidad Politécnica de Madrid (UPM) y el Beijing Institute of Technology (BIT), los estudiantes del BIT visitaron en la tarde de ayer las instalaciones de Indra en Madrid, donde se les presentaron diferentes soluciones tecnológicas de la compañía, destacando el enfoque IoT basado en la plataforma Minsait IoT Sofia2.

 

IoTVision

 

Sebastián Gómez, responsable de Desarrollo de Negocio, y Ayla Ruiz, consultora de la plataforma, pusieron en contexto a los estudiantes definiendo los orígenes, el presente y el futuro de la plataforma, así como las características principales de Sofia2 y sus capacidades

 

IMG_20180123_153430862

 

 

Además, presentaron los diferentes tipos de proyectos a los que aplica Sofia2, y contaron con la ayuda de Mario Briceño y Lucía Fernandez, ingenieros IoT de la plataforma, para explicar ejemplos prácticos de uso y alguna de las diferentes soluciones que existen actualmente que utilizan Sofia2 como base tecnológica.

 

IMG_20180123_160417

 

Los estudiantes del BIT mostraron mucho interés con la posibilidad de crear sus propios proyectos en el entorno de experimentación, disponible en el CloudLab Sofia2

 

¡¡Hasta pronto!!

Beijing Institute of Technology (BIT) meets Sofia2

Beijing Institute of Technology (BIT) meets Sofia2

IMG_20180123_153430862

 

In the context of “Winter School”, the collaboration framework between Polytechnic University of Madrid (UPM) and Beijing Institute of Technology (BIT), students from BIT visited Indra’s facilities in Madrid. Different Indra’s technological solutions were presented, highlighting the IoT approach based on Minsait IoT Sofia2 platform.

 

IoTVision

 

Sebastián Gómez, Business Development manager and Ayla Ruiz, platform consultant, introduced Sofia2 to the students, explaining its origin, present and future, as well as its main characteristics and capabilities.

 

IMG_20180123_153430862

 

They also presented the different types of projects where Sofia2 can be applied. They got help from Mario Briceño and Lucía Fernandez, IoT engineers, to explain practical examples and some of the different solutions that use Sofia2 as a technological base.

 

IMG_20180123_160417

 

BIT students showed great interest in creating their own projects using  CloudLabthe Sofia2’s experimentation environment.

See you soon!!

Beijing Institute of Technology (BIT) meets Sofia2

Acquisition, transformation and consumption of data with GSMA/FIWARE Data Model

dataingestGSMA

 

In the post How to work with Data Model FIWARE/GSMA in Sofia2 we saw how the Sofia2 platform supports the GSMA and FIWARE Data Models. We learned how to create Ontologies according to these models and how to insert data and consult them using the tool available on the BDTR and BDH Console. We also saw how to publish this Ontology as a RESTFul API and how to consume the API.

 

In addition, we have the document Use of FIWARE Data Model and API NGSI9 publication, where we explain how to consume APIS modeled conformant FIWARE Data Model semantics and published in the Platform following the NGSI-9 protocol.

 

For the example, we use the Ontologies:

  • GSMA_OffStreetParking_Destino
  • GSMA_PointOfInterest_Beach
  • GSMA_PointOfInterest_Museum

 

Step by step we explains how to subscribe to these Ontologies, how to consult your Data through the BDTR and BDH Console, how to subscribe to NGSI-9 APIs and consume them through the API Manager developer portal and how to access these APIs via Curl.

 

consumptionGSMA

 

With all this information, and knowing that Sofia2 allows you to create Rules Scripts (it is advisable to read the Scripting Engine Sofia2 User Guide) that will be executed before the arrival of instances of Ontologies or every so often, it is easy to understand how we can receive data with a determined structure and transform them to meet these Data Models.

 

We will check it through the following flow:

 

dataingestGSMA

 

In this example, Smart Coruña car park data is collected, an Ontology is ingested on the Sofia2 platform, each time an instance of this ontology is received, a Script is launched that transforms this data adapting it to the Data Model and consulting it, we see as indeed, it is fulfilled with the GSMA and FIWARE Data Models.

 

ejemploparking1

Acquisition, transformation and consumption of data with GSMA/FIWARE Data Model

Client Code Generation in Test&Doc APIs

54

This new utility consists of a client code editor for the APIs of the Ontologies in the most popular programming languages, in this way we will only have to copy the code that it generates and insert it in our applications.

For this we must access the API of the Ontology that we want to invoke. In this example, it will be “APARCAMIENTOSPUBLICOSMADRIDES “. So we will access the “API MANAGER” menu, and the “APIs” submenu:

Image 001

Once here, we go to “My Subscriptions” tab:Image 004

We choose the API that we want to test. And click on the “Test & Doc” button:Image 007

Here we have information about the API and the functions it exposes for its consumption. We are going to choose the “getAll” function:

Image 010

Next we are shown the information referring to that function, and on the right part a drop-down menu called “API Invocation” will appear, in which we will choose the language we want to use to invoke the function:

Image 013

And this will generate the piece of code needed to invoke the function. We will only have to complete this code using the logged user’s token in the “x-sofia2-apikey” part:

Image 016

I have created a sample page in HTML using JQuery, to insert the code that generates us for the API method, the HTML code used for the example would be:

<code>

<!DOCTYPE html>
<html>

<head>
<meta charset=”UTF-8″>
<title>Test API</title>
http://code.jquery.com/jquery-2.2.3.min.js

$(document).ready(function() {
$(“#myButton”).click(function() {

var settings = {
“async”: true,
“crossDomain”: true,
“url”: “https://sofia2.com/sib-api/api/v1/aparcamientospublicosmadrides/getAll&#8221;,
“method”: “GET”,
“headers”: {
“x-sofia2-apikey”: “********************”
}
}

$.ajax(settings).done(function (response) {
console.log(response);
var num = response.data.length;
$(“#helloWorldDiv”).html(“Request URL: https://sofia2.com/sib-api/api/v1/aparcamientospublicosmadrides/getAll
Num Result: ” + num);

});

});
});

</head>

<body>
<button id=”myButton”>Test API</button>
</br>
</br>

</body>

</html>

</code>

result could be something like this:

Image 028

Client Code Generation in Test&Doc APIs