atlassian-python-api 3.41.14__py3-none-any.whl → 3.41.15__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.14
1
+ 3.41.15
@@ -1,5 +1,7 @@
1
1
  # coding=utf-8
2
2
  import logging
3
+ from enum import Enum
4
+ from typing import Optional, Union
3
5
 
4
6
  from deprecated import deprecated
5
7
  from requests import HTTPError
@@ -10,6 +12,16 @@ from atlassian.bitbucket.cloud import Cloud
10
12
  log = logging.getLogger(__name__)
11
13
 
12
14
 
15
+ class MergeStrategy(Enum):
16
+ """
17
+ Merge strategies used by the merge_pull_request method.
18
+ """
19
+
20
+ MERGE_COMMIT = "merge_commit"
21
+ SQUASH = "squash"
22
+ FAST_FORWARD = "fast_forward"
23
+
24
+
13
25
  class Bitbucket(BitbucketBase):
14
26
  def __init__(self, url, *args, **kwargs):
15
27
  if "cloud" not in kwargs and ("bitbucket.org" in url):
@@ -2194,7 +2206,16 @@ class Bitbucket(BitbucketBase):
2194
2206
  url = "{}/merge".format(self._url_pull_request(project_key, repository_slug, pr_id))
2195
2207
  return self.get(url)
2196
2208
 
2197
- def merge_pull_request(self, project_key, repository_slug, pr_id, pr_version):
2209
+ def merge_pull_request(
2210
+ self,
2211
+ project_key: str,
2212
+ repository_slug: str,
2213
+ pr_id: int,
2214
+ merge_message: str,
2215
+ close_source_branch: bool = False,
2216
+ merge_strategy: Union[str, MergeStrategy] = MergeStrategy.MERGE_COMMIT,
2217
+ pr_version: Optional[int] = None,
2218
+ ):
2198
2219
  """
2199
2220
  Merge pull request
2200
2221
  The authenticated user must have REPO_READ permission for the repository
@@ -2203,14 +2224,23 @@ class Bitbucket(BitbucketBase):
2203
2224
  :param project_key: PROJECT
2204
2225
  :param repository_slug: my_shiny_repo
2205
2226
  :param pr_id: 2341
2227
+ :param merge_message: "feat: add new file handler"
2206
2228
  :param pr_version:
2229
+ :param close_source_branch: True
2230
+ :param merge_strategy: "squash"
2207
2231
  :return:
2208
2232
  """
2209
2233
  url = "{}/merge".format(self._url_pull_request(project_key, repository_slug, pr_id))
2210
2234
  params = {}
2235
+ data = {
2236
+ "type": "pullrequest",
2237
+ "message": merge_message,
2238
+ "close_source_branch": close_source_branch,
2239
+ "merge_strategy": MergeStrategy(merge_strategy).value,
2240
+ }
2211
2241
  if not self.cloud:
2212
2242
  params["version"] = pr_version
2213
- return self.post(url, params=params)
2243
+ return self.post(url, data=data, params=params)
2214
2244
 
2215
2245
  def reopen_pull_request(self, project_key, repository_slug, pr_id, pr_version):
2216
2246
  """
@@ -164,7 +164,10 @@ class BitbucketBase(AtlassianRestAPI):
164
164
  # The format contains a : in the timezone which is supported from 3.7 on.
165
165
  if sys.version_info <= (3, 7):
166
166
  value_str = RE_TIMEZONE.sub(r"\1\2", value_str)
167
- value = datetime.strptime(value_str, self.CONF_TIMEFORMAT)
167
+ try:
168
+ value = datetime.strptime(value_str, self.CONF_TIMEFORMAT)
169
+ except ValueError:
170
+ value = datetime.strptime(value_str, "%Y-%m-%dT%H:%M:%S.%fZ", tzinfo="UTC")
168
171
  else:
169
172
  value = value_str
170
173
 
atlassian/confluence.py CHANGED
@@ -37,6 +37,7 @@ class Confluence(AtlassianRestAPI):
37
37
  @staticmethod
38
38
  def _create_body(body, representation):
39
39
  if representation not in [
40
+ "atlas_doc_format",
40
41
  "editor",
41
42
  "export_view",
42
43
  "view",
@@ -3067,10 +3068,8 @@ class Confluence(AtlassianRestAPI):
3067
3068
  :param group_name: str - name of group to add user to
3068
3069
  :return: Current state of the group
3069
3070
  """
