Debian Codegraph @

hass_nabucasa/api.py

raw symbols SCIP
1 """Define the API base class."""
2
3 from __future__scip-python python python-stdlib 3.11 __future__/__init__: import annotationsscip-python python python-stdlib 3.11 __future__/annotations.annotations.
4
5 from collections.abcscip-python python python-stdlib 3.11 `collections.abc`/__init__: import Awaitablescip-python python python-stdlib 3.11 typing/Awaitable#, Callablescip-python python python-stdlib 3.11 typing/Callable., Coroutinescip-python python python-stdlib 3.11 typing/Coroutine#
6 import contextlibscip-python python python-stdlib 3.11 contextlib/__init__:
7 from dataclassesscip-python python python-stdlib 3.11 dataclasses/__init__: import dataclassscip-python python python-stdlib 3.11 dataclasses/dataclass().
8 from functoolsscip-python python python-stdlib 3.11 functools/__init__: import wrapsscip-python python python-stdlib 3.11 functools/wraps().
9 from jsonscip-python python python-stdlib 3.11 json/__init__: import JSONDecodeError
10 import loggingscip-python python python-stdlib 3.11 logging/__init__:
11 from typingscip-python python python-stdlib 3.11 typing/__init__: import TYPE_CHECKINGscip-python python python-stdlib 3.11 typing/TYPE_CHECKING.TYPE_CHECKING., Anyscip-python python python-stdlib 3.11 typing/Any., ParamSpecscip-python python python-stdlib 3.11 typing/ParamSpec#, TypeVarscip-python python python-stdlib 3.11 typing/TypeVar#, finalscip-python python python-stdlib 3.11 typing/final().
12
13 from aiohttpscip-python python aiohttp 3.14.1 aiohttp/__init__: import (
14 ClientError,
15 ClientResponse,
16 ClientResponseError,
17 ClientTimeout,
18 ContentTypeError,
19 hdrs,
20 )
21 from aiohttp.typedefsscip-python python aiohttp 3.14.1 `aiohttp.typedefs`/__init__: import Query
22 import voluptuousscip-python python voluptuous 0.16.0 voluptuous/__init__: as vol
23 from voluptuous.humanizescip-python python voluptuous 0.16.0 `voluptuous.humanize`/__init__: import humanize_error
24 from yarlscip-python python yarl 1.23.0 yarl/__init__: import URL
25
26 from .authscip-python python hass-nabucasa 0.0.0 auth/__init__: import Unauthenticatedscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.auth`/Unauthenticated#, UnknownErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.auth`/UnknownError#
27 from .exceptionsscip-python python hass-nabucasa 0.0.0 exceptions/__init__: import CloudErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.exceptions`/CloudError#
28
29 if TYPE_CHECKINGscip-python python python-stdlib 3.11 typing/TYPE_CHECKING.TYPE_CHECKING.:
30 from . import Cloudscip-python python hass-nabucasa 0.0.0 hass_nabucasa/Cloud#, _ClientTscip-python python hass-nabucasa 0.0.0 hass_nabucasa/_ClientT.
31 from .service_discoveryscip-python python hass-nabucasa 0.0.0 service_discovery/__init__: import ServiceDiscoveryActionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.service_discovery`/ServiceDiscoveryAction.
32
33 Pscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/P. = ParamSpecscip-python python python-stdlib 3.11 typing/ParamSpec#("P")
34 Tscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/T. = TypeVarscip-python python python-stdlib 3.11 typing/TypeVar#("T")
35
36 _LOGGERscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/_LOGGER. = loggingscip-python python python-stdlib 3.11 logging/__init__:.getLoggerscip-python python python-stdlib 3.11 logging/getLogger().(__name__scip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/)
37
38 ALLOW_EMPTY_RESPONSEscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ALLOW_EMPTY_RESPONSE. = frozensetscip-python python python-stdlib 3.11 builtins/frozenset#(
39 {
40 "DELETE",
41 "POST",
42 "HEAD",
43 }
44 )
45
46 DEFAULT_API_TIMEOUTscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/DEFAULT_API_TIMEOUT. = ClientTimeout(total=60)
47
48
49 def api_exception_handlerscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().(
50 exceptionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().(exception): typescip-python python python-stdlib 3.11 builtins/type#[CloudApiErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#],
51 ) -> Callablescip-python python python-stdlib 3.11 typing/Callable.[
52 [Callablescip-python python python-stdlib 3.11 typing/Callable.[Pscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/P., Awaitablescip-python python python-stdlib 3.11 typing/Awaitable#[Tscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/T.]]],
53 Callablescip-python python python-stdlib 3.11 typing/Callable.[Pscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/P., Coroutinescip-python python python-stdlib 3.11 typing/Coroutine#[Anyscip-python python python-stdlib 3.11 typing/Any., Anyscip-python python python-stdlib 3.11 typing/Any., Tscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/T.]],
54 ]:
55 """Handle API exceptions."""
56
57 def decoratorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().decorator().(
58 funcscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().decorator().(func): Callablescip-python python python-stdlib 3.11 typing/Callable.[Pscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/P., Awaitablescip-python python python-stdlib 3.11 typing/Awaitable#[Tscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/T.]],
59 ) -> Callablescip-python python python-stdlib 3.11 typing/Callable.[Pscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/P., Coroutinescip-python python python-stdlib 3.11 typing/Coroutine#[Anyscip-python python python-stdlib 3.11 typing/Any., Anyscip-python python python-stdlib 3.11 typing/Any., Tscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/T.]]:
60 @wrapsscip-python python python-stdlib 3.11 functools/wraps().(funcscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().decorator().(func))
61 async def wrapperscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().decorator().wrapper().(*argsscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().decorator().wrapper().(args): Pscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/P..args, **kwargsscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().decorator().wrapper().(kwargs): Pscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/P..kwargs) -> Tscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/T.:
62 try:
63 return await funcscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().decorator().(func)(*argsscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().decorator().wrapper().(args), **kwargsscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().decorator().wrapper().(kwargs))
64 except (
65 CloudApiNonRetryableErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiNonRetryableError#,
66 CloudApiCodedErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#,
67 exceptionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().(exception),
68 ):
69 raise
70 except CloudApiErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError# as err:
71 raise exceptionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().(exception)(
72 err,
73 orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(orig_exc)=err,
74 reasonscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(reason)=err.reasonscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#reason.,
75 statusscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(status)=err.statusscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#status.,
76 ) from err
77 except (UnknownErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.auth`/UnknownError#, Unauthenticatedscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.auth`/Unauthenticated#) as err:
78 raise exceptionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().(exception)(err, orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(orig_exc)=err) from err
79 except Exceptionscip-python python python-stdlib 3.11 builtins/Exception# as err:
80 raise exceptionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().(exception)(
81 f"Unexpected error while calling API: {err}",
82 orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(orig_exc)=err,
83 ) from err
84
85 return wrapperscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().decorator().wrapper().
86
87 return decoratorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/api_exception_handler().decorator().
88
89
90 class CloudApiErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#(CloudErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.exceptions`/CloudError#):
91 """Exception raised when handling cloud API."""
92
93 def __init__scip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(
94 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(self),
95 contextscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(context): strscip-python python python-stdlib 3.11 builtins/str# | Exceptionscip-python python python-stdlib 3.11 builtins/Exception#,
96 *,
97 orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(orig_exc): Exceptionscip-python python python-stdlib 3.11 builtins/Exception# | None = None,
98 reasonscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(reason): strscip-python python python-stdlib 3.11 builtins/str# | None = None,
99 statusscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(status): intscip-python python python-stdlib 3.11 builtins/int# | None = None,
100 ) -> None:
101 """Initialize."""
102 superscip-python python python-stdlib 3.11 builtins/super#().__init__scip-python python python-stdlib 3.11 builtins/BaseException#__init__().(contextscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(context))
103 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(self).orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#orig_exc. = orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(orig_exc)
104 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(self).reasonscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#reason. = reasonscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(reason)
105 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(self).statusscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#status. = statusscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(status)
106
107
108 class CloudApiCodedErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#(CloudApiErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#):
109 """Exception raised when handling cloud API."""
110
111 def __init__scip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#__init__().(selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#__init__().(self), contextscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#__init__().(context): strscip-python python python-stdlib 3.11 builtins/str# | Exceptionscip-python python python-stdlib 3.11 builtins/Exception#, *, codescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#__init__().(code): strscip-python python python-stdlib 3.11 builtins/str#) -> None:
112 """Initialize."""
113 superscip-python python python-stdlib 3.11 builtins/super#().__init__scip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(contextscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#__init__().(context))
114 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#__init__().(self).codescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#code. = codescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#__init__().(code)
115
116
117 class CloudApiTimeoutErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiTimeoutError#(CloudApiErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#):
118 """Exception raised when handling cloud API times out."""
119
120
121 class CloudApiClientErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiClientError#(CloudApiErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#):
122 """Exception raised when handling cloud API client error."""
123
124
125 class CloudApiNonRetryableErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiNonRetryableError#(CloudApiCodedErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#):
126 """Exception raised when handling cloud API non-retryable error."""
127
128
129 class CloudApiInvalidResponseErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiInvalidResponseError#(CloudApiErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#):
130 """Exception raised when API response fails schema validation."""
131
132
133 @dataclassscip-python python python-stdlib 3.11 dataclasses/dataclass().
134 class CloudApiRawResponsescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiRawResponse#:
135 """A raw response from the cloud API."""
136
137 responsescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiRawResponse#response.: ClientResponse
138 datascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiRawResponse#data.: Anyscip-python python python-stdlib 3.11 typing/Any. = None
139
140
141 class ApiBasescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#:
142 """Class to help communicate with the cloud API."""
143
144 def __init__scip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#__init__().(selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#__init__().(self), cloudscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#__init__().(cloud): Cloudscip-python python hass-nabucasa 0.0.0 hass_nabucasa/Cloud#[_ClientTscip-python python hass-nabucasa 0.0.0 hass_nabucasa/_ClientT.]) -> None:
145 """Initialize the API base."""
146 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#__init__().(self)._cloudscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_cloud. = cloudscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#__init__().(cloud)
147
148 @propertyscip-python python python-stdlib 3.11 builtins/property#
149 def hostnamescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#hostname().(selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#hostname().(self)) -> strscip-python python python-stdlib 3.11 builtins/str# | None:
150 """Get the hostname for path-based API calls."""
151 return None
152
153 @propertyscip-python python python-stdlib 3.11 builtins/property#
154 def non_retryable_error_codesscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#non_retryable_error_codes().(selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#non_retryable_error_codes().(self)) -> setscip-python python python-stdlib 3.11 builtins/set#[strscip-python python python-stdlib 3.11 builtins/str#]:
155 """Get the non-retryable error codes."""
156 return setscip-python python python-stdlib 3.11 builtins/set#()
157
158 @propertyscip-python python python-stdlib 3.11 builtins/property#
159 @finalscip-python python python-stdlib 3.11 typing/final().
160 def _non_retryable_error_codesscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_non_retryable_error_codes().(selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_non_retryable_error_codes().(self)) -> setscip-python python python-stdlib 3.11 builtins/set#[strscip-python python python-stdlib 3.11 builtins/str#]:
161 """Get the non-retryable error codes."""
162 return {"NC-CE-02", "NC-CE-03"}.unionscip-python python python-stdlib 3.11 builtins/set#union().(selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_non_retryable_error_codes().(self).non_retryable_error_codesscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#non_retryable_error_codes().)
163
164 def _do_log_requestscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(
165 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(self),
166 methodscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(method): strscip-python python python-stdlib 3.11 builtins/str#,
167 urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(url): strscip-python python python-stdlib 3.11 builtins/str# | URL,
168 include_path_in_logscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(include_path_in_log): boolscip-python python python-stdlib 3.11 builtins/bool# = True,
169 ) -> None:
170 """Log the response."""
171 if not _LOGGERscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/_LOGGER..isEnabledForscip-python python python-stdlib 3.11 logging/Logger#isEnabledFor().(loggingscip-python python python-stdlib 3.11 logging/__init__:.DEBUGscip-python python python-stdlib 3.11 logging/DEBUG.DEBUG.):
172 return
173 urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(url) = urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(url) if isinstance(urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(url), URL) else URL(urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(url))
174 target = urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(url).path if include_path_in_logscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(include_path_in_log) else ""
175 _LOGGERscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/_LOGGER..debugscip-python python python-stdlib 3.11 logging/Logger#debug().("Sending %s request to %s%s", methodscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(method), urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(url).host, target)
176
177 def _do_log_responsescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(
178 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(self),
179 respscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(resp): ClientResponse,
180 datascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(data): listscip-python python python-stdlib 3.11 builtins/list#[Anyscip-python python python-stdlib 3.11 typing/Any.] | dictscip-python python python-stdlib 3.11 builtins/dict#[Anyscip-python python python-stdlib 3.11 typing/Any., Anyscip-python python python-stdlib 3.11 typing/Any.] | strscip-python python python-stdlib 3.11 builtins/str# | None = None,
181 include_path_in_logscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(include_path_in_log): boolscip-python python python-stdlib 3.11 builtins/bool# = True,
182 ) -> None:
183 """Log the response."""
184 if not _LOGGERscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/_LOGGER..isEnabledForscip-python python python-stdlib 3.11 logging/Logger#isEnabledFor().(loggingscip-python python python-stdlib 3.11 logging/__init__:.DEBUGscip-python python python-stdlib 3.11 logging/DEBUG.DEBUG.):
185 return
186 isok = respscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(resp).status < 400
187 target = respscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(resp).url.path if include_path_in_logscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(include_path_in_log) else ""
188 if len(respscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(resp).url.query) > 0:
189 allowed_values = {"true", "false"}
190 query_params = [
191 f"{key}=***"
192 if value.lowerscip-python python python-stdlib 3.11 builtins/str#lower().() not in allowed_values
193 else f"{key}={value}"
194 for key, value in respscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(resp).url.query.items()
195 ]
196 target += f"?{'&'.joinscip-python python python-stdlib 3.11 builtins/str#join().(query_params)}"
197 _LOGGERscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/_LOGGER..debugscip-python python python-stdlib 3.11 logging/Logger#debug().(
198 "Response for %s from %s%s (%s) %s",
199 respscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(resp).method,
200 respscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(resp).url.host,
201 target,
202 respscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(resp).status,
203 datascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(data)["reason"]
204 if not isok and isinstance(datascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(data), dictscip-python python python-stdlib 3.11 builtins/dict#) and "reason" in datascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(data)
205 else datascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(data)["message"]
206 if not isok and isinstance(datascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(data), dictscip-python python python-stdlib 3.11 builtins/dict#) and "message" in datascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(data)
207 else "",
208 )
209
210 async def _call_raw_apiscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(
211 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(self),
212 *,
213 urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(url): strscip-python python python-stdlib 3.11 builtins/str#,
214 methodscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(method): strscip-python python python-stdlib 3.11 builtins/str#,
215 client_timeoutscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(client_timeout): ClientTimeout,
216 headersscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(headers): dictscip-python python python-stdlib 3.11 builtins/dict#[strscip-python python python-stdlib 3.11 builtins/str#, Anyscip-python python python-stdlib 3.11 typing/Any.],
217 jsondatascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(jsondata): dictscip-python python python-stdlib 3.11 builtins/dict#[strscip-python python python-stdlib 3.11 builtins/str#, Anyscip-python python python-stdlib 3.11 typing/Any.] | None = None,
218 datascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(data): Anyscip-python python python-stdlib 3.11 typing/Any. | None = None,
219 paramsscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(params): Query | None = None,
220 include_path_in_logscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(include_path_in_log): boolscip-python python python-stdlib 3.11 builtins/bool# = True,
221 ) -> ClientResponse:
222 """Call raw API."""
223 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(self)._do_log_requestscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_request().(methodscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(method), urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(url), include_path_in_logscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(include_path_in_log))
224 try:
225 resp = await selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(self)._cloudscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_cloud..websessionscip-python python hass-nabucasa 0.0.0 hass_nabucasa/Cloud#websession()..request(
226 method=methodscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(method),
227 url=urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(url),
228 timeout=client_timeoutscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(client_timeout),
229 headers=headersscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(headers),
230 json=jsondatascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(jsondata),
231 data=datascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(data),
232 params=paramsscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(params),
233 )
234 except TimeoutErrorscip-python python python-stdlib 3.11 builtins/TimeoutError# as err:
235 raise CloudApiTimeoutErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiTimeoutError#(
236 f"Timeout reached while calling API: total allowed time is "
237 f"{client_timeoutscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(client_timeout).total} seconds",
238 orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(orig_exc)=err,
239 ) from err
240 except ClientResponseError as err:
241 raise CloudApiClientErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiClientError#(
242 f"Failed to fetch: ({err.status}) {err.message}",
243 orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(orig_exc)=err,
244 statusscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(status)=err.status,
245 ) from err
246 except ClientError as err:
247 raise CloudApiClientErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiClientError#(f"Failed to fetch: {err}", orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(orig_exc)=err) from err
248 except Exceptionscip-python python python-stdlib 3.11 builtins/Exception# as err:
249 raise CloudApiErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#(
250 f"Unexpected error while calling API: {err}",
251 orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(orig_exc)=err,
252 ) from err
253
254 return resp
255
256 async def _call_cloud_apiscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(
257 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(self),
258 *,
259 actionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(action): ServiceDiscoveryActionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.service_discovery`/ServiceDiscoveryAction. | None = None,
260 action_valuesscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(action_values): dictscip-python python python-stdlib 3.11 builtins/dict#[strscip-python python python-stdlib 3.11 builtins/str#, Anyscip-python python python-stdlib 3.11 typing/Any.] | None = None,
261 pathscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(path): strscip-python python python-stdlib 3.11 builtins/str# | None = None,
262 api_versionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(api_version): intscip-python python python-stdlib 3.11 builtins/int# | None = None,
263 methodscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(method): strscip-python python python-stdlib 3.11 builtins/str# = "GET",
264 client_timeoutscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(client_timeout): ClientTimeout | None = None,
265 jsondatascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(jsondata): dictscip-python python python-stdlib 3.11 builtins/dict#[strscip-python python python-stdlib 3.11 builtins/str#, Anyscip-python python python-stdlib 3.11 typing/Any.] | None = None,
266 headersscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(headers): dictscip-python python python-stdlib 3.11 builtins/dict#[strscip-python python python-stdlib 3.11 builtins/str#, Anyscip-python python python-stdlib 3.11 typing/Any.] | None = None,
267 skip_token_checkscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(skip_token_check): boolscip-python python python-stdlib 3.11 builtins/bool# = False,
268 raw_responsescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(raw_response): boolscip-python python python-stdlib 3.11 builtins/bool# = False,
269 paramsscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(params): Query | None = None,
270 include_path_in_logscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(include_path_in_log): boolscip-python python python-stdlib 3.11 builtins/bool# = True,
271 schemascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(schema): vol.Schemascip-python python hass-nabucasa 0.0.0 `voluptuous.schema_builder`/Schema# | None = None,
272 ) -> Anyscip-python python python-stdlib 3.11 typing/Any.:
273 """Call cloud API."""
274 if actionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(action) is None and pathscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(path) is None:
275 raise CloudApiErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#("Either 'action' or 'path' parameter must be provided")
276
277 data: dictscip-python python python-stdlib 3.11 builtins/dict#[strscip-python python python-stdlib 3.11 builtins/str#, Anyscip-python python python-stdlib 3.11 typing/Any.] | listscip-python python python-stdlib 3.11 builtins/list#[Anyscip-python python python-stdlib 3.11 typing/Any.] | strscip-python python python-stdlib 3.11 builtins/str# | None = None
278 if not skip_token_checkscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(skip_token_check):
279 await selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(self)._cloudscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_cloud..authscip-python python hass-nabucasa 0.0.0 hass_nabucasa/Cloud#auth..async_check_tokenscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.auth`/CognitoAuth#async_check_token().()
280 if TYPE_CHECKINGscip-python python python-stdlib 3.11 typing/TYPE_CHECKING.TYPE_CHECKING.:
281 assert selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(self)._cloudscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_cloud..id_tokenscip-python python hass-nabucasa 0.0.0 hass_nabucasa/Cloud#id_token. is not None
282
283 if actionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(action) is not None:
284 final_url = selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(self)._cloudscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_cloud..service_discoveryscip-python python hass-nabucasa 0.0.0 hass_nabucasa/Cloud#service_discovery..action_urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.service_discovery`/ServiceDiscovery#action_url().(
285 actionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.service_discovery`/ServiceDiscovery#action_url().(action)=actionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(action),
286 **(action_valuesscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(action_values) or {}),
287 )
288 else:
289 url_path = f"{f'/v{api_versionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(api_version)}' if api_versionscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(api_version) else ''}{pathscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(path)}"
290 final_url = f"https://{selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(self).hostnamescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#hostname().}{url_path}"
291
292 resp = await selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(self)._call_raw_apiscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(
293 methodscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(method)=methodscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(method),
294 urlscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(url)=final_url,
295 client_timeoutscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(client_timeout)=client_timeoutscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(client_timeout) or DEFAULT_API_TIMEOUTscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/DEFAULT_API_TIMEOUT.,
296 headersscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(headers)={
297 hdrs.ACCEPT: "application/json",
298 hdrs.AUTHORIZATION: f"Bearer {selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(self)._cloudscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_cloud..id_tokenscip-python python hass-nabucasa 0.0.0 hass_nabucasa/Cloud#id_token.}",
299 hdrs.CONTENT_TYPE: "application/json",
300 hdrs.USER_AGENT: selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(self)._cloudscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_cloud..clientscip-python python hass-nabucasa 0.0.0 hass_nabucasa/Cloud#client..client_namescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.client`/CloudClient#client_name().,
301 **(headersscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(headers) or {}),
302 },
303 jsondatascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(jsondata)=jsondatascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(jsondata),
304 paramsscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(params)=paramsscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(params),
305 include_path_in_logscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_raw_api().(include_path_in_log)=include_path_in_logscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(include_path_in_log),
306 )
307
308 if resp.status < 500:
309 with contextlibscip-python python python-stdlib 3.11 contextlib/__init__:.suppressscip-python python python-stdlib 3.11 contextlib/suppress#(ContentTypeError, JSONDecodeError):
310 data = await resp.json()
311
312 selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(self)._do_log_responsescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_do_log_response().(resp, data, include_path_in_logscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(include_path_in_log))
313
314 if data is None and resp.method.upperscip-python python python-stdlib 3.11 builtins/str#upper().() not in ALLOW_EMPTY_RESPONSEscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ALLOW_EMPTY_RESPONSE.:
315 raise CloudApiErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#("Failed to parse API response") from None
316
317 if (
318 resp.status == 400
319 and isinstance(data, dictscip-python python python-stdlib 3.11 builtins/dict#)
320 and (message := data.getscip-python python python-stdlib 3.11 builtins/dict#get().("message"))
321 and (code := message.split(" ")[0])
322 and code in selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(self)._non_retryable_error_codesscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_non_retryable_error_codes().
323 ):
324 raise CloudApiNonRetryableErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiNonRetryableError#(message, codescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#__init__().(code)=code) from None
325
326 if resp.status == 403 and selfscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(self)._cloudscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_cloud..subscription_expiredscip-python python hass-nabucasa 0.0.0 hass_nabucasa/Cloud#subscription_expired().:
327 raise CloudApiNonRetryableErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiNonRetryableError#(
328 "Subscription has expired",
329 codescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiCodedError#__init__().(code)="subscription_expired",
330 ) from None
331
332 if raw_responsescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(raw_response):
333 return CloudApiRawResponsescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiRawResponse#(datascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiRawResponse#data.=data, responsescip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiRawResponse#response.=resp)
334
335 try:
336 resp.raise_for_status()
337 except ClientResponseError as err:
338 reason = (
339 data.getscip-python python python-stdlib 3.11 builtins/dict#get().("reason", data.getscip-python python python-stdlib 3.11 builtins/dict#get().("message"))
340 if isinstance(data, dictscip-python python python-stdlib 3.11 builtins/dict#)
341 else None
342 )
343 raise CloudApiErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#(
344 f"Failed to fetch: ({err.status}) {err.message}",
345 orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(orig_exc)=err,
346 reasonscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(reason)=reason,
347 statusscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(status)=resp.status,
348 ) from err
349
350 if schemascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(schema) is not None and data is not None:
351 try:
352 data = schemascip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/ApiBase#_call_cloud_api().(schema)(data)
353 except vol.Invalidscip-python python hass-nabucasa 0.0.0 `voluptuous.error`/Invalid# as err:
354 raise CloudApiInvalidResponseErrorscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiInvalidResponseError#(
355 f"Invalid response: {humanize_error(data, err)}",
356 orig_excscip-python python hass-nabucasa 0.0.0 `hass_nabucasa.api`/CloudApiError#__init__().(orig_exc)=err,
357 ) from err
358
359 return data