Skip to main content

aws_sdk_athena/types/
_database.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Contains metadata information for a database in a data catalog.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct Database {
7    /// <p>The name of the database.</p>
8    pub name: ::std::string::String,
9    /// <p>An optional description of the database.</p>
10    pub description: ::std::option::Option<::std::string::String>,
11    /// <p>A set of custom key/value pairs.</p>
12    pub parameters: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
13}
14impl Database {
15    /// <p>The name of the database.</p>
16    pub fn name(&self) -> &str {
17        use std::ops::Deref;
18        self.name.deref()
19    }
20    /// <p>An optional description of the database.</p>
21    pub fn description(&self) -> ::std::option::Option<&str> {
22        self.description.as_deref()
23    }
24    /// <p>A set of custom key/value pairs.</p>
25    pub fn parameters(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, ::std::string::String>> {
26        self.parameters.as_ref()
27    }
28}
29impl Database {
30    /// Creates a new builder-style object to manufacture [`Database`](crate::types::Database).
31    pub fn builder() -> crate::types::builders::DatabaseBuilder {
32        crate::types::builders::DatabaseBuilder::default()
33    }
34}
35
36/// A builder for [`Database`](crate::types::Database).
37#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
38#[non_exhaustive]
39pub struct DatabaseBuilder {
40    pub(crate) name: ::std::option::Option<::std::string::String>,
41    pub(crate) description: ::std::option::Option<::std::string::String>,
42    pub(crate) parameters: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
43}
44impl DatabaseBuilder {
45    /// <p>The name of the database.</p>
46    /// This field is required.
47    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
48        self.name = ::std::option::Option::Some(input.into());
49        self
50    }
51    /// <p>The name of the database.</p>
52    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
53        self.name = input;
54        self
55    }
56    /// <p>The name of the database.</p>
57    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
58        &self.name
59    }
60    /// <p>An optional description of the database.</p>
61    pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
62        self.description = ::std::option::Option::Some(input.into());
63        self
64    }
65    /// <p>An optional description of the database.</p>
66    pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
67        self.description = input;
68        self
69    }
70    /// <p>An optional description of the database.</p>
71    pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
72        &self.description
73    }
74    /// Adds a key-value pair to `parameters`.
75    ///
76    /// To override the contents of this collection use [`set_parameters`](Self::set_parameters).
77    ///
78    /// <p>A set of custom key/value pairs.</p>
79    pub fn parameters(mut self, k: impl ::std::convert::Into<::std::string::String>, v: impl ::std::convert::Into<::std::string::String>) -> Self {
80        let mut hash_map = self.parameters.unwrap_or_default();
81        hash_map.insert(k.into(), v.into());
82        self.parameters = ::std::option::Option::Some(hash_map);
83        self
84    }
85    /// <p>A set of custom key/value pairs.</p>
86    pub fn set_parameters(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>) -> Self {
87        self.parameters = input;
88        self
89    }
90    /// <p>A set of custom key/value pairs.</p>
91    pub fn get_parameters(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
92        &self.parameters
93    }
94    /// Consumes the builder and constructs a [`Database`](crate::types::Database).
95    /// This method will fail if any of the following fields are not set:
96    /// - [`name`](crate::types::builders::DatabaseBuilder::name)
97    pub fn build(self) -> ::std::result::Result<crate::types::Database, ::aws_smithy_types::error::operation::BuildError> {
98        ::std::result::Result::Ok(crate::types::Database {
99            name: self.name.ok_or_else(|| {
100                ::aws_smithy_types::error::operation::BuildError::missing_field(
101                    "name",
102                    "name was not specified but it is required when building Database",
103                )
104            })?,
105            description: self.description,
106            parameters: self.parameters,
107        })
108    }
109}