atlassian-python-api 3.41.18__py3-none-any.whl → 3.41.21__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
- 3.41.18
1
+ 3.41.21
@@ -113,7 +113,9 @@ class BitbucketCloudBase(BitbucketBase):
113
113
  e = j["error"]
114
114
  error_msg = e["message"]
115
115
  if e.get("detail"):
116
- error_msg += "\n" + e["detail"]
116
+ # It uses interpolation instead of concatenation because of
117
+ # https://github.com/atlassian-api/atlassian-python-api/issues/1481
118
+ error_msg = "{}\n{}".format(error_msg, str(e["detail"]))
117
119
  except Exception as e:
118
120
  log.error(e)
119
121
  response.raise_for_status()
@@ -1 +1 @@
1
- """ Bitbucket Cloud common package """
1
+ """Bitbucket Cloud common package"""
@@ -27,7 +27,7 @@ class Repositories(RepositoriesBase):
27
27
  def __init__(self, url, *args, **kwargs):
28
28
  super(Repositories, self).__init__(url, *args, **kwargs)
29
29
 
30
- def each(self, after=None, role=None, q=None, sort=None):
30
+ def each(self, after=None, role=None, q=None, sort=None, pagelen=None):
31
31
  """
32
32
  Get all repositories matching the criteria.
33
33
 
@@ -47,6 +47,8 @@ class Repositories(RepositoriesBase):
47
47
  See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
48
48
  :param sort: string: Name of a response property to sort results.
49
49
  See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
50
+ :param pagelen: int: Name of a response property to change page size.
51
+ See https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination for details.
50
52
 
51
53
  :return: A generator for the repository objects
52
54
 
@@ -64,6 +66,8 @@ class Repositories(RepositoriesBase):
64
66
  params["q"] = q
65
67
  if sort is not None:
66
68
  params["sort"] = sort
69
+ if pagelen is not None:
70
+ params["pagelen"] = pagelen
67
71
  for repository in self._get_paged(None, params):
68
72
  yield self._get_object(repository)
69
73
 
@@ -3,7 +3,7 @@
3
3
  from ..base import BitbucketCloudBase
4
4
  from ..common.builds import Build
5
5
  from ..common.comments import Comment
6
- from ..common.users import User, Participant
6
+ from ..common.users import Participant, User
7
7
 
8
8
 
9
9
  class Commits(BitbucketCloudBase):
@@ -186,3 +186,29 @@ class Commit(BitbucketCloudBase):
186
186
  API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-approve-delete
187
187
  """
188
188
  return super(BitbucketCloudBase, self).delete("approve")
189
+
190
+ def get_pull_requests(self, start=0, pagelen=0):
191
+ """
192
+ Retrieves pull requests associated with the current commit.
193
+
194
+ Pull Request Commit Links app must be installed first before using this API;
195
+ installation automatically occurs when 'Go to pull request' is clicked
196
+ from the web interface for a commit's details.
197
+
198
+ API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-commit-commit-pullrequests-get
199
+
200
+ :param start: int, OPTIONAL: The starting page of pull requests to retrieve. Defaults to 0.
201
+ :param pagelen: int, OPTIONAL: The number of pull requests to retrieve per page. Defaults to 0.
202
+ :return: Generator[PullRequest]: A generator that yields `PullRequest` objects.
203
+ """
204
+ # NOTE: Import moved inside the method to avoid circular import issues
205
+ from ...cloud.repositories.pullRequests import PullRequest
206
+
207
+ params = {}
208
+ if start:
209
+ params["page"] = start
210
+ if pagelen:
211
+ params["pagelen"] = pagelen
212
+
213
+ for pull_request in self._get_paged(url="pullrequests", params=params):
214
+ yield PullRequest(pull_request, **self._new_session_args)
@@ -32,7 +32,7 @@ class Refs(BitbucketCloudBase):
32
32
 
33
33
  return self._get_object(self.post(None, data))
34
34
 
35
- def each(self, q=None, sort=None):
35
+ def each(self, q=None, sort=None, pagelen=None):
36
36
  """
37
37
  Returns the list of refs in this repository.
38
38
 
@@ -40,6 +40,8 @@ class Refs(BitbucketCloudBase):
40
40
  See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
41
41
  :param sort: string: Name of a response property to sort results.
42
42
  See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
43
+ :param pagelen: int: Name of a response property to change page size.
44
+ See https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination for details.
43
45
 
44
46
  :return: A generator for the Ref objects
45
47
  """
@@ -48,6 +50,8 @@ class Refs(BitbucketCloudBase):
48
50
  params["sort"] = sort
49
51
  if q is not None:
50
52
  params["q"] = q
53
+ if pagelen is not None:
54
+ params["pagelen"] = pagelen
51
55
  for ref in self._get_paged(None, trailing=True, params=params):
52
56
  yield self._get_object(super(Refs, self).get(ref.get("name")))
53
57
 
