1 """Config flow to configure the Azure DevOps integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
8 from aioazuredevops.client
import DevOpsClient
10 import voluptuous
as vol
15 from .const
import CONF_ORG, CONF_PAT, CONF_PROJECT, DOMAIN
19 """Handle a Azure DevOps config flow."""
24 """Initialize config flow."""
26 self.
_project_project: str |
None =
None
27 self.
_pat_pat: str |
None =
None
30 self, errors: dict[str, str] |
None =
None
31 ) -> ConfigFlowResult:
32 """Show the setup form to the user."""
35 data_schema=vol.Schema(
37 vol.Required(CONF_ORG, default=self.
_organization_organization): str,
38 vol.Required(CONF_PROJECT, default=self.
_project_project): str,
39 vol.Optional(CONF_PAT): str,
46 """Check the setup of the flow."""
47 errors: dict[str, str] = {}
50 client = DevOpsClient(session=aiohttp_session)
53 if self.
_pat_pat
is not None:
55 if not client.authorized:
56 errors[
"base"] =
"invalid_auth"
59 if project_info
is None:
60 errors[
"base"] =
"project_error"
62 except aiohttp.ClientError:
63 errors[
"base"] =
"cannot_connect"
68 self, user_input: dict[str, str] |
None =
None
69 ) -> ConfigFlowResult:
70 """Handle a flow initiated by the user."""
71 if user_input
is None:
75 self.
_project_project = user_input[CONF_PROJECT]
76 self.
_pat_pat = user_input.get(CONF_PAT)
82 if errors
is not None:
87 self, entry_data: Mapping[str, Any]
88 ) -> ConfigFlowResult:
89 """Handle configuration by re-auth."""
90 if entry_data.get(CONF_ORG)
and entry_data.get(CONF_PROJECT):
92 self.
_project_project = entry_data[CONF_PROJECT]
93 self.
_pat_pat = entry_data[CONF_PAT]
95 self.context[
"title_placeholders"] = {
96 "project_url": f
"{self._organization}/{self._project}",
101 self, user_input: dict[str, str] |
None =
None
102 ) -> ConfigFlowResult:
103 """Handle configuration by re-auth."""
104 errors: dict[str, str] |
None =
None
105 if user_input
is not None:
108 self.hass.config_entries.async_update_entry(
112 CONF_PROJECT: self.
_project_project,
113 CONF_PAT: self.
_pat_pat,
118 step_id=
"reauth_confirm",
119 description_placeholders={
120 "project_url": f
"{self._organization}/{self._project}"
122 data_schema=vol.Schema({vol.Required(CONF_PAT): str}),
127 """Handle create entry."""
129 title=f
"{self._organization}/{self._project}",
132 CONF_PROJECT: self.
_project_project,
133 CONF_PAT: self.
_pat_pat,
ConfigFlowResult async_step_user(self, dict[str, str]|None user_input=None)
ConfigFlowResult _async_create_entry(self)
ConfigFlowResult async_step_reauth_confirm(self, dict[str, str]|None user_input=None)
dict[str, str]|None _check_setup(self)
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
ConfigFlowResult _show_setup_form(self, dict[str, str]|None errors=None)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
ConfigEntry _get_reauth_entry(self)
ConfigEntry|None async_set_unique_id(self, str|None unique_id=None, *bool raise_on_progress=True)
ConfigFlowResult async_create_entry(self, *str title, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None, Mapping[str, Any]|None options=None)
ConfigFlowResult async_abort(self, *str reason, Mapping[str, str]|None description_placeholders=None)
ConfigFlowResult 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_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)
_FlowResultT async_abort(self, *str reason, Mapping[str, str]|None description_placeholders=None)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)