8000 implement S3 BucketInventoryConfiguration CRUD operations (#8696) · codeperl/localstack@5320b14 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5320b14

Browse files
authored
implement S3 BucketInventoryConfiguration CRUD operations (localstack#8696)
1 parent 015e39e commit 5320b14

File tree

7 files changed

+729
-45
lines changed
  • unit
  • 7 files changed

    +729
    -45
    lines changed

    localstack/aws/spec-patches.json

    Lines changed: 15 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -850,6 +850,21 @@
    850850
    "documentation": "<p>The target bucket for logging does not exist</p>",
    851851
    "exception": true
    852852
    }
    853+
    },
    854+
    {
    855+
    "op": "add",
    856+
    "path": "/operations/PutBucketInventoryConfiguration/http/responseCode",
    857+
    "value": 204
    858+
    },
    859+
    {
    860+
    "op": "add",
    861+
    "path": "/operations/PutBucketAnalyticsConfiguration/http/responseCode",
    862+
    "value": 204
    863+
    },
    864+
    {
    865+
    "op": "add",
    866+
    "path": "/operations/PutBucketIntelligentTieringConfiguration/http/responseCode",
    867+
    "value": 204
    853868
    }
    854869
    ]
    855870
    }

    localstack/services/s3/models.py

    Lines changed: 20 additions & 17 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,5 +1,3 @@
    1-
    from typing import Dict, Set
    2-
    31
    from moto.s3 import s3_backends as moto_s3_backends
    42
    from moto.s3.models import S3Backend as MotoS3Backend
    53

    @@ -13,6 +11,8 @@
    1311
    CORSConfiguration,
    1412
    IntelligentTieringConfiguration,
    1513
    IntelligentTieringId,
    14+
    InventoryConfiguration,
    15+
    InventoryId,
    1616
    NotificationConfiguration,
    1717
    ReplicationConfiguration,
    1818
    WebsiteConfiguration,
    @@ -28,36 +28,39 @@ def get_moto_s3_backend(context: RequestContext = None) -> MotoS3Backend:
    2828

    2929
    class S3Store(BaseStore):
    3030
    # maps bucket name to bucket's list of notification configurations
    31-
    bucket_notification_configs: Dict[BucketName, NotificationConfiguration] = CrossRegionAttribute(
    31+
    bucket_notification_configs: dict[BucketName, NotificationConfiguration] = CrossRegionAttribute(
    3232
    default=dict
    3333
    )
    3434

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

    3838
    # maps bucket name to bucket's replication settings
    39-
    bucket_replication: Dict[BucketName, ReplicationConfiguration] = CrossRegionAttribute(
    39+
    bucket_replication: dict[BucketName, ReplicationConfiguration] = CrossRegionAttribute(
    4040
    default=dict
    4141
    )
    4242

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

    49-
    bucket_versioning_status: Dict[BucketName, bool] = CrossRegionAttribute(default=dict)
    48+
    bucket_versioning_status: dict[BucketName, bool] = CrossRegionAttribute(default=dict)
    5049

    51-
    bucket_website_configuration: Dict[BucketName, WebsiteConfiguration] = CrossRegionAttribute(
    50+
    bucket_website_configuration: dict[BucketName, WebsiteConfiguration] = CrossRegionAttribute(
    5251
    default=dict
    5352
    )
    5453

    55-
    bucket_analytics_configuration: Dict[
    56-
    BucketName, Dict[AnalyticsId, AnalyticsConfiguration]
    54+
    bucket_analytics_configuration: dict[
    55+
    BucketName, dict[AnalyticsId, AnalyticsConfiguration]
    56+
    ] = CrossRegionAttribute(default=dict)
    57+
    58+
    bucket_intelligent_tiering_configuration: dict[
    59+
    BucketName, dict[IntelligentTieringId, IntelligentTieringConfiguration]
    5760
    ] = CrossRegionAttribute(default=dict)
    5861

    59-
    bucket_intelligent_tiering_configuration: Dict[
    60-
    BucketName, Dict[IntelligentTieringId, IntelligentTieringConfiguration]
    62+
    bucket_inventory_configurations: dict[
    63+
    BucketName, dict[InventoryId, InventoryConfiguration]
    6164
    ] = CrossRegionAttribute(default=dict)
    6265

    6366

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

    6972
    @property
    70-
    def cors(self) -> Dict[str, CORSConfiguration]:
    73+
    def cors(self) -> dict[str, CORSConfiguration]:
    7174
    if self._cors_index_cache is None:
    7275
    self._cors_index_cache = self._build_cors_index()
    7376
    return self._cors_index_cache
    7477

    7578
    @property
    76-
    def buckets(self) -> Set[str]:
    79+
    def buckets(self) -> set[str]:
    7780
    if self._bucket_index_cache is None:
    7881
    self._bucket_index_cache = self._build_bucket_index()
    7982
    return self._bucket_index_cache
    @@ -83,14 +86,14 @@ def invalidate(self):
    8386
    self._bucket_index_cache = None
    8487

    8588
    @staticmethod
    86-
    def _build_cors_index() -> Dict[BucketName, CORSConfiguration]:
    89+
    def _build_cors_index() -> dict[BucketName, CORSConfiguration]:
    8790
    result = {}
    8891
    for account_id, regions in s3_stores.items():
    8992
    result.update(regions[config.DEFAULT_REGION].bucket_cors)
    9093
    return result
    9194

    9295
    @staticmeth 5454 od
    93-
    def _build_bucket_index() -> Set[BucketName]:
    96+
    def _build_bucket_index() -> set[BucketName]:
    9497
    result = set()
    9598
    for account_id, regions in moto_s3_backends.items():
    9699
    result.update(regions["global"].buckets.keys())

    0 commit comments

    Comments
     (0)
    0