Skip to main content

aws_sdk_kendra/types/
_document_attribute.rs

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