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