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.2.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

cloud_storage_clients-0.2.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cloud_storage_clients-0.2.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.7 Linux/6.5.0-17-generic

File hashes

Hashes for cloud_storage_clients-0.2.0.tar.gz
Algorithm Hash digest
SHA256 079952cb5d0178f9482bec7a0b8626cdcd8133257a108f92fb244ae9650d9a31
MD5 c322dbad90ca0a48415a4c2dc0e77d32
BLAKE2b-256 d71df1de1cebde2244f33b9d5c55445c416778cfc7ffaeda34d1641a7c09c82d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cloud_storage_clients-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c580b14f70c59b8e2cca3701ea8b7a92d0fa1369cff711366c9b78bbd3220754
MD5 436dcdddb077af8c8e8cd5c4decda719
BLAKE2b-256 5f4b723ee913bcb48feb58c887d63c008d6692837ad79f6ac0284409b1e818a4

See more details on using hashes here.

Supported by

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