aws-sdk-kendra 1.95.0

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

/// <p>Provides user and group information for <a href="https://docs.aws.amazon.com/kendra/latest/dg/user-context-filter.html">user context filtering</a>.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Principal {
    /// <p>The name of the user or group.</p>
    pub name: ::std::string::String,
    /// <p>The type of principal.</p>
    pub r#type: crate::types::PrincipalType,
    /// <p>Whether to allow or deny document access to the principal.</p>
    pub access: crate::types::ReadAccessType,
    /// <p>The identifier of the data source the principal should access documents from.</p>
    pub data_source_id: ::std::option::Option<::std::string::String>,
}
impl Principal {
    /// <p>The name of the user or group.</p>
    pub fn name(&self) -> &str {
        use std::ops::Deref;
        self.name.deref()
    }
    /// <p>The type of principal.</p>
    pub fn r#type(&self) -> &crate::types::PrincipalType {
        &self.r#type
    }
    /// <p>Whether to allow or deny document access to the principal.</p>
    pub fn access(&self) -> &crate::types::ReadAccessType {
        &self.access
    }
    /// <p>The identifier of the data source the principal should access documents from.</p>
    pub fn data_source_id(&self) -> ::std::option::Option<&str> {
        self.data_source_id.as_deref()
    }
}
impl Principal {
    /// Creates a new builder-style object to manufacture [`Principal`](crate::types::Principal).
    pub fn builder() -> crate::types::builders::PrincipalBuilder {
        crate::types::builders::PrincipalBuilder::default()
    }
}

/// A builder for [`Principal`](crate::types::Principal).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct PrincipalBuilder {
    pub(crate) name: ::std::option::Option<::std::string::String>,
    pub(crate) r#type: ::std::option::Option<crate::types::PrincipalType>,
    pub(crate) access: ::std::option::Option<crate::types::ReadAccessType>,
    pub(crate) data_source_id: ::std::option::Option<::std::string::String>,
}
impl PrincipalBuilder {
    /// <p>The name of the user or group.</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 user or group.</p>
    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.name = input;
        self
    }
    /// <p>The name of the user or group.</p>
    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.name
    }
    /// <p>The type of principal.</p>
    /// This field is required.
    pub fn r#type(mut self, input: crate::types::PrincipalType) -> Self {
        self.r#type = ::std::option::Option::Some(input);
        self
    }
    /// <p>The type of principal.</p>
    pub fn set_type(mut self, input: ::std::option::Option<crate::types::PrincipalType>) -> Self {
        self.r#type = input;
        self
    }
    /// <p>The type of principal.</p>
    pub fn get_type(&self) -> &::std::option::Option<crate::types::PrincipalType> {
        &self.r#type
    }
    /// <p>Whether to allow or deny document access to the principal.</p>
    /// This field is required.
    pub fn access(mut self, input: crate::types::ReadAccessType) -> Self {
        self.access = ::std::option::Option::Some(input);
        self
    }
    /// <p>Whether to allow or deny document access to the principal.</p>
    pub fn set_access(mut self, input: ::std::option::Option<crate::types::ReadAccessType>) -> Self {
        self.access = input;
        self
    }
    /// <p>Whether to allow or deny document access to the principal.</p>
    pub fn get_access(&self) -> &::std::option::Option<crate::types::ReadAccessType> {
        &self.access
    }
    /// <p>The identifier of the data source the principal should access documents from.</p>
    pub fn data_source_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.data_source_id = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The identifier of the data source the principal should access documents from.</p>
    pub fn set_data_source_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.data_source_id = input;
        self
    }
    /// <p>The identifier of the data source the principal should access documents from.</p>
    pub fn get_data_source_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.data_source_id
    }
    /// Consumes the builder and constructs a [`Principal`](crate::types::Principal).
    /// This method will fail if any of the following fields are not set:
    /// - [`name`](crate::types::builders::PrincipalBuilder::name)
    /// - [`r#type`](crate::types::builders::PrincipalBuilder::type)
    /// - [`access`](crate::types::builders::PrincipalBuilder::access)
    pub fn build(self) -> ::std::result::Result<crate::types::Principal, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Principal {
            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 Principal",
                )
            })?,
            r#type: self.r#type.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "r#type",
                    "r#type was not specified but it is required when building Principal",
                )
            })?,
            access: self.access.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "access",
                    "access was not specified but it is required when building Principal",
                )
            })?,
            data_source_id: self.data_source_id,
        })
    }
}