Skip to content

Commit 9631471

Browse files
committed
Update Requests to use pick and format
1 parent f64043f commit 9631471

File tree

2 files changed

+80
-42
lines changed

2 files changed

+80
-42
lines changed

README.ja.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ Context Broker 自体への GET リクエストと同じように機能します
236236
#### 1️⃣ リクエスト:
237237
238238
```console
239-
curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/subscriptions/' \
239+
curl -L -X POST \
240+
'http://localhost:1026/ngsi-ld/v1/subscriptions/' \
240241
-H 'Content-Type: application/ld+json' \
241242
--data-raw '{
242243
"description": "Notify me of low stock in Store 001",
@@ -267,7 +268,8 @@ curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/subscriptions/' \
267268
#### 2️⃣ リクエスト:
268269

269270
```console
270-
curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/subscriptions/' \
271+
curl -L -X POST \
272+
'http://localhost:1026/ngsi-ld/v1/subscriptions/' \
271273
-H 'Content-Type: application/json' \
272274
-H 'Link: <https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
273275
--data-raw '{
@@ -298,7 +300,8 @@ curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/subscriptions/' \
298300
#### 3️⃣ リクエスト:
299301

300302
```console
301-
curl -L -X GET 'http://localhost:1026/ngsi-ld/v1/subscriptions/'
303+
curl -L -X GET \
304+
'http://localhost:1026/ngsi-ld/v1/subscriptions/'
302305
```
303306

304307
#### レスポンス:
@@ -469,7 +472,8 @@ Context Broker A にレジストレーションする循環依存関係を回避
469472
#### 4️⃣ リクエスト:
470473

471474
```console
472-
curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
475+
curl -L -X POST \
476+
'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
473477
-H 'Content-Type: application/json' \
474478
-H 'Link: <https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
475479
--data-raw ' {
@@ -506,7 +510,8 @@ curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
506510
#### 5️⃣ リクエスト:
507511

508512
```console
509-
curl -G -iX GET 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
513+
curl -G -iX GET \
514+
'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
510515
-H 'Accept: application/ld+json' \
511516
-H 'Link: <https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
512517
-d 'type=Building'
@@ -651,9 +656,11 @@ curl -iX GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:sto
651656
#### 7️⃣ リクエスト:
652657

653658
```console
654-
curl -L -X GET 'http://localhost:3000/static/tweets/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001?attrs=tweets' \
659+
curl -G -X GET \
660+
'http://localhost:3000/static/tweets/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001' \
655661
-H 'Link: <https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
656-
-H 'Content-Type: application/ld+json'
662+
-H 'Content-Type: application/ld+json' \
663+
-d 'pick=id,type,tweets'
657664
```
658665

659666
#### レスポンス:
@@ -689,7 +696,8 @@ curl -L -X GET 'http://localhost:3000/static/tweets/ngsi-ld/v1/entities/urn:ngsi
689696
#### 8️⃣ リクエスト:
690697

691698
```console
692-
curl -L -X PATCH 'http://localhost:3000/static/tweets/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs' \
699+
curl -L -X PATCH \
700+
'http://localhost:3000/static/tweets/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs' \
693701
-H 'Link: <https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
694702
-H 'Content-Type: application/json' \
695703
--data-raw '{
@@ -711,8 +719,11 @@ curl -L -X PATCH 'http://localhost:3000/static/tweets/ngsi-ld/v1/entities/urn:ng
711719
から取得した更新された値を返します。例えば、フォワーディング・エンドポイント
712720

713721
```console
714-
curl -L -X GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001?attrs=tweets&options=keyValues' \
715-
-H 'Link: <https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
722+
curl -G -X GET \
723+
'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001' \
724+
-H 'Link: <https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
725+
-d 'pick=id,type,tweets' \
726+
-d 'format=simplified'
716727
```
717728

718729
#### レスポンス:
@@ -757,7 +768,8 @@ Context Broker への PATCH リクエスト (`ngsi-ld/v1/entities/<entity-id>/`
757768
されます。
758769

759770
```console
760-
curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs/tweets' \
771+
curl -L -X PATCH \
772+
'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs/tweets' \
761773
-H 'Link: <https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
762774
-H 'Content-Type: application/json' \
763775
--data-raw '{
@@ -774,9 +786,11 @@ curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building
774786
前の操作の結果は、GET リクエストを使用してエンティティ全体を取得することで確認できます。
775787

776788
```console
777-
curl -L -X GET 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001?attrs=tweets&options=keyValues' \
789+
curl -L -X GET \
790+
'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001?options=keyValues' \
778791
-H 'Link: <https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
779-
-H 'Content-Type: application/json'
792+
-H 'Content-Type: application/json' \
793+
-d 'pick=id,type,tweets'
780794
```
781795

