12 tools for the new Confluence toolkit. | Name | Description | |----------------------------------|------------------------------------------------------------------------------------| | Confluence.CreatePage | Create a new page at the root of the given space. | | Confluence.UpdatePageContent | Update a page's content. | | Confluence.RenamePage | Rename a page by changing its title. | | Confluence.GetPage | Retrieve a SINGLE page's content by its ID or title. | | Confluence.GetPagesById | Get the content of MULTIPLE pages by their ID in a single efficient request. | | Confluence.ListPages | Get the content of multiple pages by their ID. | | Confluence.ListAttachments | List attachments in a workspace. | | Confluence.GetAttachmentsForPage | Get attachments for a page by its ID or title. | | Confluence.SearchContent | Search for content in Confluence. | | Confluence.GetSpace | Get the details of a space by its ID or key. | | Confluence.ListSpaces | List all spaces sorted by name in ascending order. | | Confluence.GetSpaceHierarchy | Retrieve the full hierarchical structure of a Confluence space as a tree structure.| ### Confluence Clients Confluence has deprecated most of their V1 endpoints, so most of the tools use V2. However, we still need a V1 client to support search. The V1 search API has not been deprecated yet, because there is no V2 equivalent. But we need to be aware in the future for when this deprecation happens. ### Future work * Content of pages are returned in the Confluence `storage` format. This is the format that Confluence uses to store pages internally. We should understand the storage format more deeply, and write utility function to transform this format into plain text. * Better protections against extremely large pages. I've tested up to 6,000 word pages. * Tools for blog posts * Tool for getting the children of a page. (`get_space_hierarchy` will suffice for now) * Allow for numerical titles
63 lines
2.4 KiB
Python
63 lines
2.4 KiB
Python
from enum import Enum
|
|
|
|
|
|
class BodyFormat(str, Enum):
|
|
STORAGE = "storage" # Storage representation for editing, with relative urls in the markup
|
|
|
|
def to_api_value(self) -> str:
|
|
mapping = {
|
|
BodyFormat.STORAGE: "storage",
|
|
}
|
|
return mapping.get(self, BodyFormat.STORAGE.value)
|
|
|
|
|
|
class PageUpdateMode(str, Enum):
|
|
"""The mode of update for a page"""
|
|
|
|
PREPEND = "prepend" # Add content to the beginning of the page.
|
|
APPEND = "append" # Add content to the end of the page.
|
|
REPLACE = "replace" # Replace the entire page with the new content.
|
|
|
|
|
|
class PageSortOrder(str, Enum):
|
|
"""The order of the pages to sort by"""
|
|
|
|
ID_ASCENDING = "id-ascending"
|
|
ID_DESCENDING = "id-descending"
|
|
TITLE_ASCENDING = "title-ascending"
|
|
TITLE_DESCENDING = "title-descending"
|
|
CREATED_DATE_ASCENDING = "created-date-oldest-to-newest"
|
|
CREATED_DATE_DESCENDING = "created-date-newest-to-oldest"
|
|
MODIFIED_DATE_ASCENDING = "modified-date-oldest-to-newest"
|
|
MODIFIED_DATE_DESCENDING = "modified-date-newest-to-oldest"
|
|
|
|
def to_api_value(self) -> str:
|
|
mapping = {
|
|
PageSortOrder.ID_ASCENDING: "id",
|
|
PageSortOrder.ID_DESCENDING: "-id",
|
|
PageSortOrder.TITLE_ASCENDING: "title",
|
|
PageSortOrder.TITLE_DESCENDING: "-title",
|
|
PageSortOrder.CREATED_DATE_ASCENDING: "created-date",
|
|
PageSortOrder.CREATED_DATE_DESCENDING: "-created-date",
|
|
PageSortOrder.MODIFIED_DATE_ASCENDING: "modified-date",
|
|
PageSortOrder.MODIFIED_DATE_DESCENDING: "-modified-date",
|
|
}
|
|
return mapping.get(self, PageSortOrder.CREATED_DATE_DESCENDING.value)
|
|
|
|
|
|
class AttachmentSortOrder(str, Enum):
|
|
"""The order of the attachments to sort by"""
|
|
|
|
CREATED_DATE_ASCENDING = "created-date-oldest-to-newest"
|
|
CREATED_DATE_DESCENDING = "created-date-newest-to-oldest"
|
|
MODIFIED_DATE_ASCENDING = "modified-date-oldest-to-newest"
|
|
MODIFIED_DATE_DESCENDING = "modified-date-newest-to-oldest"
|
|
|
|
def to_api_value(self) -> str:
|
|
mapping = {
|
|
AttachmentSortOrder.CREATED_DATE_ASCENDING: "created-date",
|
|
AttachmentSortOrder.CREATED_DATE_DESCENDING: "-created-date",
|
|
AttachmentSortOrder.MODIFIED_DATE_ASCENDING: "modified-date",
|
|
AttachmentSortOrder.MODIFIED_DATE_DESCENDING: "-modified-date",
|
|
}
|
|
return mapping.get(self, AttachmentSortOrder.CREATED_DATE_DESCENDING.value)
|