| Name | cloud-storage-clients JSON |
| Version |
0.2.0
JSON |
| download |
| home_page | |
| Summary | Storage clients for different cloud providers |
| upload_time | 2024-02-15 15:50:12 |
| maintainer | |
| docs_url | None |
| author | picsellia |
| requires_python | >=3.8,<4.0 |
| license | MSI |
| keywords |
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
## 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](https://fr.picsellia.com/).
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](https://python-poetry.org/) environment
```bash
poetry add cloud-storage-clients
```
Or use the package manager [pip](https://pip.pypa.io/en/stable/) to install it.
```bash
pip install cloud-storage-clients
```
## Usage
### Basic client usage to retrieve a specific object name from an S3 bucket
```python
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
```python
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
```
Raw data
{
"_id": null,
"home_page": "",
"name": "cloud-storage-clients",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "picsellia",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/d7/1d/f1de1cebde2244f33b9d5c55445c416778cfc7ffaeda34d1641a7c09c82d/cloud_storage_clients-0.2.0.tar.gz",
"platform": null,
"description": "## cloud-storage-clients\n\n`cloud-storage-clients` is a Python library for having an unique interface over different cloud storage providers.\nIt can be used to connect a python client to providers.\nThis package is maintained by [Picsellia](https://fr.picsellia.com/).\n\nThis has been conceived for you to override classes.\nFor example, override VaultRepository if you retrieve credentials in another way.\nYou can create or override factories of client to add some additional parameters.\n\n## Installation\n\nAdd it to your [poetry](https://python-poetry.org/) environment\n```bash\npoetry add cloud-storage-clients\n```\n\nOr use the package manager [pip](https://pip.pypa.io/en/stable/) to install it.\n```bash\npip install cloud-storage-clients\n```\n\n## Usage\n\n### Basic client usage to retrieve a specific object name from an S3 bucket\n```python\nfrom cloud_storage_clients.connector import Connector\nfrom cloud_storage_clients.s3.client import S3Client\n\nconnector = Connector(client_type=\"s3\", bucket=\"my-bucket\")\n\nclient = S3Client(connector, {\"access_key_id\": \"access-key\", \"secret_access_key\": \"secret-access-key\" })\n\nwith open(\"/path/object-name.jpg\", \"wb\") as file:\n response = client.get(\"object-name.jpg\")\n file.write(response.content)\n\n```\n\n### Pool Instanciation\n```python\nfrom cloud_storage_clients.connector import Connector\nfrom cloud_storage_clients.s3.factory import S3ClientFactory\nfrom cloud_storage_clients.repositories.vault_adapter import DefaultVaultAdapter, TokenCredentials\nfrom cloud_storage_clients.repositories.vault import VaultCredentialRepository\nfrom cloud_storage_clients.pool import ClientPool\n\n# Login to your Vault by creating a VaultAdapter and its repository\nvault_adapter = DefaultVaultAdapter(\n url=\"http://localhost:7200\",\n credentials=TokenCredentials(token=\"vault_token\", unseal_key=\"unseal_key\")\n)\nrepository = VaultCredentialRepository(adapter=vault_adapter)\n\n# Instantiate a ClientPool and add an S3ClientFactory for minio client_type\npool = ClientPool(default_repository=repository)\npool.register_factory(\"minio\", factory=S3ClientFactory())\n\n# Create a connector object\nconnector = Connector(client_type=\"minio\", bucket=\"my-bucket\")\n\n# Use pool to instantiate a client that have its credentials in Vault\nclient = pool.get_client(connector)\n\n# Generate a presigned url that an user without access to your bucket can download\npresigned_url = client.get_download_url(\"object-name\", 3600).url\n\n\n\n```\n",
"bugtrack_url": null,
"license": "MSI",
"summary": "Storage clients for different cloud providers",
"version": "0.2.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5f4b723ee913bcb48feb58c887d63c008d6692837ad79f6ac0284409b1e818a4",
"md5": "436dcdddb077af8c8e8cd5c4decda719",
"sha256": "c580b14f70c59b8e2cca3701ea8b7a92d0fa1369cff711366c9b78bbd3220754"
},
"downloads": -1,
"filename": "cloud_storage_clients-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "436dcdddb077af8c8e8cd5c4decda719",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 19089,
"upload_time": "2024-02-15T15:50:11",
"upload_time_iso_8601": "2024-02-15T15:50:11.194679Z",
"url": "https://files.pythonhosted.org/packages/5f/4b/723ee913bcb48feb58c887d63c008d6692837ad79f6ac0284409b1e818a4/cloud_storage_clients-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d71df1de1cebde2244f33b9d5c55445c416778cfc7ffaeda34d1641a7c09c82d",
"md5": "c322dbad90ca0a48415a4c2dc0e77d32",
"sha256": "079952cb5d0178f9482bec7a0b8626cdcd8133257a108f92fb244ae9650d9a31"
},
"downloads": -1,
"filename": "cloud_storage_clients-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "c322dbad90ca0a48415a4c2dc0e77d32",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 12690,
"upload_time": "2024-02-15T15:50:12",
"upload_time_iso_8601": "2024-02-15T15:50:12.881661Z",
"url": "https://files.pythonhosted.org/packages/d7/1d/f1de1cebde2244f33b9d5c55445c416778cfc7ffaeda34d1641a7c09c82d/cloud_storage_clients-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-15 15:50:12",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "cloud-storage-clients"
}