Skip to main content

rustack_events_model/
operations.rs

1//! EventBridge operation enum.
2
3use std::fmt;
4
5/// All supported EventBridge operations.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub enum EventsOperation {
8    // Phase 0: Event bus management
9    /// Create an event bus.
10    CreateEventBus,
11    /// Delete an event bus.
12    DeleteEventBus,
13    /// Describe an event bus.
14    DescribeEventBus,
15    /// List event buses.
16    ListEventBuses,
17
18    // Phase 0: Rule management
19    /// Create or update a rule.
20    PutRule,
21    /// Delete a rule.
22    DeleteRule,
23    /// Describe a rule.
24    DescribeRule,
25    /// List rules on an event bus.
26    ListRules,
27    /// Enable a rule.
28    EnableRule,
29    /// Disable a rule.
30    DisableRule,
31
32    // Phase 0: Target management
33    /// Add targets to a rule.
34    PutTargets,
35    /// Remove targets from a rule.
36    RemoveTargets,
37    /// List targets for a rule.
38    ListTargetsByRule,
39
40    // Phase 0: Event operations
41    /// Put events onto an event bus.
42    PutEvents,
43    /// Test an event pattern against an event.
44    TestEventPattern,
45
46    // Phase 1: Tags, permissions, reverse lookup
47    /// Tag a resource.
48    TagResource,
49    /// Untag a resource.
50    UntagResource,
51    /// List tags for a resource.
52    ListTagsForResource,
53    /// Add a permission to an event bus.
54    PutPermission,
55    /// Remove a permission from an event bus.
56    RemovePermission,
57    /// List rule names that target a given ARN.
58    ListRuleNamesByTarget,
59
60    // Phase 2: Update and input transform
61    /// Update an event bus.
62    UpdateEventBus,
63
64    // Phase 3: Archive/Replay stubs
65    /// Create an archive.
66    CreateArchive,
67    /// Delete an archive.
68    DeleteArchive,
69    /// Describe an archive.
70    DescribeArchive,
71    /// List archives.
72    ListArchives,
73    /// Update an archive.
74    UpdateArchive,
75    /// Start a replay.
76    StartReplay,
77    /// Cancel a replay.
78    CancelReplay,
79    /// Describe a replay.
80    DescribeReplay,
81    /// List replays.
82    ListReplays,
83
84    // Phase 3: API Destinations stubs
85    /// Create an API destination.
86    CreateApiDestination,
87    /// Delete an API destination.
88    DeleteApiDestination,
89    /// Describe an API destination.
90    DescribeApiDestination,
91    /// List API destinations.
92    ListApiDestinations,
93    /// Update an API destination.
94    UpdateApiDestination,
95
96    // Phase 3: Connections stubs
97    /// Create a connection.
98    CreateConnection,
99    /// Delete a connection.
100    DeleteConnection,
101    /// Describe a connection.
102    DescribeConnection,
103    /// List connections.
104    ListConnections,
105    /// Update a connection.
106    UpdateConnection,
107    /// Deauthorize a connection.
108    DeauthorizeConnection,
109
110    // Phase 3: Endpoints stubs
111    /// Create an endpoint.
112    CreateEndpoint,
113    /// Delete an endpoint.
114    DeleteEndpoint,
115    /// Describe an endpoint.
116    DescribeEndpoint,
117    /// List endpoints.
118    ListEndpoints,
119    /// Update an endpoint.
120    UpdateEndpoint,
121
122    // Phase 3: Partner event sources stubs
123    /// Activate an event source.
124    ActivateEventSource,
125    /// Create a partner event source.
126    CreatePartnerEventSource,
127    /// Deactivate an event source.
128    DeactivateEventSource,
129    /// Delete a partner event source.
130    DeletePartnerEventSource,
131    /// Describe an event source.
132    DescribeEventSource,
133    /// Describe a partner event source.
134    DescribePartnerEventSource,
135    /// List event sources.
136    ListEventSources,
137    /// List partner event source accounts.
138    ListPartnerEventSourceAccounts,
139    /// List partner event sources.
140    ListPartnerEventSources,
141    /// Put partner events.
142    PutPartnerEvents,
143}
144
145impl EventsOperation {
146    /// Returns the AWS operation name string.
147    #[must_use]
148    pub fn as_str(&self) -> &'static str {
149        match self {
150            Self::CreateEventBus => "CreateEventBus",
151            Self::DeleteEventBus => "DeleteEventBus",
152            Self::DescribeEventBus => "DescribeEventBus",
153            Self::ListEventBuses => "ListEventBuses",
154            Self::PutRule => "PutRule",
155            Self::DeleteRule => "DeleteRule",
156            Self::DescribeRule => "DescribeRule",
157            Self::ListRules => "ListRules",
158            Self::EnableRule => "EnableRule",
159            Self::DisableRule => "DisableRule",
160            Self::PutTargets => "PutTargets",
161            Self::RemoveTargets => "RemoveTargets",
162            Self::ListTargetsByRule => "ListTargetsByRule",
163            Self::PutEvents => "PutEvents",
164            Self::TestEventPattern => "TestEventPattern",
165            Self::TagResource => "TagResource",
166            Self::UntagResource => "UntagResource",
167            Self::ListTagsForResource => "ListTagsForResource",
168            Self::PutPermission => "PutPermission",
169            Self::RemovePermission => "RemovePermission",
170            Self::ListRuleNamesByTarget => "ListRuleNamesByTarget",
171            Self::UpdateEventBus => "UpdateEventBus",
172            Self::CreateArchive => "CreateArchive",
173            Self::DeleteArchive => "DeleteArchive",
174            Self::DescribeArchive => "DescribeArchive",
175            Self::ListArchives => "ListArchives",
176            Self::UpdateArchive => "UpdateArchive",
177            Self::StartReplay => "StartReplay",
178            Self::CancelReplay => "CancelReplay",
179            Self::DescribeReplay => "DescribeReplay",
180            Self::ListReplays => "ListReplays",
181            Self::CreateApiDestination => "CreateApiDestination",
182            Self::DeleteApiDestination => "DeleteApiDestination",
183            Self::DescribeApiDestination => "DescribeApiDestination",
184            Self::ListApiDestinations => "ListApiDestinations",
185            Self::UpdateApiDestination => "UpdateApiDestination",
186            Self::CreateConnection => "CreateConnection",
187            Self::DeleteConnection => "DeleteConnection",
188            Self::DescribeConnection => "DescribeConnection",
189            Self::ListConnections => "ListConnections",
190            Self::UpdateConnection => "UpdateConnection",
191            Self::DeauthorizeConnection => "DeauthorizeConnection",
192            Self::CreateEndpoint => "CreateEndpoint",
193            Self::DeleteEndpoint => "DeleteEndpoint",
194            Self::DescribeEndpoint => "DescribeEndpoint",
195            Self::ListEndpoints => "ListEndpoints",
196            Self::UpdateEndpoint => "UpdateEndpoint",
197            Self::ActivateEventSource => "ActivateEventSource",
198            Self::CreatePartnerEventSource => "CreatePartnerEventSource",
199            Self::DeactivateEventSource => "DeactivateEventSource",
200            Self::DeletePartnerEventSource => "DeletePartnerEventSource",
201            Self::DescribeEventSource => "DescribeEventSource",
202            Self::DescribePartnerEventSource => "DescribePartnerEventSource",
203            Self::ListEventSources => "ListEventSources",
204            Self::ListPartnerEventSourceAccounts => "ListPartnerEventSourceAccounts",
205            Self::ListPartnerEventSources => "ListPartnerEventSources",
206            Self::PutPartnerEvents => "PutPartnerEvents",
207        }
208    }
209
210    /// Parse an operation name string into an `EventsOperation`.
211    #[must_use]
212    pub fn from_name(name: &str) -> Option<Self> {
213        match name {
214            "CreateEventBus" => Some(Self::CreateEventBus),
215            "DeleteEventBus" => Some(Self::DeleteEventBus),
216            "DescribeEventBus" => Some(Self::DescribeEventBus),
217            "ListEventBuses" => Some(Self::ListEventBuses),
218            "PutRule" => Some(Self::PutRule),
219            "DeleteRule" => Some(Self::DeleteRule),
220            "DescribeRule" => Some(Self::DescribeRule),
221            "ListRules" => Some(Self::ListRules),
222            "EnableRule" => Some(Self::EnableRule),
223            "DisableRule" => Some(Self::DisableRule),
224            "PutTargets" => Some(Self::PutTargets),
225            "RemoveTargets" => Some(Self::RemoveTargets),
226            "ListTargetsByRule" => Some(Self::ListTargetsByRule),
227            "PutEvents" => Some(Self::PutEvents),
228            "TestEventPattern" => Some(Self::TestEventPattern),
229            "TagResource" => Some(Self::TagResource),
230            "UntagResource" => Some(Self::UntagResource),
231            "ListTagsForResource" => Some(Self::ListTagsForResource),
232            "PutPermission" => Some(Self::PutPermission),
233            "RemovePermission" => Some(Self::RemovePermission),
234            "ListRuleNamesByTarget" => Some(Self::ListRuleNamesByTarget),
235            "UpdateEventBus" => Some(Self::UpdateEventBus),
236            "CreateArchive" => Some(Self::CreateArchive),
237            "DeleteArchive" => Some(Self::DeleteArchive),
238            "DescribeArchive" => Some(Self::DescribeArchive),
239            "ListArchives" => Some(Self::ListArchives),
240            "UpdateArchive" => Some(Self::UpdateArchive),
241            "StartReplay" => Some(Self::StartReplay),
242            "CancelReplay" => Some(Self::CancelReplay),
243            "DescribeReplay" => Some(Self::DescribeReplay),
244            "ListReplays" => Some(Self::ListReplays),
245            "CreateApiDestination" => Some(Self::CreateApiDestination),
246            "DeleteApiDestination" => Some(Self::DeleteApiDestination),
247            "DescribeApiDestination" => Some(Self::DescribeApiDestination),
248            "ListApiDestinations" => Some(Self::ListApiDestinations),
249            "UpdateApiDestination" => Some(Self::UpdateApiDestination),
250            "CreateConnection" => Some(Self::CreateConnection),
251            "DeleteConnection" => Some(Self::DeleteConnection),
252            "DescribeConnection" => Some(Self::DescribeConnection),
253            "ListConnections" => Some(Self::ListConnections),
254            "UpdateConnection" => Some(Self::UpdateConnection),
255            "DeauthorizeConnection" => Some(Self::DeauthorizeConnection),
256            "CreateEndpoint" => Some(Self::CreateEndpoint),
257            "DeleteEndpoint" => Some(Self::DeleteEndpoint),
258            "DescribeEndpoint" => Some(Self::DescribeEndpoint),
259            "ListEndpoints" => Some(Self::ListEndpoints),
260            "UpdateEndpoint" => Some(Self::UpdateEndpoint),
261            "ActivateEventSource" => Some(Self::ActivateEventSource),
262            "CreatePartnerEventSource" => Some(Self::CreatePartnerEventSource),
263            "DeactivateEventSource" => Some(Self::DeactivateEventSource),
264            "DeletePartnerEventSource" => Some(Self::DeletePartnerEventSource),
265            "DescribeEventSource" => Some(Self::DescribeEventSource),
266            "DescribePartnerEventSource" => Some(Self::DescribePartnerEventSource),
267            "ListEventSources" => Some(Self::ListEventSources),
268            "ListPartnerEventSourceAccounts" => Some(Self::ListPartnerEventSourceAccounts),
269            "ListPartnerEventSources" => Some(Self::ListPartnerEventSources),
270            "PutPartnerEvents" => Some(Self::PutPartnerEvents),
271            _ => None,
272        }
273    }
274
275    /// Returns `true` if this operation is implemented.
276    #[must_use]
277    pub fn is_implemented(&self) -> bool {
278        matches!(
279            self,
280            // Phase 0
281            Self::CreateEventBus
282                | Self::DeleteEventBus
283                | Self::DescribeEventBus
284                | Self::ListEventBuses
285                | Self::PutRule
286                | Self::DeleteRule
287                | Self::DescribeRule
288                | Self::ListRules
289                | Self::EnableRule
290                | Self::DisableRule
291                | Self::PutTargets
292                | Self::RemoveTargets
293                | Self::ListTargetsByRule
294                | Self::PutEvents
295                | Self::TestEventPattern
296                // Phase 1
297                | Self::TagResource
298                | Self::UntagResource
299                | Self::ListTagsForResource
300                | Self::PutPermission
301                | Self::RemovePermission
302                | Self::ListRuleNamesByTarget
303                // Phase 2
304                | Self::UpdateEventBus
305                // Phase 3: Archives
306                | Self::CreateArchive
307                | Self::DeleteArchive
308                | Self::DescribeArchive
309                | Self::ListArchives
310                | Self::UpdateArchive
311                // Phase 3: Replays
312                | Self::StartReplay
313                | Self::CancelReplay
314                | Self::DescribeReplay
315                | Self::ListReplays
316                // Phase 3: API Destinations
317                | Self::CreateApiDestination
318                | Self::DeleteApiDestination
319                | Self::DescribeApiDestination
320                | Self::ListApiDestinations
321                | Self::UpdateApiDestination
322                // Phase 3: Connections
323                | Self::CreateConnection
324                | Self::DeleteConnection
325                | Self::DescribeConnection
326                | Self::ListConnections
327                | Self::UpdateConnection
328                | Self::DeauthorizeConnection
329                // Phase 3: Endpoints
330                | Self::CreateEndpoint
331                | Self::DeleteEndpoint
332                | Self::DescribeEndpoint
333                | Self::ListEndpoints
334                | Self::UpdateEndpoint
335        )
336    }
337}
338
339impl fmt::Display for EventsOperation {
340    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
341        f.write_str(self.as_str())
342    }
343}