atlassian-python-api 5.0.0__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 (44) hide show
  1. atlassian/VERSION +1 -1
  2. atlassian/__init__.py +13 -2
  3. atlassian/assets.py +10 -3
  4. atlassian/bamboo.py +197 -4
  5. atlassian/bitbucket/__init__.py +87 -1
  6. atlassian/bitbucket/base.py +11 -14
  7. atlassian/bitbucket/cloud/repositories/__init__.py +33 -0
  8. atlassian/bitbucket/cloud/workspaces/__init__.py +15 -7
  9. atlassian/bitbucket/server/__init__.py +11 -0
  10. atlassian/cloud_admin.py +418 -0
  11. atlassian/confluence/__init__.py +13 -1
  12. atlassian/confluence/base.py +80 -14
  13. atlassian/confluence/cloud/__init__.py +233 -11
  14. atlassian/confluence/cloud/classification_levels.py +77 -0
  15. atlassian/confluence/cloud/cloud.py +79 -186
  16. atlassian/confluence/cloud/content_properties.py +71 -0
  17. atlassian/confluence/cloud/databases.py +59 -0
  18. atlassian/confluence/cloud/folders.py +48 -0
  19. atlassian/confluence/cloud/graphql.py +99 -0
  20. atlassian/confluence/cloud/tasks.py +86 -0
  21. atlassian/confluence/cloud/whiteboards.py +95 -0
  22. atlassian/confluence/server/__init__.py +603 -194
  23. atlassian/confluence_base.py +28 -3
  24. atlassian/crowd.py +78 -0
  25. atlassian/jira/__init__.py +21 -0
  26. atlassian/jira/core_methods.py +11698 -0
  27. atlassian/jira/jira_cloud.py +160 -0
  28. atlassian/{jira.py → jira/jira_server.py} +336 -8
  29. atlassian/jira/service_management_methods.py +1381 -0
  30. atlassian/jira/software_methods.py +2114 -0
  31. atlassian/rest_client.py +67 -8
  32. atlassian/service_desk.py +10 -3
  33. atlassian/yogi/__init__.py +17 -0
  34. atlassian/yogi/base.py +11 -0
  35. atlassian/yogi/cloud.py +2367 -0
  36. atlassian/yogi/yogi_confluence_cloud.py +10 -0
  37. atlassian/yogi/yogi_confluence_dc.py +94 -0
  38. atlassian/yogi/yogi_jira_cloud.py +10 -0
  39. atlassian/yogi/yogi_jira_dc.py +64 -0
  40. {atlassian_python_api-5.0.0.dist-info → atlassian_python_api-5.0.2.dist-info}/METADATA +80 -10
  41. {atlassian_python_api-5.0.0.dist-info → atlassian_python_api-5.0.2.dist-info}/RECORD +44 -25
  42. {atlassian_python_api-5.0.0.dist-info → atlassian_python_api-5.0.2.dist-info}/WHEEL +0 -0
  43. {atlassian_python_api-5.0.0.dist-info → atlassian_python_api-5.0.2.dist-info}/licenses/LICENSE +0 -0
  44. {atlassian_python_api-5.0.0.dist-info → atlassian_python_api-5.0.2.dist-info}/top_level.txt +0 -0
@@ -11,12 +11,26 @@ import re
11
11
  import warnings
12
12
  from typing import Any, Dict, List, Optional
13
13
 
14
- from ...confluence_base import ConfluenceBase
14
+ from .classification_levels import ClassificationLevelOperations
15
+ from .content_properties import ContentPropertyOperations
16
+ from .databases import DatabaseOperations
17
+ from .folders import FolderOperations
18
+ from .graphql import GraphQLOperations
19
+ from .tasks import TaskOperations
20
+ from .whiteboards import WhiteboardOperations
15
21
 
16
22
  log = logging.getLogger(__name__)
17
23
 
18
24
 
