aws_sdk_s3/types/
_event.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `Event`, it is important to ensure
4/// your code is forward-compatible. That is, if a match arm handles a case for a
5/// feature that is supported by the service but has not been represented as an enum
6/// variant in a current version of SDK, your code should continue to work when you
7/// upgrade SDK to a future version in which the enum does include a variant for that
8/// feature.
9///
10/// Here is an example of how you can make a match expression forward-compatible:
11///
12/// ```text
13/// # let event = unimplemented!();
14/// match event {
15///     Event::S3IntelligentTiering => { /* ... */ },
16///     Event::S3LifecycleExpiration => { /* ... */ },
17///     Event::S3LifecycleExpirationDelete => { /* ... */ },
18///     Event::S3LifecycleExpirationDeleteMarkerCreated => { /* ... */ },
19///     Event::S3LifecycleTransition => { /* ... */ },
20///     Event::S3ObjectAclPut => { /* ... */ },
21///     Event::S3ObjectCreated => { /* ... */ },
22///     Event::S3ObjectCreatedCompleteMultipartUpload => { /* ... */ },
23///     Event::S3ObjectCreatedCopy => { /* ... */ },
24///     Event::S3ObjectCreatedPost => { /* ... */ },
25///     Event::S3ObjectCreatedPut => { /* ... */ },
26///     Event::S3ObjectRemoved => { /* ... */ },
27///     Event::S3ObjectRemovedDelete => { /* ... */ },
28///     Event::S3ObjectRemovedDeleteMarkerCreated => { /* ... */ },
29///     Event::S3ObjectRestore => { /* ... */ },
30///     Event::S3ObjectRestoreCompleted => { /* ... */ },
31///     Event::S3ObjectRestoreDelete => { /* ... */ },
32///     Event::S3ObjectRestorePost => { /* ... */ },
33///     Event::S3ObjectTagging => { /* ... */ },
34///     Event::S3ObjectTaggingDelete => { /* ... */ },
35///     Event::S3ObjectTaggingPut => { /* ... */ },
36///     Event::S3ReducedRedundancyLostObject => { /* ... */ },
37///     Event::S3Replication => { /* ... */ },
38///     Event::S3ReplicationOperationFailedReplication => { /* ... */ },
39///     Event::S3ReplicationOperationMissedThreshold => { /* ... */ },
40///     Event::S3ReplicationOperationNotTracked => { /* ... */ },
41///     Event::S3ReplicationOperationReplicatedAfterThreshold => { /* ... */ },
42///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
43///     _ => { /* ... */ },
44/// }
45/// ```
46/// The above code demonstrates that when `event` represents
47/// `NewFeature`, the execution path will lead to the second last match arm,
48/// even though the enum does not contain a variant `Event::NewFeature`
49/// in the current version of SDK. The reason is that the variable `other`,
50/// created by the `@` operator, is bound to
51/// `Event::Unknown(UnknownVariantValue("NewFeature".to_owned()))`
52/// and calling `as_str` on it yields `"NewFeature"`.
53/// This match expression is forward-compatible when executed with a newer
54/// version of SDK where the variant `Event::NewFeature` is defined.
55/// Specifically, when `event` represents `NewFeature`,
56/// the execution path will hit the second last match arm as before by virtue of
57/// calling `as_str` on `Event::NewFeature` also yielding `"NewFeature"`.
58///
59/// Explicitly matching on the `Unknown` variant should
60/// be avoided for two reasons:
61/// - The inner data `UnknownVariantValue` is opaque, and no further information can be extracted.
62/// - It might inadvertently shadow other intended match arms.
63///
64/// <p>The bucket event for which to send notifications.</p>
65#[non_exhaustive]
66#[derive(
67    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
68)]
69pub enum Event {
70    #[allow(missing_docs)] // documentation missing in model
71    S3IntelligentTiering,
72    #[allow(missing_docs)] // documentation missing in model
73    S3LifecycleExpiration,
74    #[allow(missing_docs)] // documentation missing in model
75    S3LifecycleExpirationDelete,
76    #[allow(missing_docs)] // documentation missing in model
77    S3LifecycleExpirationDeleteMarkerCreated,
78    #[allow(missing_docs)] // documentation missing in model
79    S3LifecycleTransition,
80    #[allow(missing_docs)] // documentation missing in model
81    S3ObjectAclPut,
82    #[allow(missing_docs)] // documentation missing in model
83    S3ObjectCreated,
84    #[allow(missing_docs)] // documentation missing in model
85    S3ObjectCreatedCompleteMultipartUpload,
86    #[allow(missing_docs)] // documentation missing in model
87    S3ObjectCreatedCopy,
88    #[allow(missing_docs)] // documentation missing in model
89    S3ObjectCreatedPost,
90    #[allow(missing_docs)] // documentation missing in model
91    S3ObjectCreatedPut,
92    #[allow(missing_docs)] // documentation missing in model
93    S3ObjectRemoved,
94    #[allow(missing_docs)] // documentation missing in model
95    S3ObjectRemovedDelete,
96    #[allow(missing_docs)] // documentation missing in model
97    S3ObjectRemovedDeleteMarkerCreated,
98    #[allow(missing_docs)] // documentation missing in model
99    S3ObjectRestore,
100    #[allow(missing_docs)] // documentation missing in model
101    S3ObjectRestoreCompleted,
102    #[allow(missing_docs)] // documentation missing in model
103    S3ObjectRestoreDelete,
104    #[allow(missing_docs)] // documentation missing in model
105    S3ObjectRestorePost,
106    #[allow(missing_docs)] // documentation missing in model
107    S3ObjectTagging,
108    #[allow(missing_docs)] // documentation missing in model
109    S3ObjectTaggingDelete,
110    #[allow(missing_docs)] // documentation missing in model
111    S3ObjectTaggingPut,
112    #[allow(missing_docs)] // documentation missing in model
113    S3ReducedRedundancyLostObject,
114    #[allow(missing_docs)] // documentation missing in model
115    S3Replication,
116    #[allow(missing_docs)] // documentation missing in model
117    S3ReplicationOperationFailedReplication,
118    #[allow(missing_docs)] // documentation missing in model
119    S3ReplicationOperationMissedThreshold,
120    #[allow(missing_docs)] // documentation missing in model
121    S3ReplicationOperationNotTracked,
122    #[allow(missing_docs)] // documentation missing in model
123    S3ReplicationOperationReplicatedAfterThreshold,
124    /// `Unknown` contains new variants that have been added since this code was generated.
125    #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
126    Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
127}
128impl ::std::convert::From<&str> for Event {
129    fn from(s: &str) -> Self {
130        match s {
131            "s3:IntelligentTiering" => Event::S3IntelligentTiering,
132            "s3:LifecycleExpiration:*" => Event::S3LifecycleExpiration,
133            "s3:LifecycleExpiration:Delete" => Event::S3LifecycleExpirationDelete,
134            "s3:LifecycleExpiration:DeleteMarkerCreated" => Event::S3LifecycleExpirationDeleteMarkerCreated,
135            "s3:LifecycleTransition" => Event::S3LifecycleTransition,
136            "s3:ObjectAcl:Put" => Event::S3ObjectAclPut,
137            "s3:ObjectCreated:*" => Event::S3ObjectCreated,
138            "s3:ObjectCreated:CompleteMultipartUpload" => Event::S3ObjectCreatedCompleteMultipartUpload,
139            "s3:ObjectCreated:Copy" => Event::S3ObjectCreatedCopy,
140            "s3:ObjectCreated:Post" => Event::S3ObjectCreatedPost,
141            "s3:ObjectCreated:Put" => Event::S3ObjectCreatedPut,
142            "s3:ObjectRemoved:*" => Event::S3ObjectRemoved,
143            "s3:ObjectRemoved:Delete" => Event::S3ObjectRemovedDelete,
144            "s3:ObjectRemoved:DeleteMarkerCreated" => Event::S3ObjectRemovedDeleteMarkerCreated,
145            "s3:ObjectRestore:*" => Event::S3ObjectRestore,
146            "s3:ObjectRestore:Completed" => Event::S3ObjectRestoreCompleted,
147            "s3:ObjectRestore:Delete" => Event::S3ObjectRestoreDelete,
148            "s3:ObjectRestore:Post" => Event::S3ObjectRestorePost,
149            "s3:ObjectTagging:*" => Event::S3ObjectTagging,
150            "s3:ObjectTagging:Delete" => Event::S3ObjectTaggingDelete,
151            "s3:ObjectTagging:Put" => Event::S3ObjectTaggingPut,
152            "s3:ReducedRedundancyLostObject" => Event::S3ReducedRedundancyLostObject,
153            "s3:Replication:*" => Event::S3Replication,
154            "s3:Replication:OperationFailedReplication" => Event::S3ReplicationOperationFailedReplication,
155            "s3:Replication:OperationMissedThreshold" => Event::S3ReplicationOperationMissedThreshold,
156            "s3:Replication:OperationNotTracked" => Event::S3ReplicationOperationNotTracked,
157            "s3:Replication:OperationReplicatedAfterThreshold" => Event::S3ReplicationOperationReplicatedAfterThreshold,
158            other => Event::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
159        }
160    }
161}
162impl ::std::str::FromStr for Event {
163    type Err = ::std::convert::Infallible;
164
165    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
166        ::std::result::Result::Ok(Event::from(s))
167    }
168}
169impl Event {
170    /// Returns the `&str` value of the enum member.
171    pub fn as_str(&self) -> &str {
172        match self {
173            Event::S3IntelligentTiering => "s3:IntelligentTiering",
174            Event::S3LifecycleExpiration => "s3:LifecycleExpiration:*",
175            Event::S3LifecycleExpirationDelete => "s3:LifecycleExpiration:Delete",
176            Event::S3LifecycleExpirationDeleteMarkerCreated => "s3:LifecycleExpiration:DeleteMarkerCreated",
177            Event::S3LifecycleTransition => "s3:LifecycleTransition",
178            Event::S3ObjectAclPut => "s3:ObjectAcl:Put",
179            Event::S3ObjectCreated => "s3:ObjectCreated:*",
180            Event::S3ObjectCreatedCompleteMultipartUpload => "s3:ObjectCreated:CompleteMultipartUpload",
181            Event::S3ObjectCreatedCopy => "s3:ObjectCreated:Copy",
182            Event::S3ObjectCreatedPost => "s3:ObjectCreated:Post",
183            Event::S3ObjectCreatedPut => "s3:ObjectCreated:Put",
184            Event::S3ObjectRemoved => "s3:ObjectRemoved:*",
185            Event::S3ObjectRemovedDelete => "s3:ObjectRemoved:Delete",
186            Event::S3ObjectRemovedDeleteMarkerCreated => "s3:ObjectRemoved:DeleteMarkerCreated",
187            Event::S3ObjectRestore => "s3:ObjectRestore:*",
188            Event::S3ObjectRestoreCompleted => "s3:ObjectRestore:Completed",
189            Event::S3ObjectRestoreDelete => "s3:ObjectRestore:Delete",
190            Event::S3ObjectRestorePost => "s3:ObjectRestore:Post",
191            Event::S3ObjectTagging => "s3:ObjectTagging:*",
192            Event::S3ObjectTaggingDelete => "s3:ObjectTagging:Delete",
193            Event::S3ObjectTaggingPut => "s3:ObjectTagging:Put",
194            Event::S3ReducedRedundancyLostObject => "s3:ReducedRedundancyLostObject",
195            Event::S3Replication => "s3:Replication:*",
196            Event::S3ReplicationOperationFailedReplication => "s3:Replication:OperationFailedReplication",
197            Event::S3ReplicationOperationMissedThreshold => "s3:Replication:OperationMissedThreshold",
198            Event::S3ReplicationOperationNotTracked => "s3:Replication:OperationNotTracked",
199            Event::S3ReplicationOperationReplicatedAfterThreshold => "s3:Replication:OperationReplicatedAfterThreshold",
200            Event::Unknown(value) => value.as_str(),
201        }
202    }
203    /// Returns all the `&str` representations of the enum members.
204    pub const fn values() -> &'static [&'static str] {
205        &[
206            "s3:IntelligentTiering",
207            "s3:LifecycleExpiration:*",
208            "s3:LifecycleExpiration:Delete",
209            "s3:LifecycleExpiration:DeleteMarkerCreated",
210            "s3:LifecycleTransition",
211            "s3:ObjectAcl:Put",
212            "s3:ObjectCreated:*",
213            "s3:ObjectCreated:CompleteMultipartUpload",
214            "s3:ObjectCreated:Copy",
215            "s3:ObjectCreated:Post",
216            "s3:ObjectCreated:Put",
217            "s3:ObjectRemoved:*",
218            "s3:ObjectRemoved:Delete",
219            "s3:ObjectRemoved:DeleteMarkerCreated",
220            "s3:ObjectRestore:*",
221            "s3:ObjectRestore:Completed",
222            "s3:ObjectRestore:Delete",
223            "s3:ObjectRestore:Post",
224            "s3:ObjectTagging:*",
225            "s3:ObjectTagging:Delete",
226            "s3:ObjectTagging:Put",
227            "s3:ReducedRedundancyLostObject",
228            "s3:Replication:*",
229            "s3:Replication:OperationFailedReplication",
230            "s3:Replication:OperationMissedThreshold",
231            "s3:Replication:OperationNotTracked",
232            "s3:Replication:OperationReplicatedAfterThreshold",
233        ]
234    }
235}
236impl ::std::convert::AsRef<str> for Event {
237    fn as_ref(&self) -> &str {
238        self.as_str()
239    }
240}
241impl Event {
242    /// Parses the enum value while disallowing unknown variants.
243    ///
244    /// Unknown variants will result in an error.
245    pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
246        match Self::from(value) {
247            #[allow(deprecated)]
248            Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
249            known => Ok(known),
250        }
251    }
252}
253impl ::std::fmt::Display for Event {
254    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
255        match self {
256            Event::S3IntelligentTiering => write!(f, "s3:IntelligentTiering"),
257            Event::S3LifecycleExpiration => write!(f, "s3:LifecycleExpiration:*"),
258            Event::S3LifecycleExpirationDelete => write!(f, "s3:LifecycleExpiration:Delete"),
259            Event::S3LifecycleExpirationDeleteMarkerCreated => write!(f, "s3:LifecycleExpiration:DeleteMarkerCreated"),
260            Event::S3LifecycleTransition => write!(f, "s3:LifecycleTransition"),
261            Event::S3ObjectAclPut => write!(f, "s3:ObjectAcl:Put"),
262            Event::S3ObjectCreated => write!(f, "s3:ObjectCreated:*"),
263            Event::S3ObjectCreatedCompleteMultipartUpload => write!(f, "s3:ObjectCreated:CompleteMultipartUpload"),
264            Event::S3ObjectCreatedCopy => write!(f, "s3:ObjectCreated:Copy"),
265            Event::S3ObjectCreatedPost => write!(f, "s3:ObjectCreated:Post"),
266            Event::S3ObjectCreatedPut => write!(f, "s3:ObjectCreated:Put"),
267            Event::S3ObjectRemoved => write!(f, "s3:ObjectRemoved:*"),
268            Event::S3ObjectRemovedDelete => write!(f, "s3:ObjectRemoved:Delete"),
269            Event::S3ObjectRemovedDeleteMarkerCreated => write!(f, "s3:ObjectRemoved:DeleteMarkerCreated"),
270            Event::S3ObjectRestore => write!(f, "s3:ObjectRestore:*"),
271            Event::S3ObjectRestoreCompleted => write!(f, "s3:ObjectRestore:Completed"),
272            Event::S3ObjectRestoreDelete => write!(f, "s3:ObjectRestore:Delete"),
273            Event::S3ObjectRestorePost => write!(f, "s3:ObjectRestore:Post"),
274            Event::S3ObjectTagging => write!(f, "s3:ObjectTagging:*"),
275            Event::S3ObjectTaggingDelete => write!(f, "s3:ObjectTagging:Delete"),
276            Event::S3ObjectTaggingPut => write!(f, "s3:ObjectTagging:Put"),
277            Event::S3ReducedRedundancyLostObject => write!(f, "s3:ReducedRedundancyLostObject"),
278            Event::S3Replication => write!(f, "s3:Replication:*"),
279            Event::S3ReplicationOperationFailedReplication => write!(f, "s3:Replication:OperationFailedReplication"),
280            Event::S3ReplicationOperationMissedThreshold => write!(f, "s3:Replication:OperationMissedThreshold"),
281            Event::S3ReplicationOperationNotTracked => write!(f, "s3:Replication:OperationNotTracked"),
282            Event::S3ReplicationOperationReplicatedAfterThreshold => write!(f, "s3:Replication:OperationReplicatedAfterThreshold"),
283            Event::Unknown(value) => write!(f, "{}", value),
284        }
285    }
286}