1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct RunTask;
6impl RunTask {
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::run_task::RunTaskInput,
14 ) -> ::std::result::Result<
15 crate::operation::run_task::RunTaskOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::run_task::RunTaskError,
18 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19 >,
20 > {
21 let map_err =
22 |err: ::aws_smithy_runtime_api::client::result::SdkError<
23 ::aws_smithy_runtime_api::client::interceptors::context::Error,
24 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
25 >| { err.map_service_error(|err| err.downcast::<crate::operation::run_task::RunTaskError>().expect("correct error type")) };
26 let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
27 .await
28 .map_err(map_err)?;
29 let output = context.finalize().map_err(map_err)?;
30 ::std::result::Result::Ok(
31 output
32 .downcast::<crate::operation::run_task::RunTaskOutput>()
33 .expect("correct output type"),
34 )
35 }
36
37 pub(crate) async fn orchestrate_with_stop_point(
38 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
39 input: crate::operation::run_task::RunTaskInput,
40 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
41 ) -> ::std::result::Result<
42 ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
43 ::aws_smithy_runtime_api::client::result::SdkError<
44 ::aws_smithy_runtime_api::client::interceptors::context::Error,
45 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
46 >,
47 > {
48 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
49 use ::tracing::Instrument;
50 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("ECS", "RunTask", input, runtime_plugins, stop_point)
51 .instrument(::tracing::debug_span!(
54 "ECS.RunTask",
55 "rpc.service" = "ECS",
56 "rpc.method" = "RunTask",
57 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
58 "rpc.system" = "aws-api",
59 ))
60 .await
61 }
62
63 pub(crate) fn operation_runtime_plugins(
64 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
65 client_config: &crate::config::Config,
66 config_override: ::std::option::Option<crate::config::Builder>,
67 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
68 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
69 runtime_plugins = runtime_plugins.with_operation_plugin(crate::client_idempotency_token::IdempotencyTokenRuntimePlugin::new(
70 |token_provider, input| {
71 let input: &mut crate::operation::run_task::RunTaskInput = input.downcast_mut().expect("correct type");
72 if input.client_token.is_none() {
73 input.client_token = ::std::option::Option::Some(token_provider.make_idempotency_token());
74 }
75 },
76 ));
77 if let ::std::option::Option::Some(config_override) = config_override {
78 for plugin in config_override.runtime_plugins.iter().cloned() {
79 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
80 }
81 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
82 config_override,
83 client_config.config.clone(),
84 &client_config.runtime_components,
85 ));
86 }
87 runtime_plugins
88 }
89}
90impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for RunTask {
91 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
92 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("RunTask");
93
94 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
95 RunTaskRequestSerializer,
96 ));
97 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
98 RunTaskResponseDeserializer,
99 ));
100
101 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
102 crate::config::auth::Params::builder()
103 .operation_name("RunTask")
104 .build()
105 .expect("required fields set"),
106 ));
107
108 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
109 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("RunTask", "ECS"));
110 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
111 signing_options.double_uri_encode = true;
112 signing_options.content_sha256_header = false;
113 signing_options.normalize_uri_path = true;
114 signing_options.payload_override = None;
115
116 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
117 signing_options,
118 ..::std::default::Default::default()
119 });
120
121 ::std::option::Option::Some(cfg.freeze())
122 }
123
124 fn runtime_components(
125 &self,
126 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
127 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
128 #[allow(unused_mut)]
129 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("RunTask")
130 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
131 ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
132 ))
133 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
134 RunTaskEndpointParamsInterceptor,
135 ))
136 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
137 crate::operation::run_task::RunTaskError,
138 >::new())
139 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
140 crate::operation::run_task::RunTaskError,
141 >::new())
142 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
143 crate::operation::run_task::RunTaskError,
144 >::new());
145
146 ::std::borrow::Cow::Owned(rcb)
147 }
148}
149
150#[derive(Debug)]
151struct RunTaskResponseDeserializer;
152impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for RunTaskResponseDeserializer {
153 fn deserialize_nonstreaming_with_config(
154 &self,
155 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
156 _cfg: &::aws_smithy_types::config_bag::ConfigBag,
157 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
158 let (success, status) = (response.status().is_success(), response.status().as_u16());
159 let headers = response.headers();
160 let body = response.body().bytes().expect("body loaded");
161 #[allow(unused_mut)]
162 let mut force_error = false;
163 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
164 let parse_result = if !success && status != 200 || force_error {
165 crate::protocol_serde::shape_run_task::de_run_task_http_error(status, headers, body)
166 } else {
167 crate::protocol_serde::shape_run_task::de_run_task_http_response(status, headers, body)
168 };
169 crate::protocol_serde::type_erase_result(parse_result)
170 }
171}
172#[derive(Debug)]
173struct RunTaskRequestSerializer;
174impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for RunTaskRequestSerializer {
175 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
176 fn serialize_input(
177 &self,
178 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
179 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
180 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
181 let input = input.downcast::<crate::operation::run_task::RunTaskInput>().expect("correct type");
182 let _header_serialization_settings = _cfg
183 .load::<crate::serialization_settings::HeaderSerializationSettings>()
184 .cloned()
185 .unwrap_or_default();
186 let mut request_builder = {
187 #[allow(clippy::uninlined_format_args)]
188 fn uri_base(
189 _input: &crate::operation::run_task::RunTaskInput,
190 output: &mut ::std::string::String,
191 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
192 use ::std::fmt::Write as _;
193 ::std::write!(output, "/").expect("formatting should succeed");
194 ::std::result::Result::Ok(())
195 }
196 #[allow(clippy::unnecessary_wraps)]
197 fn update_http_builder(
198 input: &crate::operation::run_task::RunTaskInput,
199 builder: ::http_1x::request::Builder,
200 ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
201 let mut uri = ::std::string::String::new();
202 uri_base(input, &mut uri)?;
203 ::std::result::Result::Ok(builder.method("POST").uri(uri))
204 }
205 let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
206 builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-amz-json-1.1");
207 builder = _header_serialization_settings.set_default_header(
208 builder,
209 ::http_1x::header::HeaderName::from_static("x-amz-target"),
210 "AmazonEC2ContainerServiceV20141113.RunTask",
211 );
212 builder
213 };
214 let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_run_task::ser_run_task_input(&input)?);
215 if let Some(content_length) = body.content_length() {
216 let content_length = content_length.to_string();
217 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
218 }
219 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
220 }
221}
222#[derive(Debug)]
223struct RunTaskEndpointParamsInterceptor;
224
225#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
226impl ::aws_smithy_runtime_api::client::interceptors::Intercept for RunTaskEndpointParamsInterceptor {
227 fn name(&self) -> &'static str {
228 "RunTaskEndpointParamsInterceptor"
229 }
230
231 fn read_before_execution(
232 &self,
233 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
234 '_,
235 ::aws_smithy_runtime_api::client::interceptors::context::Input,
236 ::aws_smithy_runtime_api::client::interceptors::context::Output,
237 ::aws_smithy_runtime_api::client::interceptors::context::Error,
238 >,
239 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
240 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
241 let _input = context
242 .input()
243 .downcast_ref::<RunTaskInput>()
244 .ok_or("failed to downcast to RunTaskInput")?;
245
246 let params = crate::config::endpoint::Params::builder()
247 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
248 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
249 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
250 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
251 .build()
252 .map_err(|err| {
253 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
254 })?;
255 cfg.interceptor_state()
256 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
257 ::std::result::Result::Ok(())
258 }
259}
260
261#[non_exhaustive]
266#[derive(::std::fmt::Debug)]
267pub enum RunTaskError {
268 AccessDeniedException(crate::types::error::AccessDeniedException),
270 BlockedException(crate::types::error::BlockedException),
272 ClientException(crate::types::error::ClientException),
274 ClusterNotFoundException(crate::types::error::ClusterNotFoundException),
276 ConflictException(crate::types::error::ConflictException),
278 InvalidParameterException(crate::types::error::InvalidParameterException),
281 PlatformTaskDefinitionIncompatibilityException(crate::types::error::PlatformTaskDefinitionIncompatibilityException),
283 PlatformUnknownException(crate::types::error::PlatformUnknownException),
285 ServerException(crate::types::error::ServerException),
287 UnsupportedFeatureException(crate::types::error::UnsupportedFeatureException),
289 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
291 variable wildcard pattern and check `.code()`:
292 \
293 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
294 \
295 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-RunTaskError) for what information is available for the error.")]
296 Unhandled(crate::error::sealed_unhandled::Unhandled),
297}
298impl RunTaskError {
299 pub fn unhandled(
301 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
302 ) -> Self {
303 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
304 source: err.into(),
305 meta: ::std::default::Default::default(),
306 })
307 }
308
309 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
311 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
312 source: err.clone().into(),
313 meta: err,
314 })
315 }
316 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
321 match self {
322 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
323 Self::BlockedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
324 Self::ClientException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
325 Self::ClusterNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
326 Self::ConflictException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
327 Self::InvalidParameterException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
328 Self::PlatformTaskDefinitionIncompatibilityException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
329 Self::PlatformUnknownException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
330 Self::ServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
331 Self::UnsupportedFeatureException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
332 Self::Unhandled(e) => &e.meta,
333 }
334 }
335 pub fn is_access_denied_exception(&self) -> bool {
337 matches!(self, Self::AccessDeniedException(_))
338 }
339 pub fn is_blocked_exception(&self) -> bool {
341 matches!(self, Self::BlockedException(_))
342 }
343 pub fn is_client_exception(&self) -> bool {
345 matches!(self, Self::ClientException(_))
346 }
347 pub fn is_cluster_not_found_exception(&self) -> bool {
349 matches!(self, Self::ClusterNotFoundException(_))
350 }
351 pub fn is_conflict_exception(&self) -> bool {
353 matches!(self, Self::ConflictException(_))
354 }
355 pub fn is_invalid_parameter_exception(&self) -> bool {
357 matches!(self, Self::InvalidParameterException(_))
358 }
359 pub fn is_platform_task_definition_incompatibility_exception(&self) -> bool {
361 matches!(self, Self::PlatformTaskDefinitionIncompatibilityException(_))
362 }
363 pub fn is_platform_unknown_exception(&self) -> bool {
365 matches!(self, Self::PlatformUnknownException(_))
366 }
367 pub fn is_server_exception(&self) -> bool {
369 matches!(self, Self::ServerException(_))
370 }
371 pub fn is_unsupported_feature_exception(&self) -> bool {
373 matches!(self, Self::UnsupportedFeatureException(_))
374 }
375}
376impl ::std::error::Error for RunTaskError {
377 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
378 match self {
379 Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
380 Self::BlockedException(_inner) => ::std::option::Option::Some(_inner),
381 Self::ClientException(_inner) => ::std::option::Option::Some(_inner),
382 Self::ClusterNotFoundException(_inner) => ::std::option::Option::Some(_inner),
383 Self::ConflictException(_inner) => ::std::option::Option::Some(_inner),
384 Self::InvalidParameterException(_inner) => ::std::option::Option::Some(_inner),
385 Self::PlatformTaskDefinitionIncompatibilityException(_inner) => ::std::option::Option::Some(_inner),
386 Self::PlatformUnknownException(_inner) => ::std::option::Option::Some(_inner),
387 Self::ServerException(_inner) => ::std::option::Option::Some(_inner),
388 Self::UnsupportedFeatureException(_inner) => ::std::option::Option::Some(_inner),
389 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
390 }
391 }
392}
393impl ::std::fmt::Display for RunTaskError {
394 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
395 match self {
396 Self::AccessDeniedException(_inner) => _inner.fmt(f),
397 Self::BlockedException(_inner) => _inner.fmt(f),
398 Self::ClientException(_inner) => _inner.fmt(f),
399 Self::ClusterNotFoundException(_inner) => _inner.fmt(f),
400 Self::ConflictException(_inner) => _inner.fmt(f),
401 Self::InvalidParameterException(_inner) => _inner.fmt(f),
402 Self::PlatformTaskDefinitionIncompatibilityException(_inner) => _inner.fmt(f),
403 Self::PlatformUnknownException(_inner) => _inner.fmt(f),
404 Self::ServerException(_inner) => _inner.fmt(f),
405 Self::UnsupportedFeatureException(_inner) => _inner.fmt(f),
406 Self::Unhandled(_inner) => {
407 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
408 write!(f, "unhandled error ({code})")
409 } else {
410 f.write_str("unhandled error")
411 }
412 }
413 }
414 }
415}
416impl ::aws_smithy_types::retry::ProvideErrorKind for RunTaskError {
417 fn code(&self) -> ::std::option::Option<&str> {
418 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
419 }
420 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
421 ::std::option::Option::None
422 }
423}
424impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for RunTaskError {
425 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
426 match self {
427 Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
428 Self::BlockedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
429 Self::ClientException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
430 Self::ClusterNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
431 Self::ConflictException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
432 Self::InvalidParameterException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
433 Self::PlatformTaskDefinitionIncompatibilityException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
434 Self::PlatformUnknownException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
435 Self::ServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
436 Self::UnsupportedFeatureException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
437 Self::Unhandled(_inner) => &_inner.meta,
438 }
439 }
440}
441impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for RunTaskError {
442 fn create_unhandled_error(
443 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
444 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
445 ) -> Self {
446 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
447 source,
448 meta: meta.unwrap_or_default(),
449 })
450 }
451}
452impl ::aws_types::request_id::RequestId for crate::operation::run_task::RunTaskError {
453 fn request_id(&self) -> Option<&str> {
454 self.meta().request_id()
455 }
456}
457
458pub use crate::operation::run_task::_run_task_input::RunTaskInput;
459
460pub use crate::operation::run_task::_run_task_output::RunTaskOutput;
461
462mod _run_task_input;
463
464mod _run_task_output;
465
466pub mod builders;