|
def | __init__ (self, path) |
|
def | add_authorization (self, headers) |
|
def | add_content_type (self, headers) |
|
def | build_data (self, params) |
|
def | build_headers (self, params) |
|
def | build_json (self, params) |
|
def | build_path (self, params) |
|
def | build_query (self, params) |
|
def | build_url (self, params) |
|
def | check_token (self) |
|
def | get_data (self, response) |
|
def | get_response (self, response, no_refresh=False) |
|
def | refresh_token (self) |
|
def | request (self, params) |
|
def | send (self, params, no_refresh=False) |
|
Generic class to wrap web APIs
Definition at line 43 of file scripts/mycroft/api/__init__.py.
def mycroft.api.Api.__init__ |
( |
|
self, |
|
|
|
path |
|
) |
| |
def mycroft.api.Api.add_authorization |
( |
|
self, |
|
|
|
headers |
|
) |
| |
def mycroft.api.Api.add_content_type |
( |
|
self, |
|
|
|
headers |
|
) |
| |
def mycroft.api.Api.build_data |
( |
|
self, |
|
|
|
params |
|
) |
| |
def mycroft.api.Api.build_headers |
( |
|
self, |
|
|
|
params |
|
) |
| |
def mycroft.api.Api.build_json |
( |
|
self, |
|
|
|
params |
|
) |
| |
def mycroft.api.Api.build_path |
( |
|
self, |
|
|
|
params |
|
) |
| |
def mycroft.api.Api.build_query |
( |
|
self, |
|
|
|
params |
|
) |
| |
def mycroft.api.Api.build_url |
( |
|
self, |
|
|
|
params |
|
) |
| |
def mycroft.api.Api.check_token |
( |
|
self | ) |
|
def mycroft.api.Api.get_data |
( |
|
self, |
|
|
|
response |
|
) |
| |
def mycroft.api.Api.get_response |
( |
|
self, |
|
|
|
response, |
|
|
|
no_refresh = False |
|
) |
| |
Parse response and extract data from response.
Will try to refresh the access token if it's expired.
Arguments:
response (requests Response object): Response to parse
no_refresh (bool): Disable refreshing of the token
Returns:
data fetched from server
Definition at line 151 of file scripts/mycroft/api/__init__.py.
def mycroft.api.Api.refresh_token |
( |
|
self | ) |
|
def mycroft.api.Api.request |
( |
|
self, |
|
|
|
params |
|
) |
| |
def mycroft.api.Api.send |
( |
|
self, |
|
|
|
params, |
|
|
|
no_refresh = False |
|
) |
| |
Send request to mycroft backend.
The method handles Etags and will return a cached response value
if nothing has changed on the remote.
Arguments:
params (dict): request parameters
no_refresh (bool): optional parameter to disable refreshs of token
Returns:
Requests response object.
Definition at line 108 of file scripts/mycroft/api/__init__.py.
dictionary mycroft.api.Api.etag_to_response = {} |
|
static |
mycroft.api.Api.old_params |
dictionary mycroft.api.Api.params_to_etag = {} |
|
static |
The documentation for this class was generated from the following file: