1
- from typing import Dict , Set
2
-
3
1
from moto .s3 import s3_backends as moto_s3_backends
4
2
from moto .s3 .models import S3Backend as MotoS3Backend
5
3
13
11
CORSConfiguration ,
14
12
IntelligentTieringConfiguration ,
15
13
IntelligentTieringId ,
14
+ InventoryConfiguration ,
15
+ InventoryId ,
16
16
NotificationConfiguration ,
17
17
ReplicationConfiguration ,
18
18
WebsiteConfiguration ,
@@ -28,36 +28,39 @@ def get_moto_s3_backend(context: RequestContext = None) -> MotoS3Backend:
28
28
29
29
class S3Store (BaseStore ):
30
30
# 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 (
32
32
default = dict
33
33
)
34
34
35
35
# 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 )
37
37
38
38
# maps bucket name to bucket's replication settings
39
- bucket_replication : Dict [BucketName , ReplicationConfiguration ] = CrossRegionAttribute (
39
+ bucket_replication : dict [BucketName , ReplicationConfiguration ] = CrossRegionAttribute (
40
40
default = dict
41
41
)
42
42
43
43
# 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 [
46
45
BucketName , BucketLifecycleConfiguration
47
46
] = CrossRegionAttribute (default = dict )
48
47
49
- bucket_versioning_status : Dict [BucketName , bool ] = CrossRegionAttribute (default = dict )
48
+ bucket_versioning_status : dict [BucketName , bool ] = CrossRegionAttribute (default = dict )
50
49
51
- bucket_website_configuration : Dict [BucketName , WebsiteConfiguration ] = CrossRegionAttribute (
50
+ bucket_website_configuration : dict [BucketName , WebsiteConfiguration ] = CrossRegionAttribute (
52
51
default = dict
53
52
)
54
53
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 ]
57
60
] = CrossRegionAttribute (default = dict )
58
61
59
- bucket_intelligent_tiering_configuration : Dict [
60
- BucketName , Dict [ IntelligentTieringId , IntelligentTieringConfiguration ]
62
+ bucket_inventory_configurations : dict [
63
+ BucketName , dict [ InventoryId , InventoryConfiguration ]
61
64
] = CrossRegionAttribute (default = dict )
62
65
63
66
@@ -67,13 +70,13 @@ def __init__(self):
67
70
self ._bucket_index_cache = None
68
71
69
72
@property
70
- def cors (self ) -> Dict [str , CORSConfiguration ]:
73
+ def cors (self ) -> dict [str , CORSConfiguration ]:
71
74
if self ._cors_index_cache is None :
72
75
self ._cors_index_cache = self ._build_cors_index ()
73
76
return self ._cors_index_cache
74
77
75
78
@property
76
- def buckets (self ) -> Set [str ]:
79
+ def buckets (self ) -> set [str ]:
77
80
if self ._bucket_index_cache is None :
78
81
self ._bucket_index_cache = self ._build_bucket_index ()
79
82
return self ._bucket_index_cache
@@ -83,14 +86,14 @@ def invalidate(self):
83
86
self ._bucket_index_cache = None
84
87
85
88
@staticmethod
86
- def _build_cors_index () -> Dict [BucketName , CORSConfiguration ]:
89
+ def _build_cors_index () -> dict [BucketName , CORSConfiguration ]:
87
90
result = {}
88
91
for account_id , regions in s3_stores .items ():
89
92
result .update (regions [config .DEFAULT_REGION ].bucket_cors )
90
93
return result
91
94
92
95
@staticmeth
5454
od
93
- def _build_bucket_index () -> Set [BucketName ]:
96
+ def _build_bucket_index () -> set [BucketName ]:
94
97
result = set ()
95
98
for account_id , regions in moto_s3_backends .items ():
96
99
result .update (regions ["global" ].buckets .keys ())
0 commit comments