@@ -1 +1 @@
1
- """ Bitbucket Server common package """
1
+ """Bitbucket Server common package"""
atlassian/confluence.py CHANGED
@@ -390,7 +390,8 @@ class Confluence(AtlassianRestAPI):
390
390
  """
391
391
  Fetches html tables added to confluence page
392
392
  :param page_id: integer confluence page_id
393
- :return: json object with page_id, number_of_tables_in_page and list of list tables_content representing scrapepd tables
393
+ :return: json object with page_id, number_of_tables_in_page
394
+ and list of list tables_content representing scraped tables
394
395
  """
395
396
  try:
396
397
  page_content = self.get_page_by_id(page_id, expand="body.storage")["body"]["storage"]["value"]
@@ -732,17 +733,17 @@ class Confluence(AtlassianRestAPI):
732
733
  """
733
734
  Get all pages from a set of space ids:
734
735
  https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-get
735
-
736
736
  :param space_ids: A Set of space IDs passed as a filter to Confluence
737
737
  :param batch_size: OPTIONAL: The batch size of pages to retrieve from confluence per request MAX is 250.
738
738
  Default: 250
739
739
  :param sort: OPTIONAL: The order the pages are retrieved in.
740
- Valid values: id, -id, created-date, -created-date, modified-date, -modified-date, title, -title
740
+ Valid values:
741
+ id, -id, created-date, -created-date, modified-date, -modified-date, title, -title
741
742
  :param status: OPTIONAL: Filter pages based on their status.
742
743
  Valid values: current, archived, deleted, trashed
743
744
  Default: current,archived
744
745
  :param title: OPTIONAL: Filter pages based on their title.
745
- :param body-format: OPTIONAL: The format of the body in the response. Valid values: storage, atlas_doc_format
746
+ :param body_format: OPTIONAL: The format of the body in the response. Valid values: storage, atlas_doc_format
746
747
  :return:
747
748
  """
748
749
  path = "/api/v2/pages"
@@ -1469,8 +1470,7 @@ class Confluence(AtlassianRestAPI):
1469
1470
  file_name = attachment["title"] or attachment["id"] # Use attachment ID if title is unavailable
1470
1471
  download_link = self.url + attachment["_links"]["download"]
1471
1472
  # Fetch the file content
1472
- response = self._session.get(str(download_link))
1473
- response.raise_for_status() # Raise error if request fails
1473
+ response = self.get(str(download_link))
1474
1474
 
1475
1475
  if to_memory:
1476
1476
  # Store in BytesIO object
@@ -1492,7 +1492,11 @@ class Confluence(AtlassianRestAPI):
1492
1492
  except PermissionError:
1493
1493
  raise PermissionError("Permission denied when trying to save files to '{path}'.".format(path=path))
1494
1494
  except requests.HTTPError as http_err:
1495
- raise Exception("HTTP error occurred while downloading attachments: {http_err}".format(http_err=http_err))
1495
+ raise requests.HTTPError(
1496
+ "HTTP error occurred while downloading attachments: {http_err}".format(http_err=http_err),
1497
+ response=http_err.response,
1498
+ request=http_err.request,
1499
+ )
1496
1500
  except Exception as err:
1497
1501
  raise Exception("An unexpected error occurred: {error}".format(error=err))
1498
1502
 
@@ -2736,7 +2740,8 @@ class Confluence(AtlassianRestAPI):
2736
2740
  """
2737
2741
  Export a Confluence space to a file of the specified type.
2738
2742
  (!) This method was developed for Confluence Cloud and may not work with Confluence on-prem.
2739
- (!) This is an experimental method that does not trigger an officially supported REST endpoint. It may break if Atlassian changes the space export front-end logic.
2743
+ (!) This is an experimental method that does not trigger an officially supported REST endpoint.
2744
+ It may break if Atlassian changes the space export front-end logic.
2740
2745
 
2741
2746
  :param space_key: The key of the space to export.
2742
2747
  :param export_type: The type of export to perform. Valid values are: 'html', 'csv', 'xml', 'pdf'.
@@ -2744,7 +2749,8 @@ class Confluence(AtlassianRestAPI):
2744
2749
  """
2745
2750
 
2746
2751
  def get_atl_request(url: str):
2747
- # Nested function used to get atl_token used for XSRF protection. this is only applicable to html/csv/xml space exports
2752
+ # Nested function used to get atl_token used for XSRF protection.
2753
+ # This is only applicable to html/csv/xml space exports
2748
2754
  try:
2749
2755
  response = self.get(url, advanced_mode=True)
2750
2756
  parsed_html = BeautifulSoup(response.text, "html.parser")
@@ -2753,7 +2759,7 @@ class Confluence(AtlassianRestAPI):
2753
2759
  except Exception as e:
2754
2760
  raise ApiError("Problems with getting the atl_token for get_space_export method :", reason=e)
2755
2761
 
2756
- # Checks if space_ke parameter is valid and if api_token has relevant permissions to space
2762
+ # Checks if space_ke parameter is valid and if api_token has relevant permissions to space
2757
2763
  self.get_space(space_key=space_key, expand="permissions")
2758
2764
 
2759
2765
  try:
atlassian/jira.py CHANGED
@@ -223,7 +223,7 @@ class Jira(AtlassianRestAPI):
223
223
  def get_attachments_ids_from_issue(self, issue):
