atlassian-python-api 4.0.7__py3-none-any.whl → 5.0.1__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 (66) hide show
  1. atlassian/VERSION +1 -1
  2. atlassian/__init__.py +18 -1
  3. atlassian/assets.py +1 -1
  4. atlassian/bamboo.py +23 -6
  5. atlassian/bitbucket/__init__.py +3 -3
  6. atlassian/bitbucket/base.py +5 -15
  7. atlassian/bitbucket/cloud/repositories/__init__.py +33 -0
  8. atlassian/bitbucket/cloud/repositories/pipelines.py +1 -1
  9. atlassian/bitbucket/cloud/workspaces/__init__.py +17 -9
  10. atlassian/bitbucket/cloud/workspaces/projects.py +1 -1
  11. atlassian/bitbucket/server/__init__.py +1 -1
  12. atlassian/bitbucket/server/projects/__init__.py +2 -1
  13. atlassian/bitbucket/server/projects/repos/__init__.py +1 -0
  14. atlassian/confluence/__init__.py +51 -4100
  15. atlassian/confluence/base.py +239 -0
  16. atlassian/confluence/cloud/__init__.py +557 -0
  17. atlassian/confluence/cloud/base.py +25 -0
  18. atlassian/confluence/cloud/cloud.py +2335 -0
  19. atlassian/confluence/cloud/databases.py +59 -0
  20. atlassian/confluence/cloud/folders.py +48 -0
  21. atlassian/confluence/cloud/tasks.py +86 -0
  22. atlassian/confluence/cloud/whiteboards.py +95 -0
  23. atlassian/confluence/server/__init__.py +4197 -0
  24. atlassian/confluence/server/base.py +25 -0
  25. atlassian/confluence/server/confluence_server.py +28 -0
  26. atlassian/confluence_base.py +306 -0
  27. atlassian/confluence_v2.py +7 -0
  28. atlassian/crowd.py +1 -1
  29. atlassian/insight.py +3 -2
  30. atlassian/jira.py +312 -18
  31. atlassian/jira_models.py +10 -0
  32. atlassian/models/__init__.py +5 -0
  33. atlassian/models/jira/__init__.py +109 -0
  34. atlassian/models/jira/adf.py +178 -0
  35. atlassian/models/jira/builders.py +272 -0
  36. atlassian/models/jira/comment.py +52 -0
  37. atlassian/models/jira/fields.py +236 -0
  38. atlassian/models/jira/issues.py +101 -0
  39. atlassian/models/jira/serializer.py +138 -0
  40. atlassian/models/jira/transition.py +78 -0
  41. atlassian/models/jira/update.py +179 -0
  42. atlassian/models/jira/validation.py +56 -0
  43. atlassian/models/py.typed +0 -0
  44. atlassian/rest_client.py +122 -22
  45. atlassian/service_desk.py +41 -1
  46. atlassian/statuspage.py +7 -6
  47. atlassian/tempo/__init__.py +14 -0
  48. atlassian/tempo/cloud/__init__.py +232 -0
  49. atlassian/tempo/cloud/base.py +38 -0
  50. atlassian/tempo/server/__init__.py +78 -0
  51. atlassian/tempo/server/accounts.py +38 -0
  52. atlassian/tempo/server/base.py +50 -0
  53. atlassian/tempo/server/budgets.py +42 -0
  54. atlassian/tempo/server/events.py +52 -0
  55. atlassian/tempo/server/planner.py +42 -0
  56. atlassian/tempo/server/servlet.py +46 -0
  57. atlassian/tempo/server/teams.py +50 -0
  58. atlassian/tempo/server/timesheets.py +54 -0
  59. atlassian/typehints.py +14 -2
  60. atlassian/xray.py +2 -0
  61. {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.1.dist-info}/METADATA +45 -5
  62. atlassian_python_api-5.0.1.dist-info/RECORD +96 -0
  63. {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.1.dist-info}/WHEEL +1 -1
  64. atlassian_python_api-4.0.7.dist-info/RECORD +0 -58
  65. {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.1.dist-info}/licenses/LICENSE +0 -0
  66. {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.1.dist-info}/top_level.txt +0 -0
atlassian/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.7
1
+ 5.0.1
atlassian/__init__.py CHANGED
@@ -6,7 +6,8 @@ from .bamboo import Bamboo
6
6
  from .bitbucket import Bitbucket
