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 9ae54f4 commit c91cf98
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 202 deletions.
64 changes: 34 additions & 30 deletions NGSI-LD Entity Relationships.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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 All @@ -26,10 +26,10 @@
"raw": "[\n {\n \"id\": \"urn:ngsi-ld:TemperatureSensor:001\",\n \"type\": \"TemperatureSensor\",\n \"description\" : {\"type\": \"Property\", \"value\": \"Temperature Gauge 1\"},\n \"category\": {\"type\": \"Property\", \"value\": \"sensor\"},\n \"controlledProperty\" : {\"type\": \"Property\", \"value\": \"temperature\"},\n \"temperature\": {\"type\": \"Property\", \"value\": 20, \"unitCode\": \"CEL\"}\n },\n {\n \"id\": \"urn:ngsi-ld:TemperatureSensor:002\",\n \"type\": \"TemperatureSensor\",\n \"description\" : {\"type\": \"Property\", \"value\": \"Temperature Gauge 2\"},\n \"category\": {\"type\": \"Property\", \"value\": \"sensor\"},\n \"controlledProperty\" : {\"type\": \"Property\", \"value\": \"temperature\"},\n \"temperature\": {\"type\": \"Property\", \"value\": 21, \"unitCode\": \"CEL\"}\n },\n {\n \"id\": \"urn:ngsi-ld:TemperatureSensor:003\",\n \"type\": \"TemperatureSensor\",\n \"description\" : {\"type\": \"Property\", \"value\": \"Temperature Gauge 3\"},\n \"category\": {\"type\": \"Property\", \"value\": \"sensor\"},\n \"controlledProperty\" : {\"type\": \"Property\", \"value\": \"temperature\"},\n \"temperature\": {\"type\": \"Property\", \"value\": 27, \"unitCode\": \"CEL\"}\n }\n]"
},
"url": {
"raw": "http://{{orion}}/ngsi-ld/v1/entityOperations/upsert",
"raw": "http://{{context-broker}}/ngsi-ld/v1/entityOperations/upsert",
"protocol": "http",
"host": [
"{{orion}}"
"{{context-broker}}"
],
"path": [
"ngsi-ld",
Expand All @@ -53,7 +53,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 All @@ -62,10 +62,10 @@
"raw": "[\n {\n \"id\": \"urn:ngsi-ld:FillingLevelSensor:001\",\n \"type\": \"FillingLevelSensor\",\n \"description\" : {\"type\": \"Property\", \"value\": \"Filling Level Sensor 1\"},\n \"category\": {\"type\": \"Property\", \"value\": \"sensor\"},\n \"controlledProperty\" : {\"type\": \"Property\", \"value\": \"fillingLevel\"},\n \"fillingLevel\": {\"type\": \"Property\", \"value\": 1, \"unitCode\": \"C62\"}\n },\n {\n \"id\": \"urn:ngsi-ld:FillingLevelSensor:002\",\n \"type\": \"FillingLevelSensor\",\n \"description\" : {\"type\": \"Property\", \"value\": \"Filling Level Sensor 2\"},\n \"category\": {\"type\": \"Property\", \"value\": \"sensor\"},\n \"controlledProperty\" : {\"type\": \"Property\", \"value\": \"fillingLevel\"},\n \"fillingLevel\": {\"type\": \"Property\", \"value\": 0.9, \"unitCode\": \"C62\"}\n },\n {\n \"id\": \"urn:ngsi-ld:FillingLevelSensor:003\",\n \"type\": \"FillingLevelSensor\",\n \"description\" : {\"type\": \"Property\", \"value\": \"Filling Gauge 3\"},\n \"category\": {\"type\": \"Property\", \"value\": \"sensor\"},\n \"controlledProperty\" : {\"type\": \"Property\", \"value\": \"fillingLevel\"},\n \"fillingLevel\": {\"type\": \"Property\", \"value\": 0.8, \"unitCode\": \"C62\"}\n }\n]"
},
"url": {
"raw": "http://{{orion}}/ngsi-ld/v1/entityOperations/upsert",
"raw": "http://{{context-broker}}/ngsi-ld/v1/entityOperations/upsert",
"protocol": "http",
"host": [
"{{orion}}"
"{{context-broker}}"
],
"path": [
"ngsi-ld",
Expand All @@ -85,15 +85,15 @@
"header": [
{
"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"
}
],
"url": {
"raw": "http://{{orion}}/ngsi-ld/v1/entities/?type=TemperatureSensor,FillingLevelSensor&options=keyValues",
"raw": "http://{{context-broker}}/ngsi-ld/v1/entities/?type=TemperatureSensor,FillingLevelSensor&options=keyValues",
"protocol": "http",
"host": [
"{{orion}}"
"{{context-broker}}"
],
"path": [
"ngsi-ld",
Expand Down Expand Up @@ -127,7 +127,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 All @@ -136,10 +136,10 @@
"raw": "[\n {\n \"id\": \"urn:ngsi-ld:TemperatureSensor:001\",\n \"type\": \"TemperatureSensor\",\n \"controllingAsset\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:farm001\"\n }\n },\n {\n \"id\": \"urn:ngsi-ld:TemperatureSensor:002\",\n \"type\": \"TemperatureSensor\",\n \"controllingAsset\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:barn002\"\n }\n },\n {\n \"id\": \"urn:ngsi-ld:FillingLevelSensor:003\",\n \"type\": \"FillingLevelSensor\",\n \"controllingAsset\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:farm002\"\n }\n },\n {\n \"id\": \"urn:ngsi-ld:FillingLevelSensor:001\",\n \"type\": \"FillingLevelSensor\",\n \"controllingAsset\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:farm001\"\n }\n },\n {\n \"id\": \"urn:ngsi-ld:FillingLevelSensor:002\",\n \"type\": \"FillingLevelSensor\",\n \"controllingAsset\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:barn002\"\n }\n },\n {\n \"id\": \"urn:ngsi-ld:TemperatureSensor:003\",\n \"type\": \"TemperatureSensor\",\n \"controllingAsset\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Building:farm002\"\n }\n }\n]"
},
"url": {
"raw": "http://{{orion}}/ngsi-ld/v1/entityOperations/update?options=update",
"raw": "http://{{context-broker}}/ngsi-ld/v1/entityOperations/update?options=update",
"protocol": "http",
"host": [
"{{orion}}"
"{{context-broker}}"
],
"path": [
"ngsi-ld",
Expand All @@ -165,7 +165,7 @@
"header": [
{
"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 @@ -206,7 +206,7 @@
"header": [
{
"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 @@ -257,15 +257,15 @@
"header": [
{
"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"
}
],
"url": {
"raw": "http://{{orion}}/ngsi-ld/v1/entities?q=controllingAsset==\"urn:ngsi-ld:Building:farm001\"&options=keyValues&attrs=controllingAsset",
"raw": "http://{{context-broker}}/ngsi-ld/v1/entities?q=controllingAsset==\"urn:ngsi-ld:Building:farm001\"&options=keyValues&attrs=controllingAsset",
"protocol": "http",
"host": [
"{{orion}}"
"{{context-broker}}"
],
"path": [
"ngsi-ld",
Expand Down Expand Up @@ -302,7 +302,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 All @@ -311,10 +311,10 @@
"raw": "{\n \"id\": \"urn:ngsi-ld:Task:001\",\n \"type\": \"Task\",\n \"worker\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Person:001\"\n },\n \"field\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:PartField:002\"\n },\n \"product\": {\n \"type\": \"Relationship\",\n \"object\": \"urn:ngsi-ld:Herbicide:001\"\n },\n \"description\": {\n \"type\": \"Property\",\n \"value\": \"Spray the North Field with Agent Orange\"\n },\n \"status\": {\n \"type\": \"Property\",\n \"value\": \"scheduled\"\n },\n \"dueDate\": {\n \"type\": \"Property\",\n \"value\": \"2021-07-16\"\n }\n}"
},
"url": {
"raw": "http://{{orion}}/ngsi-ld/v1/entities/",
"raw": "http://{{context-broker}}/ngsi-ld/v1/entities/",
"protocol": "http",
"host": [
"{{orion}}"
"{{context-broker}}"
],
"path": [
"ngsi-ld",
Expand All @@ -334,7 +334,7 @@
"header": [
{
"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 All @@ -345,10 +345,10 @@
}
],
"url": {
"raw": "http://{{orion}}/ngsi-ld/v1/entities/?q=field==\"urn:ngsi-ld:PartField:002\"&options=keyValues&attrs=worker&type=Task",
"raw": "http://{{context-broker}}/ngsi-ld/v1/entities/?q=field==\"urn:ngsi-ld:PartField:002\"&options=keyValues&attrs=worker&type=Task",
"protocol": "http",
"host": [
"{{orion}}"
"{{context-broker}}"
],
"path": [
"ngsi-ld",
Expand Down Expand Up @@ -386,7 +386,7 @@
"header": [
{
"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 All @@ -397,10 +397,10 @@
}
],
"url": {
"raw": "http://{{orion}}/ngsi-ld/v1/entities/?q=product==\"urn:ngsi-ld:Herbicide:001\"&options=keyValues&attrs=field&type=Task",
"raw": "http://{{context-broker}}/ngsi-ld/v1/entities/?q=product==\"urn:ngsi-ld:Herbicide:001\"&options=keyValues&attrs=field&type=Task",
"protocol": "http",
"host": [
"{{orion}}"
"{{context-broker}}"
],
"path": [
"ngsi-ld",
Expand Down Expand Up @@ -438,7 +438,7 @@
"header": [
{
"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 All @@ -449,10 +449,10 @@
}
],
"url": {
"raw": "http://{{orion}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:farm001?attrs=temperature",
"raw": "http://{{context-broker}}/ngsi-ld/v1/entities/urn:ngsi-ld:Building:farm001?attrs=temperature",
"protocol": "http",
"host": [
"{{orion}}"
"{{context-broker}}"
],
"path": [
"ngsi-ld",
Expand Down Expand Up @@ -494,12 +494,16 @@
],
"variable": [
{
"key": "orion",
"key": "context-broker",
"value": "localhost:1026"
},
{
"key": "ngsi-context.jsonld",
"value": "http://context/ngsi-context.jsonld"
},
{
"key": "user-context.jsonld",
"value": "http://context/ngsi-context.jsonld"
}
]
}
33 changes: 16 additions & 17 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ git checkout NGSI-LD
```console
curl -X POST 'http://localhost:1026/ngsi-ld/v1/entityOperations/upsert' \
-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"' \
-H 'Accept: application/ld+json' \
--data-raw '[
{
Expand Down Expand Up @@ -259,7 +259,7 @@ curl -X POST 'http://localhost:1026/ngsi-ld/v1/entityOperations/upsert' \

```console
curl -iX POST 'http://localhost:1026/ngsi-ld/v1/entityOperations/upsert' \
-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' \
--data-raw '[
{
Expand Down Expand Up @@ -300,15 +300,14 @@ curl -iX POST 'http://localhost:1026/ngsi-ld/v1/entityOperations/upsert' \

```console
curl -X GET 'http://localhost:1026/ngsi-ld/v1/entities/?type=TemperatureSensor,FillingLevelSensor&options=keyValues' \
-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"'
```

#### レスポンス:

```json
[
{
"@context": "http://context/ngsi-context.jsonld",
"id": "urn:ngsi-ld:TemperatureSensor:001",
"type": "TemperatureSensor",
"description": "Temperature Gauge 1",
Expand All @@ -317,7 +316,6 @@ curl -X GET 'http://localhost:1026/ngsi-ld/v1/entities/?type=TemperatureSensor,F
"temperature": 20
},
{
"@context": "http://context/ngsi-context.jsonld",
"id": "urn:ngsi-ld:TemperatureSensor:002",
"type": "TemperatureSensor",
"description": "Temperature Gauge 2",
Expand Down Expand Up @@ -355,7 +353,7 @@ URN は、標準形式に従います: `urn:ngsi-ld:<entity-type>:<entity-id>`
curl -G -iX POST 'http://localhost:1026/ngsi-ld/v1/entityOperations/upsert' \
-d 'options=update' \
-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 '[
{
"id": "urn:ngsi-ld:TemperatureSensor:001",
Expand Down Expand Up @@ -398,7 +396,7 @@ curl -G -iX POST 'http://localhost:1026/ngsi-ld/v1/entityOperations/upsert' \
```console
curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:TemperatureSensor001' \
-d 'options=keyValues' \
-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"'
```

#### レスポンス:
Expand All @@ -407,7 +405,10 @@ curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Temperatu

```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:TemperatureSensor:001",
"type": "TemperatureSensor",
"description": "Temperature Gauge 1",
Expand Down Expand Up @@ -435,7 +436,7 @@ curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Temperatu
curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:TemperatureSensor:001' \
-d 'options=keyValues' \
-d 'attrs=controlledAsset' \
-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 @@ -465,7 +466,7 @@ curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities' \
-d 'q=controlledAsset==%22urn:ngsi-ld:Building:farm001%22' \
-d 'attrs=controlledAsset' \
-d 'options=keyValues' \
-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"'
```

このリクエストは、URN `urn:ngsi-ld:Building:farm001` に関連付けられている、すべての **Device** エンティティの `id`
Expand All @@ -476,12 +477,10 @@ curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities' \
```json
[
{
"@context": "http://context/ngsi-context.jsonld",
"id": "urn:ngsi-ld:TemperatureSensor:001",
"type": "TemperatureSensor",
},
{
"@context": "http://context/ngsi-context.jsonld",
"id": "urn:ngsi-ld:FillingLevelSensor:001",
"type": "FillingLevelSensor",
}
Expand All @@ -500,7 +499,7 @@ curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities' \
-d 'options=keyValues' \
-d 'count=true' \
-d 'limit=0' \
-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"'
```

影響を受けるエンティティの数を示す HTTP ヘッダをレスポンスの一部として返します:
Expand Down Expand Up @@ -532,7 +531,7 @@ NGSILD-Results-Count: 2
```console
curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/entities/' \
-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 '{
"id": "urn:ngsi-ld:Task:001",
"type": "Task",
Expand Down Expand Up @@ -563,7 +562,7 @@ curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities' \
-d 'options=keyValues' \
-d 'attrs=worker' \
-d 'type=Task' \
-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 All @@ -590,7 +589,7 @@ curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities' \
-d 'options=keyValues' \
-d 'attrs=field' \
-d 'type=Task' \
-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 @@ -627,7 +626,7 @@ _Properties-of-Properties_ および _Relationships of Properties_ はメタデ
```console
curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:farm001' \
-d 'attrs=temperature' \
-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
Loading

0 comments on commit c91cf98

Please sign in to comment.