aws_sdk_s3/types/
_encryption.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Contains the type of server-side encryption used.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
6pub struct Encryption {
7    /// <p>The server-side encryption algorithm used when storing job results in Amazon S3 (for example, AES256, <code>aws:kms</code>).</p>
8    pub encryption_type: crate::types::ServerSideEncryption,
9    /// <p>If the encryption type is <code>aws:kms</code>, this optional value specifies the ID of the symmetric encryption customer managed key to use for encryption of job results. Amazon S3 only supports symmetric encryption KMS keys. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html">Asymmetric keys in KMS</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>
10    pub kms_key_id: ::std::option::Option<::std::string::String>,
11    /// <p>If the encryption type is <code>aws:kms</code>, this optional value can be used to specify the encryption context for the restore results.</p>
12    pub kms_context: ::std::option::Option<::std::string::String>,
13}
14impl Encryption {
15    /// <p>The server-side encryption algorithm used when storing job results in Amazon S3 (for example, AES256, <code>aws:kms</code>).</p>
16    pub fn encryption_type(&self) -> &crate::types::ServerSideEncryption {
17        &self.encryption_type
18    }
19    /// <p>If the encryption type is <code>aws:kms</code>, this optional value specifies the ID of the symmetric encryption customer managed key to use for encryption of job results. Amazon S3 only supports symmetric encryption KMS keys. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html">Asymmetric keys in KMS</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>
20    pub fn kms_key_id(&self) -> ::std::option::Option<&str> {
21        self.kms_key_id.as_deref()
22    }
23    /// <p>If the encryption type is <code>aws:kms</code>, this optional value can be used to specify the encryption context for the restore results.</p>
24    pub fn kms_context(&self) -> ::std::option::Option<&str> {
25        self.kms_context.as_deref()
26    }
27}
28impl ::std::fmt::Debug for Encryption {
29    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
30        let mut formatter = f.debug_struct("Encryption");
31        formatter.field("encryption_type", &self.encryption_type);
32        formatter.field("kms_key_id", &"*** Sensitive Data Redacted ***");
33        formatter.field("kms_context", &self.kms_context);
34        formatter.finish()
35    }
36}
37impl Encryption {
38    /// Creates a new builder-style object to manufacture [`Encryption`](crate::types::Encryption).
39    pub fn builder() -> crate::types::builders::EncryptionBuilder {
40        crate::types::builders::EncryptionBuilder::default()
41    }
42}
43
44/// A builder for [`Encryption`](crate::types::Encryption).
45#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)]
46#[non_exhaustive]
47pub struct EncryptionBuilder {
48    pub(crate) encryption_type: ::std::option::Option<crate::types::ServerSideEncryption>,
49    pub(crate) kms_key_id: ::std::option::Option<::std::string::String>,
50    pub(crate) kms_context: ::std::option::Option<::std::string::String>,
51}
52impl EncryptionBuilder {
53    /// <p>The server-side encryption algorithm used when storing job results in Amazon S3 (for example, AES256, <code>aws:kms</code>).</p>
54    /// This field is required.
55    pub fn encryption_type(mut self, input: crate::types::ServerSideEncryption) -> Self {
56        self.encryption_type = ::std::option::Option::Some(input);
57        self
58    }
59    /// <p>The server-side encryption algorithm used when storing job results in Amazon S3 (for example, AES256, <code>aws:kms</code>).</p>
60    pub fn set_encryption_type(mut self, input: ::std::option::Option<crate::types::ServerSideEncryption>) -> Self {
61        self.encryption_type = input;
62        self
63    }
64    /// <p>The server-side encryption algorithm used when storing job results in Amazon S3 (for example, AES256, <code>aws:kms</code>).</p>
65    pub fn get_encryption_type(&self) -> &::std::option::Option<crate::types::ServerSideEncryption> {
66        &self.encryption_type
67    }
68    /// <p>If the encryption type is <code>aws:kms</code>, this optional value specifies the ID of the symmetric encryption customer managed key to use for encryption of job results. Amazon S3 only supports symmetric encryption KMS keys. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html">Asymmetric keys in KMS</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>
69    pub fn kms_key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
70        self.kms_key_id = ::std::option::Option::Some(input.into());
71        self
72    }
73    /// <p>If the encryption type is <code>aws:kms</code>, this optional value specifies the ID of the symmetric encryption customer managed key to use for encryption of job results. Amazon S3 only supports symmetric encryption KMS keys. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html">Asymmetric keys in KMS</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>
74    pub fn set_kms_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
75        self.kms_key_id = input;
76        self
77    }
78    /// <p>If the encryption type is <code>aws:kms</code>, this optional value specifies the ID of the symmetric encryption customer managed key to use for encryption of job results. Amazon S3 only supports symmetric encryption KMS keys. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html">Asymmetric keys in KMS</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>
79    pub fn get_kms_key_id(&self) -> &::std::option::Option<::std::string::String> {
80        &self.kms_key_id
81    }
82    /// <p>If the encryption type is <code>aws:kms</code>, this optional value can be used to specify the encryption context for the restore results.</p>
83    pub fn kms_context(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
84        self.kms_context = ::std::option::Option::Some(input.into());
85        self
86    }
87    /// <p>If the encryption type is <code>aws:kms</code>, this optional value can be used to specify the encryption context for the restore results.</p>
88    pub fn set_kms_context(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
89        self.kms_context = input;
90        self
91    }
92    /// <p>If the encryption type is <code>aws:kms</code>, this optional value can be used to specify the encryption context for the restore results.</p>
93    pub fn get_kms_context(&self) -> &::std::option::Option<::std::string::String> {
94        &self.kms_context
95    }
96    /// Consumes the builder and constructs a [`Encryption`](crate::types::Encryption).
97    /// This method will fail if any of the following fields are not set:
98    /// - [`encryption_type`](crate::types::builders::EncryptionBuilder::encryption_type)
99    pub fn build(self) -> ::std::result::Result<crate::types::Encryption, ::aws_smithy_types::error::operation::BuildError> {
100        ::std::result::Result::Ok(crate::types::Encryption {
101            encryption_type: self.encryption_type.ok_or_else(|| {
102                ::aws_smithy_types::error::operation::BuildError::missing_field(
103                    "encryption_type",
104                    "encryption_type was not specified but it is required when building Encryption",
105                )
106            })?,
107            kms_key_id: self.kms_key_id,
108            kms_context: self.kms_context,
109        })
110    }
111}
112impl ::std::fmt::Debug for EncryptionBuilder {
113    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
114        let mut formatter = f.debug_struct("EncryptionBuilder");
115        formatter.field("encryption_type", &self.encryption_type);
116        formatter.field("kms_key_id", &"*** Sensitive Data Redacted ***");
117        formatter.field("kms_context", &self.kms_context);
118        formatter.finish()
119    }
120}