7
7
  from .bitbucket import Bitbucket as Stash
8
8
  from .cloud_admin import CloudAdminOrgs, CloudAdminUsers
9
- from .confluence import Confluence
9
+ from .confluence import Confluence, ConfluenceBase, ConfluenceCloud, ConfluenceServer
10
+ from .confluence.cloud.cloud import ConfluenceCloud as ConfluenceV2
10
11
  from .crowd import Crowd
11
12
  from .insight import Insight
12
13
  from .insight import Insight as Assets # used for Insight on-premise
@@ -16,10 +17,24 @@ from .marketplace import MarketPlace
16
17
  from .portfolio import Portfolio
17
18
  from .service_desk import ServiceDesk
18
19
  from .service_desk import ServiceDesk as ServiceManagement
20
+ from .tempo import TempoCloud, TempoServer
19
21
  from .xray import Xray
20
22
 
23
+
24
+ # Confluence REST API v2 client. The existing ``Confluence`` class remains
25
+ # the backwards-compatible v1/v2 URL-dispatching client.
26
+ def create_confluence(url, *args, api_version=1, **kwargs):
27
+ """Create a version-aware Confluence client."""
28
+ return ConfluenceBase.factory(url, *args, api_version=api_version, **kwargs)
29
+
30
+
21
31
  __all__ = [
22
32
  "Confluence",
33
+ "ConfluenceBase",
34
+ "ConfluenceCloud",
35
+ "ConfluenceServer",
36
+ "ConfluenceV2",
37
+ "create_confluence",
23
38
  "Jira",
24
39
  "Bitbucket",
25
40
  "CloudAdminOrgs",
@@ -35,4 +50,6 @@ __all__ = [
35
50
  "Insight",
36
51
  "Assets",
37
52
  "AssetsCloud",
53
+ "TempoCloud",
54
+ "TempoServer",
38
55
  ]
atlassian/assets.py CHANGED
@@ -174,7 +174,7 @@ class AssetsCloud(AtlassianRestAPI):
174
174
  raise NotImplementedError
175
175
  params = {"comment": comment, "objectId": object_id, "role": role}
176
176
  url = "rest/assets/1.0/comment/create"
177
- return self.post(url, params=params)
177
+ return self.post(url, data=params)
178
178
 
179
179
  def get_comment_of_object(self, object_id):
180
180
  """
atlassian/bamboo.py CHANGED
@@ -71,8 +71,8 @@ class Bamboo(AtlassianRestAPI):
71
71
  max_results,
72
72
  label=None,
73
73
  start_index=0,
74
- **kwargs
75
- ): # fmt: skip
74
+ **kwargs,
75
+ ):
76
76
  flags = []
77
77
  params = {"max-results": max_results}
78
78
  if expand:
@@ -628,8 +628,8 @@ class Bamboo(AtlassianRestAPI):
628
628
  stage=None,
629
629
  execute_all_stages=True,
630
630
  custom_revision=None,
631
- **bamboo_variables
632
- ): # fmt: skip
631
+ **bamboo_variables,
632
+ ):
633
633
  """
634
634
  Fire build execution for specified plan.
635
635
  !IMPORTANT! NOTE: for some reason, this method always execute all stages
@@ -1203,8 +1203,25 @@ class Bamboo(AtlassianRestAPI):
1203
1203
  params={"includeShared": include_shared},
1204
1204
  )
1205
1205
 
1206
- def activity(self):
1207
- return self.get("build/admin/ajax/getDashboardSummary.action")
1206
+ def activity(self, busy=None):
1207
+ """Return active online agents and their current build activity.
1208
+
1209
+ The former dashboard AJAX endpoint was an internal Bamboo UI endpoint
1210
+ and is not present in current Bamboo releases. The supported agent
1211
+ REST resource exposes ``active`` and ``busy`` for each online agent.
1212
+
1213
+ :param busy: Optional filter for busy (``True``) or idle (``False``)
1214
+ agents. By default, return all active online agents.
1215
+ :return: List of active agent dictionaries, including ``busy``.
1216
+ """
1217
+ agents = self.agent_status(online=True)
1218
+ if not isinstance(agents, list):
1219
+ return agents
1220
+
1221
+ active_agents = [agent for agent in agents if agent.get("active", agent.get("online", False))]
1222
+ if busy is None:
1223
+ return active_agents
1224
+ return [agent for agent in active_agents if agent.get("busy") is busy]
1208
1225
 
