"value": "urn:ngsi-ld:Store:001" }, "refProduct": { "type": "Relationship", "value": "urn:ngsi-ld:Product:001" }, "stockCount": { "type": "Integer", "value": 10000 }} inventory_entity = ContextEntity(**inventory_dict) cb_client.post_entity(inventory_entity) # # 2 Read data from FIWARE # # ## 2.1 Inventory relationship with Store and Product logger.info(inventory_entity.get_relationships()) # ## 2.2 Get entities # with ContextBrokerClient(fiware_header=fiware_header) as cb_client: # It should return the inventory item according to the relationship logger.info( cb_client.get_entity_list(q="refProduct==urn:ngsi-ld:Product:001")) logger.info( cb_client.get_entity_list(q="refStore==urn:ngsi-ld:Store:001")) # It should not return the inventory item according to the relationship logger.info( cb_client.get_entity_list(q="refStore==urn:ngsi-ld:Store:002")) # # 3 Delete test entities
thermal_zone_description = NamedContextAttribute(name="description", type="Text", value="This zones covers " "the entire building") thermal_zone.add_attributes(attrs=[thermal_zone_description]) # ToDo: Create and a property that references your building model. Use the # `Relationship` for type and `refBuilding` for its name ref_building = NamedContextAttribute(name="refBuilding", type="Relationship", value=building.id) thermal_zone.add_attributes(attrs=[ref_building]) # print all relationships of your thermal zone for relationship in thermal_zone.get_relationships(): print(f"Relationship properties of your thermal zone mdoel: \n " f"{relationship.json(indent=2)} \n") # ToDo: Post your thermal zone model to the context broker ... ... # ToDo: Create and a property that references your thermal zone. Use the # `Relationship` for type and `hasZone` for its name. Make sure that # your local model and the server model are in sync afterwards. ref_zone = NamedContextAttribute(...) cbc.update_or_append_entity_attributes(...) building = cbc.get_entity(entity_id=building.id, entity_type=building.type)