782796
#### レスポンス:

README.md

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The tutorial uses [cUrl](https://ec.haxx.se/) commands throughout, but is also a
2222
[Postman documentation](https://fiware.github.io/tutorials.Context-Providers/ngsi-ld.html)
2323

2424
[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/2c53b7c2bce9fd7b7b47)
25-
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?repo=FIWARE/tutorials.LD-Subscriptions-Registrations/tree/NGSI-LD)
25+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?repo=FIWARE/tutorials.LD-Subscriptions-Registrations&ref=NGSI-LD)
2626

2727
## Contents
2828

@@ -284,9 +284,13 @@ Animals are not available on the default tenant, Data about animals on the farm
284284
#### 1️⃣ Request:
285285
286286
```console
287-
curl -L 'http://localhost:1027/ngsi-ld/v1/entities/?type=Animal&limit=100&options=concise' \
288-
-H 'Content-Type: application/json' \
289-
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
287+
curl -G -X GET \
288+
'http://localhost:1027/ngsi-ld/v1/entities' \
289+
-H 'Content-Type: application/json' \
290+
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
291+
-d 'format=Animal' \
292+
-d 'limit=100' \
293+
-d 'format=concise'
290294
```
291295
292296
#### Response:
@@ -319,9 +323,13 @@ The response on port `1027` consists of the details of the **Animal** entities h
319323
#### 2️⃣ Request:
320324

321325
```console
322-
curl -L 'http://localhost:1026/ngsi-ld/v1/entities/?type=Animal&limit=100&options=concise' \
323-
-H 'Content-Type: application/json' \
324-
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
326+
curl -G -X GET \
327+
'http://localhost:1026/ngsi-ld/v1/entities' \
328+
-H 'Content-Type: application/json' \
329+
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
330+
-d 'format=Animal' \
331+
-d 'limit=100' \
332+
-d 'format=concise'
325333
```
326334

327335
#### Response:
@@ -358,7 +366,8 @@ but no data is held in the primary context broker whatsoever.
358366
#### 3️⃣ Request:
359367

360368
```console
361-
curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
369+
curl -X POST \
370+
'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
362371
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
363372
-H 'Content-Type: application/json' \
364373
-d '{
@@ -390,9 +399,13 @@ animals from the farmer subsystem:
390399
#### 4️⃣ Request:
391400

392401
```console
393-
curl -L 'http://localhost:1026/ngsi-ld/v1/entities/?type=Animal&limit=100&options=concise' \
394-
-H 'Content-Type: application/json' \
395-
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
402+
curl -G -X GET \
403+
'http://localhost:1026/ngsi-ld/v1/entities' \
404+
-H 'Content-Type: application/json' \
405+
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
406+
-d 'format=Animal' \
407+
-d 'limit=100' \
408+
-d 'format=concise'
396409
```
397410

398411
#### Response:
@@ -434,8 +447,10 @@ by the associated `@context` file.
434447
#### 5️⃣ Request:
435448

436449
```console
437-
curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/?type=Animal' \
438-
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
450+
curl -G -X GET \
451+
'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
452+
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
453+
-d 'type=Animal'
439454
```
440455

441456
#### Response:
@@ -503,7 +518,7 @@ curl -G -X GET \
503518
'http://localhost:1030/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
504519
-H 'Content-Type: application/json' \
505520
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
506-
-d 'attrs=name,comment'
521+
-d 'pick=id,type,name,comment'
507522
```
508523

509524
#### Response:
@@ -528,7 +543,8 @@ own broker and the vet:
528543
#### 7️⃣ Request:
529544

530545
```console
531-
curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
546+
curl -X POST \
547+
'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
532548
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
533549
-H 'NGSILD-Tenant: farmer' \
534550
-H 'Content-Type: application/json' \
@@ -676,7 +692,7 @@ curl -G -X GET \
676692
-H 'Accept: application/json' \
677693
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
678694
-H 'NGSILD-Tenant: contractor' \
679-
-d 'attrs=name%2Ccomment'
695+
-d 'pick=id,type,name,comment'
680696
```
681697

