Skip to content

Commit

Permalink
Merge pull request telefonicaid#1762 from telefonicaid/task/NGSIv2
Browse files Browse the repository at this point in the history
Task/ngsiv2
  • Loading branch information
manucarrace authored Dec 2, 2019
2 parents 8953ca6 + 9b6d90b commit 3339fe5
Show file tree
Hide file tree
Showing 21 changed files with 1,334 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Fix: Changing cygnus port does not work (#1698)
[cygnus-commons][MongoBackend] Proper processing of mongo errors in create index operations (#1756)
[cygnus-ngsi] Support for NGSIv2 notifications (#953)
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ private CommonConstants() {
public static final String HEADER_FIWARE_SERVICE = "fiware-service";
public static final String HEADER_FIWARE_SERVICE_PATH = "fiware-servicepath";
public static final String HEADER_CORRELATOR_ID = "fiware-correlator";
public static final String HEADER_NGSI_VERSION = "ngsiv2-attrsformat";

// Used by CKANBackendImpl... TBD: should not be here!!
public static final String RECV_TIME_TS = "recvTimeTs";
Expand Down
2 changes: 2 additions & 0 deletions cygnus-ngsi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ $ ./notification-json-simple.sh http://localhost:5050/notify myservice myservice

Or you can connect a real NGSI source such as [Orion Context Broker](https://github.com/telefonicaid/fiware-orion). Please, check the [User and Programmer Guide](../doc/cygnus-ngsi/user_and_programmer_guide/connecting_orion.md) for further details.

Support for NGSIv2 notifications has been added from version above 1.17.1. For this purpose, it's been added a new dir [/NGSIv2](./resources/ngsi-examples/NGSIv2) which contains script files in order to emulate some NGSIv2 notification types.

[Top](#top)

### <a name="section2.7"></a>Management API overview
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/sh
# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U
#
# This file is part of fiware-cygnus.
#
# fiware-cygnus is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# fiware-cygnus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with fiware-cygnus. If not, see http://www.gnu.org/licenses/.
#
# For those usages not covered by this license please contact with
# [email protected]

# This script is aimed to Cygnus debugging.

URL=$1

if [ "$2" != "" ]
then
SERVICE=$2
else
SERVICE=default
fi

if [ "$3" != "" ]
then
SERVICE_PATH=$3
else
SERVICE_PATH=/
fi

curl $URL -v -s -S --header 'Content-Type: application/json; charset=utf-8' --header 'Accept: application/json' --header 'User-Agent: orion/0.10.0' --header "Fiware-Service: $SERVICE" --header "Fiware-ServicePath: $SERVICE_PATH" --header "ngsiv2-attrsformat: normalized" -d @- <<EOF
{
"subscriptionId" : "51c0ac9ed714fb3b37d7d5a8",
"data" : [
{
"field1" : {
"type" : "type1",
"value" : { "a": "1", "b": "2" },
"metadata": {}
},
"field2" : {
"type" : "type2",
"value" : [ "v1", "v2" ],
"metadata": {}
},
"type" : "Room",
"id" : "Room2"
}
]
}
EOF
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh
# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U
#
# This file is part of fiware-cygnus.
#
# fiware-cygnus is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# fiware-cygnus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with fiware-cygnus. If not, see http://www.gnu.org/licenses/.
#
# For those usages not covered by this license please contact with
# [email protected]

# This script is aimed to Cygnus debugging.

URL=$1

if [ "$2" != "" ]
then
SERVICE=$2
else
SERVICE=default
fi

if [ "$3" != "" ]
then
SERVICE_PATH=$3
else
SERVICE_PATH=/
fi

curl $URL -v -s -S --header 'Content-Type: application/json; charset=utf-8' --header 'Accept: application/json' --header 'User-Agent: orion/0.10.0' --header "Fiware-Service: $SERVICE" --header "Fiware-ServicePath: $SERVICE_PATH" --header "ngsiv2-attrsformat: normalized" -d @- <<EOF
{
"subscriptionId" : "51c0ac9ed714fb3b37d7d5a8",
"data" : [
{
"temperature" :
{
"type" : "centigrade",
"value" : "26.5",
"metadata": {}
},
"the_geom" :
{
"type" : "geometry",
"value" : "$4, $5",
"metadata": {
"location": {
"type": "string",
"value": "WGS84"
}
}
},
"type" : "Car",
"id" : "Car1"
}
]
}
EOF
70 changes: 70 additions & 0 deletions cygnus-ngsi/resources/ngsi-examples/NGSIv2/notification-json-md.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/sh
# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U
#
# This file is part of fiware-cygnus.
#
# fiware-cygnus is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# fiware-cygnus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with fiware-cygnus. If not, see http://www.gnu.org/licenses/.
#
# For those usages not covered by this license please contact with
# [email protected]

# This script is aimed to Cygnus debugging.

URL=$1

if [ "$2" != "" ]
then
SERVICE=$2
else
SERVICE=default
fi

if [ "$3" != "" ]
then
SERVICE_PATH=$3
else
SERVICE_PATH=/
fi

curl $URL -v -s -S --header 'Content-Type: application/json: charset=utf-8' --header 'Accept: application/json' --header 'User-Agent: orion/0.10.0' --header "Fiware-Service: $SERVICE" --header "Fiware-ServicePath: $SERVICE_PATH" --header "ngsiv2-attrsformat: normalized" -d @- <<EOF
{
"subscriptionId" : "51c0ac9ed714fb3b37d7d5a8",
"data" : [
{
"temperature": {
"type" : "centigrade",
"value" : "26.5",
"metadata": {}
},
"pressure": {
"type" : "mmhg",
"value" : "720",
"metadata": {
"ID": {
"type": "string",
"value": "ground"
}
}
},
"humidity": {
"type" : "percentage",
"value" : "42",
"metadata": {}
},
"type" : "Room",
"id" : "Room1"
}
]
}
EOF
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/bin/sh
# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U
#
# This file is part of fiware-cygnus.
#
# fiware-cygnus is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# fiware-cygnus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with fiware-cygnus. If not, see http://www.gnu.org/licenses/.
#
# For those usages not covered by this license please contact with
# [email protected]

# This script is aimed to Cygnus debugging.

URL=$1

if [ "$2" != "" ]
then
SERVICE=$2
else
SERVICE=default
fi

if [ "$3" != "" ]
then
SERVICE_PATH=$3
else
SERVICE_PATH=/
fi

curl $URL -v -s -S --header 'Content-Type: application/json; charset=utf-8' --header 'Accept: application/json' --header 'User-Agent: orion/0.10.0' --header "Fiware-Service: $SERVICE" --header "Fiware-ServicePath: $SERVICE_PATH" --header "ngsiv2-attrsformat: normalized" -d @- <<EOF
{
"subscriptionId" : "51c0ac9ed714fb3b37d7d5a8",
"data" : [
{
"id": "netrisModel",
"type": "model",
"TimeInstant": {
"type": "ISO8601",
"value": "2014-03-20T14:21:14Z",
"metadata": {}
},
"ModelProp1": {
"type": "String",
"value": "abc",
"metadata": {}
},
"ModelProp2": {
"type": "String",
"value": "def",
"metadata": {}
},
"et": {
"type": "compound",
"value":
{
"name": "external temperature",
"phenomenon": "temperature",
"type": "Quantity",
"uom": "Cel",
"persistence": [ "sth", "ckan" ]
},
"metadata": {}
},
"internal temperature": {
"type": "compound",
"value": [
{
"name": "internal temperature",
"phenomenon": "temperature",
"type": "Quantity",
"uom": "Cel"
}
],
"metadata": {}
},
"h": {
"type": "compound",
"value": [
{
"name": "house humidity",
"phenomenon": "humidity",
"type": "Quantity",
"uom": "%"
}
],
"metadata": {}
},
"reset": {
"type": "compound",
"value": [
{
"type": "action",
"input_params": "reqTimeInstant,correlatorID,param_a,param_b",
"output_params": "result,resTimeIntant,param_c,param_d"
}
],
"metadata": {}
},
"color": {
"type": "compound",
"value": [
{
"type": "action",
"input_params": "reqTimeInstant,correlatorID",
"output_params": "result,resTimeInstant"
}
],
"metadata": {}
}
}
]
}
EOF
Loading

0 comments on commit 3339fe5

Please sign in to comment.