atlassian-python-api 4.0.7__py3-none-any.whl → 5.0.0__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 -1
- atlassian/__init__.py +18 -1
- atlassian/assets.py +1 -1
- atlassian/bamboo.py +4 -4
- atlassian/bitbucket/__init__.py +3 -3
- atlassian/bitbucket/cloud/repositories/pipelines.py +1 -1
- atlassian/bitbucket/cloud/workspaces/__init__.py +2 -2
- atlassian/bitbucket/cloud/workspaces/projects.py +1 -1
- atlassian/bitbucket/server/__init__.py +1 -1
- atlassian/bitbucket/server/projects/__init__.py +2 -1
- atlassian/bitbucket/server/projects/repos/__init__.py +1 -0
- atlassian/confluence/__init__.py +54 -4106
- atlassian/confluence/base.py +195 -0
- atlassian/confluence/cloud/__init__.py +354 -0
- atlassian/confluence/cloud/base.py +25 -0
- atlassian/confluence/cloud/cloud.py +2480 -0
- atlassian/confluence/server/__init__.py +3988 -0
- atlassian/confluence/server/base.py +25 -0
- atlassian/confluence/server/confluence_server.py +28 -0
- atlassian/confluence_base.py +281 -0
- atlassian/confluence_v2.py +7 -0
- atlassian/crowd.py +1 -1
- atlassian/insight.py +3 -2
- atlassian/jira.py +309 -16
- atlassian/jira_models.py +10 -0
- atlassian/models/__init__.py +5 -0
- atlassian/models/jira/__init__.py +109 -0
- atlassian/models/jira/adf.py +178 -0
- atlassian/models/jira/builders.py +272 -0
- atlassian/models/jira/comment.py +52 -0
- atlassian/models/jira/fields.py +236 -0
- atlassian/models/jira/issues.py +101 -0
- atlassian/models/jira/serializer.py +138 -0
- atlassian/models/jira/transition.py +78 -0
- atlassian/models/jira/update.py +179 -0
- atlassian/models/jira/validation.py +56 -0
- atlassian/models/py.typed +0 -0
- atlassian/rest_client.py +81 -15
- atlassian/service_desk.py +41 -1
- atlassian/statuspage.py +7 -6
- atlassian/tempo/__init__.py +14 -0
- atlassian/tempo/cloud/__init__.py +232 -0
- atlassian/tempo/cloud/base.py +38 -0
- atlassian/tempo/server/__init__.py +78 -0
- atlassian/tempo/server/accounts.py +38 -0
- atlassian/tempo/server/base.py +50 -0
- atlassian/tempo/server/budgets.py +42 -0
- atlassian/tempo/server/events.py +52 -0
- atlassian/tempo/server/planner.py +42 -0
- atlassian/tempo/server/servlet.py +46 -0
- atlassian/tempo/server/teams.py +50 -0
- atlassian/tempo/server/timesheets.py +54 -0
- atlassian/typehints.py +14 -2
- atlassian/xray.py +2 -0
- {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.0.dist-info}/METADATA +45 -5
- atlassian_python_api-5.0.0.dist-info/RECORD +92 -0
- {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.0.dist-info}/WHEEL +1 -1
- atlassian_python_api-4.0.7.dist-info/RECORD +0 -58
- {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.0.dist-info}/licenses/LICENSE +0 -0
- {atlassian_python_api-4.0.7.dist-info → atlassian_python_api-5.0.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
import copy
|
|
4
|
+
from urllib.parse import urlparse
|
|
5
|
+
import logging
|
|
6
|
+
from requests import HTTPError
|
|
7
|
+
from ..rest_client import AtlassianRestAPI
|
|
8
|
+
|
|
9
|
+
log = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ConfluenceBase(AtlassianRestAPI):
|
|
13
|
+
"""
|
|
14
|
+
Base class for Confluence API operations.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
@staticmethod
|
|
18
|
+
def _is_cloud_url(url):
|
|
19
|
+
"""Compatibility proxy for the version-aware Confluence base class."""
|
|
20
|
+
from ..confluence_base import ConfluenceBase as VersionedConfluenceBase
|
|
21
|
+
|
|
22
|
+
return VersionedConfluenceBase._is_cloud_url(url)
|
|
23
|
+
|
|
24
|
+
def __init__(self, url, *args, **kwargs):
|
|
25
|
+
"""
|
|
26
|
+
Init the rest api wrapper
|
|
27
|
+
|
|
28
|
+
:param url: string: The base url used for the rest api.
|
|
29
|
+
:param *args: list: The fixed arguments for the AtlassianRestApi.
|
|
30
|
+
:param **kwargs: dict: The keyword arguments for the AtlassianRestApi.
|
|
31
|
+
|
|
32
|
+
:return: nothing
|
|
33
|
+
"""
|
|
34
|
+
self._update_data(kwargs.pop("data", {}))
|
|
35
|
+
if url is None:
|
|
36
|
+
url = self.get_link("self")
|
|
37
|
+
if isinstance(url, list): # Server has a list of links
|
|
38
|
+
url = url[0]
|
|
39
|
+
super().__init__(url, *args, **kwargs)
|
|
40
|
+
|
|
41
|
+
def _sub_url(self, url):
|
|
42
|
+
"""
|
|
43
|
+
Get the full url from a relative one.
|
|
44
|
+
|
|
45
|
+
:param url: string: The sub url
|
|
46
|
+
:return: The absolute url
|
|
47
|
+
"""
|
|
48
|
+
return self.url_joiner(self.url, url)
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def _new_session_args(self):
|
|
52
|
+
"""
|
|
53
|
+
Get the kwargs for new objects (session, root, version,...).
|
|
54
|
+
|
|
55
|
+
:return: A dict with the kwargs for new objects
|
|
56
|
+
"""
|
|
57
|
+
return {
|
|
58
|
+
"session": self._session,
|
|
59
|
+
"cloud": self.cloud,
|
|
60
|
+
"api_root": self.api_root,
|
|
61
|
+
"api_version": self.api_version,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
def _update_data(self, data):
|
|
65
|
+
"""
|
|
66
|
+
Internal function to update the data.
|
|
67
|
+
|
|
68
|
+
:param data: dict: The new data.
|
|
69
|
+
:return: The updated object
|
|
70
|
+
"""
|
|
71
|
+
self.__data = data
|
|
72
|
+
return self
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def data(self):
|
|
76
|
+
"""
|
|
77
|
+
Get the internal cached data. For data integrity a deep copy is returned.
|
|
78
|
+
|
|
79
|
+
:return: A copy of the data cache
|
|
80
|
+
"""
|
|
81
|
+
return copy.copy(self.__data)
|
|
82
|
+
|
|
83
|
+
def get_data(self, id, default=None):
|
|
84
|
+
"""
|
|
85
|
+
Get a data element from the internal data cache. For data integrity a deep copy is returned.
|
|
86
|
+
If data isn't present, the default value is returned.
|
|
87
|
+
|
|
88
|
+
:param id: string: The data element to return
|
|
89
|
+
:param default: any (default is None): The value to return if id is not present
|
|
90
|
+
|
|
91
|
+
:return: The requested data element
|
|
92
|
+
"""
|
|
93
|
+
return copy.copy(self.__data[id]) if id in self.__data else default
|
|
94
|
+
|
|
95
|
+
def get_link(self, link):
|
|
96
|
+
"""
|
|
97
|
+
Get a link from the data.
|
|
98
|
+
|
|
99
|
+
:param link: string: The link identifier
|
|
100
|
+
:return: The requested link or None if it isn't present
|
|
101
|
+
"""
|
|
102
|
+
links = self.get_data("links")
|
|
103
|
+
if links is None or link not in links:
|
|
104
|
+
return None
|
|
105
|
+
return links[link]["href"]
|
|
106
|
+
|
|
107
|
+
def _get_paged(
|
|
108
|
+
self,
|
|
109
|
+
url,
|
|
110
|
+
params=None,
|
|
111
|
+
data=None,
|
|
112
|
+
flags=None,
|
|
113
|
+
trailing=None,
|
|
114
|
+
absolute=False,
|
|
115
|
+
):
|
|
116
|
+
"""
|
|
117
|
+
Used to get the paged data
|
|
118
|
+
|
|
119
|
+
:param url: string: The url to retrieve
|
|
120
|
+
:param params: dict (default is None): The parameter's
|
|
121
|
+
:param data: dict (default is None): The data
|
|
122
|
+
:param flags: string[] (default is None): The flags
|
|
123
|
+
:param trailing: bool (default is None): If True, a trailing slash is added to the url
|
|
124
|
+
:param absolute: bool (default is False): If True, the url is used absolute and not relative to the root
|
|
125
|
+
|
|
126
|
+
:return: A generator object for the data elements
|
|
127
|
+
"""
|
|
128
|
+
if params is None:
|
|
129
|
+
params = {}
|
|
130
|
+
|
|
131
|
+
while True:
|
|
132
|
+
response = self.get(
|
|
133
|
+
url,
|
|
134
|
+
trailing=trailing,
|
|
135
|
+
params=params,
|
|
136
|
+
data=data,
|
|
137
|
+
flags=flags,
|
|
138
|
+
absolute=absolute,
|
|
139
|
+
)
|
|
140
|
+
if "results" not in response:
|
|
141
|
+
return
|
|
142
|
+
|
|
143
|
+
yield from response.get("results", [])
|
|
144
|
+
|
|
145
|
+
next_link = response.get("_links", {}).get("next")
|
|
146
|
+
if next_link is None:
|
|
147
|
+
break
|
|
148
|
+
if isinstance(next_link, str):
|
|
149
|
+
url = next_link
|
|
150
|
+
else:
|
|
151
|
+
url = next_link.get("href")
|
|
152
|
+
if url is None:
|
|
153
|
+
break
|
|
154
|
+
|
|
155
|
+
if url.startswith("/"):
|
|
156
|
+
# Relative URL from Confluence Server: prepend scheme+host from self.url
|
|
157
|
+
parsed = urlparse(self.url)
|
|
158
|
+
url = f"{parsed.scheme}://{parsed.netloc}{url}"
|
|
159
|
+
|
|
160
|
+
# From now on we have absolute URLs with parameters
|
|
161
|
+
absolute = True
|
|
162
|
+
# Params are now provided by the url
|
|
163
|
+
params = {}
|
|
164
|
+
# Trailing should not be added as it is already part of the url
|
|
165
|
+
trailing = False
|
|
166
|
+
|
|
167
|
+
return
|
|
168
|
+
|
|
169
|
+
def raise_for_status(self, response):
|
|
170
|
+
"""
|
|
171
|
+
Checks the response for errors and throws an exception if return code >= 400
|
|
172
|
+
|
|
173
|
+
Implementation for Confluence Server according to
|
|
174
|
+
https://developer.atlassian.com/server/confluence/rest/v1002/intro/#about
|
|
175
|
+
Implementation for Confluence Cloud according to
|
|
176
|
+
https://developer.atlassian.com/cloud/confluence/rest/v2/intro/#about
|
|
177
|
+
:param response:
|
|
178
|
+
:return:
|
|
179
|
+
"""
|
|
180
|
+
if 400 <= response.status_code < 600:
|
|
181
|
+
try:
|
|
182
|
+
j = response.json()
|
|
183
|
+
if "message" in j:
|
|
184
|
+
error_msg = j["message"]
|
|
185
|
+
if "detail" in j:
|
|
186
|
+
error_msg = f"{error_msg}\n{str(j['detail'])}"
|
|
187
|
+
else:
|
|
188
|
+
error_msg = f"HTTP {response.status_code}: {response.reason}"
|
|
189
|
+
except Exception as e:
|
|
190
|
+
log.error(e)
|
|
191
|
+
response.raise_for_status()
|
|
192
|
+
else:
|
|
193
|
+
raise HTTPError(error_msg, response=response)
|
|
194
|
+
else:
|
|
195
|
+
response.raise_for_status()
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from .base import ConfluenceCloudBase
|
|
5
|
+
from requests import HTTPError
|
|
6
|
+
from atlassian.errors import (
|
|
7
|
+
ApiError,
|
|
8
|
+
)
|
|
9
|
+
from .cloud import ConfluenceCloud # noqa: F401
|
|
10
|
+
|
|
11
|
+
log = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Cloud(ConfluenceCloudBase):
|
|
15
|
+
"""
|
|
16
|
+
Confluence Cloud REST API wrapper
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, url="https://api.atlassian.com/", *args, **kwargs):
|
|
20
|
+
# Set default values only if not provided
|
|
21
|
+
if "cloud" not in kwargs:
|
|
22
|
+
kwargs["cloud"] = True
|
|
23
|
+
if "api_version" not in kwargs:
|
|
24
|
+
kwargs["api_version"] = "2"
|
|
25
|
+
if "api_root" not in kwargs:
|
|
26
|
+
kwargs["api_root"] = "wiki/api/v2"
|
|
27
|
+
url = url.strip("/")
|
|
28
|
+
super(Cloud, self).__init__(url, *args, **kwargs)
|
|
29
|
+
|
|
30
|
+
# Content Management
|
|
31
|
+
def get_content(self, content_id, **kwargs):
|
|
32
|
+
"""Get content by ID."""
|
|
33
|
+
return self.get(f"content/{content_id}", **kwargs)
|
|
34
|
+
|
|
35
|
+
def get_content_by_type(self, content_type, **kwargs):
|
|
36
|
+
"""Get content by type (page, blogpost, etc.)."""
|
|
37
|
+
return self.get("content", params={"type": content_type, **kwargs})
|
|
38
|
+
|
|
39
|
+
def get_all_pages_from_space(self, space_key, **kwargs):
|
|
40
|
+
"""Get all pages from space."""
|
|
41
|
+
return self._get_paged("content", params={"spaceKey": space_key, "type": "page", **kwargs})
|
|
42
|
+
|
|
43
|
+
def get_all_blog_posts_from_space(self, space_key, **kwargs):
|
|
44
|
+
"""Get all blog posts from space."""
|
|
45
|
+
return self._get_paged("content", params={"spaceKey": space_key, "type": "blogpost", **kwargs})
|
|
46
|
+
|
|
47
|
+
def create_content(self, data, **kwargs):
|
|
48
|
+
"""Create new content."""
|
|
49
|
+
return self.post("content", data=data, **kwargs)
|
|
50
|
+
|
|
51
|
+
def update_content(self, content_id, data, **kwargs):
|
|
52
|
+
"""Update existing content."""
|
|
53
|
+
return self.put(f"content/{content_id}", data=data, **kwargs)
|
|
54
|
+
|
|
55
|
+
def delete_content(self, content_id, **kwargs):
|
|
56
|
+
"""Delete content."""
|
|
57
|
+
return self.delete(f"content/{content_id}", **kwargs)
|
|
58
|
+
|
|
59
|
+
def get_content_children(self, content_id, **kwargs):
|
|
60
|
+
"""Get child content."""
|
|
61
|
+
return self.get(f"content/{content_id}/children", **kwargs)
|
|
62
|
+
|
|
63
|
+
def get_content_descendants(self, content_id, **kwargs):
|
|
64
|
+
"""Get descendant content."""
|
|
65
|
+
return self.get(f"content/{content_id}/descendants", **kwargs)
|
|
66
|
+
|
|
67
|
+
def get_child_pages(self, content_id, **kwargs):
|
|
68
|
+
"""Get child pages of a content item."""
|
|
69
|
+
return self.get(f"content/{content_id}/child/page", **kwargs)
|
|
70
|
+
|
|
71
|
+
def get_descendant_pages(self, content_id, **kwargs):
|
|
72
|
+
"""Get all descendant pages of a content item."""
|
|
73
|
+
return self.get(f"content/{content_id}/descendant/page", **kwargs)
|
|
74
|
+
|
|
75
|
+
def get_content_ancestors(self, content_id, **kwargs):
|
|
76
|
+
"""Get ancestor content."""
|
|
77
|
+
return self.get(f"content/{content_id}/ancestors", **kwargs)
|
|
78
|
+
|
|
79
|
+
def get_page_by_title(self, space_key, title, **kwargs):
|
|
80
|
+
"""Get page by title and space key."""
|
|
81
|
+
return self.get("content", params={"spaceKey": space_key, "title": title, "type": "page", **kwargs})
|
|
82
|
+
|
|
83
|
+
def get_blog_post_by_title(self, space_key, title, **kwargs):
|
|
84
|
+
"""Get blog post by title and space key."""
|
|
85
|
+
return self.get("content", params={"spaceKey": space_key, "title": title, "type": "blogpost", **kwargs})
|
|
86
|
+
|
|
87
|
+
def blog_post_exists(self, space_key, title, **kwargs):
|
|
88
|
+
"""Check if blog post exists."""
|
|
89
|
+
result = self.get_blog_post_by_title(space_key, title, **kwargs)
|
|
90
|
+
return len(result.get("results", [])) > 0
|
|
91
|
+
|
|
92
|
+
def page_exists(self, space_key, title, **kwargs):
|
|
93
|
+
"""Check if page exists in Confluence Cloud."""
|
|
94
|
+
result = self.get_page_by_title(space_key, title, **kwargs)
|
|
95
|
+
return len(result.get("results", [])) > 0
|
|
96
|
+
|
|
97
|
+
def get_page_child_by_type(self, page_id, type="page", start=None, limit=None, expand=None):
|
|
98
|
+
"""
|
|
99
|
+
Provide content by type (page, blog, comment)
|
|
100
|
+
:param page_id: A string containing the id of the type content container.
|
|
101
|
+
:param type:
|
|
102
|
+
:param start: OPTIONAL: The start point of the collection to return. Default: None (0).
|
|
103
|
+
:param limit: OPTIONAL: how many items should be returned after the start index. Default: Site limit 200.
|
|
104
|
+
:param expand: OPTIONAL: expand e.g. history
|
|
105
|
+
:return:
|
|
106
|
+
"""
|
|
107
|
+
params = {}
|
|
108
|
+
if start is not None:
|
|
109
|
+
params["start"] = int(start)
|
|
110
|
+
if limit is not None:
|
|
111
|
+
params["limit"] = int(limit)
|
|
112
|
+
if expand is not None:
|
|
113
|
+
params["expand"] = expand
|
|
114
|
+
|
|
115
|
+
url = f"rest/api/content/{page_id}/child/{type}"
|
|
116
|
+
log.info(url)
|
|
117
|
+
|
|
118
|
+
try:
|
|
119
|
+
if not self.advanced_mode and start is None and limit is None:
|
|
120
|
+
return self._get_paged(url, params=params)
|
|
121
|
+
else:
|
|
122
|
+
response = self.get(url, params=params)
|
|
123
|
+
if self.advanced_mode:
|
|
124
|
+
return response
|
|
125
|
+
return response.get("results")
|
|
126
|
+
except HTTPError as e:
|
|
127
|
+
if e.response.status_code == 404:
|
|
128
|
+
# Raise ApiError as the documented reason is ambiguous
|
|
129
|
+
raise ApiError(
|
|
130
|
+
"There is no content with the given id, "
|
|
131
|
+
"or the calling user does not have permission to view the content",
|
|
132
|
+
reason=e,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
raise
|
|
136
|
+
|
|
137
|
+
def get_child_title_list(self, page_id, type="page", start=None, limit=None):
|
|
138
|
+
"""
|
|
139
|
+
Find a list of Child title
|
|
140
|
+
:param page_id: A string containing the id of the type content container.
|
|
141
|
+
:param type:
|
|
142
|
+
:param start: OPTIONAL: The start point of the collection to return. Default: None (0).
|
|
143
|
+
:param limit: OPTIONAL: how many items should be returned after the start index. Default: Site limit 200.
|
|
144
|
+
:return:
|
|
145
|
+
"""
|
|
146
|
+
child_page = self.get_page_child_by_type(page_id, type, start, limit)
|
|
147
|
+
child_title_list = [child["title"] for child in child_page]
|
|
148
|
+
return child_title_list
|
|
149
|
+
|
|
150
|
+
def get_child_id_list(self, page_id, type="page", start=None, limit=None):
|
|
151
|
+
"""
|
|
152
|
+
Find a list of Child id
|
|
153
|
+
:param page_id: A string containing the id of the type content container.
|
|
154
|
+
:param type:
|
|
155
|
+
:param start: OPTIONAL: The start point of the collection to return. Default: None (0).
|
|
156
|
+
:param limit: OPTIONAL: how many items should be returned after the start index. Default: Site limit 200.
|
|
157
|
+
:return:
|
|
158
|
+
"""
|
|
159
|
+
child_page = self.get_page_child_by_type(page_id, type, start, limit)
|
|
160
|
+
child_id_list = [child["id"] for child in child_page]
|
|
161
|
+
return child_id_list
|
|
162
|
+
|
|
163
|
+
# Space Management
|
|
164
|
+
def get_spaces(self, **kwargs):
|
|
165
|
+
"""
|
|
166
|
+
Get all spaces (single page).
|
|
167
|
+
|
|
168
|
+
Calls the Confluence Cloud v2 endpoint ``/wiki/api/v2/spaces``.
|
|
169
|
+
For paginated enumeration of every space, use :meth:`get_all_spaces`.
|
|
170
|
+
"""
|
|
171
|
+
return self.get("spaces", **kwargs)
|
|
172
|
+
|
|
173
|
+
def get_all_spaces(self, **kwargs):
|
|
174
|
+
"""
|
|
175
|
+
Get all spaces with full pagination.
|
|
176
|
+
|
|
177
|
+
Returns a generator yielding each space dict from the Confluence Cloud
|
|
178
|
+
v2 endpoint ``/wiki/api/v2/spaces``. Replaces the legacy v1
|
|
179
|
+
``get_all_spaces`` (which hit ``/rest/api/space``) — that endpoint is
|
|
180
|
+
not available on the OAuth API gateway and returns
|
|
181
|
+
``GoneException: This deprecated endpoint has been removed``.
|
|
182
|
+
"""
|
|
183
|
+
return self._get_paged("spaces", params=kwargs)
|
|
184
|
+
|
|
185
|
+
def get_space(self, space_id, **kwargs):
|
|
186
|
+
"""Get space by ID."""
|
|
187
|
+
return self.get(f"spaces/{space_id}", **kwargs)
|
|
188
|
+
|
|
189
|
+
def create_space(self, data, **kwargs):
|
|
190
|
+
"""Create new space."""
|
|
191
|
+
return self.post("spaces", data=data, **kwargs)
|
|
192
|
+
|
|
193
|
+
def update_space(self, space_id, data, **kwargs):
|
|
194
|
+
"""Update existing space."""
|
|
195
|
+
return self.put(f"spaces/{space_id}", data=data, **kwargs)
|
|
196
|
+
|
|
197
|
+
def delete_space(self, space_id, **kwargs):
|
|
198
|
+
"""Delete space."""
|
|
199
|
+
return self.delete(f"spaces/{space_id}", **kwargs)
|
|
200
|
+
|
|
201
|
+
def get_space_content(self, space_id, **kwargs):
|
|
202
|
+
"""Get space content."""
|
|
203
|
+
return self.get(f"spaces/{space_id}/content", **kwargs)
|
|
204
|
+
|
|
205
|
+
# User Management
|
|
206
|
+
def get_users(self, **kwargs):
|
|
207
|
+
"""Get all users."""
|
|
208
|
+
return self.get("user", **kwargs)
|
|
209
|
+
|
|
210
|
+
def get_user(self, user_id, **kwargs):
|
|
211
|
+
"""Get user by ID."""
|
|
212
|
+
return self.get(f"user/{user_id}", **kwargs)
|
|
213
|
+
|
|
214
|
+
def get_current_user(self, **kwargs):
|
|
215
|
+
"""Get current user."""
|
|
216
|
+
return self.get("user/current", **kwargs)
|
|
217
|
+
|
|
218
|
+
# Group Management
|
|
219
|
+
def get_groups(self, **kwargs):
|
|
220
|
+
"""Get all groups."""
|
|
221
|
+
return self.get("group", **kwargs)
|
|
222
|
+
|
|
223
|
+
def get_group(self, group_id, **kwargs):
|
|
224
|
+
"""Get group by ID."""
|
|
225
|
+
return self.get(f"group/{group_id}", **kwargs)
|
|
226
|
+
|
|
227
|
+
def get_group_members(self, group_id, **kwargs):
|
|
228
|
+
"""Get group members."""
|
|
229
|
+
return self.get(f"group/{group_id}/member", **kwargs)
|
|
230
|
+
|
|
231
|
+
# Label Management
|
|
232
|
+
def get_labels(self, **kwargs):
|
|
233
|
+
"""Get all labels."""
|
|
234
|
+
return self.get("label", **kwargs)
|
|
235
|
+
|
|
236
|
+
def get_content_labels(self, content_id, **kwargs):
|
|
237
|
+
"""Get content labels."""
|
|
238
|
+
return self.get(f"content/{content_id}/label", **kwargs)
|
|
239
|
+
|
|
240
|
+
def add_content_labels(self, content_id, data, **kwargs):
|
|
241
|
+
"""Add labels to content."""
|
|
242
|
+
return self.post(f"content/{content_id}/label", data=data, **kwargs)
|
|
243
|
+
|
|
244
|
+
def remove_content_label(self, content_id, label_id, **kwargs):
|
|
245
|
+
"""Remove label from content."""
|
|
246
|
+
return self.delete(f"content/{content_id}/label/{label_id}", **kwargs)
|
|
247
|
+
|
|
248
|
+
# Attachment Management
|
|
249
|
+
def get_attachments(self, content_id, **kwargs):
|
|
250
|
+
"""Get content attachments."""
|
|
251
|
+
return self.get(f"content/{content_id}/child/attachment", **kwargs)
|
|
252
|
+
|
|
253
|
+
def get_attachment(self, attachment_id, **kwargs):
|
|
254
|
+
"""Get attachment by ID."""
|
|
255
|
+
return self.get(f"content/{attachment_id}", **kwargs)
|
|
256
|
+
|
|
257
|
+
def create_attachment(self, content_id, data, **kwargs):
|
|
258
|
+
"""Create new attachment."""
|
|
259
|
+
return self.post(f"content/{content_id}/child/attachment", data=data, **kwargs)
|
|
260
|
+
|
|
261
|
+
def update_attachment(self, attachment_id, data, **kwargs):
|
|
262
|
+
"""Update existing attachment."""
|
|
263
|
+
return self.put(f"content/{attachment_id}", data=data, **kwargs)
|
|
264
|
+
|
|
265
|
+
def delete_attachment(self, attachment_id, **kwargs):
|
|
266
|
+
"""Delete attachment."""
|
|
267
|
+
return self.delete(f"content/{attachment_id}", **kwargs)
|
|
268
|
+
|
|
269
|
+
# Comment Management
|
|
270
|
+
def get_comments(self, content_id, **kwargs):
|
|
271
|
+
"""Get content comments."""
|
|
272
|
+
return self.get(f"content/{content_id}/child/comment", **kwargs)
|
|
273
|
+
|
|
274
|
+
def get_comment(self, comment_id, **kwargs):
|
|
275
|
+
"""Get comment by ID."""
|
|
276
|
+
return self.get(f"content/{comment_id}", **kwargs)
|
|
277
|
+
|
|
278
|
+
def create_comment(self, content_id, data, **kwargs):
|
|
279
|
+
"""Create new comment."""
|
|
280
|
+
return self.post(f"content/{content_id}/child/comment", data=data, **kwargs)
|
|
281
|
+
|
|
282
|
+
def update_comment(self, comment_id, data, **kwargs):
|
|
283
|
+
"""Update existing comment."""
|
|
284
|
+
return self.put(f"content/{comment_id}", data=data, **kwargs)
|
|
285
|
+
|
|
286
|
+
def delete_comment(self, comment_id, **kwargs):
|
|
287
|
+
"""Delete comment."""
|
|
288
|
+
return self.delete(f"content/{comment_id}", **kwargs)
|
|
289
|
+
|
|
290
|
+
# Search
|
|
291
|
+
def search_content(self, query, **kwargs):
|
|
292
|
+
"""Search content."""
|
|
293
|
+
return self.get("content/search", params={"cql": query, **kwargs})
|
|
294
|
+
|
|
295
|
+
def search_spaces(self, query, **kwargs):
|
|
296
|
+
"""Search spaces."""
|
|
297
|
+
return self.get("space/search", params={"query": query, **kwargs})
|
|
298
|
+
|
|
299
|
+
# Page Properties
|
|
300
|
+
def get_content_properties(self, content_id, **kwargs):
|
|
301
|
+
"""Get content properties."""
|
|
302
|
+
return self.get(f"content/{content_id}/property", **kwargs)
|
|
303
|
+
|
|
304
|
+
def get_content_property(self, content_id, property_key, **kwargs):
|
|
305
|
+
"""Get content property by key."""
|
|
306
|
+
return self.get(f"content/{content_id}/property/{property_key}", **kwargs)
|
|
307
|
+
|
|
308
|
+
def create_content_property(self, content_id, data, **kwargs):
|
|
309
|
+
"""Create new content property."""
|
|
310
|
+
return self.post(f"content/{content_id}/property", data=data, **kwargs)
|
|
311
|
+
|
|
312
|
+
def update_content_property(self, content_id, property_key, data, **kwargs):
|
|
313
|
+
"""Update existing content property."""
|
|
314
|
+
return self.put(f"content/{content_id}/property/{property_key}", data=data, **kwargs)
|
|
315
|
+
|
|
316
|
+
def delete_content_property(self, content_id, property_key, **kwargs):
|
|
317
|
+
"""Delete content property."""
|
|
318
|
+
return self.delete(f"content/{content_id}/property/{property_key}", **kwargs)
|
|
319
|
+
|
|
320
|
+
# Templates
|
|
321
|
+
def get_templates(self, **kwargs):
|
|
322
|
+
"""Get all templates."""
|
|
323
|
+
return self.get("template", **kwargs)
|
|
324
|
+
|
|
325
|
+
def get_template(self, template_id, **kwargs):
|
|
326
|
+
"""Get template by ID."""
|
|
327
|
+
return self.get(f"template/{template_id}", **kwargs)
|
|
328
|
+
|
|
329
|
+
# Analytics
|
|
330
|
+
def get_content_analytics(self, content_id, **kwargs):
|
|
331
|
+
"""Get content analytics."""
|
|
332
|
+
return self.get(f"content/{content_id}/analytics", **kwargs)
|
|
333
|
+
|
|
334
|
+
def get_space_analytics(self, space_id, **kwargs):
|
|
335
|
+
"""Get space analytics."""
|
|
336
|
+
return self.get(f"space/{space_id}/analytics", **kwargs)
|
|
337
|
+
|
|
338
|
+
# Export
|
|
339
|
+
def export_content(self, content_id, **kwargs):
|
|
340
|
+
"""Export content."""
|
|
341
|
+
return self.get(f"content/{content_id}/export", **kwargs)
|
|
342
|
+
|
|
343
|
+
def export_space(self, space_id, **kwargs):
|
|
344
|
+
"""Export space."""
|
|
345
|
+
return self.get(f"space/{space_id}/export", **kwargs)
|
|
346
|
+
|
|
347
|
+
# Utility Methods
|
|
348
|
+
def get_metadata(self, **kwargs):
|
|
349
|
+
"""Get API metadata."""
|
|
350
|
+
return self.get("metadata", **kwargs)
|
|
351
|
+
|
|
352
|
+
def get_health(self, **kwargs):
|
|
353
|
+
"""Get API health status."""
|
|
354
|
+
return self.get("health", **kwargs)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
from ..base import ConfluenceBase
|
|
6
|
+
|
|
7
|
+
log = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ConfluenceCloudBase(ConfluenceBase):
|
|
11
|
+
"""
|
|
12
|
+
Base class for Confluence Cloud API operations.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, url, *args, **kwargs):
|
|
16
|
+
"""
|
|
17
|
+
Init the rest api wrapper
|
|
18
|
+
|
|
19
|
+
:param url: string: The base url used for the rest api.
|
|
20
|
+
:param *args: list: The fixed arguments for the AtlassianRestApi.
|
|
21
|
+
:param **kwargs: dict: The keyword arguments for the AtlassianRestApi.
|
|
22
|
+
|
|
23
|
+
:return: nothing
|
|
24
|
+
"""
|
|
25
|
+
super(ConfluenceCloudBase, self).__init__(url, *args, **kwargs)
|