-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete subscriptions in bulk using python script #4626
Conversation
# WARNING! use this filter or you will remove *all* subscriptions | ||
filter = 'offset=0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even with offset=0
, all subscription would be removed :). Note that offset/limit are not actually filters, but a mechanism to get paginated results.
Let's keep the filter varible, just in case in the future gets implemented, but I'd suggest to use something like this in this point
# WARNING! use this filter or you will remove *all* subscriptions | |
filter = 'offset=0' | |
# WARNING! use this filter or you will remove *all* subscriptions | |
# FIXME: note that filtering is not supported in the GET /v2/subscriptions. If at the it is get | |
# implemented (https://github.com/telefonicaid/fiware-orion/issues/1145 or additional issues), | |
# let's adjust this point of the script with a valid example filter | |
#filter = '&type=device' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I intentionally put the offset value as the actual filter (q/type) is not working yet.
But the suggested changes gives more clarity so I'll update the PR:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even with
offset=0
, all subscription would be removed :). Note that offset/limit are not actually filters, but a mechanism to get paginated results.Let's keep the filter varible, just in case in the future gets implemented, but I'd suggest to use something like this in this point
filter variable cannot be commented as it make request bad. Please see below screenshot for reference:
So I can add below lines as well in the script:
# WARNING! use this filter or you will remove *all* subscriptions
# FIXME: note that filtering is not supported in the GET /v2/subscriptions. If at the it is get
# implemented (https://github.com/telefonicaid/fiware-orion/issues/1145 or additional issues),
# let's adjust this point of the script with a valid example filter
#filter = '&type=device'
# For now we can keep filter variable empty.
filter = ''
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 01f8553
""" | ||
try: | ||
# Fetching subscriptions with pagination | ||
response = requests.get(f"{cb_endpoint}?limit={page_size}&{filter}", headers=headers, verify=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response = requests.get(f"{cb_endpoint}?limit={page_size}&{filter}", headers=headers, verify=False) | |
response = requests.get(f"{cb_endpoint}?limit={page_size}{filter}", headers=headers, verify=False) |
Let's assume that filter is either the empty string or a query param with the &
already included (as in existing delete_entities_by_query.py)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 01f8553
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for your contribution!
Delete subscriptions in bulk this python script (Issue #4578 )