Skip to content

Commit

Permalink
Fix CR
Browse files Browse the repository at this point in the history
  • Loading branch information
liormgem committed Mar 19, 2024
1 parent 8a8d22e commit 35d610b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Packs/Gem/Integrations/Gem/Gem.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def _generate_token(self) -> str:

return token_res.get('access_token')

def _filter_non_empty_params(self, params):
return {k: v for k, v in params.items() if v is not None}

def fetch_threats(self, maxincidents=None, start_time=None) -> list[dict]:
"""
Fetches a list of threats from the Gem API.
Expand All @@ -165,7 +168,7 @@ def fetch_threats(self, maxincidents=None, start_time=None) -> list[dict]:
return self.http_request(
method='GET',
url_suffix=FETCH_ENDPOINT,
params={k: v for k, v in params.items() if v is not None}
params=self._filter_non_empty_params(params)

)

Expand Down Expand Up @@ -206,7 +209,7 @@ def get_alert_details(self, alert_id: str):
response = self.http_request(
method='GET',
url_suffix=ALERTS_ENDPOINT,
params={k: v for k, v in params.items() if v is not None}
params=self._filter_non_empty_params(params)
)

return response
Expand Down Expand Up @@ -243,7 +246,7 @@ def list_threats(self, limit, time_start=None, time_end=None, ordering=None, sta
response = self.http_request(
method='GET',
url_suffix=THREATS_ENDPOINT,
params={k: v for k, v in params.items() if v is not None}
params=self._filter_non_empty_params(params)

)
results_fetched = limit
Expand All @@ -256,7 +259,7 @@ def list_threats(self, limit, time_start=None, time_end=None, ordering=None, sta
response = self.http_request(
method='GET',
url_suffix=THREATS_ENDPOINT,
params={k: v for k, v in params.items() if v is not None}
params=self._filter_non_empty_params(params)

)
if len(response['results']) < PAGE_SIZE:
Expand Down Expand Up @@ -294,7 +297,7 @@ def list_inventory_resources(self, limit, include_deleted=None, region=None, res
response = self.http_request(
method='GET',
url_suffix=INVENTORY_ENDPOINT,
params={k: v for k, v in params.items() if v is not None}
params=self._filter_non_empty_params(params)

)
results_fetched += len(response['results'])
Expand All @@ -308,7 +311,7 @@ def list_inventory_resources(self, limit, include_deleted=None, region=None, res
response = self.http_request(
method='GET',
url_suffix=INVENTORY_ENDPOINT,
params={k: v for k, v in params.items() if v is not None}
params=self._filter_non_empty_params(params)

)
results_fetched += len(response['results'])
Expand All @@ -325,7 +328,7 @@ def _breakdown(self, breakdown_by, entity_id=None, entity_type=None, read_only=N
response = self.http_request(
method='GET',
url_suffix=BREAKDOWN_ENDPOINT,
params={k: v for k, v in params.items() if v is not None}
params=self._filter_non_empty_params(params)
)

return response['table']
Expand Down Expand Up @@ -499,7 +502,7 @@ def run_action_on_entity(self, action: str, entity_id: str, entity_type: str, al
response = self.http_request(
method='POST',
url_suffix=RUN_ACTION_ENDPOINT,
params={k: v for k, v in params.items() if v is not None}
params=self._filter_non_empty_params(params)
)

return response
Expand All @@ -520,7 +523,7 @@ def add_timeline_event(self, threat_id: str, comment: str, timestamp: str) -> di
response = self.http_request(
method='POST',
url_suffix=ADD_TIMELINE_EVENT_ENDPOINT.format(id=threat_id),
json_data={k: v for k, v in params.items() if v is not None}
json_data=self._filter_non_empty_params(params)
)

return response
Expand Down

0 comments on commit 35d610b

Please sign in to comment.