Skip to content
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

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

ArqamFarooqui110719
Copy link
Contributor

Delete subscriptions in bulk this python script (Issue #4578 )

@ArqamFarooqui110719
Copy link
Contributor Author

I have verified the script and it is working successfully. Please find attached screenshot for reference:
issue_4578_screenshot

Comment on lines 42 to 43
# WARNING! use this filter or you will remove *all* subscriptions
filter = 'offset=0'
Copy link
Member

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

Suggested change
# 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'

Copy link
Contributor Author

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:)

Copy link
Contributor Author

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:

filter_variable

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 = ''

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with it

Copy link
Contributor Author

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 01f8553

Copy link
Member

@fgalan fgalan left a 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!

@fgalan fgalan merged commit 8f540c4 into telefonicaid:master Oct 28, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants