Debian Codegraph @

ansible_collections/amazon/aws/plugins/module_utils/_s3/waiters.py

raw
1 # -*- coding: utf-8 -*-
2
3 # Copyright: Contributors to the Ansible project
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 from __future__ import annotations
7
8 import typing
9
10 if typing.TYPE_CHECKING:
11 from typing import Dict
12
13 from ..waiter import BaseWaiterFactory
14
15
16 class S3WaiterFactory(BaseWaiterFactory):
17 """Factory for creating S3-specific waiters."""
18
19 @property
20 def _waiter_model_data(self) -> Dict:
21 """
22 Define waiter models for S3 operations.
23
24 Returns:
25 Dictionary containing waiter configurations for S3 operations.
26 """
27 PATH_BUCKET_KEY_ENABLED = "ServerSideEncryptionConfiguration.Rules[].BucketKeyEnabled"
28 data = dict(
29 bucket_exists=dict(
30 operation="HeadBucket",
31 delay=5,
32 maxAttempts=20,
33 acceptors=[
34 dict(state="success", matcher="status", expected=200),
35 dict(state="success", matcher="status", expected=301),
36 dict(state="success", matcher="status", expected=403),
37 ],
38 ),
39 bucket_not_exists=dict(
40 operation="HeadBucket",
41 delay=5,
42 maxAttempts=60,
43 acceptors=[
44 dict(state="success", matcher="status", expected=404),
45 ],
46 ),
47 bucket_versioning_enabled=dict(
48 operation="GetBucketVersioning",
49 delay=8,
50 maxAttempts=25,
51 acceptors=[
52 dict(state="success", matcher="path", argument="Status", expected="Enabled"),
53 ],
54 ),
55 bucket_versioning_suspended=dict(
56 operation="GetBucketVersioning",
57 delay=8,
58 maxAttempts=25,
59 acceptors=[
60 dict(state="success", matcher="path", argument="Status", expected="Suspended"),
61 ],
62 ),
63 bucket_key_encryption_enabled=dict(
64 operation="GetBucketEncryption",
65 delay=5,
66 maxAttempts=12,
67 acceptors=[
68 dict(state="success", matcher="pathAll", argument=PATH_BUCKET_KEY_ENABLED, expected=True),
69 ],
70 ),
71 bucket_key_encryption_disabled=dict(
72 operation="GetBucketEncryption",
73 delay=5,
74 maxAttempts=12,
75 acceptors=[
76 dict(state="success", matcher="pathAll", argument=PATH_BUCKET_KEY_ENABLED, expected=False),
77 ],
78 ),
79 )
80
81 return data
82
83
84 waiter_factory = S3WaiterFactory()