Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fronzbot committed Jul 20, 2020
1 parent 5fc3152 commit fe8eac3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
8 changes: 2 additions & 6 deletions blinkpy/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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.
Expand All @@ -24,10 +24,6 @@ def __init__(self, login_data=None, no_prompt=False, retry_opts=None):
- 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 = {}
Expand All @@ -40,7 +36,7 @@ def __init__(self, login_data=None, no_prompt=False, retry_opts=None):
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):
Expand Down
23 changes: 23 additions & 0 deletions docs/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit fe8eac3

Please sign in to comment.