19
- class ConfluenceCloud(ConfluenceBase):
25
+ class ConfluenceCloud(
26
+ ClassificationLevelOperations,
27
+ ContentPropertyOperations,
28
+ GraphQLOperations,
29
+ WhiteboardOperations,
30
+ TaskOperations,
31
+ FolderOperations,
32
+ DatabaseOperations,
33
+ ):
20
34
  """
21
35
  Confluence Cloud API implementation class
22
36
  """
@@ -237,6 +251,61 @@ class ConfluenceCloud(ConfluenceBase):
237
251
  log.error(f"Failed to retrieve pages: {e}")
238
252
  raise
239
253
 
254
+ def get_page_versions(
255
+ self,
256
+ page_id: str,
257
+ body_format: Optional[str] = None,
258
+ limit: int = 25,
259
+ sort: Optional[str] = None,
260
+ cursor: Optional[str] = None,
261
+ ) -> Dict[str, Any]:
262
+ """Return the version history for a Confluence Cloud page.
263
+
264
+ This uses the Cloud V2 version endpoint. Cloud V2 exposes version
265
+ retrieval only; deletion remains unavailable in that API.
266
+ """
267
+ if body_format is not None and body_format not in ("storage", "atlas_doc_format", "view"):
268
+ raise ValueError("body_format must be 'storage', 'atlas_doc_format', or 'view'")
269
+ params: Dict[str, Any] = {"limit": limit}
270
+ if body_format is not None:
271
+ params["body-format"] = body_format
272
+ if sort is not None:
273
+ params["sort"] = sort
274
+ if cursor is not None:
275
+ params["cursor"] = cursor
276
+ return self.get(self.get_endpoint("page_versions", id=page_id), params=params)
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
+
305
+ def get_page_version(self, page_id: str, version_number: int) -> Dict[str, Any]:
306
+ """Return details for one Confluence Cloud page version."""
307
+ return self.get(self.get_endpoint("page_version", id=page_id, version_number=version_number), params={})
308
+
240
309
  def get_child_pages(
241
310
  self,
242
311
  parent_id: str,
@@ -621,7 +690,7 @@ class ConfluenceCloud(ConfluenceBase):
621
690
  Args:
622
691
  ids: (optional) List of space IDs to filter by
623
692
  keys: (optional) List of space keys to filter by
624
- _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'
625
694
  status: (optional) Status of spaces to filter by. Valid values: 'current', 'archived'
626
695
  labels: (optional) List of labels to filter by (matches any)
627
696
  sort: (optional) Sort order. Format: [field] or [-field] for descending
@@ -641,10 +710,10 @@ class ConfluenceCloud(ConfluenceBase):
641
710
 
642
711
  # Add optional filters
643
712
  if ids:
644
- params["id"] = ",".join(ids)
713
+ params["ids"] = ids
645
714
 
646
715
  if keys:
647
- params["key"] = ",".join(keys)
716
+ params["keys"] = keys
648
717
 
649
718
  if type:
650
719
  if type not in ("global", "personal"):
@@ -657,7 +726,7 @@ class ConfluenceCloud(ConfluenceBase):
657
726
  params["status"] = status
658
727
 
659
728
  if labels:
660
- params["label"] = ",".join(labels)
729
+ params["labels"] = labels
661
730
 
662
731
  if sort:
663
732
  valid_sort_fields = ["id", "-id", "key", "-key", "name", "-name", "type", "-type", "status", "-status"]
@@ -676,6 +745,10 @@ class ConfluenceCloud(ConfluenceBase):
676
745
  log.error(f"Failed to retrieve spaces: {e}")
677
746
  raise
678
747
 
748
+ def get_space_names(self, **kwargs) -> List[str]:
749
+ """Return every visible space name without retrieving page content."""
750
+ return [space["name"] for space in self.get_spaces(**kwargs) if space.get("name")]
751
+
679
752
  def get_space(self, space_id: str) -> Dict[str, Any]:
680
753
  """
681
754
  Returns a specific space by ID.
@@ -1855,186 +1928,6 @@ class ConfluenceCloud(ConfluenceBase):
1855
1928
  log.error(f"Failed to delete comment {comment_id}: {e}")
1856
1929
  raise
1857
1930
 
1858
- # V2-specific methods will be implemented here in Phase 2 and Phase 3
1859
-
1860
- """
1861
- ##############################################################################################
1862
- # Confluence Whiteboards API v2 #
1863
- ##############################################################################################
1864
- """
1865
-
1866
- def create_whiteboard(
1867
- self,
1868
- space_id: str,
1869
- title: Optional[str] = None,
1870
- parent_id: Optional[str] = None,
1871
- template_key: Optional[str] = None,
1872
- locale: Optional[str] = None,
1873
- ) -> Dict[str, Any]:
1874
- """
1875
- Creates a new whiteboard in the specified space.
1876
-
1877
- Args:
1878
- space_id: ID of the space where the whiteboard will be created
1879
- title: (optional) Title of the new whiteboard
1880
- parent_id: (optional) ID of the parent content
1881
- template_key: (optional) Key of the template to use for the whiteboard
1882
- locale: (optional) Locale for the template if template_key is provided
1883
-
1884
- Returns:
1885
- Created whiteboard data
1886
-
1887
- Raises:
1888
- HTTPError: If the API call fails
1889
- """
1890
- endpoint = self.get_endpoint("whiteboard")
1891
-
1892
- data = {"spaceId": space_id}
1893
-
1894
- if title is not None:
1895
- data["title"] = title
1896
-
1897
- if parent_id is not None:
1898
- data["parentId"] = parent_id
1899
-
1900
- if template_key is not None:
1901
- data["templateKey"] = template_key
1902
-
1903
- if locale is not None:
1904
- data["locale"] = locale
1905
-
1906
- try:
1907
- return self.post(endpoint, data=data)
1908
- except Exception as e:
1909
- log.error(f"Failed to create whiteboard in space {space_id}: {e}")
1910
- raise
1911
-
1912
- def get_whiteboard_by_id(self, whiteboard_id: str) -> Dict[str, Any]:
1913
- """
1914
- Get a whiteboard by its ID.
1915
-
1916
- Args:
1917
- whiteboard_id: ID of the whiteboard to retrieve
1918
-
1919
- Returns:
1920
- Whiteboard data
1921
-
1922
- Raises:
1923
- HTTPError: If the API call fails
1924
- """
1925
- endpoint = self.get_endpoint("whiteboard_by_id", id=whiteboard_id)
1926
-
1927
- try:
1928
- return self.get(endpoint)
1929
- except Exception as e:
1930
- log.error(f"Failed to get whiteboard {whiteboard_id}: {e}")
1931
- raise
1932
-
1933
- def delete_whiteboard(self, whiteboard_id: str) -> Dict[str, Any]:
1934
- """
1935
- Delete a whiteboard by its ID.
1936
- This moves the whiteboard to the trash, where it can be restored later.
1937
-
1938
- Args:
1939
- whiteboard_id: ID of the whiteboard to delete
1940
-
1941
- Returns:
1942
- Response data from the API
1943
-
1944
- Raises:
1945
- HTTPError: If the API call fails
1946
- """
1947
- endpoint = self.get_endpoint("whiteboard_by_id", id=whiteboard_id)
1948
-
1949
- try:
1950
- return self.delete(endpoint)
1951
- except Exception as e:
1952
- log.error(f"Failed to delete whiteboard {whiteboard_id}: {e}")
1953
- raise
1954
-
1955
- def get_whiteboard_children(
1956
- self, whiteboard_id: str, cursor: Optional[str] = None, limit: Optional[int] = None
1957
- ) -> List[Dict[str, Any]]:
1958
- """
1959
- Get the children of a whiteboard.
1960
-
1961
- Args:
1962
- whiteboard_id: ID of the whiteboard
1963
- cursor: (optional) Cursor for pagination
1964
- limit: (optional) Maximum number of results to return
1965
-
1966
- Returns:
1967
- List of whiteboard children
1968
-
1969
- Raises:
1970
- HTTPError: If the API call fails
1971
- """
1972
- endpoint = self.get_endpoint("whiteboard_children", id=whiteboard_id)
1973
-
1974
- params = {}
1975
- if cursor:
1976
- params["cursor"] = cursor
1977
- if limit:
1978
- params["limit"] = limit
1979
-
1980
- try:
1981
- return list(self._get_paged(endpoint, params=params))
1982
- except Exception as e:
1983
- log.error(f"Failed to get children for whiteboard {whiteboard_id}: {e}")
1984
- raise
1985
-
1986
- def get_whiteboard_ancestors(self, whiteboard_id: str) -> List[Dict[str, Any]]:
1987
- """
1988
- Get the ancestors of a whiteboard.
1989
-
1990
- Args:
1991
- whiteboard_id: ID of the whiteboard
1992
-
1993
- Returns:
1994
- List of ancestor content
1995
-
1996
- Raises:
1997
- HTTPError: If the API call fails
1998
- """
1999
- endpoint = self.get_endpoint("whiteboard_ancestors", id=whiteboard_id)
2000
-
2001
- try:
2002
- response = self.get(endpoint)
2003
- return response.get("results", [])
2004
- except Exception as e:
2005
- log.error(f"Failed to get ancestors for whiteboard {whiteboard_id}: {e}")
2006
- raise
2007
-
2008
- def get_space_whiteboards(
2009
- self, space_id: str, cursor: Optional[str] = None, limit: int = 25
2010
- ) -> List[Dict[str, Any]]:
2011
- """
2012
- Get all whiteboards in a space.
2013
-
2014
- Args:
2015
- space_id: ID or key of the space
2016
- cursor: (optional) Cursor for pagination
2017
- limit: (optional) Maximum number of results to return (default: 25)
2018
-
2019
- Returns:
2020
- List of whiteboards in the space
2021
-
2022
- Raises:
2023
- HTTPError: If the API call fails
2024
- """
2025
- endpoint = self.get_endpoint("whiteboard")
2026
-
2027
- params = {"spaceId": space_id, "limit": limit}
2028
-
2029
- if cursor:
2030
- params["cursor"] = cursor
2031
-
2032
- try:
2033
- return list(self._get_paged(endpoint, params=params))
2034
- except Exception as e:
2035
- log.error(f"Failed to get whiteboards for space {space_id}: {e}")
2036
- raise
2037
-
2038
1931
  """
2039
1932
  ##############################################################################################
2040
1933
  # Confluence Custom Content API (Cloud only) #
@@ -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,59 @@
1
+ """Confluence Cloud V2 database lifecycle operations.
2
+
3
+ The public API currently exposes database metadata only. Record, field, view,
4
+ and query operations are intentionally not provided because Atlassian does not
5
+ publish endpoints for them.
6
+ """
7
+
8
+ from typing import Any, Dict, Optional
9
+
10
+ from ...confluence_base import ConfluenceBase
11
+
12
+
13
+ class DatabaseOperations(ConfluenceBase):
14
+ """Base component implementing the supported Cloud database endpoints."""
15
+
16
+ def create_database(
17
+ self,
18
+ space_id: str,
19
+ title: str,
20
+ parent_id: Optional[str] = None,
21
+ private: Optional[bool] = None,
22
+ ) -> Optional[Dict[str, Any]]:
23
+ """Create a database in a Confluence Cloud space.
24
+
25
+ Requires the ``write:database:confluence`` scope for scoped tokens.
26
+ """
27
+ data: Dict[str, str] = {"spaceId": space_id, "title": title}
28
+ if parent_id is not None:
29
+ data["parentId"] = parent_id
30
+ params = {"private": private} if private is not None else None
31
+ return self.post(self.get_endpoint("database"), data=data, params=params)
32
+
33
+ def get_database(
34
+ self,
35
+ database_id: str,
36
+ include_collaborators: Optional[bool] = None,
37
+ include_direct_children: Optional[bool] = None,
38
+ include_operations: Optional[bool] = None,
39
+ include_properties: Optional[bool] = None,
40
+ ) -> Optional[Dict[str, Any]]:
41
+ """Return database metadata by ID.
42
+
43
+ Requires the ``read:database:confluence`` scope for scoped tokens.
44
+ """
45
+ optional_params = {
46
+ "include-collaborators": include_collaborators,
47
+ "include-direct-children": include_direct_children,
48
+ "include-operations": include_operations,
49
+ "include-properties": include_properties,
50
+ }
51
+ params = {key: value for key, value in optional_params.items() if value is not None}
52
+ return self.get(self.get_endpoint("database_by_id", id=database_id), params=params)
53
+
54
+ def delete_database(self, database_id: str) -> Optional[Dict[str, Any]]:
55
+ """Move a database to the Confluence Cloud trash.
56
+
57
+ Requires the ``delete:database:confluence`` scope for scoped tokens.
58
+ """
59
+ return self.delete(self.get_endpoint("database_by_id", id=database_id))
@@ -0,0 +1,48 @@
1
+ """Confluence Cloud V2 folder operations."""
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+ from ...confluence_base import ConfluenceBase
6
+
7
+
8
+ class FolderOperations(ConfluenceBase):
9
+ """Base component implementing the supported Cloud folder endpoints."""
10
+
11
+ def create_folder(self, space_id: str, title: str, parent_id: Optional[str] = None) -> Optional[Dict[str, Any]]:
12
+ """Create a folder in a Confluence Cloud space.
13
+
14
+ ``parent_id`` can identify a page or folder. Scoped tokens require the
15
+ ``write:folder:confluence`` scope.
16
+ """
17
+ data: Dict[str, str] = {"spaceId": space_id, "title": title}
18
+ if parent_id is not None:
19
+ data["parentId"] = parent_id
20
+ return self.post(self.get_endpoint("folder"), data=data)
21
+
22
+ def get_folder(
23
+ self,
24
+ folder_id: str,
25
+ include_collaborators: Optional[bool] = None,
26
+ include_direct_children: Optional[bool] = None,
27
+ include_operations: Optional[bool] = None,
28
+ include_properties: Optional[bool] = None,
29
+ ) -> Optional[Dict[str, Any]]:
30
+ """Return a Confluence Cloud folder by ID.
31
+
32
+ Scoped tokens require the ``read:folder:confluence`` scope.
33
+ """
34
+ optional_params = {
35
+ "include-collaborators": include_collaborators,
36
+ "include-direct-children": include_direct_children,
37
+ "include-operations": include_operations,
38
+ "include-properties": include_properties,
39
+ }
40
+ params = {key: value for key, value in optional_params.items() if value is not None}
41
+ return self.get(self.get_endpoint("folder_by_id", id=folder_id), params=params)
42
+
43
+ def delete_folder(self, folder_id: str) -> Optional[Dict[str, Any]]:
44
+ """Move a Confluence Cloud folder to the trash.
45
+
46
+ Scoped tokens require the ``delete:folder:confluence`` scope.
47
+ """
48
+ return self.delete(self.get_endpoint("folder_by_id", id=folder_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)
@@ -0,0 +1,86 @@
1
+ """Confluence Cloud V2 task operations."""
2
+
3
+ from typing import Any, Dict, List, Optional, Sequence
4
+
5
+ from ...confluence_base import ConfluenceBase
6
+
7
+
8
+ class TaskOperations(ConfluenceBase):
9
+ """Operations for Confluence Cloud inline tasks."""
10
+
11
+ def get_tasks(
12
+ self,
13
+ body_format: Optional[str] = None,
14
+ include_blank_tasks: Optional[bool] = None,
15
+ status: Optional[str] = None,
16
+ task_ids: Optional[Sequence[int]] = None,
17
+ space_ids: Optional[Sequence[int]] = None,
18
+ page_ids: Optional[Sequence[int]] = None,
19
+ blogpost_ids: Optional[Sequence[int]] = None,
20
+ created_by: Optional[Sequence[str]] = None,
21
+ assigned_to: Optional[Sequence[str]] = None,
22
+ completed_by: Optional[Sequence[str]] = None,
23
+ created_at_from: Optional[int] = None,
24
+ created_at_to: Optional[int] = None,
25
+ due_at_from: Optional[int] = None,
26
+ due_at_to: Optional[int] = None,
27
+ completed_at_from: Optional[int] = None,
28
+ completed_at_to: Optional[int] = None,
29
+ cursor: Optional[str] = None,
30
+ limit: int = 25,
31
+ ) -> List[Dict[str, Any]]:
32
+ """Return all visible Confluence Cloud tasks matching the supplied filters.
33
+
34
+ Date filters are Unix epoch milliseconds. The endpoint is cursor
35
+ paginated; this method follows every result page, while ``limit``
36
+ controls the number requested per page (1--250).
37
+ """
38
+ if body_format is not None and body_format not in ("storage", "atlas_doc_format", "view"):
39
+ raise ValueError("body_format must be 'storage', 'atlas_doc_format', or 'view'")
40
+ if status is not None and status not in ("complete", "incomplete"):
41
+ raise ValueError("status must be 'complete' or 'incomplete'")
42
+ if not 1 <= limit <= 250:
43
+ raise ValueError("limit must be between 1 and 250")
44
+
45
+ filters = {
46
+ "body-format": body_format,
47
+ "include-blank-tasks": include_blank_tasks,
48
+ "status": status,
49
+ "task-id": task_ids,
50
+ "space-id": space_ids,
51
+ "page-id": page_ids,
52
+ "blogpost-id": blogpost_ids,
53
+ "created-by": created_by,
54
+ "assigned-to": assigned_to,
55
+ "completed-by": completed_by,
56
+ "created-at-from": created_at_from,
57
+ "created-at-to": created_at_to,
58
+ "due-at-from": due_at_from,
59
+ "due-at-to": due_at_to,
60
+ "completed-at-from": completed_at_from,
61
+ "completed-at-to": completed_at_to,
62
+ "cursor": cursor,
63
+ }
64
+ params = {key: value for key, value in filters.items() if value is not None}
65
+ params["limit"] = limit
66
+ return list(self._get_paged(self.get_endpoint("tasks"), params=params))
67
+
68
+ def get_task(self, task_id: int, body_format: Optional[str] = None) -> Optional[Dict[str, Any]]:
69
+ """Return a task by ID. Scoped tokens require ``read:task:confluence``."""
70
+ if body_format is not None and body_format not in ("storage", "atlas_doc_format", "view"):
71
+ raise ValueError("body_format must be 'storage', 'atlas_doc_format', or 'view'")
72
+ params = {"body-format": body_format} if body_format is not None else None
73
+ return self.get(self.get_endpoint("task_by_id", id=task_id), params=params)
74
+
75
+ def update_task(self, task_id: int, status: str, body_format: Optional[str] = None) -> Optional[Dict[str, Any]]:
76
+ """Update a task's status to ``complete`` or ``incomplete``.
77
+
78
+ Confluence currently supports updating only the status. Scoped tokens
79
+ require ``write:task:confluence``.
80
+ """
81
+ if status not in ("complete", "incomplete"):
82
+ raise ValueError("status must be 'complete' or 'incomplete'")
83
+ if body_format is not None and body_format not in ("storage", "atlas_doc_format", "view"):
84
+ raise ValueError("body_format must be 'storage', 'atlas_doc_format', or 'view'")
85
+ params = {"body-format": body_format} if body_format is not None else None
86
+ return self.put(self.get_endpoint("task_by_id", id=task_id), data={"status": status}, params=params)