From 8168774f4018e79311cbc9e7879cc9ac606a5a2a Mon Sep 17 00:00:00 2001 From: Alberto Abella Date: Fri, 24 May 2024 17:30:32 +0200 Subject: [PATCH] created example of code --- Agent/code/code_for_using_dataModel.DCAT-AP_Agent.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Agent/code/code_for_using_dataModel.DCAT-AP_Agent.py b/Agent/code/code_for_using_dataModel.DCAT-AP_Agent.py index b536e45..907baf1 100644 --- a/Agent/code/code_for_using_dataModel.DCAT-AP_Agent.py +++ b/Agent/code/code_for_using_dataModel.DCAT-AP_Agent.py @@ -24,13 +24,18 @@ # curl -X GET http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000 # # # now the python code you can use to insert some value in the context broker according to the data model +# # Version Warning! +# # This code is designed to work with the version 0.8 of pysmartdatamodels or later +# # to work with earlier version you need to replace the import instruction for +# # from pysmartdatamodels import pysmartdatamodels as sdm # -from pysmartdatamodels import pysmartdatamodels as sdm +# +import pysmartdatamodels as sdm import subprocess serverUrl = "http://localhost:1026" # supposed that your broker is installed in localhost. Edit to match your configuration dataModel = "Agent" subject = "dataModel.DCAT-AP" -Type = "{'type': 'Property', 'value': 'EU Publications office'}" +Type = "EU Publications office" attribute = "Type" value = Type # The next line creates the query for inserting this attribute in a NGSI-LD context broker if the attribute does not exist it creates it