web_monitoring.db.Client¶
-
class
web_monitoring.db.
Client
(email, password, url='https://api.monitoring.envirodatagov.org', timeout=None, retries=None)[source]¶ Communicate with web-monitoring-db via its REST API.
This object encapsulates authentication information and provides methods corresponding to the REST API.
The Client can also be configured via environment variables using the class method
Client.from_env()
.- Parameters
- emailstring
- passwordstring
- urlstring, optional
Default is
https://api.monitoring.envirodatagov.org
.- timeoutfloat, optional
A default connection timeout in seconds to be used for all requests.
0
indicates no timeout should be used. Individual requests may override this value. Default: 30.5 seconds.- retriesint or tuple of (int, float) or urllib3.util.Retry, optional
How to handle retrying failed requests. If an int, indictes the number of retries. If a tuple, the first item is the number of retries and the second is the backoff factor. For details about how those work, see the urllib3
Retry
documentation: https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#urllib3.util.Retry Default:(2, 2)
-
__init__
(email, password, url='https://api.monitoring.envirodatagov.org', timeout=None, retries=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(email, password[, url, timeout, …])Initialize self.
add_annotation
(*, annotation, page_id, …)Submit updated annotations for a change between versions.
add_version
(*, page_id, capture_time, uri, …)Submit one new Version.
add_versions
(versions, *[, update, …])Submit versions in bulk for importing into web-monitoring-db.
from_env
(**kwargs)Instantiate a
Client
by obtaining its authentication info from these environment variables:get_annotation
(*, annotation_id, page_id, …)Get a specific Annontation.
get_annotations
(*, page_id, to_version_id[, …])Iterate through Annotations for a Change between two Versions.
get_change
(*, page_id, to_version_id[, …])Get a Changes between two Versions.
get_changes
(page_id[, include_total])Iterate through a set of changes between any two versions of a page.
get_import_status
(import_id)Check on the status of a batch Version import job.
get_page
(page_id)Lookup a specific Page by ID.
get_pages
(*[, chunk, chunk_size, sort, …])Get an iterable of all pages, optionally filtered by search criteria.
get_user_session
()Get the current user session.
get_version
(version_id[, …])Lookup a specific Version by ID.
get_version_by_versionista_id
(versionista_id)Look up a Version by its Verisonista-issued ID.
get_version_content
(version_id)Download the saved content from a given Version.
get_versions
(*[, page_id, chunk, …])Iterate over a set of versions, optionally filtered by search criteria.
iterate_requests
(method, url[, data, timeout])list_annotations
(*, page_id, to_version_id)List Annotations for a Change between two Versions.
list_changes
(page_id[, include_total])List Changes between two Versions on a Page.
list_pages
(*[, chunk, chunk_size, sort, …])List all Pages, optionally filtered by search criteria.
list_versions
(*[, page_id, chunk, …])List Versions, optionally filtered by serach criteria, including Page.
monitor_import_statuses
(import_ids[, stop])Poll status of Version import jobs until all complete.
request
(method, url[, data, timeout])request_json
(method, url[, data, timeout])validate_credentials
()Validate that the DB Client is authorized for the provided host.