mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
parent
26a38f1fae
commit
962358bf87
@ -1,8 +1,11 @@
|
||||
"""Cloud APIs."""
|
||||
from functools import wraps
|
||||
import logging
|
||||
|
||||
from . import auth_api
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _check_token(func):
|
||||
"""Decorate a function to verify valid token."""
|
||||
@ -15,7 +18,21 @@ def _check_token(func):
|
||||
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
|
||||
@_log_response
|
||||
async def async_create_cloudhook(cloud):
|
||||
"""Create a cloudhook."""
|
||||
websession = cloud.hass.helpers.aiohttp_client.async_get_clientsession()
|
||||
|
@ -18,7 +18,7 @@ SERVERS = {
|
||||
'amazonaws.com/prod/smart_home_sync'),
|
||||
'subscription_info_url': ('https://stripe-api.nabucasa.com/payments/'
|
||||
'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 self._cookies
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
"""Return yarl of URL."""
|
||||
return self._url
|
||||
|
||||
@property
|
||||
def content(self):
|
||||
"""Return content."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user