confluence ¤
admin ¤
client ¤
ConfluenceClient ¤
Bases: HttpClient
Helper methods for Confluence API.
Should not be used directly, be used by firefighter.confluence.service.ConfluenceService.
Source code in src/firefighter/confluence/client.py
models ¤
PostMortem ¤
RunbookFilterSet ¤
Bases: FilterSet
Set of filters for Runbooks.
RunbookManager ¤
Bases: Manager['Runbook']
search
staticmethod
¤
Parameters:
-
queryset
(QuerySet[Runbook] | None
) –Queryset to search in. If None, search in all incidents. The Queryset allows to search on a subset of Runbooks (already filtered).
-
search_term
(str
) –Search term.
Returns:
-
tuple[QuerySet[Runbook], bool]
–tuple[QuerySet[Runbook], bool]: Queryset of Runbooks matching the search term, and a boolean indicating if the search may contain duplicates objects.
Source code in src/firefighter/confluence/models.py
service ¤
ConfluenceService ¤
Provide methods to interact with Confluence, without regards to the underlying library or HTTP client used.
TODO: The service should provide Pythonic errors and return types, and should not leak the underlying library or Confluence errors. It is not a priority for now, as the Confluence API is not used in critical paths.
Source code in src/firefighter/confluence/service.py
base_url
class-attribute
instance-attribute
¤
Confluence base URL. (with /wiki
, without /rest/api
)
create_page ¤
create_page(title: str, parent_id: ConfluencePageId, body: str, space: str | None = None) -> ConfluencePage
TODO: Errors.
Parameters:
-
title
(str
) –Title of the page to create.
-
parent_id
(ConfluencePageId
) –Where to create the page. Will be a child of this page.
-
body
(str
) –Body of the page.
-
space
(str | None
, default:None
) –Space to create the page in. If None, defaults to theService's default space. Defaults to None.
Returns:
-
ConfluencePage
(ConfluencePage
) –The newly created page.
Source code in src/firefighter/confluence/service.py
create_postmortem ¤
Create a PostMortem page.
Parameters:
-
title
(str
) –Title of the PostMortem page.
Returns:
-
None | ConfluencePage
–None | ConfluencePage: The newly created page, or None if it failed.
Source code in src/firefighter/confluence/service.py
get_page ¤
TODO: Errors.
Parameters:
-
page_id
(ConfluencePageId
) –ID of the page to get.
Returns:
-
ConfluencePage
(ConfluencePage
) –The page.
Source code in src/firefighter/confluence/service.py
get_page_children_pages ¤
get_page_children_pages(page_id: ConfluencePageId, *args: Any, **kwargs: Any) -> list[ConfluencePage]
Get all children pages of a given page. TODO: testing.
Parameters:
-
page_id
(ConfluencePageId
) –ID of the page to get children pages from.
-
*args
(Any
, default:()
) –Arguments to pass to Confluence.
-
**kwargs
(Any
, default:{}
) –Keyword arguments to pass to Confluence.
Returns:
-
list[ConfluencePage]
–list[ConfluencePage]: list of children pages.
Source code in src/firefighter/confluence/service.py
get_page_descendant_pages ¤
get_page_descendant_pages(page_id: ConfluencePageId, *args: Any, **kwargs: Any) -> list[ConfluencePage]
Get all descendant (nested children) pages of a given page. TODO: Pagination support and testing.
Parameters:
-
page_id
(ConfluencePageId
) –ID of the page to get children pages from.
-
*args
(Any
, default:()
) –Arguments to pass to Confluence.
-
**kwargs
(Any
, default:{}
) –Keyword arguments to pass to Confluence.
Returns:
-
list[ConfluencePage]
–list[ConfluencePage]: list of children pages.
Source code in src/firefighter/confluence/service.py
move_page ¤
move_page(
page_id: ConfluencePageId,
target_page_id: ConfluencePageId,
position: Literal["before", "after", "append"] = "append",
*,
dry_run: bool = False
) -> None | ConfluencePage
Parameters:
-
page_id
(ConfluencePageId
) –ID of the page to move.
-
target_page_id
(ConfluencePageId
) –ID of the parent page to move the page in relation to.
-
position
(Literal['before', 'after', 'append']
, default:'append'
) –Where should the page be moved, in relation to the target page. Defaults to "append".
-
dry_run
(bool
, default:False
) –If True, will log instead of moving. Defaults to False.
Returns:
-
None | ConfluencePage
–None | ConfluencePage: The moved page, or None if it failed.
Source code in src/firefighter/confluence/service.py
parse_confluence_page ¤
Helper to parse a Confluence page into a PageInfo object.
Parameters:
-
pm
(dict[str, Any] | ConfluencePage
) –ConfluencePage from the API, or a dict with the same structure.
Returns:
-
PageInfo
(PageInfo
) –The parsed page details that are present on firefighter.confluence.models.ConfluencePage.
Raises:
-
TypeError
–If one of page_id, page_title, page_url or page_edit_url are not strings.
Source code in src/firefighter/confluence/service.py
sort_pages ¤
sort_pages(page_ids: list[tuple[ConfluencePageId, ConfluencePage]], *, dry_run: bool = False) -> None
Sort pages according to the list order.
Be careful: - this will move pages around, and will not check if the pages are already in the right order. - this will not check that the pages are in the same parent. - this will perform n moves, where n is the number of pages in the list.
Parameters:
-
page_ids
(list[tuple[ConfluencePageId, ConfluencePage]]
) –Sorted list of (PageId, Page) tuples.
-
dry_run
(bool
, default:False
) –If True, will log instead of sorting. Defaults to False.
Source code in src/firefighter/confluence/service.py
update_oncall_page ¤
Update the Confluence list of On-Call users, if the page needs to be updated. Users should have a SlackUser AND a PagerDutyUser associated.
Parameters:
Returns:
-
bool
(bool
) –has the page been updated?
Source code in src/firefighter/confluence/service.py
tasks ¤
archive_postmortems ¤
archive_and_sort_postmortems ¤
Archive postmortems that are older than 2 weeks, for incidents that are closed.
Parameters:
-
dry_run
(bool
, default:True
) –Should actions be performed? If True, Confluence will be accessed in read-only mode. Defaults to False.
Source code in src/firefighter/confluence/tasks/archive_postmortems.py
sort_postmortems_in_bins ¤
Sort postmortems in each quarter archive folder.
Parameters:
-
quarter_bins
(dict[str, int]
) –description
-
dry_run
(bool
, default:False
) –description. Defaults to False.
Source code in src/firefighter/confluence/tasks/archive_postmortems.py
sort_runbooks ¤
sort_runbooks ¤
Sort runbooks in Confluence.
Parameters:
-
dry_run
(bool
, default:False
) –Should actions be performed? If True, Confluence will be accessed in read-only mode. Defaults to False.
Source code in src/firefighter/confluence/tasks/sort_runbooks.py
sort_runbooks_in_folders ¤
Sort runbooks in each folder.
Parameters:
-
folders
(list[ConfluencePageId]
) –List of folders to sort runbooks in.
-
dry_run
(bool
, default:False
) –Do not perform the sort. Defaults to False.
Source code in src/firefighter/confluence/tasks/sort_runbooks.py
sync_pages_content ¤
sync_postmortems ¤
sync_runbooks ¤
urls ¤
utils ¤
PageInfo ¤
Bases: TypedDict
Dict mapped to mandatory fields for a firefighter.confluence.models.ConfluencePage.
parse_postmortem_title ¤
Parse postmortem title and return the date and quarter associated to this date, in the format YYYYQX.
Parameters:
-
title
(str
) –Title of the postmortem, in the format #YYYYMMDD-
- (SEV/P )
Returns:
-
tuple[datetime, str] | tuple[None, None]
–tuple[datetime, str] | tuple[None, None]: Date and quarter associated to this date.
Source code in src/firefighter/confluence/utils.py
parse_runbook_title ¤
Parse runbooks title and return the service name, or None if the title is not valid.
Useful to remove prefixes like [WIP] or [ARCHIVED] from the title, to sort runbooks.
Parameters:
-
title
(str
) –Title of the runbook
Returns:
-
str | None
–str | None: Service name or None if the title is not valid.