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,81 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
from ..base import BitbucketCloudBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class GroupPermissions(BitbucketCloudBase):
|
|
7
|
+
def __init__(self, url, *args, **kwargs):
|
|
8
|
+
super(GroupPermissions, self).__init__(url, *args, **kwargs)
|
|
9
|
+
|
|
10
|
+
def __get_object(self, data):
|
|
11
|
+
return GroupPermission(
|
|
12
|
+
self.url,
|
|
13
|
+
data,
|
|
14
|
+
**self._new_session_args
|
|
15
|
+
) # fmt: skip
|
|
16
|
+
|
|
17
|
+
def each(self, q=None, sort=None):
|
|
18
|
+
"""
|
|
19
|
+
Returns the list of group permissions in this repository.
|
|
20
|
+
|
|
21
|
+
:param q: string: Query string to narrow down the response.
|
|
22
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
23
|
+
:param sort: string: Name of a response property to sort results.
|
|
24
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
25
|
+
|
|
26
|
+
:return: A generator for the GroupPermission objects
|
|
27
|
+
|
|
28
|
+
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-permissions-config-groups-get
|
|
29
|
+
"""
|
|
30
|
+
params = {}
|
|
31
|
+
if sort is not None:
|
|
32
|
+
params["sort"] = sort
|
|
33
|
+
if q is not None:
|
|
34
|
+
params["q"] = q
|
|
35
|
+
for group_permission in self._get_paged(
|
|
36
|
+
None,
|
|
37
|
+
trailing=True,
|
|
38
|
+
params=params,
|
|
39
|
+
):
|
|
40
|
+
yield self.__get_object(group_permission)
|
|
41
|
+
|
|
42
|
+
return
|
|
43
|
+
|
|
44
|
+
def get(self, group_slug):
|
|
45
|
+
"""
|
|
46
|
+
Returns the group permission with the group slug in this repository.
|
|
47
|
+
|
|
48
|
+
:param group_slug: string: The requested permission group_slug
|
|
49
|
+
|
|
50
|
+
:return: The requested GroupPermission objects
|
|
51
|
+
|
|
52
|
+
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-permissions-config-groups-group-slug-get
|
|
53
|
+
"""
|
|
54
|
+
return self.__get_object(super(GroupPermissions, self).get(group_slug))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class GroupPermission(BitbucketCloudBase):
|
|
58
|
+
def __init__(self, url, data, *args, **kwargs):
|
|
59
|
+
super(GroupPermission, self).__init__(
|
|
60
|
+
url, *args, data=data, expected_type="repository_group_permission", **kwargs
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def type(self):
|
|
65
|
+
"""The repository variable type"""
|
|
66
|
+
return self.get_data("type")
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def permission(self):
|
|
70
|
+
"""The repository variable permission"""
|
|
71
|
+
return self.get_data("permission")
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def group(self):
|
|
75
|
+
"""The repository variable group"""
|
|
76
|
+
return self.get_data("group")
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def links(self):
|
|
80
|
+
"""The repository variable links"""
|
|
81
|
+
return self.get_data("links")
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
from ..base import BitbucketCloudBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Hooks(BitbucketCloudBase):
|
|
7
|
+
"""Bitbucket Cloud webhooks."""
|
|
8
|
+
|
|
9
|
+
def __init__(self, url, *args, **kwargs):
|
|
10
|
+
super(Hooks, self).__init__(url, *args, **kwargs)
|
|
11
|
+
|
|
12
|
+
def __get_object(self, data):
|
|
13
|
+
return Hook(data, **self._new_session_args)
|
|
14
|
+
|
|
15
|
+
def create(
|
|
16
|
+
self,
|
|
17
|
+
url,
|
|
18
|
+
description,
|
|
19
|
+
events,
|
|
20
|
+
active=True,
|
|
21
|
+
):
|
|
22
|
+
"""
|
|
23
|
+
Creates a new webhook for the current repository
|
|
24
|
+
|
|
25
|
+
param: url: string: Url that will receive event requests
|
|
26
|
+
param: description: string: Details about the webhook
|
|
27
|
+
param: events: [string] List of event types that requests will generate for
|
|
28
|
+
param: active: boolean: Enables/Disables the webhook
|
|
29
|
+
|
|
30
|
+
:return: Hook Object
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
data = {"url": url, "description": description, "active": active, "events": events}
|
|
34
|
+
|
|
35
|
+
return self.__get_object(self.post(None, data))
|
|
36
|
+
|
|
37
|
+
def each(self):
|
|
38
|
+
"""
|
|
39
|
+
Return the list of webhooks in this repository.
|
|
40
|
+
|
|
41
|
+
:return: A generator for the Webhook objects
|
|
42
|
+
"""
|
|
43
|
+
for hook in self._get_paged(None):
|
|
44
|
+
yield self.__get_object(hook)
|
|
45
|
+
|
|
46
|
+
def get(self, id):
|
|
47
|
+
"""
|
|
48
|
+
Return the hook with the requested hook uuid in this repository.
|
|
49
|
+
|
|
50
|
+
:param id: string: The id of the webhook
|
|
51
|
+
|
|
52
|
+
:return: The requested hook object
|
|
53
|
+
"""
|
|
54
|
+
return self.__get_object(
|
|
55
|
+
super(Hooks, self).get(
|
|
56
|
+
self.url_joiner(self.get_link("hooks"), id),
|
|
57
|
+
absolute=True,
|
|
58
|
+
)
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Hook(BitbucketCloudBase):
|
|
63
|
+
"""
|
|
64
|
+
Bitbucket Cloud hook endpoint.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
def __init__(self, data, *args, **kwargs):
|
|
68
|
+
super(Hook, self).__init__(None, *args, data=data, expected_type="webhook_subscription", **kwargs)
|
|
69
|
+
|
|
70
|
+
def uuid(self):
|
|
71
|
+
"""hook uuid."""
|
|
72
|
+
return self.get_data("uuid")
|
|
73
|
+
|
|
74
|
+
def webhook_url(self):
|
|
75
|
+
"""webhook url."""
|
|
76
|
+
return self.get_data("url")
|
|
77
|
+
|
|
78
|
+
def description(self):
|
|
79
|
+
"""webhook description."""
|
|
80
|
+
return self.get_data("description")
|
|
81
|
+
|
|
82
|
+
def active(self):
|
|
83
|
+
"""is webhook active?"""
|
|
84
|
+
return self.get_data("active")
|
|
85
|
+
|
|
86
|
+
def events(self):
|
|
87
|
+
"""events that the webhook is triggered by"""
|
|
88
|
+
return self.get_data("events")
|
|
89
|
+
|
|
90
|
+
def update(self, **kwargs):
|
|
91
|
+
"""
|
|
92
|
+
Update a webhook
|
|
93
|
+
|
|
94
|
+
Valid keywords:
|
|
95
|
+
param: url: string: Url that will receive event requests
|
|
96
|
+
param: description: string: Details about the webhook
|
|
97
|
+
param: events: [string] List of event types that requests will generate for
|
|
98
|
+
param: active: boolean: Enables/Disables the webhook
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
payload = {
|
|
102
|
+
"url": self.webhook_url(),
|
|
103
|
+
"description": self.description(),
|
|
104
|
+
"events": self.events(),
|
|
105
|
+
"active": self.active(),
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
for key in payload.keys() and kwargs.keys():
|
|
109
|
+
payload[key] = kwargs[key]
|
|
110
|
+
|
|
111
|
+
return self._update_data(self.put(None, data=payload))
|
|
112
|
+
|
|
113
|
+
def delete(self):
|
|
114
|
+
"""
|
|
115
|
+
Delete the webhook.
|
|
116
|
+
"""
|
|
117
|
+
return super(Hook, self).delete(None)
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
from ..base import BitbucketCloudBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Issues(BitbucketCloudBase):
|
|
7
|
+
def __init__(self, url, *args, **kwargs):
|
|
8
|
+
super(Issues, self).__init__(url, *args, **kwargs)
|
|
9
|
+
|
|
10
|
+
def __get_object(self, data):
|
|
11
|
+
return Issue(data, **self._new_session_args)
|
|
12
|
+
|
|
13
|
+
def create(self, title, description, kind, priority):
|
|
14
|
+
"""
|
|
15
|
+
Create a new issue in the issue tracker of the given repository.
|
|
16
|
+
|
|
17
|
+
:param title: string: The title of the issue
|
|
18
|
+
:param description: string: The description of the issue
|
|
19
|
+
:param kind: string: One of: bug, enhancement, proposal, task
|
|
20
|
+
:param priority: string: One of: trivial, minor, major, critical, blocker
|
|
21
|
+
|
|
22
|
+
:return: The created Issue object
|
|
23
|
+
|
|
24
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/issues/%7Bissue_id%7D#put
|
|
25
|
+
"""
|
|
26
|
+
data = {
|
|
27
|
+
"title": title,
|
|
28
|
+
"kind": kind,
|
|
29
|
+
"priority": priority,
|
|
30
|
+
"content": {"raw": description},
|
|
31
|
+
}
|
|
32
|
+
return self.__get_object(self.post(None, data=data))
|
|
33
|
+
|
|
34
|
+
def each(self, q=None, sort=None):
|
|
35
|
+
"""
|
|
36
|
+
Returns the list of issues in this repository.
|
|
37
|
+
|
|
38
|
+
:param q: string: Query string to narrow down the response.
|
|
39
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
40
|
+
:param sort: string: Name of a response property to sort results.
|
|
41
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
42
|
+
|
|
43
|
+
:return: A generator for the Issue objects
|
|
44
|
+
|
|
45
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/issues#get
|
|
46
|
+
"""
|
|
47
|
+
params = {}
|
|
48
|
+
if sort is not None:
|
|
49
|
+
params["sort"] = sort
|
|
50
|
+
if q is not None:
|
|
51
|
+
params["q"] = q
|
|
52
|
+
for issue in self._get_paged(None, params=params):
|
|
53
|
+
yield self.__get_object(issue)
|
|
54
|
+
|
|
55
|
+
return
|
|
56
|
+
|
|
57
|
+
def get(self, id):
|
|
58
|
+
"""
|
|
59
|
+
Returns the issue with the ID in this repository.
|
|
60
|
+
|
|
61
|
+
:param id: string: The requested issue ID
|
|
62
|
+
|
|
63
|
+
:return: The requested Issue objects
|
|
64
|
+
|
|
65
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/issues/%7Bissue_id%7D#get
|
|
66
|
+
"""
|
|
67
|
+
return self.__get_object(super(Issues, self).get(id))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class Issue(BitbucketCloudBase):
|
|
71
|
+
def __init__(self, data, *args, **kwargs):
|
|
72
|
+
super(Issue, self).__init__(None, *args, data=data, expected_type="issue", **kwargs)
|
|
73
|
+
|
|
74
|
+
def update(self, **kwargs):
|
|
75
|
+
"""
|
|
76
|
+
Update the issue properties. Fields not present in the request body are ignored.
|
|
77
|
+
|
|
78
|
+
:param kwargs: dict: The data to update.
|
|
79
|
+
|
|
80
|
+
:return: The updated issue
|
|
81
|
+
|
|
82
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/issues/%7Bissue_id%7D#put
|
|
83
|
+
"""
|
|
84
|
+
return self._update_data(self.put(None, data=kwargs))
|
|
85
|
+
|
|
86
|
+
def delete(self):
|
|
87
|
+
"""
|
|
88
|
+
Delete the issue.
|
|
89
|
+
|
|
90
|
+
:return: The response on success
|
|
91
|
+
|
|
92
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/issues/%7Bissue_id%7D#delete
|
|
93
|
+
"""
|
|
94
|
+
return super(Issue, self).delete(None)
|
|
95
|
+
|
|
96
|
+
@property
|
|
97
|
+
def id(self):
|
|
98
|
+
"""The issue id"""
|
|
99
|
+
return self.get_data("id")
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def title(self):
|
|
103
|
+
"""The issue title"""
|
|
104
|
+
return self.get_data("title")
|
|
105
|
+
|
|
106
|
+
@title.setter
|
|
107
|
+
def title(self, title):
|
|
108
|
+
"""Setter for the issue title"""
|
|
109
|
+
return self.update(title=title)
|
|
110
|
+
|
|
111
|
+
@property
|
|
112
|
+
def state(self):
|
|
113
|
+
"""The issue state"""
|
|
114
|
+
return self.get_data("state")
|
|
115
|
+
|
|
116
|
+
@state.setter
|
|
117
|
+
def state(self, state):
|
|
118
|
+
"""Setter for the issue state"""
|
|
119
|
+
return self.update(state=state)
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
def kind(self):
|
|
123
|
+
"""The issue kind"""
|
|
124
|
+
return self.get_data("kind")
|
|
125
|
+
|
|
126
|
+
@kind.setter
|
|
127
|
+
def kind(self, kind):
|
|
128
|
+
"""Setter for the issue kind"""
|
|
129
|
+
return self.update(kind=kind)
|
|
130
|
+
|
|
131
|
+
@property
|
|
132
|
+
def priority(self):
|
|
133
|
+
"""The issue priority"""
|
|
134
|
+
return self.get_data("priority")
|
|
135
|
+
|
|
136
|
+
@priority.setter
|
|
137
|
+
def priority(self, priority):
|
|
138
|
+
"""Setter for the issue property"""
|
|
139
|
+
return self.update(priority=priority)
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def votes(self):
|
|
143
|
+
"""The issue votes"""
|
|
144
|
+
return self.get_data("votes")
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def content(self):
|
|
148
|
+
"""The issue content"""
|
|
149
|
+
return self.get_data("content")
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def created_on(self):
|
|
153
|
+
"""The issue creation time"""
|
|
154
|
+
return self.get_time("created_on")
|
|
155
|
+
|
|
156
|
+
@property
|
|
157
|
+
def edited_on(self):
|
|
158
|
+
"""The issue edit time"""
|
|
159
|
+
return self.get_time("edited_on")
|
|
160
|
+
|
|
161
|
+
@property
|
|
162
|
+
def updated_on(self):
|
|
163
|
+
"""The issue last update time"""
|
|
164
|
+
return self.get_time("updated_on")
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
from .pullRequests import PullRequest
|
|
4
|
+
from requests import HTTPError
|
|
5
|
+
|
|
6
|
+
from ..base import BitbucketCloudBase
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Pipelines(BitbucketCloudBase):
|
|
10
|
+
def __init__(self, url, *args, **kwargs):
|
|
11
|
+
super(Pipelines, self).__init__(url, *args, **kwargs)
|
|
12
|
+
|
|
13
|
+
def __get_object(self, data):
|
|
14
|
+
return Pipeline(
|
|
15
|
+
self.url_joiner(self.url, data["uuid"]),
|
|
16
|
+
data,
|
|
17
|
+
**self._new_session_args
|
|
18
|
+
) # fmt: skip
|
|
19
|
+
|
|
20
|
+
def trigger(self, branch="master", type="custom", commit=None, pattern=None, variables=None):
|
|
21
|
+
"""
|
|
22
|
+
Trigger a new pipeline. The following options are possible (1 and 2
|
|
23
|
+
trigger the pipeline that the branch is associated with in the Pipelines
|
|
24
|
+
configuration):
|
|
25
|
+
|
|
26
|
+
1. Latest revision of a branch (specify ``branch``)
|
|
27
|
+
2. Specific commit on a branch (additionally specify ``commit``)
|
|
28
|
+
3. Specific pipeline (additionally specify ``pattern``. ``commit`` is optional here)
|
|
29
|
+
|
|
30
|
+
Variables have to be a list of dictionaries:
|
|
31
|
+
|
|
32
|
+
{
|
|
33
|
+
"key": "var1key",
|
|
34
|
+
"value": "var1value",
|
|
35
|
+
"secured": true
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
:return: The initiated Pipeline object
|
|
39
|
+
|
|
40
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/#post
|
|
41
|
+
"""
|
|
42
|
+
data = {
|
|
43
|
+
"target": {
|
|
44
|
+
"ref_type": "branch",
|
|
45
|
+
"type": "pipeline_ref_target",
|
|
46
|
+
"ref_name": branch,
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
if commit is not None:
|
|
50
|
+
data["target"]["commit"] = {
|
|
51
|
+
"type": type,
|
|
52
|
+
"hash": commit,
|
|
53
|
+
}
|
|
54
|
+
if pattern is not None:
|
|
55
|
+
data["target"]["selector"] = {
|
|
56
|
+
"type": "custom",
|
|
57
|
+
"pattern": pattern,
|
|
58
|
+
}
|
|
59
|
+
if variables is not None:
|
|
60
|
+
data["variables"] = variables
|
|
61
|
+
|
|
62
|
+
return self.__get_object(self.post(None, trailing=True, data=data))
|
|
63
|
+
|
|
64
|
+
def each(self, q=None, sort=None):
|
|
65
|
+
"""
|
|
66
|
+
Returns the list of pipelines in this repository.
|
|
67
|
+
|
|
68
|
+
:param q: string: Query string to narrow down the response.
|
|
69
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
70
|
+
:param sort: string: Name of a response property to sort results.
|
|
71
|
+
See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
|
|
72
|
+
|
|
73
|
+
:return: A generator for the Pipeline objects
|
|
74
|
+
|
|
75
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/#get
|
|
76
|
+
"""
|
|
77
|
+
params = {}
|
|
78
|
+
if sort is not None:
|
|
79
|
+
params["sort"] = sort
|
|
80
|
+
if q is not None:
|
|
81
|
+
params["q"] = q
|
|
82
|
+
for pipeline in self._get_paged(
|
|
83
|
+
None,
|
|
84
|
+
trailing=True,
|
|
85
|
+
paging_workaround=True,
|
|
86
|
+
params=params,
|
|
87
|
+
):
|
|
88
|
+
yield self.__get_object(pipeline)
|
|
89
|
+
|
|
90
|
+
return
|
|
91
|
+
|
|
92
|
+
def get(self, uuid):
|
|
93
|
+
"""
|
|
94
|
+
Returns the pipeline with the uuid in this repository.
|
|
95
|
+
|
|
96
|
+
:param uuid: string: The requested pipeline uuid
|
|
97
|
+
|
|
98
|
+
:return: The requested Pipeline objects
|
|
99
|
+
|
|
100
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/%7Bpipeline_uuid%7D#get
|
|
101
|
+
"""
|
|
102
|
+
return self.__get_object(super(Pipelines, self).get(uuid))
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class Pipeline(BitbucketCloudBase):
|
|
106
|
+
def __init__(self, url, data, *args, **kwargs):
|
|
107
|
+
super(Pipeline, self).__init__(url, *args, data=data, expected_type="pipeline", **kwargs)
|
|
108
|
+
|
|
109
|
+
def __get_object(self, data):
|
|
110
|
+
return Step(
|
|
111
|
+
"{}/steps/{}".format(self.url, data["uuid"]),
|
|
112
|
+
data,
|
|
113
|
+
**self._new_session_args
|
|
114
|
+
) # fmt: skip
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def uuid(self):
|
|
118
|
+
"""The pipeline uuid"""
|
|
119
|
+
return self.get_data("uuid")
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
def build_number(self):
|
|
123
|
+
"""The pipeline build number"""
|
|
124
|
+
return self.get_data("build_number")
|
|
125
|
+
|
|
126
|
+
@property
|
|
127
|
+
def build_seconds_used(self):
|
|
128
|
+
"""The pipeline duration in seconds"""
|
|
129
|
+
return self.get_data("build_seconds_used")
|
|
130
|
+
|
|
131
|
+
@property
|
|
132
|
+
def created_on(self):
|
|
133
|
+
"""The pipeline creation time"""
|
|
134
|
+
return self.get_time("created_on")
|
|
135
|
+
|
|
136
|
+
@property
|
|
137
|
+
def completed_on(self):
|
|
138
|
+
"""The pipeline completion time"""
|
|
139
|
+
return self.get_time("completed_on")
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def pullrequest(self):
|
|
143
|
+
"""Returns a PullRequest object if the pipeline was triggered by a pull request, else None"""
|
|
144
|
+
target = self.get_data("target")
|
|
145
|
+
if target["type"] == "pipeline_pullrequest_target":
|
|
146
|
+
return PullRequest(
|
|
147
|
+
target["pullrequest"]["links"]["self"]["href"],
|
|
148
|
+
target["pullrequest"],
|
|
149
|
+
**self._new_session_args
|
|
150
|
+
) # fmt: skip
|
|
151
|
+
else:
|
|
152
|
+
return None
|
|
153
|
+
|
|
154
|
+
def stop(self):
|
|
155
|
+
"""
|
|
156
|
+
Stop the pipeline
|
|
157
|
+
|
|
158
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/%7Bpipeline_uuid%7D/stopPipeline#post
|
|
159
|
+
"""
|
|
160
|
+
return self.post("stopPipeline")
|
|
161
|
+
|
|
162
|
+
def steps(self):
|
|
163
|
+
"""
|
|
164
|
+
Get the pipeline steps.
|
|
165
|
+
|
|
166
|
+
:return: A generator for the pipeline steps objects
|
|
167
|
+
|
|
168
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/%7Bpipeline_uuid%7D/steps/#get
|
|
169
|
+
"""
|
|
170
|
+
for step in self._get_paged("steps", trailing=True):
|
|
171
|
+
yield self.__get_object(step)
|
|
172
|
+
|
|
173
|
+
return
|
|
174
|
+
|
|
175
|
+
def step(self, uuid):
|
|
176
|
+
"""
|
|
177
|
+
Get a specific pipeline step with the uuid.
|
|
178
|
+
|
|
179
|
+
:return: The requested pipeline step objects
|
|
180
|
+
|
|
181
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/%7Bpipeline_uuid%7D/steps/%7Bstep_uuid%7D#get
|
|
182
|
+
"""
|
|
183
|
+
return self.__get_object(self.get("steps/{}".format(uuid)))
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class Step(BitbucketCloudBase):
|
|
187
|
+
def __init__(self, url, data, *args, **kwargs):
|
|
188
|
+
super(Step, self).__init__(url, *args, data=data, expected_type="pipeline_step", **kwargs)
|
|
189
|
+
|
|
190
|
+
@property
|
|
191
|
+
def uuid(self):
|
|
192
|
+
"""The step uuid"""
|
|
193
|
+
return self.get_data("uuid")
|
|
194
|
+
|
|
195
|
+
@property
|
|
196
|
+
def run_number(self):
|
|
197
|
+
"""The run number"""
|
|
198
|
+
return self.get_data("run_number")
|
|
199
|
+
|
|
200
|
+
@property
|
|
201
|
+
def started_on(self):
|
|
202
|
+
"""The step start time"""
|
|
203
|
+
return self.get_time("started_on")
|
|
204
|
+
|
|
205
|
+
@property
|
|
206
|
+
def completed_on(self):
|
|
207
|
+
"""The step end time"""
|
|
208
|
+
return self.get_time("completed_on")
|
|
209
|
+
|
|
210
|
+
@property
|
|
211
|
+
def duration_in_seconds(self):
|
|
212
|
+
"""The step duration in seconds"""
|
|
213
|
+
return self.get_data("duration_in_seconds")
|
|
214
|
+
|
|
215
|
+
@property
|
|
216
|
+
def state(self):
|
|
217
|
+
"""The step state"""
|
|
218
|
+
return self.get_data("state")
|
|
219
|
+
|
|
220
|
+
@property
|
|
221
|
+
def setup_commands(self):
|
|
222
|
+
"""The step setup commands"""
|
|
223
|
+
return self.get_data("setup_commands")
|
|
224
|
+
|
|
225
|
+
@property
|
|
226
|
+
def script_commands(self):
|
|
227
|
+
"""The step script commands"""
|
|
228
|
+
return self.get_data("script_commands")
|
|
229
|
+
|
|
230
|
+
def log(self, start=None, end=None):
|
|
231
|
+
"""
|
|
232
|
+
Returns the log content in the given range.
|
|
233
|
+
|
|
234
|
+
:param start: int: The start of the range. First element is 0.
|
|
235
|
+
:param end: int: The end of the range, must be greater than start.
|
|
236
|
+
|
|
237
|
+
:return: The byte representation of the log or if range is given a tuple with
|
|
238
|
+
the overall size and the byte representation of the requested range.
|
|
239
|
+
|
|
240
|
+
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/%7Bpipeline_uuid%7D/steps/%7Bstep_uuid%7D/log#get
|
|
241
|
+
"""
|
|
242
|
+
headers = {"Accept": "application/octet-stream"}
|
|
243
|
+
if ((start is not None) and (end is None)) or ((start is None) and (end is not None)):
|
|
244
|
+
raise ValueError("For a range [start] and [end] are needed.")
|
|
245
|
+
if start is not None:
|
|
246
|
+
start = int(start)
|
|
247
|
+
end = int(end)
|
|
248
|
+
if (start >= 0) and (start < end):
|
|
249
|
+
headers["Range"] = "bytes={}-{}".format(start, end)
|
|
250
|
+
else:
|
|
251
|
+
raise ValueError("Value of [start] must be o or greater and [end] must be greater than [start].")
|
|
252
|
+
|
|
253
|
+
response = None
|
|
254
|
+
try:
|
|
255
|
+
response = self.get("log", headers=headers, advanced_mode=True)
|
|
256
|
+
response.raise_for_status()
|
|
257
|
+
except HTTPError as e:
|
|
258
|
+
# A 404 indicates that no log is present.
|
|
259
|
+
if not e.response.status_code == 404:
|
|
260
|
+
# Rethrow the exception
|
|
261
|
+
raise
|
|
262
|
+
return None
|
|
263
|
+
|
|
264
|
+
if response is None:
|
|
265
|
+
if start is None:
|
|
266
|
+
return None
|
|
267
|
+
return None, None
|
|
268
|
+
|
|
269
|
+
if start is None:
|
|
270
|
+
return response.content
|
|
271
|
+
return (
|
|
272
|
+
response.headers["Content-Range"].split("/")[1],
|
|
273
|
+
response.content,
|
|
274
|
+
)
|