aws_sdk_transcribe/types/
_tag.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Adds metadata, in the form of a key:value pair, to the specified resource.</p>
4/// <p>For example, you could add the tag <code>Department:Sales</code> to a resource to indicate that it pertains to your organization's sales department. You can also use tags for tag-based access control.</p>
5/// <p>To learn more about tagging, see <a href="https://docs.aws.amazon.com/transcribe/latest/dg/tagging.html">Tagging resources</a>.</p>
6#[non_exhaustive]
7#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
8pub struct Tag {
9    /// <p>The first part of a key:value pair that forms a tag associated with a given resource. For example, in the tag <code>Department:Sales</code>, the key is 'Department'.</p>
10    pub key: ::std::string::String,
11    /// <p>The second part of a key:value pair that forms a tag associated with a given resource. For example, in the tag <code>Department:Sales</code>, the value is 'Sales'.</p>
12    /// <p>Note that you can set the value of a tag to an empty string, but you can't set the value of a tag to null. Omitting the tag value is the same as using an empty string.</p>
13    pub value: ::std::string::String,
14}
15impl Tag {
16    /// <p>The first part of a key:value pair that forms a tag associated with a given resource. For example, in the tag <code>Department:Sales</code>, the key is 'Department'.</p>
17    pub fn key(&self) -> &str {
18        use std::ops::Deref;
19        self.key.deref()
20    }
21    /// <p>The second part of a key:value pair that forms a tag associated with a given resource. For example, in the tag <code>Department:Sales</code>, the value is 'Sales'.</p>
22    /// <p>Note that you can set the value of a tag to an empty string, but you can't set the value of a tag to null. Omitting the tag value is the same as using an empty string.</p>
23    pub fn value(&self) -> &str {
24        use std::ops::Deref;
25        self.value.deref()
26    }
27}
28impl Tag {
29    /// Creates a new builder-style object to manufacture [`Tag`](crate::types::Tag).
30    pub fn builder() -> crate::types::builders::TagBuilder {
31        crate::types::builders::TagBuilder::default()
32    }
33}
34
35/// A builder for [`Tag`](crate::types::Tag).
36#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
37#[non_exhaustive]
38pub struct TagBuilder {
39    pub(crate) key: ::std::option::Option<::std::string::String>,
40    pub(crate) value: ::std::option::Option<::std::string::String>,
41}
42impl TagBuilder {
43    /// <p>The first part of a key:value pair that forms a tag associated with a given resource. For example, in the tag <code>Department:Sales</code>, the key is 'Department'.</p>
44    /// This field is required.
45    pub fn key(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
46        self.key = ::std::option::Option::Some(input.into());
47        self
48    }
49    /// <p>The first part of a key:value pair that forms a tag associated with a given resource. For example, in the tag <code>Department:Sales</code>, the key is 'Department'.</p>
50    pub fn set_key(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
51        self.key = input;
52        self
53    }
54    /// <p>The first part of a key:value pair that forms a tag associated with a given resource. For example, in the tag <code>Department:Sales</code>, the key is 'Department'.</p>
55    pub fn get_key(&self) -> &::std::option::Option<::std::string::String> {
56        &self.key
57    }
58    /// <p>The second part of a key:value pair that forms a tag associated with a given resource. For example, in the tag <code>Department:Sales</code>, the value is 'Sales'.</p>
59    /// <p>Note that you can set the value of a tag to an empty string, but you can't set the value of a tag to null. Omitting the tag value is the same as using an empty string.</p>
60    /// This field is required.
61    pub fn value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
62        self.value = ::std::option::Option::Some(input.into());
63        self
64    }
65    /// <p>The second part of a key:value pair that forms a tag associated with a given resource. For example, in the tag <code>Department:Sales</code>, the value is 'Sales'.</p>
66    /// <p>Note that you can set the value of a tag to an empty string, but you can't set the value of a tag to null. Omitting the tag value is the same as using an empty string.</p>
67    pub fn set_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
68        self.value = input;
69        self
70    }
71    /// <p>The second part of a key:value pair that forms a tag associated with a given resource. For example, in the tag <code>Department:Sales</code>, the value is 'Sales'.</p>
72    /// <p>Note that you can set the value of a tag to an empty string, but you can't set the value of a tag to null. Omitting the tag value is the same as using an empty string.</p>
73    pub fn get_value(&self) -> &::std::option::Option<::std::string::String> {
74        &self.value
75    }
76    /// Consumes the builder and constructs a [`Tag`](crate::types::Tag).
77    /// This method will fail if any of the following fields are not set:
78    /// - [`key`](crate::types::builders::TagBuilder::key)
79    /// - [`value`](crate::types::builders::TagBuilder::value)
80    pub fn build(self) -> ::std::result::Result<crate::types::Tag, ::aws_smithy_types::error::operation::BuildError> {
81        ::std::result::Result::Ok(crate::types::Tag {
82            key: self.key.ok_or_else(|| {
83                ::aws_smithy_types::error::operation::BuildError::missing_field("key", "key was not specified but it is required when building Tag")
84            })?,
85            value: self.value.ok_or_else(|| {
86                ::aws_smithy_types::error::operation::BuildError::missing_field(
87                    "value",
88                    "value was not specified but it is required when building Tag",
89                )
90            })?,
91        })
92    }
93}