Skip to content

Commit 502e554

Browse files
authored
Make search_assignable_users_for_issues function GDPR compliant. (#1117)
* Added query parameter to `search_assignable_users_for_issues()` function for GDPR compatibality. * Update docstring
1 parent 20680c5 commit 502e554

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

jira/client.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -2891,21 +2891,24 @@ def search_assignable_users_for_projects(
28912891

28922892
def search_assignable_users_for_issues(
28932893
self,
2894-
username: str,
2894+
username: Optional[str] = None,
28952895
project: Optional[str] = None,
28962896
issueKey: Optional[str] = None,
28972897
expand: Optional[Any] = None,
28982898
startAt: int = 0,
28992899
maxResults: int = 50,
2900+
query: Optional[str] = None,
29002901
):
29012902
"""Get a list of user Resources that match the search string for assigning or creating issues.
2903+
"username" query parameter is deprecated in Jira Cloud; the expected parameter now is "query", which can just be
2904+
the full email again. But the "user" parameter is kept for backwards compatibility, i.e. Jira Server/Data Center.
29022905
29032906
This method is intended to find users that are eligible to create issues in a project or be assigned
29042907
to an existing issue. When searching for eligible creators, specify a project. When searching for eligible
29052908
assignees, specify an issue key.
29062909
29072910
Args:
2908-
username (str): A string to match usernames against
2911+
username (Optional[str]): A string to match usernames against
29092912
project (Optional[str]): Filter returned users by permission in this project
29102913
(expected if a result will be used to create an issue)
29112914
issueKey (Optional[str]): Filter returned users by this issue
@@ -2914,17 +2917,27 @@ def search_assignable_users_for_issues(
29142917
startAt (int): Index of the first user to return (Default: 0)
29152918
maxResults (int): maximum number of users to return.
29162919
If maxResults evaluates as False, it will try to get all items in batches. (Default: 50)
2920+
query (Optional[str]): Search term. It can just be the email.
29172921
29182922
Returns:
29192923
ResultList
29202924
"""
2921-
params = {"username": username}
2925+
if username is not None:
2926+
params = {"username": username}
2927+
if query is not None:
2928+
params = {"query": query}
29222929
if project is not None:
29232930
params["project"] = project
29242931
if issueKey is not None:
29252932
params["issueKey"] = issueKey
29262933
if expand is not None:
29272934
params["expand"] = expand
2935+
2936+
if not username and not query:
2937+
raise ValueError(
2938+
"Either 'username' or 'query' arguments must be specified."
2939+
)
2940+
29282941
return self._fetch_pages(
29292942
User, None, "user/assignable/search", startAt, maxResults, params
29302943
)

0 commit comments

Comments
 (0)