Skip to main content

rustack_events_model/
types.rs

1//! Shared EventBridge types used across input, output, and internal representations.
2//!
3//! All types follow the EventBridge JSON wire format with `PascalCase` field names.
4
5use std::collections::HashMap;
6
7use serde::{Deserialize, Serialize};
8use serde_json::Value;
9
10// ---------------------------------------------------------------------------
11// Tags
12// ---------------------------------------------------------------------------
13
14/// A tag associated with a resource.
15#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
16#[serde(rename_all = "PascalCase")]
17pub struct Tag {
18    /// The tag key.
19    pub key: String,
20    /// The tag value.
21    pub value: String,
22}
23
24// ---------------------------------------------------------------------------
25// Targets
26// ---------------------------------------------------------------------------
27
28/// A target for a rule, describing where matched events are sent.
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(rename_all = "PascalCase")]
31pub struct Target {
32    /// The unique target identifier within the rule.
33    pub id: String,
34
35    /// The ARN of the target resource.
36    pub arn: String,
37
38    /// The IAM role ARN for EventBridge to use when invoking the target.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub role_arn: Option<String>,
41
42    /// Valid JSON text passed to the target.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub input: Option<String>,
45
46    /// JSONPath expression to select part of the event to pass to the target.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub input_path: Option<String>,
49
50    /// Settings to transform input before sending to the target.
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub input_transformer: Option<InputTransformer>,
53
54    /// Parameters for a Run Command target.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub run_command_parameters: Option<Value>,
57
58    /// Parameters for an ECS task target.
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub ecs_parameters: Option<Value>,
61
62    /// Parameters for an AWS Batch job target.
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub batch_parameters: Option<Value>,
65
66    /// Parameters for an SQS queue target.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub sqs_parameters: Option<Value>,
69
70    /// Parameters for an HTTP endpoint target.
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub http_parameters: Option<Value>,
73
74    /// Parameters for a Redshift Data API target.
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub redshift_data_parameters: Option<Value>,
77
78    /// Parameters for a SageMaker pipeline target.
79    #[serde(skip_serializing_if = "Option::is_none")]
80    pub sage_maker_pipeline_parameters: Option<Value>,
81
82    /// Dead-letter queue configuration for failed invocations.
83    #[serde(skip_serializing_if = "Option::is_none")]
84    pub dead_letter_config: Option<DeadLetterConfig>,
85
86    /// Retry policy for failed invocations.
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub retry_policy: Option<RetryPolicy>,
89
90    /// Parameters for an AppSync target.
91    #[serde(skip_serializing_if = "Option::is_none")]
92    pub app_sync_parameters: Option<Value>,
93}
94
95// ---------------------------------------------------------------------------
96// Input transformer
97// ---------------------------------------------------------------------------
98
99/// Settings to transform input before sending to the target.
100#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(rename_all = "PascalCase")]
102pub struct InputTransformer {
103    /// Map of JSON paths to extract from the event.
104    #[serde(default, skip_serializing_if = "HashMap::is_empty")]
105    pub input_paths_map: HashMap<String, String>,
106
107    /// Template string that uses extracted values.
108    pub input_template: String,
109}
110
111// ---------------------------------------------------------------------------
112// Dead-letter config
113// ---------------------------------------------------------------------------
114
115/// Dead-letter queue configuration for a target.
116#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(rename_all = "PascalCase")]
118pub struct DeadLetterConfig {
119    /// The ARN of the SQS queue used as the dead-letter queue.
120    #[serde(skip_serializing_if = "Option::is_none")]
121    pub arn: Option<String>,
122}
123
124// ---------------------------------------------------------------------------
125// Retry policy
126// ---------------------------------------------------------------------------
127
128/// Retry policy for a target invocation.
129#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(rename_all = "PascalCase")]
131pub struct RetryPolicy {
132    /// Maximum number of retry attempts.
133    #[serde(skip_serializing_if = "Option::is_none")]
134    pub maximum_retry_attempts: Option<i32>,
135
136    /// Maximum age of a request that EventBridge sends to a target (in seconds).
137    #[serde(skip_serializing_if = "Option::is_none")]
138    pub maximum_event_age_in_seconds: Option<i32>,
139}
140
141// ---------------------------------------------------------------------------
142// Rule (list output)
143// ---------------------------------------------------------------------------
144
145/// A rule returned by `ListRules`.
146#[derive(Debug, Clone, Default, Serialize, Deserialize)]
147#[serde(rename_all = "PascalCase")]
148pub struct Rule {
149    /// The name of the rule.
150    #[serde(skip_serializing_if = "Option::is_none")]
151    pub name: Option<String>,
152
153    /// The ARN of the rule.
154    #[serde(skip_serializing_if = "Option::is_none")]
155    pub arn: Option<String>,
156
157    /// The event pattern for the rule.
158    #[serde(skip_serializing_if = "Option::is_none")]
159    pub event_pattern: Option<String>,
160
161    /// The schedule expression for the rule.
162    #[serde(skip_serializing_if = "Option::is_none")]
163    pub schedule_expression: Option<String>,
164
165    /// The state of the rule (`ENABLED` or `DISABLED`).
166    #[serde(skip_serializing_if = "Option::is_none")]
167    pub state: Option<String>,
168
169    /// The description of the rule.
170    #[serde(skip_serializing_if = "Option::is_none")]
171    pub description: Option<String>,
172
173    /// The IAM role ARN associated with the rule.
174    #[serde(skip_serializing_if = "Option::is_none")]
175    pub role_arn: Option<String>,
176
177    /// If the rule was created by an AWS service on behalf of your account.
178    #[serde(skip_serializing_if = "Option::is_none")]
179    pub managed_by: Option<String>,
180
181    /// The name of the event bus associated with the rule.
182    #[serde(skip_serializing_if = "Option::is_none")]
183    pub event_bus_name: Option<String>,
184}
185
186// ---------------------------------------------------------------------------
187// EventBus (list output)
188// ---------------------------------------------------------------------------
189
190/// An event bus returned by `ListEventBuses`.
191#[derive(Debug, Clone, Default, Serialize, Deserialize)]
192#[serde(rename_all = "PascalCase")]
193pub struct EventBus {
194    /// The name of the event bus.
195    #[serde(skip_serializing_if = "Option::is_none")]
196    pub name: Option<String>,
197
198    /// The ARN of the event bus.
199    #[serde(skip_serializing_if = "Option::is_none")]
200    pub arn: Option<String>,
201
202    /// The description of the event bus.
203    #[serde(skip_serializing_if = "Option::is_none")]
204    pub description: Option<String>,
205
206    /// The policy for the event bus.
207    #[serde(skip_serializing_if = "Option::is_none")]
208    pub policy: Option<String>,
209}
210
211// ---------------------------------------------------------------------------
212// Result entries
213// ---------------------------------------------------------------------------
214
215/// An entry in a `PutEvents` response.
216#[derive(Debug, Clone, Default, Serialize, Deserialize)]
217#[serde(rename_all = "PascalCase")]
218pub struct PutEventsResultEntry {
219    /// The ID of the event that was successfully submitted.
220    #[serde(skip_serializing_if = "Option::is_none")]
221    pub event_id: Option<String>,
222
223    /// The error code if the event was not submitted.
224    #[serde(skip_serializing_if = "Option::is_none")]
225    pub error_code: Option<String>,
226
227    /// The error message if the event was not submitted.
228    #[serde(skip_serializing_if = "Option::is_none")]
229    pub error_message: Option<String>,
230}
231
232/// An entry in a `PutTargets` response indicating a failed target.
233#[derive(Debug, Clone, Default, Serialize, Deserialize)]
234#[serde(rename_all = "PascalCase")]
235pub struct PutTargetsResultEntry {
236    /// The ID of the target that failed.
237    #[serde(skip_serializing_if = "Option::is_none")]
238    pub target_id: Option<String>,
239
240    /// The error code for the failure.
241    #[serde(skip_serializing_if = "Option::is_none")]
242    pub error_code: Option<String>,
243
244    /// The error message for the failure.
245    #[serde(skip_serializing_if = "Option::is_none")]
246    pub error_message: Option<String>,
247}
248
249/// An entry in a `RemoveTargets` response indicating a failed removal.
250#[derive(Debug, Clone, Default, Serialize, Deserialize)]
251#[serde(rename_all = "PascalCase")]
252pub struct RemoveTargetsResultEntry {
253    /// The ID of the target that failed to be removed.
254    #[serde(skip_serializing_if = "Option::is_none")]
255    pub target_id: Option<String>,
256
257    /// The error code for the failure.
258    #[serde(skip_serializing_if = "Option::is_none")]
259    pub error_code: Option<String>,
260
261    /// The error message for the failure.
262    #[serde(skip_serializing_if = "Option::is_none")]
263    pub error_message: Option<String>,
264}
265
266// ---------------------------------------------------------------------------
267// Condition
268// ---------------------------------------------------------------------------
269
270/// A condition used in `PutPermission` for policy-based access control.
271#[derive(Debug, Clone, Serialize, Deserialize)]
272#[serde(rename_all = "PascalCase")]
273pub struct Condition {
274    /// The type of condition (e.g., `"StringEquals"`).
275    #[serde(rename = "Type")]
276    pub condition_type: String,
277
278    /// The key for the condition (e.g., `"aws:PrincipalOrgID"`).
279    pub key: String,
280
281    /// The value for the condition.
282    pub value: String,
283}