682698
#### Response:
@@ -734,7 +750,7 @@ curl -G -X GET \
734750
-H 'Accept: application/json' \
735751
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
736752
-H 'NGSILD-Tenant: farmer' \
737-
-d 'attrs=name%2Ccomment'
753+
-d 'pick=id,type,name,comment'
738754
```
739755

740756
#### Response:
@@ -776,7 +792,8 @@ The result of a `exclusive` registration is that no data for the registered attr
776792
Consider for example an Animal collar which supplies data for the entity `urn:ngsi-ld:Animal:cow001` - this is likely to be a device attached to an IoT Agent. The underlying device protocol and payload doesn't matter, since we are able to make an NGSI-LD request to the IoT Agent which then requests information from the device itself:
777793

778794
```console
779-
curl -L 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
795+
curl -X GET \
796+
'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
780797
-H 'Accept: application/json' \
781798
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
782799
-H 'NGSILD-Tenant: openiot'
@@ -822,7 +839,8 @@ The response shows the live readings from the device itself.
822839
An exclusive registration can be made on the **Farmer** context broker to always receive **live** information from the IoT Agent. The `mode` is set to `"exclusive"`, and since the IoT Agent is only accepting **GET** requests the `"operations` attribute is set to `"retrieveOps"` only. A fixed `contextSourceInfo` can be used if the endpoint does not understand JSON-LD expansion/compaction.
823840

824841
```console
825-
curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
842+
curl -X POST \
843+
'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
826844
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
827845
-H 'NGSILD-Tenant: farmer' \
828846
-H 'Content-Type: application/json' \
@@ -861,10 +879,11 @@ curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
861879
The **farmer** context broker is now able to get the `location` and `heartRate` of `urn:ngsi-ld:Device:cow001`
862880

863881
```console
864-
curl -L 'http://localhost:1027/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001?attrs=location%2CheartRate' \
882+
curl -G -X 'http://localhost:1027/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
865883
-H 'Accept: application/json' \
866884
-H 'NGSILD-Tenant: farmer' \
867-
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
885+
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
886+
-d 'pick=id,type,location,heartRate'
868887
```
869888

870889
#### Response:
@@ -903,7 +922,8 @@ curl -L 'http://localhost:1027/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001?att
903922
Note that an attempt by the Farmer to directly update the `location` or `heartRate` attributes will **fail** with **409 - Conflict** as an exclusive registration prohibits this:
904923

905924
```console
906-
curl -L -X PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
925+
curl -L -X PATCH \
926+
'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow001' \
907927
-H 'Accept: application/ld+json' \
908928
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
909929
-H 'NGSILD-Tenant: farmer' \
@@ -944,10 +964,11 @@ of fields. In some cases you already have a temperature gauge in a field and you
944964
To find the **AgriParcel** `temperature` data currently available to the **farmer**, make a request to the `/entities` endpoint and supply the `type` parameter.
945965

946966
```console
947-
curl -L 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel&attrs=temperature' \
967+
curl -G -X 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel' \
948968
-H 'Accept: application/json' \
949969
-H 'NGSILD-Tenant: farmer' \
950-
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
970+
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
971+
-d 'pick=id,type,temperature'
951972
```
952973

953974
#### Response:
@@ -974,10 +995,11 @@ Initially only one AgriParcel is returned, since it is the only one which the **
974995
Make the same request directly to the **Weather** context broker to obtain the information known to the Weather forecaster:
975996

976997
```console
977-
curl -L 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel&attrs=temperature' \
998+
curl -G -X 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel' \
978999
-H 'Accept: application/json' \
9791000
-H 'NGSILD-Tenant: weather' \
980-
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
1001+
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
1002+
-d 'pick=id,type,temperature'
9811003
```
9821004

9831005
#### Response:
@@ -1026,7 +1048,8 @@ The weather forecast context broker has more information and its values have a m
10261048
An auxiliary registration can be made on the **Farmer** context broker to only receive **live** information from the weather forecaster if it does not hold information locally. The `mode` is set to `"auxilary"`, and since the IoT Agent is only accepting **GET** requests the `"operations` attribute is set to `"retrieveOps"` only.
10271049

10281050
```console
1029-
curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
1051+
curl -X POST \
1052+
'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
10301053
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
10311054
-H 'NGSILD-Tenant: farmer' \
10321055
-H 'Content-Type: application/json' \
@@ -1056,10 +1079,11 @@ curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
10561079
Once the registration has been created, the farmer can request for `temperature` data once again.
10571080

10581081
```console
1059-
curl -L 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel&attrs=temperature' \
1082+
curl -G -X 'http://localhost:1026/ngsi-ld/v1/entities/?type=AgriParcel' \
10601083
-H 'Accept: application/json' \
10611084
-H 'NGSILD-Tenant: farmer' \
1062-
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"'
1085+
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
1086+
-d 'pick=id,type,temperature'
10631087
```
10641088

10651089
#### Response:

0 commit comments

Comments
 (0)