Skip to content

Commit

Permalink
Merge branch 'adrima01-main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Jul 23, 2024
2 parents ffb8033 + f08114a commit a64299d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pylookyloo/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,26 @@ def send_mail(self, tree_uuid: str, email: str = '', comment: str | None = None)
def get_recent_captures(self, timestamp: str | datetime | float | None=None) -> list[str]:
'''Gets the uuids of the most recent captures
:param timestamp: Timestamp of the capture
:param timestamp: Oldest timestamp to consider
'''
if not timestamp:
url = urljoin(self.root_url, str(PurePosixPath('json', 'recent_captures')))
else:
if timestamp:
if isinstance(timestamp, datetime):
timestamp = timestamp.timestamp()
url = urljoin(self.root_url, str(PurePosixPath('json', 'recent_captures', str(timestamp))))
else:
url = urljoin(self.root_url, str(PurePosixPath('json', 'recent_captures')))
r = self.session.get(url)
return r.json()

def get_categories_captures(self, category: str | None=None) -> list[str] | dict[str, list[str]] | None:
'''Get uuids for a specific category or all categorized uuids if category is None
:param category: The category according to which the uuids are to be returned
'''
if category:
url = urljoin(self.root_url, str(PurePosixPath('json', 'categories', category)))
else:
url = urljoin(self.root_url, str(PurePosixPath('json', 'categories')))
r = self.session.get(url)
return r.json()

Expand Down

0 comments on commit a64299d

Please sign in to comment.