firefighter ¤
This is the main entrypoint for FireFighter.
Warning
This app does not contain any business logic. It is responsible for loading all the settings, providing common base features and tying together all the other apps.
Features¤
- Load all settings
- Provide
ASGI
andWSGI
entrypoints - Configure loggers
- Provide a Celery app
- Set the base URL routing
- Provides a
healthcheck
endpoint - Provide a
robots.txt
endpoint - Provides some utils
- Provides SSO integration
- Register the Django admin and customize its theme
apps ¤
asgi ¤
ASGI config for firefighter project.
It exposes the ASGI callable as a module-level variable named application
.
For more information on this file, see https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
fields_forms_widgets ¤
CustomCheckboxSelectMultiple ¤
Bases: CheckboxSelectMultiple
Custom template.
FFDateRangeSingleFilter ¤
Bases: Filter
TODO Fix typings, implement tests, move in proper location.
GroupedCheckboxSelectMultiple ¤
Bases: CustomCheckboxSelectMultiple
Widget to group checkboxes in a select multiple. TODO Make this generic!
optgroups ¤
optgroups(name: str, value: list[Any], attrs: dict[str, Any] | None = None) -> list[tuple[str | None, list[dict[str, Any]], int | None]]
Return a list of optgroups for this widget.
Source code in src/firefighter/firefighter/fields_forms_widgets.py
TextDateRangeField ¤
Bases: Field
to_python ¤
Validate date range. Field is optional.
Source code in src/firefighter/firefighter/fields_forms_widgets.py
filters ¤
Collection of custom Django template filters. They are added as built-in filters and thus can be used in templates of any app.
apply_filter ¤
apply_filter(value: Any, fn_holder: dict[Literal['filter_args', 'filter'], Callable[..., V]]) -> V | Any
Applies a filter function to a given value.
Parameters:
-
value
(Any
) –The value to be filtered.
-
fn_holder
(dict[Literal['filter_args', 'filter'], Callable[..., V]]
) –A dictionary containing the filter function and its arguments.
Returns:
-
V | Any
–The filtered value.
Source code in src/firefighter/firefighter/filters.py
get_item ¤
Get the value of a key from a dictionary or object.
Parameters:
-
dictionary
(dict[str, Any]
) –The dictionary or object to get the value from.
-
key
(Any
) –The key to get the value for.
Returns:
-
Any
(Any
) –The value of the key in the dictionary or object.
Source code in src/firefighter/firefighter/filters.py
markdown ¤
Converts markdown-formatted text to HTML.
Sanitize the HTML to only allow a subset of tags.
Parameters:
-
text
(str
) –The markdown-formatted text to convert.
Returns:
-
str
(str
) –The HTML-formatted text.
Source code in src/firefighter/firefighter/filters.py
readable_time_delta ¤
Format a time delta as a string. Ignore seconds and microseconds From https://github.com/wimglenn/readabledelta/blob/master/readabledelta.py (The Unlicense).
Source code in src/firefighter/firefighter/filters.py
timedelta_chop_microseconds ¤
Removes microseconds from a timedelta object.
Parameters:
-
delta
(timedelta
) –The timedelta object to remove microseconds from.
Returns:
-
timedelta
(timedelta
) –A new timedelta object with microseconds removed.
Source code in src/firefighter/firefighter/filters.py
formats ¤
See Django docs: https://docs.djangoproject.com/en/4.2/topics/i18n/formatting/ .
http_client ¤
HttpClient ¤
Base class for HTTP clients. Uses httpx under the hood.
Sets some defaults, including: - a timeout of 15 seconds for the connection and 20 seconds for the read, to avoid hanging indefinitely - access logging
Used by firefighter.confluence.client.ConfluenceClient.
Source code in src/firefighter/firefighter/http_client.py
settings ¤
This module define all the settings for the FireFighter project.
Warning
It should NOT be imported directly from any other module.
To use the settings, import them through Django's django.conf.settings object:
components ¤
api ¤
DRF_STANDARDIZED_ERRORS
module-attribute
¤
DRF_STANDARDIZED_ERRORS = {'ALLOWED_ERROR_STATUS_CODES': ['400', '401', '403', '404', '429', '500']}
Additional servers to add to the OpenAPI schema
celery ¤
Celery settings definition.
common ¤
Django settings for server project.
For more information on this file, see https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their config, see https://docs.djangoproject.com/en/4.2/ref/settings/
FF_DEBUG_ERROR_PAGES
module-attribute
¤
Add routes to display error pages. Useful for debugging.
FF_EXPOSE_API_DOCS
module-attribute
¤
Expose the API documentation. Useful for debugging. Can be a security issue.
FF_HTTP_CLIENT_ADDITIONAL_HEADERS
module-attribute
¤
Additional headers to send with every HTTP request made using our HttpClient. Useful for global auth, or adding a specific User-Agent.
FF_OVERRIDE_MENUS_CREATION
module-attribute
¤
Override the default menus creation. Useful for custom menus.
FF_ROLE_REMINDER_MIN_DAYS_INTERVAL
module-attribute
¤
FF_ROLE_REMINDER_MIN_DAYS_INTERVAL = config('FF_ROLE_REMINDER_MIN_DAYS_INTERVAL', default=90, cast=int)
Number of days between role explanation/reminders, for each role. -1 disable the messages, and 0 will send the message everytime.
FF_SKIP_SECRET_KEY_CHECK
module-attribute
¤
Skip the SECRET_KEY check. Make sure to set a strong SECRET_KEY in production.
FF_USER_ID_HEADER
module-attribute
¤
Header name to add to every HTTP request made using our HttpClient. Useful for logging.
confluence ¤
CONFLUENCE_API_KEY
module-attribute
¤
The Confluence API key to use.
CONFLUENCE_ON_CALL_PAGE_ID
module-attribute
¤
CONFLUENCE_ON_CALL_PAGE_ID: int | None = config('CONFLUENCE_ON_CALL_PAGE_ID', cast=int, default=None)
The Confluence page ID where to export the current on-call schedule. If not set, export tasks will be skipped.
CONFLUENCE_POSTMORTEM_FOLDER_ID
module-attribute
¤
The Confluence page ID where to create and nest postmortems.
CONFLUENCE_POSTMORTEM_SPACE
module-attribute
¤
XXX To rename CONFLUENCE_DEFAULT_SPACE. The Confluence space where to create pages by default, mainly for postmortems.
CONFLUENCE_POSTMORTEM_TEMPLATE_PAGE_ID
module-attribute
¤
CONFLUENCE_POSTMORTEM_TEMPLATE_PAGE_ID: int = config('CONFLUENCE_POSTMORTEM_TEMPLATE_PAGE_ID', cast=int)
The Confluence page ID of the template to use for postmortems.
CONFLUENCE_RUNBOOKS_FOLDER_ID
module-attribute
¤
The Confluence page ID where runbooks are stored.
CONFLUENCE_URL
module-attribute
¤
The Confluence URL to use. If no protocol is defined, https will be used.
CONFLUENCE_USERNAME
module-attribute
¤
The Confluence username to use.
ENABLE_CONFLUENCE
module-attribute
¤
Enable the Confluence app.
jira_app ¤
logging ¤
pagerduty ¤
raid ¤
ENABLE_RAID
module-attribute
¤
Enable the Raid app. Jira app must be enabled and configured as well.
RAID_DEFAULT_JIRA_QRAFT_USER_ID
module-attribute
¤
The default Jira user ID to use for creating issues
RAID_JIRA_PROJECT_KEY
module-attribute
¤
The Jira project key to use for creating issues, e.g. 'INC'
RAID_JIRA_USER_IDS
module-attribute
¤
Mapping of domain to default Jira user ID
RAID_QUALIFIER_URL
module-attribute
¤
Link to the board with issues to qualify
slack ¤
FF_SLACK_SKIP_CHECKS
module-attribute
¤
FF_SLACK_SKIP_CHECKS: bool = config('FF_SLACK_SKIP_CHECKS', cast=bool, default=_is_default_skip_check_cmd)
Skip Slack checks. Only use for testing or demo.
SLACK_APP_EMOJI
module-attribute
¤
Emoji to represent the app in Slack surfaces. Can be an actual emoji, or a string for a custom emoji present in your Workspace, like ":incident_logo:".
SLACK_BOT_TOKEN
module-attribute
¤
The Slack bot token to use.
SLACK_EMERGENCY_COMMUNICATION_GUIDE_URL
module-attribute
¤
SLACK_EMERGENCY_COMMUNICATION_GUIDE_URL: str | None = config('SLACK_EMERGENCY_COMMUNICATION_GUIDE_URL', default=None)
URL to add in the Slack emergency message. Useful to point to your own documentation.
SLACK_EMERGENCY_USERGROUP_ID
module-attribute
¤
The Slack usergroup ID to use for emergency notifications. If not set, no group will be mentionned in the message.
SLACK_INCIDENT_COMMAND
module-attribute
¤
The Slack slash command to use to create and manage incidents.
SLACK_INCIDENT_COMMAND_ALIASES
module-attribute
¤
SLACK_INCIDENT_COMMAND_ALIASES: list[str] = config('SLACK_INCIDENT_COMMAND_ALIASES', cast=Csv(), default='')
Comma-separated list of aliases for the incident command.
SLACK_INCIDENT_HELP_GUIDE_URL
module-attribute
¤
URL to add in the Slack help message (/incident help). Useful to point to your own documentation.
SLACK_POSTMORTEM_HELP_URL
module-attribute
¤
URL to a guide on how to write a postmortem. Useful to point to your own documentation.
SLACK_SEVERITY_HELP_GUIDE_URL
module-attribute
¤
URL to add in the form to choose the priority. Useful to point to your own documentation.
SLACK_SIGNING_SECRET
module-attribute
¤
The Slack signing secret to use.
environments ¤
Overriding settings based on the environment.
settings_builder ¤
sso ¤
urls ¤
firefighter URL Configuration.
The urlpatterns
list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:¤
Function views¤
- Add an import:
from my_app import views
- Add a URL to urlpatterns:
path('', views.home, name='home')
Class-based views¤
- Add an import:
from other_app.views import Home
- Add a URL to urlpatterns:
path('', Home.as_view(), name='home')
Including another URLconf¤
- Import the include() function:
from django.urls import include, path
- Add a URL to urlpatterns:
path('blog/', include('blog.urls'))
utils ¤
get_first_in ¤
get_first_in(ulist: list[T], key: str | Sequence[str], matches: Iterable[str], default: V | None = None) -> T | V | None
Returns the first element of a list of dicts, where the value of a key matches one in the provided iterable.
Source code in src/firefighter/firefighter/utils.py
get_in ¤
get_in(dictionary: dict[str, Any] | Any | None, keys: str | Sequence[str], default: Any | None = None) -> Any
Get a value from arbitrarily nested dicts.
Source code in src/firefighter/firefighter/utils.py
views ¤
CustomDetailView ¤
Bases: DetailView[_MT]
, Generic[_MT]
A custom detail view that adds the admin edit URL to the context, as admin_edit_url
.
get_admin_edit_url
cached
¤
Construct the URL name for the admin edit page using the model's app_label and model_name.
Source code in src/firefighter/firefighter/views.py
wsgi ¤
WSGI config for firefighter project.
It exposes the WSGI callable as a module-level variable named application
.
For more information on this file, see https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/