1 """Config flow for Google Assistant SDK integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
9 import voluptuous
as vol
20 from .const
import CONF_LANGUAGE_CODE, DEFAULT_NAME, DOMAIN, SUPPORTED_LANGUAGE_CODES
21 from .helpers
import default_language_code
23 _LOGGER = logging.getLogger(__name__)
27 config_entry_oauth2_flow.AbstractOAuth2FlowHandler, domain=DOMAIN
29 """Config flow to handle Google Assistant SDK OAuth2 authentication."""
36 return logging.getLogger(__name__)
40 """Extra data that needs to be appended to the authorize url."""
42 "scope":
"https://www.googleapis.com/auth/assistant-sdk-prototype",
44 "access_type":
"offline",
49 self, entry_data: Mapping[str, Any]
50 ) -> ConfigFlowResult:
51 """Perform reauth upon an API authentication error."""
55 self, user_input: dict[str, Any] |
None =
None
56 ) -> ConfigFlowResult:
57 """Confirm reauth dialog."""
58 if user_input
is None:
59 return self.async_show_form(step_id=
"reauth_confirm")
60 return await self.async_step_user()
63 """Create an entry for the flow, or update existing entry."""
64 if self.
sourcesource == SOURCE_REAUTH:
65 return self.async_update_reload_and_abort(
66 self._get_reauth_entry(), data=data
69 return self.async_create_entry(
80 config_entry: ConfigEntry,
82 """Create the options flow."""
87 """Google Assistant SDK options flow."""
90 self, user_input: dict[str, Any] |
None =
None
91 ) -> ConfigFlowResult:
92 """Manage the options."""
93 if user_input
is not None:
98 data_schema=vol.Schema(
103 ): vol.In(SUPPORTED_LANGUAGE_CODES),
dict[str, Any] extra_authorize_data(self)
ConfigFlowResult async_step_reauth_confirm(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_oauth_create_entry(self, dict[str, Any] data)
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
OptionsFlow async_get_options_flow(ConfigEntry config_entry)
logging.Logger logger(self)
ConfigFlowResult async_step_init(self, dict[str, Any]|None user_input=None)
ConfigEntry config_entry(self)
None config_entry(self, ConfigEntry value)
_FlowResultT async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
_FlowResultT async_create_entry(self, *str|None title=None, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None)
str default_language_code(HomeAssistant hass)