atlassian-python-api 4.0.1__py3-none-any.whl → 4.0.3__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 CHANGED
@@ -1 +1 @@
1
- 4.0.1
1
+ 4.0.3
atlassian/confluence.py CHANGED
@@ -647,24 +647,80 @@ class Confluence(AtlassianRestAPI):
647
647
  content_type="page",
648
648
  ):
649
649
  """
650
- Get all pages from space
650
+ Retrieve all pages from a Confluence space.
651
651
 
652
- :param space:
653
- :param start: OPTIONAL: The start point of the collection to return. Default: None (0).
654
- :param limit: OPTIONAL: The limit of the number of pages to return, this may be restricted by
655
- fixed system limits. Default: 50
656
- :param status: OPTIONAL: list of statuses the content to be found is in.
657
- Defaults to current is not specified.
658
- If set to 'any', content in 'current' and 'trashed' status will be fetched.
659
- Does not support 'historical' status for now.
660
- :param expand: OPTIONAL: a comma separated list of properties to expand on the content.
661
- Default value: history,space,version.
662
- :param content_type: the content type to return. Default value: page. Valid values: page, blogpost.
663
- :return:
652
+ :param space: The space key to fetch pages from.
653
+ :param start: OPTIONAL: The starting point of the collection. Default: 0.
654
+ :param limit: OPTIONAL: The maximum number of pages per request. Default: 50.
655
+ :param status: OPTIONAL: Filter pages by status ('current', 'trashed', 'any'). Default: None.
656
+ :param expand: OPTIONAL: Comma-separated list of properties to expand. Default: history,space,version.
657
+ :param content_type: OPTIONAL: The content type to return ('page', 'blogpost'). Default: page.
658
+ :return: List containing all pages from the specified space.
659
+ """
660
+ all_pages = [] # Initialize an empty list to store all pages
661
+ while True:
662
+ # Fetch a single batch of pages
663
+ response = self.get_all_pages_from_space_raw(
664
+ space=space,
665
+ start=start,
666
+ limit=limit,
667
+ status=status,
668
+ expand=expand,
669
+ content_type=content_type,
670
+ )
671
+
672
+ # Extract results from the response
673
+ results = response.get("results", [])
674
+ all_pages.extend(results) # Add the current batch of pages to the list
675
+
676
+ # Break the loop if no more pages are available
677
+ if len(results) < limit:
678
+ break
679
+
680
+ # Increment the start index for the next batch
681
+ start += limit
682
+ return all_pages
683
+
684
+ def get_all_pages_from_space_as_generator(
685
+ self,
686
+ space,
687
+ start=0,
688
+ limit=50,
689
+ status=None,
690
+ expand="history,space,version",
691
+ content_type="page",
692
+ ):
693
+ """
694
+ Retrieve all pages from a Confluence space using pagination.
695
+
696
+ :param space: The space key to fetch pages from.
697
+ :param start: OPTIONAL: The starting point of the collection. Default: 0.
698
+ :param limit: OPTIONAL: The maximum number of pages per request. Default: 50.
699
+ :param status: OPTIONAL: Filter pages by status ('current', 'trashed', 'any'). Default: None.
700
+ :param expand: OPTIONAL: Comma-separated list of properties to expand. Default: history,space,version.
701
+ :param content_type: OPTIONAL: The content type to return ('page', 'blogpost'). Default: page.
702
+ :return: Generator yielding pages one by one.
664
703
  """
665
- return self.get_all_pages_from_space_raw(
666
- space=space, start=start, limit=limit, status=status, expand=expand, content_type=content_type
667
- ).get("results")
704
+ while True:
705
+ # Fetch a single batch of pages
706
+ response = self.get_all_pages_from_space_raw(
707
+ space=space,
708
+ start=start,
709
+ limit=limit,
710
+ status=status,
711
+ expand=expand,
712
+ content_type=content_type,
713
+ )
714
+
715
+ # Extract results from the response
716
+ results = response.get("results", [])
717
+ yield from results # Yield each page individually
718
+
719
+ # Break the loop if no more pages are available
720
+ if len(results) < limit:
721
+ break
722
+ start += limit
723
+ pass
668
724
 
669
725
  def get_all_pages_from_space_trash(self, space, start=0, limit=500, status="trashed", content_type="page"):
