Skip to main content

Requests transport adapters for file://, s3://, and oci:// URLs.

Project description

session-adapters

PyPI - Version PyPI - Python Version

Requests transport adapters for file://, s3://, and oci:// URLs.

Why This Project

session-adapters lets you use a standard requests.Session with non-HTTP backends:

  • file:// for local filesystem artifacts
  • s3:// for AWS S3 objects and prefix listings
  • oci:// for OCI registry artifacts (via ORAS client)

This keeps one client interface while changing only the URL scheme.

Installation

pip install session-adapters

Quick Start

import requests

from session_adapters.file_adapter import FileAdapter
from session_adapters.s3_adapter import S3Adapter
from session_adapters.oci_adapter import OCIAdapter

session = requests.Session()
session.mount("file://", FileAdapter())
session.mount("s3://", S3Adapter())
session.mount("oci://", OCIAdapter())

# Local file
resp = session.get("file:///tmp/example.txt")
print(resp.status_code)

# S3 object
resp = session.get("s3://my-bucket/path/to/object.json")
print(resp.status_code)

# OCI artifact
resp = session.get("oci://registry.example.com/my-repo:latest")
print(resp.status_code)

Adapter Notes

File Adapter

  • Supports GET, HEAD, PUT, DELETE
  • Uses local filesystem paths from file:// URLs

S3 Adapter

  • Supports GET, HEAD, PUT, DELETE
  • Supports query options like:
    • range=bytes=0-99
    • versionId=...
    • delimiter=/
    • maxKeys=...

OCI Adapter

  • Supports GET, HEAD, PUT, DELETE
  • Parses refs as tags (:tag) or digests (@sha256:...)
  • Uses oras.client.OrasClient under the hood

Development

Run tests:

hatch run test:test-q

Run lint checks:

hatch run dev:check
ruff format --check .

License

session-adapters is distributed under the terms of the MIT license.

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

session_adapters-0.2.0.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

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

session_adapters-0.2.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file session_adapters-0.2.0.tar.gz.

File metadata

  • Download URL: session_adapters-0.2.0.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for session_adapters-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ee4c8dbfe8e821d04b9ab4470f0b5d0d0f9d3eba36714e3142d2af82ee2106ba
MD5 f35554d0eae3a780b37e1d8e7538c017
BLAKE2b-256 df6ec34556f14c49ea83a7848231ab2e0c2747a759ce33f57c0738c9019c7a14

See more details on using hashes here.

Provenance

The following attestation bundles were made for session_adapters-0.2.0.tar.gz:

Publisher: package.yaml on Terradue/session-adapters

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file session_adapters-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for session_adapters-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b655b5848d37184e862bb6cf5e51717a16ecc194ade2a9f7e041aeb1c2f7425f
MD5 7d4842193ad27893342365655e843b37
BLAKE2b-256 bc2afed1a1f186f4d041b8a4c860844e325c4e19f2b299e5d00a0b981108746c

See more details on using hashes here.

Provenance

The following attestation bundles were made for session_adapters-0.2.0-py3-none-any.whl:

Publisher: package.yaml on Terradue/session-adapters

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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