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.
Files changed (54) hide show
  1. atlassian/VERSION +1 -0
  2. atlassian/__init__.py +32 -0
  3. atlassian/bamboo.py +1343 -0
  4. atlassian/bitbucket/__init__.py +3572 -0
  5. atlassian/bitbucket/base.py +198 -0
  6. atlassian/bitbucket/cloud/__init__.py +24 -0
  7. atlassian/bitbucket/cloud/base.py +123 -0
  8. atlassian/bitbucket/cloud/common/__init__.py +1 -0
  9. atlassian/bitbucket/cloud/common/builds.py +85 -0
  10. atlassian/bitbucket/cloud/common/comments.py +50 -0
  11. atlassian/bitbucket/cloud/common/users.py +79 -0
  12. atlassian/bitbucket/cloud/repositories/__init__.py +437 -0
  13. atlassian/bitbucket/cloud/repositories/branchRestrictions.py +175 -0
  14. atlassian/bitbucket/cloud/repositories/commits.py +188 -0
  15. atlassian/bitbucket/cloud/repositories/defaultReviewers.py +94 -0
  16. atlassian/bitbucket/cloud/repositories/deploymentEnvironments.py +264 -0
  17. atlassian/bitbucket/cloud/repositories/diffstat.py +92 -0
  18. atlassian/bitbucket/cloud/repositories/groupPermissions.py +81 -0
  19. atlassian/bitbucket/cloud/repositories/hooks.py +117 -0
  20. atlassian/bitbucket/cloud/repositories/issues.py +164 -0
  21. atlassian/bitbucket/cloud/repositories/pipelines.py +274 -0
  22. atlassian/bitbucket/cloud/repositories/pullRequests.py +483 -0
  23. atlassian/bitbucket/cloud/repositories/refs.py +136 -0
  24. atlassian/bitbucket/cloud/repositories/repositoryVariables.py +146 -0
  25. atlassian/bitbucket/cloud/workspaces/__init__.py +146 -0
  26. atlassian/bitbucket/cloud/workspaces/members.py +62 -0
  27. atlassian/bitbucket/cloud/workspaces/permissions.py +125 -0
  28. atlassian/bitbucket/cloud/workspaces/projects.py +215 -0
  29. atlassian/bitbucket/server/__init__.py +46 -0
  30. atlassian/bitbucket/server/base.py +63 -0
  31. atlassian/bitbucket/server/common/__init__.py +1 -0
  32. atlassian/bitbucket/server/common/permissions.py +220 -0
  33. atlassian/bitbucket/server/globalPermissions.py +198 -0
  34. atlassian/bitbucket/server/projects/__init__.py +244 -0
  35. atlassian/bitbucket/server/projects/repos/__init__.py +327 -0
  36. atlassian/cloud_admin.py +32 -0
  37. atlassian/confluence.py +3336 -0
  38. atlassian/crowd.py +266 -0
  39. atlassian/errors.py +27 -0
  40. atlassian/insight.py +678 -0
  41. atlassian/jira.py +5324 -0
  42. atlassian/marketplace.py +84 -0
  43. atlassian/portfolio.py +108 -0
  44. atlassian/request_utils.py +39 -0
  45. atlassian/rest_client.py +558 -0
  46. atlassian/service_desk.py +911 -0
  47. atlassian/statuspage.py +3133 -0
  48. atlassian/utils.py +327 -0
  49. atlassian/xray.py +632 -0
  50. atlassian_python_api-3.41.13.dist-info/LICENSE +201 -0
  51. atlassian_python_api-3.41.13.dist-info/METADATA +261 -0
  52. atlassian_python_api-3.41.13.dist-info/RECORD +54 -0
  53. atlassian_python_api-3.41.13.dist-info/WHEEL +5 -0
  54. atlassian_python_api-3.41.13.dist-info/top_level.txt +1 -0
