aws_sdk_geomaps/operation/
get_static_map.rs1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetStaticMap;
6impl GetStaticMap {
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_static_map::GetStaticMapInput,
14 ) -> ::std::result::Result<
15 crate::operation::get_static_map::GetStaticMapOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::get_static_map::GetStaticMapError,
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_static_map::GetStaticMapError>()
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_static_map::GetStaticMapOutput>()
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_static_map::GetStaticMapInput,
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("Geo Maps", "GetStaticMap", input, runtime_plugins, stop_point)
55 .instrument(::tracing::debug_span!(
58 "Geo Maps.GetStaticMap",
59 "rpc.service" = "Geo Maps",
60 "rpc.method" = "GetStaticMap",
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 GetStaticMap {
90 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
91 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetStaticMap");
92
93 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
94 GetStaticMapRequestSerializer,
95 ));
96 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
97 GetStaticMapResponseDeserializer,
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::Metadata::new("GetStaticMap", "Geo Maps"));
105 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
106 signing_options.double_uri_encode = true;
107 signing_options.content_sha256_header = false;
108 signing_options.normalize_uri_path = true;
109 signing_options.payload_override = None;
110
111 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
112 signing_options,
113 ..::std::default::Default::default()
114 });
115
116 ::std::option::Option::Some(cfg.freeze())
117 }
118
119 fn runtime_components(
120 &self,
121 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
122 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
123 #[allow(unused_mut)]
124 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetStaticMap")
125 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
126 .with_interceptor(GetStaticMapEndpointParamsInterceptor)
127 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
128 crate::operation::get_static_map::GetStaticMapError,
129 >::new())
130 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
131 crate::operation::get_static_map::GetStaticMapError,
132 >::new())
133 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
134 crate::operation::get_static_map::GetStaticMapError,
135 >::new());
136
137 ::std::borrow::Cow::Owned(rcb)
138 }
139}
140
141#[derive(Debug)]
142struct GetStaticMapResponseDeserializer;
143impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetStaticMapResponseDeserializer {
144 fn deserialize_nonstreaming(
145 &self,
146 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
147 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
148 let (success, status) = (response.status().is_success(), response.status().as_u16());
149 let headers = response.headers();
150 let body = response.body().bytes().expect("body loaded");
151 #[allow(unused_mut)]
152 let mut force_error = false;
153 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
154 let parse_result = if !success && status != 200 || force_error {
155 crate::protocol_serde::shape_get_static_map::de_get_static_map_http_error(status, headers, body)
156 } else {
157 crate::protocol_serde::shape_get_static_map::de_get_static_map_http_response(status, headers, body)
158 };
159 crate::protocol_serde::type_erase_result(parse_result)
160 }
161}
162#[derive(Debug)]
163struct GetStaticMapRequestSerializer;
164impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetStaticMapRequestSerializer {
165 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
166 fn serialize_input(
167 &self,
168 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
169 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
170 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
171 let input = input
172 .downcast::<crate::operation::get_static_map::GetStaticMapInput>()
173 .expect("correct type");
174 let _header_serialization_settings = _cfg
175 .load::<crate::serialization_settings::HeaderSerializationSettings>()
176 .cloned()
177 .unwrap_or_default();
178 let mut request_builder = {
179 fn uri_base(
180 _input: &crate::operation::get_static_map::GetStaticMapInput,
181 output: &mut ::std::string::String,
182 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
183 use ::std::fmt::Write as _;
184 let input_1 = &_input.file_name;
185 let input_1 = input_1
186 .as_ref()
187 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("file_name", "cannot be empty or unset"))?;
188 let file_name = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Default);
189 if file_name.is_empty() {
190 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
191 "file_name",
192 "cannot be empty or unset",
193 ));
194 }
195 ::std::write!(output, "/static/{FileName}", FileName = file_name).expect("formatting should succeed");
196 ::std::result::Result::Ok(())
197 }
198 fn uri_query(
199 _input: &crate::operation::get_static_map::GetStaticMapInput,
200 mut output: &mut ::std::string::String,
201 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
202 let mut query = ::aws_smithy_http::query::Writer::new(output);
203 if let ::std::option::Option::Some(inner_2) = &_input.bounding_box {
204 {
205 query.push_kv("bounding-box", &::aws_smithy_http::query::fmt_string(inner_2));
206 }
207 }
208 if let ::std::option::Option::Some(inner_3) = &_input.bounded_positions {
209 {
210 query.push_kv("bounded-positions", &::aws_smithy_http::query::fmt_string(inner_3));
211 }
212 }
213 if let ::std::option::Option::Some(inner_4) = &_input.center {
214 {
215 query.push_kv("center", &::aws_smithy_http::query::fmt_string(inner_4));
216 }
217 }
218 if let ::std::option::Option::Some(inner_5) = &_input.color_scheme {
219 {
220 query.push_kv("color-scheme", &::aws_smithy_http::query::fmt_string(inner_5));
221 }
222 }
223 if let ::std::option::Option::Some(inner_6) = &_input.compact_overlay {
224 {
225 query.push_kv("compact-overlay", &::aws_smithy_http::query::fmt_string(inner_6));
226 }
227 }
228 if let ::std::option::Option::Some(inner_7) = &_input.crop_labels {
229 {
230 query.push_kv("crop-labels", ::aws_smithy_types::primitive::Encoder::from(*inner_7).encode());
231 }
232 }
233 if let ::std::option::Option::Some(inner_8) = &_input.geo_json_overlay {
234 {
235 query.push_kv("geojson-overlay", &::aws_smithy_http::query::fmt_string(inner_8));
236 }
237 }
238 let inner_9 = &_input.height;
239 let inner_9 = inner_9
240 .as_ref()
241 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("height", "cannot be empty or unset"))?;
242 query.push_kv("height", ::aws_smithy_types::primitive::Encoder::from(*inner_9).encode());
243 if let ::std::option::Option::Some(inner_10) = &_input.key {
244 {
245 query.push_kv("key", &::aws_smithy_http::query::fmt_string(inner_10));
246 }
247 }
248 if let ::std::option::Option::Some(inner_11) = &_input.label_size {
249 {
250 query.push_kv("label-size", &::aws_smithy_http::query::fmt_string(inner_11));
251 }
252 }
253 if let ::std::option::Option::Some(inner_12) = &_input.language {
254 {
255 query.push_kv("lang", &::aws_smithy_http::query::fmt_string(inner_12));
256 }
257 }
258 if let ::std::option::Option::Some(inner_13) = &_input.padding {
259 {
260 query.push_kv("padding", ::aws_smithy_types::primitive::Encoder::from(*inner_13).encode());
261 }
262 }
263 if let ::std::option::Option::Some(inner_14) = &_input.political_view {
264 {
265 query.push_kv("political-view", &::aws_smithy_http::query::fmt_string(inner_14));
266 }
267 }
268 if let ::std::option::Option::Some(inner_15) = &_input.points_of_interests {
269 {
270 query.push_kv("pois", &::aws_smithy_http::query::fmt_string(inner_15));
271 }
272 }
273 if let ::std::option::Option::Some(inner_16) = &_input.radius {
274 {
275 query.push_kv("radius", ::aws_smithy_types::primitive::Encoder::from(*inner_16).encode());
276 }
277 }
278 if let ::std::option::Option::Some(inner_17) = &_input.scale_bar_unit {
279 {
280 query.push_kv("scale-unit", &::aws_smithy_http::query::fmt_string(inner_17));
281 }
282 }
283 if let ::std::option::Option::Some(inner_18) = &_input.style {
284 {
285 query.push_kv("style", &::aws_smithy_http::query::fmt_string(inner_18));
286 }
287 }
288 let inner_19 = &_input.width;
289 let inner_19 = inner_19
290 .as_ref()
291 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("width", "cannot be empty or unset"))?;
292 query.push_kv("width", ::aws_smithy_types::primitive::Encoder::from(*inner_19).encode());
293 if let ::std::option::Option::Some(inner_20) = &_input.zoom {
294 {
295 query.push_kv("zoom", ::aws_smithy_types::primitive::Encoder::from(*inner_20).encode());
296 }
297 }
298 ::std::result::Result::Ok(())
299 }
300 #[allow(clippy::unnecessary_wraps)]
301 fn update_http_builder(
302 input: &crate::operation::get_static_map::GetStaticMapInput,
303 builder: ::http::request::Builder,
304 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
305 let mut uri = ::std::string::String::new();
306 uri_base(input, &mut uri)?;
307 uri_query(input, &mut uri)?;
308 ::std::result::Result::Ok(builder.method("GET").uri(uri))
309 }
310 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
311 builder
312 };
313 let body = ::aws_smithy_types::body::SdkBody::from("");
314
315 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
316 }
317}
318#[derive(Debug)]
319struct GetStaticMapEndpointParamsInterceptor;
320
321impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetStaticMapEndpointParamsInterceptor {
322 fn name(&self) -> &'static str {
323 "GetStaticMapEndpointParamsInterceptor"
324 }
325
326 fn read_before_execution(
327 &self,
328 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
329 '_,
330 ::aws_smithy_runtime_api::client::interceptors::context::Input,
331 ::aws_smithy_runtime_api::client::interceptors::context::Output,
332 ::aws_smithy_runtime_api::client::interceptors::context::Error,
333 >,
334 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
335 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
336 let _input = context
337 .input()
338 .downcast_ref::<GetStaticMapInput>()
339 .ok_or("failed to downcast to GetStaticMapInput")?;
340
341 let params = crate::config::endpoint::Params::builder()
342 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
343 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
344 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
345 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
346 .build()
347 .map_err(|err| {
348 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
349 })?;
350 cfg.interceptor_state()
351 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
352 ::std::result::Result::Ok(())
353 }
354}
355
356#[non_exhaustive]
361#[derive(::std::fmt::Debug)]
362pub enum GetStaticMapError {
363 AccessDeniedException(crate::types::error::AccessDeniedException),
365 InternalServerException(crate::types::error::InternalServerException),
367 ThrottlingException(crate::types::error::ThrottlingException),
369 ValidationException(crate::types::error::ValidationException),
371 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
373 variable wildcard pattern and check `.code()`:
374 \
375 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
376 \
377 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetStaticMapError) for what information is available for the error.")]
378 Unhandled(crate::error::sealed_unhandled::Unhandled),
379}
380impl GetStaticMapError {
381 pub fn unhandled(
383 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
384 ) -> Self {
385 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
386 source: err.into(),
387 meta: ::std::default::Default::default(),
388 })
389 }
390
391 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
393 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
394 source: err.clone().into(),
395 meta: err,
396 })
397 }
398 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
403 match self {
404 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
405 Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
406 Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
407 Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
408 Self::Unhandled(e) => &e.meta,
409 }
410 }
411 pub fn is_access_denied_exception(&self) -> bool {
413 matches!(self, Self::AccessDeniedException(_))
414 }
415 pub fn is_internal_server_exception(&self) -> bool {
417 matches!(self, Self::InternalServerException(_))
418 }
419 pub fn is_throttling_exception(&self) -> bool {
421 matches!(self, Self::ThrottlingException(_))
422 }
423 pub fn is_validation_exception(&self) -> bool {
425 matches!(self, Self::ValidationException(_))
426 }
427}
428impl ::std::error::Error for GetStaticMapError {
429 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
430 match self {
431 Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
432 Self::InternalServerException(_inner) => ::std::option::Option::Some(_inner),
433 Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
434 Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
435 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
436 }
437 }
438}
439impl ::std::fmt::Display for GetStaticMapError {
440 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
441 match self {
442 Self::AccessDeniedException(_inner) => _inner.fmt(f),
443 Self::InternalServerException(_inner) => _inner.fmt(f),
444 Self::ThrottlingException(_inner) => _inner.fmt(f),
445 Self::ValidationException(_inner) => _inner.fmt(f),
446 Self::Unhandled(_inner) => {
447 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
448 write!(f, "unhandled error ({code})")
449 } else {
450 f.write_str("unhandled error")
451 }
452 }
453 }
454 }
455}
456impl ::aws_smithy_types::retry::ProvideErrorKind for GetStaticMapError {
457 fn code(&self) -> ::std::option::Option<&str> {
458 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
459 }
460 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
461 match self {
462 Self::InternalServerException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
463 Self::ThrottlingException(inner) => ::std::option::Option::Some(inner.retryable_error_kind()),
464 _ => ::std::option::Option::None,
465 }
466 }
467}
468impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetStaticMapError {
469 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
470 match self {
471 Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
472 Self::InternalServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
473 Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
474 Self::ValidationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
475 Self::Unhandled(_inner) => &_inner.meta,
476 }
477 }
478}
479impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetStaticMapError {
480 fn create_unhandled_error(
481 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
482 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
483 ) -> Self {
484 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
485 source,
486 meta: meta.unwrap_or_default(),
487 })
488 }
489}
490impl ::aws_types::request_id::RequestId for crate::operation::get_static_map::GetStaticMapError {
491 fn request_id(&self) -> Option<&str> {
492 self.meta().request_id()
493 }
494}
495
496pub use crate::operation::get_static_map::_get_static_map_output::GetStaticMapOutput;
497
498pub use crate::operation::get_static_map::_get_static_map_input::GetStaticMapInput;
499
500mod _get_static_map_input;
501
502mod _get_static_map_output;
503
504pub mod builders;