1209
1226
  def get_custom_expiry(self, limit=25):
1210
1227
  """
@@ -1056,7 +1056,7 @@ class Bitbucket(BitbucketBase):
1056
1056
  repo_administrators = []
1057
1057
  for user in self.repo_users(project_key, repo_key):
1058
1058
  if user["permission"] == "REPO_ADMIN":
1059
- repo_administrators.append(user)
1059
+ repo_administrators.append(user["user"])
1060
1060
  for group in self.repo_groups_with_administrator_permissions(project_key, repo_key):
1061
1061
  for user in self.group_members(group):
1062
1062
  repo_administrators.append(user)
@@ -2575,8 +2575,8 @@ class Bitbucket(BitbucketBase):
2575
2575
  commit_id,
2576
2576
  report_key,
2577
2577
  report_title,
2578
- **report_params
2579
- ): # fmt: skip
2578
+ **report_params,
2579
+ ):
2580
2580
  """
2581
2581
  Create a new insight report, or replace the existing one
2582
2582
  if a report already exists for the given repository_slug, commit, and report key.
@@ -1,15 +1,11 @@
1
1
  # coding=utf-8
2
2
 
3
3
  import copy
4
- import re
5
- import sys
6
4
  from datetime import datetime
7
5
  from pprint import PrettyPrinter
8
6
 
9
7
  from ..rest_client import AtlassianRestAPI
10
8
 
11
- RE_TIMEZONE = re.compile(r"(\d{2}):(\d{2})$")
12
-
13
9
 
14
10
  class BitbucketBase(AtlassianRestAPI):
15
11
  CONF_TIMEFORMAT = "%Y-%m-%dT%H:%M:%S.%f%z"
@@ -160,17 +156,11 @@ class BitbucketBase(AtlassianRestAPI):
160
156
  return value_str
161
157
 
162
158
  if isinstance(value_str, str):
163
- # The format contains a : in the timezone which is supported from 3.7 on.
164
- if sys.version_info <= (3, 7):
165
- value_str = RE_TIMEZONE.sub(r"\1\2", value_str)
166
- try:
167
- value_str = value_str[:26] + "Z"
168
- value = datetime.strptime(value_str, self.CONF_TIMEFORMAT)
169
- except ValueError:
170
- value = datetime.strptime(
171
- value_str,
172
- "%Y-%m-%dT%H:%M:%S.%fZ",
173
- )
159
+ # Bitbucket Cloud returns ISO 8601 timestamps with optional
160
+ # fractional seconds and either an offset or a trailing ``Z``.
161
+ # Do not trim or otherwise alter the timestamp: doing so turns
162
+ # ``+00:00`` into the invalid ``+00:00Z`` form.
163
+ value = datetime.fromisoformat(value_str.replace("Z", "+00:00"))
174
164
  else:
175
165
  value = value_str
176
166
 
@@ -1,5 +1,7 @@
1
1
  # coding=utf-8
2
2
 
3
+ from urllib.parse import quote
4
+
3
5
  from requests import HTTPError
4
6
 
5
7
  from .branchRestrictions import BranchRestrictions
@@ -377,6 +379,37 @@ class Repository(BitbucketCloudBase):
377
379
  """The repository avatar"""
378
380
  return self.get(self.get_link("avatar"), absolute=True)
379
381
 
382
+ def get_source_file(self, commit, path):
383
+ """Return the raw bytes of a file at a branch, tag, or commit.
384
+
385
+ :param commit: Branch name, tag, or commit hash to read from.
386
+ :param path: Repository-relative path of the file.
387
+ :return: Raw file content as bytes.
388
+
389
+ API docs:
390
+ https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-commit-path-get
391
+ """
392
+ source_path = quote(path.strip("/"), safe="/")
393
+ if not source_path:
394
+ raise ValueError("path must identify a file")
395
+ return self.get(
396
+ f"src/{quote(str(commit), safe='')}/{source_path}",
397
+ not_json_response=True,
398
+ )
399
+
400
+ def get_source_directory(self, commit, path=""):
401
+ """Return the JSON directory listing at a branch, tag, or commit.
402
+
403
+ :param commit: Branch name, tag, or commit hash to browse.
404
+ :param path: Optional repository-relative directory path.
405
+ :return: Paginated Bitbucket directory listing.
406
+ """
407
+ source_path = quote(path.strip("/"), safe="/")
408
+ endpoint = f"src/{quote(str(commit), safe='')}"
409
+ if source_path:
410
+ endpoint = f"{endpoint}/{source_path}"
411
+ return self.get(endpoint)
412
+
380
413
  @property
