Skip to content

Commit

Permalink
Confluence: add collaborative editing methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gonchik committed Feb 24, 2023
1 parent 827de3d commit d11bbb1
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 8 deletions.
106 changes: 98 additions & 8 deletions atlassian/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@
from requests import HTTPError
from deprecated import deprecated
from atlassian import utils
from .errors import (
ApiError,
ApiNotFoundError,
ApiPermissionError,
ApiValueError,
ApiConflictError,
)
from .errors import ApiError, ApiNotFoundError, ApiPermissionError, ApiValueError, ApiConflictError, ApiNotAcceptable
from .rest_client import AtlassianRestAPI

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -1572,17 +1566,18 @@ def update_existing_page(
representation="storage",
minor_edit=False,
version_comment=None,
full_width=False,
):
"""Duplicate update_page. Left for the people who used it before. Use update_page instead"""
return self.update_page(
page_id=page_id,
title=title,
body=body,
parent_id=None,
type=type,
representation=representation,
minor_edit=minor_edit,
version_comment=version_comment,
full_width=full_width,
)

def update_page(
Expand Down Expand Up @@ -2943,6 +2938,101 @@ def clean_jira_metadata_cache(self, global_id):
params = {"globalId": global_id}
return self.delete(url, params=params)

# Collaborative editing
def collaborative_editing_get_configuration(self):
"""
Get collaborative editing configuration
Related to the on-prem setup Confluence Data Center
:return:
"""
if self.cloud:
return ApiNotAcceptable
url = "rest/synchrony-interop/configuration"
return self.get(url, headers=self.no_check_headers)

def collaborative_editing_disable(self):
"""
Disable collaborative editing
Related to the on-prem setup Confluence Data Center
:return:
"""
if self.cloud:
return ApiNotAcceptable
url = "rest/synchrony-interop/disable"
return self.post(url, headers=self.no_check_headers)

def collaborative_editing_enable(self):
"""
Disable collaborative editing
Related to the on-prem setup Confluence Data Center
:return:
"""
if self.cloud:
return ApiNotAcceptable
url = "rest/synchrony-interop/enable"
return self.post(url, headers=self.no_check_headers)

def collaborative_editing_restart(self):
"""
Disable collaborative editing
Related to the on-prem setup Confluence Data Center
:return:
"""
if self.cloud:
return ApiNotAcceptable
url = "rest/synchrony-interop/restart"
return self.post(url, headers=self.no_check_headers)

def collaborative_editing_shared_draft_status(self):
"""
Status of collaborative editing
Related to the on-prem setup Confluence Data Center
:return: false or true parameter in json
{
"sharedDraftsEnabled": false
}
"""
if self.cloud:
return ApiNotAcceptable
url = "rest/synchrony-interop/status"
return self.get(url, headers=self.no_check_headers)

def collaborative_editing_synchrony_status(self):
"""
Status of collaborative editing
Related to the on-prem setup Confluence Data Center
:return: stopped or running parameter in json
{
"status": "stopped"
}
"""
if self.cloud:
return ApiNotAcceptable
url = "rest/synchrony-interop/synchrony-status"
return self.get(url, headers=self.no_check_headers)

def synchrony_get_configuration(self):
"""
Status of collaborative editing
Related to the on-prem setup Confluence Data Center
:return:
"""
if self.cloud:
return ApiNotAcceptable
url = "rest/synchrony/1.0/config/status"
return self.get(url, headers=self.no_check_headers)

def synchrony_remove_draft(self, page_id):
"""
Status of collaborative editing
Related to the on-prem setup Confluence Data Center
:return:
"""
if self.cloud:
return ApiNotAcceptable
url = "rest/synchrony/1.0/content/{pageId}/changes/unpublished".format(pageId=page_id)
return self.delete(url)

def get_license_details(self):
"""
Returns the license detailed information
Expand Down
4 changes: 4 additions & 0 deletions atlassian/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ class ApiValueError(ApiError):

class ApiConflictError(ApiError):
pass


class ApiNotAcceptable(ApiError):
pass

0 comments on commit d11bbb1

Please sign in to comment.