aws_sdk_glue/types/
_sql_alias.rs

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