Search code examples
pythonfiware-orion

Fiware-orion Remove all entities of the same type


I dont know what command pass to the Fiware Orion API(v2) to remove all element of an specific type. In this example fake.

I tried this, but it doesn't works :

response = self.PM.request(
        method='post', url='http://127.0.0.1:1026/v2/op/update', headers={'Content-Type': 'application/json'},
        body=json.dumps({
            "actionType": "delete",
            "entities": [{
                "idPattern": ".*",
                "type": "Fake",
            }]
        }))

I can remove the elements by ID. It is only a work around, but tells me that I am connecting correctly to the API. This is the code that works:

response = self.PM.request(
        method='post', url='http://127.0.0.1:1026/v2/op/update', headers={'Content-Type': 'application/json'},
        body=json.dumps({
            "actionType": "delete",
            "entities": [{
                    "id": "Fake1",
                },
                {
                    "id": "Fake2",
                }
            ]}))

Solution

  • According to the docs this feature does not exist. Also, if you search the source code for "delete type" I don't see anything that matches. You'd need to do a select first and iterate through all the ids deleting them.