670
726
  """
@@ -1238,7 +1294,7 @@ class Confluence(AtlassianRestAPI):
1238
1294
  def get_all_spaces(
1239
1295
  self,
1240
1296
  start=0,
1241
- limit=500,
1297
+ limit=50,
1242
1298
  expand=None,
1243
1299
  space_type=None,
1244
1300
  space_status=None,
@@ -2425,7 +2481,7 @@ class Confluence(AtlassianRestAPI):
2425
2481
  else:
2426
2482
  members.extend(values)
2427
2483
  if not members:
2428
- print((f"Did not get members from {group_name} group, please check permissions or connectivity"))
2484
+ print(f"Did not get members from {group_name} group, please check permissions or connectivity")
2429
2485
  return members
2430
2486
 
2431
2487
  def get_space(self, space_key, expand="description.plain,homepage", params=None):
@@ -3315,6 +3371,250 @@ class Confluence(AtlassianRestAPI):
3315
3371
  url = "rest/api/user/%s/group/%s" % (username, group_name)
3316
3372
  return self.put(url)
3317
3373
 
3374
+ # Space Permissions
3375
+ def get_all_space_permissions(self, space_key):
3376
+ """
3377
+ Returns list of permissions granted to users and groups in the particular space.
3378
+ :param space_key:
3379
+ :return:
3380
+ """
3381
+ url = f"rest/api/space/{space_key}/permissions"
3382
+ return self.get(url)
3383
+
3384
+ def set_permissions_to_multiple_items_for_space(self, space_key, user_key=None, group_name=None, operations=None):
3385
+ """
3386
+ Sets permissions to multiple users/groups in the given space.
3387
+ Request should contain all permissions that user/group/anonymous user will have in a given space.
3388
+ If permission is absent in the request, but was granted before, it will be revoked.
3389
+ If empty list of permissions passed to user/group/anonymous user,
3390
+ then all their existing permissions will be revoked.
3391
+ If user/group/anonymous user not mentioned in the request, their permissions will not be revoked.
3392
+
3393
+ Maximum 40 different users/groups/anonymous user could be passed in the request.
3394
+ :param space_key:
3395
+ :param user_key:
3396
+ :param group_name:
3397
+ :param operations:
3398
+ :return:
3399
+ """
3400
+ url = f"rest/api/space/{space_key}/permissions"
3401
+ params = []
3402
+
3403
+ if user_key:
3404
+ params.append({"userKey": user_key, "operations": operations or []})
3405
+
3406
+ if group_name:
3407
+ params.append({"groupName": group_name, "operations": operations or []})
3408
+
3409
+ if not user_key and not group_name:
3410
+ params.append({"operations": operations or []})
3411
+ payload_json = json.dumps(params)
3412
+ return self.post(url, data=payload_json)
3413
+
3414
+ def get_permissions_granted_to_anonymous_for_space(self, space_key):
3415
+ """
3416
+ Get permissions granted to anonymous user for the given space
3417
+ :param space_key:
3418
+ :return:
3419
+ """
3420
+ url = f"rest/api/space/{space_key}/permissions/anonymous"
3421
+ return self.get(url)
3422
+
3423
+ def set_permissions_to_anonymous_for_space(self, space_key, operations=None):
3424
+ """
3425
+ Grant permissions to anonymous user in the given space. Operation doesn't override existing permissions,
3426
+ will only add those one that weren't granted before. Multiple permissions could be passed in one request.
3427
+ Supported targetType and operationKey pairs:
3428
+
3429
+ space read
3430
+ space administer
3431
+ space export
3432
+ space restrict
3433
+ space delete_own
3434
+ space delete_mail
3435
+ page create
3436
+ page delete
3437
+ blogpost create
3438
+ blogpost delete
3439
+ comment create
3440
+ comment delete
3441
+ attachment create
3442
+ attachment delete
3443
+ :param space_key:
3444
+ :param operations:
3445
+ :return:
3446
+ """
3447
+ url = f"rest/api/space/{space_key}/permissions/anonymous"
3448
+ data = {"operations": operations or []}
3449
+ return self.put(url, data=data)
3450
+
3451
+ def remove_permissions_from_anonymous_for_space(self, space_key, operations=None):
3452
+ """
3453
+ Revoke permissions from anonymous user in the given space.
3454
+ If anonymous user doesn't have permissions that we are trying to revoke,
3455
+ those permissions will be silently skipped. Multiple permissions could be passed in one request.
3456
+ Supported targetType and operationKey pairs:
3457
+
3458
+ space read
3459
+ space administer
3460
+ space export
3461
+ space restrict
3462
+ space delete_own
3463
+ space delete_mail
3464
+ page create
3465
+ page delete
3466
+ blogpost create
3467
+ blogpost delete
3468
+ comment create
3469
+ comment delete
3470
+ attachment create
3471
+ attachment delete
3472
+ :param space_key:
3473
+ :param operations:
3474
+ :return:
3475
+ """
3476
+ url = f"rest/api/space/{space_key}/permissions/anonymous/revoke"
3477
+ data = {"operations": operations or []}
3478
+ return self.put(url, data=data)
3479
+
3480
+ def get_permissions_granted_to_group_for_space(self, space_key, group_name):
3481
+ """
3482
+ Get permissions granted to group for the given space
3483
+ :param space_key:
3484
+ :param group_name:
3485
+ :return:
3486
+ """
3487
+ url = f"rest/api/space/{space_key}/permissions/group/{group_name}"
3488
+ return self.get(url)
3489
+
3490
+ def set_permissions_to_group_for_space(self, space_key, group_name, operations=None):
3491
+ """
3492
+ Grant permissions to group in the given space.
3493
+ Operation doesn't override existing permissions, will only add those one that weren't granted before.
3494
+ Multiple permissions could be passed in one request. Supported targetType and operationKey pairs:
3495
+
3496
+ space read
3497
+ space administer
3498
+ space export
3499
+ space restrict
3500
+ space delete_own
3501
+ space delete_mail
3502
+ page create
3503
+ page delete
3504
+ blogpost create
3505
+ blogpost delete
3506
+ comment create
3507
+ comment delete
3508
+ attachment create
3509
+ attachment delete
3510
+ :param space_key:
3511
+ :param group_name:
3512
+ :param operations:
3513
+ :return:
3514
+ """
3515
+ url = f"rest/api/space/{space_key}/permissions/group/{group_name}"
3516
+ data = {"operations": operations or []}
3517
+ return self.put(url, data=data)
3518
+
3519
+ def remove_permissions_from_group_for_space(self, space_key, group_name, operations=None):
3520
+ """
3521
+ Revoke permissions from a group in the given space.
3522
+ If group doesn't have permissions that we are trying to revoke,
3523
+ those permissions will be silently skipped. Multiple permissions could be passed in one request.
3524
+ Supported targetType and operationKey pairs:
3525
+
3526
+ space read
3527
+ space administer
3528
+ space export
3529
+ space restrict
3530
+ space delete_own
3531
+ space delete_mail
3532
+ page create
3533
+ page delete
3534
+ blogpost create
3535
+ blogpost delete
3536
+ comment create
3537
+ comment delete
3538
+ attachment create
3539
+ attachment delete
3540
+ :param space_key:
3541
+ :param group_name:
3542
+ :param operations:
3543
+ :return:
3544
+ """
3545
+ url = f"rest/api/space/{space_key}/permissions/group/{group_name}/revoke"
3546
+ data = {"operations": operations or []}
3547
+ return self.put(url, data=data)
3548
+
3549
+ def get_permissions_granted_to_user_for_space(self, space_key, user_key):
3550
+ """
3551
+ Get permissions granted to user for the given space
3552
+ :param space_key:
3553
+ :param user_key:
3554
+ :return:
3555
+ """
3556
+ url = f"rest/api/space/{space_key}/permissions/user/{user_key}"
3557
+ return self.get(url)
3558
+
3559
+ def set_permissions_to_user_for_space(self, space_key, user_key, operations=None):
3560
+ """
3561
+ Grant permissions to user in the given space.
3562
+ Operation doesn't override existing permissions, will only add those one that weren't granted before.
3563
+ Multiple permissions could be passed in one request. Supported targetType and operationKey pairs:
3564
+
3565
+ space read
3566
+ space administer
3567
+ space export
3568
+ space restrict
3569
+ space delete_own
3570
+ space delete_mail
3571
+ page create
3572
+ page delete
3573
+ blogpost create
3574
+ blogpost delete
3575
+ comment create
3576
+ comment delete
3577
+ attachment create
3578
+ attachment delete
3579
+ :param space_key:
3580
+ :param user_key:
3581
+ :param operations:
3582
+ :return:
3583
+ """
3584
+ url = f"rest/api/space/{space_key}/permissions/user/{user_key}"
3585
+ data = {"operations": operations or []}
3586
+ return self.put(url, data=data)
3587
+
3588
+ def remove_permissions_from_user_for_space(self, space_key, user_key, operations=None):
3589
+ """
3590
+ Revoke permissions from a user in the given space.
3591
+ If user doesn't have permissions that we are trying to revoke,
3592
+ those permissions will be silently skipped. Multiple permissions could be passed in one request.
3593
+ Supported targetType and operationKey pairs:
3594
+
3595
+ space read
3596
+ space administer
3597
+ space export
3598
+ space restrict
3599
+ space delete_own
3600
+ space delete_mail
3601
+ page create
3602
+ page delete
3603
+ blogpost create
3604
+ blogpost delete
3605
+ comment create
3606
+ comment delete
3607
+ attachment create
3608
+ attachment delete
3609
+ :param space_key:
3610
+ :param user_key:
3611
+ :param operations:
3612
+ :return:
3613
+ """
3614
+ url = f"rest/api/space/{space_key}/permissions/user/{user_key}/revoke"
3615
+ data = {"operations": operations or []}
3616
+ return self.put(url, params=data)
3617
+
3318
3618
  def add_space_permissions(
3319
3619
  self,
3320
3620
  space_key,
atlassian/jira.py CHANGED
@@ -470,7 +470,7 @@ class Jira(AtlassianRestAPI):
470
470
  return self.put(url)
471
471
 
472
472
  """