224
224
  """
225
225
  Get attachments IDs from jira issue
226
- :param jira issue key: str
226
+ :param issue: str : jira issue key
227
227
  :return: list of integers attachment IDs
228
228
  """
229
229
  issue_id = self.get_issue(issue)["fields"]["attachment"]
@@ -242,6 +242,16 @@ class Jira(AtlassianRestAPI):
242
242
  url = "{base_url}/{attachment_id}".format(base_url=base_url, attachment_id=attachment_id)
243
243
  return self.get(url)
244
244
 
245
+ def download_issue_attachments(self, issue, path=None):
246
+ """
247
+ Downloads all attachments from a Jira issue.
248
+ :param issue: The issue-key of the Jira issue
249
+ :param path: Path to directory where attachments will be saved. If None, current working directory will be used.
250
+ :return: A message indicating the result of the download operation.
251
+ """
252
+ return self.download_attachments_from_issue(issue=issue, path=path, cloud=self.cloud)
253
+
254
+ @deprecated(version="3.41.20", reason="Use download_issue_attachments instead")
245
255
  def download_attachments_from_issue(self, issue, path=None, cloud=True):
246
256
  """
247
257
  Downloads all attachments from a Jira issue.
@@ -656,12 +666,16 @@ class Jira(AtlassianRestAPI):
656
666
  def get_custom_fields(self, search=None, start=1, limit=50):
657
667
  """
658
668
  Get custom fields. Evaluated on 7.12
669
+ Get fields paginated in cloud
659
670
  :param search: str
660
671
  :param start: long Default: 1
661
672
  :param limit: int Default: 50
662
673
  :return:
663
674
  """
664
- url = self.resource_url("customFields")
675
+ if self.cloud:
676
+ url = self.resource_url("field/search")
677
+ else:
678
+ url = self.resource_url("customFields")
665
679
  params = {}
666
680
  if search:
667
681
  params["search"] = search
@@ -1382,7 +1396,7 @@ class Jira(AtlassianRestAPI):
1382
1396
 
1383
1397
  def update_issue(self, issue_key, update):
1384
1398
  """
1385
- :param issue: the issue to update
1399
+ :param issue_key: the issue to update
1386
1400
  :param update: the update to make
1387
1401
  :return: True if successful, False if not
1388
1402
  """
@@ -1391,7 +1405,7 @@ class Jira(AtlassianRestAPI):
1391
1405
 
1392
1406
  def label_issue(self, issue_key, labels):
1393
1407
  """
1394
- :param issue: the issue to update
1408
+ :param issue_key: the issue to update
1395
1409
  :param labels: the labels to add
1396
1410
  :return: True if successful, False if not
1397
1411
  """
@@ -1400,7 +1414,7 @@ class Jira(AtlassianRestAPI):
1400
1414
 
1401
1415
  def unlabel_issue(self, issue_key, labels):
1402
1416
  """
1403
- :param issue: the issue to update
1417
+ :param issue_key: the issue to update
1404
1418
  :param labels: the labels to remove
1405
1419
  :return: True if successful, False if not
1406
1420
  """
@@ -2508,7 +2522,7 @@ class Jira(AtlassianRestAPI):
2508
2522
  """
2509
2523
  base_url = self.resource_url("project")
2510
2524
  url = "{base_url}/{key}/archive".format(base_url=base_url, key=key)
2511
- return self.post(url)
2525
+ return self.put(url)
2512
2526
 
2513
2527
  def project(self, key, expand=None):
2514
2528
  """
@@ -3760,6 +3774,53 @@ api-group-workflows/#api-rest-api-2-workflow-search-get)
3760
3774
  url = "{base_url}/{schemeID}/permission".format(base_url=base_url, schemeID=permission_id)
3761
3775
  return self.post(url, data=new_permission)
3762
3776
 
3777
+ def update_permissionscheme(self, permission_id, name, description=None, permissions=None, scope=None, expand=None):
3778
+ """
3779
+ Updates a permission scheme. Below are some important things to note when using this resource:
3780
+ - If a permissions list is present in the request, then it is set in the permission scheme, overwriting all existing grants.
3781
+ - If you want to update only the name and description, then do not send a permissions list in the request.
3782
+ - Sending an empty list will remove all permission grants from the permission scheme.
3783
+
3784
+ Cloud API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-permission-schemes/#api-rest-api-3-permissionscheme-schemeid-put
3785
+
3786
+ :param permission_id: int, REQUIRED: The ID of the permission scheme to update.
3787
+ :param name: str, REQUIRED: The name of the permission scheme. Must be unique.
3788
+ :param description: str, OPTIONAL: A description for the permission scheme. Defaults to None.
3789
+ :param permissions: list[dict], OPTIONAL: A collection of permission grants. Defaults to None.
3790
+ Example:
3791
+ [
3792
+ {
3793
+ "holder": {
3794
+ "parameter": "jira-core-users",
3795
+ "type": "group",
3796
+ "value": "ca85fac0-d974-40ca-a615-7af99c48d24f"
3797
+ },
3798
+ "permission": "ADMINISTER_PROJECTS"
3799
+ }
3800
+ ]
3801
+ :param scope: OPTIONAL: The scope of the permission scheme.
3802
+ :param expand: str, OPTIONAL: Use expand to include additional information in the response.
3803
+ This parameter accepts a comma-separated list.
3804
+ Note that permissions are always included when you specify any value.
3805
+
3806
+ :return:
3807
+ """
3808
+ base_url = self.resource_url("permissionscheme")
3809
+ url = "{base_url}/{scheme_id}".format(base_url=base_url, scheme_id=permission_id)
3810
+ data = {"name": name}
3811
+ if description is not None:
3812
+ data["description"] = description
3813
+ if permissions is not None:
3814
+ data["permissions"] = permissions
3815
+ if scope is not None:
3816
+ data["scope"] = scope
3817
+
3818
+ params = {}
3819
+ if expand:
3820
+ params["expand"] = expand
3821
+
3822
+ return self.put(url, data=data, params=params)
3823
+
3763
3824
  """
