Skip to content

chore: working with properly endpoint for current Jira v10.3.7 version #2356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1743,29 +1743,53 @@ def group_members(self, group: str) -> OrderedDict:
Args:
group (str): Name of the group.
"""
users = {}

if self._version < (6, 0, 0):
raise NotImplementedError(
"Group members is not implemented in Jira before version 6.0, upgrade the instance, if possible."
"Group members is not implemented in Jira before version 6.0,"
" upgrade the instance, if possible."
)

params = {"groupname": group, "expand": "users"}
r = self._get_json("group", params=params)
size = r["users"]["size"]
end_index = r["users"]["end-index"]

while end_index < size - 1:
params = {
"groupname": group,
"expand": f"users[{end_index + 1}:{end_index + 50}]",
}
r2 = self._get_json("group", params=params)
for user in r2["users"]["items"]:
r["users"]["items"].append(user)
end_index = r2["users"]["end-index"]
elif self._version < (10, 0, 0):
params = {"groupname": group, "expand": "users"}
r = self._get_json("group", params=params)
size = r["users"]["size"]
end_index = r["users"]["end-index"]

while end_index < size - 1:
params = {
"groupname": group,
"expand": f"users[{end_index + 1}:{end_index + 50}]",
}
r2 = self._get_json("group", params=params)
for user in r2["users"]["items"]:
r["users"]["items"].append(user)
end_index = r2["users"]["end-index"]
size = r["users"]["size"]
users = r["users"]["items"]
else:
params = {"groupname": group}
group_member_api_endpoint = "group/member"
r = self._get_json(group_member_api_endpoint, params=params)
end_index = r["maxResults"]
is_last = r["isLast"]

while is_last is False:
params = {
"groupname": group,
"startAt": f"{end_index}",
}
r2 = self._get_json(group_member_api_endpoint, params=params)
is_last = r2["isLast"]
for user in r2["values"]:
r["values"].append(user)
end_index += r2["maxResults"]

users = r["values"]

result = {}
for user in r["users"]["items"]:
for user in users:
# 'id' is likely available only in older JIRA Server,
# it's not available on newer JIRA Server.
# 'name' is not available in JIRA Cloud.
Expand Down
Loading