8000 implement S3 BucketInventoryConfiguration CRUD operations by bentsku · Pull Request #8696 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

implement S3 BucketInventoryConfiguration CRUD operations #8696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
first iteration, no negative testing/validation
  • Loading branch information
bentsku committed Jul 14, 2023
commit affc09b189bb5071033340fadc47a34f068eda4d
15 changes: 15 additions & 0 deletions localstack/aws/spec-patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,21 @@
"documentation": "<p>The target bucket for logging does not exist</p>",
"exception": true
}
},
{
"op": "add",
"path": "/operations/PutBucketInventoryConfiguration/http/responseCode",
"value": 204
},
{
"op": "add",
"path": "/operations/PutBucketAnalyticsConfiguration/http/responseCode",
"value": 204
},
{
"op": "add",
"path": "/operations/PutBucketIntelligentTieringConfiguration/http/responseCode",
"value": 204
}
]
}
37 changes: 20 additions & 17 deletions localstack/services/s3/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict, Set

from moto.s3 import s3_backends as moto_s3_backends
from moto.s3.models import S3Backend as MotoS3Backend

Expand All @@ -13,6 +11,8 @@
CORSConfiguration,
IntelligentTieringConfiguration,
IntelligentTieringId,
InventoryConfiguration,
InventoryId,
NotificationConfiguration,
ReplicationConfiguration,
WebsiteConfiguration,
Expand All @@ -28,36 +28,39 @@ def get_moto_s3_backend(context: RequestContext = None) -> MotoS3Backend:

class S3Store(BaseStore):
# maps bucket name to bucket's list of notification configurations
bucket_notification_configs: Dict[BucketName, NotificationConfiguration] = CrossRegionAttribute(
bucket_notification_configs: dict[BucketName, NotificationConfiguration] = CrossRegionAttribute(
default=dict
)

# maps bucket name to bucket's CORS settings, used as index
bucket_cors: Dict[BucketName, CORSConfiguration] = CrossRegionAttribute(default=dict)
bucket_cors: dict[BucketName, CORSConfiguration] = CrossRegionAttribute(default=dict)

# maps bucket name to bucket's replication settings
bucket_replication: Dict[BucketName, ReplicationConfiguration] = CrossRegionAttribute(
bucket_replication: dict[BucketName, ReplicationConfiguration] = CrossRegionAttribute(
default=dict
)

# maps bucket name to bucket's lifecycle configuration
# TODO: need to check "globality" of parameters / redirect
bucket_lifecycle_configuration: Dict[
bucket_lifecycle_configuration: dict[
BucketName, BucketLifecycleConfiguration
] = CrossRegionAttribute(default=dict)

bucket_versioning_status: Dict[BucketName, bool] = CrossRegionAttribute(default=dict)
bucket_versioning_status: dict[BucketName, bool] = CrossRegionAttribute(default=dict)

bucket_website_configuration: Dict[BucketName, WebsiteConfiguration] = CrossRegionAttribute(
bucket_website_configuration: dict[BucketName, WebsiteConfiguration] = CrossRegionAttribute(
default=dict
)

bucket_analytics_configuration: Dict[
BucketName, Dict[AnalyticsId, AnalyticsConfiguration]
bucket_analytics_configuration: dict[
BucketName, dict[AnalyticsId, AnalyticsConfiguration]
] = CrossRegionAttribute(default=dict)

bucket_intelligent_tiering_configuration: dict[
BucketName, dict[IntelligentTieringId, IntelligentTieringConfiguration]
] = CrossRegionAttribute(default=dict)

bucket_intelligent_tiering_configuration: Dict[
BucketName, Dict[IntelligentTieringId, IntelligentTieringConfiguratio B622 n]
bucket_inventory_configurations: dict[
BucketName, dict[InventoryId, InventoryConfiguration]
] = CrossRegionAttribute(default=dict)


Expand All @@ -67,13 +70,13 @@ def __init__(self):
self._bucket_index_cache = None

@property
def cors(self) -> Dict[str, CORSConfiguration]:
def cors(self) -> dict[str, CORSConfiguration]:
if self._cors_index_cache is None:
self._cors_index_cache = self._build_cors_index()
return self._cors_index_cache

@property
def buckets(self) -> Set[str]:
def buckets(self) -> set[str]:
if self._bucket_index_cache is None:
self._bucket_index_cache = self._build_bucket_index()
return self._bucket_index_cache
Expand All @@ -83,14 +86,14 @@ def invalidate(self):
self._bucket_index_cache = None

@staticmethod
def _build_cors_index() -> Dict[BucketName, CORSConfiguration]:
def _build_cors_index() -> dict[BucketName, CORSConfiguration]:
result = {}
for account_id, regions in s3_stores.items():
result.update(regions[config.DEFAULT_REGION].bucket_cors)
return result

@staticmethod
def _build_bucket_index() -> Set[BucketName]:
def _build_bucket_index() -> set[BucketName]:
result = set()
for account_id, regions in moto_s3_backends.items():
result.update(regions["global"].buckets.keys())
Expand Down
Loading
0