3764
3825
  REST resource that allows to view security schemes defined in the product.
3765
3826
  Resource for managing priority schemes.
atlassian/rest_client.py CHANGED
@@ -1,5 +1,6 @@
1
1
  # coding=utf-8
2
2
  import logging
3
+ import random
3
4
  from json import dumps
4
5
 
5
6
  import requests
@@ -9,12 +10,13 @@ try:
9
10
  from oauthlib.oauth1.rfc5849 import SIGNATURE_RSA_SHA512 as SIGNATURE_RSA
10
11
  except ImportError:
11
12
  from oauthlib.oauth1 import SIGNATURE_RSA
13
+ import time
14
+
15
+ import urllib3
12
16
  from requests import HTTPError
13
17
  from requests_oauthlib import OAuth1, OAuth2
14
18
  from six.moves.urllib.parse import urlencode
15
- import time
16
19
  from urllib3.util import Retry
17
- import urllib3
18
20
 
19
21
  from atlassian.request_utils import get_default_logger
20
22
 
@@ -69,6 +71,9 @@ class AtlassianRestAPI(object):
69
71
  retry_status_codes=[413, 429, 503],
70
72
  max_backoff_seconds=1800,
71
73
  max_backoff_retries=1000,
74
+ backoff_factor=1.0,
75
+ backoff_jitter=1.0,
76
+ retry_with_header=True,
72
77
  ):
73
78
  """
74
79
  init function for the AtlassianRestAPI object.
@@ -102,6 +107,20 @@ class AtlassianRestAPI(object):
102
107
  wait any longer than this. Defaults to 1800.
103
108
  :param max_backoff_retries: Maximum number of retries to try before
104
109
  continuing. Defaults to 1000.
110
+ :param backoff_factor: Factor by which to multiply the backoff time (for exponential backoff).
111
+ Defaults to 1.0.
112
+ :param backoff_jitter: Random variation to add to the backoff time to avoid synchronized retries.
113
+ Defaults to 1.0.
114
+ :param retry_with_header: Enable retry logic based on the `Retry-After` header.
115
+ If set to True, the request will automatically retry if the response
116
+ contains a `Retry-After` header with a delay and has a status code of 429.
117
+ The retry delay will be extracted
118
+ from the `Retry-After` header and the request will be paused for the specified
119
+ duration before retrying. Defaults to True.
120
+ If the `Retry-After` header is not present, retries will not occur.
121
+ However, if the `Retry-After` header is missing and `backoff_and_retry` is enabled,
122
+ the retry logic will still be triggered based on the status code 429,
123
+ provided that 429 is included in the `retry_status_codes` list.
105
124
  """
106
125
  self.url = url
107
126
  self.username = username
@@ -115,21 +134,34 @@ class AtlassianRestAPI(object):
115
134
  self.cloud = cloud
116
135
  self.proxies = proxies
117
136
  self.cert = cert
137
+ self.backoff_and_retry = backoff_and_retry
138
+ self.max_backoff_retries = max_backoff_retries
139
+ self.retry_status_codes = retry_status_codes
140
+ self.max_backoff_seconds = max_backoff_seconds
141
+ self.use_urllib3_retry = int(urllib3.__version__.split(".")[0]) >= 2
142
+ self.backoff_factor = backoff_factor
143
+ self.backoff_jitter = backoff_jitter
144
+ self.retry_with_header = retry_with_header
118
145
  if session is None:
119
146
  self._session = requests.Session()
120
147
  else:
121
148
  self._session = session
122
- if backoff_and_retry and int(urllib3.__version__.split(".")[0]) >= 2:
149
+
150
+ if proxies is not None:
151
+ self._session.proxies = self.proxies
152
+
153
+ if self.backoff_and_retry and self.use_urllib3_retry:
123
154
  # Note: we only retry on status and not on any of the
124
155
  # other supported reasons
125
156
  retries = Retry(
126
157
  total=None,
127
- status=max_backoff_retries,
158
+ status=self.max_backoff_retries,
128
159
  allowed_methods=None,
129
- status_forcelist=retry_status_codes,
130
- backoff_factor=1,
131
- backoff_jitter=1,
132
- backoff_max=max_backoff_seconds,
160
+ status_forcelist=self.retry_status_codes,
161
+ backoff_factor=self.backoff_factor,
162
+ backoff_jitter=self.backoff_jitter,
163
+ backoff_max=self.max_backoff_seconds,
164
+ respect_retry_after_header=self.retry_with_header,
133
165
  )
