1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>A structure that contains the information about one evaluation event or custom event sent to Evidently. This is a JSON payload. If this event specifies a pre-defined event type, the payload must follow the defined event schema.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Event {
/// <p>The timestamp of the event.</p>
pub timestamp: ::aws_smithy_types::DateTime,
/// <p><code>aws.evidently.evaluation</code> specifies an evaluation event, which determines which feature variation that a user sees. <code>aws.evidently.custom</code> specifies a custom event, which generates metrics from user actions such as clicks and checkouts.</p>
pub r#type: crate::types::EventType,
/// <p>The event data.</p>
pub data: ::std::string::String,
}
impl Event {
/// <p>The timestamp of the event.</p>
pub fn timestamp(&self) -> &::aws_smithy_types::DateTime {
&self.timestamp
}
/// <p><code>aws.evidently.evaluation</code> specifies an evaluation event, which determines which feature variation that a user sees. <code>aws.evidently.custom</code> specifies a custom event, which generates metrics from user actions such as clicks and checkouts.</p>
pub fn r#type(&self) -> &crate::types::EventType {
&self.r#type
}
/// <p>The event data.</p>
pub fn data(&self) -> &str {
use std::ops::Deref;
self.data.deref()
}
}
impl Event {
/// Creates a new builder-style object to manufacture [`Event`](crate::types::Event).
pub fn builder() -> crate::types::builders::EventBuilder {
crate::types::builders::EventBuilder::default()
}
}
/// A builder for [`Event`](crate::types::Event).
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
pub struct EventBuilder {
pub(crate) timestamp: ::std::option::Option<::aws_smithy_types::DateTime>,
pub(crate) r#type: ::std::option::Option<crate::types::EventType>,
pub(crate) data: ::std::option::Option<::std::string::String>,
}
impl EventBuilder {
/// <p>The timestamp of the event.</p>
/// This field is required.
pub fn timestamp(mut self, input: ::aws_smithy_types::DateTime) -> Self {
self.timestamp = ::std::option::Option::Some(input);
self
}
/// <p>The timestamp of the event.</p>
pub fn set_timestamp(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
self.timestamp = input;
self
}
/// <p>The timestamp of the event.</p>
pub fn get_timestamp(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
&self.timestamp
}
/// <p><code>aws.evidently.evaluation</code> specifies an evaluation event, which determines which feature variation that a user sees. <code>aws.evidently.custom</code> specifies a custom event, which generates metrics from user actions such as clicks and checkouts.</p>
/// This field is required.
pub fn r#type(mut self, input: crate::types::EventType) -> Self {
self.r#type = ::std::option::Option::Some(input);
self
}
/// <p><code>aws.evidently.evaluation</code> specifies an evaluation event, which determines which feature variation that a user sees. <code>aws.evidently.custom</code> specifies a custom event, which generates metrics from user actions such as clicks and checkouts.</p>
pub fn set_type(mut self, input: ::std::option::Option<crate::types::EventType>) -> Self {
self.r#type = input;
self
}
/// <p><code>aws.evidently.evaluation</code> specifies an evaluation event, which determines which feature variation that a user sees. <code>aws.evidently.custom</code> specifies a custom event, which generates metrics from user actions such as clicks and checkouts.</p>
pub fn get_type(&self) -> &::std::option::Option<crate::types::EventType> {
&self.r#type
}
/// <p>The event data.</p>
/// This field is required.
pub fn data(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.data = ::std::option::Option::Some(input.into());
self
}
/// <p>The event data.</p>
pub fn set_data(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.data = input;
self
}
/// <p>The event data.</p>
pub fn get_data(&self) -> &::std::option::Option<::std::string::String> {
&self.data
}
/// Consumes the builder and constructs a [`Event`](crate::types::Event).
/// This method will fail if any of the following fields are not set:
/// - [`timestamp`](crate::types::builders::EventBuilder::timestamp)
/// - [`r#type`](crate::types::builders::EventBuilder::r#type)
/// - [`data`](crate::types::builders::EventBuilder::data)
pub fn build(self) -> ::std::result::Result<crate::types::Event, ::aws_smithy_types::error::operation::BuildError> {
::std::result::Result::Ok(crate::types::Event {
timestamp: self.timestamp.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"timestamp",
"timestamp was not specified but it is required when building Event",
)
})?,
r#type: self.r#type.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"r#type",
"r#type was not specified but it is required when building Event",
)
})?,
data: self.data.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"data",
"data was not specified but it is required when building Event",
)
})?,
})
}
}