Skip to content

Commit

Permalink
Version 2.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
mminichino committed Dec 20, 2023
1 parent fdd0ffd commit c998635
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cbcmgr/cb_capella.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def list_users(self):
return results

def get_user(self, name: str = None, email: str = None):
results = self.api_get(f"/v4/organizations/{self.organization_id}/users").json()
results = self.capella_get(f"/v4/organizations/{self.organization_id}/users")

return next((u for u in results if u.get('name') == name or u.get('email') == email), None)

Expand Down
13 changes: 13 additions & 0 deletions cbcmgr/httpsessionmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ def api_get(self, endpoint, items=None):
self._response = response_text
return self

def capella_get(self, endpoint):
page = 1
items = []
while True:
url = f"{self.url_prefix}{endpoint}?page={page}&perPage=100"
response = self.session.get(url, auth=self.auth_class, verify=False, timeout=self.timeout)
response_json = json.loads(response.text)
items.extend(response_json.get('data'))
page = response_json.get('cursor', {}).get('pages', {}).get('next', 0)
if page == 0:
break
return items

def api_post(self, endpoint, body):
response = self.session.post(self.url_prefix + endpoint,
auth=self.auth_class,
Expand Down

0 comments on commit c998635

Please sign in to comment.