oasis-open / cti-taxii-client

OASIS TC Open Repository: TAXII 2 Client Library Written in Python
https://taxii2client.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
108 stars 52 forks source link

Getting all the data after a date using pagination. #118

Closed Aekansh-Ak closed 7 months ago

Aekansh-Ak commented 7 months ago

I am able to get the data after a certain data using this-:

collection = Collection('url/collections/collection-id', cert=('public.crt', 'key')) r = collection.get_objects(added_after="2024-01-01T00:00:00.000Z")

But from what I understand this will only return top 100 objects and I need to us pagination to get all the data.

So, I used this...

for bundles in as_pages(collection.get_objects(added_after="2024-01-01T00:00:00.000Z"), per_request=50): bundle = bundles['objects'] print(bundle)

Error-:

Traceback (most recent call last): File "test_fin.py", line 11, in for bundles in as_pages(collection.get_objects(added_after="2024-01-01T00:00:00.000Z"), per_request=50): File "/usr/local/lib/python3.6/site-packages/taxii2client/v21/init.py", line 32, in as_pages envelope = func(limit=per_request, *args, **kwargs) TypeError: 'dict' object is not callable

Please help

chisholm commented 7 months ago

You need to pass a callable function to as_pages(), not the result of calling get_objects(). See:

https://taxii2client.readthedocs.io/en/latest/api/taxii2client.v21.html#taxii2client.v21.as_pages

E.g. try passing collection.get_objects as a bound method.