aws-sdk-cloudextensions 1.0.0

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

/// Declares a host capability that an extension requires. Capabilities must be explicitly approved by the deployer before the extension can use them.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Capability {
    /// A unique identifier for this capability within the extension's configuration.
    pub id: ::std::string::String,
    /// A description of why the extension needs this capability and how it will be used.
    pub purpose: ::std::string::String,
    /// Whether this capability is mandatory for the extension to function. Defaults to false.
    pub required: ::std::option::Option<bool>,
    /// The type-specific details of the requested capability.
    pub definition: ::std::option::Option<crate::types::CapabilityDefinition>,
}
impl Capability {
    /// A unique identifier for this capability within the extension's configuration.
    pub fn id(&self) -> &str {
        use std::ops::Deref;
        self.id.deref()
    }
    /// A description of why the extension needs this capability and how it will be used.
    pub fn purpose(&self) -> &str {
        use std::ops::Deref;
        self.purpose.deref()
    }
    /// Whether this capability is mandatory for the extension to function. Defaults to false.
    pub fn required(&self) -> ::std::option::Option<bool> {
        self.required
    }
    /// The type-specific details of the requested capability.
    pub fn definition(&self) -> ::std::option::Option<&crate::types::CapabilityDefinition> {
        self.definition.as_ref()
    }
}
impl Capability {
    /// Creates a new builder-style object to manufacture [`Capability`](crate::types::Capability).
    pub fn builder() -> crate::types::builders::CapabilityBuilder {
        crate::types::builders::CapabilityBuilder::default()
    }
}

/// A builder for [`Capability`](crate::types::Capability).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct CapabilityBuilder {
    pub(crate) id: ::std::option::Option<::std::string::String>,
    pub(crate) purpose: ::std::option::Option<::std::string::String>,
    pub(crate) required: ::std::option::Option<bool>,
    pub(crate) definition: ::std::option::Option<crate::types::CapabilityDefinition>,
}
impl CapabilityBuilder {
    /// A unique identifier for this capability within the extension's configuration.
    /// This field is required.
    pub fn id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.id = ::std::option::Option::Some(input.into());
        self
    }
    /// A unique identifier for this capability within the extension's configuration.
    pub fn set_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.id = input;
        self
    }
    /// A unique identifier for this capability within the extension's configuration.
    pub fn get_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.id
    }
    /// A description of why the extension needs this capability and how it will be used.
    /// This field is required.
    pub fn purpose(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.purpose = ::std::option::Option::Some(input.into());
        self
    }
    /// A description of why the extension needs this capability and how it will be used.
    pub fn set_purpose(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.purpose = input;
        self
    }
    /// A description of why the extension needs this capability and how it will be used.
    pub fn get_purpose(&self) -> &::std::option::Option<::std::string::String> {
        &self.purpose
    }
    /// Whether this capability is mandatory for the extension to function. Defaults to false.
    pub fn required(mut self, input: bool) -> Self {
        self.required = ::std::option::Option::Some(input);
        self
    }
    /// Whether this capability is mandatory for the extension to function. Defaults to false.
    pub fn set_required(mut self, input: ::std::option::Option<bool>) -> Self {
        self.required = input;
        self
    }
    /// Whether this capability is mandatory for the extension to function. Defaults to false.
    pub fn get_required(&self) -> &::std::option::Option<bool> {
        &self.required
    }
    /// The type-specific details of the requested capability.
    /// This field is required.
    pub fn definition(mut self, input: crate::types::CapabilityDefinition) -> Self {
        self.definition = ::std::option::Option::Some(input);
        self
    }
    /// The type-specific details of the requested capability.
    pub fn set_definition(mut self, input: ::std::option::Option<crate::types::CapabilityDefinition>) -> Self {
        self.definition = input;
        self
    }
    /// The type-specific details of the requested capability.
    pub fn get_definition(&self) -> &::std::option::Option<crate::types::CapabilityDefinition> {
        &self.definition
    }
    /// Consumes the builder and constructs a [`Capability`](crate::types::Capability).
    /// This method will fail if any of the following fields are not set:
    /// - [`id`](crate::types::builders::CapabilityBuilder::id)
    /// - [`purpose`](crate::types::builders::CapabilityBuilder::purpose)
    pub fn build(self) -> ::std::result::Result<crate::types::Capability, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Capability {
            id: self.id.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "id",
                    "id was not specified but it is required when building Capability",
                )
            })?,
            purpose: self.purpose.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "purpose",
                    "purpose was not specified but it is required when building Capability",
                )
            })?,
            required: self.required,
            definition: self.definition,
        })
    }
}