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.
82 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>> {
83 let input = self.inner.build().map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
84 let runtime_plugins = crate::operation::start_medical_scribe_stream::StartMedicalScribeStream::operation_runtime_plugins(
85 self.handle.runtime_plugins.clone(),
86 &self.handle.conf,
87 self.config_override,
88 );
89 let mut output =
90 crate::operation::start_medical_scribe_stream::StartMedicalScribeStream::orchestrate(
91 &runtime_plugins,
92 input,
93 )
94 .await?;
95
96 // Converts any error encountered beyond this point into an `SdkError` response error
97 // with an `HttpResponse`. However, since we have already exited the `orchestrate`
98 // function, the original `HttpResponse` is no longer available and cannot be restored.
99 // This means that header information from the original response has been lost.
100 //
101 // Note that the response body would have been consumed by the deserializer
102 // regardless, even if the initial message was hypothetically processed during
103 // the orchestrator's deserialization phase but later resulted in an error.
104 fn response_error(
105 err: impl ::std::convert::Into<::aws_smithy_runtime_api::box_error::BoxError>
106 ) -> ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamError, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse> {
107 ::aws_smithy_runtime_api::client::result::SdkError::response_error(err, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse::new(
108 ::aws_smithy_runtime_api::http::StatusCode::try_from(200).expect("valid successful code"),
109 ::aws_smithy_types::body::SdkBody::empty()))
110 }
111
112 let message = output.result_stream.try_recv_initial_response().await.map_err(response_error)?;
113
114 match message {
115 ::std::option::Option::Some(_message) => {
116
117 ::std::result::Result::Ok(output)
118 }
119 ::std::option::Option::None => ::std::result::Result::Ok(output),
120 }
121 }
122
123 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
124 pub fn customize(
125 self,
126 ) -> crate::client::customize::CustomizableOperation<crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamOutput, crate::operation::start_medical_scribe_stream::StartMedicalScribeStreamError, Self> {
127 crate::client::customize::CustomizableOperation::new(self)
128 }
129 pub(crate) fn config_override(
130 mut self,
131 config_override: impl ::std::convert::Into<crate::config::Builder>,
132 ) -> Self {
133 self.set_config_override(::std::option::Option::Some(config_override.into()));
134 self
135 }
136
137 pub(crate) fn set_config_override(
138 &mut self,
139 config_override: ::std::option::Option<crate::config::Builder>,
140 ) -> &mut Self {
141 self.config_override = config_override;
142 self
143 }
144 /// <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>
145 pub fn session_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
146 self.inner = self.inner.session_id(input.into());
147 self
148 }
149 /// <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>
150 pub fn set_session_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
151 self.inner = self.inner.set_session_id(input);
152 self
153 }
154 /// <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>
155 pub fn get_session_id(&self) -> &::std::option::Option<::std::string::String> {
156 self.inner.get_session_id()
157 }
158 /// <p>Specify the language code for your HealthScribe streaming session.</p>
159 pub fn language_code(mut self, input: crate::types::MedicalScribeLanguageCode) -> Self {
160 self.inner = self.inner.language_code(input);
161 self
162 }
163 /// <p>Specify the language code for your HealthScribe streaming session.</p>
164 pub fn set_language_code(mut self, input: ::std::option::Option<crate::types::MedicalScribeLanguageCode>) -> Self {
165 self.inner = self.inner.set_language_code(input);
166 self
167 }
168 /// <p>Specify the language code for your HealthScribe streaming session.</p>
169 pub fn get_language_code(&self) -> &::std::option::Option<crate::types::MedicalScribeLanguageCode> {
170 self.inner.get_language_code()
171 }
172 /// <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>
173 pub fn media_sample_rate_hertz(mut self, input: i32) -> Self {
174 self.inner = self.inner.media_sample_rate_hertz(input);
175 self
176 }
177 /// <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>
178 pub fn set_media_sample_rate_hertz(mut self, input: ::std::option::Option<i32>) -> Self {
179 self.inner = self.inner.set_media_sample_rate_hertz(input);
180 self
181 }
182 /// <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>
183 pub fn get_media_sample_rate_hertz(&self) -> &::std::option::Option<i32> {
184 self.inner.get_media_sample_rate_hertz()
185 }
186 /// <p>Specify the encoding used for the input audio.</p>
187 /// <p>Supported formats are:</p>
188 /// <ul>
189 /// <li>
190 /// <p>FLAC</p></li>
191 /// <li>
192 /// <p>OPUS-encoded audio in an Ogg container</p></li>
193 /// <li>
194 /// <p>PCM (only signed 16-bit little-endian audio formats, which does not include WAV)</p></li>
195 /// </ul>
196 /// <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>
197 pub fn media_encoding(mut self, input: crate::types::MedicalScribeMediaEncoding) -> Self {
198 self.inner = self.inner.media_encoding(input);
199 self
200 }
201 /// <p>Specify the encoding used for the input audio.</p>
202 /// <p>Supported formats are:</p>
203 /// <ul>
204 /// <li>
205 /// <p>FLAC</p></li>
206 /// <li>
207 /// <p>OPUS-encoded audio in an Ogg container</p></li>
208 /// <li>
209 /// <p>PCM (only signed 16-bit little-endian audio formats, which does not include WAV)</p></li>
210 /// </ul>
211 /// <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>
212 pub fn set_media_encoding(mut self, input: ::std::option::Option<crate::types::MedicalScribeMediaEncoding>) -> Self {
213 self.inner = self.inner.set_media_encoding(input);
214 self
215 }
216 /// <p>Specify the encoding used for the input audio.</p>
217 /// <p>Supported formats are:</p>
218 /// <ul>
219 /// <li>
220 /// <p>FLAC</p></li>
221 /// <li>
222 /// <p>OPUS-encoded audio in an Ogg container</p></li>
223 /// <li>
224 /// <p>PCM (only signed 16-bit little-endian audio formats, which does not include WAV)</p></li>
225 /// </ul>
226 /// <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>
227 pub fn get_media_encoding(&self) -> &::std::option::Option<crate::types::MedicalScribeMediaEncoding> {
228 self.inner.get_media_encoding()
229 }
230 /// <p>Specify the input stream where you will send events in real time.</p>
231 /// <p>The first element of the input stream must be a <code>MedicalScribeConfigurationEvent</code>.</p>
232 pub fn input_stream(mut self, input: ::aws_smithy_http::event_stream::EventStreamSender<crate::types::MedicalScribeInputStream, crate::types::error::MedicalScribeInputStreamError>) -> Self {
233 self.inner = self.inner.input_stream(input);
234 self
235 }
236 /// <p>Specify the input stream where you will send events in real time.</p>
237 /// <p>The first element of the input stream must be a <code>MedicalScribeConfigurationEvent</code>.</p>
238 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 {
239 self.inner = self.inner.set_input_stream(input);
240 self
241 }
242 /// <p>Specify the input stream where you will send events in real time.</p>
243 /// <p>The first element of the input stream must be a <code>MedicalScribeConfigurationEvent</code>.</p>
244 pub fn get_input_stream(&self) -> &::std::option::Option<::aws_smithy_http::event_stream::EventStreamSender<crate::types::MedicalScribeInputStream, crate::types::error::MedicalScribeInputStreamError>> {
245 self.inner.get_input_stream()
246 }
247}
248