telefonicaid / fiware-orion

Context Broker and CEF building block for context data management, providing NGSI interfaces.
https://fiware-orion.rtfd.io/
GNU Affero General Public License v3.0
212 stars 264 forks source link

Delete bulk subscriptions using script #4578

Open ArqamFarooqui110719 opened 3 months ago

ArqamFarooqui110719 commented 3 months ago

Bug description I have thousands of subscription created in my orion setup. Is there any script available, using which I can delete all subscriptions using IDs.

If not, shouldn't we have a script (python/shell) which can delete multiple subscription on single click.

fgalan commented 3 months ago

Maybe this can be useful:

https://github.com/telefonicaid/fiware-orion/blob/master/scripts/utils/delete_entities_by_list.py https://github.com/telefonicaid/fiware-orion/blob/master/scripts/utils/delete_entities_by_query.py

I think the code is pretty straightforward, but if you some doubt, just ask it :)

fgalan commented 3 months ago

Ah, sorry... those scripts are for entities and you are asking for subscriptions

I think we don't have such script. Maybe a delete_subscriptions.py script (based on the previous ones) could be useful. It would be an interesting contribution :)

ArqamFarooqui110719 commented 3 months ago

Ah, sorry... those scripts are for entities and you are asking for subscriptions

Yes, for subscriptions:)

I think we don't have such script. Maybe a delete_subscriptions.py script (based on the previous ones) could be useful. It would be an interesting contribution :)

Yes, I am looking into it.

ArqamFarooqui110719 commented 3 months ago

Before starting, I want to confirm few point:

  1. Currently we are able to delete subscriptions one by one using subscription ID.
  2. So, for deleting the subscriptions in bulk, we need to collect the subscriptions IDs of each subscription (may be, in any variable)
  3. then process delete operation for each subscription one by one.

@fgalan, Please confirm above steps. And if you have any suggestion please let me know.

fgalan commented 3 months ago

That's correct!

I'd suggest to implement the script in Python, with his the tooling language that we use in this repository.

Regarding step 2, to collect subscription IDs, the GET /v2/subscriptions operation has to be used. Note that you could have a large number of subscription, so you should use the pagination options, as delete_entities_by_query.py does. Details of the API operation can be found at https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md#list-subscriptions-get-v2subscriptions

Finally, as an extra feature of your script it would be interesting to include filtering capabilities, based in the JSON of each subscription obtained. For instance, delete subscription which match a given description, etc.