5.8.Entityの削除 |
---|
5.8.2.Attributeの削除 |
---|
2022年4月12日 |
||
同様に、特定のAttributeをエンドポイントにすることで、Attributeを削除できます。例えばStore001のlocationを消す場合は。 |
||
curl -X DELETE http://localhost:1026/v2/entities/urn:ngsi-ld:Store:001/attrs/location | ||
結果は以下となります。 |
||
PS C:\Users\owner> curl -X GET http://localhost:1026/v2/entities/urn:ngsi-ld:Store:001 {"id":"urn:ngsi-ld:Store:001","type":"Store","address":{"type":"PostalAddress","value":{"streetAddress":"長沼町202-5","addressLocality":"八王子市","addressRegion":"東京都","postalCode":"1920907"},"metadata":{}},"location":{"type":"geo:json","value":{"type":"Point","coordinates":[139.37158,35.64226]},"metadata":{}},"name":{"type":"Text","value":"ローソン八王 子長沼町店","metadata":{}}} PS C:\Users\owner> curl -X DELETE http://localhost:1026/v2/entities/urn:ngsi-ld:Store:001/attrs/location PS C:\Users\owner> curl -X GET http://localhost:1026/v2/entities/urn:ngsi-ld:Store:001 {"id":"urn:ngsi-ld:Store:001","type":"Store","address":{"type":"PostalAddress","value":{"streetAddress":"長沼町202-5","addressLocality":"八王子市","addressRegion":"東京都","postalCode":"1920907"},"metadata":{}},"name":{"type":"Text","value":"ローソン八王子長沼町店","metadata":{}}} PS C:\Users\owner> |
||
locationが消えていますね。 |
||
|
||
|
||
2022年4月12日 |
||
今度はStore001とStore002を消してみましょう。例によって、バッチ用のjsonテキストを作ります。 |
||
{ "actionType":"delete", "entities":[ { "id":"urn:ngsi-ld:Store:001", "type":"Store" }, { "id":"urn:ngsi-ld:Store:002", "type":"Store" } ] } |
||
そして、バッチ用のコマンドを投入します。ファイルはdeleteStore001.jsonとしました。 |
||
curl -X POST -H 'Content-Type: application/json' -d @d:\deleteStore001.json 'http://localhost:1026/v2/op/update' | ||
以下のような応答があります。 |
||
PS C:\Users\owner> curl -X POST -H 'Content-Type: application/json' -d @d:\deleteStore001.json 'http://localhost:1026/v2/op/update' PS C:\Users\owner> curl -X GET http://localhost:1026/v2/entities/urn:ngsi-ld:Store:001 {"error":"NotFound","description":"The requested entity has not been found. Check type and id"} PS C:\Users\owner> curl -X GET http://localhost:1026/v2/entities/urn:ngsi-ld:Store:002 {"error":"NotFound","description":"The requested entity has not been found. Check type and id"} PS C:\Users\owner> |
||
2件とも削除されています。 |
||
|
||
|
||
2022年4月12日 |
||
これも同様に、v2/op/updateのエンドポイントに、以下のjson文字列を実行します。 |
||
{ "actionType":"delete", "entities":[ { "id":"urn:ngsi-ld:Store:001", "type":"Store", "name":{}, "location": {} } ] } |
||
そうすると、以下の様にnameとlocationが消えています。 |
||
PS C:\Users\owner> curl -X GET http://localhost:1026/v2/entities/urn:ngsi-ld:Store:001 {"id":"urn:ngsi-ld:Store:001","type":"Store","address":{"type":"PostalAddress","value":{"streetAddress":"長沼町202-5","addressLocality":"八王子市","addressRegion":"東京都","postalCode":"1920907"},"metadata":{}},"location":{"type":"geo:json","value":{"type":"Point","coordinates":[139.37158,35.64226]},"metadata":{}},"name":{"type":"Text","value":"ローソン八王 子長沼町店","metadata":{}}} PS C:\Users\owner> curl -X POST -H 'Content-Type: application/json' -d @d:\deleteStore001attrs.json 'http://localhost:1026/v2/op/update' PS C:\Users\owner> curl -X GET http://localhost:1026/v2/entities/urn:ngsi-ld:Store:001 {"id":"urn:ngsi-ld:Store:001","type":"Store","address":{"type":"PostalAddress","value":{"streetAddress":"長沼町202-5","addressLocality":"八王子市","addressRegion":"東京都","postalCode":"1920907"},"metadata":{}}} PS C:\Users\owner> |
||