134
166
  self._session.mount(self.url, HTTPAdapter(max_retries=retries))
135
167
  if username and password:
@@ -205,6 +237,59 @@ class AtlassianRestAPI(object):
205
237
  log.error(e)
206
238
  return None
207
239
 
240
+ def _calculate_backoff_value(self, retry_count):
241
+ """
242
+ Calculate the backoff delay for a given retry attempt.
243
+
244
+ This method computes an exponential backoff delay based on the retry count and
245
+ a configurable backoff factor. It optionally adds a random jitter to introduce
246
+ variability in the delay, which can help prevent synchronized retries in
247
+ distributed systems. The calculated backoff delay is clamped between 0 and a
248
+ maximum allowable delay (`self.max_backoff_seconds`) to avoid excessively long
249
+ wait times.
250
+
251
+ :param retry_count: int, REQUIRED: The current retry attempt number (1-based).
252
+ Determines the exponential backoff delay.
253
+ :return: float: The calculated backoff delay in seconds, adjusted for jitter
254
+ and clamped to the maximum allowable value.
255
+ """
256
+ backoff_value = self.backoff_factor * (2 ** (retry_count - 1))
257
+ if self.backoff_jitter != 0.0:
258
+ backoff_value += random.uniform(0, self.backoff_jitter) # nosec B311
259
+ return float(max(0, min(self.max_backoff_seconds, backoff_value)))
260
+
261
+ def _retry_handler(self):
262
+ """
263
+ Creates and returns a retry handler function for managing HTTP request retries.
264
+
265
+ The returned handler function determines whether a request should be retried
266
+ based on the response and retry settings.
267
+
268
+ :return: Callable[[Response], bool]: A function that takes an HTTP response object as input and
269
+ returns `True` if the request should be retried, or `False` otherwise.
270
+ """
271
+ retries = 0
272
+
273
+ def _handle(response):
274
+ nonlocal retries
275
+
276
+ if self.retry_with_header and "Retry-After" in response.headers and response.status_code == 429:
277
+ time.sleep(int(response.headers["Retry-After"]))
278
+ return True
279
+
280
+ if not self.backoff_and_retry or self.use_urllib3_retry:
281
+ return False
282
+
283
+ if retries < self.max_backoff_retries and response.status_code in self.retry_status_codes:
284
+ retries += 1
285
+ backoff_value = self._calculate_backoff_value(retries)
286
+ time.sleep(backoff_value)
287
+ return True
288
+
289
+ return False
290
+
291
+ return _handle
292
+
208
293
  def log_curl_debug(self, method, url, data=None, headers=None, level=logging.DEBUG):
209
294
  """
210
295
 
@@ -270,30 +355,32 @@ class AtlassianRestAPI(object):
270
355
  :param advanced_mode: bool, OPTIONAL: Return the raw response
271
356
  :return:
272
357
  """
358
+ url = self.url_joiner(None if absolute else self.url, path, trailing)
359
+ params_already_in_url = True if "?" in url else False
360
+ if params or flags:
361
+ if params_already_in_url:
362
+ url += "&"
363
+ else:
364
+ url += "?"
365
+ if params:
366
+ url += urlencode(params or {})
367
+ if flags:
368
+ url += ("&" if params or params_already_in_url else "") + "&".join(flags or [])
369
+ json_dump = None
370
+ if files is None:
371
+ data = None if not data else dumps(data)
372
+ json_dump = None if not json else dumps(json)
373
+
374
+ headers = headers or self.default_headers
273
375
 
376
+ retry_handler = self._retry_handler()
274
377
  while True:
275
- url = self.url_joiner(None if absolute else self.url, path, trailing)
276
- params_already_in_url = True if "?" in url else False
277
- if params or flags:
278
- if params_already_in_url:
279
- url += "&"
280
- else:
281
- url += "?"
282
- if params:
283
- url += urlencode(params or {})
284
- if flags:
285
- url += ("&" if params or params_already_in_url else "") + "&".join(flags or [])
286
- json_dump = None
287
- if files is None:
288
- data = None if not data else dumps(data)
289
- json_dump = None if not json else dumps(json)
290
378
  self.log_curl_debug(
291
379
  method=method,
292
380
  url=url,
293
381
  headers=headers,
294
- data=data if data else json_dump,
382
+ data=data or json_dump,
295
383
  )
296
- headers = headers or self.default_headers
297
384
  response = self._session.request(
298
385
  method=method,
299
386
  url=url,
@@ -306,15 +393,15 @@ class AtlassianRestAPI(object):
306
393
  proxies=self.proxies,
307
394
  cert=self.cert,
308
395
  )
309
- response.encoding = "utf-8"
396
+ continue_retries = retry_handler(response)
397
+ if continue_retries:
398
+ continue
399
+ break
310
400
 
311
- log.debug("HTTP: %s %s -> %s %s", method, path, response.status_code, response.reason)
312
- log.debug("HTTP: Response text -> %s", response.text)
401
+ response.encoding = "utf-8"
313
402
 