381
414
  def branch_restrictions(self):
382
415
  """The repository branch restrictions"""
@@ -1,9 +1,9 @@
1
1
  # coding=utf-8
2
2
 
3
- from .pullRequests import PullRequest
4
3
  from requests import HTTPError
5
4
 
6
5
  from ..base import BitbucketCloudBase
6
+ from .pullRequests import PullRequest
7
7
 
8
8
 
9
9
  class Pipelines(BitbucketCloudBase):
@@ -1,12 +1,12 @@
1
1
  # coding=utf-8
2
2
 
3
3
  from requests import HTTPError
4
- from ..base import BitbucketCloudBase
5
4
 
5
+ from ..base import BitbucketCloudBase
6
+ from ..repositories import WorkspaceRepositories
6
7
  from .members import WorkspaceMembers
7
8
  from .permissions import Permissions
8
9
  from .projects import Projects
9
- from ..repositories import WorkspaceRepositories
10
10
 
11
11
 
12
12
  class Workspaces(BitbucketCloudBase):
@@ -36,17 +36,25 @@ class Workspaces(BitbucketCloudBase):
36
36
 
37
37
  :return: A generator for the Workspace objects
38
38
 
39
- API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces#get.
39
+ The former ``/workspaces`` listing endpoint is deprecated. This method
40
+ uses ``/user/workspaces`` and resolves each returned workspace to keep
41
+ yielding :class:`Workspace` objects as before.
42
+
43
+ API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-workspaces/#api-user-workspaces-get.
40
44
  """
41
45
  params = {}
42
- if role is not None:
43
- params["role"] = role
44
- if q is not None:
45
- params["q"] = q
46
+ # The replacement endpoint does not support the legacy ``role`` and
47
+ # ``q`` filters. They are intentionally not forwarded because doing so
48
+ # would produce an invalid request.
46
49
  if sort is not None:
47
50
  params["sort"] = sort
48
- for workspace in self._get_paged(None, params):
49
- yield self.__get_object(workspace)
51
+ user_workspaces_url = f"{self.url.rsplit('/', 1)[0]}/user/workspaces"
52
+ for workspace_access in self._get_paged(user_workspaces_url, params=params, absolute=True):
53
+ workspace_data = workspace_access.get("workspace", workspace_access)
54
+ workspace_id = workspace_data.get("slug") or workspace_data.get("uuid")
55
+ if workspace_id is None:
56
+ raise ValueError("Bitbucket returned a workspace without a slug or UUID")
57
+ yield self.get(workspace_id)
50
58
 
51
59
  return
52
60
 
@@ -1,8 +1,8 @@
1
1
  # coding=utf-8
2
2
 
3
3
  from requests import HTTPError
4
- from ..base import BitbucketCloudBase
5
4
 
5
+ from ..base import BitbucketCloudBase
6
6
  from ..repositories import ProjectRepositories
7
7
 
8
8
 
@@ -1,8 +1,8 @@
1
1
  # coding=utf-8
2
2
 
3
3
  from .base import BitbucketServerBase
4
- from .projects import Projects
5
4
  from .globalPermissions import Groups, Users
5
+ from .projects import Projects
6
6
 
7
7
 
8
8
  class Server(BitbucketServerBase):
@@ -1,9 +1,10 @@
1
1
  # coding=utf-8
2
2
 
3
3
  from requests import HTTPError
4
- from .repos import Repositories
4
+
5
5
  from ..base import BitbucketServerBase
6
6
  from ..common.permissions import Groups, Users
7
+ from .repos import Repositories
7
8
 
8
9
 
9
10
  class Projects(BitbucketServerBase):
@@ -1,6 +1,7 @@
1
1
  # coding=utf-8
2
2
 
3
3
  from requests import HTTPError
4
+
4
5
  from ...base import BitbucketServerBase
5
6
  from ...common.permissions import Groups, Users
6
7