Skip to content

Commit

Permalink
Use user-context
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox committed Jul 4, 2024
1 parent da00bf1 commit 3170912
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 51 deletions.
28 changes: 14 additions & 14 deletions NGSI-LD IoT Agent JSON.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
}
],
Expand Down Expand Up @@ -242,7 +242,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
}
],
Expand Down Expand Up @@ -325,7 +325,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
}
],
Expand Down Expand Up @@ -504,7 +504,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
}
],
Expand Down Expand Up @@ -551,7 +551,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
}
],
Expand Down Expand Up @@ -594,7 +594,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
},
{
Expand Down Expand Up @@ -667,7 +667,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
}
],
Expand Down Expand Up @@ -714,7 +714,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
}
],
Expand Down Expand Up @@ -757,7 +757,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
},
{
Expand Down Expand Up @@ -829,7 +829,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
}
],
Expand Down Expand Up @@ -876,7 +876,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
}
],
Expand Down Expand Up @@ -919,7 +919,7 @@
},
{
"key": "Link",
"value": "<{{ngsi-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"value": "<{{user-context.jsonld}}>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"",
"type": "text"
},
{
Expand Down Expand Up @@ -1483,8 +1483,8 @@
"value": "localhost:3001"
},
{
"key": "ngsi-context.jsonld",
"value": "http://context/ngsi-context.jsonld"
"key": "user-context.jsonld",
"value": "http://context/user-context.jsonld"
},
{
"key": "scorpio",
Expand Down
38 changes: 22 additions & 16 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,10 @@ Agent は最初に Context Broker がレスポンスしている URL を認識

```console
curl -iX POST 'http://localhost:4041/iot/services' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
--data-raw '{
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
--data-raw '{
"services": [
{
"apikey": "4jggokgpepnvsb2uv4s40d59ov",
Expand Down Expand Up @@ -704,17 +704,20 @@ Context Broker からエンティティのデータを取得することで、

```console
curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:temperature001' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'NGSILD-Tenant: openiot' \
-H 'Accept: application/ld+json' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-d 'attrs=temperature'
```

#### レスポンス:

```json
{
"@context": "http://context/ngsi-context.jsonld",
"@context": [
"http://context/ngsi-context.jsonld",
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.7.jsonld"
],
"id": "urn:ngsi-ld:Device:temperature001",
"type": "Device",
"temperature": {
Expand Down Expand Up @@ -753,17 +756,20 @@ curl -iX POST 'http://localhost:7896/iot/json?k=4jggokgpepnvsb2uv4s40d59ov&i=mot

```console
curl -L -X GET 'http://localhost:1026/ngsi-ld/v1/entities/?type=Device' \
-H 'NGSILD-Tenant: openiot' \
-H 'NGSILD-Path: /' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
-H 'NGSILD-Tenant: openiot' \
-H 'Accept: application/ld+json' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
```

#### レスポンス:

```json
[
{
"@context": "http://context/ngsi-context.jsonld",
"@context": [
"http://context/ngsi-context.jsonld",
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.7.jsonld"
],
"id": "urn:ngsi-ld:Device:motion003",
"type": "Device",
"c": {
Expand Down Expand Up @@ -863,7 +869,7 @@ Irrigation system をオンにするコマンドの結果は、Context Broker
```console
curl -L -X GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:water001' \
-H 'NGSILD-Tenant: openiot' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Accept: application/json'
```

Expand Down Expand Up @@ -1032,7 +1038,7 @@ IoT Agent を IoT デバイスに接続すると、Orion Context Broker にコ
curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:water001/attrs/on' \
-H 'NGSILD-Tenant: openiot' \
-H 'Content-Type: application/json' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--data-raw '{

"type": "Property",
Expand All @@ -1057,7 +1063,7 @@ curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:w
curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:tractor001/attrs/start' \
-H 'NGSILD-Tenant: openiot' \
-H 'Content-Type: application/json' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--data-raw '{

"type": "Property",
Expand All @@ -1078,7 +1084,7 @@ curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:t
curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:filling001/attrs/add' \
-H 'NGSILD-Tenant: openiot' \
-H 'Content-Type: application/json' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--data-raw '{

"type": "Property",
Expand Down
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -701,17 +701,20 @@ add the `fiware-service` and `fiware-service-path` headers.

```console
curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:temperature001' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'NGSILD-Tenant: openiot' \
-H 'Accept: application/ld+json' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-d 'attrs=temperature'
```

#### Response:

```json
{
"@context": "http://context/ngsi-context.jsonld",
"@context": [
"http://context/ngsi-context.jsonld",
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.7.jsonld"
],
"id": "urn:ngsi-ld:Device:temperature001",
"type": "Device",
"temperature": {
Expand Down Expand Up @@ -752,17 +755,20 @@ based on the knowledge of the service group

```console
curl -L -X GET 'http://localhost:1026/ngsi-ld/v1/entities/?type=Device' \
-H 'NGSILD-Tenant: openiot' \
-H 'NGSILD-Path: /' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
-H 'NGSILD-Tenant: openiot' \
-H 'Accept: application/ld+json' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
```

#### Response:

```json
[
{
"@context": "http://context/ngsi-context.jsonld",
"@context": [
"http://context/ngsi-context.jsonld",
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.7.jsonld"
],
"id": "urn:ngsi-ld:Device:motion003",
"type": "Device",
"c": {
Expand Down Expand Up @@ -863,7 +869,7 @@ The result of the command to turn on the irrigation system can be read by queryi
```console
curl -L -X GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:water001' \
-H 'NGSILD-Tenant: openiot' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Accept: application/json'
```

Expand Down Expand Up @@ -909,10 +915,10 @@ both `attributes` and `command` attributes in the body of the request.

```console
curl -L -X POST 'http://localhost:4041/iot/devices' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
--data-raw '{
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
--data-raw '{
"devices": [
{
"device_id": "filling001",
Expand Down Expand Up @@ -968,7 +974,7 @@ curl -L -X POST 'http://localhost:4041/iot/devices' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
--data-raw '{
--data-raw '{
"devices": [
{
"device_id": "tractor001",
Expand Down Expand Up @@ -1025,7 +1031,7 @@ To invoke the `on` command, the `on` attribute must be updated in the context.
curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:water001/attrs/on' \
-H 'NGSILD-Tenant: openiot' \
-H 'Content-Type: application/json' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--data-raw '{
"type": "Property",
Expand All @@ -1048,7 +1054,7 @@ To invoke the `start` command, the `start` attribute must be updated in the cont
curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:tractor001/attrs/start' \
-H 'NGSILD-Tenant: openiot' \
-H 'Content-Type: application/json' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--data-raw '{
"type": "Property",
Expand All @@ -1067,7 +1073,7 @@ Change the state of the **Fillling System**, the `add` attribute must be updated
curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Device:filling001/attrs/add' \
-H 'NGSILD-Tenant: openiot' \
-H 'Content-Type: application/json' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--data-raw '{
"type": "Property",
Expand Down
6 changes: 6 additions & 0 deletions data-models/user-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": [
"http://context/user-context.jsonld",
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.8.jsonld"
]
}
4 changes: 2 additions & 2 deletions docker-compose/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
target: /usr/local/apache2/conf/mime.types
read_only: true
healthcheck:
test: (wget --server-response --spider --quiet http://ld-context/ngsi-context.jsonld 2>&1 | awk 'NR==1{print $$2}'| grep -q -e "200") || exit 1
test: (wget --server-response --spider --quiet http://context/user-context.jsonld 2>&1 | awk 'NR==1{print $$2}'| grep -q -e "200") || exit 1

# Databases
mongo-db:
Expand Down Expand Up @@ -91,7 +91,7 @@ services:
- IOTA_DEFAULT_RESOURCE=/iot/json

- IOTA_CB_NGSI_VERSION=ld # use NGSI-LD when sending updates for active attributes
- IOTA_JSON_LD_CONTEXT=http://context/ngsi-context.jsonld
- IOTA_JSON_LD_CONTEXT=http://context/user-context.jsonld
- IOTA_FALLBACK_TENANT=openiot
- IOTA_MULTI_CORE=true
healthcheck:
Expand Down
4 changes: 2 additions & 2 deletions import-data
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ curl -s -o /dev/null -X POST 'http://'"${CONTEXT_BROKER}"'/ngsi-ld/v1/entityOper
echo -e "Registering Farmer and Devices as data sources.\n"

curl -s -o /dev/null -X POST 'http://'"${CONTEXT_BROKER}"'/ngsi-ld/v1/csourceRegistrations/' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json' \
-H 'Content-Type: application/json' \
-d '{
"type": "ContextSourceRegistration",
Expand All @@ -120,7 +120,7 @@ curl -s -o /dev/null -X POST 'http://'"${CONTEXT_BROKER}"'/ngsi-ld/v1/csourceReg


curl -s -o /dev/null -X POST 'http://farmer/ngsi-ld/v1/csourceRegistrations/' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json' \
-H 'Content-Type: application/json' \
-d '{
"type": "ContextSourceRegistration",
Expand Down

0 comments on commit 3170912

Please sign in to comment.