aws-sdk-accessanalyzer 1.106.0

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

/// <p>A location in a policy that is represented as a path through the JSON representation and a corresponding span.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Location {
    /// <p>A path in a policy, represented as a sequence of path elements.</p>
    pub path: ::std::vec::Vec<crate::types::PathElement>,
    /// <p>A span in a policy.</p>
    pub span: ::std::option::Option<crate::types::Span>,
}
impl Location {
    /// <p>A path in a policy, represented as a sequence of path elements.</p>
    pub fn path(&self) -> &[crate::types::PathElement] {
        use std::ops::Deref;
        self.path.deref()
    }
    /// <p>A span in a policy.</p>
    pub fn span(&self) -> ::std::option::Option<&crate::types::Span> {
        self.span.as_ref()
    }
}
impl Location {
    /// Creates a new builder-style object to manufacture [`Location`](crate::types::Location).
    pub fn builder() -> crate::types::builders::LocationBuilder {
        crate::types::builders::LocationBuilder::default()
    }
}

/// A builder for [`Location`](crate::types::Location).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct LocationBuilder {
    pub(crate) path: ::std::option::Option<::std::vec::Vec<crate::types::PathElement>>,
    pub(crate) span: ::std::option::Option<crate::types::Span>,
}
impl LocationBuilder {
    /// Appends an item to `path`.
    ///
    /// To override the contents of this collection use [`set_path`](Self::set_path).
    ///
    /// <p>A path in a policy, represented as a sequence of path elements.</p>
    pub fn path(mut self, input: crate::types::PathElement) -> Self {
        let mut v = self.path.unwrap_or_default();
        v.push(input);
        self.path = ::std::option::Option::Some(v);
        self
    }
    /// <p>A path in a policy, represented as a sequence of path elements.</p>
    pub fn set_path(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::PathElement>>) -> Self {
        self.path = input;
        self
    }
    /// <p>A path in a policy, represented as a sequence of path elements.</p>
    pub fn get_path(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::PathElement>> {
        &self.path
    }
    /// <p>A span in a policy.</p>
    /// This field is required.
    pub fn span(mut self, input: crate::types::Span) -> Self {
        self.span = ::std::option::Option::Some(input);
        self
    }
    /// <p>A span in a policy.</p>
    pub fn set_span(mut self, input: ::std::option::Option<crate::types::Span>) -> Self {
        self.span = input;
        self
    }
    /// <p>A span in a policy.</p>
    pub fn get_span(&self) -> &::std::option::Option<crate::types::Span> {
        &self.span
    }
    /// Consumes the builder and constructs a [`Location`](crate::types::Location).
    /// This method will fail if any of the following fields are not set:
    /// - [`path`](crate::types::builders::LocationBuilder::path)
    pub fn build(self) -> ::std::result::Result<crate::types::Location, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Location {
            path: self.path.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "path",
                    "path was not specified but it is required when building Location",
                )
            })?,
            span: self.span,
        })
    }
}