314
- if response.status_code == 429:
315
- time.sleep(int(response.headers["Retry-After"]))
316
- else:
317
- break
403
+ log.debug("HTTP: %s %s -> %s %s", method, path, response.status_code, response.reason)
404
+ log.debug("HTTP: Response text -> %s", response.text)
318
405
 
319
406
  if self.advanced_mode or advanced_mode:
320
407
  return response
atlassian/service_desk.py CHANGED
@@ -196,6 +196,7 @@ class ServiceDesk(AtlassianRestAPI):
196
196
 
197
197
  :param issue_id_or_key: str
198
198
  :param users_list: list
199
+ :param account_list: list
199
200
  :return:
200
201
  """
201
202
  url = "rest/servicedeskapi/request/{}/participant".format(issue_id_or_key)
@@ -214,6 +215,7 @@ class ServiceDesk(AtlassianRestAPI):
214
215
 
215
216
  :param issue_id_or_key: str
216
217
  :param users_list: list
218
+ :param account_list: list
217
219
  :return:
218
220
  """
219
221
  url = "rest/servicedeskapi/request/{}/participant".format(issue_id_or_key)
atlassian/xray.py CHANGED
@@ -1,6 +1,7 @@
1
1
  # coding=utf-8
2
2
  import logging
3
3
  import re
4
+ from requests import HTTPError
4
5
  from .rest_client import AtlassianRestAPI
5
6
 
6
7
  log = logging.getLogger(__name__)
@@ -13,6 +14,25 @@ class Xray(AtlassianRestAPI):
13
14
  kwargs["api_root"] = "rest/raven"
14
15
  super(Xray, self).__init__(*args, **kwargs)
15
16
 
17
+ def raise_for_status(self, response):
18
+ """
19
+ Checks the response for an error status and raises an exception with the error message provided by the server
20
+ :param response:
21
+ :return:
22
+ """
23
+ if response.status_code == 401 and response.headers.get("Content-Type") != "application/json;charset=UTF-8":
24
+ raise HTTPError("Unauthorized (401)", response=response)
25
+
26
+ if 400 <= response.status_code < 600:
27
+ try:
28
+ j = response.json()
29
+ error_msg = j["message"]
30
+ except Exception as e:
31
+ log.error(e)
32
+ response.raise_for_status()
33
+ else:
34
+ raise HTTPError(error_msg, response=response)
35
+
16
36
  def resource_url(self, resource, api_root=None, api_version=None):
17
37
  """
18
38
  Overloading the method from AtlassianRestAPI to be compatible with the "middle man" version used by Xray.
@@ -463,6 +483,16 @@ class Xray(AtlassianRestAPI):
463
483
  url = self.resource_url("testrun/{0}".format(test_run_id))
464
484
  return self.put(url, update)
465
485
 
486
+ def get_test_run_iteration(self, test_run_id, iteration_id):
487
+ """
488
+ Retrieve the specified iteration for the given test run.
489
+ :param test_run_id: ID of the test run (e.g. 100).
490
+ :param iteration_id: ID of the iteration.
491
+ :return: Returns the specified iteration for the given test run.
492
+ """
493
+ url = self.resource_url("testrun/{0}/iteration/{1}".format(test_run_id, iteration_id))
494
+ return self.get(url)
495
+
466
496
  def get_test_run_status(self, test_run_id):
467
497
  """
468
498
  Retrieve the status for the given test run.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: atlassian-python-api
3
- Version: 3.41.18
3
+ Version: 3.41.21
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
@@ -1,31 +1,31 @@
1
- atlassian/VERSION,sha256=z1ZgB8gRqxokPyvk5XQGlYHR2gJozsqQ7AfiKhSAi2o,8
1
+ atlassian/VERSION,sha256=O5dBKwitImKiKQKLHtL4PSYF2dcaBbDHylGcl7paUq4,8
2
2
  atlassian/__init__.py,sha256=F13CZFoWIj9pDkj83soA7hwwHtvDC6EqFATey9p36PM,768
3
3
  atlassian/bamboo.py,sha256=uPpmwkHQ_RiM8BkZvPunl6n1RnpEflKIS9AefZd5ne8,48969
4
4
  atlassian/cloud_admin.py,sha256=vZxMA6IrdCQw1KAX3xKal_0ayTWGdMVhe3i0bPpChGk,969
5
- atlassian/confluence.py,sha256=TsKIz_4AthBjVh2LuL8xZhAq0KHCnEpKXLJzReT1m_g,134503
5
+ atlassian/confluence.py,sha256=8HiGY6W1uap6_l63vTMhoMHlJjeWbtXDt4qBFbm49Bk,134613
6
6
  atlassian/crowd.py,sha256=owgIavDgS5vnPEx-AiBi0mLa2DKV0jKW381vn0uLMfM,9556
7
7
  atlassian/errors.py,sha256=GAKr6W4zPn7ZUMRLHG8-UgAdVnxDzKVZ-jyGXAccALE,398
8
8
  atlassian/insight.py,sha256=6R9jxOqdFZKpWp5KPWVBKftcxdxbWAXbYdycHux3DdE,23717
