@@ -1432,15 +1432,28 @@ def invalidate_websudo(self):
1432
1432
1433
1433
def user_find_by_user_string (
1434
1434
self ,
1435
- username ,
1435
+ username = None ,
1436
+ query = None ,
1437
+ account_id = None ,
1438
+ property_key = None ,
1436
1439
start = 0 ,
1437
1440
limit = 50 ,
1438
1441
include_inactive_users = False ,
1439
1442
include_active_users = True ,
1440
1443
):
1441
1444
"""
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.
1444
1457
:param start: OPTIONAL: The start point of the collection to return. Default: 0.
1445
1458
:param limit: OPTIONAL: The limit of the number of users to return, this may be restricted by
1446
1459
fixed system limits. Default by built-in method: 50
@@ -1450,12 +1463,33 @@ def user_find_by_user_string(
1450
1463
"""
1451
1464
url = "rest/api/2/user/search"
1452
1465
params = {
1453
- "username" : username ,
1454
1466
"includeActive" : include_active_users ,
1455
1467
"includeInactive" : include_inactive_users ,
1456
1468
"startAt" : start ,
1457
1469
"maxResults" : limit ,
1458
1470
}
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
+
1459
1493
return self .get (url , params = params )
1460
1494
1461
1495
def is_user_in_application (self , username , application_key ):
0 commit comments