Skip to main content

aws_sdk_sagemaker/operation/create_notebook_instance_lifecycle_config/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_notebook_instance_lifecycle_config::_create_notebook_instance_lifecycle_config_input::CreateNotebookInstanceLifecycleConfigInputBuilder;
3
4pub use crate::operation::create_notebook_instance_lifecycle_config::_create_notebook_instance_lifecycle_config_output::CreateNotebookInstanceLifecycleConfigOutputBuilder;
5
6impl crate::operation::create_notebook_instance_lifecycle_config::builders::CreateNotebookInstanceLifecycleConfigInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.create_notebook_instance_lifecycle_config();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `CreateNotebookInstanceLifecycleConfig`.
24///
25/// <p>Creates a lifecycle configuration that you can associate with a notebook instance. A <i>lifecycle configuration</i> is a collection of shell scripts that run when you create or start a notebook instance.</p>
26/// <p>Each lifecycle configuration script has a limit of 16384 characters.</p>
27/// <p>The value of the <code>$PATH</code> environment variable that is available to both scripts is <code>/sbin:bin:/usr/sbin:/usr/bin</code>.</p>
28/// <p>View Amazon CloudWatch Logs for notebook instance lifecycle configurations in log group <code>/aws/sagemaker/NotebookInstances</code> in log stream <code>\[notebook-instance-name\]/\[LifecycleConfigHook\]</code>.</p>
29/// <p>Lifecycle configuration scripts cannot run for longer than 5 minutes. If a script runs for longer than 5 minutes, it fails and the notebook instance is not created or started.</p>
30/// <p>For information about notebook instance lifestyle configurations, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/notebook-lifecycle-config.html">Step 2.1: (Optional) Customize a Notebook Instance</a>.</p><note>
31/// <p>Lifecycle configuration scripts execute with root access and the notebook instance's IAM execution role privileges. Grant this permission only to trusted principals. See <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/notebook-lifecycle-config.html">Customize a Notebook Instance Using a Lifecycle Configuration Script</a> for security best practices.</p>
32/// </note>
33#[derive(::std::clone::Clone, ::std::fmt::Debug)]
34pub struct CreateNotebookInstanceLifecycleConfigFluentBuilder {
35    handle: ::std::sync::Arc<crate::client::Handle>,
36    inner: crate::operation::create_notebook_instance_lifecycle_config::builders::CreateNotebookInstanceLifecycleConfigInputBuilder,
37    config_override: ::std::option::Option<crate::config::Builder>,
38}
39impl
40    crate::client::customize::internal::CustomizableSend<
41        crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigOutput,
42        crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError,
43    > for CreateNotebookInstanceLifecycleConfigFluentBuilder
44{
45    fn send(
46        self,
47        config_override: crate::config::Builder,
48    ) -> crate::client::customize::internal::BoxFuture<
49        crate::client::customize::internal::SendResult<
50            crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigOutput,
51            crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError,
52        >,
53    > {
54        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
55    }
56}
57impl CreateNotebookInstanceLifecycleConfigFluentBuilder {
58    /// Creates a new `CreateNotebookInstanceLifecycleConfigFluentBuilder`.
59    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
60        Self {
61            handle,
62            inner: ::std::default::Default::default(),
63            config_override: ::std::option::Option::None,
64        }
65    }
66    /// Access the CreateNotebookInstanceLifecycleConfig as a reference.
67    pub fn as_input(
68        &self,
69    ) -> &crate::operation::create_notebook_instance_lifecycle_config::builders::CreateNotebookInstanceLifecycleConfigInputBuilder {
70        &self.inner
71    }
72    /// Sends the request and returns the response.
73    ///
74    /// If an error occurs, an `SdkError` will be returned with additional details that
75    /// can be matched against.
76    ///
77    /// By default, any retryable failures will be retried twice. Retry behavior
78    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
79    /// set when configuring the client.
80    pub async fn send(
81        self,
82    ) -> ::std::result::Result<
83        crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigOutput,
84        ::aws_smithy_runtime_api::client::result::SdkError<
85            crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError,
86            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
87        >,
88    > {
89        let input = self
90            .inner
91            .build()
92            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
93        let runtime_plugins =
94            crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfig::operation_runtime_plugins(
95                self.handle.runtime_plugins.clone(),
96                &self.handle.conf,
97                self.config_override,
98            );
99        crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfig::orchestrate(&runtime_plugins, input).await
100    }
101
102    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
103    pub fn customize(
104        self,
105    ) -> crate::client::customize::CustomizableOperation<
106        crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigOutput,
107        crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError,
108        Self,
109    > {
110        crate::client::customize::CustomizableOperation::new(self)
111    }
112    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
113        self.set_config_override(::std::option::Option::Some(config_override.into()));
114        self
115    }
116
117    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
118        self.config_override = config_override;
119        self
120    }
121    /// <p>The name of the lifecycle configuration.</p>
122    pub fn notebook_instance_lifecycle_config_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
123        self.inner = self.inner.notebook_instance_lifecycle_config_name(input.into());
124        self
125    }
126    /// <p>The name of the lifecycle configuration.</p>
127    pub fn set_notebook_instance_lifecycle_config_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
128        self.inner = self.inner.set_notebook_instance_lifecycle_config_name(input);
129        self
130    }
131    /// <p>The name of the lifecycle configuration.</p>
132    pub fn get_notebook_instance_lifecycle_config_name(&self) -> &::std::option::Option<::std::string::String> {
133        self.inner.get_notebook_instance_lifecycle_config_name()
134    }
135    ///
136    /// Appends an item to `OnCreate`.
137    ///
138    /// To override the contents of this collection use [`set_on_create`](Self::set_on_create).
139    ///
140    /// <p>A shell script that runs only once, when you create a notebook instance. The shell script must be a base64-encoded string.</p>
141    pub fn on_create(mut self, input: crate::types::NotebookInstanceLifecycleHook) -> Self {
142        self.inner = self.inner.on_create(input);
143        self
144    }
145    /// <p>A shell script that runs only once, when you create a notebook instance. The shell script must be a base64-encoded string.</p>
146    pub fn set_on_create(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::NotebookInstanceLifecycleHook>>) -> Self {
147        self.inner = self.inner.set_on_create(input);
148        self
149    }
150    /// <p>A shell script that runs only once, when you create a notebook instance. The shell script must be a base64-encoded string.</p>
151    pub fn get_on_create(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::NotebookInstanceLifecycleHook>> {
152        self.inner.get_on_create()
153    }
154    ///
155    /// Appends an item to `OnStart`.
156    ///
157    /// To override the contents of this collection use [`set_on_start`](Self::set_on_start).
158    ///
159    /// <p>A shell script that runs every time you start a notebook instance, including when you create the notebook instance. The shell script must be a base64-encoded string.</p>
160    pub fn on_start(mut self, input: crate::types::NotebookInstanceLifecycleHook) -> Self {
161        self.inner = self.inner.on_start(input);
162        self
163    }
164    /// <p>A shell script that runs every time you start a notebook instance, including when you create the notebook instance. The shell script must be a base64-encoded string.</p>
165    pub fn set_on_start(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::NotebookInstanceLifecycleHook>>) -> Self {
166        self.inner = self.inner.set_on_start(input);
167        self
168    }
169    /// <p>A shell script that runs every time you start a notebook instance, including when you create the notebook instance. The shell script must be a base64-encoded string.</p>
170    pub fn get_on_start(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::NotebookInstanceLifecycleHook>> {
171        self.inner.get_on_start()
172    }
173    ///
174    /// Appends an item to `Tags`.
175    ///
176    /// To override the contents of this collection use [`set_tags`](Self::set_tags).
177    ///
178    /// <p>An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different ways, for example, by purpose, owner, or environment. For more information, see <a href="https://docs.aws.amazon.com/tag-editor/latest/userguide/tagging.html">Tagging Amazon Web Services Resources</a>.</p>
179    pub fn tags(mut self, input: crate::types::Tag) -> Self {
180        self.inner = self.inner.tags(input);
181        self
182    }
183    /// <p>An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different ways, for example, by purpose, owner, or environment. For more information, see <a href="https://docs.aws.amazon.com/tag-editor/latest/userguide/tagging.html">Tagging Amazon Web Services Resources</a>.</p>
184    pub fn set_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>) -> Self {
185        self.inner = self.inner.set_tags(input);
186        self
187    }
188    /// <p>An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different ways, for example, by purpose, owner, or environment. For more information, see <a href="https://docs.aws.amazon.com/tag-editor/latest/userguide/tagging.html">Tagging Amazon Web Services Resources</a>.</p>
189    pub fn get_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Tag>> {
190        self.inner.get_tags()
191    }
192}