aws_sdk_transcribestreaming/operation/start_medical_scribe_stream/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::start_medical_scribe_stream::_start_medical_scribe_stream_output::StartMedicalScribeStreamOutputBuilder;
3
4pub use crate::operation::start_medical_scribe_stream::_start_medical_scribe_stream_input::StartMedicalScribeStreamInputBuilder;
5
6impl crate::operation::start_medical_scribe_stream::builders::StartMedicalScribeStreamInputBuilder {
7 /// Sends a request with this input using the given client.
8 pub async fn send_with(self, client: &crate::Client) -> ::std::result::Result<
9 crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamOutput,
10 ::aws_smithy_runtime_api::client::result::SdkError<
11 crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamError,
12 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse
13 >
14 > {
15 let mut fluent_builder = client.start_medical_scribe_stream();
16 fluent_builder.inner = self;
17 fluent_builder.send().await
18 }
19 }
20/// Fluent builder constructing a request to `StartMedicalScribeStream`.
21///
22/// <p>Starts a bidirectional HTTP/2 stream, where audio is streamed to Amazon Web Services HealthScribe and the transcription results are streamed to your application.</p>
23/// <p>When you start a stream, you first specify the stream configuration in a <code>MedicalScribeConfigurationEvent</code>. This event includes channel definitions, encryption settings, medical scribe context, and post-stream analytics settings, such as the output configuration for aggregated transcript and clinical note generation. These are additional streaming session configurations beyond those provided in your initial start request headers. Whether you are starting a new session or resuming an existing session, your first event must be a <code>MedicalScribeConfigurationEvent</code>.</p>
24/// <p>After you send a <code>MedicalScribeConfigurationEvent</code>, you start <code>AudioEvents</code> and Amazon Web Services HealthScribe responds with real-time transcription results. When you are finished, to start processing the results with the post-stream analytics, send a <code>MedicalScribeSessionControlEvent</code> with a <code>Type</code> of <code>END_OF_SESSION</code> and Amazon Web Services HealthScribe starts the analytics.</p>
25/// <p>You can pause or resume streaming. To pause streaming, complete the input stream without sending the <code>MedicalScribeSessionControlEvent</code>. To resume streaming, call the <code>StartMedicalScribeStream</code> and specify the same SessionId you used to start the stream.</p>
26/// <p>The following parameters are required:</p>
27/// <ul>
28/// <li>
29/// <p><code>language-code</code></p></li>
30/// <li>
31/// <p><code>media-encoding</code></p></li>
32/// <li>
33/// <p><code>media-sample-rate-hertz</code></p></li>
34/// </ul>
35/// <p></p>
36/// <p>For more information on streaming with Amazon Web Services HealthScribe, see <a href="https://docs.aws.amazon.com/transcribe/latest/dg/health-scribe-streaming.html">Amazon Web Services HealthScribe</a>.</p>
37#[derive(::std::fmt::Debug)]
38pub struct StartMedicalScribeStreamFluentBuilder {
39 handle: ::std::sync::Arc<crate::client::Handle>,
40 inner: crate::operation::start_medical_scribe_stream::builders::StartMedicalScribeStreamInputBuilder,
41config_override: ::std::option::Option<crate::config::Builder>,
42 }
43impl
44 crate::client::customize::internal::CustomizableSend<
45 crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamOutput,
46 crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamError,
47 > for StartMedicalScribeStreamFluentBuilder
48 {
49 fn send(
50 self,
51 config_override: crate::config::Builder,
52 ) -> crate::client::customize::internal::BoxFuture<
53 crate::client::customize::internal::SendResult<
54 crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamOutput,
55 crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamError,
56 >,
57 > {
58 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
59 }
60 }
61impl StartMedicalScribeStreamFluentBuilder {
62 /// Creates a new `StartMedicalScribeStreamFluentBuilder`.
63 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
64 Self {
65 handle,
66 inner: ::std::default::Default::default(),
67 config_override: ::std::option::Option::None,
68 }
69 }
70 /// Access the StartMedicalScribeStream as a reference.
71 pub fn as_input(&self) -> &crate::operation::start_medical_scribe_stream::builders::StartMedicalScribeStreamInputBuilder {
72 &self.inner
73 }
74 /// Sends the request and returns the response.
75 ///
76 /// If an error occurs, an `SdkError` will be returned with additional details that
77 /// can be matched against.
78 ///
79 /// By default, any retryable failures will be retried twice. Retry behavior
80 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
81 /// set when configuring the client. Note: retries are enabled by default when using
82 /// `aws_config::load_from_env()` or when using `BehaviorVersion::v2025_01_17()` or later.
83 pub async fn send(self) -> ::std::result::Result<crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamOutput, ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamError, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse>> {
84 let input = self.inner.build().map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
85 let runtime_plugins = crate::operation::start_medical_scribe_stream::StartMedicalScribeStream::operation_runtime_plugins(
86 self.handle.runtime_plugins.clone(),
87 &self.handle.conf,
88 self.config_override,
89 );
90 let mut output =
91 crate::operation::start_medical_scribe_stream::StartMedicalScribeStream::orchestrate(
92 &runtime_plugins,
93 input,
94 )
95 .await?;
96
97 // Converts any error encountered beyond this point into an `SdkError` response error
98 // with an `HttpResponse`. However, since we have already exited the `orchestrate`
99 // function, the original `HttpResponse` is no longer available and cannot be restored.
100 // This means that header information from the original response has been lost.
101 //
102 // Note that the response body would have been consumed by the deserializer
103 // regardless, even if the initial message was hypothetically processed during
104 // the orchestrator's deserialization phase but later resulted in an error.
105 fn response_error(
106 err: impl ::std::convert::Into<::aws_smithy_runtime_api::box_error::BoxError>
107 ) -> ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamError, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse> {
108 ::aws_smithy_runtime_api::client::result::SdkError::response_error(err, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse::new(
109 ::aws_smithy_runtime_api::http::StatusCode::try_from(200).expect("valid successful code"),
110 ::aws_smithy_types::body::SdkBody::empty()))
111 }
112
113 let message = output.result_stream.try_recv_initial_response().await.map_err(response_error)?;
114
115 match message {
116 ::std::option::Option::Some(_message) => {
117
118 ::std::result::Result::Ok(output)
119 }
120 ::std::option::Option::None => ::std::result::Result::Ok(output),
121 }
122 }
123
124 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
125 pub fn customize(
126 self,
127 ) -> crate::client::customize::CustomizableOperation<crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamOutput, crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamError, Self> {
128 crate::client::customize::CustomizableOperation::new(self)
129 }
130 pub(crate) fn config_override(
131 mut self,
132 config_override: impl ::std::convert::Into<crate::config::Builder>,
133 ) -> Self {
134 self.set_config_override(::std::option::Option::Some(config_override.into()));
135 self
136 }
137
138 pub(crate) fn set_config_override(
139 &mut self,
140 config_override: ::std::option::Option<crate::config::Builder>,
141 ) -> &mut Self {
142 self.config_override = config_override;
143 self
144 }
145 /// <p>Specify an identifier for your streaming session (in UUID format). If you don't include a SessionId in your request, Amazon Web Services HealthScribe generates an ID and returns it in the response.</p>
146 pub fn session_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
147 self.inner = self.inner.session_id(input.into());
148 self
149 }
150 /// <p>Specify an identifier for your streaming session (in UUID format). If you don't include a SessionId in your request, Amazon Web Services HealthScribe generates an ID and returns it in the response.</p>
151 pub fn set_session_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
152 self.inner = self.inner.set_session_id(input);
153 self
154 }
155 /// <p>Specify an identifier for your streaming session (in UUID format). If you don't include a SessionId in your request, Amazon Web Services HealthScribe generates an ID and returns it in the response.</p>
156 pub fn get_session_id(&self) -> &::std::option::Option<::std::string::String> {
157 self.inner.get_session_id()
158 }
159 /// <p>Specify the language code for your HealthScribe streaming session.</p>
160 pub fn language_code(mut self, input: crate::types::MedicalScribeLanguageCode) -> Self {
161 self.inner = self.inner.language_code(input);
162 self
163 }
164 /// <p>Specify the language code for your HealthScribe streaming session.</p>
165 pub fn set_language_code(mut self, input: ::std::option::Option<crate::types::MedicalScribeLanguageCode>) -> Self {
166 self.inner = self.inner.set_language_code(input);
167 self
168 }
169 /// <p>Specify the language code for your HealthScribe streaming session.</p>
170 pub fn get_language_code(&self) -> &::std::option::Option<crate::types::MedicalScribeLanguageCode> {
171 self.inner.get_language_code()
172 }
173 /// <p>Specify the sample rate of the input audio (in hertz). Amazon Web Services HealthScribe supports a range from 16,000 Hz to 48,000 Hz. The sample rate you specify must match that of your audio.</p>
174 pub fn media_sample_rate_hertz(mut self, input: i32) -> Self {
175 self.inner = self.inner.media_sample_rate_hertz(input);
176 self
177 }
178 /// <p>Specify the sample rate of the input audio (in hertz). Amazon Web Services HealthScribe supports a range from 16,000 Hz to 48,000 Hz. The sample rate you specify must match that of your audio.</p>
179 pub fn set_media_sample_rate_hertz(mut self, input: ::std::option::Option<i32>) -> Self {
180 self.inner = self.inner.set_media_sample_rate_hertz(input);
181 self
182 }
183 /// <p>Specify the sample rate of the input audio (in hertz). Amazon Web Services HealthScribe supports a range from 16,000 Hz to 48,000 Hz. The sample rate you specify must match that of your audio.</p>
184 pub fn get_media_sample_rate_hertz(&self) -> &::std::option::Option<i32> {
185 self.inner.get_media_sample_rate_hertz()
186 }
187 /// <p>Specify the encoding used for the input audio.</p>
188 /// <p>Supported formats are:</p>
189 /// <ul>
190 /// <li>
191 /// <p>FLAC</p></li>
192 /// <li>
193 /// <p>OPUS-encoded audio in an Ogg container</p></li>
194 /// <li>
195 /// <p>PCM (only signed 16-bit little-endian audio formats, which does not include WAV)</p></li>
196 /// </ul>
197 /// <p>For more information, see <a href="https://docs.aws.amazon.com/transcribe/latest/dg/how-input.html#how-input-audio">Media formats</a>.</p>
198 pub fn media_encoding(mut self, input: crate::types::MedicalScribeMediaEncoding) -> Self {
199 self.inner = self.inner.media_encoding(input);
200 self
201 }
202 /// <p>Specify the encoding used for the input audio.</p>
203 /// <p>Supported formats are:</p>
204 /// <ul>
205 /// <li>
206 /// <p>FLAC</p></li>
207 /// <li>
208 /// <p>OPUS-encoded audio in an Ogg container</p></li>
209 /// <li>
210 /// <p>PCM (only signed 16-bit little-endian audio formats, which does not include WAV)</p></li>
211 /// </ul>
212 /// <p>For more information, see <a href="https://docs.aws.amazon.com/transcribe/latest/dg/how-input.html#how-input-audio">Media formats</a>.</p>
213 pub fn set_media_encoding(mut self, input: ::std::option::Option<crate::types::MedicalScribeMediaEncoding>) -> Self {
214 self.inner = self.inner.set_media_encoding(input);
215 self
216 }
217 /// <p>Specify the encoding used for the input audio.</p>
218 /// <p>Supported formats are:</p>
219 /// <ul>
220 /// <li>
221 /// <p>FLAC</p></li>
222 /// <li>
223 /// <p>OPUS-encoded audio in an Ogg container</p></li>
224 /// <li>
225 /// <p>PCM (only signed 16-bit little-endian audio formats, which does not include WAV)</p></li>
226 /// </ul>
227 /// <p>For more information, see <a href="https://docs.aws.amazon.com/transcribe/latest/dg/how-input.html#how-input-audio">Media formats</a>.</p>
228 pub fn get_media_encoding(&self) -> &::std::option::Option<crate::types::MedicalScribeMediaEncoding> {
229 self.inner.get_media_encoding()
230 }
231 /// <p>Specify the input stream where you will send events in real time.</p>
232 /// <p>The first element of the input stream must be a <code>MedicalScribeConfigurationEvent</code>.</p>
233 pub fn input_stream(mut self, input: ::aws_smithy_http::event_stream::EventStreamSender<crate::types::MedicalScribeInputStream, crate::types::error::MedicalScribeInputStreamError>) -> Self {
234 self.inner = self.inner.input_stream(input);
235 self
236 }
237 /// <p>Specify the input stream where you will send events in real time.</p>
238 /// <p>The first element of the input stream must be a <code>MedicalScribeConfigurationEvent</code>.</p>
239 pub fn set_input_stream(mut self, input: ::std::option::Option<::aws_smithy_http::event_stream::EventStreamSender<crate::types::MedicalScribeInputStream, crate::types::error::MedicalScribeInputStreamError>>) -> Self {
240 self.inner = self.inner.set_input_stream(input);
241 self
242 }
243 /// <p>Specify the input stream where you will send events in real time.</p>
244 /// <p>The first element of the input stream must be a <code>MedicalScribeConfigurationEvent</code>.</p>
245 pub fn get_input_stream(&self) -> &::std::option::Option<::aws_smithy_http::event_stream::EventStreamSender<crate::types::MedicalScribeInputStream, crate::types::error::MedicalScribeInputStreamError>> {
246 self.inner.get_input_stream()
247 }
248}
249