@@ -1432,15 +1432,28 @@ def invalidate_websudo(self):
14321432
14331433 def user_find_by_user_string (
14341434 self ,
1435- username ,
1435+ username = None ,
1436+ query = None ,
1437+ account_id = None ,
1438+ property_key = None ,
14361439 start = 0 ,
14371440 limit = 50 ,
14381441 include_inactive_users = False ,
14391442 include_active_users = True ,
14401443 ):
14411444 """
1442- Fuzzy search using username and display name
1443- :param username: Use '.' to find all users
1445+ Fuzzy search using display name, emailAddress or property, or an exact search for accountId or username
1446+
1447+ On Jira Cloud, you can use only one of query or account_id params. You may not specify username.
1448+ On Jira Server, you must specify a username. You may not use query, account_id or property_key.
1449+
1450+ :param username: OPTIONAL: Required for Jira Server, cannot be used on Jira Cloud.
1451+ Use '.' to find all users.
1452+ :param query: OPTIONAL: String matched against "displayName" and "emailAddress" user attributes
1453+ :param account_id: OPTIONAL: String matched exactly against a user "accountId".
1454+ Required unless "query" or "property" parameters are specified.
1455+ :param property_key: OPTIONAL: String used to search properties by key. Required unless
1456+ "account_id" or "query" is specified.
14441457 :param start: OPTIONAL: The start point of the collection to return. Default: 0.
14451458 :param limit: OPTIONAL: The limit of the number of users to return, this may be restricted by
14461459 fixed system limits. Default by built-in method: 50
@@ -1450,12 +1463,33 @@ def user_find_by_user_string(
14501463 """
14511464 url = "rest/api/2/user/search"
14521465 params = {
1453- "username" : username ,
14541466 "includeActive" : include_active_users ,
14551467 "includeInactive" : include_inactive_users ,
14561468 "startAt" : start ,
14571469 "maxResults" : limit ,
14581470 }
1471+
1472+ if self .cloud :
1473+ if username :
1474+ return "Jira Cloud no longer supports a username parameter, use account_id, query or property_key"
1475+ elif account_id and query :
1476+ return "You cannot specify both the query and account_id parameters"
1477+ elif not any ([account_id , query , property_key ]):
1478+ return "You must specify at least one parameter: query or account_id or property_key"
1479+ elif account_id :
1480+ params ["accountId" ] = account_id
1481+
1482+ if query :
1483+ params ["query" ] = query
1484+ if property_key :
1485+ params ["property" ] = property_key
1486+ elif not username :
1487+ return "Username parameter is required for user search on Jira Server"
1488+ elif any ([account_id , query , property_key ]):
1489+ return "Jira Server does not support account_id, query or property_key parameters"
1490+ else :
1491+ params ["username" ] = username
1492+
14591493 return self .get (url , params = params )
14601494
14611495 def is_user_in_application (self , username , application_key ):
0 commit comments