473
- Troubleshooting. (Available for DC) It gives the posibility to download support zips.
473
+ Troubleshooting. (Available for DC) It gives the possibility to download support zips.
474
474
  Reference: https://confluence.atlassian.com/support/create-a-support-zip-using-the-rest-api-in-data-center-applications-952054641.html
475
475
  """
476
476
 
@@ -1571,9 +1571,9 @@ class Jira(AtlassianRestAPI):
1571
1571
  self,
1572
1572
  issue_key: str,
1573
1573
  fields: Union[str, dict],
1574
- update: Optional[dict[Any, Any]] = None,
1575
- history_metadata: Optional[dict[Any, Any]] = None,
1576
- properties: Optional[list[Any]] = None,
1574
+ update: Optional[Dict[Any, Any]] = None,
1575
+ history_metadata: Optional[Dict[Any, Any]] = None,
1576
+ properties: Optional[List[Any]] = None,
1577
1577
  notify_users: bool = True,
1578
1578
  ):
1579
1579
  """
@@ -4050,7 +4050,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4050
4050
  permission_id: str,
4051
4051
  name: str,
4052
4052
  description: Optional[str] = None,
4053
- permissions: Optional[list[dict]] = None,
4053
+ permissions: Optional[List[dict]] = None,
4054
4054
  scope: Optional[str] = None,
