aws-sdk-ecs 1.124.0

AWS SDK for Amazon EC2 Container Service
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>An object representing a container instance host device.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Device {
    /// <p>The path for the device on the host container instance.</p>
    pub host_path: ::std::string::String,
    /// <p>The path inside the container at which to expose the host device.</p>
    pub container_path: ::std::option::Option<::std::string::String>,
    /// <p>The explicit permissions to provide to the container for the device. By default, the container has permissions for <code>read</code>, <code>write</code>, and <code>mknod</code> for the device.</p>
    pub permissions: ::std::option::Option<::std::vec::Vec<crate::types::DeviceCgroupPermission>>,
}
impl Device {
    /// <p>The path for the device on the host container instance.</p>
    pub fn host_path(&self) -> &str {
        use std::ops::Deref;
        self.host_path.deref()
    }
    /// <p>The path inside the container at which to expose the host device.</p>
    pub fn container_path(&self) -> ::std::option::Option<&str> {
        self.container_path.as_deref()
    }
    /// <p>The explicit permissions to provide to the container for the device. By default, the container has permissions for <code>read</code>, <code>write</code>, and <code>mknod</code> for the device.</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 `.permissions.is_none()`.
    pub fn permissions(&self) -> &[crate::types::DeviceCgroupPermission] {
        self.permissions.as_deref().unwrap_or_default()
    }
}
impl Device {
    /// Creates a new builder-style object to manufacture [`Device`](crate::types::Device).
    pub fn builder() -> crate::types::builders::DeviceBuilder {
        crate::types::builders::DeviceBuilder::default()
    }
}

/// A builder for [`Device`](crate::types::Device).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct DeviceBuilder {
    pub(crate) host_path: ::std::option::Option<::std::string::String>,
    pub(crate) container_path: ::std::option::Option<::std::string::String>,
    pub(crate) permissions: ::std::option::Option<::std::vec::Vec<crate::types::DeviceCgroupPermission>>,
}
impl DeviceBuilder {
    /// <p>The path for the device on the host container instance.</p>
    /// This field is required.
    pub fn host_path(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.host_path = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The path for the device on the host container instance.</p>
    pub fn set_host_path(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.host_path = input;
        self
    }
    /// <p>The path for the device on the host container instance.</p>
    pub fn get_host_path(&self) -> &::std::option::Option<::std::string::String> {
        &self.host_path
    }
    /// <p>The path inside the container at which to expose the host device.</p>
    pub fn container_path(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.container_path = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The path inside the container at which to expose the host device.</p>
    pub fn set_container_path(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.container_path = input;
        self
    }
    /// <p>The path inside the container at which to expose the host device.</p>
    pub fn get_container_path(&self) -> &::std::option::Option<::std::string::String> {
        &self.container_path
    }
    /// Appends an item to `permissions`.
    ///
    /// To override the contents of this collection use [`set_permissions`](Self::set_permissions).
    ///
    /// <p>The explicit permissions to provide to the container for the device. By default, the container has permissions for <code>read</code>, <code>write</code>, and <code>mknod</code> for the device.</p>
    pub fn permissions(mut self, input: crate::types::DeviceCgroupPermission) -> Self {
        let mut v = self.permissions.unwrap_or_default();
        v.push(input);
        self.permissions = ::std::option::Option::Some(v);
        self
    }
    /// <p>The explicit permissions to provide to the container for the device. By default, the container has permissions for <code>read</code>, <code>write</code>, and <code>mknod</code> for the device.</p>
    pub fn set_permissions(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::DeviceCgroupPermission>>) -> Self {
        self.permissions = input;
        self
    }
    /// <p>The explicit permissions to provide to the container for the device. By default, the container has permissions for <code>read</code>, <code>write</code>, and <code>mknod</code> for the device.</p>
    pub fn get_permissions(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::DeviceCgroupPermission>> {
        &self.permissions
    }
    /// Consumes the builder and constructs a [`Device`](crate::types::Device).
    /// This method will fail if any of the following fields are not set:
    /// - [`host_path`](crate::types::builders::DeviceBuilder::host_path)
    pub fn build(self) -> ::std::result::Result<crate::types::Device, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Device {
            host_path: self.host_path.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "host_path",
                    "host_path was not specified but it is required when building Device",
                )
            })?,
            container_path: self.container_path,
            permissions: self.permissions,
        })
    }
}