1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | /// Orchestration and serialization glue logic for `OperationWithDefaults`.
|
3 + | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
4 + | #[non_exhaustive]
|
5 + | pub struct OperationWithDefaults;
|
6 + | impl OperationWithDefaults {
|
7 + | /// Creates a new `OperationWithDefaults`
|
8 + | 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::operation_with_defaults::OperationWithDefaultsInput,
|
14 + | ) -> ::std::result::Result<
|
15 + | crate::operation::operation_with_defaults::OperationWithDefaultsOutput,
|
16 + | ::aws_smithy_runtime_api::client::result::SdkError<
|
17 + | crate::operation::operation_with_defaults::OperationWithDefaultsError,
|
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::operation_with_defaults::OperationWithDefaultsError>()
|
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::operation_with_defaults::OperationWithDefaultsOutput>()
|
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::operation_with_defaults::OperationWithDefaultsInput,
|
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 + | ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point(
|
54 + | "restjsonprotocol",
|
55 + | "OperationWithDefaults",
|
56 + | input,
|
57 + | runtime_plugins,
|
58 + | stop_point,
|
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_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
|
70 + | ::aws_smithy_runtime::client::auth::no_auth::NO_AUTH_SCHEME_ID,
|
71 + | ]));
|
72 + | if let ::std::option::Option::Some(config_override) = config_override {
|
73 + | for plugin in config_override.runtime_plugins.iter().cloned() {
|
74 + | runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
|
75 + | }
|
76 + | runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
|
77 + | config_override,
|
78 + | client_config.config.clone(),
|
79 + | &client_config.runtime_components,
|
80 + | ));
|
81 + | }
|
82 + | runtime_plugins
|
83 + | }
|
84 + | }
|
85 + | impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for OperationWithDefaults {
|
86 + | fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
|
87 + | let mut cfg = ::aws_smithy_types::config_bag::Layer::new("OperationWithDefaults");
|
88 + |
|
89 + | cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
|
90 + | OperationWithDefaultsRequestSerializer,
|
91 + | ));
|
92 + | cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
|
93 + | OperationWithDefaultsResponseDeserializer,
|
94 + | ));
|
95 + |
|
96 + | cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
|
97 + | ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
|
98 + | ));
|
99 + |
|
100 + | cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
|
101 + | "OperationWithDefaults",
|
102 + | "restjsonprotocol",
|
103 + | ));
|
104 + |
|
105 + | ::std::option::Option::Some(cfg.freeze())
|
106 + | }
|
107 + |
|
108 + | fn runtime_components(
|
109 + | &self,
|
110 + | _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
|
111 + | ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
|
112 + | #[allow(unused_mut)]
|
113 + | let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("OperationWithDefaults")
|
114 + | .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
|
115 + | .with_interceptor(OperationWithDefaultsEndpointParamsInterceptor)
|
116 + | .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
|
117 + | crate::operation::operation_with_defaults::OperationWithDefaultsError,
|
118 + | >::new())
|
119 + | .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
|
120 + | crate::operation::operation_with_defaults::OperationWithDefaultsError,
|
121 + | >::new());
|
122 + |
|
123 + | ::std::borrow::Cow::Owned(rcb)
|
124 + | }
|
125 + | }
|
126 + |
|
127 + | #[derive(Debug)]
|
128 + | struct OperationWithDefaultsResponseDeserializer;
|
129 + | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for OperationWithDefaultsResponseDeserializer {
|
130 + | fn deserialize_nonstreaming(
|
131 + | &self,
|
132 + | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
133 + | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
134 + | let (success, status) = (response.status().is_success(), response.status().as_u16());
|
135 + | let headers = response.headers();
|
136 + | let body = response.body().bytes().expect("body loaded");
|
137 + | #[allow(unused_mut)]
|
138 + | let mut force_error = false;
|
139 + |
|
140 + | let parse_result = if !success && status != 200 || force_error {
|
141 + | crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults_http_error(status, headers, body)
|
142 + | } else {
|
143 + | crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults_http_response(status, headers, body)
|
144 + | };
|
145 + | crate::protocol_serde::type_erase_result(parse_result)
|
146 + | }
|
147 + | }
|
148 + | #[derive(Debug)]
|
149 + | struct OperationWithDefaultsRequestSerializer;
|
150 + | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for OperationWithDefaultsRequestSerializer {
|
151 + | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
152 + | fn serialize_input(
|
153 + | &self,
|
154 + | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
155 + | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
156 + | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
157 + | let input = input
|
158 + | .downcast::<crate::operation::operation_with_defaults::OperationWithDefaultsInput>()
|
159 + | .expect("correct type");
|
160 + | let _header_serialization_settings = _cfg
|
161 + | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
162 + | .cloned()
|
163 + | .unwrap_or_default();
|
164 + | let mut request_builder = {
|
165 + | fn uri_base(
|
166 + | _input: &crate::operation::operation_with_defaults::OperationWithDefaultsInput,
|
167 + | output: &mut ::std::string::String,
|
168 + | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
169 + | use ::std::fmt::Write as _;
|
170 + | ::std::write!(output, "/OperationWithDefaults").expect("formatting should succeed");
|
171 + | ::std::result::Result::Ok(())
|
172 + | }
|
173 + | #[allow(clippy::unnecessary_wraps)]
|
174 + | fn update_http_builder(
|
175 + | input: &crate::operation::operation_with_defaults::OperationWithDefaultsInput,
|
176 + | builder: ::http::request::Builder,
|
177 + | ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
178 + | let mut uri = ::std::string::String::new();
|
179 + | uri_base(input, &mut uri)?;
|
180 + | ::std::result::Result::Ok(builder.method("POST").uri(uri))
|
181 + | }
|
182 + | let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
|
183 + | builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/json");
|
184 + | builder
|
185 + | };
|
186 + | let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_input(
|
187 + | &input,
|
188 + | )?);
|
189 + | if let Some(content_length) = body.content_length() {
|
190 + | let content_length = content_length.to_string();
|
191 + | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
|
192 + | }
|
193 + | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
194 + | }
|
195 + | }
|
196 + | #[derive(Debug)]
|
197 + | struct OperationWithDefaultsEndpointParamsInterceptor;
|
198 + |
|
199 + | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for OperationWithDefaultsEndpointParamsInterceptor {
|
200 + | fn name(&self) -> &'static str {
|
201 + | "OperationWithDefaultsEndpointParamsInterceptor"
|
202 + | }
|
203 + |
|
204 + | fn read_before_execution(
|
205 + | &self,
|
206 + | context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
|
207 + | '_,
|
208 + | ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
209 + | ::aws_smithy_runtime_api::client::interceptors::context::Output,
|
210 + | ::aws_smithy_runtime_api::client::interceptors::context::Error,
|
211 + | >,
|
212 + | cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
213 + | ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
|
214 + | let _input = context
|
215 + | .input()
|
216 + | .downcast_ref::<OperationWithDefaultsInput>()
|
217 + | .ok_or("failed to downcast to OperationWithDefaultsInput")?;
|
218 + |
|
219 + | let params = crate::config::endpoint::Params::builder().build().map_err(|err| {
|
220 + | ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
|
221 + | })?;
|
222 + | cfg.interceptor_state()
|
223 + | .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
|
224 + | ::std::result::Result::Ok(())
|
225 + | }
|
226 + | }
|
227 + | #[allow(unreachable_code, unused_variables)]
|
228 + | #[cfg(test)]
|
229 + | mod operation_with_defaults_test {
|
230 + | use ::aws_smithy_protocol_test::FloatEquals;
|
231 + |
|
232 + | /// Client populates default values in input.
|
233 + | /// Test ID: RestJsonClientPopulatesDefaultValuesInInput
|
234 + | #[::tokio::test]
|
235 + | #[::tracing_test::traced_test]
|
236 + | #[should_panic]
|
237 + | async fn rest_json_client_populates_default_values_in_input_request() {
|
238 + | let (http_client, request_receiver) = ::aws_smithy_runtime::client::http::test_util::capture_request(None);
|
239 + | let config_builder = crate::config::Config::builder().with_test_defaults().endpoint_url("https://example.com");
|
240 + |
|
241 + | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
242 + | let result = client
|
243 + | .operation_with_defaults()
|
244 + | .set_defaults(::std::option::Option::Some(crate::types::Defaults::builder().build()))
|
245 + | .send()
|
246 + | .await;
|
247 + | let _ = dbg!(result);
|
248 + | let http_request = request_receiver.expect_request();
|
249 + | let expected_headers = [("Content-Type", "application/json")];
|
250 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
251 + | let body = http_request.body().bytes().expect("body should be strict");
|
252 + | ::aws_smithy_protocol_test::assert_ok(
|
253 + | ::aws_smithy_protocol_test::validate_body(body, "{\n \"defaults\": {\n \"defaultString\": \"hi\",\n \"defaultBoolean\": true,\n \"defaultList\": [],\n \"defaultDocumentMap\": {},\n \"defaultDocumentString\": \"hi\",\n \"defaultDocumentBoolean\": true,\n \"defaultDocumentList\": [],\n \"defaultTimestamp\": 0,\n \"defaultBlob\": \"YWJj\",\n \"defaultByte\": 1,\n \"defaultShort\": 1,\n \"defaultInteger\": 10,\n \"defaultLong\": 100,\n \"defaultFloat\": 1.0,\n \"defaultDouble\": 1.0,\n \"defaultMap\": {},\n \"defaultEnum\": \"FOO\",\n \"defaultIntEnum\": 1,\n \"emptyString\": \"\",\n \"falseBoolean\": false,\n \"emptyBlob\": \"\",\n \"zeroByte\": 0,\n \"zeroShort\": 0,\n \"zeroInteger\": 0,\n \"zeroLong\": 0,\n \"zeroFloat\": 0.0,\n \"zeroDouble\": 0.0\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
254 + | );
|
255 + | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
256 + | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
257 + | ::pretty_assertions::assert_eq!(uri.path(), "/OperationWithDefaults", "path was incorrect");
|
258 + | }
|
259 + | /// Client skips top level default values in input.
|
260 + | /// Test ID: RestJsonClientSkipsTopLevelDefaultValuesInInput
|
261 + | #[::tokio::test]
|
262 + | #[::tracing_test::traced_test]
|
263 + | async fn rest_json_client_skips_top_level_default_values_in_input_request() {
|
264 + | let (http_client, request_receiver) = ::aws_smithy_runtime::client::http::test_util::capture_request(None);
|
265 + | let config_builder = crate::config::Config::builder().with_test_defaults().endpoint_url("https://example.com");
|
266 + |
|
267 + | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
268 + | let result = client.operation_with_defaults().send().await;
|
269 + | let _ = dbg!(result);
|
270 + | let http_request = request_receiver.expect_request();
|
271 + | let expected_headers = [("Content-Type", "application/json")];
|
272 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
273 + | let body = http_request.body().bytes().expect("body should be strict");
|
274 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
275 + | body,
|
276 + | "{\n}",
|
277 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
278 + | ));
|
279 + | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
280 + | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
281 + | ::pretty_assertions::assert_eq!(uri.path(), "/OperationWithDefaults", "path was incorrect");
|
282 + | }
|
283 + | /// Client uses explicitly provided member values over defaults
|
284 + | /// Test ID: RestJsonClientUsesExplicitlyProvidedMemberValuesOverDefaults
|
285 + | #[::tokio::test]
|
286 + | #[::tracing_test::traced_test]
|
287 + | #[should_panic]
|
288 + | async fn rest_json_client_uses_explicitly_provided_member_values_over_defaults_request() {
|
289 + | let (http_client, request_receiver) = ::aws_smithy_runtime::client::http::test_util::capture_request(None);
|
290 + | let config_builder = crate::config::Config::builder().with_test_defaults().endpoint_url("https://example.com");
|
291 + |
|
292 + | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
293 + | let result = client
|
294 + | .operation_with_defaults()
|
295 + | .set_defaults(::std::option::Option::Some(
|
296 + | crate::types::Defaults::builder()
|
297 + | .set_default_string(::std::option::Option::Some("bye".to_owned()))
|
298 + | .set_default_boolean(::std::option::Option::Some(true))
|
299 + | .set_default_list(::std::option::Option::Some(vec!["a".to_owned()]))
|
300 + | .set_default_document_map(::std::option::Option::Some({
|
301 + | let json_bytes = br#"{
|
302 + | "name": "Jack"
|
303 + | }"#;
|
304 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
305 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
306 + | }))
|
307 + | .set_default_document_string(::std::option::Option::Some({
|
308 + | let json_bytes = br#""bye""#;
|
309 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
310 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
311 + | }))
|
312 + | .set_default_document_boolean(::std::option::Option::Some({
|
313 + | let json_bytes = br#"true"#;
|
314 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
315 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
316 + | }))
|
317 + | .set_default_document_list(::std::option::Option::Some({
|
318 + | let json_bytes = br#"[
|
319 + | "b"
|
320 + | ]"#;
|
321 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
322 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
323 + | }))
|
324 + | .set_default_null_document(::std::option::Option::Some({
|
325 + | let json_bytes = br#""notNull""#;
|
326 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
327 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
328 + | }))
|
329 + | .set_default_timestamp(::std::option::Option::Some(::aws_smithy_types::DateTime::from_fractional_secs(1, 0_f64)))
|
330 + | .set_default_blob(::std::option::Option::Some(::aws_smithy_types::Blob::new("hi")))
|
331 + | .set_default_byte(::std::option::Option::Some(2))
|
332 + | .set_default_short(::std::option::Option::Some(2))
|
333 + | .set_default_integer(::std::option::Option::Some(20))
|
334 + | .set_default_long(::std::option::Option::Some(200))
|
335 + | .set_default_float(::std::option::Option::Some(2.0_f32))
|
336 + | .set_default_double(::std::option::Option::Some(2.0_f64))
|
337 + | .set_default_map(::std::option::Option::Some({
|
338 + | let mut ret = ::std::collections::HashMap::new();
|
339 + | ret.insert("name".to_owned(), "Jack".to_owned());
|
340 + | ret
|
341 + | }))
|
342 + | .set_default_enum(::std::option::Option::Some(
|
343 + | "BAR".parse::<crate::types::TestEnum>().expect("static value validated to member"),
|
344 + | ))
|
345 + | .set_default_int_enum(::std::option::Option::Some(2))
|
346 + | .set_empty_string(::std::option::Option::Some("foo".to_owned()))
|
347 + | .set_false_boolean(::std::option::Option::Some(true))
|
348 + | .set_empty_blob(::std::option::Option::Some(::aws_smithy_types::Blob::new("hi")))
|
349 + | .set_zero_byte(::std::option::Option::Some(1))
|
350 + | .set_zero_short(::std::option::Option::Some(1))
|
351 + | .set_zero_integer(::std::option::Option::Some(1))
|
352 + | .set_zero_long(::std::option::Option::Some(1))
|
353 + | .set_zero_float(::std::option::Option::Some(1.0_f32))
|
354 + | .set_zero_double(::std::option::Option::Some(1.0_f64))
|
355 + | .build(),
|
356 + | ))
|
357 + | .send()
|
358 + | .await;
|
359 + | let _ = dbg!(result);
|
360 + | let http_request = request_receiver.expect_request();
|
361 + | let expected_headers = [("Content-Type", "application/json")];
|
362 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
363 + | let body = http_request.body().bytes().expect("body should be strict");
|
364 + | ::aws_smithy_protocol_test::assert_ok(
|
365 + | ::aws_smithy_protocol_test::validate_body(body, "{\n \"defaults\": {\n \"defaultString\": \"bye\",\n \"defaultBoolean\": true,\n \"defaultList\": [\"a\"],\n \"defaultDocumentMap\": {\"name\": \"Jack\"},\n \"defaultDocumentString\": \"bye\",\n \"defaultDocumentBoolean\": true,\n \"defaultDocumentList\": [\"b\"],\n \"defaultNullDocument\": \"notNull\",\n \"defaultTimestamp\": 1,\n \"defaultBlob\": \"aGk=\",\n \"defaultByte\": 2,\n \"defaultShort\": 2,\n \"defaultInteger\": 20,\n \"defaultLong\": 200,\n \"defaultFloat\": 2.0,\n \"defaultDouble\": 2.0,\n \"defaultMap\": {\"name\": \"Jack\"},\n \"defaultEnum\": \"BAR\",\n \"defaultIntEnum\": 2,\n \"emptyString\": \"foo\",\n \"falseBoolean\": true,\n \"emptyBlob\": \"aGk=\",\n \"zeroByte\": 1,\n \"zeroShort\": 1,\n \"zeroInteger\": 1,\n \"zeroLong\": 1,\n \"zeroFloat\": 1.0,\n \"zeroDouble\": 1.0\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
366 + | );
|
367 + | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
368 + | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
369 + | ::pretty_assertions::assert_eq!(uri.path(), "/OperationWithDefaults", "path was incorrect");
|
370 + | }
|
371 + | /// Any time a value is provided for a member in the top level of input, it is used, regardless of if its the default.
|
372 + | /// Test ID: RestJsonClientUsesExplicitlyProvidedValuesInTopLevel
|
373 + | #[::tokio::test]
|
374 + | #[::tracing_test::traced_test]
|
375 + | async fn rest_json_client_uses_explicitly_provided_values_in_top_level_request() {
|
376 + | let (http_client, request_receiver) = ::aws_smithy_runtime::client::http::test_util::capture_request(None);
|
377 + | let config_builder = crate::config::Config::builder().with_test_defaults().endpoint_url("https://example.com");
|
378 + |
|
379 + | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
380 + | let result = client
|
381 + | .operation_with_defaults()
|
382 + | .set_top_level_default(::std::option::Option::Some("hi".to_owned()))
|
383 + | .set_other_top_level_default(::std::option::Option::Some(0))
|
384 + | .send()
|
385 + | .await;
|
386 + | let _ = dbg!(result);
|
387 + | let http_request = request_receiver.expect_request();
|
388 + | let expected_headers = [("Content-Type", "application/json")];
|
389 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
390 + | let body = http_request.body().bytes().expect("body should be strict");
|
391 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
392 + | body,
|
393 + | "{\n \"topLevelDefault\": \"hi\",\n \"otherTopLevelDefault\": 0\n}",
|
394 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
395 + | ));
|
396 + | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
397 + | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
398 + | ::pretty_assertions::assert_eq!(uri.path(), "/OperationWithDefaults", "path was incorrect");
|
399 + | }
|
400 + | /// Typically, non top-level members would have defaults filled in, but if they have the clientOptional trait, the defaults should be ignored.
|
401 + | /// Test ID: RestJsonClientIgnoresNonTopLevelDefaultsOnMembersWithClientOptional
|
402 + | #[::tokio::test]
|
403 + | #[::tracing_test::traced_test]
|
404 + | async fn rest_json_client_ignores_non_top_level_defaults_on_members_with_client_optional_request() {
|
405 + | let (http_client, request_receiver) = ::aws_smithy_runtime::client::http::test_util::capture_request(None);
|
406 + | let config_builder = crate::config::Config::builder().with_test_defaults().endpoint_url("https://example.com");
|
407 + |
|
408 + | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
409 + | let result = client
|
410 + | .operation_with_defaults()
|
411 + | .set_client_optional_defaults(::std::option::Option::Some(crate::types::ClientOptionalDefaults::builder().build()))
|
412 + | .send()
|
413 + | .await;
|
414 + | let _ = dbg!(result);
|
415 + | let http_request = request_receiver.expect_request();
|
416 + | let expected_headers = [("Content-Type", "application/json")];
|
417 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
418 + | let body = http_request.body().bytes().expect("body should be strict");
|
419 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
420 + | body,
|
421 + | "{\n \"clientOptionalDefaults\": {}\n}",
|
422 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
423 + | ));
|
424 + | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
425 + | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
426 + | ::pretty_assertions::assert_eq!(uri.path(), "/OperationWithDefaults", "path was incorrect");
|
427 + | }
|
428 + | /// Client populates default values when missing in response.
|
429 + | /// Test ID: RestJsonClientPopulatesDefaultsValuesWhenMissingInResponse
|
430 + | #[::tokio::test]
|
431 + | #[::tracing_test::traced_test]
|
432 + | async fn rest_json_client_populates_defaults_values_when_missing_in_response_response() {
|
433 + | let expected_output = crate::operation::operation_with_defaults::OperationWithDefaultsOutput::builder()
|
434 + | .set_default_string(::std::option::Option::Some("hi".to_owned()))
|
435 + | .set_default_boolean(::std::option::Option::Some(true))
|
436 + | .set_default_list(::std::option::Option::Some(vec![]))
|
437 + | .set_default_document_map(::std::option::Option::Some({
|
438 + | let json_bytes = br#"{}"#;
|
439 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
440 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
441 + | }))
|
442 + | .set_default_document_string(::std::option::Option::Some({
|
443 + | let json_bytes = br#""hi""#;
|
444 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
445 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
446 + | }))
|
447 + | .set_default_document_boolean(::std::option::Option::Some({
|
448 + | let json_bytes = br#"true"#;
|
449 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
450 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
451 + | }))
|
452 + | .set_default_document_list(::std::option::Option::Some({
|
453 + | let json_bytes = br#"[]"#;
|
454 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
455 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
456 + | }))
|
457 + | .set_default_timestamp(::std::option::Option::Some(::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64)))
|
458 + | .set_default_blob(::std::option::Option::Some(::aws_smithy_types::Blob::new("abc")))
|
459 + | .set_default_byte(::std::option::Option::Some(1))
|
460 + | .set_default_short(::std::option::Option::Some(1))
|
461 + | .set_default_integer(::std::option::Option::Some(10))
|
462 + | .set_default_long(::std::option::Option::Some(100))
|
463 + | .set_default_float(::std::option::Option::Some(1.0_f32))
|
464 + | .set_default_double(::std::option::Option::Some(1.0_f64))
|
465 + | .set_default_map(::std::option::Option::Some(::std::collections::HashMap::new()))
|
466 + | .set_default_enum(::std::option::Option::Some(
|
467 + | "FOO".parse::<crate::types::TestEnum>().expect("static value validated to member"),
|
468 + | ))
|
469 + | .set_default_int_enum(::std::option::Option::Some(1))
|
470 + | .set_empty_string(::std::option::Option::Some("".to_owned()))
|
471 + | .set_false_boolean(::std::option::Option::Some(false))
|
472 + | .set_empty_blob(::std::option::Option::Some(::aws_smithy_types::Blob::new("")))
|
473 + | .set_zero_byte(::std::option::Option::Some(0))
|
474 + | .set_zero_short(::std::option::Option::Some(0))
|
475 + | .set_zero_integer(::std::option::Option::Some(0))
|
476 + | .set_zero_long(::std::option::Option::Some(0))
|
477 + | .set_zero_float(::std::option::Option::Some(0.0_f32))
|
478 + | .set_zero_double(::std::option::Option::Some(0.0_f64))
|
479 + | .build();
|
480 + | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
481 + | ::http::response::Builder::new()
|
482 + | .header("Content-Type", "application/json")
|
483 + | .status(200)
|
484 + | .body(::aws_smithy_types::body::SdkBody::from("{}"))
|
485 + | .unwrap(),
|
486 + | )
|
487 + | .unwrap();
|
488 + | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
489 + | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
490 + |
|
491 + | let op = crate::operation::operation_with_defaults::OperationWithDefaults::new();
|
492 + | let config = op.config().expect("the operation has config");
|
493 + | let de = config
|
494 + | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
495 + | .expect("the config must have a deserializer");
|
496 + |
|
497 + | let parsed = de.deserialize_streaming(&mut http_response);
|
498 + | let parsed = parsed.unwrap_or_else(|| {
|
499 + | let http_response =
|
500 + | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
501 + | de.deserialize_nonstreaming(&http_response)
|
502 + | });
|
503 + | let parsed = parsed
|
504 + | .expect("should be successful response")
|
505 + | .downcast::<crate::operation::operation_with_defaults::OperationWithDefaultsOutput>()
|
506 + | .unwrap();
|
507 + | ::pretty_assertions::assert_eq!(
|
508 + | parsed.default_string,
|
509 + | expected_output.default_string,
|
510 + | "Unexpected value for `default_string`"
|
511 + | );
|
512 + | ::pretty_assertions::assert_eq!(
|
513 + | parsed.default_boolean,
|
514 + | expected_output.default_boolean,
|
515 + | "Unexpected value for `default_boolean`"
|
516 + | );
|
517 + | ::pretty_assertions::assert_eq!(parsed.default_list, expected_output.default_list, "Unexpected value for `default_list`");
|
518 + | ::pretty_assertions::assert_eq!(
|
519 + | parsed.default_document_map,
|
520 + | expected_output.default_document_map,
|
521 + | "Unexpected value for `default_document_map`"
|
522 + | );
|
523 + | ::pretty_assertions::assert_eq!(
|
524 + | parsed.default_document_string,
|
525 + | expected_output.default_document_string,
|
526 + | "Unexpected value for `default_document_string`"
|
527 + | );
|
528 + | ::pretty_assertions::assert_eq!(
|
529 + | parsed.default_document_boolean,
|
530 + | expected_output.default_document_boolean,
|
531 + | "Unexpected value for `default_document_boolean`"
|
532 + | );
|
533 + | ::pretty_assertions::assert_eq!(
|
534 + | parsed.default_document_list,
|
535 + | expected_output.default_document_list,
|
536 + | "Unexpected value for `default_document_list`"
|
537 + | );
|
538 + | ::pretty_assertions::assert_eq!(
|
539 + | parsed.default_null_document,
|
540 + | expected_output.default_null_document,
|
541 + | "Unexpected value for `default_null_document`"
|
542 + | );
|
543 + | ::pretty_assertions::assert_eq!(
|
544 + | parsed.default_timestamp,
|
545 + | expected_output.default_timestamp,
|
546 + | "Unexpected value for `default_timestamp`"
|
547 + | );
|
548 + | ::pretty_assertions::assert_eq!(parsed.default_blob, expected_output.default_blob, "Unexpected value for `default_blob`");
|
549 + | ::pretty_assertions::assert_eq!(parsed.default_byte, expected_output.default_byte, "Unexpected value for `default_byte`");
|
550 + | ::pretty_assertions::assert_eq!(
|
551 + | parsed.default_short,
|
552 + | expected_output.default_short,
|
553 + | "Unexpected value for `default_short`"
|
554 + | );
|
555 + | ::pretty_assertions::assert_eq!(
|
556 + | parsed.default_integer,
|
557 + | expected_output.default_integer,
|
558 + | "Unexpected value for `default_integer`"
|
559 + | );
|
560 + | ::pretty_assertions::assert_eq!(parsed.default_long, expected_output.default_long, "Unexpected value for `default_long`");
|
561 + | assert!(
|
562 + | parsed.default_float.float_equals(&expected_output.default_float),
|
563 + | "Unexpected value for `default_float` {:?} vs. {:?}",
|
564 + | expected_output.default_float,
|
565 + | parsed.default_float
|
566 + | );
|
567 + | assert!(
|
568 + | parsed.default_double.float_equals(&expected_output.default_double),
|
569 + | "Unexpected value for `default_double` {:?} vs. {:?}",
|
570 + | expected_output.default_double,
|
571 + | parsed.default_double
|
572 + | );
|
573 + | ::pretty_assertions::assert_eq!(parsed.default_map, expected_output.default_map, "Unexpected value for `default_map`");
|
574 + | ::pretty_assertions::assert_eq!(parsed.default_enum, expected_output.default_enum, "Unexpected value for `default_enum`");
|
575 + | ::pretty_assertions::assert_eq!(
|
576 + | parsed.default_int_enum,
|
577 + | expected_output.default_int_enum,
|
578 + | "Unexpected value for `default_int_enum`"
|
579 + | );
|
580 + | ::pretty_assertions::assert_eq!(parsed.empty_string, expected_output.empty_string, "Unexpected value for `empty_string`");
|
581 + | ::pretty_assertions::assert_eq!(
|
582 + | parsed.false_boolean,
|
583 + | expected_output.false_boolean,
|
584 + | "Unexpected value for `false_boolean`"
|
585 + | );
|
586 + | ::pretty_assertions::assert_eq!(parsed.empty_blob, expected_output.empty_blob, "Unexpected value for `empty_blob`");
|
587 + | ::pretty_assertions::assert_eq!(parsed.zero_byte, expected_output.zero_byte, "Unexpected value for `zero_byte`");
|
588 + | ::pretty_assertions::assert_eq!(parsed.zero_short, expected_output.zero_short, "Unexpected value for `zero_short`");
|
589 + | ::pretty_assertions::assert_eq!(parsed.zero_integer, expected_output.zero_integer, "Unexpected value for `zero_integer`");
|
590 + | ::pretty_assertions::assert_eq!(parsed.zero_long, expected_output.zero_long, "Unexpected value for `zero_long`");
|
591 + | assert!(
|
592 + | parsed.zero_float.float_equals(&expected_output.zero_float),
|
593 + | "Unexpected value for `zero_float` {:?} vs. {:?}",
|
594 + | expected_output.zero_float,
|
595 + | parsed.zero_float
|
596 + | );
|
597 + | assert!(
|
598 + | parsed.zero_double.float_equals(&expected_output.zero_double),
|
599 + | "Unexpected value for `zero_double` {:?} vs. {:?}",
|
600 + | expected_output.zero_double,
|
601 + | parsed.zero_double
|
602 + | );
|
603 + | }
|
604 + | /// Client ignores default values if member values are present in the response.
|
605 + | /// Test ID: RestJsonClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse
|
606 + | #[::tokio::test]
|
607 + | #[::tracing_test::traced_test]
|
608 + | #[should_panic]
|
609 + | async fn rest_json_client_ignores_default_values_if_member_values_are_present_in_response_response() {
|
610 + | let expected_output = crate::operation::operation_with_defaults::OperationWithDefaultsOutput::builder()
|
611 + | .set_default_string(::std::option::Option::Some("bye".to_owned()))
|
612 + | .set_default_boolean(::std::option::Option::Some(false))
|
613 + | .set_default_list(::std::option::Option::Some(vec!["a".to_owned()]))
|
614 + | .set_default_document_map(::std::option::Option::Some({
|
615 + | let json_bytes = br#"{
|
616 + | "name": "Jack"
|
617 + | }"#;
|
618 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
619 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
620 + | }))
|
621 + | .set_default_document_string(::std::option::Option::Some({
|
622 + | let json_bytes = br#""bye""#;
|
623 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
624 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
625 + | }))
|
626 + | .set_default_document_boolean(::std::option::Option::Some({
|
627 + | let json_bytes = br#"false"#;
|
628 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
629 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
630 + | }))
|
631 + | .set_default_document_list(::std::option::Option::Some({
|
632 + | let json_bytes = br#"[
|
633 + | "b"
|
634 + | ]"#;
|
635 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
636 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
637 + | }))
|
638 + | .set_default_null_document(::std::option::Option::Some({
|
639 + | let json_bytes = br#""notNull""#;
|
640 + | let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
641 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
|
642 + | }))
|
643 + | .set_default_timestamp(::std::option::Option::Some(::aws_smithy_types::DateTime::from_fractional_secs(1, 0_f64)))
|
644 + | .set_default_blob(::std::option::Option::Some(::aws_smithy_types::Blob::new("hi")))
|
645 + | .set_default_byte(::std::option::Option::Some(2))
|
646 + | .set_default_short(::std::option::Option::Some(2))
|
647 + | .set_default_integer(::std::option::Option::Some(20))
|
648 + | .set_default_long(::std::option::Option::Some(200))
|
649 + | .set_default_float(::std::option::Option::Some(2.0_f32))
|
650 + | .set_default_double(::std::option::Option::Some(2.0_f64))
|
651 + | .set_default_map(::std::option::Option::Some({
|
652 + | let mut ret = ::std::collections::HashMap::new();
|
653 + | ret.insert("name".to_owned(), "Jack".to_owned());
|
654 + | ret
|
655 + | }))
|
656 + | .set_default_enum(::std::option::Option::Some(
|
657 + | "BAR".parse::<crate::types::TestEnum>().expect("static value validated to member"),
|
658 + | ))
|
659 + | .set_default_int_enum(::std::option::Option::Some(2))
|
660 + | .set_empty_string(::std::option::Option::Some("foo".to_owned()))
|
661 + | .set_false_boolean(::std::option::Option::Some(true))
|
662 + | .set_empty_blob(::std::option::Option::Some(::aws_smithy_types::Blob::new("hi")))
|
663 + | .set_zero_byte(::std::option::Option::Some(1))
|
664 + | .set_zero_short(::std::option::Option::Some(1))
|
665 + | .set_zero_integer(::std::option::Option::Some(1))
|
666 + | .set_zero_long(::std::option::Option::Some(1))
|
667 + | .set_zero_float(::std::option::Option::Some(1.0_f32))
|
668 + | .set_zero_double(::std::option::Option::Some(1.0_f64))
|
669 + | .build();
|
670 + | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http::response::Builder::new()
|
671 + | .header("Content-Type", "application/json")
|
672 + | .status(200)
|
673 + | .body(::aws_smithy_types::body::SdkBody::from("{\n \"defaultString\": \"bye\",\n \"defaultBoolean\": false,\n \"defaultList\": [\"a\"],\n \"defaultDocumentMap\": {\"name\": \"Jack\"},\n \"defaultDocumentString\": \"bye\",\n \"defaultDocumentBoolean\": false,\n \"defaultDocumentList\": [\"b\"],\n \"defaultNullDocument\": \"notNull\",\n \"defaultTimestamp\": 2,\n \"defaultBlob\": \"aGk=\",\n \"defaultByte\": 2,\n \"defaultShort\": 2,\n \"defaultInteger\": 20,\n \"defaultLong\": 200,\n \"defaultFloat\": 2.0,\n \"defaultDouble\": 2.0,\n \"defaultMap\": {\"name\": \"Jack\"},\n \"defaultEnum\": \"BAR\",\n \"defaultIntEnum\": 2,\n \"emptyString\": \"foo\",\n \"falseBoolean\": true,\n \"emptyBlob\": \"aGk=\",\n \"zeroByte\": 1,\n \"zeroShort\": 1,\n \"zeroInteger\": 1,\n \"zeroLong\": 1,\n \"zeroFloat\": 1.0,\n \"zeroDouble\": 1.0\n}"))
|
674 + | .unwrap()
|
675 + | ).unwrap();
|
676 + | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
677 + | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
678 + |
|
679 + | let op = crate::operation::operation_with_defaults::OperationWithDefaults::new();
|
680 + | let config = op.config().expect("the operation has config");
|
681 + | let de = config
|
682 + | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
683 + | .expect("the config must have a deserializer");
|
684 + |
|
685 + | let parsed = de.deserialize_streaming(&mut http_response);
|
686 + | let parsed = parsed.unwrap_or_else(|| {
|
687 + | let http_response =
|
688 + | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
689 + | de.deserialize_nonstreaming(&http_response)
|
690 + | });
|
691 + | let parsed = parsed
|
692 + | .expect("should be successful response")
|
693 + | .downcast::<crate::operation::operation_with_defaults::OperationWithDefaultsOutput>()
|
694 + | .unwrap();
|
695 + | ::pretty_assertions::assert_eq!(
|
696 + | parsed.default_string,
|
697 + | expected_output.default_string,
|
698 + | "Unexpected value for `default_string`"
|
699 + | );
|
700 + | ::pretty_assertions::assert_eq!(
|
701 + | parsed.default_boolean,
|
702 + | expected_output.default_boolean,
|
703 + | "Unexpected value for `default_boolean`"
|
704 + | );
|
705 + | ::pretty_assertions::assert_eq!(parsed.default_list, expected_output.default_list, "Unexpected value for `default_list`");
|
706 + | ::pretty_assertions::assert_eq!(
|
707 + | parsed.default_document_map,
|
708 + | expected_output.default_document_map,
|
709 + | "Unexpected value for `default_document_map`"
|
710 + | );
|
711 + | ::pretty_assertions::assert_eq!(
|
712 + | parsed.default_document_string,
|
713 + | expected_output.default_document_string,
|
714 + | "Unexpected value for `default_document_string`"
|
715 + | );
|
716 + | ::pretty_assertions::assert_eq!(
|
717 + | parsed.default_document_boolean,
|
718 + | expected_output.default_document_boolean,
|
719 + | "Unexpected value for `default_document_boolean`"
|
720 + | );
|
721 + | ::pretty_assertions::assert_eq!(
|
722 + | parsed.default_document_list,
|
723 + | expected_output.default_document_list,
|
724 + | "Unexpected value for `default_document_list`"
|
725 + | );
|
726 + | ::pretty_assertions::assert_eq!(
|
727 + | parsed.default_null_document,
|
728 + | expected_output.default_null_document,
|
729 + | "Unexpected value for `default_null_document`"
|
730 + | );
|
731 + | ::pretty_assertions::assert_eq!(
|
732 + | parsed.default_timestamp,
|
733 + | expected_output.default_timestamp,
|
734 + | "Unexpected value for `default_timestamp`"
|
735 + | );
|
736 + | ::pretty_assertions::assert_eq!(parsed.default_blob, expected_output.default_blob, "Unexpected value for `default_blob`");
|
737 + | ::pretty_assertions::assert_eq!(parsed.default_byte, expected_output.default_byte, "Unexpected value for `default_byte`");
|
738 + | ::pretty_assertions::assert_eq!(
|
739 + | parsed.default_short,
|
740 + | expected_output.default_short,
|
741 + | "Unexpected value for `default_short`"
|
742 + | );
|
743 + | ::pretty_assertions::assert_eq!(
|
744 + | parsed.default_integer,
|
745 + | expected_output.default_integer,
|
746 + | "Unexpected value for `default_integer`"
|
747 + | );
|
748 + | ::pretty_assertions::assert_eq!(parsed.default_long, expected_output.default_long, "Unexpected value for `default_long`");
|
749 + | assert!(
|
750 + | parsed.default_float.float_equals(&expected_output.default_float),
|
751 + | "Unexpected value for `default_float` {:?} vs. {:?}",
|
752 + | expected_output.default_float,
|
753 + | parsed.default_float
|
754 + | );
|
755 + | assert!(
|
756 + | parsed.default_double.float_equals(&expected_output.default_double),
|
757 + | "Unexpected value for `default_double` {:?} vs. {:?}",
|
758 + | expected_output.default_double,
|
759 + | parsed.default_double
|
760 + | );
|
761 + | ::pretty_assertions::assert_eq!(parsed.default_map, expected_output.default_map, "Unexpected value for `default_map`");
|
762 + | ::pretty_assertions::assert_eq!(parsed.default_enum, expected_output.default_enum, "Unexpected value for `default_enum`");
|
763 + | ::pretty_assertions::assert_eq!(
|
764 + | parsed.default_int_enum,
|
765 + | expected_output.default_int_enum,
|
766 + | "Unexpected value for `default_int_enum`"
|
767 + | );
|
768 + | ::pretty_assertions::assert_eq!(parsed.empty_string, expected_output.empty_string, "Unexpected value for `empty_string`");
|
769 + | ::pretty_assertions::assert_eq!(
|
770 + | parsed.false_boolean,
|
771 + | expected_output.false_boolean,
|
772 + | "Unexpected value for `false_boolean`"
|
773 + | );
|
774 + | ::pretty_assertions::assert_eq!(parsed.empty_blob, expected_output.empty_blob, "Unexpected value for `empty_blob`");
|
775 + | ::pretty_assertions::assert_eq!(parsed.zero_byte, expected_output.zero_byte, "Unexpected value for `zero_byte`");
|
776 + | ::pretty_assertions::assert_eq!(parsed.zero_short, expected_output.zero_short, "Unexpected value for `zero_short`");
|
777 + | ::pretty_assertions::assert_eq!(parsed.zero_integer, expected_output.zero_integer, "Unexpected value for `zero_integer`");
|
778 + | ::pretty_assertions::assert_eq!(parsed.zero_long, expected_output.zero_long, "Unexpected value for `zero_long`");
|
779 + | assert!(
|
780 + | parsed.zero_float.float_equals(&expected_output.zero_float),
|
781 + | "Unexpected value for `zero_float` {:?} vs. {:?}",
|
782 + | expected_output.zero_float,
|
783 + | parsed.zero_float
|
784 + | );
|
785 + | assert!(
|
786 + | parsed.zero_double.float_equals(&expected_output.zero_double),
|
787 + | "Unexpected value for `zero_double` {:?} vs. {:?}",
|
788 + | expected_output.zero_double,
|
789 + | parsed.zero_double
|
790 + | );
|
791 + | }
|
792 + | }
|
793 + |
|
794 + | /// Error type for the `OperationWithDefaultsError` operation.
|
795 + | #[non_exhaustive]
|
796 + | #[derive(::std::fmt::Debug)]
|
797 + | pub enum OperationWithDefaultsError {
|
798 + | /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
|
799 + | #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
|
800 + | variable wildcard pattern and check `.code()`:
|
801 + | \
|
802 + | `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
|
803 + | \
|
804 + | See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-OperationWithDefaultsError) for what information is available for the error.")]
|
805 + | Unhandled(crate::error::sealed_unhandled::Unhandled),
|
806 + | }
|
807 + | impl OperationWithDefaultsError {
|
808 + | /// Creates the `OperationWithDefaultsError::Unhandled` variant from any error type.
|
809 + | pub fn unhandled(
|
810 + | err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
|
811 + | ) -> Self {
|
812 + | Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
|
813 + | source: err.into(),
|
814 + | meta: ::std::default::Default::default(),
|
815 + | })
|
816 + | }
|
817 + |
|
818 + | /// Creates the `OperationWithDefaultsError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
|
819 + | pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
|
820 + | Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
|
821 + | source: err.clone().into(),
|
822 + | meta: err,
|
823 + | })
|
824 + | }
|
825 + | ///
|
826 + | /// Returns error metadata, which includes the error code, message,
|
827 + | /// request ID, and potentially additional information.
|
828 + | ///
|
829 + | pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
|
830 + | match self {
|
831 + | Self::Unhandled(e) => &e.meta,
|
832 + | }
|
833 + | }
|
834 + | }
|
835 + | impl ::std::error::Error for OperationWithDefaultsError {
|
836 + | fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
|
837 + | match self {
|
838 + | Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
|
839 + | }
|
840 + | }
|
841 + | }
|
842 + | impl ::std::fmt::Display for OperationWithDefaultsError {
|
843 + | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
844 + | match self {
|
845 + | Self::Unhandled(_inner) => {
|
846 + | if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
|
847 + | write!(f, "unhandled error ({code})")
|
848 + | } else {
|
849 + | f.write_str("unhandled error")
|
850 + | }
|
851 + | }
|
852 + | }
|
853 + | }
|
854 + | }
|
855 + | impl ::aws_smithy_types::retry::ProvideErrorKind for OperationWithDefaultsError {
|
856 + | fn code(&self) -> ::std::option::Option<&str> {
|
857 + | ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
|
858 + | }
|
859 + | fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
|
860 + | ::std::option::Option::None
|
861 + | }
|
862 + | }
|
863 + | impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for OperationWithDefaultsError {
|
864 + | fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
|
865 + | match self {
|
866 + | Self::Unhandled(_inner) => &_inner.meta,
|
867 + | }
|
868 + | }
|
869 + | }
|
870 + | impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for OperationWithDefaultsError {
|
871 + | fn create_unhandled_error(
|
872 + | source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
|
873 + | meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
|
874 + | ) -> Self {
|
875 + | Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
|
876 + | source,
|
877 + | meta: meta.unwrap_or_default(),
|
878 + | })
|
879 + | }
|
880 + | }
|
881 + |
|
882 + | pub use crate::operation::operation_with_defaults::_operation_with_defaults_output::OperationWithDefaultsOutput;
|
883 + |
|
884 + | pub use crate::operation::operation_with_defaults::_operation_with_defaults_input::OperationWithDefaultsInput;
|
885 + |
|
886 + | mod _operation_with_defaults_input;
|
887 + |
|
888 + | mod _operation_with_defaults_output;
|
889 + |
|
890 + | /// Builders
|
891 + | pub mod builders;
|