aws-sdk-glue 1.147.0

AWS SDK for AWS Glue
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>The <code>Database</code> object represents a logical grouping of tables that might reside in a Hive metastore or an RDBMS.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Database {
    /// <p>The name of the database. For Hive compatibility, this is folded to lowercase when it is stored.</p>
    pub name: ::std::string::String,
    /// <p>A description of the database.</p>
    pub description: ::std::option::Option<::std::string::String>,
    /// <p>The location of the database (for example, an HDFS path).</p>
    pub location_uri: ::std::option::Option<::std::string::String>,
    /// <p>These key-value pairs define parameters and properties of the database.</p>
    pub parameters: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    /// <p>The time at which the metadata database was created in the catalog.</p>
    pub create_time: ::std::option::Option<::aws_smithy_types::DateTime>,
    /// <p>Creates a set of default permissions on the table for principals. Used by Lake Formation. Not used in the normal course of Glue operations.</p>
    pub create_table_default_permissions: ::std::option::Option<::std::vec::Vec<crate::types::PrincipalPermissions>>,
    /// <p>A <code>DatabaseIdentifier</code> structure that describes a target database for resource linking.</p>
    pub target_database: ::std::option::Option<crate::types::DatabaseIdentifier>,
    /// <p>The ID of the Data Catalog in which the database resides.</p>
    pub catalog_id: ::std::option::Option<::std::string::String>,
    /// <p>A <code>FederatedDatabase</code> structure that references an entity outside the Glue Data Catalog.</p>
    pub federated_database: ::std::option::Option<crate::types::FederatedDatabase>,
}
impl Database {
    /// <p>The name of the database. For Hive compatibility, this is folded to lowercase when it is stored.</p>
    pub fn name(&self) -> &str {
        use std::ops::Deref;
        self.name.deref()
    }
    /// <p>A description of the database.</p>
    pub fn description(&self) -> ::std::option::Option<&str> {
        self.description.as_deref()
    }
    /// <p>The location of the database (for example, an HDFS path).</p>
    pub fn location_uri(&self) -> ::std::option::Option<&str> {
        self.location_uri.as_deref()
    }
    /// <p>These key-value pairs define parameters and properties of the database.</p>
    pub fn parameters(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, ::std::string::String>> {
        self.parameters.as_ref()
    }
    /// <p>The time at which the metadata database was created in the catalog.</p>
    pub fn create_time(&self) -> ::std::option::Option<&::aws_smithy_types::DateTime> {
        self.create_time.as_ref()
    }
    /// <p>Creates a set of default permissions on the table for principals. Used by Lake Formation. Not used in the normal course of Glue operations.</p>
    ///
    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.create_table_default_permissions.is_none()`.
    pub fn create_table_default_permissions(&self) -> &[crate::types::PrincipalPermissions] {
        self.create_table_default_permissions.as_deref().unwrap_or_default()
    }
    /// <p>A <code>DatabaseIdentifier</code> structure that describes a target database for resource linking.</p>
    pub fn target_database(&self) -> ::std::option::Option<&crate::types::DatabaseIdentifier> {
        self.target_database.as_ref()
    }
    /// <p>The ID of the Data Catalog in which the database resides.</p>
    pub fn catalog_id(&self) -> ::std::option::Option<&str> {
        self.catalog_id.as_deref()
    }
    /// <p>A <code>FederatedDatabase</code> structure that references an entity outside the Glue Data Catalog.</p>
    pub fn federated_database(&self) -> ::std::option::Option<&crate::types::FederatedDatabase> {
        self.federated_database.as_ref()
    }
}
impl Database {
    /// Creates a new builder-style object to manufacture [`Database`](crate::types::Database).
    pub fn builder() -> crate::types::builders::DatabaseBuilder {
        crate::types::builders::DatabaseBuilder::default()
    }
}

/// A builder for [`Database`](crate::types::Database).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct DatabaseBuilder {
    pub(crate) name: ::std::option::Option<::std::string::String>,
    pub(crate) description: ::std::option::Option<::std::string::String>,
    pub(crate) location_uri: ::std::option::Option<::std::string::String>,
    pub(crate) parameters: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    pub(crate) create_time: ::std::option::Option<::aws_smithy_types::DateTime>,
    pub(crate) create_table_default_permissions: ::std::option::Option<::std::vec::Vec<crate::types::PrincipalPermissions>>,
    pub(crate) target_database: ::std::option::Option<crate::types::DatabaseIdentifier>,
    pub(crate) catalog_id: ::std::option::Option<::std::string::String>,
    pub(crate) federated_database: ::std::option::Option<crate::types::FederatedDatabase>,
}
impl DatabaseBuilder {
    /// <p>The name of the database. For Hive compatibility, this is folded to lowercase when it is stored.</p>
    /// This field is required.
    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.name = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The name of the database. For Hive compatibility, this is folded to lowercase when it is stored.</p>
    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.name = input;
        self
    }
    /// <p>The name of the database. For Hive compatibility, this is folded to lowercase when it is stored.</p>
    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.name
    }
    /// <p>A description of the database.</p>
    pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.description = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>A description of the database.</p>
    pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.description = input;
        self
    }
    /// <p>A description of the database.</p>
    pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
        &self.description
    }
    /// <p>The location of the database (for example, an HDFS path).</p>
    pub fn location_uri(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.location_uri = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The location of the database (for example, an HDFS path).</p>
    pub fn set_location_uri(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.location_uri = input;
        self
    }
    /// <p>The location of the database (for example, an HDFS path).</p>
    pub fn get_location_uri(&self) -> &::std::option::Option<::std::string::String> {
        &self.location_uri
    }
    /// Adds a key-value pair to `parameters`.
    ///
    /// To override the contents of this collection use [`set_parameters`](Self::set_parameters).
    ///
    /// <p>These key-value pairs define parameters and properties of the database.</p>
    pub fn parameters(mut self, k: impl ::std::convert::Into<::std::string::String>, v: impl ::std::convert::Into<::std::string::String>) -> Self {
        let mut hash_map = self.parameters.unwrap_or_default();
        hash_map.insert(k.into(), v.into());
        self.parameters = ::std::option::Option::Some(hash_map);
        self
    }
    /// <p>These key-value pairs define parameters and properties of the database.</p>
    pub fn set_parameters(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>) -> Self {
        self.parameters = input;
        self
    }
    /// <p>These key-value pairs define parameters and properties of the database.</p>
    pub fn get_parameters(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
        &self.parameters
    }
    /// <p>The time at which the metadata database was created in the catalog.</p>
    pub fn create_time(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.create_time = ::std::option::Option::Some(input);
        self
    }
    /// <p>The time at which the metadata database was created in the catalog.</p>
    pub fn set_create_time(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.create_time = input;
        self
    }
    /// <p>The time at which the metadata database was created in the catalog.</p>
    pub fn get_create_time(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        &self.create_time
    }
    /// Appends an item to `create_table_default_permissions`.
    ///
    /// To override the contents of this collection use [`set_create_table_default_permissions`](Self::set_create_table_default_permissions).
    ///
    /// <p>Creates a set of default permissions on the table for principals. Used by Lake Formation. Not used in the normal course of Glue operations.</p>
    pub fn create_table_default_permissions(mut self, input: crate::types::PrincipalPermissions) -> Self {
        let mut v = self.create_table_default_permissions.unwrap_or_default();
        v.push(input);
        self.create_table_default_permissions = ::std::option::Option::Some(v);
        self
    }
    /// <p>Creates a set of default permissions on the table for principals. Used by Lake Formation. Not used in the normal course of Glue operations.</p>
    pub fn set_create_table_default_permissions(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::PrincipalPermissions>>) -> Self {
        self.create_table_default_permissions = input;
        self
    }
    /// <p>Creates a set of default permissions on the table for principals. Used by Lake Formation. Not used in the normal course of Glue operations.</p>
    pub fn get_create_table_default_permissions(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::PrincipalPermissions>> {
        &self.create_table_default_permissions
    }
    /// <p>A <code>DatabaseIdentifier</code> structure that describes a target database for resource linking.</p>
    pub fn target_database(mut self, input: crate::types::DatabaseIdentifier) -> Self {
        self.target_database = ::std::option::Option::Some(input);
        self
    }
    /// <p>A <code>DatabaseIdentifier</code> structure that describes a target database for resource linking.</p>
    pub fn set_target_database(mut self, input: ::std::option::Option<crate::types::DatabaseIdentifier>) -> Self {
        self.target_database = input;
        self
    }
    /// <p>A <code>DatabaseIdentifier</code> structure that describes a target database for resource linking.</p>
    pub fn get_target_database(&self) -> &::std::option::Option<crate::types::DatabaseIdentifier> {
        &self.target_database
    }
    /// <p>The ID of the Data Catalog in which the database resides.</p>
    pub fn catalog_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.catalog_id = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The ID of the Data Catalog in which the database resides.</p>
    pub fn set_catalog_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.catalog_id = input;
        self
    }
    /// <p>The ID of the Data Catalog in which the database resides.</p>
    pub fn get_catalog_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.catalog_id
    }
    /// <p>A <code>FederatedDatabase</code> structure that references an entity outside the Glue Data Catalog.</p>
    pub fn federated_database(mut self, input: crate::types::FederatedDatabase) -> Self {
        self.federated_database = ::std::option::Option::Some(input);
        self
    }
    /// <p>A <code>FederatedDatabase</code> structure that references an entity outside the Glue Data Catalog.</p>
    pub fn set_federated_database(mut self, input: ::std::option::Option<crate::types::FederatedDatabase>) -> Self {
        self.federated_database = input;
        self
    }
    /// <p>A <code>FederatedDatabase</code> structure that references an entity outside the Glue Data Catalog.</p>
    pub fn get_federated_database(&self) -> &::std::option::Option<crate::types::FederatedDatabase> {
        &self.federated_database
    }
    /// Consumes the builder and constructs a [`Database`](crate::types::Database).
    /// This method will fail if any of the following fields are not set:
    /// - [`name`](crate::types::builders::DatabaseBuilder::name)
    pub fn build(self) -> ::std::result::Result<crate::types::Database, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Database {
            name: self.name.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "name",
                    "name was not specified but it is required when building Database",
                )
            })?,
            description: self.description,
            location_uri: self.location_uri,
            parameters: self.parameters,
            create_time: self.create_time,
            create_table_default_permissions: self.create_table_default_permissions,
            target_database: self.target_database,
            catalog_id: self.catalog_id,
            federated_database: self.federated_database,
        })
    }
}