From fe8eac3dc6fcff2cb28116c6cd9d3a9cb327a56b Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Mon, 20 Jul 2020 01:42:07 +0000 Subject: [PATCH] Update documentation --- blinkpy/auth.py | 8 ++------ docs/advanced.rst | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/blinkpy/auth.py b/blinkpy/auth.py index 5cbf0f9..59950da 100644 --- a/blinkpy/auth.py +++ b/blinkpy/auth.py @@ -14,7 +14,7 @@ _LOGGER = logging.getLogger(__name__) class Auth: """Class to handle login communication.""" - def __init__(self, login_data=None, no_prompt=False, retry_opts=None): + def __init__(self, login_data=None, no_prompt=False): """ Initialize auth handler. @@ -24,10 +24,6 @@ class Auth: - password :param no_prompt: Should any user input prompts be supressed? True/FALSE - :param retry_opts: Dictionary containing retry options: - - backoff: backoff factor for http request (backoff*(2^(total_retries)-1) - - retries: total retries to attempt - - retry_list: list of status codes to force retry """ if login_data is None: login_data = {} @@ -40,7 +36,7 @@ class Auth: self.login_response = None self.is_errored = False self.no_prompt = no_prompt - self.session = self.create_session(opts=retry_opts) + self.session = self.create_session() @property def login_attributes(self): diff --git a/docs/advanced.rst b/docs/advanced.rst index 24fd431..95bf603 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -30,6 +30,29 @@ By default, the ``blink.auth.Auth`` class creates its own websession via its ``c blink.auth = Auth() blink.auth.session = YourCustomSession + +Custom Retry Logic +-------------------- +The built-in auth session via the ``create_session`` method allows for customizable retry intervals and conditions. These parameters are: + +- retries +- backoff +- retry_list + +``retries`` is the total number of retry attempts that each http request can do before timing out. ``backoff`` is a parameter that allows for non-linear retry times such that the time between retries is backoff*(2^(retries) - 1). ``retry_list`` is simply a list of status codes to force a retry. By default ``retries=3``, ``backoff=1``, and ``retry_list=[429, 500, 502, 503, 504]``. To override them, you need to add you overrides to a dictionary and use that to create a new session with the ``opts`` variable in the ``create_session`` method. The following example can serve as a guide where only the number of retries and backoff factor are overridden: + +.. code:: python + + from blinkpy.blinkpy import Blink + from blinkpy.auth import Auth + + blink = Blink() + blink.auth = Auth() + + opts = {"retries": 10, "backoff": 2} + blink.auth.session = blink.auth.create_session(opts=opts) + + Custom HTTP requests --------------------- In addition to custom sessions, custom blink server requests can be performed. This give you the ability to bypass the built-in ``Auth.query`` method. It also allows flexibility by giving you the option to pass your own url, rather than be limited to what is currently implemented in the ``blinkpy.api`` module.