1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct InvokeFlow;
6impl InvokeFlow {
7 pub fn new() -> Self {
9 Self
10 }
11 pub(crate) async fn orchestrate(
12 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
13 input: crate::operation::invoke_flow::InvokeFlowInput,
14 ) -> ::std::result::Result<
15 crate::operation::invoke_flow::InvokeFlowOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::invoke_flow::InvokeFlowError,
18 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19 >,
20 > {
21 let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
22 ::aws_smithy_runtime_api::client::interceptors::context::Error,
23 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24 >| {
25 err.map_service_error(|err| {
26 err.downcast::<crate::operation::invoke_flow::InvokeFlowError>()
27 .expect("correct error type")
28 })
29 };
30 let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
31 .await
32 .map_err(map_err)?;
33 let output = context.finalize().map_err(map_err)?;
34 ::std::result::Result::Ok(
35 output
36 .downcast::<crate::operation::invoke_flow::InvokeFlowOutput>()
37 .expect("correct output type"),
38 )
39 }
40
41 pub(crate) async fn orchestrate_with_stop_point(
42 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
43 input: crate::operation::invoke_flow::InvokeFlowInput,
44 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
45 ) -> ::std::result::Result<
46 ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
47 ::aws_smithy_runtime_api::client::result::SdkError<
48 ::aws_smithy_runtime_api::client::interceptors::context::Error,
49 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
50 >,
51 > {
52 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
53 use ::tracing::Instrument;
54 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("Bedrock Agent Runtime", "InvokeFlow", input, runtime_plugins, stop_point)
55 .instrument(::tracing::debug_span!(
58 "Bedrock Agent Runtime.InvokeFlow",
59 "rpc.service" = "Bedrock Agent Runtime",
60 "rpc.method" = "InvokeFlow",
61 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
62 "rpc.system" = "aws-api",
63 ))
64 .await
65 }
66
67 pub(crate) fn operation_runtime_plugins(
68 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
69 client_config: &crate::config::Config,
70 config_override: ::std::option::Option<crate::config::Builder>,
71 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
72 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
73 runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
74 ::aws_runtime::auth::sigv4::SCHEME_ID,
75 ]));
76 if let ::std::option::Option::Some(config_override) = config_override {
77 for plugin in config_override.runtime_plugins.iter().cloned() {
78 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
79 }
80 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
81 config_override,
82 client_config.config.clone(),
83 &client_config.runtime_components,
84 ));
85 }
86 runtime_plugins
87 }
88}
89impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for InvokeFlow {
90 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
91 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("InvokeFlow");
92
93 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
94 InvokeFlowRequestSerializer,
95 ));
96 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
97 InvokeFlowResponseDeserializer,
98 ));
99
100 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
101 ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
102 ));
103
104 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
105 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
106 "InvokeFlow",
107 "Bedrock Agent Runtime",
108 ));
109 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
110 signing_options.double_uri_encode = true;
111 signing_options.content_sha256_header = false;
112 signing_options.normalize_uri_path = true;
113 signing_options.payload_override = None;
114
115 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
116 signing_options,
117 ..::std::default::Default::default()
118 });
119
120 ::std::option::Option::Some(cfg.freeze())
121 }
122
123 fn runtime_components(
124 &self,
125 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
126 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
127 #[allow(unused_mut)]
128 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("InvokeFlow")
129 .with_interceptor(InvokeFlowEndpointParamsInterceptor)
130 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
131 crate::operation::invoke_flow::InvokeFlowError,
132 >::new())
133 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
134 crate::operation::invoke_flow::InvokeFlowError,
135 >::new())
136 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
137 crate::operation::invoke_flow::InvokeFlowError,
138 >::new());
139
140 ::std::borrow::Cow::Owned(rcb)
141 }
142}
143
144#[derive(Debug)]
145struct InvokeFlowResponseDeserializer;
146impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for InvokeFlowResponseDeserializer {
147 fn deserialize_streaming(
148 &self,
149 response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
150 ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
151 #[allow(unused_mut)]
152 let mut force_error = false;
153 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
154
155 if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
157 return ::std::option::Option::None;
158 }
159 ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
160 crate::protocol_serde::shape_invoke_flow::de_invoke_flow_http_response(response),
161 ))
162 }
163
164 fn deserialize_nonstreaming(
165 &self,
166 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
167 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
168 let body = response.body().bytes().expect("body loaded");
170 crate::protocol_serde::type_erase_result(crate::protocol_serde::shape_invoke_flow::de_invoke_flow_http_error(
171 response.status().as_u16(),
172 response.headers(),
173 body,
174 ))
175 }
176}
177#[derive(Debug)]
178struct InvokeFlowRequestSerializer;
179impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for InvokeFlowRequestSerializer {
180 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
181 fn serialize_input(
182 &self,
183 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
184 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
185 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
186 let input = input.downcast::<crate::operation::invoke_flow::InvokeFlowInput>().expect("correct type");
187 let _header_serialization_settings = _cfg
188 .load::<crate::serialization_settings::HeaderSerializationSettings>()
189 .cloned()
190 .unwrap_or_default();
191 let mut request_builder = {
192 fn uri_base(
193 _input: &crate::operation::invoke_flow::InvokeFlowInput,
194 output: &mut ::std::string::String,
195 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
196 use ::std::fmt::Write as _;
197 let input_1 = &_input.flow_identifier;
198 let input_1 = input_1
199 .as_ref()
200 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("flow_identifier", "cannot be empty or unset"))?;
201 let flow_identifier = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
202 if flow_identifier.is_empty() {
203 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
204 "flow_identifier",
205 "cannot be empty or unset",
206 ));
207 }
208 let input_2 = &_input.flow_alias_identifier;
209 let input_2 = input_2.as_ref().ok_or_else(|| {
210 ::aws_smithy_types::error::operation::BuildError::missing_field("flow_alias_identifier", "cannot be empty or unset")
211 })?;
212 let flow_alias_identifier = ::aws_smithy_http::label::fmt_string(input_2, ::aws_smithy_http::label::EncodingStrategy::Default);
213 if flow_alias_identifier.is_empty() {
214 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
215 "flow_alias_identifier",
216 "cannot be empty or unset",
217 ));
218 }
219 ::std::write!(
220 output,
221 "/flows/{flowIdentifier}/aliases/{flowAliasIdentifier}",
222 flowIdentifier = flow_identifier,
223 flowAliasIdentifier = flow_alias_identifier
224 )
225 .expect("formatting should succeed");
226 ::std::result::Result::Ok(())
227 }
228 #[allow(clippy::unnecessary_wraps)]
229 fn update_http_builder(
230 input: &crate::operation::invoke_flow::InvokeFlowInput,
231 builder: ::http::request::Builder,
232 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
233 let mut uri = ::std::string::String::new();
234 uri_base(input, &mut uri)?;
235 ::std::result::Result::Ok(builder.method("POST").uri(uri))
236 }
237 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
238 builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/json");
239 builder
240 };
241 let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_invoke_flow::ser_invoke_flow_input(&input)?);
242 if let Some(content_length) = body.content_length() {
243 let content_length = content_length.to_string();
244 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
245 }
246 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
247 }
248}
249#[derive(Debug)]
250struct InvokeFlowEndpointParamsInterceptor;
251
252impl ::aws_smithy_runtime_api::client::interceptors::Intercept for InvokeFlowEndpointParamsInterceptor {
253 fn name(&self) -> &'static str {
254 "InvokeFlowEndpointParamsInterceptor"
255 }
256
257 fn read_before_execution(
258 &self,
259 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
260 '_,
261 ::aws_smithy_runtime_api::client::interceptors::context::Input,
262 ::aws_smithy_runtime_api::client::interceptors::context::Output,
263 ::aws_smithy_runtime_api::client::interceptors::context::Error,
264 >,
265 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
266 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
267 let _input = context
268 .input()
269 .downcast_ref::<InvokeFlowInput>()
270 .ok_or("failed to downcast to InvokeFlowInput")?;
271
272 let params = crate::config::endpoint::Params::builder()
273 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
274 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
275 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
276 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
277 .build()
278 .map_err(|err| {
279 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
280 })?;
281 cfg.interceptor_state()
282 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
283 ::std::result::Result::Ok(())
284 }
285}
286
287#[non_exhaustive]
292#[derive(::std::fmt::Debug)]
293pub enum InvokeFlowError {
294 ValidationException(crate::types::error::ValidationException),
296 InternalServerException(crate::types::error::InternalServerException),
298 AccessDeniedException(crate::types::error::AccessDeniedException),
300 DependencyFailedException(crate::types::error::DependencyFailedException),
302 ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
304 ThrottlingException(crate::types::error::ThrottlingException),
306 BadGatewayException(crate::types::error::BadGatewayException),
308 ConflictException(crate::types::error::ConflictException),
310 ServiceQuotaExceededException(crate::types::error::ServiceQuotaExceededException),
312 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
314 variable wildcard pattern and check `.code()`:
315 \
316 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
317 \
318 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-InvokeFlowError) for what information is available for the error.")]
319 Unhandled(crate::error::sealed_unhandled::Unhandled),
320}
321impl InvokeFlowError {
322 pub fn unhandled(
324 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
325 ) -> Self {
326 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
327 source: err.into(),
328 meta: ::std::default::Default::default(),
329 })
330 }
331
332 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
334 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
335 source: err.clone().into(),
336 meta: err,
337 })
338 }
339 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
344 match self {
345 Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
346 Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
347 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
348 Self::DependencyFailedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
349 Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
350 Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
351 Self::BadGatewayException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
352 Self::ConflictException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
353 Self::ServiceQuotaExceededException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
354 Self::Unhandled(e) => &e.meta,
355 }
356 }
357 pub fn is_validation_exception(&self) -> bool {
359 matches!(self, Self::ValidationException(_))
360 }
361 pub fn is_internal_server_exception(&self) -> bool {
363 matches!(self, Self::InternalServerException(_))
364 }
365 pub fn is_access_denied_exception(&self) -> bool {
367 matches!(self, Self::AccessDeniedException(_))
368 }
369 pub fn is_dependency_failed_exception(&self) -> bool {
371 matches!(self, Self::DependencyFailedException(_))
372 }
373 pub fn is_resource_not_found_exception(&self) -> bool {
375 matches!(self, Self::ResourceNotFoundException(_))
376 }
377 pub fn is_throttling_exception(&self) -> bool {
379 matches!(self, Self::ThrottlingException(_))
380 }
381 pub fn is_bad_gateway_exception(&self) -> bool {
383 matches!(self, Self::BadGatewayException(_))
384 }
385 pub fn is_conflict_exception(&self) -> bool {
387 matches!(self, Self::ConflictException(_))
388 }
389 pub fn is_service_quota_exceeded_exception(&self) -> bool {
391 matches!(self, Self::ServiceQuotaExceededException(_))
392 }
393}
394impl ::std::error::Error for InvokeFlowError {
395 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
396 match self {
397 Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
398 Self::InternalServerException(_inner) => ::std::option::Option::Some(_inner),
399 Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
400 Self::DependencyFailedException(_inner) => ::std::option::Option::Some(_inner),
401 Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
402 Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
403 Self::BadGatewayException(_inner) => ::std::option::Option::Some(_inner),
404 Self::ConflictException(_inner) => ::std::option::Option::Some(_inner),
405 Self::ServiceQuotaExceededException(_inner) => ::std::option::Option::Some(_inner),
406 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
407 }
408 }
409}
410impl ::std::fmt::Display for InvokeFlowError {
411 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
412 match self {
413 Self::ValidationException(_inner) => _inner.fmt(f),
414 Self::InternalServerException(_inner) => _inner.fmt(f),
415 Self::AccessDeniedException(_inner) => _inner.fmt(f),
416 Self::DependencyFailedException(_inner) => _inner.fmt(f),
417 Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
418 Self::ThrottlingException(_inner) => _inner.fmt(f),
419 Self::BadGatewayException(_inner) => _inner.fmt(f),
420 Self::ConflictException(_inner) => _inner.fmt(f),
421 Self::ServiceQuotaExceededException(_inner) => _inner.fmt(f),
422 Self::Unhandled(_inner) => {
423 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
424 write!(f, "unhandled error ({code})")
425 } else {
426 f.write_str("unhandled error")
427 }
428 }
429 }
430 }
431}
432impl ::aws_smithy_types::retry::ProvideErrorKind for InvokeFlowError {
433 fn code(&self) -> ::std::option::Option<&str> {
434 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
435 }
436 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
437 ::std::option::Option::None
438 }
439}
440impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for InvokeFlowError {
441 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
442 match self {
443 Self::ValidationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
444 Self::InternalServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
445 Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
446 Self::DependencyFailedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
447 Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
448 Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
449 Self::BadGatewayException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
450 Self::ConflictException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
451 Self::ServiceQuotaExceededException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
452 Self::Unhandled(_inner) => &_inner.meta,
453 }
454 }
455}
456impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for InvokeFlowError {
457 fn create_unhandled_error(
458 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
459 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
460 ) -> Self {
461 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
462 source,
463 meta: meta.unwrap_or_default(),
464 })
465 }
466}
467impl ::aws_types::request_id::RequestId for crate::operation::invoke_flow::InvokeFlowError {
468 fn request_id(&self) -> Option<&str> {
469 self.meta().request_id()
470 }
471}
472
473pub use crate::operation::invoke_flow::_invoke_flow_output::InvokeFlowOutput;
474
475pub use crate::operation::invoke_flow::_invoke_flow_input::InvokeFlowInput;
476
477mod _invoke_flow_input;
478
479mod _invoke_flow_output;
480
481pub mod builders;