mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
parent
26a38f1fae
commit
962358bf87
@ -1,8 +1,11 @@
|
|||||||
"""Cloud APIs."""
|
"""Cloud APIs."""
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
import logging
|
||||||
|
|
||||||
from . import auth_api
|
from . import auth_api
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _check_token(func):
|
def _check_token(func):
|
||||||
"""Decorate a function to verify valid token."""
|
"""Decorate a function to verify valid token."""
|
||||||
@ -15,7 +18,21 @@ def _check_token(func):
|
|||||||
return check_token
|
return check_token
|
||||||
|
|
||||||
|
|
||||||
|
def _log_response(func):
|
||||||
|
"""Decorate a function to log bad responses."""
|
||||||
|
@wraps(func)
|
||||||
|
async def log_response(*args):
|
||||||
|
"""Log response if it's bad."""
|
||||||
|
resp = await func(*args)
|
||||||
|
meth = _LOGGER.debug if resp.status < 400 else _LOGGER.warning
|
||||||
|
meth('Fetched %s (%s)', resp.url, resp.status)
|
||||||
|
return resp
|
||||||
|
|
||||||
|
return log_response
|
||||||
|
|
||||||
|
|
||||||
@_check_token
|
@_check_token
|
||||||
|
@_log_response
|
||||||
async def async_create_cloudhook(cloud):
|
async def async_create_cloudhook(cloud):
|
||||||
"""Create a cloudhook."""
|
"""Create a cloudhook."""
|
||||||
websession = cloud.hass.helpers.aiohttp_client.async_get_clientsession()
|
websession = cloud.hass.helpers.aiohttp_client.async_get_clientsession()
|
||||||
|
@ -18,7 +18,7 @@ SERVERS = {
|
|||||||
'amazonaws.com/prod/smart_home_sync'),
|
'amazonaws.com/prod/smart_home_sync'),
|
||||||
'subscription_info_url': ('https://stripe-api.nabucasa.com/payments/'
|
'subscription_info_url': ('https://stripe-api.nabucasa.com/payments/'
|
||||||
'subscription_info'),
|
'subscription_info'),
|
||||||
'cloudhook_create_url': 'https://webhook-api.nabucasa.com/generate'
|
'cloudhook_create_url': 'https://webhooks-api.nabucasa.com/generate'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +177,11 @@ class AiohttpClientMockResponse:
|
|||||||
"""Return dict of cookies."""
|
"""Return dict of cookies."""
|
||||||
return self._cookies
|
return self._cookies
|
||||||
|
|
||||||
|
@property
|
||||||
|
def url(self):
|
||||||
|
"""Return yarl of URL."""
|
||||||
|
return self._url
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def content(self):
|
def content(self):
|
||||||
"""Return content."""
|
"""Return content."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user