Skip to content

Commit

Permalink
starting after logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasjhall committed Jan 12, 2021
1 parent f739909 commit 0d51e68
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
### Issues

- Closes #11
- Closes #12

## Changed
### Added

- _get_data now has `id_override=None` so you can override `&starting_after=` as you wish
- `id_override=0` implemented in Logs get_logs()

### Changed

- Changed paginaition to work without compounding to a `414`

Expand Down
6 changes: 3 additions & 3 deletions SimpleMDMpy/Logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def __init__(self, api_key):
SimpleMDMpy.SimpleMDM.Connection.__init__(self, api_key)
self.url = self._url("/logs")

def get_logs(self):
"""And I mean all the LOGS, before pagination"""
def get_logs(self, id_override=0):
"""And I mean all the LOGS"""
url = self.url
data = {}
return self._get_data(url, data)
return self._get_data(url, data, id_override=id_override)
6 changes: 3 additions & 3 deletions SimpleMDMpy/SimpleMDM.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def _url(self, path): #pylint: disable=no-self-use
"""base api url"""
return 'https://a.simplemdm.com/api/v1' + path

def _get_data(self, url, data=None):
def _get_data(self, url, data=None, id_override=None):
"""GET call to SimpleMDM API"""
id = 0 #pylint: disable=invalid-name,redefined-builtin
id = id_override #pylint: disable=invalid-name,redefined-builtin
has_more = True
resp_data = []
while has_more:
Expand All @@ -36,7 +36,7 @@ def _get_data(self, url, data=None):
if not resp.status_code in range(200, 207):
break
has_more = resp_json.get('has_more', None)
if has_more is None:
if has_more is None or resp_json['data'] == []:
resp_data = resp_json['data']
break
else:
Expand Down

0 comments on commit 0d51e68

Please sign in to comment.