atlassian-python-api 3.41.13__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 -0
- atlassian/__init__.py +32 -0
- atlassian/bamboo.py +1343 -0
- atlassian/bitbucket/__init__.py +3572 -0
- atlassian/bitbucket/base.py +198 -0
- atlassian/bitbucket/cloud/__init__.py +24 -0
- atlassian/bitbucket/cloud/base.py +123 -0
- atlassian/bitbucket/cloud/common/__init__.py +1 -0
- atlassian/bitbucket/cloud/common/builds.py +85 -0
- atlassian/bitbucket/cloud/common/comments.py +50 -0
- atlassian/bitbucket/cloud/common/users.py +79 -0
- atlassian/bitbucket/cloud/repositories/__init__.py +437 -0
- atlassian/bitbucket/cloud/repositories/branchRestrictions.py +175 -0
- atlassian/bitbucket/cloud/repositories/commits.py +188 -0
- atlassian/bitbucket/cloud/repositories/defaultReviewers.py +94 -0
- atlassian/bitbucket/cloud/repositories/deploymentEnvironments.py +264 -0
- atlassian/bitbucket/cloud/repositories/diffstat.py +92 -0
- atlassian/bitbucket/cloud/repositories/groupPermissions.py +81 -0
- atlassian/bitbucket/cloud/repositories/hooks.py +117 -0
- atlassian/bitbucket/cloud/repositories/issues.py +164 -0
- atlassian/bitbucket/cloud/repositories/pipelines.py +274 -0
- atlassian/bitbucket/cloud/repositories/pullRequests.py +483 -0
- atlassian/bitbucket/cloud/repositories/refs.py +136 -0
- atlassian/bitbucket/cloud/repositories/repositoryVariables.py +146 -0
- atlassian/bitbucket/cloud/workspaces/__init__.py +146 -0
- atlassian/bitbucket/cloud/workspaces/members.py +62 -0
- atlassian/bitbucket/cloud/workspaces/permissions.py +125 -0
- atlassian/bitbucket/cloud/workspaces/projects.py +215 -0
- atlassian/bitbucket/server/__init__.py +46 -0
- atlassian/bitbucket/server/base.py +63 -0
- atlassian/bitbucket/server/common/__init__.py +1 -0
- atlassian/bitbucket/server/common/permissions.py +220 -0
- atlassian/bitbucket/server/globalPermissions.py +198 -0
- atlassian/bitbucket/server/projects/__init__.py +244 -0
- atlassian/bitbucket/server/projects/repos/__init__.py +327 -0
- atlassian/cloud_admin.py +32 -0
- atlassian/confluence.py +3336 -0
- atlassian/crowd.py +266 -0
- atlassian/errors.py +27 -0
- atlassian/insight.py +678 -0
- atlassian/jira.py +5324 -0
- atlassian/marketplace.py +84 -0
- atlassian/portfolio.py +108 -0
- atlassian/request_utils.py +39 -0
- atlassian/rest_client.py +558 -0
- atlassian/service_desk.py +911 -0
- atlassian/statuspage.py +3133 -0
- atlassian/utils.py +327 -0
- atlassian/xray.py +632 -0
- atlassian_python_api-3.41.13.dist-info/LICENSE +201 -0
- atlassian_python_api-3.41.13.dist-info/METADATA +261 -0
- atlassian_python_api-3.41.13.dist-info/RECORD +54 -0
- atlassian_python_api-3.41.13.dist-info/WHEEL +5 -0
- atlassian_python_api-3.41.13.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
import copy
|
|
4
|
+
import re
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
from pprint import PrettyPrinter
|
|
9
|
+
from ..rest_client import AtlassianRestAPI
|
|
10
|
+
|
|
11
|
+
RE_TIMEZONE = re.compile(r"(\d{2}):(\d{2})$")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class BitbucketBase(AtlassianRestAPI):
|
|
15
|
+
CONF_TIMEFORMAT = "%Y-%m-%dT%H:%M:%S.%f%z"
|
|
16
|
+
bulk_headers = {"Content-Type": "application/vnd.atl.bitbucket.bulk+json"}
|
|
17
|
+
|
|
18
|
+
def __init__(self, url, *args, **kwargs):
|
|
19
|
+
"""
|
|
20
|
+
Init the rest api wrapper
|
|
21
|
+
|
|
22
|
+
:param url: string: The base url used for the rest api.
|
|
23
|
+
:param *args: list: The fixed arguments for the AtlassianRestApi.
|
|
24
|
+
:param **kwargs: dict: The keyword arguments for the AtlassianRestApi.
|
|
25
|
+
|
|
26
|
+
:return: nothing
|
|
27
|
+
"""
|
|
28
|
+
self._update_data(kwargs.pop("data", {}))
|
|
29
|
+
if url is None:
|
|
30
|
+
url = self.get_link("self")
|
|
31
|
+
if isinstance(url, list): # Server has a list of links
|
|
32
|
+
url = url[0]
|
|
33
|
+
self.timeformat_lambda = kwargs.pop("timeformat_lambda", lambda x: self._default_timeformat_lambda(x))
|
|
34
|
+
self._check_timeformat_lambda()
|
|
35
|
+
super(BitbucketBase, self).__init__(url, *args, **kwargs)
|
|
36
|
+
|
|
37
|
+
def __str__(self):
|
|
38
|
+
return PrettyPrinter(indent=4).pformat(self.__data if self.__data else self)
|
|
39
|
+
|
|
40
|
+
def _get_paged(
|
|
41
|
+
self,
|
|
42
|
+
url,
|
|
43
|
+
params=None,
|
|
44
|
+
data=None,
|
|
45
|
+
flags=None,
|
|
46
|
+
trailing=None,
|
|
47
|
+
absolute=False,
|
|
48
|
+
):
|
|
49
|
+
"""
|
|
50
|
+
Used to get the paged data
|
|
51
|
+
|
|
52
|
+
:param url: string: The url to retrieve
|
|
53
|
+
:param params: dict (default is None): The parameter's
|
|
54
|
+
:param data: dict (default is None): The data
|
|
55
|
+
:param flags: string[] (default is None): The flags
|
|
56
|
+
:param trailing: bool (default is None): If True, a trailing slash is added to the url
|
|
57
|
+
:param absolute: bool (default is False): If True, the url is used absolute and not relative to the root
|
|
58
|
+
|
|
59
|
+
:return: A generator object for the data elements
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
if params is None:
|
|
63
|
+
params = {}
|
|
64
|
+
|
|
65
|
+
while True:
|
|
66
|
+
response = self.get(
|
|
67
|
+
url,
|
|
68
|
+
trailing=trailing,
|
|
69
|
+
params=params,
|
|
70
|
+
data=data,
|
|
71
|
+
flags=flags,
|
|
72
|
+
absolute=absolute,
|
|
73
|
+
)
|
|
74
|
+
if "values" not in response:
|
|
75
|
+
return
|
|
76
|
+
|
|
77
|
+
for value in response.get("values", []):
|
|
78
|
+
yield value
|
|
79
|
+
|
|
80
|
+
if self.cloud:
|
|
81
|
+
url = response.get("next")
|
|
82
|
+
if url is None:
|
|
83
|
+
break
|
|
84
|
+
# From now on we have absolute URLs with parameters
|
|
85
|
+
absolute = True
|
|
86
|
+
# Params are now provided by the url
|
|
87
|
+
params = {}
|
|
88
|
+
# Trailing should not be added as it is already part of the url
|
|
89
|
+
trailing = False
|
|
90
|
+
else:
|
|
91
|
+
if response.get("nextPageStart") is None:
|
|
92
|
+
break
|
|
93
|
+
params["start"] = response.get("nextPageStart")
|
|
94
|
+
|
|
95
|
+
return
|
|
96
|
+
|
|
97
|
+
@staticmethod
|
|
98
|
+
def _default_timeformat_lambda(timestamp):
|
|
99
|
+
"""
|
|
100
|
+
Default time format function.
|
|
101
|
+
|
|
102
|
+
:param timestamp: datetime str: The datetime object of the parsed string or the raw value if parsing failed
|
|
103
|
+
|
|
104
|
+
:return: timestamp if it was a datetime object, else None
|
|
105
|
+
"""
|
|
106
|
+
return timestamp if isinstance(timestamp, datetime) else None
|
|
107
|
+
|
|
108
|
+
def _check_timeformat_lambda(self):
|
|
109
|
+
"""
|
|
110
|
+
Check the lambda for the time format. Raise an exception if the value is wrong
|
|
111
|
+
"""
|
|
112
|
+
LAMBDA = lambda: 0 # noqa: E731
|
|
113
|
+
if self.timeformat_lambda is None or (
|
|
114
|
+
isinstance(self.timeformat_lambda, type(LAMBDA)) and self.timeformat_lambda.__name__ == LAMBDA.__name__
|
|
115
|
+
):
|
|
116
|
+
return True
|
|
117
|
+
else:
|
|
118
|
+
ValueError("Expected [None] or [lambda function] for argument [timeformat_func]")
|
|
119
|
+
|
|
120
|
+
def _sub_url(self, url):
|
|
121
|
+
"""
|
|
122
|
+
Get the full url from a relative one.
|
|
123
|
+
|
|
124
|
+
:param url: string: The sub url
|
|
125
|
+
|
|
126
|
+
:return: The absolute url
|
|
127
|
+
"""
|
|
128
|
+
return self.url_joiner(self.url, url)
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def data(self):
|
|
132
|
+
"""
|
|
133
|
+
Get the internal cached data. For data integrity a deep copy is returned.
|
|
134
|
+
|
|
135
|
+
:return: A copy of the data cache
|
|
136
|
+
"""
|
|
137
|
+
return copy.copy(self.__data)
|
|
138
|
+
|
|
139
|
+
def get_data(self, id, default=None):
|
|
140
|
+
"""
|
|
141
|
+
Get a data element from the internal data cache. For data integrity a deep copy is returned.
|
|
142
|
+
If data isn't present, the default value is returned.
|
|
143
|
+
|
|
144
|
+
:param id: string: The data element to return
|
|
145
|
+
:param default: any (default is None): The value to return if id is not present
|
|
146
|
+
|
|
147
|
+
:return: The requested data element
|
|
148
|
+
"""
|
|
149
|
+
return copy.copy(self.__data[id]) if id in self.__data else default
|
|
150
|
+
|
|
151
|
+
def get_time(self, id):
|
|
152
|
+
"""
|
|
153
|
+
Return the time value with the expected format.
|
|
154
|
+
|
|
155
|
+
:param id: string: The id for the time data
|
|
156
|
+
|
|
157
|
+
:return: The time with the configured format, see timeformat_lambda.
|
|
158
|
+
"""
|
|
159
|
+
value_str = self.get_data(id)
|
|
160
|
+
if self.timeformat_lambda is None:
|
|
161
|
+
return value_str
|
|
162
|
+
|
|
163
|
+
if isinstance(value_str, str):
|
|
164
|
+
# The format contains a : in the timezone which is supported from 3.7 on.
|
|
165
|
+
if sys.version_info <= (3, 7):
|
|
166
|
+
value_str = RE_TIMEZONE.sub(r"\1\2", value_str)
|
|
167
|
+
value = datetime.strptime(value_str, self.CONF_TIMEFORMAT)
|
|
168
|
+
else:
|
|
169
|
+
value = value_str
|
|
170
|
+
|
|
171
|
+
return self.timeformat_lambda(value)
|
|
172
|
+
|
|
173
|
+
def _update_data(self, data):
|
|
174
|
+
"""
|
|
175
|
+
Internal function to update the data.
|
|
176
|
+
|
|
177
|
+
:param data: dict: The new data.
|
|
178
|
+
|
|
179
|
+
:return: The updated object
|
|
180
|
+
"""
|
|
181
|
+
self.__data = data
|
|
182
|
+
|
|
183
|
+
return self
|
|
184
|
+
|
|
185
|
+
@property
|
|
186
|
+
def _new_session_args(self):
|
|
187
|
+
"""
|
|
188
|
+
Get the kwargs for new objects (session, root, version,...).
|
|
189
|
+
|
|
190
|
+
:return: A dict with the kwargs for new objects
|
|
191
|
+
"""
|
|
192
|
+
return dict(
|
|
193
|
+
session=self._session,
|
|
194
|
+
cloud=self.cloud,
|
|
195
|
+
api_root=self.api_root,
|
|
196
|
+
api_version=self.api_version,
|
|
197
|
+
timeformat_lambda=self.timeformat_lambda,
|
|
198
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
from .base import BitbucketCloudBase
|
|
4
|
+
from .workspaces import Workspaces
|
|
5
|
+
from .repositories import Repositories
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Cloud(BitbucketCloudBase):
|
|
9
|
+
def __init__(self, url="https://api.bitbucket.org/", *args, **kwargs):
|
|
10
|
+
kwargs["cloud"] = True
|
|
11
|
+
kwargs["api_root"] = None
|
|
12
|
+
kwargs["api_version"] = "2.0"
|
|
13
|
+
url = url.strip("/") + "/{}".format(kwargs["api_version"])
|
|
14
|
+
super(Cloud, self).__init__(url, *args, **kwargs)
|
|
15
|
+
self.__workspaces = Workspaces("{}/workspaces".format(self.url), **self._new_session_args)
|
|
16
|
+
self.__repositories = Repositories("{}/repositories".format(self.url), **self._new_session_args)
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def workspaces(self):
|
|
20
|
+
return self.__workspaces
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def repositories(self):
|
|
24
|
+
return self.__repositories
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from ..base import BitbucketBase
|
|
5
|
+
|
|
6
|
+
from requests import HTTPError
|
|
7
|
+
|
|
8
|
+
log = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BitbucketCloudBase(BitbucketBase):
|
|
12
|
+
def __init__(self, url, *args, **kwargs):
|
|
13
|
+
"""
|
|
14
|
+
Init the rest api wrapper
|
|
15
|
+
|
|
16
|
+
:param url: string: The base url used for the rest api.
|
|
17
|
+
:param *args: list: The fixed arguments for the AtlassianRestApi.
|
|
18
|
+
:param **kwargs: dict: The keyword arguments for the AtlassianRestApi.
|
|
19
|
+
|
|
20
|
+
:return: nothing
|
|
21
|
+
"""
|
|
22
|
+
expected_type = kwargs.pop("expected_type", None)
|
|
23
|
+
super(BitbucketCloudBase, self).__init__(url, *args, **kwargs)
|
|
24
|
+
if expected_type is not None and not expected_type == self.get_data("type"):
|
|
25
|
+
raise ValueError("Expected type of data is [{}], got [{}].".format(expected_type, self.get_data("type")))
|
|
26
|
+
|
|
27
|
+
def get_link(self, link):
|
|
28
|
+
"""
|
|
29
|
+
Get a link from the data.
|
|
30
|
+
|
|
31
|
+
:param link: string: The link identifier
|
|
32
|
+
|
|
33
|
+
:return: The requested link or None if it isn't present
|
|
34
|
+
"""
|
|
35
|
+
links = self.get_data("links")
|
|
36
|
+
if links is None or link not in links:
|
|
37
|
+
return None
|
|
38
|
+
return links[link]["href"]
|
|
39
|
+
|
|
40
|
+
def _get_paged(
|
|
41
|
+
self,
|
|
42
|
+
url,
|
|
43
|
+
params=None,
|
|
44
|
+
data=None,
|
|
45
|
+
flags=None,
|
|
46
|
+
trailing=None,
|
|
47
|
+
absolute=False,
|
|
48
|
+
paging_workaround=False,
|
|
49
|
+
):
|
|
50
|
+
"""
|
|
51
|
+
Used to get the paged data
|
|
52
|
+
|
|
53
|
+
:param url: string: The url to retrieve
|
|
54
|
+
:param params: dict (default is None): The parameter's
|
|
55
|
+
:param data: dict (default is None): The data
|
|
56
|
+
:param flags: string[] (default is None): The flags
|
|
57
|
+
:param trailing: bool (default is None): If True, a trailing slash is added to the url
|
|
58
|
+
:param absolute: bool (default is False): If True, the url is used absolute and not relative to the root
|
|
59
|
+
:param paging_workaround: bool (default is False): If True, the paging is done on our own because
|
|
60
|
+
of https://jira.atlassian.com/browse/BCLOUD-13806
|
|
61
|
+
|
|
62
|
+
:return: A generator object for the data elements
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
if params is None:
|
|
66
|
+
params = {}
|
|
67
|
+
if paging_workaround:
|
|
68
|
+
params["page"] = 1
|
|
69
|
+
|
|
70
|
+
while True:
|
|
71
|
+
response = super(BitbucketCloudBase, self).get(
|
|
72
|
+
url,
|
|
73
|
+
trailing=trailing,
|
|
74
|
+
params=params,
|
|
75
|
+
data=data,
|
|
76
|
+
flags=flags,
|
|
77
|
+
absolute=absolute,
|
|
78
|
+
)
|
|
79
|
+
if len(response.get("values", [])) == 0:
|
|
80
|
+
return
|
|
81
|
+
|
|
82
|
+
for value in response["values"]:
|
|
83
|
+
yield value
|
|
84
|
+
|
|
85
|
+
if paging_workaround:
|
|
86
|
+
params["page"] += 1
|
|
87
|
+
else:
|
|
88
|
+
url = response.get("next")
|
|
89
|
+
if url is None:
|
|
90
|
+
break
|
|
91
|
+
# From now on we have absolute URLs with parameters
|
|
92
|
+
absolute = True
|
|
93
|
+
# Params are now provided by the url
|
|
94
|
+
params = {}
|
|
95
|
+
# Trailing should not be added as it is already part of the url
|
|
96
|
+
trailing = False
|
|
97
|
+
|
|
98
|
+
return
|
|
99
|
+
|
|
100
|
+
def raise_for_status(self, response):
|
|
101
|
+
"""
|
|
102
|
+
Checks the response for errors and throws an exception if return code >= 400
|
|
103
|
+
|
|
104
|
+
Implementation for Bitbucket Cloud according to
|
|
105
|
+
https://developer.atlassian.com/cloud/bitbucket/rest/intro/#standardized-error-responses
|
|
106
|
+
|
|
107
|
+
:param response:
|
|
108
|
+
:return:
|
|
109
|
+
"""
|
|
110
|
+
if 400 <= response.status_code < 600:
|
|
111
|
+
try:
|
|
112
|
+
j = response.json()
|
|
113
|
+
e = j["error"]
|
|
114
|
+
error_msg = e["message"]
|
|
115
|
+
if e.get("detail"):
|
|
116
|
+
error_msg += "\n" + e["detail"]
|
|
117
|
+
except Exception as e:
|
|
118
|
+
log.error(e)
|
|
119
|
+
response.raise_for_status()
|
|
120
|
+
else:
|
|
121
|
+
raise HTTPError(error_msg, response=response)
|
|
122
|
+
else:
|
|
123
|
+
response.raise_for_status()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
""" Bitbucket Cloud common package """
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from ..base import BitbucketCloudBase
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Build(BitbucketCloudBase):
|
|
5
|
+
STATE_FAILED = "FAILED"
|
|
6
|
+
STATE_INPROGRESS = "INPROGRESS"
|
|
7
|
+
STATE_STOPPED = "STOPPED"
|
|
8
|
+
STATE_SUCCESSFUL = "SUCCESSFUL"
|
|
9
|
+
|
|
10
|
+
def __init__(self, data, *args, **kwargs):
|
|
11
|
+
super(Build, self).__init__(None, None, *args, data=data, expected_type="build", **kwargs)
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def key(self):
|
|
15
|
+
"""Key of the build."""
|
|
16
|
+
return self.get_data("key")
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def name(self):
|
|
20
|
+
"""Name of the build."""
|
|
21
|
+
return self.get_data("name")
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def description(self):
|
|
25
|
+
"""Build description."""
|
|
26
|
+
return self.get_data("description")
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def failed(self):
|
|
30
|
+
"""True if the build failed."""
|
|
31
|
+
return self.get_data("state") == self.STATE_FAILED
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def inprogress(self):
|
|
35
|
+
"""True if the build is in progress."""
|
|
36
|
+
return self.get_data("state") == self.STATE_INPROGRESS
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def successful(self):
|
|
40
|
+
"""True if the build was successful."""
|
|
41
|
+
return self.get_data("state") == self.STATE_SUCCESSFUL
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def stopped(self):
|
|
45
|
+
"""True if the build was stopped."""
|
|
46
|
+
return self.get_data("state") == self.STATE_STOPPED
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def created_on(self):
|
|
50
|
+
"""Time of creation."""
|
|
51
|
+
return self.get_time("created_on")
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def updated_on(self):
|
|
55
|
+
"""Time of last update."""
|
|
56
|
+
return self.get_time("updated_on")
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def commit(self):
|
|
60
|
+
"""Return the hash key of the commit."""
|
|
61
|
+
return self.get_data("commit")["hash"]
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def website(self):
|
|
65
|
+
"""
|
|
66
|
+
Return the url to the build's webpage.
|
|
67
|
+
This url points to the build's frontend website (Pipelines, Jenkins ...)
|
|
68
|
+
"""
|
|
69
|
+
return self.get_data("url")
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def refname(self):
|
|
73
|
+
"""Return the refname.
|
|
74
|
+
|
|
75
|
+
This can be used to indicate on which branch/tag the
|
|
76
|
+
build happened.
|
|
77
|
+
"""
|
|
78
|
+
return self.get_data("refname")
|
|
79
|
+
|
|
80
|
+
def update(self, **kwargs):
|
|
81
|
+
"""Update build status.
|
|
82
|
+
|
|
83
|
+
See https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-key-put
|
|
84
|
+
"""
|
|
85
|
+
return self._update_data(self.put(None, data=kwargs))
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from ..base import BitbucketCloudBase
|
|
2
|
+
from ..common.users import User
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Comment(BitbucketCloudBase):
|
|
6
|
+
def __init__(self, data, *args, **kwargs):
|
|
7
|
+
super(Comment, self).__init__(
|
|
8
|
+
None,
|
|
9
|
+
None,
|
|
10
|
+
*args,
|
|
11
|
+
data=data,
|
|
12
|
+
expected_type="pullrequest_comment",
|
|
13
|
+
**kwargs
|
|
14
|
+
) # fmt: skip
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def raw(self):
|
|
18
|
+
"""The raw comment."""
|
|
19
|
+
return self.get_data("content")["raw"]
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def html(self):
|
|
23
|
+
"""The html comment."""
|
|
24
|
+
return self.get_data("content")["html"]
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def markup(self):
|
|
28
|
+
"""The markup type."""
|
|
29
|
+
return self.get_data("content")["markup"]
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def user(self):
|
|
33
|
+
"""User object with user information of the comment."""
|
|
34
|
+
return User(None, self.get_data("user"), **self._new_session_args)
|
|
35
|
+
|
|
36
|
+
def update(self, **kwargs):
|
|
37
|
+
"""Update the comment properties. Fields not present in the request body are ignored.
|
|
38
|
+
|
|
39
|
+
:param kwargs: dict: The data to update.
|
|
40
|
+
|
|
41
|
+
:return: The updated comment
|
|
42
|
+
"""
|
|
43
|
+
return self._update_data(self.put(None, data=kwargs))
|
|
44
|
+
|
|
45
|
+
def delete(self):
|
|
46
|
+
"""Delete the comment.
|
|
47
|
+
|
|
48
|
+
:return: The response on success
|
|
49
|
+
"""
|
|
50
|
+
return super(Comment, self).delete(None)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from ..base import BitbucketCloudBase
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class User(BitbucketCloudBase):
|
|
5
|
+
def __init__(self, url, data, *args, **kwargs):
|
|
6
|
+
super(User, self).__init__(url, *args, data=data, expected_type="user", **kwargs)
|
|
7
|
+
|
|
8
|
+
@property
|
|
9
|
+
def display_name(self):
|
|
10
|
+
"""Display name used by Bitbucket Cloud"""
|
|
11
|
+
return str(self.get_data("display_name"))
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def nickname(self):
|
|
15
|
+
"""Username used by Bitbucket Cloud"""
|
|
16
|
+
return self.get_data("nickname")
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def account_id(self):
|
|
20
|
+
"""Account id used by Bitbucket Cloud"""
|
|
21
|
+
return self.get_data("account_id")
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def uuid(self):
|
|
25
|
+
"""User id used by Bitbucket Cloud"""
|
|
26
|
+
return self.get_data("uuid")
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def avatar(self):
|
|
30
|
+
"""URL to user avatar on Bitbucket Cloud"""
|
|
31
|
+
return self.get_data("links")["avatar"]["href"]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class Participant(BitbucketCloudBase):
|
|
35
|
+
ROLE_REVIEWER = "REVIEWER"
|
|
36
|
+
ROLE_PARTICIPANT = "PARTICIPANT"
|
|
37
|
+
CHANGES_REQUESTED = "changes_requested"
|
|
38
|
+
|
|
39
|
+
def __init__(self, data, *args, **kwargs):
|
|
40
|
+
super(Participant, self).__init__(None, None, *args, data=data, expected_type="participant", **kwargs)
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def user(self):
|
|
44
|
+
"""User object with user information of the participant."""
|
|
45
|
+
return User(None, self.get_data("user"), **self._new_session_args)
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def is_participant(self):
|
|
49
|
+
"""True if the user is a pull request participant."""
|
|
50
|
+
return self.get_data("role") == self.ROLE_PARTICIPANT
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def is_reviewer(self):
|
|
54
|
+
"""True if the user is a pull request reviewer."""
|
|
55
|
+
return self.get_data("role") == self.ROLE_REVIEWER
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def is_default_reviewer(self):
|
|
59
|
+
"""True if the user is a default reviewer."""
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def has_changes_requested(self):
|
|
63
|
+
"""True if user requested changes."""
|
|
64
|
+
return str(self.get_data("state")) == self.CHANGES_REQUESTED
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def has_approved(self):
|
|
68
|
+
"""True if user approved the pull request."""
|
|
69
|
+
return self.get_data("approved")
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def participated_on(self):
|
|
73
|
+
"""Time of last participation."""
|
|
74
|
+
return self.get_time("participated_on")
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def avatar(self):
|
|
78
|
+
"""URL to user avatar on Bitbucket Cloud"""
|
|
79
|
+
return self.get_data("links")["avatar"]["href"]
|