Skip to main content

aws_sdk_pipes/types/
_tag.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>A key-value pair associated with an Amazon Web Services resource. In EventBridge, rules and event buses support tagging.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
6pub struct Tag {
7    /// <p>A string you can use to assign a value. The combination of tag keys and values can help you organize and categorize your resources.</p>
8    pub key: ::std::string::String,
9    /// <p>The value for the specified tag key.</p>
10    pub value: ::std::string::String,
11}
12impl Tag {
13    /// <p>A string you can use to assign a value. The combination of tag keys and values can help you organize and categorize your resources.</p>
14    pub fn key(&self) -> &str {
15        use std::ops::Deref;
16        self.key.deref()
17    }
18    /// <p>The value for the specified tag key.</p>
19    pub fn value(&self) -> &str {
20        use std::ops::Deref;
21        self.value.deref()
22    }
23}
24impl ::std::fmt::Debug for Tag {
25    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
26        let mut formatter = f.debug_struct("Tag");
27        formatter.field("key", &self.key);
28        formatter.field("value", &"*** Sensitive Data Redacted ***");
29        formatter.finish()
30    }
31}
32impl Tag {
33    /// Creates a new builder-style object to manufacture [`Tag`](crate::types::Tag).
34    pub fn builder() -> crate::types::builders::TagBuilder {
35        crate::types::builders::TagBuilder::default()
36    }
37}
38
39/// A builder for [`Tag`](crate::types::Tag).
40#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)]
41#[non_exhaustive]
42pub struct TagBuilder {
43    pub(crate) key: ::std::option::Option<::std::string::String>,
44    pub(crate) value: ::std::option::Option<::std::string::String>,
45}
46impl TagBuilder {
47    /// <p>A string you can use to assign a value. The combination of tag keys and values can help you organize and categorize your resources.</p>
48    /// This field is required.
49    pub fn key(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
50        self.key = ::std::option::Option::Some(input.into());
51        self
52    }
53    /// <p>A string you can use to assign a value. The combination of tag keys and values can help you organize and categorize your resources.</p>
54    pub fn set_key(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
55        self.key = input;
56        self
57    }
58    /// <p>A string you can use to assign a value. The combination of tag keys and values can help you organize and categorize your resources.</p>
59    pub fn get_key(&self) -> &::std::option::Option<::std::string::String> {
60        &self.key
61    }
62    /// <p>The value for the specified tag key.</p>
63    /// This field is required.
64    pub fn value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
65        self.value = ::std::option::Option::Some(input.into());
66        self
67    }
68    /// <p>The value for the specified tag key.</p>
69    pub fn set_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
70        self.value = input;
71        self
72    }
73    /// <p>The value for the specified tag key.</p>
74    pub fn get_value(&self) -> &::std::option::Option<::std::string::String> {
75        &self.value
76    }
77    /// Consumes the builder and constructs a [`Tag`](crate::types::Tag).
78    /// This method will fail if any of the following fields are not set:
79    /// - [`key`](crate::types::builders::TagBuilder::key)
80    /// - [`value`](crate::types::builders::TagBuilder::value)
81    pub fn build(self) -> ::std::result::Result<crate::types::Tag, ::aws_smithy_types::error::operation::BuildError> {
82        ::std::result::Result::Ok(crate::types::Tag {
83            key: self.key.ok_or_else(|| {
84                ::aws_smithy_types::error::operation::BuildError::missing_field("key", "key was not specified but it is required when building Tag")
85            })?,
86            value: self.value.ok_or_else(|| {
87                ::aws_smithy_types::error::operation::BuildError::missing_field(
88                    "value",
89                    "value was not specified but it is required when building Tag",
90                )
91            })?,
92        })
93    }
94}
95impl ::std::fmt::Debug for TagBuilder {
96    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
97        let mut formatter = f.debug_struct("TagBuilder");
98        formatter.field("key", &self.key);
99        formatter.field("value", &"*** Sensitive Data Redacted ***");
100        formatter.finish()
101    }
102}