aws_sdk_backup/types/_key_value.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Pair of two related strings. Allowed characters are letters, white space, and numbers that can be represented in UTF-8 and the following characters: <code> + - = . _ : /</code></p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct KeyValue {
7 /// <p>The tag key (String). The key can't start with <code>aws:</code>.</p>
8 /// <p>Length Constraints: Minimum length of 1. Maximum length of 128.</p>
9 /// <p>Pattern: <code>^(?!\[aA\]{1}\[wW\]{1}\[sS\]{1}:)(\[\p{L}\p{Z}\p{N}_.:/=+\-@\]+)$</code></p>
10 pub key: ::std::string::String,
11 /// <p>The value of the key.</p>
12 /// <p>Length Constraints: Maximum length of 256.</p>
13 /// <p>Pattern: <code>^(\[\p{L}\p{Z}\p{N}_.:/=+\-@\]*)$</code></p>
14 pub value: ::std::string::String,
15}
16impl KeyValue {
17 /// <p>The tag key (String). The key can't start with <code>aws:</code>.</p>
18 /// <p>Length Constraints: Minimum length of 1. Maximum length of 128.</p>
19 /// <p>Pattern: <code>^(?!\[aA\]{1}\[wW\]{1}\[sS\]{1}:)(\[\p{L}\p{Z}\p{N}_.:/=+\-@\]+)$</code></p>
20 pub fn key(&self) -> &str {
21 use std::ops::Deref;
22 self.key.deref()
23 }
24 /// <p>The value of the key.</p>
25 /// <p>Length Constraints: Maximum length of 256.</p>
26 /// <p>Pattern: <code>^(\[\p{L}\p{Z}\p{N}_.:/=+\-@\]*)$</code></p>
27 pub fn value(&self) -> &str {
28 use std::ops::Deref;
29 self.value.deref()
30 }
31}
32impl KeyValue {
33 /// Creates a new builder-style object to manufacture [`KeyValue`](crate::types::KeyValue).
34 pub fn builder() -> crate::types::builders::KeyValueBuilder {
35 crate::types::builders::KeyValueBuilder::default()
36 }
37}
38
39/// A builder for [`KeyValue`](crate::types::KeyValue).
40#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
41#[non_exhaustive]
42pub struct KeyValueBuilder {
43 pub(crate) key: ::std::option::Option<::std::string::String>,
44 pub(crate) value: ::std::option::Option<::std::string::String>,
45}
46impl KeyValueBuilder {
47 /// <p>The tag key (String). The key can't start with <code>aws:</code>.</p>
48 /// <p>Length Constraints: Minimum length of 1. Maximum length of 128.</p>
49 /// <p>Pattern: <code>^(?!\[aA\]{1}\[wW\]{1}\[sS\]{1}:)(\[\p{L}\p{Z}\p{N}_.:/=+\-@\]+)$</code></p>
50 /// This field is required.
51 pub fn key(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
52 self.key = ::std::option::Option::Some(input.into());
53 self
54 }
55 /// <p>The tag key (String). The key can't start with <code>aws:</code>.</p>
56 /// <p>Length Constraints: Minimum length of 1. Maximum length of 128.</p>
57 /// <p>Pattern: <code>^(?!\[aA\]{1}\[wW\]{1}\[sS\]{1}:)(\[\p{L}\p{Z}\p{N}_.:/=+\-@\]+)$</code></p>
58 pub fn set_key(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
59 self.key = input;
60 self
61 }
62 /// <p>The tag key (String). The key can't start with <code>aws:</code>.</p>
63 /// <p>Length Constraints: Minimum length of 1. Maximum length of 128.</p>
64 /// <p>Pattern: <code>^(?!\[aA\]{1}\[wW\]{1}\[sS\]{1}:)(\[\p{L}\p{Z}\p{N}_.:/=+\-@\]+)$</code></p>
65 pub fn get_key(&self) -> &::std::option::Option<::std::string::String> {
66 &self.key
67 }
68 /// <p>The value of the key.</p>
69 /// <p>Length Constraints: Maximum length of 256.</p>
70 /// <p>Pattern: <code>^(\[\p{L}\p{Z}\p{N}_.:/=+\-@\]*)$</code></p>
71 /// This field is required.
72 pub fn value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
73 self.value = ::std::option::Option::Some(input.into());
74 self
75 }
76 /// <p>The value of the key.</p>
77 /// <p>Length Constraints: Maximum length of 256.</p>
78 /// <p>Pattern: <code>^(\[\p{L}\p{Z}\p{N}_.:/=+\-@\]*)$</code></p>
79 pub fn set_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
80 self.value = input;
81 self
82 }
83 /// <p>The value of the key.</p>
84 /// <p>Length Constraints: Maximum length of 256.</p>
85 /// <p>Pattern: <code>^(\[\p{L}\p{Z}\p{N}_.:/=+\-@\]*)$</code></p>
86 pub fn get_value(&self) -> &::std::option::Option<::std::string::String> {
87 &self.value
88 }
89 /// Consumes the builder and constructs a [`KeyValue`](crate::types::KeyValue).
90 /// This method will fail if any of the following fields are not set:
91 /// - [`key`](crate::types::builders::KeyValueBuilder::key)
92 /// - [`value`](crate::types::builders::KeyValueBuilder::value)
93 pub fn build(self) -> ::std::result::Result<crate::types::KeyValue, ::aws_smithy_types::error::operation::BuildError> {
94 ::std::result::Result::Ok(crate::types::KeyValue {
95 key: self.key.ok_or_else(|| {
96 ::aws_smithy_types::error::operation::BuildError::missing_field(
97 "key",
98 "key was not specified but it is required when building KeyValue",
99 )
100 })?,
101 value: self.value.ok_or_else(|| {
102 ::aws_smithy_types::error::operation::BuildError::missing_field(
103 "value",
104 "value was not specified but it is required when building KeyValue",
105 )
106 })?,
107 })
108 }
109}