3070
- url = "rest/api/2/group/user"
3071
- params = {"groupname": group_name}
3072
- data = {"name": username}
3073
- return self.post(url, params=params, data=data)
3071
+ url = f"rest/api/user/{username}/group/{group_name}"
3072
+ return self.put(url)
3074
3073
 
3075
3074
  def add_space_permissions(
3076
3075
  self,
atlassian/jira.py CHANGED
@@ -284,11 +284,11 @@ class Jira(AtlassianRestAPI):
284
284
  """
285
285
  Returns the content for an attachment
286
286
  :param attachment_id: int
287
- :return: json
287
+ :return: content as bytes
288
288
  """
289
289
  base_url = self.resource_url("attachment")
290
290
  url = "{base_url}/content/{attachment_id}".format(base_url=base_url, attachment_id=attachment_id)
291
- return self.get(url)
291
+ return self.get(url, not_json_response=True)
292
292
 
293
293
  def remove_attachment(self, attachment_id):
294
294
  """
atlassian/service_desk.py CHANGED
@@ -1,6 +1,8 @@
1
1
  # coding=utf-8
2
2
  import logging
3
3
 
4
+ from requests import HTTPError
5
+
4
6
  from .rest_client import AtlassianRestAPI
5
7
 
6
8
  log = logging.getLogger(__name__)
@@ -909,3 +911,22 @@ class ServiceDesk(AtlassianRestAPI):
909
911
 
910
912
  url = "rest/servicedeskapi/servicedesk/{}/requesttype".format(service_desk_id)
911
913
  return self.post(url, headers=self.experimental_headers, data=data)
914
+
915
+ def raise_for_status(self, response):
916
+ """
917
+ Checks the response for an error status and raises an exception with the error message provided by the server
918
+ :param response:
919
+ :return:
920
+ """
921
+ if response.status_code == 401 and response.headers.get("Content-Type") != "application/json;charset=UTF-8":
922
+ raise HTTPError("Unauthorized (401)", response=response)
923
+
924
+ if 400 <= response.status_code < 600:
925
+ try:
926
+ j = response.json()
927
+ error_msg = j["errorMessage"]
928
+ except Exception as e:
929
+ log.error(e)
930
+ response.raise_for_status()
931
+ else:
932
+ raise HTTPError(error_msg, response=response)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atlassian-python-api
3
- Version: 3.41.14
3
+ Version: 3.41.15
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
@@ -53,7 +53,7 @@ Requires-Dist: requests-oauthlib
53
53
  Requires-Dist: jmespath
54
54
  Requires-Dist: beautifulsoup4
55
55
  Provides-Extra: kerberos
56
- Requires-Dist: requests-kerberos ; extra == 'kerberos'
56
+ Requires-Dist: requests-kerberos; extra == "kerberos"
57
57
 
58
58
  ============================
59
59
  Atlassian Python API wrapper
@@ -1,22 +1,22 @@
1
- atlassian/VERSION,sha256=EZz2f1O1U9uaH788ZIwZcYwzjsOJf3L8eyPh4vdBftE,8
1
+ atlassian/VERSION,sha256=RJ_VCwbjh_nVAQg_AsjMCLcKveJAo0IYu_2kXj5_DIs,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=yT5w6jBgM8Q1Wvhoh_6JzwhvvGDIO3qZVKlMs12W86Q,122528
5
+ atlassian/confluence.py,sha256=0ngO1AuF67g8ng6Uy5wy53YF2PILFB2zcv8wi1jIBWM,122479
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=oOWYoIway05rNup5GPDRm3S5WYuDhHe7JJ-g3vNccsk,23798
9
- atlassian/jira.py,sha256=ckKljgN5dkcj4JALBAiWJy31VQLPyom0qCuNk2fB0CM,209745
9
+ atlassian/jira.py,sha256=27yY6cr-aPabG3vzDw6SczRxeSi5aJg3jR_zR7ZoASg,209781
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
13
  atlassian/rest_client.py,sha256=vmAqgNeU-pFQJy5Q6vQs9BEgPftoQdhvTcuMjJGeJbA,18685
14
- atlassian/service_desk.py,sha256=8pM37-aTD4fG8VyA84s9JBGPsKgT7OHUdf9x-GffutY,32632
14
+ atlassian/service_desk.py,sha256=VwKzAWYumm7GsHTNo8l6FlzxF5CNXmL_6Fg6rEnj67Y,33411
15
15
  atlassian/statuspage.py,sha256=M6Ryz4cpLrjqEiv-W6Uch4_OLjdxVILQpUojeAnYYdA,94470
16
16
  atlassian/utils.py,sha256=oKvkGflmgygUcTU-fKd0LBnovgBpu3e5uHsj0sng_vg,10955
17
17
  atlassian/xray.py,sha256=3OvLMNfTxfCXgKXxpjhq3a01RemOEtvJH9OqbCJrHEs,26219
18
- atlassian/bitbucket/__init__.py,sha256=tbWu7qASsV6JeIw9sWorg1z3Ij16Ks8ThXfpDK1X-o0,133929
19
- atlassian/bitbucket/base.py,sha256=KfzR9YsdF_zfvq6KOMFzbxNut36vQ2ZJcBmURYzF4N4,6303
18
+ atlassian/bitbucket/__init__.py,sha256=yamIoXHuCzsje6vDzpx3CHo_F4HHz2ik8dF4VZtgUJg,134792
19
+ atlassian/bitbucket/base.py,sha256=aZpA8J-iMWVahXLCUt-X2MmZ1nG20wCGD0ykKlZrEJ0,6447
20
20
  atlassian/bitbucket/cloud/__init__.py,sha256=MX58kb4PKRK5M_iLyh0pya0FG8c9cYJkCAEVsugiGok,821
21
21
  atlassian/bitbucket/cloud/base.py,sha256=K2v04dr3K22Wsx8w-fmPQym3vsSflOERYA_TtSMwr4c,4094
22
22
  atlassian/bitbucket/cloud/common/__init__.py,sha256=5r9gwfcmU-AwZXG4kjU_Jpj_R72MLXJXOn0otMYAg4c,39
@@ -47,8 +47,8 @@ atlassian/bitbucket/server/common/__init__.py,sha256=0j0CWKFaX1kDqfDQkf3__Y2p24t
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=GNWhabbnLG7kpgCS85wPzOxtbeCtySchCqFwFZnTdh4,10783
50
- atlassian_python_api-3.41.14.dist-info/LICENSE,sha256=xamAnoX0zfBamIilAfP3nSIt7dIvnj7oueX14l6uKPY,11335
51
- atlassian_python_api-3.41.14.dist-info/METADATA,sha256=0iFWNBA8NQgqwuyawKe0w6-R56z5iG9zpDzPav8hGiM,8792
52
- atlassian_python_api-3.41.14.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
53
- atlassian_python_api-3.41.14.dist-info/top_level.txt,sha256=84-EDv8LNaZx01TCGjBzglwPU1JSRJ7fPSq9uy55Sv0,10
54
- atlassian_python_api-3.41.14.dist-info/RECORD,,
50
+ atlassian_python_api-3.41.15.dist-info/LICENSE,sha256=xamAnoX0zfBamIilAfP3nSIt7dIvnj7oueX14l6uKPY,11335
51
+ atlassian_python_api-3.41.15.dist-info/METADATA,sha256=Br4Jq4tdigSGKdia0GRiQEEYiOEf05E57FU-V4r9I3k,8791
52
+ atlassian_python_api-3.41.15.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
53
+ atlassian_python_api-3.41.15.dist-info/top_level.txt,sha256=84-EDv8LNaZx01TCGjBzglwPU1JSRJ7fPSq9uy55Sv0,10
54
+ atlassian_python_api-3.41.15.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (74.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5