4055
4055
  expand: Optional[str] = None,
4056
4056
  ):
@@ -4065,7 +4065,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
4065
4065
  :param permission_id: int, REQUIRED: The ID of the permission scheme to update.
4066
4066
  :param name: str, REQUIRED: The name of the permission scheme. Must be unique.
4067
4067
  :param description: str, OPTIONAL: A description for the permission scheme. Defaults to None.
4068
- :param permissions: list[dict], OPTIONAL: A collection of permission grants. Defaults to None.
4068
+ :param permissions: List[dict], OPTIONAL: A collection of permission grants. Defaults to None.
4069
4069
  Example:
4070
4070
  [
4071
4071
  {
@@ -5692,7 +5692,7 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
5692
5692
  """
5693
5693
  Flags or un-flags one or multiple issues in Jira with a flag indicator.
5694
5694
  :param issue_keys: List of issue keys to flag or un-flag.
5695
- :type issue_keys: list[str]
5695
+ :type issue_keys: List[str]
5696
5696
  :param flag: Flag indicating whether to flag or un-flag the issues (default is True for flagging).
5697
5697
  :type flag: bool
5698
5698
  :return: POST request response.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atlassian-python-api
3
- Version: 4.0.1
3
+ Version: 4.0.3
4
4
  Summary: Python Atlassian REST API Wrapper
5
5
  Home-page: https://github.com/atlassian-api/atlassian-python-api
6
6
  Download-URL: https://github.com/atlassian-api/atlassian-python-api
@@ -46,6 +46,7 @@ Requires-Dist: oauthlib
46
46
  Requires-Dist: requests_oauthlib
47
47
  Requires-Dist: jmespath
48
48
  Requires-Dist: beautifulsoup4
49
+ Requires-Dist: typing-extensions
49
50
  Provides-Extra: kerberos
50
51
  Requires-Dist: requests-kerberos; extra == "kerberos"
51
52
  Dynamic: author
@@ -1,12 +1,12 @@
1
- atlassian/VERSION,sha256=9NpsFPgUIeK1iOscLU6BITKjDVwrQ2bmI5HTUxyQv0k,5
1
+ atlassian/VERSION,sha256=-hKigq1uD-UusmfWTSaUCl1KpmksCOtneKMYfWt8aT4,5
2
2
  atlassian/__init__.py,sha256=F13CZFoWIj9pDkj83soA7hwwHtvDC6EqFATey9p36PM,768
3
3
  atlassian/bamboo.py,sha256=Zmi7o7ETuTvCW37Fq4Vq0e_elfaXC_oDMcMl-9wO-d8,48017
4
4
  atlassian/cloud_admin.py,sha256=avdj1FdrGaxIRnPt4bXxQB65P8nVxNEpEHzlcH-ugac,961
5
- atlassian/confluence.py,sha256=yCTSvZjRfw2bNgnTWoIsNJ63u11HBrjDzL1KlMlUfe0,132661
5
+ atlassian/confluence.py,sha256=mWma3wlEIrpnwyhWz9UxYjMiQHegeq1YnxBuFgIQ564,143045
6
6
  atlassian/crowd.py,sha256=hsLqcmKLm-qWK3xV1pDYCeGcvUIR8k6DJkMlwcDn8QM,9255
7
7
  atlassian/errors.py,sha256=GAKr6W4zPn7ZUMRLHG8-UgAdVnxDzKVZ-jyGXAccALE,398
8
8
  atlassian/insight.py,sha256=fCR9IXmatTp6-l-pOeLFFQGgBeafSzBdkgIHLWkOXEo,23398
9
- atlassian/jira.py,sha256=l8U4yXropYezCEWCdf1sy2uLHUkfMG2XBDGxdr9HgIs,224650
9
+ atlassian/jira.py,sha256=pLxwGdzCQyE59MZ9luX0Qdd8ADU6YFo0maf2WrDsLXE,224651
10
10
  atlassian/marketplace.py,sha256=dLm4I8GROkdhyu3BdGtK_ssq1g44KZFi8S0HS_ZepLs,2540
11
11
  atlassian/portfolio.py,sha256=q38sFFC7DHmHM4vsFzl8sT7HcRRGKH3tT5nRlqltDzc,3696
12
12
  atlassian/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -49,8 +49,8 @@ atlassian/bitbucket/server/common/__init__.py,sha256=woZpR3WXAA3A99hZ1UZI_gLPHaA
49
49
  atlassian/bitbucket/server/common/permissions.py,sha256=ve-hWRIrG0zSMo1hp2uTLHGO1PlXorzZlpt7Sc9KhJw,7300
50
50
  atlassian/bitbucket/server/projects/__init__.py,sha256=6G3MZBOTFpwx5x3chg-M8-BbmOnrdRZiZYp2YKJScbw,7668
51
51
  atlassian/bitbucket/server/projects/repos/__init__.py,sha256=RFnZ5APax9VXASYbHbMjW12L2NR4gWbXzS-c-KyExTI,10776
52
- atlassian_python_api-4.0.1.dist-info/licenses/LICENSE,sha256=xamAnoX0zfBamIilAfP3nSIt7dIvnj7oueX14l6uKPY,11335
53
- atlassian_python_api-4.0.1.dist-info/METADATA,sha256=GGnVZG5YGtPHuxnLeY6jUHkhdYMUxUGIKNghorUjkHo,9486
54
- atlassian_python_api-4.0.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
55
- atlassian_python_api-4.0.1.dist-info/top_level.txt,sha256=84-EDv8LNaZx01TCGjBzglwPU1JSRJ7fPSq9uy55Sv0,10
56
- atlassian_python_api-4.0.1.dist-info/RECORD,,
52
+ atlassian_python_api-4.0.3.dist-info/licenses/LICENSE,sha256=xamAnoX0zfBamIilAfP3nSIt7dIvnj7oueX14l6uKPY,11335
53
+ atlassian_python_api-4.0.3.dist-info/METADATA,sha256=6rYDt5lrS87l3hdh_shFt2GBqpa5euE2OoMqJWEzN6I,9519
54
+ atlassian_python_api-4.0.3.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
55
+ atlassian_python_api-4.0.3.dist-info/top_level.txt,sha256=84-EDv8LNaZx01TCGjBzglwPU1JSRJ7fPSq9uy55Sv0,10
56
+ atlassian_python_api-4.0.3.dist-info/RECORD,,