web_monitoring.db.Client
- class web_monitoring.db.Client(email=None, password=None, url=None, 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:
- email
str, optional - password
str, optional - url
str, optional Default is
https://api.monitoring.envirodatagov.org.- timeout
float, optional A default connection timeout in seconds to be used for all requests.
0indicates no timeout should be used. Individual requests may override this value. Default: 30.5 seconds.- retries
intortupleof(int,float)orurllib3.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
Retrydocumentation: https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#urllib3.util.Retry Default:(2, 2)
- email
Methods
__init__([email, password, url, timeout, ...])add_annotation(*, annotation, page_id, ...)Submit updated annotations for a change between versions.
add_version(*, page_id, capture_time, ...[, ...])Submit one new Version.
add_versions(versions, *[, update, ...])Submit versions in bulk for importing into web-monitoring-db.
from_env(**kwargs)Instantiate a
Clientby obtaining its authentication info from these environment variables (all are optional):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])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.