Skip to main content

DRB Http driver

Project description

Http & Https Implementation

This drb-driver-http module implements http and https protocol access with DRB data model.

Http Factory and Http Node

The module implements the factory model defined in DRB in its node resolver. Based on the python entry point mechanism, this module can be dynamically imported into applications.

The entry point group reference is drb.driver.
The implementation name is http.
The factory class is encoded into drb.drivers.http.
The http signature id is b065a5aa-35a3-11ec-8d3d-0242ac130003
The https signature id is c18ef57c-3673-11ec-8d3d-0242ac130003

The HttpNode can be instantiated from an uri. The ParsedPath class provided in drb core module can help to manage these inputs.

Using this module

The project is present in https://www.pypi.org service. it can be freely loaded into projects with the following command line:

pip install drb-driver-http

Access Data

DrbHttpNode manages the http protocol to access remote data. The construction parameter is an url. Both http and https are supported. They allow access the http content en header. The content is accessible with value node class attribute. It shall also be possible to retrieve specific streamed implementation using get_impl methode. The URL HTTP GET response header of the given URL is accessible via attributes of the node.

from drb.drivers.http import DrbHttpNode

node = DrbHttpNode('https://gitlab.com/drb-python/impl/http/-/raw/main/README.md')

print(node.name)
print(node.attributes)
print(node.path)
print(node.value)

HTTP protocol does not allow navigation inside http path so this implementation is not able to provide any children of the same HTTP type.

Authentication

Http node is able to manage Basic authentication based on username and password, as well as OAuth2.0 authentication based on token. It should also support Digest authentication via requests package HTTPDigestAuth implementation.

Basic Auth

To implements Basic authentication connection, the HTTPBasicAuth class from requests package is used.

from requests.auth import HTTPBasicAuth
from drb.drivers.http import DrbHttpNode

auth = HTTPBasicAuth('username', 'password')
node = DrbHttpNode('https://www.gael.fr', auth=auth)

OAuth2.0 connection

A dedicated HTTPOAuth2 class is available to manage OAuth2.0 authentication. It allows token retrieval and refresh when expired.

from drb.drivers.http import DrbHttpNode, HTTPOAuth2

svc_url = 'https://www.gael-systems.com/service'
token_svc = 'https://auth.gael-systems.com/token'
user = 'user'
password = 'pass'
service_id = 'service'
secret = 'secret'

auth = HTTPOAuth2(username=user, password=password, token_url=token_svc,
                  client_id=service_id, client_secret=secret)

node = DrbHttpNode(svc_url, auth=auth)

The renewal event of the token is triggered by computation. Based on the token expiration delay, the implementation computes the period to create or refresh a new token. Thanks to this mechanism, no unnecessary connection is performed by the client for this stage.

Limitations

None

Documentation

The documentation of this implementation can be found here https://drb-python.gitlab.io/impl/http

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drb_driver_http-1.3.9.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drb_driver_http-1.3.9-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file drb_driver_http-1.3.9.tar.gz.

File metadata

  • Download URL: drb_driver_http-1.3.9.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/8.5.0 pkginfo/1.12.1.2 requests/2.27.1 requests-toolbelt/1.0.0 tqdm/4.68.3 CPython/3.8.20

File hashes

Hashes for drb_driver_http-1.3.9.tar.gz
Algorithm Hash digest
SHA256 bb76109f2344ae35fca40a7392ecd6e18de36abb39e4f25dac281e4415ae3726
MD5 9682a3fc688e285faca204b5a8534d2b
BLAKE2b-256 1539a5676ee9658a773f1d80af1f9f53cd062b7adc9aa94abb8b6b7ebb8360f8

See more details on using hashes here.

File details

Details for the file drb_driver_http-1.3.9-py3-none-any.whl.

File metadata

  • Download URL: drb_driver_http-1.3.9-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/8.5.0 pkginfo/1.12.1.2 requests/2.27.1 requests-toolbelt/1.0.0 tqdm/4.68.3 CPython/3.8.20

File hashes

Hashes for drb_driver_http-1.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 45bad8c5cb963d9fb3c0e3c6d66ce526d1af36d0bc4cc5826cef2fb6e9d39019
MD5 d2b1930c63775507ca8c642ac13d010c
BLAKE2b-256 474481c60796ac9da469d2f756922573a570fe4e451e82a96c79f519341a71da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page