aws_sdk_deadline/operation/
get_task.rs1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetTask;
6impl GetTask {
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::get_task::GetTaskInput,
14 ) -> ::std::result::Result<
15 crate::operation::get_task::GetTaskOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::get_task::GetTaskError,
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::get_task::GetTaskError>().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::get_task::GetTaskOutput>()
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::get_task::GetTaskInput,
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("deadline", "GetTask", input, runtime_plugins, stop_point)
51 .instrument(::tracing::debug_span!(
54 "deadline.GetTask",
55 "rpc.service" = "deadline",
56 "rpc.method" = "GetTask",
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
70 if let ::std::option::Option::Some(config_override) = config_override {
71 for plugin in config_override.runtime_plugins.iter().cloned() {
72 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
73 }
74 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
75 config_override,
76 client_config.config.clone(),
77 &client_config.runtime_components,
78 ));
79 }
80 runtime_plugins
81 }
82}
83impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetTask {
84 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
85 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetTask");
86
87 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
88 GetTaskRequestSerializer,
89 ));
90 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
91 GetTaskResponseDeserializer,
92 ));
93
94 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
95 crate::config::auth::Params::builder()
96 .operation_name("GetTask")
97 .build()
98 .expect("required fields set"),
99 ));
100
101 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
102 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("GetTask", "deadline"));
103 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
104 signing_options.double_uri_encode = true;
105 signing_options.content_sha256_header = false;
106 signing_options.normalize_uri_path = true;
107 signing_options.payload_override = None;
108
109 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
110 signing_options,
111 ..::std::default::Default::default()
112 });
113
114 ::std::option::Option::Some(cfg.freeze())
115 }
116
117 fn runtime_components(
118 &self,
119 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
120 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
121 #[allow(unused_mut)]
122 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetTask")
123 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
124 .with_interceptor(GetTaskEndpointParamsInterceptor)
125 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
126 crate::operation::get_task::GetTaskError,
127 >::new())
128 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
129 crate::operation::get_task::GetTaskError,
130 >::new())
131 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
132 crate::operation::get_task::GetTaskError,
133 >::new());
134
135 ::std::borrow::Cow::Owned(rcb)
136 }
137}
138
139#[derive(Debug)]
140struct GetTaskResponseDeserializer;
141impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetTaskResponseDeserializer {
142 fn deserialize_nonstreaming(
143 &self,
144 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
145 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
146 let (success, status) = (response.status().is_success(), response.status().as_u16());
147 let headers = response.headers();
148 let body = response.body().bytes().expect("body loaded");
149 #[allow(unused_mut)]
150 let mut force_error = false;
151 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
152 let parse_result = if !success && status != 200 || force_error {
153 crate::protocol_serde::shape_get_task::de_get_task_http_error(status, headers, body)
154 } else {
155 crate::protocol_serde::shape_get_task::de_get_task_http_response(status, headers, body)
156 };
157 crate::protocol_serde::type_erase_result(parse_result)
158 }
159}
160#[derive(Debug)]
161struct GetTaskRequestSerializer;
162impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetTaskRequestSerializer {
163 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
164 fn serialize_input(
165 &self,
166 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
167 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
168 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
169 let input = input.downcast::<crate::operation::get_task::GetTaskInput>().expect("correct type");
170 let _header_serialization_settings = _cfg
171 .load::<crate::serialization_settings::HeaderSerializationSettings>()
172 .cloned()
173 .unwrap_or_default();
174 let mut request_builder = {
175 #[allow(clippy::uninlined_format_args)]
176 fn uri_base(
177 _input: &crate::operation::get_task::GetTaskInput,
178 output: &mut ::std::string::String,
179 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
180 use ::std::fmt::Write as _;
181 let input_1 = &_input.farm_id;
182 let input_1 = input_1
183 .as_ref()
184 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("farm_id", "cannot be empty or unset"))?;
185 let farm_id = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
186 if farm_id.is_empty() {
187 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
188 "farm_id",
189 "cannot be empty or unset",
190 ));
191 }
192 let input_2 = &_input.queue_id;
193 let input_2 = input_2
194 .as_ref()
195 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("queue_id", "cannot be empty or unset"))?;
196 let queue_id = ::aws_smithy_http::label::fmt_string(input_2, ::aws_smithy_http::label::EncodingStrategy::Default);
197 if queue_id.is_empty() {
198 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
199 "queue_id",
200 "cannot be empty or unset",
201 ));
202 }
203 let input_3 = &_input.job_id;
204 let input_3 = input_3
205 .as_ref()
206 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("job_id", "cannot be empty or unset"))?;
207 let job_id = ::aws_smithy_http::label::fmt_string(input_3, ::aws_smithy_http::label::EncodingStrategy::Default);
208 if job_id.is_empty() {
209 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
210 "job_id",
211 "cannot be empty or unset",
212 ));
213 }
214 let input_4 = &_input.step_id;
215 let input_4 = input_4
216 .as_ref()
217 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("step_id", "cannot be empty or unset"))?;
218 let step_id = ::aws_smithy_http::label::fmt_string(input_4, ::aws_smithy_http::label::EncodingStrategy::Default);
219 if step_id.is_empty() {
220 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
221 "step_id",
222 "cannot be empty or unset",
223 ));
224 }
225 let input_5 = &_input.task_id;
226 let input_5 = input_5
227 .as_ref()
228 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("task_id", "cannot be empty or unset"))?;
229 let task_id = ::aws_smithy_http::label::fmt_string(input_5, ::aws_smithy_http::label::EncodingStrategy::Default);
230 if task_id.is_empty() {
231 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
232 "task_id",
233 "cannot be empty or unset",
234 ));
235 }
236 ::std::write!(
237 output,
238 "/2023-10-12/farms/{farmId}/queues/{queueId}/jobs/{jobId}/steps/{stepId}/tasks/{taskId}",
239 farmId = farm_id,
240 queueId = queue_id,
241 jobId = job_id,
242 stepId = step_id,
243 taskId = task_id
244 )
245 .expect("formatting should succeed");
246 ::std::result::Result::Ok(())
247 }
248 #[allow(clippy::unnecessary_wraps)]
249 fn update_http_builder(
250 input: &crate::operation::get_task::GetTaskInput,
251 builder: ::http::request::Builder,
252 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
253 let mut uri = ::std::string::String::new();
254 uri_base(input, &mut uri)?;
255 ::std::result::Result::Ok(builder.method("GET").uri(uri))
256 }
257 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
258 builder
259 };
260 let body = ::aws_smithy_types::body::SdkBody::from("");
261
262 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
263 }
264}
265#[derive(Debug)]
266struct GetTaskEndpointParamsInterceptor;
267
268impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetTaskEndpointParamsInterceptor {
269 fn name(&self) -> &'static str {
270 "GetTaskEndpointParamsInterceptor"
271 }
272
273 fn read_before_execution(
274 &self,
275 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
276 '_,
277 ::aws_smithy_runtime_api::client::interceptors::context::Input,
278 ::aws_smithy_runtime_api::client::interceptors::context::Output,
279 ::aws_smithy_runtime_api::client::interceptors::context::Error,
280 >,
281 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
282 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
283 let _input = context
284 .input()
285 .downcast_ref::<GetTaskInput>()
286 .ok_or("failed to downcast to GetTaskInput")?;
287
288 let endpoint_prefix = ::aws_smithy_runtime_api::client::endpoint::EndpointPrefix::new("management.").map_err(|err| {
289 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint prefix could not be built", err)
290 })?;
291 cfg.interceptor_state().store_put(endpoint_prefix);
292
293 let params = crate::config::endpoint::Params::builder()
294 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
295 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
296 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
297 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
298 .build()
299 .map_err(|err| {
300 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
301 })?;
302 cfg.interceptor_state()
303 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
304 ::std::result::Result::Ok(())
305 }
306}
307
308#[non_exhaustive]
313#[derive(::std::fmt::Debug)]
314pub enum GetTaskError {
315 AccessDeniedException(crate::types::error::AccessDeniedException),
317 InternalServerErrorException(crate::types::error::InternalServerErrorException),
319 ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
321 ThrottlingException(crate::types::error::ThrottlingException),
323 ValidationException(crate::types::error::ValidationException),
325 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
327 variable wildcard pattern and check `.code()`:
328 \
329 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
330 \
331 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetTaskError) for what information is available for the error.")]
332 Unhandled(crate::error::sealed_unhandled::Unhandled),
333}
334impl GetTaskError {
335 pub fn unhandled(
337 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
338 ) -> Self {
339 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
340 source: err.into(),
341 meta: ::std::default::Default::default(),
342 })
343 }
344
345 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
347 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
348 source: err.clone().into(),
349 meta: err,
350 })
351 }
352 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
357 match self {
358 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
359 Self::InternalServerErrorException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
360 Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
361 Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
362 Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
363 Self::Unhandled(e) => &e.meta,
364 }
365 }
366 pub fn is_access_denied_exception(&self) -> bool {
368 matches!(self, Self::AccessDeniedException(_))
369 }
370 pub fn is_internal_server_error_exception(&self) -> bool {
372 matches!(self, Self::InternalServerErrorException(_))
373 }
374 pub fn is_resource_not_found_exception(&self) -> bool {
376 matches!(self, Self::ResourceNotFoundException(_))
377 }
378 pub fn is_throttling_exception(&self) -> bool {
380 matches!(self, Self::ThrottlingException(_))
381 }
382 pub fn is_validation_exception(&self) -> bool {
384 matches!(self, Self::ValidationException(_))
385 }
386}
387impl ::std::error::Error for GetTaskError {
388 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
389 match self {
390 Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
391 Self::InternalServerErrorException(_inner) => ::std::option::Option::Some(_inner),
392 Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
393 Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
394 Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
395 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
396 }
397 }
398}
399impl ::std::fmt::Display for GetTaskError {
400 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
401 match self {
402 Self::AccessDeniedException(_inner) => _inner.fmt(f),
403 Self::InternalServerErrorException(_inner) => _inner.fmt(f),
404 Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
405 Self::ThrottlingException(_inner) => _inner.fmt(f),
406 Self::ValidationException(_inner) => _inner.fmt(f),
407 Self::Unhandled(_inner) => {
408 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
409 write!(f, "unhandled error ({code})")
410 } else {
411 f.write_str("unhandled error")
412 }
413 }
414 }
415 }
416}
417impl ::aws_smithy_types::retry::ProvideErrorKind for GetTaskError {
418 fn code(&self) -> ::std::option::Option<&str> {
419 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
420 }
421 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
422 match self {
423 Self::InternalServerErrorException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
424 Self::ThrottlingException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
425 _ => ::std::option::Option::None,
426 }
427 }
428}
429impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetTaskError {
430 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
431 match self {
432 Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
433 Self::InternalServerErrorException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
434 Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
435 Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
436 Self::ValidationException(_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 GetTaskError {
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::get_task::GetTaskError {
453 fn request_id(&self) -> Option<&str> {
454 self.meta().request_id()
455 }
456}
457
458pub use crate::operation::get_task::_get_task_output::GetTaskOutput;
459
460pub use crate::operation::get_task::_get_task_input::GetTaskInput;
461
462mod _get_task_input;
463
464mod _get_task_output;
465
466pub mod builders;