Home Assistant Unofficial Reference 2024.12.1
diagnostics.py
Go to the documentation of this file.
1 """Diagnostics helpers for Alexa."""
2 
3 from __future__ import annotations
4 
5 from collections.abc import Mapping
6 from typing import Any
7 
8 from homeassistant.components.diagnostics import async_redact_data
9 from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
10 from homeassistant.core import callback
11 
12 STORAGE_ACCESS_TOKEN = "access_token"
13 STORAGE_REFRESH_TOKEN = "refresh_token"
14 
15 TO_REDACT_LWA = {
16  CONF_CLIENT_ID,
17  CONF_CLIENT_SECRET,
18  STORAGE_ACCESS_TOKEN,
19  STORAGE_REFRESH_TOKEN,
20 }
21 
22 TO_REDACT_AUTH = {"correlationToken", "token"}
23 
24 
25 @callback
26 def async_redact_lwa_params(lwa_params: dict[str, str]) -> dict[str, str]:
27  """Redact lwa_params."""
28  return async_redact_data(lwa_params, TO_REDACT_LWA)
29 
30 
31 @callback
32 def async_redact_auth_data(mapping: Mapping[Any, Any]) -> dict[str, str]:
33  """React auth data."""
34  return async_redact_data(mapping, TO_REDACT_AUTH)
dict[str, str] async_redact_auth_data(Mapping[Any, Any] mapping)
Definition: diagnostics.py:32
dict[str, str] async_redact_lwa_params(dict[str, str] lwa_params)
Definition: diagnostics.py:26
dict async_redact_data(Mapping data, Iterable[Any] to_redact)
Definition: util.py:14