Skip to main content

Storage clients for different cloud providers

Project description

cloud-storage-clients

cloud-storage-clients is a Python library for having an unique interface over different cloud storage providers. It can be used to connect a python client to providers. This package is maintained by Picsellia.

This has been conceived for you to override classes. For example, override VaultRepository if you retrieve credentials in another way. You can create or override factories of client to add some additional parameters.

Installation

Add it to your poetry environment

poetry add cloud-storage-clients

Or use the package manager pip to install it.

pip install cloud-storage-clients

Usage

Basic client usage to retrieve a specific object name from an S3 bucket

from cloud_storage_clients.connector import Connector
from cloud_storage_clients.s3.client import S3Client

connector = Connector(client_type="s3", bucket="my-bucket")

client = S3Client(connector, {"access_key_id": "access-key", "secret_access_key": "secret-access-key" })

with open("/path/object-name.jpg", "wb") as file:
    response = client.get("object-name.jpg")
    file.write(response.content)

Pool Instanciation

from cloud_storage_clients.connector import Connector
from cloud_storage_clients.s3.factory import S3ClientFactory
from cloud_storage_clients.repositories.vault_adapter import DefaultVaultAdapter, TokenCredentials
from cloud_storage_clients.repositories.vault import VaultCredentialRepository
from cloud_storage_clients.pool import ClientPool

# Login to your Vault by creating a VaultAdapter and its repository
vault_adapter = DefaultVaultAdapter(
    url="http://localhost:7200",
    credentials=TokenCredentials(token="vault_token", unseal_key="unseal_key")
)
repository = VaultCredentialRepository(adapter=vault_adapter)

# Instantiate a ClientPool and add an S3ClientFactory for minio client_type
pool = ClientPool(default_repository=repository)
pool.register_factory("minio", factory=S3ClientFactory())

# Create a connector object
connector = Connector(client_type="minio", bucket="my-bucket")

# Use pool to instantiate a client that have its credentials in Vault
client = pool.get_client(connector)

# Generate a presigned url that an user without access to your bucket can download
presigned_url = client.get_download_url("object-name", 3600).url

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

cloud_storage_clients-0.4.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

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

cloud_storage_clients-0.4.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file cloud_storage_clients-0.4.0.tar.gz.

File metadata

  • Download URL: cloud_storage_clients-0.4.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.29 {"installer":{"name":"uv","version":"0.9.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cloud_storage_clients-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7013f7576965dec1abad93175a70652b0029934851096128272e0de5533d596e
MD5 b3a4d63e77777406a4faf96f0252326a
BLAKE2b-256 789aaf8d0184d4d10b69c40914aa12eb9a77cd5e5ad2be06fe968d90fa7aa0e5

See more details on using hashes here.

File details

Details for the file cloud_storage_clients-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: cloud_storage_clients-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.29 {"installer":{"name":"uv","version":"0.9.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cloud_storage_clients-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 988551b8e0e3f55653e21d17015a32707c53b173b5d45bca7ff4a21b17d40dc4
MD5 c3d42188a6802a0bc01a6eb22e7a2c69
BLAKE2b-256 84836963dbc3129b8e320ef10c7381d4dbc9f2e4766171ff27d38d9eb8ccfea0

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