Update documentation

This commit is contained in:
Kevin Fronczak
2020-07-20 01:42:07 +00:00
parent 5fc315201a
commit fe8eac3dc6
2 changed files with 25 additions and 6 deletions
+2 -6
View File
@@ -14,7 +14,7 @@ _LOGGER = logging.getLogger(__name__)
class Auth: class Auth:
"""Class to handle login communication.""" """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. Initialize auth handler.
@@ -24,10 +24,6 @@ class Auth:
- password - password
:param no_prompt: Should any user input prompts :param no_prompt: Should any user input prompts
be supressed? True/FALSE 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: if login_data is None:
login_data = {} login_data = {}
@@ -40,7 +36,7 @@ class Auth:
self.login_response = None self.login_response = None
self.is_errored = False self.is_errored = False
self.no_prompt = no_prompt self.no_prompt = no_prompt
self.session = self.create_session(opts=retry_opts) self.session = self.create_session()
@property @property
def login_attributes(self): def login_attributes(self):
+23
View File
@@ -30,6 +30,29 @@ By default, the ``blink.auth.Auth`` class creates its own websession via its ``c
blink.auth = Auth() blink.auth = Auth()
blink.auth.session = YourCustomSession 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 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. 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.