aws_sdk_eventbridge/operation/put_rule/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::put_rule::_put_rule_output::PutRuleOutputBuilder;
3
4pub use crate::operation::put_rule::_put_rule_input::PutRuleInputBuilder;
5
6impl crate::operation::put_rule::builders::PutRuleInputBuilder {
7 /// Sends a request with this input using the given client.
8 pub async fn send_with(
9 self,
10 client: &crate::Client,
11 ) -> ::std::result::Result<
12 crate::operation::put_rule::PutRuleOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::put_rule::PutRuleError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.put_rule();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `PutRule`.
24///
25/// <p>Creates or updates the specified rule. Rules are enabled by default, or based on value of the state. You can disable a rule using <a href="https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_DisableRule.html">DisableRule</a>.</p>
26/// <p>A single rule watches for events from a single event bus. Events generated by Amazon Web Services services go to your account's default event bus. Events generated by SaaS partner services or applications go to the matching partner event bus. If you have custom applications or services, you can specify whether their events go to your default event bus or a custom event bus that you have created. For more information, see <a href="https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_CreateEventBus.html">CreateEventBus</a>.</p>
27/// <p>If you are updating an existing rule, the rule is replaced with what you specify in this <code>PutRule</code> command. If you omit arguments in <code>PutRule</code>, the old values for those arguments are not kept. Instead, they are replaced with null values.</p>
28/// <p>When you create or update a rule, incoming events might not immediately start matching to new or updated rules. Allow a short period of time for changes to take effect.</p>
29/// <p>A rule must contain at least an EventPattern or ScheduleExpression. Rules with EventPatterns are triggered when a matching event is observed. Rules with ScheduleExpressions self-trigger based on the given schedule. A rule can have both an EventPattern and a ScheduleExpression, in which case the rule triggers on matching events as well as on a schedule.</p>
30/// <p>When you initially create a rule, you can optionally assign one or more tags to the rule. Tags can help you organize and categorize your resources. You can also use them to scope user permissions, by granting a user permission to access or change only rules with certain tag values. To use the <code>PutRule</code> operation and assign tags, you must have both the <code>events:PutRule</code> and <code>events:TagResource</code> permissions.</p>
31/// <p>If you are updating an existing rule, any tags you specify in the <code>PutRule</code> operation are ignored. To update the tags of an existing rule, use <a href="https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_TagResource.html">TagResource</a> and <a href="https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_UntagResource.html">UntagResource</a>.</p>
32/// <p>Most services in Amazon Web Services treat : or / as the same character in Amazon Resource Names (ARNs). However, EventBridge uses an exact match in event patterns and rules. Be sure to use the correct ARN characters when creating event patterns so that they match the ARN syntax in the event you want to match.</p>
33/// <p>In EventBridge, it is possible to create rules that lead to infinite loops, where a rule is fired repeatedly. For example, a rule might detect that ACLs have changed on an S3 bucket, and trigger software to change them to the desired state. If the rule is not written carefully, the subsequent change to the ACLs fires the rule again, creating an infinite loop.</p>
34/// <p>To prevent this, write the rules so that the triggered actions do not re-fire the same rule. For example, your rule could fire only if ACLs are found to be in a bad state, instead of after any change.</p>
35/// <p>An infinite loop can quickly cause higher than expected charges. We recommend that you use budgeting, which alerts you when charges exceed your specified limit. For more information, see <a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/budgets-managing-costs.html">Managing Your Costs with Budgets</a>.</p>
36/// <p>To create a rule that filters for management events from Amazon Web Services services, see <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event-cloudtrail.html#eb-service-event-cloudtrail-management">Receiving read-only management events from Amazon Web Services services</a> in the <i>EventBridge User Guide</i>.</p>
37#[derive(::std::clone::Clone, ::std::fmt::Debug)]
38pub struct PutRuleFluentBuilder {
39 handle: ::std::sync::Arc<crate::client::Handle>,
40 inner: crate::operation::put_rule::builders::PutRuleInputBuilder,
41 config_override: ::std::option::Option<crate::config::Builder>,
42}
43impl crate::client::customize::internal::CustomizableSend<crate::operation::put_rule::PutRuleOutput, crate::operation::put_rule::PutRuleError>
44 for PutRuleFluentBuilder
45{
46 fn send(
47 self,
48 config_override: crate::config::Builder,
49 ) -> crate::client::customize::internal::BoxFuture<
50 crate::client::customize::internal::SendResult<crate::operation::put_rule::PutRuleOutput, crate::operation::put_rule::PutRuleError>,
51 > {
52 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
53 }
54}
55impl PutRuleFluentBuilder {
56 /// Creates a new `PutRuleFluentBuilder`.
57 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
58 Self {
59 handle,
60 inner: ::std::default::Default::default(),
61 config_override: ::std::option::Option::None,
62 }
63 }
64 /// Access the PutRule as a reference.
65 pub fn as_input(&self) -> &crate::operation::put_rule::builders::PutRuleInputBuilder {
66 &self.inner
67 }
68 /// Sends the request and returns the response.
69 ///
70 /// If an error occurs, an `SdkError` will be returned with additional details that
71 /// can be matched against.
72 ///
73 /// By default, any retryable failures will be retried twice. Retry behavior
74 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
75 /// set when configuring the client.
76 pub async fn send(
77 self,
78 ) -> ::std::result::Result<
79 crate::operation::put_rule::PutRuleOutput,
80 ::aws_smithy_runtime_api::client::result::SdkError<
81 crate::operation::put_rule::PutRuleError,
82 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
83 >,
84 > {
85 let input = self
86 .inner
87 .build()
88 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
89 let runtime_plugins = crate::operation::put_rule::PutRule::operation_runtime_plugins(
90 self.handle.runtime_plugins.clone(),
91 &self.handle.conf,
92 self.config_override,
93 );
94 crate::operation::put_rule::PutRule::orchestrate(&runtime_plugins, input).await
95 }
96
97 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
98 pub fn customize(
99 self,
100 ) -> crate::client::customize::CustomizableOperation<crate::operation::put_rule::PutRuleOutput, crate::operation::put_rule::PutRuleError, Self>
101 {
102 crate::client::customize::CustomizableOperation::new(self)
103 }
104 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
105 self.set_config_override(::std::option::Option::Some(config_override.into()));
106 self
107 }
108
109 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
110 self.config_override = config_override;
111 self
112 }
113 /// <p>The name of the rule that you are creating or updating.</p>
114 pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
115 self.inner = self.inner.name(input.into());
116 self
117 }
118 /// <p>The name of the rule that you are creating or updating.</p>
119 pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
120 self.inner = self.inner.set_name(input);
121 self
122 }
123 /// <p>The name of the rule that you are creating or updating.</p>
124 pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
125 self.inner.get_name()
126 }
127 /// <p>The scheduling expression. For example, "cron(0 20 * * ? *)" or "rate(5 minutes)".</p>
128 pub fn schedule_expression(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
129 self.inner = self.inner.schedule_expression(input.into());
130 self
131 }
132 /// <p>The scheduling expression. For example, "cron(0 20 * * ? *)" or "rate(5 minutes)".</p>
133 pub fn set_schedule_expression(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
134 self.inner = self.inner.set_schedule_expression(input);
135 self
136 }
137 /// <p>The scheduling expression. For example, "cron(0 20 * * ? *)" or "rate(5 minutes)".</p>
138 pub fn get_schedule_expression(&self) -> &::std::option::Option<::std::string::String> {
139 self.inner.get_schedule_expression()
140 }
141 /// <p>The event pattern. For more information, see <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html">Amazon EventBridge event patterns</a> in the <i> <i>Amazon EventBridge User Guide</i> </i>.</p>
142 pub fn event_pattern(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
143 self.inner = self.inner.event_pattern(input.into());
144 self
145 }
146 /// <p>The event pattern. For more information, see <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html">Amazon EventBridge event patterns</a> in the <i> <i>Amazon EventBridge User Guide</i> </i>.</p>
147 pub fn set_event_pattern(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
148 self.inner = self.inner.set_event_pattern(input);
149 self
150 }
151 /// <p>The event pattern. For more information, see <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html">Amazon EventBridge event patterns</a> in the <i> <i>Amazon EventBridge User Guide</i> </i>.</p>
152 pub fn get_event_pattern(&self) -> &::std::option::Option<::std::string::String> {
153 self.inner.get_event_pattern()
154 }
155 /// <p>The state of the rule.</p>
156 /// <p>Valid values include:</p>
157 /// <ul>
158 /// <li>
159 /// <p><code>DISABLED</code>: The rule is disabled. EventBridge does not match any events against the rule.</p></li>
160 /// <li>
161 /// <p><code>ENABLED</code>: The rule is enabled. EventBridge matches events against the rule, <i>except</i> for Amazon Web Services management events delivered through CloudTrail.</p></li>
162 /// <li>
163 /// <p><code>ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS</code>: The rule is enabled for all events, including Amazon Web Services management events delivered through CloudTrail.</p>
164 /// <p>Management events provide visibility into management operations that are performed on resources in your Amazon Web Services account. These are also known as control plane operations. For more information, see <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-management-events-with-cloudtrail.html#logging-management-events">Logging management events</a> in the <i>CloudTrail User Guide</i>, and <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event.html#eb-service-event-cloudtrail">Filtering management events from Amazon Web Services services</a> in the <i> <i>Amazon EventBridge User Guide</i> </i>.</p>
165 /// <p>This value is only valid for rules on the <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is-how-it-works-concepts.html#eb-bus-concepts-buses">default</a> event bus or <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-event-bus.html">custom event buses</a>. It does not apply to <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-saas.html">partner event buses</a>.</p></li>
166 /// </ul>
167 pub fn state(mut self, input: crate::types::RuleState) -> Self {
168 self.inner = self.inner.state(input);
169 self
170 }
171 /// <p>The state of the rule.</p>
172 /// <p>Valid values include:</p>
173 /// <ul>
174 /// <li>
175 /// <p><code>DISABLED</code>: The rule is disabled. EventBridge does not match any events against the rule.</p></li>
176 /// <li>
177 /// <p><code>ENABLED</code>: The rule is enabled. EventBridge matches events against the rule, <i>except</i> for Amazon Web Services management events delivered through CloudTrail.</p></li>
178 /// <li>
179 /// <p><code>ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS</code>: The rule is enabled for all events, including Amazon Web Services management events delivered through CloudTrail.</p>
180 /// <p>Management events provide visibility into management operations that are performed on resources in your Amazon Web Services account. These are also known as control plane operations. For more information, see <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-management-events-with-cloudtrail.html#logging-management-events">Logging management events</a> in the <i>CloudTrail User Guide</i>, and <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event.html#eb-service-event-cloudtrail">Filtering management events from Amazon Web Services services</a> in the <i> <i>Amazon EventBridge User Guide</i> </i>.</p>
181 /// <p>This value is only valid for rules on the <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is-how-it-works-concepts.html#eb-bus-concepts-buses">default</a> event bus or <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-event-bus.html">custom event buses</a>. It does not apply to <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-saas.html">partner event buses</a>.</p></li>
182 /// </ul>
183 pub fn set_state(mut self, input: ::std::option::Option<crate::types::RuleState>) -> Self {
184 self.inner = self.inner.set_state(input);
185 self
186 }
187 /// <p>The state of the rule.</p>
188 /// <p>Valid values include:</p>
189 /// <ul>
190 /// <li>
191 /// <p><code>DISABLED</code>: The rule is disabled. EventBridge does not match any events against the rule.</p></li>
192 /// <li>
193 /// <p><code>ENABLED</code>: The rule is enabled. EventBridge matches events against the rule, <i>except</i> for Amazon Web Services management events delivered through CloudTrail.</p></li>
194 /// <li>
195 /// <p><code>ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS</code>: The rule is enabled for all events, including Amazon Web Services management events delivered through CloudTrail.</p>
196 /// <p>Management events provide visibility into management operations that are performed on resources in your Amazon Web Services account. These are also known as control plane operations. For more information, see <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-management-events-with-cloudtrail.html#logging-management-events">Logging management events</a> in the <i>CloudTrail User Guide</i>, and <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event.html#eb-service-event-cloudtrail">Filtering management events from Amazon Web Services services</a> in the <i> <i>Amazon EventBridge User Guide</i> </i>.</p>
197 /// <p>This value is only valid for rules on the <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is-how-it-works-concepts.html#eb-bus-concepts-buses">default</a> event bus or <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-event-bus.html">custom event buses</a>. It does not apply to <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-saas.html">partner event buses</a>.</p></li>
198 /// </ul>
199 pub fn get_state(&self) -> &::std::option::Option<crate::types::RuleState> {
200 self.inner.get_state()
201 }
202 /// <p>A description of the rule.</p>
203 pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
204 self.inner = self.inner.description(input.into());
205 self
206 }
207 /// <p>A description of the rule.</p>
208 pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
209 self.inner = self.inner.set_description(input);
210 self
211 }
212 /// <p>A description of the rule.</p>
213 pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
214 self.inner.get_description()
215 }
216 /// <p>The Amazon Resource Name (ARN) of the IAM role associated with the rule.</p>
217 /// <p>If you're setting an event bus in another account as the target and that account granted permission to your account through an organization instead of directly by the account ID, you must specify a <code>RoleArn</code> with proper permissions in the <code>Target</code> structure, instead of here in this parameter.</p>
218 pub fn role_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
219 self.inner = self.inner.role_arn(input.into());
220 self
221 }
222 /// <p>The Amazon Resource Name (ARN) of the IAM role associated with the rule.</p>
223 /// <p>If you're setting an event bus in another account as the target and that account granted permission to your account through an organization instead of directly by the account ID, you must specify a <code>RoleArn</code> with proper permissions in the <code>Target</code> structure, instead of here in this parameter.</p>
224 pub fn set_role_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
225 self.inner = self.inner.set_role_arn(input);
226 self
227 }
228 /// <p>The Amazon Resource Name (ARN) of the IAM role associated with the rule.</p>
229 /// <p>If you're setting an event bus in another account as the target and that account granted permission to your account through an organization instead of directly by the account ID, you must specify a <code>RoleArn</code> with proper permissions in the <code>Target</code> structure, instead of here in this parameter.</p>
230 pub fn get_role_arn(&self) -> &::std::option::Option<::std::string::String> {
231 self.inner.get_role_arn()
232 }
233 ///
234 /// Appends an item to `Tags`.
235 ///
236 /// To override the contents of this collection use [`set_tags`](Self::set_tags).
237 ///
238 /// <p>The list of key-value pairs to associate with the rule.</p>
239 pub fn tags(mut self, input: crate::types::Tag) -> Self {
240 self.inner = self.inner.tags(input);
241 self
242 }
243 /// <p>The list of key-value pairs to associate with the rule.</p>
244 pub fn set_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>) -> Self {
245 self.inner = self.inner.set_tags(input);
246 self
247 }
248 /// <p>The list of key-value pairs to associate with the rule.</p>
249 pub fn get_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Tag>> {
250 self.inner.get_tags()
251 }
252 /// <p>The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.</p>
253 pub fn event_bus_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
254 self.inner = self.inner.event_bus_name(input.into());
255 self
256 }
257 /// <p>The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.</p>
258 pub fn set_event_bus_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
259 self.inner = self.inner.set_event_bus_name(input);
260 self
261 }
262 /// <p>The name or ARN of the event bus to associate with this rule. If you omit this, the default event bus is used.</p>
263 pub fn get_event_bus_name(&self) -> &::std::option::Option<::std::string::String> {
264 self.inner.get_event_bus_name()
265 }
266}