mirror of
https://github.com/brygphilomena/pyhuntress.git
synced 2025-11-04 16:27:30 +00:00
fix get_next_page() to actually get next page
This commit is contained in:
parent
75037a6166
commit
bcf940e5ff
@ -84,7 +84,6 @@ class PaginatedResponse(Generic[TModel]):
|
|||||||
self.endpointmodel = endpointmodel
|
self.endpointmodel = endpointmodel
|
||||||
self.endpoint = endpoint
|
self.endpoint = endpoint
|
||||||
self.limit = limit
|
self.limit = limit
|
||||||
print(self.endpoint)
|
|
||||||
# The following for SIEM is in the response body, not the headers
|
# The following for SIEM is in the response body, not the headers
|
||||||
self.parsed_pagination_response = parse_response_body(json.loads(response.content.decode('utf-8')).get('pagination', {}))
|
self.parsed_pagination_response = parse_response_body(json.loads(response.content.decode('utf-8')).get('pagination', {}))
|
||||||
self.params = params
|
self.params = params
|
||||||
@ -125,6 +124,7 @@ class PaginatedResponse(Generic[TModel]):
|
|||||||
next_response.response,
|
next_response.response,
|
||||||
next_response.response_model,
|
next_response.response_model,
|
||||||
next_response.endpointmodel,
|
next_response.endpointmodel,
|
||||||
|
next_response.endpoint,
|
||||||
self.next_page,
|
self.next_page,
|
||||||
next_response.limit,
|
next_response.limit,
|
||||||
self.params,
|
self.params,
|
||||||
|
|||||||
@ -69,34 +69,34 @@ def parse_response_body(
|
|||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
if first_page is not None:
|
if body.get("first_page") is not None:
|
||||||
result["first_page"] = first_page
|
result["first_page"] = body.get("first_page")
|
||||||
|
|
||||||
if prev_page is not None:
|
if body.get("prev_page") is not None:
|
||||||
result["prev_page"] = prev_page
|
result["prev_page"] = body.get("prev_page")
|
||||||
elif current_page is not None:
|
elif body.get("current_page") is not None:
|
||||||
if current_page > 1:
|
if body.get("current_page") > 1:
|
||||||
result["prev_page"] = current_page - 1
|
result["prev_page"] = body.get("current_page") - 1
|
||||||
|
|
||||||
if next_page is not None:
|
if body.get("next_page") is not None:
|
||||||
result["next_page"] = next_page
|
result["next_page"] = body.get("next_page")
|
||||||
|
|
||||||
if last_page is not None:
|
if body.get("last_page") is not None:
|
||||||
result["last_page"] = last_page
|
result["last_page"] = body.get("last_page")
|
||||||
elif last_page is None and current_page is not None:
|
elif body.get("last_page") is None and body.get("current_page") is not None:
|
||||||
result["last_page"] = math.ceil(total_count/limit)
|
result["last_page"] = math.ceil(body.get("total_count")/body.get("limit"))
|
||||||
|
|
||||||
if has_next_page:
|
if body.get("has_next_page"):
|
||||||
result["has_next_page"] = has_next_page
|
result["has_next_page"] = body.get("has_next_page")
|
||||||
elif current_page is not None and next_page is not None:
|
elif body.get("current_page") is not None and body.get("next_page") is not None:
|
||||||
result["has_next_page"] = True
|
result["has_next_page"] = True
|
||||||
elif current_page is not None and next_page is None:
|
elif body.get("current_page") is not None and body.get("next_page") is None:
|
||||||
result["has_next_page"] = False
|
result["has_next_page"] = False
|
||||||
|
|
||||||
if has_prev_page:
|
if body.get("has_prev_page"):
|
||||||
result["has_prev_page"] = has_prev_page
|
result["has_prev_page"] = body.get("has_prev_page")
|
||||||
elif current_page is not None:
|
elif body.get("current_page") is not None:
|
||||||
if current_page > 1:
|
if body.get("current_page") > 1:
|
||||||
result["has_prev_page"] = True
|
result["has_prev_page"] = True
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -39,17 +39,19 @@ siem_api_client = HuntressSIEMAPIClient(
|
|||||||
#signals = siem_api_client.signals.get()
|
#signals = siem_api_client.signals.get()
|
||||||
#print(signals)
|
#print(signals)
|
||||||
|
|
||||||
paginated_billingreports = siem_api_client.billing_reports.paginated(1, 10)
|
#paginated_billingreports = siem_api_client.billing_reports.paginated(1, 10)
|
||||||
print(paginated_billingreports.data)
|
#print(paginated_billingreports.data)
|
||||||
|
|
||||||
paginated_incidentreports = siem_api_client.incident_reports.paginated(1, 10)
|
#paginated_incidentreports = siem_api_client.incident_reports.paginated(1, 10)
|
||||||
print(paginated_incidentreports.data)
|
#print(paginated_incidentreports.data)
|
||||||
|
|
||||||
paginated_organizations = siem_api_client.organizations.paginated(1, 10)
|
paginated_organizations = siem_api_client.organizations.paginated(1, 1)
|
||||||
|
print(paginated_organizations.data)
|
||||||
|
paginated_organizations.get_next_page()
|
||||||
print(paginated_organizations.data)
|
print(paginated_organizations.data)
|
||||||
|
|
||||||
paginated_reports = siem_api_client.reports.paginated(1, 10)
|
#paginated_reports = siem_api_client.reports.paginated(1, 10)
|
||||||
print(paginated_reports.data)
|
#print(paginated_reports.data)
|
||||||
|
|
||||||
paginated_signals = siem_api_client.signals.paginated(1, 10)
|
#paginated_signals = siem_api_client.signals.paginated(1, 10)
|
||||||
print(paginated_signals.data)
|
#print(paginated_signals.data)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user