Skip to main content

aws_esdk/deps/aws_cryptography_keyStore/operation/create_key/
builders.rs

1// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0
3// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
4pub use crate::deps::aws_cryptography_keyStore::operation::create_key::_create_key_output::CreateKeyOutputBuilder;
5
6pub use crate::deps::aws_cryptography_keyStore::operation::create_key::_create_key_input::CreateKeyInputBuilder;
7
8impl CreateKeyInputBuilder {
9    /// Sends a request with this input using the given client.
10    pub async fn send_with(
11        self,
12        client: &crate::deps::aws_cryptography_keyStore::client::Client,
13    ) -> ::std::result::Result<
14        crate::deps::aws_cryptography_keyStore::operation::create_key::CreateKeyOutput,
15        crate::deps::aws_cryptography_keyStore::types::error::Error,
16    > {
17        let mut fluent_builder = client.create_key();
18        fluent_builder.inner = self;
19        fluent_builder.send().await
20    }
21}
22/// Fluent builder constructing a request to `CreateKey`.
23///
24/// Create a new Branch Key in the Key Store. Additionally create a Beacon Key that is tied to this Branch Key.
25#[derive(::std::clone::Clone, ::std::fmt::Debug)]
26pub struct CreateKeyFluentBuilder {
27    client: crate::deps::aws_cryptography_keyStore::client::Client,
28    pub(crate) inner: crate::deps::aws_cryptography_keyStore::operation::create_key::builders::CreateKeyInputBuilder,
29}
30impl CreateKeyFluentBuilder {
31    /// Creates a new `CreateKey`.
32    pub(crate) fn new(client: crate::deps::aws_cryptography_keyStore::client::Client) -> Self {
33        Self {
34            client,
35            inner: ::std::default::Default::default(),
36        }
37    }
38    /// Access the CreateKey as a reference.
39    pub fn as_input(&self) -> &crate::deps::aws_cryptography_keyStore::operation::create_key::builders::CreateKeyInputBuilder{
40        &self.inner
41    }
42    /// Sends the request and returns the response.
43    pub async fn send(
44        self,
45    ) -> ::std::result::Result<
46        crate::deps::aws_cryptography_keyStore::operation::create_key::CreateKeyOutput,
47        crate::deps::aws_cryptography_keyStore::types::error::Error,
48    > {
49        let input = self
50            .inner
51            .build()
52            // Using Opaque since we don't have a validation-specific error yet.
53            // Operations' models don't declare their own validation error,
54            // and smithy-rs seems to not generate a ValidationError case unless there is.
55            // Vanilla smithy-rs uses SdkError::construction_failure, but we aren't using SdkError.
56            .map_err(|mut e| {
57                let msg = format!("{:?}", e);
58                crate::deps::aws_cryptography_keyStore::types::error::Error::OpaqueWithText {
59                    obj: ::dafny_runtime::Object::from_ref(&mut e as &mut ::dafny_runtime::DynAny),
60                    objMessage: msg,
61                }
62            })?;
63        crate::deps::aws_cryptography_keyStore::operation::create_key::CreateKey::send(
64            &self.client,
65            input,
66        )
67        .await
68    }
69
70    /// The identifier for the created Branch Key.
71    pub fn branch_key_identifier(
72        mut self,
73        input: impl ::std::convert::Into<::std::string::String>,
74    ) -> Self {
75        self.inner = self.inner.branch_key_identifier(input.into());
76        self
77    }
78    /// The identifier for the created Branch Key.
79    pub fn set_branch_key_identifier(
80        mut self,
81        input: ::std::option::Option<::std::string::String>,
82    ) -> Self {
83        self.inner = self.inner.set_branch_key_identifier(input);
84        self
85    }
86    /// The identifier for the created Branch Key.
87    pub fn get_branch_key_identifier(&self) -> &::std::option::Option<::std::string::String> {
88        self.inner.get_branch_key_identifier()
89    }
90    /// Custom encryption context for the Branch Key. Required if branchKeyIdentifier is set.
91    pub fn encryption_context(
92        mut self,
93        input: impl ::std::convert::Into<
94            ::std::collections::HashMap<::std::string::String, ::std::string::String>,
95        >,
96    ) -> Self {
97        self.inner = self.inner.encryption_context(input.into());
98        self
99    }
100    /// Custom encryption context for the Branch Key. Required if branchKeyIdentifier is set.
101    pub fn set_encryption_context(
102        mut self,
103        input: ::std::option::Option<
104            ::std::collections::HashMap<::std::string::String, ::std::string::String>,
105        >,
106    ) -> Self {
107        self.inner = self.inner.set_encryption_context(input);
108        self
109    }
110    /// Custom encryption context for the Branch Key. Required if branchKeyIdentifier is set.
111    pub fn get_encryption_context(
112        &self,
113    ) -> &::std::option::Option<
114        ::std::collections::HashMap<::std::string::String, ::std::string::String>,
115    > {
116        self.inner.get_encryption_context()
117    }
118}