Skip to main content

aws_sdk_codestarconnections/types/
_tag.rs

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