aws_sdk_iot/types/_timestream_action.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>The Timestream rule action writes attributes (measures) from an MQTT message into an Amazon Timestream table. For more information, see the <a href="https://docs.aws.amazon.com/iot/latest/developerguide/timestream-rule-action.html">Timestream</a> topic rule action documentation.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct TimestreamAction {
7 /// <p>The ARN of the role that grants permission to write to the Amazon Timestream database table.</p>
8 pub role_arn: ::std::string::String,
9 /// <p>The name of an Amazon Timestream database.</p>
10 pub database_name: ::std::string::String,
11 /// <p>The name of the database table into which to write the measure records.</p>
12 pub table_name: ::std::string::String,
13 /// <p>Metadata attributes of the time series that are written in each measure record.</p>
14 pub dimensions: ::std::vec::Vec<crate::types::TimestreamDimension>,
15 /// <p>Specifies an application-defined value to replace the default value assigned to the Timestream record's timestamp in the <code>time</code> column.</p>
16 /// <p>You can use this property to specify the value and the precision of the Timestream record's timestamp. You can specify a value from the message payload or a value computed by a substitution template.</p>
17 /// <p>If omitted, the topic rule action assigns the timestamp, in milliseconds, at the time it processed the rule.</p>
18 pub timestamp: ::std::option::Option<crate::types::TimestreamTimestamp>,
19}
20impl TimestreamAction {
21 /// <p>The ARN of the role that grants permission to write to the Amazon Timestream database table.</p>
22 pub fn role_arn(&self) -> &str {
23 use std::ops::Deref;
24 self.role_arn.deref()
25 }
26 /// <p>The name of an Amazon Timestream database.</p>
27 pub fn database_name(&self) -> &str {
28 use std::ops::Deref;
29 self.database_name.deref()
30 }
31 /// <p>The name of the database table into which to write the measure records.</p>
32 pub fn table_name(&self) -> &str {
33 use std::ops::Deref;
34 self.table_name.deref()
35 }
36 /// <p>Metadata attributes of the time series that are written in each measure record.</p>
37 pub fn dimensions(&self) -> &[crate::types::TimestreamDimension] {
38 use std::ops::Deref;
39 self.dimensions.deref()
40 }
41 /// <p>Specifies an application-defined value to replace the default value assigned to the Timestream record's timestamp in the <code>time</code> column.</p>
42 /// <p>You can use this property to specify the value and the precision of the Timestream record's timestamp. You can specify a value from the message payload or a value computed by a substitution template.</p>
43 /// <p>If omitted, the topic rule action assigns the timestamp, in milliseconds, at the time it processed the rule.</p>
44 pub fn timestamp(&self) -> ::std::option::Option<&crate::types::TimestreamTimestamp> {
45 self.timestamp.as_ref()
46 }
47}
48impl TimestreamAction {
49 /// Creates a new builder-style object to manufacture [`TimestreamAction`](crate::types::TimestreamAction).
50 pub fn builder() -> crate::types::builders::TimestreamActionBuilder {
51 crate::types::builders::TimestreamActionBuilder::default()
52 }
53}
54
55/// A builder for [`TimestreamAction`](crate::types::TimestreamAction).
56#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
57#[non_exhaustive]
58pub struct TimestreamActionBuilder {
59 pub(crate) role_arn: ::std::option::Option<::std::string::String>,
60 pub(crate) database_name: ::std::option::Option<::std::string::String>,
61 pub(crate) table_name: ::std::option::Option<::std::string::String>,
62 pub(crate) dimensions: ::std::option::Option<::std::vec::Vec<crate::types::TimestreamDimension>>,
63 pub(crate) timestamp: ::std::option::Option<crate::types::TimestreamTimestamp>,
64}
65impl TimestreamActionBuilder {
66 /// <p>The ARN of the role that grants permission to write to the Amazon Timestream database table.</p>
67 /// This field is required.
68 pub fn role_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
69 self.role_arn = ::std::option::Option::Some(input.into());
70 self
71 }
72 /// <p>The ARN of the role that grants permission to write to the Amazon Timestream database table.</p>
73 pub fn set_role_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
74 self.role_arn = input;
75 self
76 }
77 /// <p>The ARN of the role that grants permission to write to the Amazon Timestream database table.</p>
78 pub fn get_role_arn(&self) -> &::std::option::Option<::std::string::String> {
79 &self.role_arn
80 }
81 /// <p>The name of an Amazon Timestream database.</p>
82 /// This field is required.
83 pub fn database_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
84 self.database_name = ::std::option::Option::Some(input.into());
85 self
86 }
87 /// <p>The name of an Amazon Timestream database.</p>
88 pub fn set_database_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
89 self.database_name = input;
90 self
91 }
92 /// <p>The name of an Amazon Timestream database.</p>
93 pub fn get_database_name(&self) -> &::std::option::Option<::std::string::String> {
94 &self.database_name
95 }
96 /// <p>The name of the database table into which to write the measure records.</p>
97 /// This field is required.
98 pub fn table_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
99 self.table_name = ::std::option::Option::Some(input.into());
100 self
101 }
102 /// <p>The name of the database table into which to write the measure records.</p>
103 pub fn set_table_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
104 self.table_name = input;
105 self
106 }
107 /// <p>The name of the database table into which to write the measure records.</p>
108 pub fn get_table_name(&self) -> &::std::option::Option<::std::string::String> {
109 &self.table_name
110 }
111 /// Appends an item to `dimensions`.
112 ///
113 /// To override the contents of this collection use [`set_dimensions`](Self::set_dimensions).
114 ///
115 /// <p>Metadata attributes of the time series that are written in each measure record.</p>
116 pub fn dimensions(mut self, input: crate::types::TimestreamDimension) -> Self {
117 let mut v = self.dimensions.unwrap_or_default();
118 v.push(input);
119 self.dimensions = ::std::option::Option::Some(v);
120 self
121 }
122 /// <p>Metadata attributes of the time series that are written in each measure record.</p>
123 pub fn set_dimensions(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::TimestreamDimension>>) -> Self {
124 self.dimensions = input;
125 self
126 }
127 /// <p>Metadata attributes of the time series that are written in each measure record.</p>
128 pub fn get_dimensions(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::TimestreamDimension>> {
129 &self.dimensions
130 }
131 /// <p>Specifies an application-defined value to replace the default value assigned to the Timestream record's timestamp in the <code>time</code> column.</p>
132 /// <p>You can use this property to specify the value and the precision of the Timestream record's timestamp. You can specify a value from the message payload or a value computed by a substitution template.</p>
133 /// <p>If omitted, the topic rule action assigns the timestamp, in milliseconds, at the time it processed the rule.</p>
134 pub fn timestamp(mut self, input: crate::types::TimestreamTimestamp) -> Self {
135 self.timestamp = ::std::option::Option::Some(input);
136 self
137 }
138 /// <p>Specifies an application-defined value to replace the default value assigned to the Timestream record's timestamp in the <code>time</code> column.</p>
139 /// <p>You can use this property to specify the value and the precision of the Timestream record's timestamp. You can specify a value from the message payload or a value computed by a substitution template.</p>
140 /// <p>If omitted, the topic rule action assigns the timestamp, in milliseconds, at the time it processed the rule.</p>
141 pub fn set_timestamp(mut self, input: ::std::option::Option<crate::types::TimestreamTimestamp>) -> Self {
142 self.timestamp = input;
143 self
144 }
145 /// <p>Specifies an application-defined value to replace the default value assigned to the Timestream record's timestamp in the <code>time</code> column.</p>
146 /// <p>You can use this property to specify the value and the precision of the Timestream record's timestamp. You can specify a value from the message payload or a value computed by a substitution template.</p>
147 /// <p>If omitted, the topic rule action assigns the timestamp, in milliseconds, at the time it processed the rule.</p>
148 pub fn get_timestamp(&self) -> &::std::option::Option<crate::types::TimestreamTimestamp> {
149 &self.timestamp
150 }
151 /// Consumes the builder and constructs a [`TimestreamAction`](crate::types::TimestreamAction).
152 /// This method will fail if any of the following fields are not set:
153 /// - [`role_arn`](crate::types::builders::TimestreamActionBuilder::role_arn)
154 /// - [`database_name`](crate::types::builders::TimestreamActionBuilder::database_name)
155 /// - [`table_name`](crate::types::builders::TimestreamActionBuilder::table_name)
156 /// - [`dimensions`](crate::types::builders::TimestreamActionBuilder::dimensions)
157 pub fn build(self) -> ::std::result::Result<crate::types::TimestreamAction, ::aws_smithy_types::error::operation::BuildError> {
158 ::std::result::Result::Ok(crate::types::TimestreamAction {
159 role_arn: self.role_arn.ok_or_else(|| {
160 ::aws_smithy_types::error::operation::BuildError::missing_field(
161 "role_arn",
162 "role_arn was not specified but it is required when building TimestreamAction",
163 )
164 })?,
165 database_name: self.database_name.ok_or_else(|| {
166 ::aws_smithy_types::error::operation::BuildError::missing_field(
167 "database_name",
168 "database_name was not specified but it is required when building TimestreamAction",
169 )
170 })?,
171 table_name: self.table_name.ok_or_else(|| {
172 ::aws_smithy_types::error::operation::BuildError::missing_field(
173 "table_name",
174 "table_name was not specified but it is required when building TimestreamAction",
175 )
176 })?,
177 dimensions: self.dimensions.ok_or_else(|| {
178 ::aws_smithy_types::error::operation::BuildError::missing_field(
179 "dimensions",
180 "dimensions was not specified but it is required when building TimestreamAction",
181 )
182 })?,
183 timestamp: self.timestamp,
184 })
185 }
186}