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.3.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.3.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cloud_storage_clients-0.3.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.7 Linux/6.8.0-85-generic

File hashes

Hashes for cloud_storage_clients-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ee86a75cb74fecf5dd5a168f0edaee7cc8722475fcd8f372ba467799daa113db
MD5 f15196431ba651b7030517585f3ad707
BLAKE2b-256 25cfc723d0786c258563ee17c3dfb953cea17220b23c9a84f7f2ae1aa2cf503a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cloud_storage_clients-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4655eb7e50fc4dd752f919ad857f9d44b105b6846e18165fa316f17d9354a558
MD5 bc4ae9d2b094fa480f0dcac1de38c548
BLAKE2b-256 dcc6597f2abf91da01b38d3f07d89edef5f09364725867ecd772ead70d8ce602

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