atlassian-python-api 5.0.1__py3-none-any.whl → 5.0.2__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 (37) hide show
  1. atlassian/VERSION +1 -1
  2. atlassian/__init__.py +13 -2
  3. atlassian/assets.py +10 -3
  4. atlassian/bamboo.py +178 -2
  5. atlassian/bitbucket/__init__.py +87 -1
  6. atlassian/bitbucket/base.py +9 -2
  7. atlassian/bitbucket/server/__init__.py +11 -0
  8. atlassian/cloud_admin.py +418 -0
  9. atlassian/confluence/__init__.py +9 -0
  10. atlassian/confluence/base.py +32 -10
  11. atlassian/confluence/cloud/__init__.py +19 -0
  12. atlassian/confluence/cloud/classification_levels.py +77 -0
  13. atlassian/confluence/cloud/cloud.py +43 -5
  14. atlassian/confluence/cloud/content_properties.py +71 -0
  15. atlassian/confluence/cloud/graphql.py +99 -0
  16. atlassian/confluence/server/__init__.py +274 -74
  17. atlassian/crowd.py +78 -0
  18. atlassian/jira/__init__.py +21 -0
  19. atlassian/jira/core_methods.py +11698 -0
  20. atlassian/jira/jira_cloud.py +160 -0
  21. atlassian/{jira.py → jira/jira_server.py} +333 -6
  22. atlassian/jira/service_management_methods.py +1381 -0
  23. atlassian/jira/software_methods.py +2114 -0
  24. atlassian/rest_client.py +26 -1
  25. atlassian/service_desk.py +10 -3
  26. atlassian/yogi/__init__.py +17 -0
  27. atlassian/yogi/base.py +11 -0
  28. atlassian/yogi/cloud.py +2367 -0
  29. atlassian/yogi/yogi_confluence_cloud.py +10 -0
  30. atlassian/yogi/yogi_confluence_dc.py +94 -0
  31. atlassian/yogi/yogi_jira_cloud.py +10 -0
  32. atlassian/yogi/yogi_jira_dc.py +64 -0
  33. {atlassian_python_api-5.0.1.dist-info → atlassian_python_api-5.0.2.dist-info}/METADATA +80 -10
  34. {atlassian_python_api-5.0.1.dist-info → atlassian_python_api-5.0.2.dist-info}/RECORD +37 -22
  35. {atlassian_python_api-5.0.1.dist-info → atlassian_python_api-5.0.2.dist-info}/WHEEL +0 -0
  36. {atlassian_python_api-5.0.1.dist-info → atlassian_python_api-5.0.2.dist-info}/licenses/LICENSE +0 -0
  37. {atlassian_python_api-5.0.1.dist-info → atlassian_python_api-5.0.2.dist-info}/top_level.txt +0 -0
@@ -11,15 +11,26 @@ import re
11
11
  import warnings
12
12
  from typing import Any, Dict, List, Optional
13
13
 
14
+ from .classification_levels import ClassificationLevelOperations
15
+ from .content_properties import ContentPropertyOperations
14
16
  from .databases import DatabaseOperations
15
17
  from .folders import FolderOperations
18
+ from .graphql import GraphQLOperations
16
19
  from .tasks import TaskOperations
17
20
  from .whiteboards import WhiteboardOperations
18
21
 
19
22
  log = logging.getLogger(__name__)
20
23
 
21
24
 
22
- class ConfluenceCloud(WhiteboardOperations, TaskOperations, FolderOperations, DatabaseOperations):
25
+ class ConfluenceCloud(
26
+ ClassificationLevelOperations,
27
+ ContentPropertyOperations,
28
+ GraphQLOperations,
29
+ WhiteboardOperations,
30
+ TaskOperations,
31
+ FolderOperations,
32
+ DatabaseOperations,
33
+ ):
23
34
  """
24
35
  Confluence Cloud API implementation class
25
36
  """
