Enterprise AI utilities for Google Cloud Storage and Secrets Manager operations
Project description
ZionAI Utils
A simple utility library for Google Cloud Storage and Secret Manager operations.
Installation
pip install zionai_utils
Quick Start
Secrets Manager
from zionai_utils import SecretsManager
# Initialize
secrets = SecretsManager("your-project-id")
# Get any secret
api_key = secrets.get_secret("api-key")
db_host = secrets.get_secret("database-host")
bucket_name = secrets.get_secret("storage-bucket")
Cloud Storage
from zionai_utils import GCSClient
# Initialize
client = GCSClient("your-project-id")
# Upload files
success, uri = client.upload_file("bucket-name", "document.pdf")
success, uri = client.upload_text("bucket-name", "notes.txt", "Hello World!")
success, uri = client.upload_json("bucket-name", "data.json", {"key": "value"})
Key Features
Secrets Manager
- Simple retrieval:
secrets.get_secret("secret-name") - Default values:
secrets.get_secret("secret-name", default="fallback") - Batch operations: Get multiple secrets at once
- Auto-detection: Automatically detects project ID and credentials
Cloud Storage
- Easy uploads: Files, text, or JSON with one line
- Auto-detection: Automatically detects file types
- Batch operations: Upload multiple files
- File management: List, delete, and manage files
Basic Examples
Environment Configuration
from zionai_utils import SecretsManager
secrets = SecretsManager("your-project")
# Get configuration from secrets
host = secrets.get_secret("db-host")
port = secrets.get_secret("db-port")
password = secrets.get_secret("db-password")
# Use with defaults
api_url = secrets.get_secret("api-endpoint", default="https://api.example.com")
timeout = secrets.get_secret("timeout", default="30")
File Operations
from zionai_utils import GCSClient
client = GCSClient("your-project")
# Upload different file types
success, uri = client.upload_file("my-bucket", "report.pdf")
success, uri = client.upload_text("my-bucket", "log.txt", "Application started")
success, uri = client.upload_json("my-bucket", "config.json", {"version": "1.0"})
# Batch upload
files = ["file1.pdf", "file2.docx", "file3.jpg"]
results = client.batch_upload("my-bucket", files)
# File management
all_files = client.list_files("my-bucket")
deleted = client.delete_file("my-bucket", "old-file.txt")
Combined Usage
from zionai_utils import SecretsManager, GCSClient
# Initialize
secrets = SecretsManager("your-project")
client = GCSClient("your-project")
# Get bucket name from secrets
bucket_name = secrets.get_secret("storage-bucket")
# Upload file to secret-defined bucket
success, uri = client.upload_file(bucket_name, "data.json")
Setup
1. Install Package
pip install zionai_utils
2. Google Cloud Setup
Enable required APIs:
gcloud services enable secretmanager.googleapis.com
gcloud services enable storage.googleapis.com
3. Authentication
Set environment variables:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
export GOOGLE_CLOUD_PROJECT="your-project-id"
Or provide explicitly:
from zionai_utils import SecretsManager, GCSClient
secrets = SecretsManager(
project_id="your-project",
credentials_path="/path/to/service-account.json"
)
client = GCSClient(
project_id="your-project",
credentials_path="/path/to/service-account.json"
)
Requirements
- Python 3.7+
- Google Cloud project with Secret Manager and Storage APIs enabled
- Service account with appropriate permissions:
Secret Manager Secret Accessor(for reading secrets)Storage Admin(for file operations)
License
MIT License - see LICENSE file for details.
Links
- PyPI: https://pypi.org/project/zionai-utils/
- Examples: Check the
examples/folder for more usage patterns
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
zionai_utils-1.2.0.tar.gz
(22.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zionai_utils-1.2.0.tar.gz.
File metadata
- Download URL: zionai_utils-1.2.0.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7a9bb14fc51d110d84fe93596fc21395463f697b42a90b6048ea04e8fabe1e4
|
|
| MD5 |
30226d89aced3c88c6d70a17015b2731
|
|
| BLAKE2b-256 |
bed180dd030de58ce1d3f5d2cd1ec2ccdfdc8293809ec1fd21dc2373e1762d90
|
File details
Details for the file zionai_utils-1.2.0-py3-none-any.whl.
File metadata
- Download URL: zionai_utils-1.2.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5d2e35a02d664828618cf9c35cad5279241dcbb077e53994a24d8e64e24a1cd
|
|
| MD5 |
6ad1b8c86dab4d290babcaec948c1648
|
|
| BLAKE2b-256 |
4d4b283fbff41dac38e750054ac88bf3b20dfc8b800c70d33dccac3e855474ad
|