9
- atlassian/jira.py,sha256=fCg5aKmbc568ev8Wvc4Q_8G_u0mRk_920TZ2TIxsbzI,210203
9
+ atlassian/jira.py,sha256=vmHixouZH2jn-moUchcpluCPDd8hSXRDSB_6WbCmXsQ,213323
10
10
  atlassian/marketplace.py,sha256=-y7j0mOi00gBzq1Izj-sXI8khP90rKJUYXijpKW9vs8,2590
11
11
  atlassian/portfolio.py,sha256=ioJMyxJW_Uuitszzd0ExoF1t8tykdit7Z7-WYlI6raA,3807
12
12
  atlassian/request_utils.py,sha256=HRqGJyeWS3L3SAlgC2x8tKakvyHb1HafxcrHhTNq9iE,1127
13
- atlassian/rest_client.py,sha256=nkz1ZkdA8YP564MuSvD4JHoYJ1c-WuO2UnCD4L1kzCA,19925
14
- atlassian/service_desk.py,sha256=Q5ztws347APDonqEqt9dC4yglLoiULynKYZrbHFNUeQ,33499
13
+ atlassian/rest_client.py,sha256=DBdRNPZ5coJy_LzcgBBtisX5vD2d1pU_P1qjuWak1nc,23991
14
+ atlassian/service_desk.py,sha256=LPvPHl2yuzdaBV7lgRUXNyOESquZUjp7sV3vXwekQfU,33567
15
15
  atlassian/statuspage.py,sha256=M6Ryz4cpLrjqEiv-W6Uch4_OLjdxVILQpUojeAnYYdA,94470
16
16
  atlassian/utils.py,sha256=oKvkGflmgygUcTU-fKd0LBnovgBpu3e5uHsj0sng_vg,10955
17
- atlassian/xray.py,sha256=3OvLMNfTxfCXgKXxpjhq3a01RemOEtvJH9OqbCJrHEs,26219
17
+ atlassian/xray.py,sha256=Be7FE0b-AlgCgYXMs8xamHAliHUgVqXIoWZawOh4XI4,27453
18
18
  atlassian/bitbucket/__init__.py,sha256=VmpVH3EWKm3eQMTFBLVwJDRfDlbQ_EP3EMgRryAPzQA,136984
19
19
  atlassian/bitbucket/base.py,sha256=aZpA8J-iMWVahXLCUt-X2MmZ1nG20wCGD0ykKlZrEJ0,6447
20
20
  atlassian/bitbucket/cloud/__init__.py,sha256=MX58kb4PKRK5M_iLyh0pya0FG8c9cYJkCAEVsugiGok,821
21
- atlassian/bitbucket/cloud/base.py,sha256=K2v04dr3K22Wsx8w-fmPQym3vsSflOERYA_TtSMwr4c,4094
22
- atlassian/bitbucket/cloud/common/__init__.py,sha256=5r9gwfcmU-AwZXG4kjU_Jpj_R72MLXJXOn0otMYAg4c,39
21
+ atlassian/bitbucket/cloud/base.py,sha256=P1GkxC1zE3WSYMtkNhCGBznHT-bg_WKBa5rt_Jqk5h0,4287
22
+ atlassian/bitbucket/cloud/common/__init__.py,sha256=xhpE0cKTpx6a1jjazmjIexNFuq0a5gpzefmM_NnH7fw,37
23
23
  atlassian/bitbucket/cloud/common/builds.py,sha256=Gka9aQIKxzzCU3JGHg97zNEz01_eFyOpJA9su-D2C_I,2366
24
24
  atlassian/bitbucket/cloud/common/comments.py,sha256=ktnN9G0Vr49rIAeqTElnEXvpePp6roUw_Om06JnEb-4,1329
25
25
  atlassian/bitbucket/cloud/common/users.py,sha256=BbjkMeNFp7JwuewbKL_5qO1geuZ5iu3u5AThPu1pYJo,2390
26
- atlassian/bitbucket/cloud/repositories/__init__.py,sha256=go2mUdLJzihGsA73ChaJGafDdrds7LHD_ejBSZ8R_Uk,16969
26
+ atlassian/bitbucket/cloud/repositories/__init__.py,sha256=IHfzRNSCmy1thN8t5trknvhLPlSNenokfxYczMfwP68,17250
27
27
  atlassian/bitbucket/cloud/repositories/branchRestrictions.py,sha256=E1wr1pheH9UnVLMao8-9rwmNZPJeLRoM1AmFQnfe4jQ,6503
28
- atlassian/bitbucket/cloud/repositories/commits.py,sha256=mIheLsyIsfBParfNFhSoSJGAP8c-vlHgRVqoQfBOy00,6414
28
+ atlassian/bitbucket/cloud/repositories/commits.py,sha256=Tr4YKVrNdQXQ4nIKtMfCOTLJwnF3MVBGVJcjCKvbNlU,7668
29
29
  atlassian/bitbucket/cloud/repositories/defaultReviewers.py,sha256=bSa1iPILiKf9IcWcCYCQtYxQHoqeiuYGBHD7JVmXa-4,3560
30
30
  atlassian/bitbucket/cloud/repositories/deploymentEnvironments.py,sha256=f7FAS5ljkRZOW-SkNEugQMoIVGCQVpl5gPpNW-vWEkU,9405
