atlassian-python-api 5.0.2__py3-none-any.whl → 5.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atlassian/VERSION +1 -1
- atlassian/__init__.py +7 -1
- atlassian/assets/__init__.py +6 -0
- atlassian/{assets.py → assets/assets_cloud.py} +264 -6
- atlassian/assets/assets_server.py +24 -0
- atlassian/bamboo.py +819 -2
- atlassian/bitbucket/__init__.py +149 -0
- atlassian/bitbucket/cloud/repositories/commits.py +13 -3
- atlassian/bitbucket/cloud/repositories/repositoryVariables.py +23 -0
- atlassian/bitbucket/cloud/workspaces/__init__.py +6 -1
- atlassian/company_calendar.py +215 -0
- atlassian/compass/__init__.py +109 -0
- atlassian/confluence/base.py +12 -1
- atlassian/confluence/cloud/__init__.py +17 -0
- atlassian/confluence/cloud/admin_management.py +125 -0
- atlassian/confluence/cloud/cloud.py +7 -21
- atlassian/confluence/server/__init__.py +140 -16
- atlassian/confluence_base.py +24 -13
- atlassian/crowd.py +1204 -6
- atlassian/jira/jira_cloud.py +83 -0
- atlassian/jira/jira_server.py +165 -31
- atlassian/service_desk.py +71 -11
- atlassian/{xray.py → xray/__init__.py} +136 -9
- {atlassian_python_api-5.0.2.dist-info → atlassian_python_api-5.0.4.dist-info}/METADATA +2 -5
- {atlassian_python_api-5.0.2.dist-info → atlassian_python_api-5.0.4.dist-info}/RECORD +28 -23
- {atlassian_python_api-5.0.2.dist-info → atlassian_python_api-5.0.4.dist-info}/WHEEL +0 -0
- {atlassian_python_api-5.0.2.dist-info → atlassian_python_api-5.0.4.dist-info}/licenses/LICENSE +0 -0
- {atlassian_python_api-5.0.2.dist-info → atlassian_python_api-5.0.4.dist-info}/top_level.txt +0 -0
atlassian/crowd.py
CHANGED
|
@@ -25,8 +25,12 @@ class Crowd(AtlassianRestAPI):
|
|
|
25
25
|
):
|
|
26
26
|
super(Crowd, self).__init__(url, username, password, timeout, api_root, api_version)
|
|
27
27
|
|
|
28
|
-
def _crowd_api_url(self, api, resource):
|
|
29
|
-
|
|
28
|
+
def _crowd_api_url(self, api, resource, api_version=None):
|
|
29
|
+
version = api_version or self.api_version
|
|
30
|
+
return f"/{self.api_root}/{api}/{version}/{resource}"
|
|
31
|
+
|
|
32
|
+
def _admin_api_url(self, resource):
|
|
33
|
+
return f"/{self.api_root}/admin/1.0/{resource}"
|
|
30
34
|
|
|
31
35
|
def _user_change_status(self, username, active):
|
|
32
36
|
"""
|
|
@@ -167,17 +171,18 @@ class Crowd(AtlassianRestAPI):
|
|
|
167
171
|
def group_add_user(self, username, groupname):
|
|
168
172
|
"""
|
|
169
173
|
Add user to group
|
|
174
|
+
:param username: str - username
|
|
175
|
+
:param groupname: str - group name
|
|
170
176
|
:return:
|
|
171
177
|
"""
|
|
172
178
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
params = {"username": username}
|
|
179
|
+
params = {"groupname": groupname}
|
|
180
|
+
data = {"name": username}
|
|
176
181
|
|
|
177
182
|
return self.post(
|
|
178
183
|
self._crowd_api_url("usermanagement", "user/group/direct"),
|
|
179
184
|
params=params,
|
|
180
|
-
|
|
185
|
+
data=data,
|
|
181
186
|
)
|
|
182
187
|
|
|
183
188
|
def group_remove_user(self, username, groupname):
|
|
@@ -258,6 +263,1199 @@ class Crowd(AtlassianRestAPI):
|
|
|
258
263
|
response = self.get(self._crowd_api_url("usermanagement", "user/group/nested"), params={"username": username})
|
|
259
264
|
return search("groups[*].name", response)
|
|
260
265
|
|
|
266
|
+
def group_child_groups(self, groupname, child_groupname=None, start_index=0, max_results=99999):
|
|
267
|
+
"""
|
|
268
|
+
Get direct child groups of a group.
|
|
269
|
+
:param groupname: str - parent group name
|
|
270
|
+
:param child_groupname: str - optional single child group name to retrieve
|
|
271
|
+
:param start_index: int - start index for paging
|
|
272
|
+
:param max_results: int - maximum number of results
|
|
273
|
+
:return: list of group names
|
|
274
|
+
"""
|
|
275
|
+
path = self._crowd_api_url("usermanagement", "group/child-group/direct")
|
|
276
|
+
params = {"groupname": groupname, "start-index": start_index, "max-results": max_results}
|
|
277
|
+
if child_groupname:
|
|
278
|
+
params["child-groupname"] = child_groupname
|
|
279
|
+
response = self.get(path, params=params)
|
|
280
|
+
return search("groups[*].name", response)
|
|
281
|
+
|
|
282
|
+
def nested_group_child_groups(self, groupname, child_groupname=None, start_index=0, max_results=99999):
|
|
283
|
+
"""
|
|
284
|
+
Get nested child groups of a group.
|
|
285
|
+
:param groupname: str - parent group name
|
|
286
|
+
:param child_groupname: str - optional single nested child group name to retrieve
|
|
287
|
+
:param start_index: int - start index for paging
|
|
288
|
+
:param max_results: int - maximum number of results
|
|
289
|
+
:return: list of group names
|
|
290
|
+
"""
|
|
291
|
+
path = self._crowd_api_url("usermanagement", "group/child-group/nested")
|
|
292
|
+
params = {"groupname": groupname, "start-index": start_index, "max-results": max_results}
|
|
293
|
+
if child_groupname:
|
|
294
|
+
params["child-groupname"] = child_groupname
|
|
295
|
+
response = self.get(path, params=params)
|
|
296
|
+
return search("groups[*].name", response)
|
|
297
|
+
|
|
298
|
+
def group_add_child_group(self, groupname, child_groupname):
|
|
299
|
+
"""
|
|
300
|
+
Add a direct child group membership to a group.
|
|
301
|
+
:param groupname: str - parent group name
|
|
302
|
+
:param child_groupname: str - child group name to add
|
|
303
|
+
:return:
|
|
304
|
+
"""
|
|
305
|
+
params = {"groupname": groupname}
|
|
306
|
+
data = {"name": child_groupname}
|
|
307
|
+
return self.post(self._crowd_api_url("usermanagement", "group/child-group/direct"), params=params, data=data)
|
|
308
|
+
|
|
309
|
+
def group_remove_child_group(self, groupname, child_groupname):
|
|
310
|
+
"""
|
|
311
|
+
Remove a direct child group membership from a group.
|
|
312
|
+
:param groupname: str - parent group name
|
|
313
|
+
:param child_groupname: str - child group name to remove
|
|
314
|
+
:return:
|
|
315
|
+
"""
|
|
316
|
+
params = {"groupname": groupname, "child-groupname": child_groupname}
|
|
317
|
+
return self.delete(self._crowd_api_url("usermanagement", "group/child-group/direct"), params=params)
|
|
318
|
+
|
|
319
|
+
def group_parent_groups(self, groupname, child_groupname=None, start_index=0, max_results=99999):
|
|
320
|
+
"""
|
|
321
|
+
Get direct parent groups of a group.
|
|
322
|
+
:param groupname: str - group name
|
|
323
|
+
:param child_groupname: str - optional child group name
|
|
324
|
+
:param start_index: int - start index for paging
|
|
325
|
+
:param max_results: int - maximum number of results
|
|
326
|
+
:return: list of group names
|
|
327
|
+
"""
|
|
328
|
+
path = self._crowd_api_url("usermanagement", "group/parent-group/direct")
|
|
329
|
+
params = {"groupname": groupname, "start-index": start_index, "max-results": max_results}
|
|
330
|
+
if child_groupname:
|
|
331
|
+
params["child-groupname"] = child_groupname
|
|
332
|
+
response = self.get(path, params=params)
|
|
333
|
+
return search("groups[*].name", response)
|
|
334
|
+
|
|
335
|
+
def nested_group_parent_groups(self, groupname, parent_groupname=None, start_index=0, max_results=99999):
|
|
336
|
+
"""
|
|
337
|
+
Get nested parent groups of a group.
|
|
338
|
+
:param groupname: str - group name
|
|
339
|
+
:param parent_groupname: str - optional single parent group name to retrieve
|
|
340
|
+
:param start_index: int - start index for paging
|
|
341
|
+
:param max_results: int - maximum number of results
|
|
342
|
+
:return: list of group names
|
|
343
|
+
"""
|
|
344
|
+
path = self._crowd_api_url("usermanagement", "group/parent-group/nested")
|
|
345
|
+
params = {"groupname": groupname, "start-index": start_index, "max-results": max_results}
|
|
346
|
+
if parent_groupname:
|
|
347
|
+
params["parent-groupname"] = parent_groupname
|
|
348
|
+
response = self.get(path, params=params)
|
|
349
|
+
return search("groups[*].name", response)
|
|
350
|
+
|
|
351
|
+
def group_add_parent_group(self, groupname, parent_groupname):
|
|
352
|
+
"""
|
|
353
|
+
Add a direct parent group membership to a group.
|
|
354
|
+
:param groupname: str - child group name
|
|
355
|
+
:param parent_groupname: str - parent group name to add
|
|
356
|
+
:return:
|
|
357
|
+
"""
|
|
358
|
+
params = {"groupname": groupname}
|
|
359
|
+
data = {"name": parent_groupname}
|
|
360
|
+
return self.post(self._crowd_api_url("usermanagement", "group/parent-group/direct"), params=params, data=data)
|
|
361
|
+
|
|
362
|
+
def session_create(self, username, password, validate_password=True, duration=None):
|
|
363
|
+
"""
|
|
364
|
+
Authenticate a user and create a Crowd SSO session.
|
|
365
|
+
:param username: str - username
|
|
366
|
+
:param password: str - password
|
|
367
|
+
:param validate_password: bool - whether to validate the password
|
|
368
|
+
:param duration: int - requested token duration in seconds
|
|
369
|
+
:return: session info
|
|
370
|
+
"""
|
|
371
|
+
params = {"validate-password": str(validate_password).lower()}
|
|
372
|
+
if duration:
|
|
373
|
+
params["duration"] = duration
|
|
374
|
+
data = {"userName": username, "password": password}
|
|
375
|
+
return self.post(self._crowd_api_url("usermanagement", "session"), params=params, data=data)
|
|
376
|
+
|
|
377
|
+
def session_validate(self, token, validation_factors=None):
|
|
378
|
+
"""
|
|
379
|
+
Validate a Crowd SSO session token.
|
|
380
|
+
:param token: str - SSO token
|
|
381
|
+
:param validation_factors: dict - validation factors request body
|
|
382
|
+
:return: session info
|
|
383
|
+
"""
|
|
384
|
+
data = validation_factors or {}
|
|
385
|
+
return self.post(self._crowd_api_url("usermanagement", f"session/{token}"), data=data)
|
|
386
|
+
|
|
387
|
+
def session_get(self, token):
|
|
388
|
+
"""
|
|
389
|
+
Get session information by token.
|
|
390
|
+
:param token: str - SSO token
|
|
391
|
+
:return: session info
|
|
392
|
+
"""
|
|
393
|
+
return self.get(self._crowd_api_url("usermanagement", f"session/{token}"))
|
|
394
|
+
|
|
395
|
+
def session_delete(self, token):
|
|
396
|
+
"""
|
|
397
|
+
Invalidate a Crowd SSO session token.
|
|
398
|
+
:param token: str - SSO token
|
|
399
|
+
:return:
|
|
400
|
+
"""
|
|
401
|
+
return self.delete(self._crowd_api_url("usermanagement", f"session/{token}"))
|
|
402
|
+
|
|
403
|
+
def session_delete_user_tokens(self, username, exclude=None):
|
|
404
|
+
"""
|
|
405
|
+
Delete all tokens for a user, optionally excluding one token.
|
|
406
|
+
:param username: str - username
|
|
407
|
+
:param exclude: str - token to exclude from invalidation
|
|
408
|
+
:return:
|
|
409
|
+
"""
|
|
410
|
+
params = {"username": username}
|
|
411
|
+
if exclude:
|
|
412
|
+
params["exclude"] = exclude
|
|
413
|
+
return self.delete(self._crowd_api_url("usermanagement", "session"), params=params)
|
|
414
|
+
|
|
415
|
+
def search_cql(self, entity_type, restriction=None, start_index=0, max_results=99999):
|
|
416
|
+
"""
|
|
417
|
+
Search entities using Crowd Query Language (GET).
|
|
418
|
+
:param entity_type: str - type of entity to search
|
|
419
|
+
:param restriction: str - CQL restriction
|
|
420
|
+
:param start_index: int - start index for paging
|
|
421
|
+
:param max_results: int - maximum number of results
|
|
422
|
+
:return: search results
|
|
423
|
+
"""
|
|
424
|
+
params = {"entity-type": entity_type, "start-index": start_index, "max-results": max_results}
|
|
425
|
+
if restriction:
|
|
426
|
+
params["restriction"] = restriction
|
|
427
|
+
return self.get(self._crowd_api_url("usermanagement", "search"), params=params)
|
|
428
|
+
|
|
429
|
+
def search(self, entity_type, restriction=None, start_index=0, max_results=99999):
|
|
430
|
+
"""
|
|
431
|
+
Search entities using a search restriction body (POST).
|
|
432
|
+
:param entity_type: str - type of entity to search
|
|
433
|
+
:param restriction: dict - search restriction request body
|
|
434
|
+
:param start_index: int - start index for paging
|
|
435
|
+
:param max_results: int - maximum number of results
|
|
436
|
+
:return: search results
|
|
437
|
+
"""
|
|
438
|
+
params = {"entity-type": entity_type, "start-index": start_index, "max-results": max_results}
|
|
439
|
+
data = restriction or {}
|
|
440
|
+
return self.post(self._crowd_api_url("usermanagement", "search"), params=params, data=data)
|
|
441
|
+
|
|
442
|
+
def user_authenticate(self, username, password):
|
|
443
|
+
"""
|
|
444
|
+
Authenticate a user and return user information.
|
|
445
|
+
:param username: str - username
|
|
446
|
+
:param password: str - password
|
|
447
|
+
:return: user info
|
|
448
|
+
"""
|
|
449
|
+
params = {"username": username}
|
|
450
|
+
data = {"value": password}
|
|
451
|
+
return self.post(self._crowd_api_url("usermanagement", "authentication"), params=params, data=data)
|
|
452
|
+
|
|
453
|
+
def user_authentication_notify(self, username):
|
|
454
|
+
"""
|
|
455
|
+
Notify Crowd that a user has been authenticated by a trusted application.
|
|
456
|
+
:param username: str - username
|
|
457
|
+
:return:
|
|
458
|
+
"""
|
|
459
|
+
params = {"username": username}
|
|
460
|
+
return self.post(self._crowd_api_url("usermanagement", "authentication/notify"), params=params)
|
|
461
|
+
|
|
462
|
+
def user_delete_password(self, username):
|
|
463
|
+
"""
|
|
464
|
+
Delete a user's password.
|
|
465
|
+
:param username: str - username
|
|
466
|
+
:return:
|
|
467
|
+
"""
|
|
468
|
+
params = {"username": username}
|
|
469
|
+
return self.delete(self._crowd_api_url("usermanagement", "user/password"), params=params)
|
|
470
|
+
|
|
471
|
+
def user_request_password_reset(self, username):
|
|
472
|
+
"""
|
|
473
|
+
Request a password reset email for a user.
|
|
474
|
+
:param username: str - username
|
|
475
|
+
:return:
|
|
476
|
+
"""
|
|
477
|
+
params = {"username": username}
|
|
478
|
+
return self.post(self._crowd_api_url("usermanagement", "user/mail/password"), params=params)
|
|
479
|
+
|
|
480
|
+
def user_request_usernames_reminder(self, email):
|
|
481
|
+
"""
|
|
482
|
+
Request a username reminder email.
|
|
483
|
+
:param email: str - email address
|
|
484
|
+
:return:
|
|
485
|
+
"""
|
|
486
|
+
params = {"email": email}
|
|
487
|
+
return self.post(self._crowd_api_url("usermanagement", "user/mail/usernames"), params=params)
|
|
488
|
+
|
|
489
|
+
def user_rename(self, username, new_name):
|
|
490
|
+
"""
|
|
491
|
+
Rename a user.
|
|
492
|
+
:param username: str - current username
|
|
493
|
+
:param new_name: str - new username
|
|
494
|
+
:return:
|
|
495
|
+
"""
|
|
496
|
+
params = {"username": username}
|
|
497
|
+
data = {"newName": new_name}
|
|
498
|
+
return self.post(self._crowd_api_url("usermanagement", "user/rename"), params=params, data=data)
|
|
499
|
+
|
|
500
|
+
def user_expire_all_passwords(self, confirm=True):
|
|
501
|
+
"""
|
|
502
|
+
Expire all user passwords.
|
|
503
|
+
:param confirm: bool - must be True to perform the action
|
|
504
|
+
:return:
|
|
505
|
+
"""
|
|
506
|
+
params = {"confirm": str(confirm).lower()}
|
|
507
|
+
return self.post(self._crowd_api_url("usermanagement", "user/expire-all-passwords"), params=params)
|
|
508
|
+
|
|
509
|
+
def user_avatar(self, username, size=None):
|
|
510
|
+
"""
|
|
511
|
+
Get a user's avatar.
|
|
512
|
+
:param username: str - username
|
|
513
|
+
:param size: int - requested avatar size in pixels
|
|
514
|
+
:return: avatar content
|
|
515
|
+
"""
|
|
516
|
+
params = {"username": username}
|
|
517
|
+
if size:
|
|
518
|
+
params["s"] = size
|
|
519
|
+
return self.get(self._crowd_api_url("usermanagement", "user/avatar"), params=params)
|
|
520
|
+
|
|
521
|
+
def get_cookie_config(self):
|
|
522
|
+
"""Get the Crowd cookie configuration."""
|
|
523
|
+
return self.get(self._crowd_api_url("usermanagement", "config/cookie"))
|
|
524
|
+
|
|
525
|
+
def account_change_password(self, username, old_password, new_password):
|
|
526
|
+
"""
|
|
527
|
+
Change the current user's password.
|
|
528
|
+
:param username: str - username
|
|
529
|
+
:param old_password: str - current password
|
|
530
|
+
:param new_password: str - new password
|
|
531
|
+
:return:
|
|
532
|
+
"""
|
|
533
|
+
data = {"username": username, "oldPassword": old_password, "newPassword": new_password}
|
|
534
|
+
return self.post(self._crowd_api_url("account", "change-password", api_version="1"), data=data)
|
|
535
|
+
|
|
536
|
+
def account_forgotten_password(self, username):
|
|
537
|
+
"""
|
|
538
|
+
Start the forgotten password procedure.
|
|
539
|
+
:param username: str - username
|
|
540
|
+
:return:
|
|
541
|
+
"""
|
|
542
|
+
return self.post(
|
|
543
|
+
self._crowd_api_url("account", "forgotten-password", api_version="1"),
|
|
544
|
+
params={"username": username},
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
def account_forgotten_username(self, email):
|
|
548
|
+
"""
|
|
549
|
+
Start the forgotten username procedure.
|
|
550
|
+
:param email: str - email address
|
|
551
|
+
:return:
|
|
552
|
+
"""
|
|
553
|
+
return self.post(
|
|
554
|
+
self._crowd_api_url("account", "forgotten-username", api_version="1"),
|
|
555
|
+
params={"email": email},
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
def account_reset_password(self, username, token, password, directory_id=None):
|
|
559
|
+
"""
|
|
560
|
+
Reset a forgotten password.
|
|
561
|
+
:param username: str - username
|
|
562
|
+
:param token: str - reset token
|
|
563
|
+
:param password: str - new password
|
|
564
|
+
:param directory_id: int - directory id
|
|
565
|
+
:return:
|
|
566
|
+
"""
|
|
567
|
+
data = {"username": username, "token": token, "password": password}
|
|
568
|
+
if directory_id:
|
|
569
|
+
data["directoryId"] = directory_id
|
|
570
|
+
return self.post(self._crowd_api_url("account", "reset-password", api_version="1"), data=data)
|
|
571
|
+
|
|
572
|
+
def account_validate_token(self, username, token, directory_id=None):
|
|
573
|
+
"""
|
|
574
|
+
Check whether a user's reset token is still valid.
|
|
575
|
+
:param username: str - username
|
|
576
|
+
:param token: str - reset token
|
|
577
|
+
:param directory_id: int - directory id
|
|
578
|
+
:return:
|
|
579
|
+
"""
|
|
580
|
+
data = {"username": username, "token": token}
|
|
581
|
+
if directory_id:
|
|
582
|
+
data["directoryId"] = directory_id
|
|
583
|
+
return self.post(self._crowd_api_url("account", "token-status", api_version="1"), data=data)
|
|
584
|
+
|
|
585
|
+
def directory_test_azure_ad(self, config, directory_id=None):
|
|
586
|
+
"""
|
|
587
|
+
Test Microsoft Entra ID (Azure AD) directory connection.
|
|
588
|
+
:param config: dict - Azure AD connection test data
|
|
589
|
+
:param directory_id: int - optional directory id to test against
|
|
590
|
+
:return: connection test result
|
|
591
|
+
"""
|
|
592
|
+
path = "directorymanagement/1/directory/testazuread"
|
|
593
|
+
if directory_id:
|
|
594
|
+
path = f"{path}/{directory_id}"
|
|
595
|
+
return self.post(self.url_joiner(self.api_root, path), data=config)
|
|
596
|
+
|
|
597
|
+
def directory_test_crowd(self, config, directory_id=None):
|
|
598
|
+
"""
|
|
599
|
+
Test Crowd directory connection.
|
|
600
|
+
:param config: dict - Crowd connection test data
|
|
601
|
+
:param directory_id: int - optional directory id to test against
|
|
602
|
+
:return: connection test result
|
|
603
|
+
"""
|
|
604
|
+
path = "directorymanagement/1/directory/testcrowd"
|
|
605
|
+
if directory_id:
|
|
606
|
+
path = f"{path}/{directory_id}"
|
|
607
|
+
return self.post(self.url_joiner(self.api_root, path), data=config)
|
|
608
|
+
|
|
609
|
+
def directory_test_ldap(self, config, directory_id=None):
|
|
610
|
+
"""
|
|
611
|
+
Test LDAP directory connection.
|
|
612
|
+
:param config: dict - LDAP connection test data
|
|
613
|
+
:param directory_id: int - optional directory id to test against
|
|
614
|
+
:return: connection test result
|
|
615
|
+
"""
|
|
616
|
+
path = "directorymanagement/1/directory/testldap"
|
|
617
|
+
if directory_id:
|
|
618
|
+
path = f"{path}/{directory_id}"
|
|
619
|
+
return self.post(self.url_joiner(self.api_root, path), data=config)
|
|
620
|
+
|
|
621
|
+
def directory_test_ldap_search(self, config, directory_id=None):
|
|
622
|
+
"""
|
|
623
|
+
Test LDAP directory search.
|
|
624
|
+
:param config: dict - LDAP search test data
|
|
625
|
+
:param directory_id: int - optional directory id to test against
|
|
626
|
+
:return: search test result
|
|
627
|
+
"""
|
|
628
|
+
path = "directorymanagement/1/directory/testsearch"
|
|
629
|
+
if directory_id:
|
|
630
|
+
path = f"{path}/{directory_id}"
|
|
631
|
+
return self.post(self.url_joiner(self.api_root, path), data=config)
|
|
632
|
+
|
|
633
|
+
def user_aliases(self, username):
|
|
634
|
+
"""
|
|
635
|
+
Get all aliases for a user across alias-enabled applications.
|
|
636
|
+
:param username: str - username in Crowd
|
|
637
|
+
:return: aliases
|
|
638
|
+
"""
|
|
639
|
+
return self.get(self._crowd_api_url("appmanagement", "aliases", api_version="1"), params={"user": username})
|
|
640
|
+
|
|
641
|
+
def set_user_aliases(self, username, aliases):
|
|
642
|
+
"""
|
|
643
|
+
Set aliases for a user across applications.
|
|
644
|
+
:param username: str - username in Crowd
|
|
645
|
+
:param aliases: dict - mapping of application id to alias
|
|
646
|
+
:return:
|
|
647
|
+
"""
|
|
648
|
+
return self.put(
|
|
649
|
+
self._crowd_api_url("appmanagement", "aliases", api_version="1"),
|
|
650
|
+
params={"user": username},
|
|
651
|
+
data=aliases,
|
|
652
|
+
)
|
|
653
|
+
|
|
654
|
+
def delete_user_aliases(self, username):
|
|
655
|
+
"""
|
|
656
|
+
Delete all aliases for a user.
|
|
657
|
+
:param username: str - username in Crowd
|
|
658
|
+
:return:
|
|
659
|
+
"""
|
|
660
|
+
return self.delete(
|
|
661
|
+
self._crowd_api_url("appmanagement", "aliases", api_version="1"),
|
|
662
|
+
params={"user": username},
|
|
663
|
+
)
|
|
664
|
+
|
|
665
|
+
def get_alias(self, application_id, username):
|
|
666
|
+
"""
|
|
667
|
+
Get a user's alias in a specific application.
|
|
668
|
+
:param application_id: str - application id
|
|
669
|
+
:param username: str - username
|
|
670
|
+
:return: alias
|
|
671
|
+
"""
|
|
672
|
+
return self.get(
|
|
673
|
+
self._crowd_api_url("appmanagement", f"aliases/{application_id}/alias", api_version="1"),
|
|
674
|
+
params={"user": username},
|
|
675
|
+
)
|
|
676
|
+
|
|
677
|
+
def set_alias(self, application_id, username, alias):
|
|
678
|
+
"""
|
|
679
|
+
Set a user's alias in a specific application.
|
|
680
|
+
:param application_id: str - application id
|
|
681
|
+
:param username: str - username
|
|
682
|
+
:param alias: str - alias value
|
|
683
|
+
:return:
|
|
684
|
+
"""
|
|
685
|
+
headers = {"Content-Type": "text/plain"}
|
|
686
|
+
return self.put(
|
|
687
|
+
self._crowd_api_url("appmanagement", f"aliases/{application_id}/alias", api_version="1"),
|
|
688
|
+
params={"user": username},
|
|
689
|
+
data=alias,
|
|
690
|
+
headers=headers,
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
def delete_alias(self, application_id, username):
|
|
694
|
+
"""
|
|
695
|
+
Delete a user's alias in a specific application.
|
|
696
|
+
:param application_id: str - application id
|
|
697
|
+
:param username: str - username
|
|
698
|
+
:return:
|
|
699
|
+
"""
|
|
700
|
+
return self.delete(
|
|
701
|
+
self._crowd_api_url("appmanagement", f"aliases/{application_id}/alias", api_version="1"),
|
|
702
|
+
params={"user": username},
|
|
703
|
+
)
|
|
704
|
+
|
|
705
|
+
def get_username_for_alias(self, application_id, alias):
|
|
706
|
+
"""
|
|
707
|
+
Get the username for an alias in a specific application.
|
|
708
|
+
:param application_id: str - application id
|
|
709
|
+
:param alias: str - alias
|
|
710
|
+
:return: username
|
|
711
|
+
"""
|
|
712
|
+
return self.get(
|
|
713
|
+
self._crowd_api_url("appmanagement", f"aliases/{application_id}/username", api_version="1"),
|
|
714
|
+
params={"alias": alias},
|
|
715
|
+
)
|
|
716
|
+
|
|
717
|
+
def get_applications(self, name=None):
|
|
718
|
+
"""
|
|
719
|
+
Get all applications or a specific application by name.
|
|
720
|
+
:param name: str - optional application name to filter by
|
|
721
|
+
:return: applications
|
|
722
|
+
"""
|
|
723
|
+
params = {"name": name} if name else {}
|
|
724
|
+
return self.get(self._crowd_api_url("appmanagement", "application", api_version="1"), params=params)
|
|
725
|
+
|
|
726
|
+
def create_application(self, data, include_request_address=None):
|
|
727
|
+
"""
|
|
728
|
+
Add a new application.
|
|
729
|
+
:param data: dict - application representation
|
|
730
|
+
:param include_request_address: bool - include request address in response
|
|
731
|
+
:return:
|
|
732
|
+
"""
|
|
733
|
+
params = {}
|
|
734
|
+
if include_request_address is not None:
|
|
735
|
+
params["include-request-address"] = include_request_address
|
|
736
|
+
return self.post(
|
|
737
|
+
self._crowd_api_url("appmanagement", "application", api_version="1"),
|
|
738
|
+
params=params,
|
|
739
|
+
data=data,
|
|
740
|
+
)
|
|
741
|
+
|
|
742
|
+
def get_application(self, application_id):
|
|
743
|
+
"""
|
|
744
|
+
Get an application by id.
|
|
745
|
+
:param application_id: str - application id
|
|
746
|
+
:return: application
|
|
747
|
+
"""
|
|
748
|
+
return self.get(self._crowd_api_url("appmanagement", f"application/{application_id}", api_version="1"))
|
|
749
|
+
|
|
750
|
+
def update_application(self, application_id, data):
|
|
751
|
+
"""
|
|
752
|
+
Update an application.
|
|
753
|
+
:param application_id: str - application id
|
|
754
|
+
:param data: dict - application representation
|
|
755
|
+
:return:
|
|
756
|
+
"""
|
|
757
|
+
return self.put(
|
|
758
|
+
self._crowd_api_url("appmanagement", f"application/{application_id}", api_version="1"),
|
|
759
|
+
data=data,
|
|
760
|
+
)
|
|
761
|
+
|
|
762
|
+
def delete_application(self, application_id):
|
|
763
|
+
"""
|
|
764
|
+
Delete an application.
|
|
765
|
+
:param application_id: str - application id
|
|
766
|
+
:return:
|
|
767
|
+
"""
|
|
768
|
+
return self.delete(self._crowd_api_url("appmanagement", f"application/{application_id}", api_version="1"))
|
|
769
|
+
|
|
770
|
+
def get_remote_addresses(self, application_id):
|
|
771
|
+
"""
|
|
772
|
+
Get remote addresses for an application.
|
|
773
|
+
:param application_id: str - application id
|
|
774
|
+
:return: remote addresses
|
|
775
|
+
"""
|
|
776
|
+
return self.get(
|
|
777
|
+
self._crowd_api_url("appmanagement", f"application/{application_id}/remote_address", api_version="1")
|
|
778
|
+
)
|
|
779
|
+
|
|
780
|
+
def add_remote_address(self, application_id, address):
|
|
781
|
+
"""
|
|
782
|
+
Add a remote address to an application.
|
|
783
|
+
:param application_id: str - application id
|
|
784
|
+
:param address: dict - remote address representation or string value
|
|
785
|
+
:return:
|
|
786
|
+
"""
|
|
787
|
+
data = {"value": address} if isinstance(address, str) else address
|
|
788
|
+
return self.post(
|
|
789
|
+
self._crowd_api_url("appmanagement", f"application/{application_id}/remote_address", api_version="1"),
|
|
790
|
+
data=data,
|
|
791
|
+
)
|
|
792
|
+
|
|
793
|
+
def remove_remote_address(self, application_id, address):
|
|
794
|
+
"""
|
|
795
|
+
Remove a remote address from an application.
|
|
796
|
+
:param application_id: str - application id
|
|
797
|
+
:param address: str - remote address to remove
|
|
798
|
+
:return:
|
|
799
|
+
"""
|
|
800
|
+
return self.delete(
|
|
801
|
+
self._crowd_api_url("appmanagement", f"application/{application_id}/remote_address", api_version="1"),
|
|
802
|
+
params={"address": address},
|
|
803
|
+
)
|
|
804
|
+
|
|
805
|
+
def get_admin_applications(self, name=None, active=None, start=0, limit=99999):
|
|
806
|
+
"""
|
|
807
|
+
Get all applications or filter by name and active status.
|
|
808
|
+
:param name: str - optional application name filter
|
|
809
|
+
:param active: bool - optional active status filter
|
|
810
|
+
:param start: int - start index for paging
|
|
811
|
+
:param limit: int - maximum number of results
|
|
812
|
+
:return: applications
|
|
813
|
+
"""
|
|
814
|
+
params = {"start": start, "limit": limit}
|
|
815
|
+
if name:
|
|
816
|
+
params["name"] = name
|
|
817
|
+
if active is not None:
|
|
818
|
+
params["active"] = active
|
|
819
|
+
return self.get(self._admin_api_url("application"), params=params)
|
|
820
|
+
|
|
821
|
+
def get_admin_application(self, application_id):
|
|
822
|
+
"""
|
|
823
|
+
Get an application by id.
|
|
824
|
+
:param application_id: str - application id
|
|
825
|
+
:return: application
|
|
826
|
+
"""
|
|
827
|
+
return self.get(self._admin_api_url(f"application/{application_id}"))
|
|
828
|
+
|
|
829
|
+
def update_admin_application(self, application_id, data):
|
|
830
|
+
"""
|
|
831
|
+
Update an application.
|
|
832
|
+
:param application_id: str - application id
|
|
833
|
+
:param data: dict - application representation
|
|
834
|
+
:return:
|
|
835
|
+
"""
|
|
836
|
+
return self.put(self._admin_api_url(f"application/{application_id}"), data=data)
|
|
837
|
+
|
|
838
|
+
def get_access_based_synchronization(self, application_id):
|
|
839
|
+
"""
|
|
840
|
+
Get access-based synchronization settings for an application.
|
|
841
|
+
:param application_id: str - application id
|
|
842
|
+
:return: synchronization settings
|
|
843
|
+
"""
|
|
844
|
+
return self.get(self._admin_api_url(f"application/{application_id}/access-based-synchronization"))
|
|
845
|
+
|
|
846
|
+
def update_access_based_synchronization(self, application_id, data):
|
|
847
|
+
"""
|
|
848
|
+
Update access-based synchronization settings for an application.
|
|
849
|
+
:param application_id: str - application id
|
|
850
|
+
:param data: dict - synchronization settings
|
|
851
|
+
:return:
|
|
852
|
+
"""
|
|
853
|
+
return self.put(self._admin_api_url(f"application/{application_id}/access-based-synchronization"), data=data)
|
|
854
|
+
|
|
855
|
+
def get_directory_mappings(self, application_id, start=0, limit=99999):
|
|
856
|
+
"""
|
|
857
|
+
Get directory mappings for an application.
|
|
858
|
+
:param application_id: str - application id
|
|
859
|
+
:param start: int - start index for paging
|
|
860
|
+
:param limit: int - maximum number of results
|
|
861
|
+
:return: directory mappings
|
|
862
|
+
"""
|
|
863
|
+
params = {"start": start, "limit": limit}
|
|
864
|
+
return self.get(self._admin_api_url(f"application/{application_id}/directory-mapping"), params=params)
|
|
865
|
+
|
|
866
|
+
def add_directory_mapping(self, application_id, data):
|
|
867
|
+
"""
|
|
868
|
+
Add a directory mapping to an application.
|
|
869
|
+
:param application_id: str - application id
|
|
870
|
+
:param data: dict - directory mapping representation
|
|
871
|
+
:return:
|
|
872
|
+
"""
|
|
873
|
+
return self.post(self._admin_api_url(f"application/{application_id}/directory-mapping"), data=data)
|
|
874
|
+
|
|
875
|
+
def get_directory_mapping(self, application_id, directory_id):
|
|
876
|
+
"""
|
|
877
|
+
Get a directory mapping for an application.
|
|
878
|
+
:param application_id: str - application id
|
|
879
|
+
:param directory_id: str - directory id
|
|
880
|
+
:return: directory mapping
|
|
881
|
+
"""
|
|
882
|
+
return self.get(self._admin_api_url(f"application/{application_id}/directory-mapping/{directory_id}"))
|
|
883
|
+
|
|
884
|
+
def update_directory_mapping(self, application_id, directory_id, data):
|
|
885
|
+
"""
|
|
886
|
+
Update a directory mapping for an application.
|
|
887
|
+
:param application_id: str - application id
|
|
888
|
+
:param directory_id: str - directory id
|
|
889
|
+
:param data: dict - directory mapping representation
|
|
890
|
+
:return:
|
|
891
|
+
"""
|
|
892
|
+
return self.put(
|
|
893
|
+
self._admin_api_url(f"application/{application_id}/directory-mapping/{directory_id}"),
|
|
894
|
+
data=data,
|
|
895
|
+
)
|
|
896
|
+
|
|
897
|
+
def delete_directory_mapping(self, application_id, directory_id):
|
|
898
|
+
"""
|
|
899
|
+
Delete a directory mapping from an application.
|
|
900
|
+
:param application_id: str - application id
|
|
901
|
+
:param directory_id: str - directory id
|
|
902
|
+
:return:
|
|
903
|
+
"""
|
|
904
|
+
return self.delete(self._admin_api_url(f"application/{application_id}/directory-mapping/{directory_id}"))
|
|
905
|
+
|
|
906
|
+
def move_directory_mapping(self, application_id, directory_id, data):
|
|
907
|
+
"""
|
|
908
|
+
Reorder directory mappings for an application.
|
|
909
|
+
:param application_id: str - application id
|
|
910
|
+
:param directory_id: str - directory id
|
|
911
|
+
:param data: dict - move request body
|
|
912
|
+
:return:
|
|
913
|
+
"""
|
|
914
|
+
return self.post(
|
|
915
|
+
self._admin_api_url(f"application/{application_id}/directory-mapping/{directory_id}/move"),
|
|
916
|
+
data=data,
|
|
917
|
+
)
|
|
918
|
+
|
|
919
|
+
def get_detailed_directories(self, search=None, active=None, start=0, limit=99999):
|
|
920
|
+
"""
|
|
921
|
+
Get detailed directory data list.
|
|
922
|
+
:param search: str - optional search query
|
|
923
|
+
:param active: bool - optional active status filter
|
|
924
|
+
:param start: int - start index for paging
|
|
925
|
+
:param limit: int - maximum number of results
|
|
926
|
+
:return: directories
|
|
927
|
+
"""
|
|
928
|
+
params = {"start": start, "limit": limit}
|
|
929
|
+
if search:
|
|
930
|
+
params["search"] = search
|
|
931
|
+
if active is not None:
|
|
932
|
+
params["active"] = active
|
|
933
|
+
return self.get(self._admin_api_url("directory/detailed"), params=params)
|
|
934
|
+
|
|
935
|
+
def get_detailed_directory(self, directory_id):
|
|
936
|
+
"""
|
|
937
|
+
Get detailed directory data.
|
|
938
|
+
:param directory_id: str - directory id
|
|
939
|
+
:return: directory
|
|
940
|
+
"""
|
|
941
|
+
return self.get(self._admin_api_url(f"directory/detailed/{directory_id}"))
|
|
942
|
+
|
|
943
|
+
def synchronize_directory(self, directory_id):
|
|
944
|
+
"""
|
|
945
|
+
Schedule synchronisation for a directory.
|
|
946
|
+
:param directory_id: str - directory id
|
|
947
|
+
:return:
|
|
948
|
+
"""
|
|
949
|
+
return self.post(self._admin_api_url(f"directory/detailed/{directory_id}/synchronize"))
|
|
950
|
+
|
|
951
|
+
def get_managed_directories(self, start=0, limit=99999):
|
|
952
|
+
"""
|
|
953
|
+
Get managed directories.
|
|
954
|
+
:param start: int - start index for paging
|
|
955
|
+
:param limit: int - maximum number of results
|
|
956
|
+
:return: directories
|
|
957
|
+
"""
|
|
958
|
+
return self.get(self._admin_api_url("directory/managed"), params={"start": start, "limit": limit})
|
|
959
|
+
|
|
960
|
+
def search_directory_groups(self, directory_id, term, active=None, start=0, limit=99999):
|
|
961
|
+
"""
|
|
962
|
+
Search groups in a directory.
|
|
963
|
+
:param directory_id: str - directory id
|
|
964
|
+
:param term: str - search term
|
|
965
|
+
:param active: bool - optional active status filter
|
|
966
|
+
:param start: int - start index for paging
|
|
967
|
+
:param limit: int - maximum number of results
|
|
968
|
+
:return: groups
|
|
969
|
+
"""
|
|
970
|
+
params = {"term": term, "start": start, "limit": limit}
|
|
971
|
+
if active is not None:
|
|
972
|
+
params["active"] = active
|
|
973
|
+
return self.get(self._admin_api_url(f"group/search/{directory_id}"), params=params)
|
|
974
|
+
|
|
975
|
+
def get_admin_group_nested_groups(self, group_id, start=0, limit=99999):
|
|
976
|
+
"""
|
|
977
|
+
Get nested groups for a group.
|
|
978
|
+
:param group_id: str - group id
|
|
979
|
+
:param start: int - start index for paging
|
|
980
|
+
:param limit: int - maximum number of results
|
|
981
|
+
:return: groups
|
|
982
|
+
"""
|
|
983
|
+
return self.get(
|
|
984
|
+
self._admin_api_url(f"group/{group_id}/groups"),
|
|
985
|
+
params={"start": start, "limit": limit},
|
|
986
|
+
)
|
|
987
|
+
|
|
988
|
+
def add_admin_group_nested_groups(self, group_id, data):
|
|
989
|
+
"""
|
|
990
|
+
Add nested groups to a group.
|
|
991
|
+
:param group_id: str - group id
|
|
992
|
+
:param data: dict - group membership request body
|
|
993
|
+
:return:
|
|
994
|
+
"""
|
|
995
|
+
return self.post(self._admin_api_url(f"group/{group_id}/groups"), data=data)
|
|
996
|
+
|
|
997
|
+
def get_group_administrators(self, group_id, start=0, limit=99999):
|
|
998
|
+
"""
|
|
999
|
+
Get administrators of a group.
|
|
1000
|
+
:param group_id: str - group id
|
|
1001
|
+
:param start: int - start index for paging
|
|
1002
|
+
:param limit: int - maximum number of results
|
|
1003
|
+
:return: administrators
|
|
1004
|
+
"""
|
|
1005
|
+
return self.get(
|
|
1006
|
+
self._admin_api_url(f"group-level-admin/{group_id}/admins"),
|
|
1007
|
+
params={"start": start, "limit": limit},
|
|
1008
|
+
)
|
|
1009
|
+
|
|
1010
|
+
def add_group_administrators(self, group_id, data):
|
|
1011
|
+
"""
|
|
1012
|
+
Add administrators to a group.
|
|
1013
|
+
:param group_id: str - group id
|
|
1014
|
+
:param data: dict - administrator request body
|
|
1015
|
+
:return:
|
|
1016
|
+
"""
|
|
1017
|
+
return self.post(self._admin_api_url(f"group-level-admin/{group_id}/admins"), data=data)
|
|
1018
|
+
|
|
1019
|
+
def get_group_admin_candidates(self, group_id, search=None, limit=99999):
|
|
1020
|
+
"""
|
|
1021
|
+
Get group administrator candidates.
|
|
1022
|
+
:param group_id: str - group id
|
|
1023
|
+
:param search: str - optional search string
|
|
1024
|
+
:param limit: int - maximum number of results
|
|
1025
|
+
:return: candidates
|
|
1026
|
+
"""
|
|
1027
|
+
params = {"limit": limit}
|
|
1028
|
+
if search:
|
|
1029
|
+
params["search"] = search
|
|
1030
|
+
return self.get(self._admin_api_url(f"group-level-admin/{group_id}/admins/suggestions"), params=params)
|
|
1031
|
+
|
|
1032
|
+
def remove_group_admin_user(self, group_id, admin_user_id):
|
|
1033
|
+
"""
|
|
1034
|
+
Revoke group administrator rights from a user.
|
|
1035
|
+
:param group_id: str - group id
|
|
1036
|
+
:param admin_user_id: str - admin user id
|
|
1037
|
+
:return:
|
|
1038
|
+
"""
|
|
1039
|
+
return self.delete(self._admin_api_url(f"group-level-admin/{group_id}/admins/users/{admin_user_id}"))
|
|
1040
|
+
|
|
1041
|
+
def remove_group_admin_group(self, group_id, admin_group_id):
|
|
1042
|
+
"""
|
|
1043
|
+
Revoke group administrator rights from a group.
|
|
1044
|
+
:param group_id: str - group id
|
|
1045
|
+
:param admin_group_id: str - admin group id
|
|
1046
|
+
:return:
|
|
1047
|
+
"""
|
|
1048
|
+
return self.delete(self._admin_api_url(f"group-level-admin/{group_id}/admins/groups/{admin_group_id}"))
|
|
1049
|
+
|
|
1050
|
+
def search_administered_groups(self, query=None, start=0, limit=99999):
|
|
1051
|
+
"""
|
|
1052
|
+
Search administered groups.
|
|
1053
|
+
:param query: dict - search request body
|
|
1054
|
+
:param start: int - start index for paging
|
|
1055
|
+
:param limit: int - maximum number of results
|
|
1056
|
+
:return: groups
|
|
1057
|
+
"""
|
|
1058
|
+
params = {"start": start, "limit": limit}
|
|
1059
|
+
return self.post(self._admin_api_url("groups/query"), params=params, data=query or {})
|
|
1060
|
+
|
|
1061
|
+
def get_admin_group_details(self, group_id):
|
|
1062
|
+
"""
|
|
1063
|
+
Get group details.
|
|
1064
|
+
:param group_id: str - group id
|
|
1065
|
+
:return: group details
|
|
1066
|
+
"""
|
|
1067
|
+
return self.get(self._admin_api_url(f"groups/{group_id}"))
|
|
1068
|
+
|
|
1069
|
+
def get_admin_group_members(self, group_id, start=0, limit=99999):
|
|
1070
|
+
"""
|
|
1071
|
+
Get members of a group.
|
|
1072
|
+
:param group_id: str - group id
|
|
1073
|
+
:param start: int - start index for paging
|
|
1074
|
+
:param limit: int - maximum number of results
|
|
1075
|
+
:return: members
|
|
1076
|
+
"""
|
|
1077
|
+
return self.get(self._admin_api_url(f"groups/{group_id}/users"), params={"start": start, "limit": limit})
|
|
1078
|
+
|
|
1079
|
+
def add_users_to_admin_group(self, group_id, data):
|
|
1080
|
+
"""
|
|
1081
|
+
Add users to a group.
|
|
1082
|
+
:param group_id: str - group id
|
|
1083
|
+
:param data: dict - users to add
|
|
1084
|
+
:return:
|
|
1085
|
+
"""
|
|
1086
|
+
return self.post(self._admin_api_url(f"groups/{group_id}/users"), data=data)
|
|
1087
|
+
|
|
1088
|
+
def remove_users_from_admin_group(self, group_id, data):
|
|
1089
|
+
"""
|
|
1090
|
+
Remove users from a group.
|
|
1091
|
+
:param group_id: str - group id
|
|
1092
|
+
:param data: dict - users to remove
|
|
1093
|
+
:return:
|
|
1094
|
+
"""
|
|
1095
|
+
return self.delete(self._admin_api_url(f"groups/{group_id}/users"), data=data)
|
|
1096
|
+
|
|
1097
|
+
def search_admin_group_user_suggestions(self, group_id, search=None, limit=99999):
|
|
1098
|
+
"""
|
|
1099
|
+
Search users to add to a group.
|
|
1100
|
+
:param group_id: str - group id
|
|
1101
|
+
:param search: str - optional search string
|
|
1102
|
+
:param limit: int - maximum number of results
|
|
1103
|
+
:return: user suggestions
|
|
1104
|
+
"""
|
|
1105
|
+
params = {"limit": limit}
|
|
1106
|
+
if search:
|
|
1107
|
+
params["search"] = search
|
|
1108
|
+
return self.get(self._admin_api_url(f"groups/{group_id}/users/suggestions"), params=params)
|
|
1109
|
+
|
|
1110
|
+
def search_admin_users(self, query=None, start=0, limit=99999):
|
|
1111
|
+
"""
|
|
1112
|
+
Search users.
|
|
1113
|
+
:param query: dict - search request body
|
|
1114
|
+
:param start: int - start index for paging
|
|
1115
|
+
:param limit: int - maximum number of results
|
|
1116
|
+
:return: users
|
|
1117
|
+
"""
|
|
1118
|
+
params = {"start": start, "limit": limit}
|
|
1119
|
+
return self.post(self._admin_api_url("users/search"), params=params, data=query or {})
|
|
1120
|
+
|
|
1121
|
+
def add_user_to_admin_group(self, user_id, data):
|
|
1122
|
+
"""
|
|
1123
|
+
Add a user to groups.
|
|
1124
|
+
:param user_id: str - user id
|
|
1125
|
+
:param data: dict - groups to add
|
|
1126
|
+
:return:
|
|
1127
|
+
"""
|
|
1128
|
+
return self.post(self._admin_api_url(f"users/{user_id}/groups"), data=data)
|
|
1129
|
+
|
|
1130
|
+
def remove_user_from_admin_group(self, user_id, data):
|
|
1131
|
+
"""
|
|
1132
|
+
Remove a user from groups.
|
|
1133
|
+
:param user_id: str - user id
|
|
1134
|
+
:param data: dict - groups to remove
|
|
1135
|
+
:return:
|
|
1136
|
+
"""
|
|
1137
|
+
return self.delete(self._admin_api_url(f"users/{user_id}/groups"), data=data)
|
|
1138
|
+
|
|
1139
|
+
def get_server_info(self):
|
|
1140
|
+
"""Get Crowd server information."""
|
|
1141
|
+
return self.get(self._admin_api_url("server-info"))
|
|
1142
|
+
|
|
1143
|
+
def get_application_sessions(self, search=None, start=0, limit=99999):
|
|
1144
|
+
"""
|
|
1145
|
+
Get application sessions.
|
|
1146
|
+
:param search: str - optional search keyword
|
|
1147
|
+
:param start: int - start index for paging
|
|
1148
|
+
:param limit: int - maximum number of results
|
|
1149
|
+
:return: sessions
|
|
1150
|
+
"""
|
|
1151
|
+
params = {"start": start, "limit": limit}
|
|
1152
|
+
if search:
|
|
1153
|
+
params["search"] = search
|
|
1154
|
+
return self.get(self._admin_api_url("sessions/application"), params=params)
|
|
1155
|
+
|
|
1156
|
+
def get_user_sessions(self, search=None, directory_id=None, start=0, limit=99999):
|
|
1157
|
+
"""
|
|
1158
|
+
Get user sessions.
|
|
1159
|
+
:param search: str - optional search keyword
|
|
1160
|
+
:param directory_id: str - optional directory id filter
|
|
1161
|
+
:param start: int - start index for paging
|
|
1162
|
+
:param limit: int - maximum number of results
|
|
1163
|
+
:return: sessions
|
|
1164
|
+
"""
|
|
1165
|
+
params = {"start": start, "limit": limit}
|
|
1166
|
+
if search:
|
|
1167
|
+
params["search"] = search
|
|
1168
|
+
if directory_id:
|
|
1169
|
+
params["directoryId"] = directory_id
|
|
1170
|
+
return self.get(self._admin_api_url("sessions/user"), params=params)
|
|
1171
|
+
|
|
1172
|
+
def expire_session(self, random_hash):
|
|
1173
|
+
"""
|
|
1174
|
+
Expire a session by random hash.
|
|
1175
|
+
:param random_hash: str - session random hash
|
|
1176
|
+
:return:
|
|
1177
|
+
"""
|
|
1178
|
+
return self.delete(self._admin_api_url(f"sessions/{random_hash}"))
|
|
1179
|
+
|
|
1180
|
+
def get_licensing_summary(self, application_id, version=None, jira_type=None):
|
|
1181
|
+
"""
|
|
1182
|
+
Get licensing summary for an application.
|
|
1183
|
+
:param application_id: str - application id
|
|
1184
|
+
:param version: str - optional licensing data version
|
|
1185
|
+
:param jira_type: str - optional Jira subtype
|
|
1186
|
+
:return: licensing summary
|
|
1187
|
+
"""
|
|
1188
|
+
params = {}
|
|
1189
|
+
if version:
|
|
1190
|
+
params["version"] = version
|
|
1191
|
+
if jira_type:
|
|
1192
|
+
params["jiraType"] = jira_type
|
|
1193
|
+
return self.get(self._admin_api_url(f"licensing/{application_id}/summary"), params=params)
|
|
1194
|
+
|
|
1195
|
+
def get_licensed_directories(self, application_id, version=None, jira_type=None, start=0, limit=99999):
|
|
1196
|
+
"""
|
|
1197
|
+
Get licensed directories for an application.
|
|
1198
|
+
:param application_id: str - application id
|
|
1199
|
+
:param version: str - optional licensing data version
|
|
1200
|
+
:param jira_type: str - optional Jira subtype
|
|
1201
|
+
:param start: int - start index for paging
|
|
1202
|
+
:param limit: int - maximum number of results
|
|
1203
|
+
:return: directories
|
|
1204
|
+
"""
|
|
1205
|
+
params = {"start": start, "limit": limit}
|
|
1206
|
+
if version:
|
|
1207
|
+
params["version"] = version
|
|
1208
|
+
if jira_type:
|
|
1209
|
+
params["jiraType"] = jira_type
|
|
1210
|
+
return self.get(self._admin_api_url(f"licensing/{application_id}/directories"), params=params)
|
|
1211
|
+
|
|
1212
|
+
def get_licensed_jira_types(self, application_id, version=None):
|
|
1213
|
+
"""
|
|
1214
|
+
Get Jira types for licensing.
|
|
1215
|
+
:param application_id: str - application id
|
|
1216
|
+
:param version: str - optional licensing data version
|
|
1217
|
+
:return: Jira types
|
|
1218
|
+
"""
|
|
1219
|
+
params = {"version": version} if version else {}
|
|
1220
|
+
return self.get(self._admin_api_url(f"licensing/{application_id}/jira-types"), params=params)
|
|
1221
|
+
|
|
1222
|
+
def search_licensed_users(self, application_id, query=None, start=0, limit=99999):
|
|
1223
|
+
"""
|
|
1224
|
+
Search licensed users for an application.
|
|
1225
|
+
:param application_id: str - application id
|
|
1226
|
+
:param query: dict - search request body
|
|
1227
|
+
:param start: int - start index for paging
|
|
1228
|
+
:param limit: int - maximum number of results
|
|
1229
|
+
:return: users
|
|
1230
|
+
"""
|
|
1231
|
+
params = {"start": start, "limit": limit}
|
|
1232
|
+
return self.post(
|
|
1233
|
+
self._admin_api_url(f"licensing/{application_id}/licensed-users/search"),
|
|
1234
|
+
params=params,
|
|
1235
|
+
data=query or {},
|
|
1236
|
+
)
|
|
1237
|
+
|
|
1238
|
+
def export_licensed_users(
|
|
1239
|
+
self,
|
|
1240
|
+
application_id,
|
|
1241
|
+
search=None,
|
|
1242
|
+
directory_id=None,
|
|
1243
|
+
jira_type=None,
|
|
1244
|
+
last_login_before=None,
|
|
1245
|
+
search_version=None,
|
|
1246
|
+
):
|
|
1247
|
+
"""
|
|
1248
|
+
Export licensed users for an application.
|
|
1249
|
+
:param application_id: str - application id
|
|
1250
|
+
:param search: str - optional search text
|
|
1251
|
+
:param directory_id: str - optional directory id filter
|
|
1252
|
+
:param jira_type: str - optional Jira subtype
|
|
1253
|
+
:param last_login_before: str - optional last logged in date filter
|
|
1254
|
+
:param search_version: str - optional licensing data version
|
|
1255
|
+
:return: exported users
|
|
1256
|
+
"""
|
|
1257
|
+
params = {}
|
|
1258
|
+
if search:
|
|
1259
|
+
params["search"] = search
|
|
1260
|
+
if directory_id:
|
|
1261
|
+
params["directoryId"] = directory_id
|
|
1262
|
+
if jira_type:
|
|
1263
|
+
params["jiraType"] = jira_type
|
|
1264
|
+
if last_login_before:
|
|
1265
|
+
params["lastLoginBefore"] = last_login_before
|
|
1266
|
+
if search_version:
|
|
1267
|
+
params["searchVersion"] = search_version
|
|
1268
|
+
return self.get(self._admin_api_url(f"licensing/{application_id}/licensed-users/download"), params=params)
|
|
1269
|
+
|
|
1270
|
+
def create_backup(self, data=None):
|
|
1271
|
+
"""
|
|
1272
|
+
Create a backup.
|
|
1273
|
+
:param data: dict - optional backup request body
|
|
1274
|
+
:return:
|
|
1275
|
+
"""
|
|
1276
|
+
return self.post(self._admin_api_url("backup"), data=data or {})
|
|
1277
|
+
|
|
1278
|
+
def get_backup_summary(self):
|
|
1279
|
+
"""Get backup summary."""
|
|
1280
|
+
return self.get(self._admin_api_url("backup/summary"))
|
|
1281
|
+
|
|
1282
|
+
def get_backup_configuration(self):
|
|
1283
|
+
"""Get backup configuration."""
|
|
1284
|
+
return self.get(self._admin_api_url("backup/configuration"))
|
|
1285
|
+
|
|
1286
|
+
def save_backup_configuration(self, data):
|
|
1287
|
+
"""
|
|
1288
|
+
Save backup configuration.
|
|
1289
|
+
:param data: dict - backup configuration
|
|
1290
|
+
:return:
|
|
1291
|
+
"""
|
|
1292
|
+
return self.post(self._admin_api_url("backup/configuration"), data=data)
|
|
1293
|
+
|
|
1294
|
+
def add_audit_log_changeset(self, data):
|
|
1295
|
+
"""
|
|
1296
|
+
Add an audit log changeset.
|
|
1297
|
+
:param data: dict - changeset data
|
|
1298
|
+
:return:
|
|
1299
|
+
"""
|
|
1300
|
+
return self.post(self._admin_api_url("auditlog"), data=data)
|
|
1301
|
+
|
|
1302
|
+
def get_audit_log_configuration(self):
|
|
1303
|
+
"""Get audit log configuration."""
|
|
1304
|
+
return self.get(self._admin_api_url("auditlog/configuration"))
|
|
1305
|
+
|
|
1306
|
+
def set_audit_log_configuration(self, data):
|
|
1307
|
+
"""
|
|
1308
|
+
Set audit log configuration.
|
|
1309
|
+
:param data: dict - audit log configuration
|
|
1310
|
+
:return:
|
|
1311
|
+
"""
|
|
1312
|
+
return self.put(self._admin_api_url("auditlog/configuration"), data=data)
|
|
1313
|
+
|
|
1314
|
+
def search_audit_log(self, query=None, start=0, limit=99999):
|
|
1315
|
+
"""
|
|
1316
|
+
Search audit log.
|
|
1317
|
+
:param query: dict - search request body
|
|
1318
|
+
:param start: int - start index for paging
|
|
1319
|
+
:param limit: int - maximum number of results
|
|
1320
|
+
:return: audit log entries
|
|
1321
|
+
"""
|
|
1322
|
+
params = {"start": start, "limit": limit}
|
|
1323
|
+
return self.post(self._admin_api_url("auditlog/query"), params=params, data=query or {})
|
|
1324
|
+
|
|
1325
|
+
def get_audit_log_filter_values(self, projection=None, search=None, start=0, limit=99999):
|
|
1326
|
+
"""
|
|
1327
|
+
Get audit log filter values.
|
|
1328
|
+
:param projection: str - item type requested
|
|
1329
|
+
:param search: str - optional search string
|
|
1330
|
+
:param start: int - start index for paging
|
|
1331
|
+
:param limit: int - maximum number of results
|
|
1332
|
+
:return: filter values
|
|
1333
|
+
"""
|
|
1334
|
+
params = {"start": start, "limit": limit}
|
|
1335
|
+
if projection:
|
|
1336
|
+
params["projection"] = projection
|
|
1337
|
+
if search:
|
|
1338
|
+
params["search"] = search
|
|
1339
|
+
return self.post(self._admin_api_url("auditlog/query/filter"), params=params)
|
|
1340
|
+
|
|
1341
|
+
def get_look_and_feel_config(self):
|
|
1342
|
+
"""Get look and feel configuration."""
|
|
1343
|
+
return self.get(self._admin_api_url("look-and-feel/config"))
|
|
1344
|
+
|
|
1345
|
+
def update_look_and_feel_config(self, data):
|
|
1346
|
+
"""
|
|
1347
|
+
Update look and feel configuration.
|
|
1348
|
+
:param data: dict - look and feel configuration
|
|
1349
|
+
:return:
|
|
1350
|
+
"""
|
|
1351
|
+
return self.put(self._admin_api_url("look-and-feel/config"), data=data)
|
|
1352
|
+
|
|
1353
|
+
def reset_look_and_feel_config(self):
|
|
1354
|
+
"""Reset look and feel configuration to default."""
|
|
1355
|
+
return self.post(self._admin_api_url("look-and-feel/reset-config"))
|
|
1356
|
+
|
|
1357
|
+
def get_remember_me_config(self):
|
|
1358
|
+
"""Get remember me configuration."""
|
|
1359
|
+
return self.get(self._admin_api_url("remember-me/config"))
|
|
1360
|
+
|
|
1361
|
+
def update_remember_me_config(self, data):
|
|
1362
|
+
"""
|
|
1363
|
+
Update remember me configuration.
|
|
1364
|
+
:param data: dict - remember me configuration
|
|
1365
|
+
:return:
|
|
1366
|
+
"""
|
|
1367
|
+
return self.put(self._admin_api_url("remember-me/config"), data=data)
|
|
1368
|
+
|
|
1369
|
+
def expire_all_remember_me_tokens(self):
|
|
1370
|
+
"""Expire all remember me tokens."""
|
|
1371
|
+
return self.post(self._admin_api_url("remember-me/expire-all"))
|
|
1372
|
+
|
|
1373
|
+
def get_saml_config(self):
|
|
1374
|
+
"""Get SAML configuration."""
|
|
1375
|
+
return self.get(self._admin_api_url("samlconfig"))
|
|
1376
|
+
|
|
1377
|
+
def get_saml_application_config(self, application_id):
|
|
1378
|
+
"""
|
|
1379
|
+
Get SAML configuration for an application.
|
|
1380
|
+
:param application_id: str - application id
|
|
1381
|
+
:return: SAML application configuration
|
|
1382
|
+
"""
|
|
1383
|
+
return self.get(self._admin_api_url(f"samlconfig/application/{application_id}"))
|
|
1384
|
+
|
|
1385
|
+
def update_saml_application_config(self, application_id, data):
|
|
1386
|
+
"""
|
|
1387
|
+
Update SAML configuration for an application.
|
|
1388
|
+
:param application_id: str - application id
|
|
1389
|
+
:param data: dict - SAML configuration
|
|
1390
|
+
:return:
|
|
1391
|
+
"""
|
|
1392
|
+
return self.post(self._admin_api_url(f"samlconfig/application/{application_id}"), data=data)
|
|
1393
|
+
|
|
1394
|
+
def parse_saml_metadata(self, data):
|
|
1395
|
+
"""
|
|
1396
|
+
Parse SAML metadata.
|
|
1397
|
+
:param data: bytes or str - SAML metadata content
|
|
1398
|
+
:return: parsed metadata
|
|
1399
|
+
"""
|
|
1400
|
+
headers = {"Content-Type": "application/octet-stream"}
|
|
1401
|
+
return self.post(self._admin_api_url("samlconfig/application/parse_metadata"), data=data, headers=headers)
|
|
1402
|
+
|
|
1403
|
+
def parse_saml_metadata_file(self, file_path):
|
|
1404
|
+
"""
|
|
1405
|
+
Parse SAML metadata from a file.
|
|
1406
|
+
:param file_path: str - path to SAML metadata file
|
|
1407
|
+
:return: parsed metadata
|
|
1408
|
+
"""
|
|
1409
|
+
with open(file_path, "rb") as f:
|
|
1410
|
+
return self.post(
|
|
1411
|
+
self._admin_api_url("samlconfig/application/parse_metadata_multipart"),
|
|
1412
|
+
files={"file": f},
|
|
1413
|
+
)
|
|
1414
|
+
|
|
1415
|
+
def reset_saml_certificates(self):
|
|
1416
|
+
"""Reset SAML certificates."""
|
|
1417
|
+
return self.post(self._admin_api_url("samlconfig/reset-certificates"))
|
|
1418
|
+
|
|
1419
|
+
def get_saml_idp_metadata(self):
|
|
1420
|
+
"""Get SAML identity provider metadata."""
|
|
1421
|
+
return self.get(self._admin_api_url("samlconfig/idp/metadata"))
|
|
1422
|
+
|
|
1423
|
+
def find_saml_directory_mapping_mismatch(self, application_id):
|
|
1424
|
+
"""
|
|
1425
|
+
Find directory mappings mismatch for SAML application.
|
|
1426
|
+
:param application_id: str - application id
|
|
1427
|
+
:return: mismatch info
|
|
1428
|
+
"""
|
|
1429
|
+
return self.get(self._admin_api_url(f"samlconfig/application/{application_id}/directory-mapping-mismatch"))
|
|
1430
|
+
|
|
1431
|
+
def get_dynamic_ldap_pool_statistics(self):
|
|
1432
|
+
"""Get dynamic LDAP pool statistics."""
|
|
1433
|
+
return self.get(self._admin_api_url("dynamic-ldap-pool-statistics"))
|
|
1434
|
+
|
|
1435
|
+
def save_mail_configuration(self, data):
|
|
1436
|
+
"""
|
|
1437
|
+
Save mail server configuration.
|
|
1438
|
+
:param data: dict - mail configuration
|
|
1439
|
+
:return:
|
|
1440
|
+
"""
|
|
1441
|
+
return self.post(self._admin_api_url("mail/configuration"), data=data)
|
|
1442
|
+
|
|
1443
|
+
def test_mail_configuration(self, data):
|
|
1444
|
+
"""
|
|
1445
|
+
Test mail server connection.
|
|
1446
|
+
:param data: dict - mail configuration
|
|
1447
|
+
:return:
|
|
1448
|
+
"""
|
|
1449
|
+
return self.post(self._admin_api_url("mail/configuration/test"), data=data)
|
|
1450
|
+
|
|
1451
|
+
def validate_mail_configuration(self, data):
|
|
1452
|
+
"""
|
|
1453
|
+
Validate mail server configuration fields.
|
|
1454
|
+
:param data: dict - mail configuration
|
|
1455
|
+
:return:
|
|
1456
|
+
"""
|
|
1457
|
+
return self.post(self._admin_api_url("mail/configuration/validate"), data=data)
|
|
1458
|
+
|
|
261
1459
|
def health_check(self):
|
|
262
1460
|
"""
|
|
263
1461
|
Get health status
|