Skip to main content

aws_sdk_datapipeline/types/
_field.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>A key-value pair that describes a property of a pipeline object. The value is specified as either a string value (<code>StringValue</code>) or a reference to another object (<code>RefValue</code>) but not as both.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct Field {
7    /// <p>The field identifier.</p>
8    pub key: ::std::string::String,
9    /// <p>The field value, expressed as a String.</p>
10    pub string_value: ::std::option::Option<::std::string::String>,
11    /// <p>The field value, expressed as the identifier of another object.</p>
12    pub ref_value: ::std::option::Option<::std::string::String>,
13}
14impl Field {
15    /// <p>The field identifier.</p>
16    pub fn key(&self) -> &str {
17        use std::ops::Deref;
18        self.key.deref()
19    }
20    /// <p>The field value, expressed as a String.</p>
21    pub fn string_value(&self) -> ::std::option::Option<&str> {
22        self.string_value.as_deref()
23    }
24    /// <p>The field value, expressed as the identifier of another object.</p>
25    pub fn ref_value(&self) -> ::std::option::Option<&str> {
26        self.ref_value.as_deref()
27    }
28}
29impl Field {
30    /// Creates a new builder-style object to manufacture [`Field`](crate::types::Field).
31    pub fn builder() -> crate::types::builders::FieldBuilder {
32        crate::types::builders::FieldBuilder::default()
33    }
34}
35
36/// A builder for [`Field`](crate::types::Field).
37#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
38#[non_exhaustive]
39pub struct FieldBuilder {
40    pub(crate) key: ::std::option::Option<::std::string::String>,
41    pub(crate) string_value: ::std::option::Option<::std::string::String>,
42    pub(crate) ref_value: ::std::option::Option<::std::string::String>,
43}
44impl FieldBuilder {
45    /// <p>The field identifier.</p>
46    /// This field is required.
47    pub fn key(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
48        self.key = ::std::option::Option::Some(input.into());
49        self
50    }
51    /// <p>The field identifier.</p>
52    pub fn set_key(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
53        self.key = input;
54        self
55    }
56    /// <p>The field identifier.</p>
57    pub fn get_key(&self) -> &::std::option::Option<::std::string::String> {
58        &self.key
59    }
60    /// <p>The field value, expressed as a String.</p>
61    pub fn string_value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
62        self.string_value = ::std::option::Option::Some(input.into());
63        self
64    }
65    /// <p>The field value, expressed as a String.</p>
66    pub fn set_string_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
67        self.string_value = input;
68        self
69    }
70    /// <p>The field value, expressed as a String.</p>
71    pub fn get_string_value(&self) -> &::std::option::Option<::std::string::String> {
72        &self.string_value
73    }
74    /// <p>The field value, expressed as the identifier of another object.</p>
75    pub fn ref_value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
76        self.ref_value = ::std::option::Option::Some(input.into());
77        self
78    }
79    /// <p>The field value, expressed as the identifier of another object.</p>
80    pub fn set_ref_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
81        self.ref_value = input;
82        self
83    }
84    /// <p>The field value, expressed as the identifier of another object.</p>
85    pub fn get_ref_value(&self) -> &::std::option::Option<::std::string::String> {
86        &self.ref_value
87    }
88    /// Consumes the builder and constructs a [`Field`](crate::types::Field).
89    /// This method will fail if any of the following fields are not set:
90    /// - [`key`](crate::types::builders::FieldBuilder::key)
91    pub fn build(self) -> ::std::result::Result<crate::types::Field, ::aws_smithy_types::error::operation::BuildError> {
92        ::std::result::Result::Ok(crate::types::Field {
93            key: self.key.ok_or_else(|| {
94                ::aws_smithy_types::error::operation::BuildError::missing_field("key", "key was not specified but it is required when building Field")
95            })?,
96            string_value: self.string_value,
97            ref_value: self.ref_value,
98        })
99    }
100}