31
31
  atlassian/bitbucket/cloud/repositories/diffstat.py,sha256=tzi9mDC71Jps-Lj_UdvR3mUb1nFlbN2DZ1bjHfGu26A,2893
@@ -34,7 +34,7 @@ atlassian/bitbucket/cloud/repositories/hooks.py,sha256=erNk58XuROeG4ruAqNLFTxpyR
34
34
  atlassian/bitbucket/cloud/repositories/issues.py,sha256=rJzPfhETsI7qqi9xyo_MwaTPnwxmQe2pyBYTLyMf9Eg,5065
35
35
  atlassian/bitbucket/cloud/repositories/pipelines.py,sha256=i4Vb0r3exi7gSkG0W1VGvB8x-DzZQn4RVrOHVo2e2rQ,9157
36
36
  atlassian/bitbucket/cloud/repositories/pullRequests.py,sha256=11xN8-_wUT-eV-A39fCRW-jm6jm9Qn1ClpLZiaZtEJk,16253
37
- atlassian/bitbucket/cloud/repositories/refs.py,sha256=9PKHp47uQIUeYsxzfemMRFMiGhHZfAJJJC_-ZzhQ_J8,3732
37
+ atlassian/bitbucket/cloud/repositories/refs.py,sha256=hrZKaXa7_7PYO7bNGkdq6onF8YB46eBhLd56o1miEfY,4013
38
38
  atlassian/bitbucket/cloud/repositories/repositoryVariables.py,sha256=jiN-X-x2pX2g924emGKYCFd0dp-UAn6XoFVbBj4lfk0,5034
39
39
  atlassian/bitbucket/cloud/workspaces/__init__.py,sha256=Pos5ktbVEqfcP6tTV5P-DzZL43ElDSjYT9y1CLgJnrM,5081
40
40
  atlassian/bitbucket/cloud/workspaces/members.py,sha256=qTQAC82b1E0B41dVwoCoJQgNRM9ewPM49usEHAr6NAw,1759
@@ -43,12 +43,12 @@ atlassian/bitbucket/cloud/workspaces/projects.py,sha256=oYm3Wj_RZYmeeim-j8e0-qQI
43
43
  atlassian/bitbucket/server/__init__.py,sha256=v3sCf4A6-hTYaf_6ZcCDJJk0qqDGZYG5uoNArxNGSyQ,1613
44
44
  atlassian/bitbucket/server/base.py,sha256=43GYeayyCzqwFlJC3P1zYRJ4T948I1JCL5b62f1sIDo,1839
45
45
  atlassian/bitbucket/server/globalPermissions.py,sha256=_0LMi4KqQZAfm34tHaMfMyDYShB4QMZsol1SWY3OrCM,5975
46
- atlassian/bitbucket/server/common/__init__.py,sha256=0j0CWKFaX1kDqfDQkf3__Y2p24t1tS4wfOV8ZjZ9j5M,40
46
+ atlassian/bitbucket/server/common/__init__.py,sha256=woZpR3WXAA3A99hZ1UZI_gLPHaATxEyCWW7GRTCI4e4,38
47
47
  atlassian/bitbucket/server/common/permissions.py,sha256=89KLu4PY5BUJZsjTrJ8JbrQ46EHn1qj_P-ZJ-uGv3dA,7318
48
48
  atlassian/bitbucket/server/projects/__init__.py,sha256=QXHgvrf3lS14OAbtXNdn9TC8ML2fZUkrC5C8BTR3I_0,7696
49
49
  atlassian/bitbucket/server/projects/repos/__init__.py,sha256=jvoi3Xp8fdL_-00U6XvxsJ6ThxnXsn0QewKYiZu_s_A,10810
50
- atlassian_python_api-3.41.18.dist-info/LICENSE,sha256=xamAnoX0zfBamIilAfP3nSIt7dIvnj7oueX14l6uKPY,11335
51
- atlassian_python_api-3.41.18.dist-info/METADATA,sha256=jVu1OTq1MBXCD3EeG5kmU_fyJxH0TRpQhb79QpK6u3Q,9074
52
- atlassian_python_api-3.41.18.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
53
- atlassian_python_api-3.41.18.dist-info/top_level.txt,sha256=84-EDv8LNaZx01TCGjBzglwPU1JSRJ7fPSq9uy55Sv0,10
54
- atlassian_python_api-3.41.18.dist-info/RECORD,,
50
+ atlassian_python_api-3.41.21.dist-info/LICENSE,sha256=xamAnoX0zfBamIilAfP3nSIt7dIvnj7oueX14l6uKPY,11335
51
+ atlassian_python_api-3.41.21.dist-info/METADATA,sha256=N-rodrMaadIyh_bBO_fYyPWOhsPjvxEVsc5QV3YMhPM,9074
52
+ atlassian_python_api-3.41.21.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
53
+ atlassian_python_api-3.41.21.dist-info/top_level.txt,sha256=84-EDv8LNaZx01TCGjBzglwPU1JSRJ7fPSq9uy55Sv0,10
54
+ atlassian_python_api-3.41.21.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5