diff --git a/OnStreetParking/code/code_for_using_dataModel.Parking_OnStreetParking.py b/OnStreetParking/code/code_for_using_dataModel.Parking_OnStreetParking.py index 582a8fe..e5012aa 100644 --- a/OnStreetParking/code/code_for_using_dataModel.Parking_OnStreetParking.py +++ b/OnStreetParking/code/code_for_using_dataModel.Parking_OnStreetParking.py @@ -24,31 +24,36 @@ # 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 = "OnStreetParking" subject = "dataModel.Parking" -allowedVehicleType = {'type': 'Property', 'value': ['car']} +allowedVehicleType = ['car'] attribute = "allowedVehicleType" value = allowedVehicleType # 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 print(sdm.update_broker(dataModel, subject, attribute, value, serverUrl=serverUrl, updateThenCreate=True)) -availableSpotNumber = {'type': 'Property', 'value': 3, 'observedAt': '2018-09-12T12:00:00Z'} +availableSpotNumber = 3 attribute = "availableSpotNumber" value = availableSpotNumber # 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 print(sdm.update_broker(dataModel, subject, attribute, value, serverUrl=serverUrl, updateThenCreate=True)) -category = {'type': 'Property', 'value': ['blueZone', 'shortTerm', 'forDisabled']} +category = ['blueZone', 'shortTerm', 'forDisabled'] attribute = "category" value = category # 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 print(sdm.update_broker(dataModel, subject, attribute, value, serverUrl=serverUrl, updateThenCreate=True)) -chargeType = {'type': 'Property', 'value': ['temporaryFee']} +chargeType = ['temporaryFee'] attribute = "chargeType" value = chargeType # 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