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 fn uri_base(
176 _input: &crate::operation::get_task::GetTaskInput,
177 output: &mut ::std::string::String,
178 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
179 use ::std::fmt::Write as _;
180 let input_1 = &_input.farm_id;
181 let input_1 = input_1
182 .as_ref()
183 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("farm_id", "cannot be empty or unset"))?;
184 let farm_id = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
185 if farm_id.is_empty() {
186 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
187 "farm_id",
188 "cannot be empty or unset",
189 ));
190 }
191 let input_2 = &_input.queue_id;
192 let input_2 = input_2
193 .as_ref()
194 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("queue_id", "cannot be empty or unset"))?;
195 let queue_id = ::aws_smithy_http::label::fmt_string(input_2, ::aws_smithy_http::label::EncodingStrategy::Default);
196 if queue_id.is_empty() {
197 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
198 "queue_id",
199 "cannot be empty or unset",
200 ));
201 }
202 let input_3 = &_input.job_id;
203 let input_3 = input_3
204 .as_ref()
205 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("job_id", "cannot be empty or unset"))?;
206 let job_id = ::aws_smithy_http::label::fmt_string(input_3, ::aws_smithy_http::label::EncodingStrategy::Default);
207 if job_id.is_empty() {
208 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
209 "job_id",
210 "cannot be empty or unset",
211 ));
212 }
213 let input_4 = &_input.step_id;
214 let input_4 = input_4
215 .as_ref()
216 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("step_id", "cannot be empty or unset"))?;
217 let step_id = ::aws_smithy_http::label::fmt_string(input_4, ::aws_smithy_http::label::EncodingStrategy::Default);
218 if step_id.is_empty() {
219 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
220 "step_id",
221 "cannot be empty or unset",
222 ));
223 }
224 let input_5 = &_input.task_id;
225 let input_5 = input_5
226 .as_ref()
227 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("task_id", "cannot be empty or unset"))?;
228 let task_id = ::aws_smithy_http::label::fmt_string(input_5, ::aws_smithy_http::label::EncodingStrategy::Default);
229 if task_id.is_empty() {
230 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
231 "task_id",
232 "cannot be empty or unset",
233 ));
234 }
235 ::std::write!(
236 output,
237 "/2023-10-12/farms/{farmId}/queues/{queueId}/jobs/{jobId}/steps/{stepId}/tasks/{taskId}",
238 farmId = farm_id,
239 queueId = queue_id,
240 jobId = job_id,
241 stepId = step_id,
242 taskId = task_id
243 )
244 .expect("formatting should succeed");
245 ::std::result::Result::Ok(())
246 }
247 #[allow(clippy::unnecessary_wraps)]
248 fn update_http_builder(
249 input: &crate::operation::get_task::GetTaskInput,
250 builder: ::http::request::Builder,
251 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
252 let mut uri = ::std::string::String::new();
253 uri_base(input, &mut uri)?;
254 ::std::result::Result::Ok(builder.method("GET").uri(uri))
255 }
256 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
257 builder
258 };
259 let body = ::aws_smithy_types::body::SdkBody::from("");
260
261 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
262 }
263}
264#[derive(Debug)]
265struct GetTaskEndpointParamsInterceptor;
266
267impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetTaskEndpointParamsInterceptor {
268 fn name(&self) -> &'static str {
269 "GetTaskEndpointParamsInterceptor"
270 }
271
272 fn read_before_execution(
273 &self,
274 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
275 '_,
276 ::aws_smithy_runtime_api::client::interceptors::context::Input,
277 ::aws_smithy_runtime_api::client::interceptors::context::Output,
278 ::aws_smithy_runtime_api::client::interceptors::context::Error,
279 >,
280 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
281 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
282 let _input = context
283 .input()
284 .downcast_ref::<GetTaskInput>()
285 .ok_or("failed to downcast to GetTaskInput")?;
286
287 let endpoint_prefix = ::aws_smithy_runtime_api::client::endpoint::EndpointPrefix::new("management.").map_err(|err| {
288 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint prefix could not be built", err)
289 })?;
290 cfg.interceptor_state().store_put(endpoint_prefix);
291
292 let params = crate::config::endpoint::Params::builder()
293 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
294 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
295 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
296 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
297 .build()
298 .map_err(|err| {
299 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
300 })?;
301 cfg.interceptor_state()
302 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
303 ::std::result::Result::Ok(())
304 }
305}
306
307#[non_exhaustive]
312#[derive(::std::fmt::Debug)]
313pub enum GetTaskError {
314 AccessDeniedException(crate::types::error::AccessDeniedException),
316 InternalServerErrorException(crate::types::error::InternalServerErrorException),
318 ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
320 ThrottlingException(crate::types::error::ThrottlingException),
322 ValidationException(crate::types::error::ValidationException),
324 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
326 variable wildcard pattern and check `.code()`:
327 \
328 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
329 \
330 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetTaskError) for what information is available for the error.")]
331 Unhandled(crate::error::sealed_unhandled::Unhandled),
332}
333impl GetTaskError {
334 pub fn unhandled(
336 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
337 ) -> Self {
338 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
339 source: err.into(),
340 meta: ::std::default::Default::default(),
341 })
342 }
343
344 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
346 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
347 source: err.clone().into(),
348 meta: err,
349 })
350 }
351 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
356 match self {
357 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
358 Self::InternalServerErrorException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
359 Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
360 Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
361 Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
362 Self::Unhandled(e) => &e.meta,
363 }
364 }
365 pub fn is_access_denied_exception(&self) -> bool {
367 matches!(self, Self::AccessDeniedException(_))
368 }
369 pub fn is_internal_server_error_exception(&self) -> bool {
371 matches!(self, Self::InternalServerErrorException(_))
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_validation_exception(&self) -> bool {
383 matches!(self, Self::ValidationException(_))
384 }
385}
386impl ::std::error::Error for GetTaskError {
387 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
388 match self {
389 Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
390 Self::InternalServerErrorException(_inner) => ::std::option::Option::Some(_inner),
391 Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
392 Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
393 Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
394 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
395 }
396 }
397}
398impl ::std::fmt::Display for GetTaskError {
399 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
400 match self {
401 Self::AccessDeniedException(_inner) => _inner.fmt(f),
402 Self::InternalServerErrorException(_inner) => _inner.fmt(f),
403 Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
404 Self::ThrottlingException(_inner) => _inner.fmt(f),
405 Self::ValidationException(_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 GetTaskError {
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 match self {
422 Self::InternalServerErrorException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
423 Self::ThrottlingException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
424 _ => ::std::option::Option::None,
425 }
426 }
427}
428impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetTaskError {
429 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
430 match self {
431 Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
432 Self::InternalServerErrorException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
433 Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
434 Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
435 Self::ValidationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
436 Self::Unhandled(_inner) => &_inner.meta,
437 }
438 }
439}
440impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetTaskError {
441 fn create_unhandled_error(
442 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
443 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
444 ) -> Self {
445 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
446 source,
447 meta: meta.unwrap_or_default(),
448 })
449 }
450}
451impl ::aws_types::request_id::RequestId for crate::operation::get_task::GetTaskError {
452 fn request_id(&self) -> Option<&str> {
453 self.meta().request_id()
454 }
455}
456
457pub use crate::operation::get_task::_get_task_output::GetTaskOutput;
458
459pub use crate::operation::get_task::_get_task_input::GetTaskInput;
460
461mod _get_task_input;
462
463mod _get_task_output;
464
465pub mod builders;