@@ -0,0 +1,46 @@
1
+ # coding=utf-8
2
+
3
+ from .base import BitbucketServerBase
4
+ from .projects import Projects
5
+ from .globalPermissions import Groups, Users
6
+
7
+
8
+ class Server(BitbucketServerBase):
9
+ """
10
+ Class implementing parts of the REST API described in
11
+ https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html
12
+ """
13
+
14
+ def __init__(self, url, *args, **kwargs):
15
+ kwargs["cloud"] = False
16
+ kwargs["api_root"] = "rest/api"
17
+ kwargs["api_version"] = "1.0"
18
+ url = url.strip("/") + "/{}/{}".format(kwargs["api_root"], kwargs["api_version"])
19
+ super(Server, self).__init__(url, *args, **kwargs)
20
+ self.__projects = Projects(self._sub_url("projects"), **self._new_session_args)
21
+ self.__groups = Groups(self._sub_url("admin/permissions/groups"), **self._new_session_args)
22
+ self.__users = Users(self._sub_url("admin/permissions/users"), **self._new_session_args)
23
+
24
+ @property
25
+ def groups(self):
26
+ """
27
+ Property to access the global groups
28
+ Reference: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp62
29
+ """
30
+ return self.__groups
31
+
32
+ @property
33
+ def users(self):
34
+ """
35
+ Property to access the global users
36
+ Reference: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp68
37
+ """
38
+ return self.__users
39
+
40
+ @property
41
+ def projects(self):
42
+ """
43
+ Property to access the projects
44
+ Reference: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp147
45
+ """
46
+ return self.__projects
@@ -0,0 +1,63 @@
1
+ # coding=utf-8
2
+
3
+ from ..base import BitbucketBase
4
+
5
+
6
+ class BitbucketServerBase(BitbucketBase):
7
+ def get_link(self, link):
8
+ """
9
+ Get a link from the data.
10
+
11
+ :param link: string: The link identifier
12
+
13
+ :return: The requested list of links or None if it isn't present
14
+ """
15
+ links = self.get_data("links")
16
+ if links is None or link not in links:
17
+ return None
18
+ return [x["href"] for x in links[link]]
19
+
20
+ def _get_paged(
21
+ self,
22
+ url,
23
+ params=None,
24
+ data=None,
25
+ flags=None,
26
+ trailing=False,
27
+ absolute=False,
28
+ ):
29
+ """
30
+ Used to get the paged data
31
+
32
+ :param url: string: The url to retrieve
33
+ :param params: dict (default is None): The parameter's
34
+ :param data: dict (default is None): The data
35
+ :param flags: string[] (default is None): The flags
36
+ :param trailing: bool (default is None): If True, a trailing slash is added to the url
37
+ :param absolute: bool (default is False): If True, the url is used absolute and not relative to the root
38
+
39
+ :return: A generator object for the data elements
40
+ """
41
+ if params is None:
42
+ params = {}
43
+
44
+ while True:
45
+ response = super(BitbucketServerBase, self).get(
46
+ url,
47
+ trailing=trailing,
48
+ params=params,
49
+ data=data,
50
+ flags=flags,
51
+ absolute=absolute,
52
+ )
53
+ if "values" not in response:
54
+ return
55
+
56
+ for value in response.get("values", []):
57
+ yield value
58
+
59
+ if response.get("nextPageStart") is None:
60
+ break
61
+ params["start"] = response.get("nextPageStart")
62
+
63
+ return
@@ -0,0 +1 @@
1
+ """ Bitbucket Server common package """
@@ -0,0 +1,220 @@
1
+ # coding=utf-8
2
+
3
+ from ..base import BitbucketServerBase
4
+
5
+
6
+ class Permissions(BitbucketServerBase):
7
+ ADMIN = "ADMIN"
8
+ WRITE = "WRITE"
9
+ READ = "READ"
10
+
11
+ def __init__(self, url, permission_prefix, *args, **kwargs):
12
+ self.__permission_prefix = permission_prefix
13
+ super(Permissions, self).__init__(url, *args, **kwargs)
14
+
15
+ def __permission(self, permission):
16
+ """Internal function to get the permission for the put request."""
17
+ return "{}_{}".format(self.__permission_prefix, permission)
18
+
19
+ def admin(self, name):
20
+ """
21
+ Add the admin permission for a group/user.
22
+ """
23
+ return self.add(name, self.__permission(self.ADMIN))
24
+
25
+ def write(self, name):
26
+ """
27
+ Add to write permission for a group/user.
28
+ """
29
+ return self.add(name, self.__permission(self.WRITE))
30
+
31
+ def read(self, name):
32
+ """
33
+ Add the read permission for a group/user.
34
+ """
35
+ return self.add(name, self.__permission(self.READ))
36
+
37
+ def add(self, name, permission):
38
+ """
39
+ Add the permission for a group/user.
40
+
41
+ :param name: string: The names of the groups/users
42
+ :param permission: string: The permission to grant.
43
+
44
+ API docs:
45
+ - For project groups see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp160
46
+ - For project users see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp166
47
+ - For repository groups see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp282
48
+ - For repository users see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp288
49
+ """
50
+ self.put(name, permission)
51
+ return
52
+
53
+ def each(self, filter=None):
54
+ """
55
+ Get all groups/users.
56
+
57
+ :params filter: string: If specified only group/usernames containing the supplied string will be returned
58
+
59
+ :return: A generator for the group/user permission objects
60
+
61
+ API docs:
62
+ - For project groups see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp159
63
+ - For project users see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp165
64
+ - For repository groupss see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp280
65
+ - For repository users see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp286
66
+ """
67
+ params = {}
68
+ if filter is not None:
69
+ params["filter"] = filter
70
+ for entry in self._get_paged(None, params=params):
71
+ entry = self._get_object(entry)
72
+ entry.url = self.url
73
+ yield entry
74
+
75
+ def each_none(self, filter=None):
76
+ """
77
+ Get all not granted groups/users.
78
+
79
+ :params filter: string: If specified only group/usernames containing the supplied string will be returned
80
+
81
+ :return: A generator for the group/user permission objects
82
+
83
+ API docs:
84
+ - For project groups see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp163
85
+ - For project users see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp169
86
+ - For repository groups see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp284
87
+ - For repository users see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp290
88
+ """
89
+ params = {}
90
+ if filter is not None:
91
+ params["filter"] = filter
92
+ for entry in self._get_paged("none", params=params):
93
+ yield self._get_object(entry)
94
+
95
+ def get(self, name):
96
+ """
97
+ Returns the requested group/user
98
+
99
+ :param name: string: The requested element name.
100
+
101
+ :return: The requested group/user object
102
+ """
103
+ for entry in self.each(filter=name):
104
+ if entry.name == name:
105
+ return entry
106
+
107
+ raise Exception("Unknown group/user '{}'".format(name))
108
+
109
+
110
+ class Groups(Permissions):
111
+ def __init__(self, url, permission_prefix, *args, **kwargs):
112
+ super(Groups, self).__init__(url, permission_prefix, *args, **kwargs)
113
+
114
+ def _get_object(self, data):
115
+ return Group(data, **self._new_session_args)
116
+
117
+
118
+ class Users(Permissions):
119
+ def __init__(self, url, permission_prefix, *args, **kwargs):
120
+ super(Users, self).__init__(url, permission_prefix, *args, **kwargs)
121
+
122
+ def _get_object(self, data):
123
+ return User(data, **self._new_session_args)
124
+
125
+
126
+ class PermissionBase(BitbucketServerBase):
127
+ def delete(self):
128
+ """
129
+ Delete the permission.
130
+
131
+ :return: The response on success
132
+ """
133
+ if self.url is None:
134
+ raise NotImplementedError("Delete not implemented for this object type.")
135
+ return super(BitbucketServerBase, self).delete(None, params={"name": self.name})
136
+
137
+ @property
138
+ def permission(self):
139
+ if self.url is None:
140
+ raise NotImplementedError("Pemission not implemented for this object type.")
141
+ return self.get_data("permission")
142
+
143
+ @property
144
+ def is_admin(self):
145
+ """True if group/user is admin"""
146
+ return True if self.permission == Permissions.ADMIN else False
147
+
148
+ @property
149
+ def is_write(self):
150
+ """True if group/user has write permission"""
151
+ return True if self.permission == Permissions.WRITE else False
152
+
153
+ @property
154
+ def is_read(self):
155
+ """True if group/user has read premission"""
156
+ return True if self.permission == Permissions.READ else False
157
+
158
+ @property
159
+ def can_write(self):
160
+ """True if group/user can write"""
161
+ return True if self.permission in (Permissions.ADMIN, Permissions.WRITE) else False
162
+
163
+
164
+ class Group(PermissionBase):
165
+ def __init__(self, data, *args, **kwargs):
166
+ super(Group, self).__init__(None, *args, data=data, **kwargs)
167
+
168
+ @property
169
+ def name(self):
170
+ """The name of the group"""
171
+ if self.url is None:
172
+ return self.get_data("name")
173
+ return self.get_data("group")["name"]
174
+
175
+
176
+ class User(PermissionBase):
177
+ def __init__(self, data, *args, **kwargs):
178
+ super(User, self).__init__(None, *args, data=data, **kwargs)
179
+
180
+ def __userdata(self, key):
181
+ """
182
+ Internal getter for the user data.
183
+
184
+ :param key: string: The user data to get
185
+
186
+ :return: The requested user data
187
+ """
188
+ if self.url is None:
189
+ return self.get_data(key)
190
+ return self.get_data("user")[key]
191
+
192
+ @property
193
+ def name(self):
194
+ """The name of the user"""
195
+ return self.__userdata("name")
196
+
197
+ @property
198
+ def email(self):
199
+ """The email of the user"""
200
+ return self.__userdata("emailAddress")
201
+
202
+ @property
203
+ def displayname(self):
204
+ """The displayname of the user"""
205
+ return self.__userdata("displayName")
206
+
207
+ @property
208
+ def active(self):
209
+ """The active flag of the user"""
210
+ return self.__userdata("active")
211
+
212
+ @property
213
+ def slug(self):
214
+ """The slug of the user"""
215
+ return self.__userdata("slug")
216
+
217
+ @property
218
+ def id(self):
219
+ """The id of the user"""
220
+ return self.__userdata("id")
@@ -0,0 +1,198 @@
1
+ # coding=utf-8
2
+
3
+ from .base import BitbucketServerBase
4
+
5
+
6
+ class GlobalPermissions(BitbucketServerBase):
7
+ LICENSED_USER = "LICENSED_USER"
8
+ PROJECT_CREATE = "PROJECT_CREATE"
9
+ ADMIN = "ADMIN"
10
+ SYS_ADMIN = "SYS_ADMIN"
11
+
12
+ def __init__(self, url, *args, **kwargs):
13
+ super(GlobalPermissions, self).__init__(url, *args, **kwargs)
14
+
15
+ def licensed_user(self, name):
16
+ """
17
+ Add the licensed user permission for a group/user.
18
+ """
19
+ return self.add(name, self.__permission(self.LICENSED_USER))
20
+
21
+ def project_create(self, name):
22
+ """
23
+ Add the project create permission for a group/user.
24
+ """
25
+ return self.add(name, self.__permission(self.PROJECT_CREATE))
26
+
27
+ def admin(self, name):
28
+ """
29
+ Add the admin permission for a group/user.
30
+ """
31
+ return self.add(name, self.__permission(self.ADMIN))
32
+
33
+ def sys_admin(self, name):
34
+ """
35
+ Add the sysadmin permission for a group/user.
36
+ """
37
+ return self.add(name, self.__permission(self.SYS_ADMIN))
38
+
39
+ def add(self, name, permission):
40
+ """
41
+ Add the permission for a group/user.
42
+
43
+ :param name: string: The names of the groups/users
44
+ :param permission: string: The permission to grant.
45
+
46
+ API docs:
47
+ - For groups see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp64
48
+ - For users see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp70
49
+ """
50
+ self.put(name, permission)
51
+ return
52
+
53
+ def each(self, filter=None):
54
+ """
55
+ Get all groups/users.
56
+
57
+ :params filter: string: If specified only group/usernames containing the supplied string will be returned
58
+
59
+ :return: A generator for the group/user permission objects
60
+
61
+ API docs:
62
+ - For groups see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp63
63
+ - For users see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp69
64
+ """
65
+ params = {}
66
+ if filter is not None:
67
+ params["filter"] = filter
68
+ for entry in self._get_paged(None, params=params):
69
+ entry = self._get_object(entry)
70
+ entry.url = self.url
71
+ yield entry
72
+
73
+ def each_none(self, filter=None):
74
+ """
75
+ Get all not granted groups/users.
76
+
77
+ :params filter: string: If specified only group/usernames containing the supplied string will be returned
78
+
79
+ :return: A generator for the group/user permission objects
80
+
81
+ API docs:
82
+ - For groups see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp67
83
+ - For users see https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp73
84
+ """
85
+ params = {}
86
+ if filter is not None:
87
+ params["filter"] = filter
88
+ for entry in self._get_paged("none", params=params):
89
+ yield self._get_object(entry)
90
+
91
+ def get(self, name):
92
+ """
93
+ Returns the requested group/user
94
+
95
+ :param name: string: The requested element name.
96
+
97
+ :return: The requested group/user object
98
+ """
99
+ for entry in self.each(filter=name):
100
+ if entry.name == name:
101
+ return entry
102
+
103
+ raise Exception("Unknown group/user '{}'".format(name))
104
+
105
+
106
+ class Groups(GlobalPermissions):
107
+ def __init__(self, url, *args, **kwargs):
108
+ super(Groups, self).__init__(url, *args, **kwargs)
109
+
110
+ def _get_object(self, data):
111
+ return Group(data, **self._new_session_args)
112
+
113
+
114
+ class Users(GlobalPermissions):
115
+ def __init__(self, url, *args, **kwargs):
116
+ super(Users, self).__init__(url, *args, **kwargs)
117
+
118
+ def _get_object(self, data):
119
+ return User(data, **self._new_session_args)
120
+
121
+
122
+ class PermissionBase(BitbucketServerBase):
123
+ @property
124
+ def permission(self):
125
+ if self.url is None:
126
+ raise NotImplementedError("Permission not implemented for this object type.")
127
+ return self.get_data("permission")
128
+
129
+ @property
130
+ def is_licensed_user(self):
131
+ return True if self.permission == GlobalPermissions.LICENSED_USER else False
132
+
133
+ @property
134
+ def is_project_create(self):
135
+ return True if self.permission == GlobalPermissions.PROJECT_CREATE else False
136
+
137
+ @property
138
+ def is_admin(self):
139
+ return True if self.permission == GlobalPermissions.ADMIN else False
140
+
141
+ @property
142
+ def is_sys_admin(self):
143
+ return True if self.permission == GlobalPermissions.SYS_ADMIN else False
144
+
145
+ def delete(self):
146
+ """
147
+ Delete the permission.
148
+
149
+ :return: The response on success
150
+ """
151
+ if self.url is None:
152
+ raise NotImplementedError("Delete not implemented for this object type.")
153
+ return super(PermissionBase, self).delete(None, params={"name": self.name})
154
+
155
+
156
+ class Group(PermissionBase):
157
+ def __init__(self, data, *args, **kwargs):
158
+ super(Group, self).__init__(None, *args, data=data, **kwargs)
159
+
160
+ @property
161
+ def name(self):
162
+ if self.url is None:
163
+ return self.get_data("name")
164
+ return self.get_data("group")["name"]
165
+
166
+
167
+ class User(PermissionBase):
168
+ def __init__(self, data, *args, **kwargs):
169
+ super(User, self).__init__(None, *args, data=data, **kwargs)
170
+
171
+ def __userdata(self, key):
172
+ if self.url is None:
173
+ return self.get_data(key)
174
+ return self.get_data("user")[key]
175
+
176
+ @property
177
+ def name(self):
178
+ return self.__userdata("name")
179
+
180
+ @property
181
+ def email(self):
182
+ return self.__userdata("emailAddress")
183
+
184
+ @property
185
+ def displayname(self):
186
+ return self.__userdata("displayName")
187
+
188
+ @property
189
+ def active(self):
190
+ return self.__userdata("active")
191
+
192
+ @property
193
+ def slug(self):
194
+ return self.__userdata("slug")
195
+
196
+ @property
197
+ def id(self):
198
+ return self.__userdata("id")