@@ -264,6 +275,33 @@ class ConfluenceCloud(WhiteboardOperations, TaskOperations, FolderOperations, Da
264
275
  params["cursor"] = cursor
265
276
  return self.get(self.get_endpoint("page_versions", id=page_id), params=params)
266
277
 
278
+ def iter_page_versions(
279
+ self,
280
+ page_id: str,
281
+ body_format: Optional[str] = None,
282
+ limit: int = 25,
283
+ sort: Optional[str] = None,
284
+ ):
285
+ """Yield every version of a Confluence Cloud page lazily."""
286
+ if body_format is not None and body_format not in ("storage", "atlas_doc_format", "view"):
287
+ raise ValueError("body_format must be 'storage', 'atlas_doc_format', or 'view'")
288
+ params: Dict[str, Any] = {"limit": limit}
289
+ if body_format is not None:
290
+ params["body-format"] = body_format
291
+ if sort is not None:
292
+ params["sort"] = sort
293
+ return self._get_paged(self.get_endpoint("page_versions", id=page_id), params=params)
294
+
295
+ def get_all_page_versions(
296
+ self,
297
+ page_id: str,
298
+ body_format: Optional[str] = None,
299
+ limit: int = 25,
300
+ sort: Optional[str] = None,
301
+ ) -> List[Dict[str, Any]]:
302
+ """Return every version of a Confluence Cloud page as a list."""
303
+ return list(self.iter_page_versions(page_id, body_format=body_format, limit=limit, sort=sort))
304
+
267
305
  def get_page_version(self, page_id: str, version_number: int) -> Dict[str, Any]:
268
306
  """Return details for one Confluence Cloud page version."""
269
307
  return self.get(self.get_endpoint("page_version", id=page_id, version_number=version_number), params={})
@@ -652,7 +690,7 @@ class ConfluenceCloud(WhiteboardOperations, TaskOperations, FolderOperations, Da
652
690
  Args:
653
691
  ids: (optional) List of space IDs to filter by
654
692
  keys: (optional) List of space keys to filter by
655
- _type: (optional) Type of spaces to filter by. Valid values: 'global', 'personal'
693
+ type: (optional) Type of spaces to filter by. Valid values: 'global', 'personal'
656
694
  status: (optional) Status of spaces to filter by. Valid values: 'current', 'archived'
657
695
  labels: (optional) List of labels to filter by (matches any)
658
696
  sort: (optional) Sort order. Format: [field] or [-field] for descending
@@ -672,10 +710,10 @@ class ConfluenceCloud(WhiteboardOperations, TaskOperations, FolderOperations, Da
672
710
 
673
711
  # Add optional filters
674
712
  if ids:
675
- params["id"] = ",".join(ids)
713
+ params["ids"] = ids
676
714
 
677
715
  if keys:
678
- params["key"] = ",".join(keys)
716
+ params["keys"] = keys
679
717
 
680
718
  if type:
681
719
  if type not in ("global", "personal"):
@@ -688,7 +726,7 @@ class ConfluenceCloud(WhiteboardOperations, TaskOperations, FolderOperations, Da
688
726
  params["status"] = status
689
727
 
690
728
  if labels:
691
- params["label"] = ",".join(labels)
729
+ params["labels"] = labels
692
730
 
693
731
  if sort:
694
732
  valid_sort_fields = ["id", "-id", "key", "-key", "name", "-name", "type", "-type", "status", "-status"]
@@ -0,0 +1,71 @@
1
+ """Confluence Cloud V2 content-property operations."""
2
+
3
+ from typing import Any, Dict, List, Optional
4
+
5
+ from ...confluence_base import ConfluenceBase
6
+
7
+
8
+ class ContentPropertyOperations(ConfluenceBase):
9
+ """Reusable V2 content-property operations for every supported container."""
10
+
11
+ _PROPERTY_RESOURCES = {
12
+ "attachment": "attachments",
13
+ "blogpost": "blogposts",
14
+ "comment": "comments",
15
+ "custom_content": "custom-content",
16
+ "database": "databases",
17
+ "embed": "embeds",
18
+ "folder": "folders",
19
+ "page": "pages",
20
+ "whiteboard": "whiteboards",
21
+ }
22
+
23
+ @classmethod
24
+ def _property_resource(cls, content_type: str) -> str:
25
+ try:
26
+ return cls._PROPERTY_RESOURCES[content_type]
27
+ except KeyError as error:
28
+ allowed = ", ".join(sorted(cls._PROPERTY_RESOURCES))
29
+ raise ValueError(f"content_type must be one of: {allowed}") from error
30
+
31
+ def _content_properties_url(self, content_type: str, content_id: str, property_id: Optional[str] = None) -> str:
32
+ url = f"api/v2/{self._property_resource(content_type)}/{content_id}/properties"
33
+ return f"{url}/{property_id}" if property_id is not None else url
34
+
35
+ def get_v2_content_properties(
36
+ self, content_type: str, content_id: str, cursor: Optional[str] = None, limit: int = 25
37
+ ) -> List[Dict[str, Any]]:
38
+ """Return all V2 properties for one content item.
39
+
40
+ ``content_type`` is one of ``attachment``, ``blogpost``, ``comment``,
41
+ ``custom_content``, ``database``, ``embed``, ``folder``, ``page``, or
42
+ ``whiteboard``. Pagination is followed automatically.
43
+ """
44
+ if not 1 <= limit <= 250:
45
+ raise ValueError("limit must be between 1 and 250")
46
+ params: Dict[str, Any] = {"limit": limit}
47
+ if cursor is not None:
48
+ params["cursor"] = cursor
49
+ return list(self._get_paged(self._content_properties_url(content_type, content_id), params=params))
50
+
51
+ def create_v2_content_property(
52
+ self, content_type: str, content_id: str, data: Dict[str, Any]
53
+ ) -> Optional[Dict[str, Any]]:
54
+ """Create a V2 content property for one content item."""
55
+ return self.post(self._content_properties_url(content_type, content_id), data=data)
56
+
57
+ def get_v2_content_property(self, content_type: str, content_id: str, property_id: str) -> Optional[Dict[str, Any]]:
58
+ """Return a V2 content property by its ID."""
59
+ return self.get(self._content_properties_url(content_type, content_id, property_id))
60
+
61
+ def update_v2_content_property(
62
+ self, content_type: str, content_id: str, property_id: str, data: Dict[str, Any]
63
+ ) -> Optional[Dict[str, Any]]:
64
+ """Update a V2 content property by its ID."""
65
+ return self.put(self._content_properties_url(content_type, content_id, property_id), data=data)
66
+
67
+ def delete_v2_content_property(
68
+ self, content_type: str, content_id: str, property_id: str
69
+ ) -> Optional[Dict[str, Any]]:
70
+ """Delete a V2 content property by its ID."""
71
+ return self.delete(self._content_properties_url(content_type, content_id, property_id))
@@ -0,0 +1,99 @@
1
+ """Confluence Cloud GraphQL Gateway operations."""
2
+
3
+ from typing import Any, Dict, List, Optional
4
+ from urllib.parse import urlsplit
5
+
6
+ from ...confluence_base import ConfluenceBase
7
+
8
+
9
+ class GraphQLOperations(ConfluenceBase):
10
+ """Operations for the evolving Atlassian GraphQL Gateway schema."""
11
+
12
+ _ADVANCED_SEARCH_QUERY = """
13
+ query AdvancedAGGSearchQuery(
14
+ $experience: String!,
15
+ $query: String!,
16
+ $first: Int,
17
+ $filters: SearchFilterInput!
18
+ ) {
19
+ search {
20
+ search(
21
+ experience: $experience,
22
+ query: $query,
23
+ first: $first,
24
+ filters: $filters
25
+ ) {
26
+ edges {
27
+ node {
28
+ id
29
+ title
30
+ type
31
+ url
32
+ ... on SearchConfluencePageBlogAttachment {
33
+ excerpt
34
+ }
35
+ }
36
+ }
37
+ totalCount
38
+ }
39
+ }
40
+ }
41
+ """
42
+
43
+ def _graphql_url(self) -> str:
44
+ """Return the GraphQL gateway URL for the configured Cloud site."""
45
+ parsed = urlsplit(self.url)
46
+ if parsed.hostname == "api.atlassian.com":
47
+ return "https://api.atlassian.com/graphql"
48
+ return f"{parsed.scheme}://{parsed.netloc}/gateway/api/graphql"
49
+
50
+ def graphql(self, query: str, variables: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
51
+ """Execute an Atlassian GraphQL Gateway query or mutation.
52
+
53
+ GraphQL schema fields may be added, deprecated, or removed independently
54
+ of this package. The raw GraphQL response is therefore returned so that
55
+ callers can inspect both ``data`` and GraphQL ``errors``.
56
+ """
57
+ response = self.post(
58
+ self._graphql_url(),
59
+ json={"query": query, "variables": variables or {}},
60
+ absolute=True,
61
+ )
62
+ return response or {}
63
+
64
+ def search_graphql(
65
+ self,
66
+ query: str,
67
+ cloud_id: str,
68
+ first: int = 25,
69
+ entities: Optional[List[str]] = None,
70
+ ) -> Dict[str, Any]:
71
+ """Search Confluence content through the experimental GraphQL search API.
72
+
73
+ ``cloud_id`` is the Confluence site cloud ID. The raw GraphQL response
74
+ is returned; successful results are at
75
+ ``data.search.search`` and contain ``edges`` and ``totalCount``. The
76
+ GraphQL schema is not versioned, so callers should inspect its
77
+ ``errors`` field before consuming data.
78
+ """
79
+ if not query:
80
+ raise ValueError("query must not be empty")
81
+ if not 1 <= first <= 100:
82
+ raise ValueError("first must be between 1 and 100")
83
+
84
+ variables = {
85
+ "experience": "confluence.advancedSearch",
86
+ "query": query,
87
+ "first": first,
88
+ "filters": {
89
+ "entities": entities
90
+ or [
91
+ "ati:cloud:confluence:page",
92
+ "ati:cloud:confluence:attachment",
93
+ "ati:cloud:confluence:blogpost",
94
+ "ati:cloud:confluence:space",
95
+ ],
96
+ "locations": [f"ari:cloud:confluence::site/{cloud_id}"],
97
+ },
98
+ }
99
+ return self.graphql(self._ADVANCED_SEARCH_QUERY, variables)