Skip to content

Commit b07da6a

Browse files
authored
Handle paginate to get full list of projects (#845)
1 parent 721a489 commit b07da6a

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

atlassian/bamboo.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,25 @@ def delete_label(self, project_key, plan_key, build_number, label):
594594

595595
def get_projects(self):
596596
"""Method used to list all projects defined in Bamboo.
597-
Projects without any plan are not listed by default, unless showEmpty query param is set to true."""
598-
resource = "project?showEmpty"
599-
for project in self.get(self.resource_url(resource)):
600-
yield project
597+
Projects without any plan are not listed."""
598+
start_idx = 0
599+
max_results = 25
600+
601+
while True:
602+
resource = "project?start-index={}&max-result={}".format(start_idx, max_results)
603+
604+
r = self.get(self.resource_url(resource))
605+
606+
if r is None:
607+
break
608+
609+
if start_idx > r["projects"]["size"]:
610+
break
611+
612+
start_idx += max_results
613+
614+
for project in r["projects"]["project"]:
615+
yield project
601616

602617
def get_project(self, project_key):
603618
"""Method used to retrieve information for project specified as project key.

0 commit comments

Comments
 (0)