diff --git a/docs/sdk/api.md b/docs/sdk/api.md index 1c25282..16ed50c 100644 --- a/docs/sdk/api.md +++ b/docs/sdk/api.md @@ -77,7 +77,7 @@ class DeltaGliderClient: ### boto3-Compatible Methods (Recommended) -These methods provide 100% compatibility with boto3's S3 client, making DeltaGlider a drop-in replacement. +These methods provide compatibility with boto3's core S3 client operations. DeltaGlider implements 21 essential S3 methods covering ~80% of common use cases. See [BOTO3_COMPATIBILITY.md](../../BOTO3_COMPATIBILITY.md) for complete coverage details. #### `list_objects` @@ -215,6 +215,102 @@ def get_object( Dict with Body stream and metadata (identical to boto3). +#### `create_bucket` + +Create an S3 bucket (boto3-compatible). + +```python +def create_bucket( + self, + Bucket: str, + CreateBucketConfiguration: Optional[Dict[str, str]] = None, + **kwargs +) -> Dict[str, Any] +``` + +##### Parameters + +- **Bucket** (`str`): Name of the bucket to create. +- **CreateBucketConfiguration** (`Optional[Dict[str, str]]`): Bucket configuration with optional LocationConstraint. + +##### Returns + +Dict with Location of created bucket. + +##### Notes + +- Idempotent: Creating an existing bucket returns success +- Use for basic bucket creation without advanced S3 features + +##### Examples + +```python +# Create bucket in default region +client.create_bucket(Bucket='my-releases') + +# Create bucket in specific region +client.create_bucket( + Bucket='my-backups', + CreateBucketConfiguration={'LocationConstraint': 'eu-west-1'} +) +``` + +#### `delete_bucket` + +Delete an S3 bucket (boto3-compatible). + +```python +def delete_bucket( + self, + Bucket: str, + **kwargs +) -> Dict[str, Any] +``` + +##### Parameters + +- **Bucket** (`str`): Name of the bucket to delete. + +##### Returns + +Dict confirming deletion. + +##### Notes + +- Idempotent: Deleting a non-existent bucket returns success +- Bucket must be empty before deletion + +##### Examples + +```python +# Delete empty bucket +client.delete_bucket(Bucket='old-releases') +``` + +#### `list_buckets` + +List all S3 buckets (boto3-compatible). + +```python +def list_buckets( + self, + **kwargs +) -> Dict[str, Any] +``` + +##### Returns + +Dict with list of buckets and owner information (identical to boto3). + +##### Examples + +```python +# List all buckets +response = client.list_buckets() +for bucket in response['Buckets']: + print(f"{bucket['Name']} - Created: {bucket['CreationDate']}") +``` + ### Simple API Methods #### `upload` diff --git a/docs/sdk/examples.md b/docs/sdk/examples.md index 4da8781..a98a082 100644 --- a/docs/sdk/examples.md +++ b/docs/sdk/examples.md @@ -5,14 +5,15 @@ Real-world examples and patterns for using DeltaGlider in production application ## Table of Contents 1. [Performance-Optimized Bucket Listing](#performance-optimized-bucket-listing) -2. [Software Release Management](#software-release-management) -3. [Database Backup System](#database-backup-system) -4. [CI/CD Pipeline Integration](#cicd-pipeline-integration) -5. [Container Registry Storage](#container-registry-storage) -6. [Machine Learning Model Versioning](#machine-learning-model-versioning) -7. [Game Asset Distribution](#game-asset-distribution) -8. [Log Archive Management](#log-archive-management) -9. [Multi-Region Replication](#multi-region-replication) +2. [Bucket Management](#bucket-management) +3. [Software Release Management](#software-release-management) +4. [Database Backup System](#database-backup-system) +5. [CI/CD Pipeline Integration](#cicd-pipeline-integration) +6. [Container Registry Storage](#container-registry-storage) +7. [Machine Learning Model Versioning](#machine-learning-model-versioning) +8. [Game Asset Distribution](#game-asset-distribution) +9. [Log Archive Management](#log-archive-management) +10. [Multi-Region Replication](#multi-region-replication) ## Performance-Optimized Bucket Listing @@ -204,6 +205,94 @@ performance_comparison('releases') 5. **Batch Analytics**: When doing analytics, fetch metadata once and process the results rather than making multiple calls. +## Bucket Management + +DeltaGlider provides boto3-compatible bucket management methods for creating, listing, and deleting buckets without requiring boto3. + +### Complete Bucket Lifecycle + +```python +from deltaglider import create_client + +client = create_client() + +# Create bucket +client.create_bucket(Bucket='my-releases') + +# Create bucket in specific region +client.create_bucket( + Bucket='eu-backups', + CreateBucketConfiguration={'LocationConstraint': 'eu-west-1'} +) + +# List all buckets +response = client.list_buckets() +for bucket in response['Buckets']: + print(f"{bucket['Name']} - Created: {bucket['CreationDate']}") + +# Upload some objects +with open('app-v1.0.0.zip', 'rb') as f: + client.put_object(Bucket='my-releases', Key='v1.0.0/app.zip', Body=f) + +# Delete objects first (bucket must be empty) +client.delete_object(Bucket='my-releases', Key='v1.0.0/app.zip') + +# Delete bucket +client.delete_bucket(Bucket='my-releases') +``` + +### Idempotent Operations + +Bucket management operations are idempotent for safe automation: + +```python +# Creating existing bucket returns success (no error) +client.create_bucket(Bucket='my-releases') +client.create_bucket(Bucket='my-releases') # Safe, returns success + +# Deleting non-existent bucket returns success (no error) +client.delete_bucket(Bucket='non-existent') # Safe, returns success +``` + +### Hybrid boto3/DeltaGlider Usage + +For advanced S3 features not in DeltaGlider's 21 core methods, use boto3 directly: + +```python +from deltaglider import create_client +import boto3 + +# DeltaGlider for core operations with compression +dg_client = create_client() + +# boto3 for advanced features +s3_client = boto3.client('s3') + +# Use DeltaGlider for object operations (with compression) +with open('release.zip', 'rb') as f: + dg_client.put_object(Bucket='releases', Key='v1.0.0/release.zip', Body=f) + +# Use boto3 for advanced bucket features +s3_client.put_bucket_versioning( + Bucket='releases', + VersioningConfiguration={'Status': 'Enabled'} +) + +# Use boto3 for bucket policies +policy = { + "Version": "2012-10-17", + "Statement": [{ + "Effect": "Allow", + "Principal": "*", + "Action": "s3:GetObject", + "Resource": "arn:aws:s3:::releases/*" + }] +} +s3_client.put_bucket_policy(Bucket='releases', Policy=json.dumps(policy)) +``` + +See [BOTO3_COMPATIBILITY.md](../../BOTO3_COMPATIBILITY.md) for complete method coverage. + ## Software Release Management ### Managing Multiple Product Lines