1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 2 | #[::pyo3::pyclass]
|
3 - | #[allow(missing_docs)] // documentation missing in model
|
4 - | #[derive(
|
5 - | ::std::clone::Clone,
|
6 - | ::std::cmp::Eq,
|
7 - | ::std::cmp::Ord,
|
8 - | ::std::cmp::PartialEq,
|
9 - | ::std::cmp::PartialOrd,
|
10 - | ::std::fmt::Debug,
|
11 - | ::std::hash::Hash,
|
12 - | )]
|
13 - | pub enum RequiredEnum {
|
14 - | #[allow(missing_docs)] // documentation missing in model
|
15 - | Bar,
|
16 - | #[allow(missing_docs)] // documentation missing in model
|
17 - | Baz,
|
18 - | #[allow(missing_docs)] // documentation missing in model
|
19 - | Foo,
|
20 - | }
|
21 - | pub(crate) mod required_enum_internal {
|
22 - | #[derive(Debug, PartialEq)]
|
23 - | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
24 - |
|
25 - | impl ::std::fmt::Display for ConstraintViolation {
|
26 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
27 - | write!(
|
28 - | f,
|
29 - | r#"Value provided for 'aws.protocoltests.json10#RequiredEnum' failed to satisfy constraint: Member must satisfy enum value set: [FOO, BAR, BAZ]"#
|
30 - | )
|
31 - | }
|
32 - | }
|
33 - |
|
34 - | impl ::std::error::Error for ConstraintViolation {}
|
35 - | }
|
36 - | impl ::std::convert::TryFrom<&str> for RequiredEnum {
|
37 - | type Error = crate::model::required_enum_internal::ConstraintViolation;
|
38 - | fn try_from(
|
39 - | s: &str,
|
40 - | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
41 - | match s {
|
42 - | "BAR" => Ok(RequiredEnum::Bar),
|
43 - | "BAZ" => Ok(RequiredEnum::Baz),
|
44 - | "FOO" => Ok(RequiredEnum::Foo),
|
45 - | _ => Err(crate::model::required_enum_internal::ConstraintViolation(
|
46 - | s.to_owned(),
|
47 - | )),
|
48 - | }
|
49 - | }
|
50 - | }
|
51 - | impl ::std::convert::TryFrom<::std::string::String> for RequiredEnum {
|
52 - | type Error = crate::model::required_enum_internal::ConstraintViolation;
|
53 - | fn try_from(
|
54 - | s: ::std::string::String,
|
55 - | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
56 - | {
|
57 - | s.as_str().try_into()
|
58 - | }
|
59 - | }
|
60 - | impl std::str::FromStr for RequiredEnum {
|
61 - | type Err = crate::model::required_enum_internal::ConstraintViolation;
|
62 - | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
63 - | Self::try_from(s)
|
64 - | }
|
65 - | }
|
66 - | impl RequiredEnum {
|
67 - | /// Returns the `&str` value of the enum member.
|
68 - | pub fn as_str(&self) -> &str {
|
69 - | match self {
|
70 - | RequiredEnum::Bar => "BAR",
|
71 - | RequiredEnum::Baz => "BAZ",
|
72 - | RequiredEnum::Foo => "FOO",
|
73 - | }
|
74 - | }
|
75 - | /// Returns all the `&str` representations of the enum members.
|
76 - | pub const fn values() -> &'static [&'static str] {
|
77 - | &["BAR", "BAZ", "FOO"]
|
78 - | }
|
79 - | }
|
80 - | impl ::std::convert::AsRef<str> for RequiredEnum {
|
81 - | fn as_ref(&self) -> &str {
|
82 - | self.as_str()
|
83 - | }
|
84 - | }
|
85 - | #[::pyo3::pymethods]
|
86 - | impl RequiredEnum {
|
87 - | #[getter]
|
88 - | pub fn name(&self) -> &str {
|
89 - | match self {
|
90 - | RequiredEnum::Bar => "Bar",
|
91 - | RequiredEnum::Baz => "Baz",
|
92 - | RequiredEnum::Foo => "Foo",
|
93 - | }
|
94 - | }
|
95 - | #[getter]
|
96 - | pub fn value(&self) -> &str {
|
97 - | self.as_str()
|
98 - | }
|
99 - | fn __repr__(&self) -> String {
|
100 - | self.as_str().to_owned()
|
101 - | }
|
102 - | fn __str__(&self) -> String {
|
103 - | self.as_str().to_owned()
|
104 - | }
|
105 - | }
|
106 - | impl crate::constrained::Constrained for RequiredEnum {
|
107 - | type Unconstrained = ::std::string::String;
|
108 - | }
|
109 - |
|
110 - | impl ::std::convert::From<::std::string::String>
|
111 - | for crate::constrained::MaybeConstrained<crate::model::RequiredEnum>
|
112 - | {
|
113 - | fn from(value: ::std::string::String) -> Self {
|
114 - | Self::Unconstrained(value)
|
115 - | }
|
116 - | }
|
117 - |
|
118 - | #[::pyo3::pyclass]
|
119 - | /// :param path str:
|
120 - | /// :param message str:
|
3 + | /// :param foo typing.Optional\[str\]:
|
121 4 | /// :rtype None:
|
122 - | /// Describes one specific validation failure for an input member.
|
5 + | #[allow(missing_docs)] // documentation missing in model
|
123 6 | #[derive(
|
124 7 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
125 8 | )]
|
126 - | pub struct ValidationExceptionField {
|
127 - | #[pyo3(get, set)]
|
128 - | /// :type str:
|
129 - | /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
|
130 - | pub path: ::std::string::String,
|
9 + | pub struct ComplexNestedErrorData {
|
131 10 | #[pyo3(get, set)]
|
132 - | /// :type str:
|
133 - | /// A detailed description of the validation failure.
|
134 - | pub message: ::std::string::String,
|
11 + | /// :type typing.Optional\[str\]:
|
12 + | #[allow(missing_docs)] // documentation missing in model
|
13 + | pub foo: ::std::option::Option<::std::string::String>,
|
135 14 | }
|
136 - | impl ValidationExceptionField {
|
137 - | /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
|
138 - | pub fn path(&self) -> &str {
|
139 - | use std::ops::Deref;
|
140 - | self.path.deref()
|
141 - | }
|
142 - | /// A detailed description of the validation failure.
|
143 - | pub fn message(&self) -> &str {
|
144 - | use std::ops::Deref;
|
145 - | self.message.deref()
|
15 + | impl ComplexNestedErrorData {
|
16 + | #[allow(missing_docs)] // documentation missing in model
|
17 + | pub fn foo(&self) -> ::std::option::Option<&str> {
|
18 + | self.foo.as_deref()
|
146 19 | }
|
147 20 | }
|
148 21 | #[allow(clippy::new_without_default)]
|
149 22 | #[allow(clippy::too_many_arguments)]
|
150 23 | #[::pyo3::pymethods]
|
151 - | impl ValidationExceptionField {
|
24 + | impl ComplexNestedErrorData {
|
152 25 | #[new]
|
153 - | pub fn new(path: ::std::string::String, message: ::std::string::String) -> Self {
|
154 - | Self { path, message }
|
26 + | pub fn new(foo: ::std::option::Option<::std::string::String>) -> Self {
|
27 + | Self { foo }
|
155 28 | }
|
156 29 | fn __repr__(&self) -> String {
|
157 30 | format!("{self:?}")
|
158 31 | }
|
159 32 | fn __str__(&self) -> String {
|
160 33 | format!("{self:?}")
|
161 34 | }
|
162 35 | }
|
163 - | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<ValidationExceptionField> {
|
36 + | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<ComplexNestedErrorData> {
|
164 37 | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
165 - | ob.extract::<ValidationExceptionField>().map(Box::new)
|
38 + | ob.extract::<ComplexNestedErrorData>().map(Box::new)
|
166 39 | }
|
167 40 | }
|
168 41 |
|
169 - | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<ValidationExceptionField> {
|
42 + | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<ComplexNestedErrorData> {
|
170 43 | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
171 44 | (*self).into_py(py)
|
172 45 | }
|
173 46 | }
|
174 - | impl ValidationExceptionField {
|
175 - | /// Creates a new builder-style object to manufacture [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
176 - | pub fn builder() -> crate::model::validation_exception_field::Builder {
|
177 - | crate::model::validation_exception_field::Builder::default()
|
47 + | impl ComplexNestedErrorData {
|
48 + | /// Creates a new builder-style object to manufacture [`ComplexNestedErrorData`](crate::model::ComplexNestedErrorData).
|
49 + | pub fn builder() -> crate::model::complex_nested_error_data::Builder {
|
50 + | crate::model::complex_nested_error_data::Builder::default()
|
178 51 | }
|
179 52 | }
|
180 53 |
|
181 - | #[::pyo3::pyclass]
|
182 - | /// :param greeting str:
|
183 - | /// :param language typing.Optional\[str\]:
|
184 - | /// :param farewell typing.Optional\[json_rpc10.model.Farewell\]:
|
185 - | /// :rtype None:
|
186 - | #[allow(missing_docs)] // documentation missing in model
|
187 - | #[derive(
|
188 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
189 - | )]
|
190 - | pub struct Dialog {
|
191 - | #[pyo3(get, set)]
|
192 - | /// :type typing.Optional\[str\]:
|
54 + | /// A union with a representative set of types for members.
|
55 + | #[derive(::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
56 + | pub enum MyUnion {
|
193 57 | #[allow(missing_docs)] // documentation missing in model
|
194 - | pub language: ::std::option::Option<::std::string::String>,
|
195 - | #[pyo3(get, set)]
|
196 - | /// :type str:
|
58 + | BlobValue(::aws_smithy_http_server_python::types::Blob),
|
197 59 | #[allow(missing_docs)] // documentation missing in model
|
198 - | pub greeting: ::std::string::String,
|
199 - | #[pyo3(get, set)]
|
200 - | /// :type typing.Optional\[json_rpc10.model.Farewell\]:
|
60 + | BooleanValue(bool),
|
201 61 | #[allow(missing_docs)] // documentation missing in model
|
202 - | pub farewell: ::std::option::Option<crate::model::Farewell>,
|
203 - | }
|
204 - | impl Dialog {
|
62 + | EnumValue(crate::model::FooEnum),
|
205 63 | #[allow(missing_docs)] // documentation missing in model
|
206 - | pub fn language(&self) -> ::std::option::Option<&str> {
|
207 - | self.language.as_deref()
|
208 - | }
|
64 + | IntEnumValue(i32),
|
209 65 | #[allow(missing_docs)] // documentation missing in model
|
210 - | pub fn greeting(&self) -> &str {
|
211 - | use std::ops::Deref;
|
212 - | self.greeting.deref()
|
213 - | }
|
66 + | ListValue(::std::vec::Vec<::std::string::String>),
|
214 67 | #[allow(missing_docs)] // documentation missing in model
|
215 - | pub fn farewell(&self) -> ::std::option::Option<&crate::model::Farewell> {
|
216 - | self.farewell.as_ref()
|
217 - | }
|
68 + | MapValue(::std::collections::HashMap<::std::string::String, ::std::string::String>),
|
69 + | #[allow(missing_docs)] // documentation missing in model
|
70 + | NumberValue(i32),
|
71 + | #[allow(missing_docs)] // documentation missing in model
|
72 + | StringValue(::std::string::String),
|
73 + | #[allow(missing_docs)] // documentation missing in model
|
74 + | StructureValue(crate::model::GreetingStruct),
|
75 + | #[allow(missing_docs)] // documentation missing in model
|
76 + | TimestampValue(::aws_smithy_http_server_python::types::DateTime),
|
218 77 | }
|
219 - | #[allow(clippy::new_without_default)]
|
220 - | #[allow(clippy::too_many_arguments)]
|
221 - | #[::pyo3::pymethods]
|
222 - | impl Dialog {
|
223 - | #[new]
|
224 - | pub fn new(
|
225 - | greeting: ::std::string::String,
|
226 - | language: ::std::option::Option<::std::string::String>,
|
227 - | farewell: ::std::option::Option<crate::model::Farewell>,
|
228 - | ) -> Self {
|
229 - | Self {
|
230 - | greeting,
|
231 - | language,
|
232 - | farewell,
|
78 + | impl MyUnion {
|
79 + | /// Tries to convert the enum instance into [`BlobValue`](crate::model::MyUnion::BlobValue), extracting the inner [`Blob`](::aws_smithy_http_server_python::types::Blob).
|
80 + | /// Returns `Err(&Self)` if it can't be converted.
|
81 + | pub fn as_blob_value(
|
82 + | &self,
|
83 + | ) -> ::std::result::Result<&::aws_smithy_http_server_python::types::Blob, &Self> {
|
84 + | if let MyUnion::BlobValue(val) = &self {
|
85 + | ::std::result::Result::Ok(val)
|
86 + | } else {
|
87 + | ::std::result::Result::Err(self)
|
233 88 | }
|
234 89 | }
|
235 - | fn __repr__(&self) -> String {
|
236 - | format!("{self:?}")
|
90 + | /// Returns true if this is a [`BlobValue`](crate::model::MyUnion::BlobValue).
|
91 + | pub fn is_blob_value(&self) -> bool {
|
92 + | self.as_blob_value().is_ok()
|
237 93 | }
|
238 - | fn __str__(&self) -> String {
|
239 - | format!("{self:?}")
|
94 + | /// Tries to convert the enum instance into [`BooleanValue`](crate::model::MyUnion::BooleanValue), extracting the inner [`bool`](bool).
|
95 + | /// Returns `Err(&Self)` if it can't be converted.
|
96 + | pub fn as_boolean_value(&self) -> ::std::result::Result<&bool, &Self> {
|
97 + | if let MyUnion::BooleanValue(val) = &self {
|
98 + | ::std::result::Result::Ok(val)
|
99 + | } else {
|
100 + | ::std::result::Result::Err(self)
|
101 + | }
|
240 102 | }
|
241 - | }
|
242 - | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<Dialog> {
|
243 - | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
244 - | ob.extract::<Dialog>().map(Box::new)
|
103 + | /// Returns true if this is a [`BooleanValue`](crate::model::MyUnion::BooleanValue).
|
104 + | pub fn is_boolean_value(&self) -> bool {
|
105 + | self.as_boolean_value().is_ok()
|
245 106 | }
|
246 - | }
|
247 - |
|
248 - | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<Dialog> {
|
249 - | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
250 - | (*self).into_py(py)
|
107 + | /// Tries to convert the enum instance into [`EnumValue`](crate::model::MyUnion::EnumValue), extracting the inner [`FooEnum`](crate::model::FooEnum).
|
108 + | /// Returns `Err(&Self)` if it can't be converted.
|
109 + | pub fn as_enum_value(&self) -> ::std::result::Result<&crate::model::FooEnum, &Self> {
|
110 + | if let MyUnion::EnumValue(val) = &self {
|
111 + | ::std::result::Result::Ok(val)
|
112 + | } else {
|
113 + | ::std::result::Result::Err(self)
|
114 + | }
|
251 115 | }
|
252 - | }
|
253 - | impl crate::constrained::Constrained for crate::model::Dialog {
|
254 - | type Unconstrained = crate::model::dialog_internal::Builder;
|
255 - | }
|
256 - | impl Dialog {
|
257 - | /// Creates a new builder-style object to manufacture [`Dialog`](crate::model::Dialog).
|
258 - | pub fn builder() -> crate::model::dialog::Builder {
|
259 - | crate::model::dialog::Builder::default()
|
116 + | /// Returns true if this is a [`EnumValue`](crate::model::MyUnion::EnumValue).
|
117 + | pub fn is_enum_value(&self) -> bool {
|
118 + | self.as_enum_value().is_ok()
|
260 119 | }
|
261 - | }
|
262 - |
|
263 - | #[::pyo3::pyclass]
|
264 - | /// :param phrase str:
|
265 - | /// :rtype None:
|
266 - | #[allow(missing_docs)] // documentation missing in model
|
267 - | #[derive(
|
268 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
269 - | )]
|
270 - | pub struct Farewell {
|
271 - | #[pyo3(get, set)]
|
272 - | /// :type str:
|
273 - | #[allow(missing_docs)] // documentation missing in model
|
274 - | pub phrase: ::std::string::String,
|
275 - | }
|
276 - | impl Farewell {
|
277 - | #[allow(missing_docs)] // documentation missing in model
|
278 - | pub fn phrase(&self) -> &str {
|
279 - | use std::ops::Deref;
|
280 - | self.phrase.deref()
|
120 + | /// Tries to convert the enum instance into [`IntEnumValue`](crate::model::MyUnion::IntEnumValue), extracting the inner [`i32`](i32).
|
121 + | /// Returns `Err(&Self)` if it can't be converted.
|
122 + | pub fn as_int_enum_value(&self) -> ::std::result::Result<&i32, &Self> {
|
123 + | if let MyUnion::IntEnumValue(val) = &self {
|
124 + | ::std::result::Result::Ok(val)
|
125 + | } else {
|
126 + | ::std::result::Result::Err(self)
|
127 + | }
|
281 128 | }
|
282 - | }
|
283 - | #[allow(clippy::new_without_default)]
|
284 - | #[allow(clippy::too_many_arguments)]
|
285 - | #[::pyo3::pymethods]
|
286 - | impl Farewell {
|
287 - | #[new]
|
288 - | pub fn new(phrase: ::std::string::String) -> Self {
|
289 - | Self { phrase }
|
129 + | /// Returns true if this is a [`IntEnumValue`](crate::model::MyUnion::IntEnumValue).
|
130 + | pub fn is_int_enum_value(&self) -> bool {
|
131 + | self.as_int_enum_value().is_ok()
|
290 132 | }
|
291 - | fn __repr__(&self) -> String {
|
292 - | format!("{self:?}")
|
133 + | /// Tries to convert the enum instance into [`ListValue`](crate::model::MyUnion::ListValue), extracting the inner [`Vec`](::std::vec::Vec).
|
134 + | /// Returns `Err(&Self)` if it can't be converted.
|
135 + | pub fn as_list_value(
|
136 + | &self,
|
137 + | ) -> ::std::result::Result<&::std::vec::Vec<::std::string::String>, &Self> {
|
138 + | if let MyUnion::ListValue(val) = &self {
|
139 + | ::std::result::Result::Ok(val)
|
140 + | } else {
|
141 + | ::std::result::Result::Err(self)
|
142 + | }
|
293 143 | }
|
294 - | fn __str__(&self) -> String {
|
295 - | format!("{self:?}")
|
144 + | /// Returns true if this is a [`ListValue`](crate::model::MyUnion::ListValue).
|
145 + | pub fn is_list_value(&self) -> bool {
|
146 + | self.as_list_value().is_ok()
|
296 147 | }
|
297 - | }
|
298 - | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<Farewell> {
|
299 - | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
300 - | ob.extract::<Farewell>().map(Box::new)
|
148 + | /// Tries to convert the enum instance into [`MapValue`](crate::model::MyUnion::MapValue), extracting the inner [`HashMap`](::std::collections::HashMap).
|
149 + | /// Returns `Err(&Self)` if it can't be converted.
|
150 + | pub fn as_map_value(
|
151 + | &self,
|
152 + | ) -> ::std::result::Result<
|
153 + | &::std::collections::HashMap<::std::string::String, ::std::string::String>,
|
154 + | &Self,
|
155 + | > {
|
156 + | if let MyUnion::MapValue(val) = &self {
|
157 + | ::std::result::Result::Ok(val)
|
158 + | } else {
|
159 + | ::std::result::Result::Err(self)
|
160 + | }
|
301 161 | }
|
302 - | }
|
303 - |
|
304 - | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<Farewell> {
|
305 - | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
306 - | (*self).into_py(py)
|
162 + | /// Returns true if this is a [`MapValue`](crate::model::MyUnion::MapValue).
|
163 + | pub fn is_map_value(&self) -> bool {
|
164 + | self.as_map_value().is_ok()
|
307 165 | }
|
308 - | }
|
309 - | impl crate::constrained::Constrained for crate::model::Farewell {
|
310 - | type Unconstrained = crate::model::farewell_internal::Builder;
|
311 - | }
|
312 - | impl Farewell {
|
313 - | /// Creates a new builder-style object to manufacture [`Farewell`](crate::model::Farewell).
|
314 - | pub fn builder() -> crate::model::farewell::Builder {
|
315 - | crate::model::farewell::Builder::default()
|
166 + | /// Tries to convert the enum instance into [`NumberValue`](crate::model::MyUnion::NumberValue), extracting the inner [`i32`](i32).
|
167 + | /// Returns `Err(&Self)` if it can't be converted.
|
168 + | pub fn as_number_value(&self) -> ::std::result::Result<&i32, &Self> {
|
169 + | if let MyUnion::NumberValue(val) = &self {
|
170 + | ::std::result::Result::Ok(val)
|
171 + | } else {
|
172 + | ::std::result::Result::Err(self)
|
173 + | }
|
316 174 | }
|
317 - | }
|
318 - |
|
319 - | #[::pyo3::pyclass]
|
320 - | /// :param dialog json_rpc10.model.Dialog:
|
321 - | /// :param dialog_list typing.List\[json_rpc10.model.Dialog\]:
|
322 - | /// :param dialog_map typing.Dict\[str, json_rpc10.model.Dialog\]:
|
323 - | /// :rtype None:
|
324 - | #[allow(missing_docs)] // documentation missing in model
|
325 - | #[derive(::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
326 - | pub struct TopLevel {
|
327 - | #[pyo3(get, set)]
|
328 - | /// :type json_rpc10.model.Dialog:
|
329 - | #[allow(missing_docs)] // documentation missing in model
|
330 - | pub dialog: crate::model::Dialog,
|
331 - | #[pyo3(get, set)]
|
332 - | /// :type typing.List\[json_rpc10.model.Dialog\]:
|
333 - | #[allow(missing_docs)] // documentation missing in model
|
334 - | pub dialog_list: ::std::vec::Vec<crate::model::Dialog>,
|
335 - | #[pyo3(get, set)]
|
336 - | /// :type typing.Dict\[str, json_rpc10.model.Dialog\]:
|
337 - | #[allow(missing_docs)] // documentation missing in model
|
338 - | pub dialog_map: ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
339 - | }
|
340 - | impl TopLevel {
|
341 - | #[allow(missing_docs)] // documentation missing in model
|
342 - | pub fn dialog(&self) -> &crate::model::Dialog {
|
343 - | &self.dialog
|
175 + | /// Returns true if this is a [`NumberValue`](crate::model::MyUnion::NumberValue).
|
176 + | pub fn is_number_value(&self) -> bool {
|
177 + | self.as_number_value().is_ok()
|
344 178 | }
|
345 - | #[allow(missing_docs)] // documentation missing in model
|
346 - | pub fn dialog_list(&self) -> &[crate::model::Dialog] {
|
347 - | use std::ops::Deref;
|
348 - | self.dialog_list.deref()
|
179 + | /// Tries to convert the enum instance into [`StringValue`](crate::model::MyUnion::StringValue), extracting the inner [`String`](::std::string::String).
|
180 + | /// Returns `Err(&Self)` if it can't be converted.
|
181 + | pub fn as_string_value(&self) -> ::std::result::Result<&::std::string::String, &Self> {
|
182 + | if let MyUnion::StringValue(val) = &self {
|
183 + | ::std::result::Result::Ok(val)
|
184 + | } else {
|
185 + | ::std::result::Result::Err(self)
|
186 + | }
|
349 187 | }
|
350 - | #[allow(missing_docs)] // documentation missing in model
|
351 - | pub fn dialog_map(
|
188 + | /// Returns true if this is a [`StringValue`](crate::model::MyUnion::StringValue).
|
189 + | pub fn is_string_value(&self) -> bool {
|
190 + | self.as_string_value().is_ok()
|
191 + | }
|
192 + | /// Tries to convert the enum instance into [`StructureValue`](crate::model::MyUnion::StructureValue), extracting the inner [`GreetingStruct`](crate::model::GreetingStruct).
|
193 + | /// Returns `Err(&Self)` if it can't be converted.
|
194 + | pub fn as_structure_value(
|
352 195 | &self,
|
353 - | ) -> &::std::collections::HashMap<::std::string::String, crate::model::Dialog> {
|
354 - | &self.dialog_map
|
196 + | ) -> ::std::result::Result<&crate::model::GreetingStruct, &Self> {
|
197 + | if let MyUnion::StructureValue(val) = &self {
|
198 + | ::std::result::Result::Ok(val)
|
199 + | } else {
|
200 + | ::std::result::Result::Err(self)
|
201 + | }
|
202 + | }
|
203 + | /// Returns true if this is a [`StructureValue`](crate::model::MyUnion::StructureValue).
|
204 + | pub fn is_structure_value(&self) -> bool {
|
205 + | self.as_structure_value().is_ok()
|
206 + | }
|
207 + | /// Tries to convert the enum instance into [`TimestampValue`](crate::model::MyUnion::TimestampValue), extracting the inner [`DateTime`](::aws_smithy_http_server_python::types::DateTime).
|
208 + | /// Returns `Err(&Self)` if it can't be converted.
|
209 + | pub fn as_timestamp_value(
|
210 + | &self,
|
211 + | ) -> ::std::result::Result<&::aws_smithy_http_server_python::types::DateTime, &Self> {
|
212 + | if let MyUnion::TimestampValue(val) = &self {
|
213 + | ::std::result::Result::Ok(val)
|
214 + | } else {
|
215 + | ::std::result::Result::Err(self)
|
216 + | }
|
217 + | }
|
218 + | /// Returns true if this is a [`TimestampValue`](crate::model::MyUnion::TimestampValue).
|
219 + | pub fn is_timestamp_value(&self) -> bool {
|
220 + | self.as_timestamp_value().is_ok()
|
355 221 | }
|
356 222 | }
|
357 - | #[allow(clippy::new_without_default)]
|
358 - | #[allow(clippy::too_many_arguments)]
|
223 + | #[pyo3::pyclass(name = "MyUnion")]
|
224 + | #[derive(::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
225 + | pub struct PyUnionMarkerMyUnion(pub MyUnion);
|
359 226 | #[::pyo3::pymethods]
|
360 - | impl TopLevel {
|
361 - | #[new]
|
362 - | pub fn new(
|
363 - | dialog: crate::model::Dialog,
|
364 - | dialog_list: ::std::vec::Vec<crate::model::Dialog>,
|
365 - | dialog_map: ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
366 - | ) -> Self {
|
367 - | Self {
|
368 - | dialog,
|
369 - | dialog_list,
|
370 - | dialog_map,
|
227 + | impl PyUnionMarkerMyUnion {
|
228 + | #[staticmethod]
|
229 + | /// Creates a new union instance of [`BlobValue`](crate::model::MyUnion::BlobValue)
|
230 + | /// :param data json_rpc10.types.Blob:
|
231 + | /// :rtype MyUnion:
|
232 + | pub fn blob_value(data: ::aws_smithy_http_server_python::types::Blob) -> Self {
|
233 + | Self(MyUnion::BlobValue(data))
|
234 + | }
|
235 + | /// Tries to convert the enum instance into [`BlobValue`](crate::model::MyUnion::BlobValue), extracting the inner [`Blob`](::aws_smithy_http_server_python::types::Blob).
|
236 + | /// :rtype json_rpc10.types.Blob:
|
237 + | pub fn as_blob_value(&self) -> ::pyo3::PyResult<::aws_smithy_http_server_python::types::Blob> {
|
238 + | match self.0.as_blob_value() {
|
239 + | Ok(variant) => Ok(variant.clone()),
|
240 + | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
241 + | r"MyUnion variant is not of type json_rpc10.types.Blob",
|
242 + | )),
|
371 243 | }
|
372 244 | }
|
373 - | fn __repr__(&self) -> String {
|
374 - | format!("{self:?}")
|
245 + | /// Returns true if this is a [`BlobValue`](crate::model::MyUnion::BlobValue).
|
246 + | /// :rtype bool:
|
247 + | pub fn is_blob_value(&self) -> bool {
|
248 + | self.0.is_blob_value()
|
375 249 | }
|
376 - | fn __str__(&self) -> String {
|
377 - | format!("{self:?}")
|
250 + | #[staticmethod]
|
251 + | /// Creates a new union instance of [`BooleanValue`](crate::model::MyUnion::BooleanValue)
|
252 + | /// :param data bool:
|
253 + | /// :rtype MyUnion:
|
254 + | pub fn boolean_value(data: bool) -> Self {
|
255 + | Self(MyUnion::BooleanValue(data))
|
378 256 | }
|
379 - | }
|
380 - | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<TopLevel> {
|
381 - | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
382 - | ob.extract::<TopLevel>().map(Box::new)
|
257 + | /// Tries to convert the enum instance into [`BooleanValue`](crate::model::MyUnion::BooleanValue), extracting the inner [`bool`](bool).
|
258 + | /// :rtype bool:
|
259 + | pub fn as_boolean_value(&self) -> ::pyo3::PyResult<bool> {
|
260 + | match self.0.as_boolean_value() {
|
261 + | Ok(variant) => Ok(*variant),
|
262 + | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
263 + | r"MyUnion variant is not of type bool",
|
264 + | )),
|
265 + | }
|
383 266 | }
|
384 - | }
|
385 - |
|
386 - | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<TopLevel> {
|
387 - | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
388 - | (*self).into_py(py)
|
267 + | /// Returns true if this is a [`BooleanValue`](crate::model::MyUnion::BooleanValue).
|
268 + | /// :rtype bool:
|
269 + | pub fn is_boolean_value(&self) -> bool {
|
270 + | self.0.is_boolean_value()
|
389 271 | }
|
390 - | }
|
391 - | impl crate::constrained::Constrained for crate::model::TopLevel {
|
392 - | type Unconstrained = crate::model::top_level_internal::Builder;
|
393 - | }
|
394 - | impl TopLevel {
|
395 - | /// Creates a new builder-style object to manufacture [`TopLevel`](crate::model::TopLevel).
|
396 - | pub fn builder() -> crate::model::top_level::Builder {
|
397 - | crate::model::top_level::Builder::default()
|
272 + | #[staticmethod]
|
273 + | /// Creates a new union instance of [`EnumValue`](crate::model::MyUnion::EnumValue)
|
274 + | /// :param data json_rpc10.model.FooEnum:
|
275 + | /// :rtype MyUnion:
|
276 + | pub fn enum_value(data: crate::model::FooEnum) -> Self {
|
277 + | Self(MyUnion::EnumValue(data))
|
398 278 | }
|
399 - | }
|
400 - |
|
401 - | #[::pyo3::pyclass]
|
402 - | #[allow(missing_docs)] // documentation missing in model
|
403 - | #[derive(
|
404 - | ::std::clone::Clone,
|
405 - | ::std::cmp::Eq,
|
406 - | ::std::cmp::Ord,
|
407 - | ::std::cmp::PartialEq,
|
408 - | ::std::cmp::PartialOrd,
|
409 - | ::std::fmt::Debug,
|
410 - | ::std::hash::Hash,
|
411 - | )]
|
412 - | pub enum TestEnum {
|
413 - | #[allow(missing_docs)] // documentation missing in model
|
414 - | Bar,
|
415 - | #[allow(missing_docs)] // documentation missing in model
|
416 - | Baz,
|
417 - | #[allow(missing_docs)] // documentation missing in model
|
418 - | Foo,
|
419 - | }
|
420 - | pub(crate) mod test_enum_internal {
|
421 - | #[derive(Debug, PartialEq)]
|
422 - | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
423 - |
|
424 - | impl ::std::fmt::Display for ConstraintViolation {
|
425 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
426 - | write!(
|
427 - | f,
|
428 - | r#"Value provided for 'aws.protocoltests.json10#TestEnum' failed to satisfy constraint: Member must satisfy enum value set: [FOO, BAR, BAZ]"#
|
429 - | )
|
279 + | /// Tries to convert the enum instance into [`EnumValue`](crate::model::MyUnion::EnumValue), extracting the inner [`FooEnum`](crate::model::FooEnum).
|
280 + | /// :rtype json_rpc10.model.FooEnum:
|
281 + | pub fn as_enum_value(&self) -> ::pyo3::PyResult<crate::model::FooEnum> {
|
282 + | match self.0.as_enum_value() {
|
283 + | Ok(variant) => Ok(variant.clone()),
|
284 + | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
285 + | r"MyUnion variant is not of type json_rpc10.model.FooEnum",
|
286 + | )),
|
430 287 | }
|
431 288 | }
|
432 - |
|
433 - | impl ::std::error::Error for ConstraintViolation {}
|
434 - | impl ConstraintViolation {
|
435 - | pub(crate) fn as_validation_exception_field(
|
436 - | self,
|
437 - | path: ::std::string::String,
|
438 - | ) -> crate::model::ValidationExceptionField {
|
439 - | crate::model::ValidationExceptionField {
|
440 - | message: format!(
|
441 - | r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [FOO, BAR, BAZ]"#,
|
442 - | &path
|
443 - | ),
|
444 - | path,
|
445 - | }
|
289 + | /// Returns true if this is a [`EnumValue`](crate::model::MyUnion::EnumValue).
|
290 + | /// :rtype bool:
|
291 + | pub fn is_enum_value(&self) -> bool {
|
292 + | self.0.is_enum_value()
|
293 + | }
|
294 + | #[staticmethod]
|
295 + | /// Creates a new union instance of [`IntEnumValue`](crate::model::MyUnion::IntEnumValue)
|
296 + | /// :param data int:
|
297 + | /// :rtype MyUnion:
|
298 + | pub fn int_enum_value(data: i32) -> Self {
|
299 + | Self(MyUnion::IntEnumValue(data))
|
300 + | }
|
301 + | /// Tries to convert the enum instance into [`IntEnumValue`](crate::model::MyUnion::IntEnumValue), extracting the inner [`i32`](i32).
|
302 + | /// :rtype int:
|
303 + | pub fn as_int_enum_value(&self) -> ::pyo3::PyResult<i32> {
|
304 + | match self.0.as_int_enum_value() {
|
305 + | Ok(variant) => Ok(*variant),
|
306 + | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
307 + | r"MyUnion variant is not of type int",
|
308 + | )),
|
446 309 | }
|
447 310 | }
|
448 - | }
|
449 - | impl ::std::convert::TryFrom<&str> for TestEnum {
|
450 - | type Error = crate::model::test_enum_internal::ConstraintViolation;
|
451 - | fn try_from(
|
452 - | s: &str,
|
453 - | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
454 - | match s {
|
455 - | "BAR" => Ok(TestEnum::Bar),
|
456 - | "BAZ" => Ok(TestEnum::Baz),
|
457 - | "FOO" => Ok(TestEnum::Foo),
|
458 - | _ => Err(crate::model::test_enum_internal::ConstraintViolation(
|
459 - | s.to_owned(),
|
311 + | /// Returns true if this is a [`IntEnumValue`](crate::model::MyUnion::IntEnumValue).
|
312 + | /// :rtype bool:
|
313 + | pub fn is_int_enum_value(&self) -> bool {
|
314 + | self.0.is_int_enum_value()
|
315 + | }
|
316 + | #[staticmethod]
|
317 + | /// Creates a new union instance of [`ListValue`](crate::model::MyUnion::ListValue)
|
318 + | /// :param data typing.List\[str\]:
|
319 + | /// :rtype MyUnion:
|
320 + | pub fn list_value(data: ::std::vec::Vec<::std::string::String>) -> Self {
|
321 + | Self(MyUnion::ListValue(data))
|
322 + | }
|
323 + | /// Tries to convert the enum instance into [`ListValue`](crate::model::MyUnion::ListValue), extracting the inner [`Vec`](::std::vec::Vec).
|
324 + | /// :rtype typing.List\[str\]:
|
325 + | pub fn as_list_value(&self) -> ::pyo3::PyResult<::std::vec::Vec<::std::string::String>> {
|
326 + | match self.0.as_list_value() {
|
327 + | Ok(variant) => Ok(variant.clone()),
|
328 + | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
329 + | r"MyUnion variant is not of type typing.List\[str\]",
|
460 330 | )),
|
461 331 | }
|
462 332 | }
|
463 - | }
|
464 - | impl ::std::convert::TryFrom<::std::string::String> for TestEnum {
|
465 - | type Error = crate::model::test_enum_internal::ConstraintViolation;
|
466 - | fn try_from(
|
467 - | s: ::std::string::String,
|
468 - | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
469 - | {
|
470 - | s.as_str().try_into()
|
333 + | /// Returns true if this is a [`ListValue`](crate::model::MyUnion::ListValue).
|
334 + | /// :rtype bool:
|
335 + | pub fn is_list_value(&self) -> bool {
|
336 + | self.0.is_list_value()
|
471 337 | }
|
472 - | }
|
473 - | impl std::str::FromStr for TestEnum {
|
474 - | type Err = crate::model::test_enum_internal::ConstraintViolation;
|
475 - | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
476 - | Self::try_from(s)
|
338 + | #[staticmethod]
|
339 + | /// Creates a new union instance of [`MapValue`](crate::model::MyUnion::MapValue)
|
340 + | /// :param data typing.Dict\[str, str\]:
|
341 + | /// :rtype MyUnion:
|
342 + | pub fn map_value(
|
343 + | data: ::std::collections::HashMap<::std::string::String, ::std::string::String>,
|
344 + | ) -> Self {
|
345 + | Self(MyUnion::MapValue(data))
|
477 346 | }
|
478 - | }
|
479 - | impl TestEnum {
|
480 - | /// Returns the `&str` value of the enum member.
|
481 - | pub fn as_str(&self) -> &str {
|
482 - | match self {
|
483 - | TestEnum::Bar => "BAR",
|
484 - | TestEnum::Baz => "BAZ",
|
485 - | TestEnum::Foo => "FOO",
|
347 + | /// Tries to convert the enum instance into [`MapValue`](crate::model::MyUnion::MapValue), extracting the inner [`HashMap`](::std::collections::HashMap).
|
348 + | /// :rtype typing.Dict\[str, str\]:
|
349 + | pub fn as_map_value(
|
350 + | &self,
|
351 + | ) -> ::pyo3::PyResult<::std::collections::HashMap<::std::string::String, ::std::string::String>>
|
352 + | {
|
353 + | match self.0.as_map_value() {
|
354 + | Ok(variant) => Ok(variant.clone()),
|
355 + | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
356 + | r"MyUnion variant is not of type typing.Dict\[str, str\]",
|
357 + | )),
|
486 358 | }
|
487 359 | }
|
488 - | /// Returns all the `&str` representations of the enum members.
|
489 - | pub const fn values() -> &'static [&'static str] {
|
490 - | &["BAR", "BAZ", "FOO"]
|
360 + | /// Returns true if this is a [`MapValue`](crate::model::MyUnion::MapValue).
|
361 + | /// :rtype bool:
|
362 + | pub fn is_map_value(&self) -> bool {
|
363 + | self.0.is_map_value()
|
491 364 | }
|
492 - | }
|
493 - | impl ::std::convert::AsRef<str> for TestEnum {
|
494 - | fn as_ref(&self) -> &str {
|
495 - | self.as_str()
|
365 + | #[staticmethod]
|
366 + | /// Creates a new union instance of [`NumberValue`](crate::model::MyUnion::NumberValue)
|
367 + | /// :param data int:
|
368 + | /// :rtype MyUnion:
|
369 + | pub fn number_value(data: i32) -> Self {
|
370 + | Self(MyUnion::NumberValue(data))
|
496 371 | }
|
497 - | }
|
498 - | #[::pyo3::pymethods]
|
499 - | impl TestEnum {
|
500 - | #[getter]
|
501 - | pub fn name(&self) -> &str {
|
502 - | match self {
|
503 - | TestEnum::Bar => "Bar",
|
504 - | TestEnum::Baz => "Baz",
|
505 - | TestEnum::Foo => "Foo",
|
372 + | /// Tries to convert the enum instance into [`NumberValue`](crate::model::MyUnion::NumberValue), extracting the inner [`i32`](i32).
|
373 + | /// :rtype int:
|
374 + | pub fn as_number_value(&self) -> ::pyo3::PyResult<i32> {
|
375 + | match self.0.as_number_value() {
|
376 + | Ok(variant) => Ok(*variant),
|
377 + | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
378 + | r"MyUnion variant is not of type int",
|
379 + | )),
|
506 380 | }
|
507 381 | }
|
508 - | #[getter]
|
509 - | pub fn value(&self) -> &str {
|
510 - | self.as_str()
|
382 + | /// Returns true if this is a [`NumberValue`](crate::model::MyUnion::NumberValue).
|
383 + | /// :rtype bool:
|
384 + | pub fn is_number_value(&self) -> bool {
|
385 + | self.0.is_number_value()
|
386 + | }
|
387 + | #[staticmethod]
|
388 + | /// Creates a new union instance of [`StringValue`](crate::model::MyUnion::StringValue)
|
389 + | /// :param data str:
|
390 + | /// :rtype MyUnion:
|
391 + | pub fn string_value(data: ::std::string::String) -> Self {
|
392 + | Self(MyUnion::StringValue(data))
|
511 393 | }
|
512 - | fn __repr__(&self) -> String {
|
513 - | self.as_str().to_owned()
|
394 + | /// Tries to convert the enum instance into [`StringValue`](crate::model::MyUnion::StringValue), extracting the inner [`String`](::std::string::String).
|
395 + | /// :rtype str:
|
396 + | pub fn as_string_value(&self) -> ::pyo3::PyResult<::std::string::String> {
|
397 + | match self.0.as_string_value() {
|
398 + | Ok(variant) => Ok(variant.clone()),
|
399 + | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
400 + | r"MyUnion variant is not of type str",
|
401 + | )),
|
402 + | }
|
514 403 | }
|
515 - | fn __str__(&self) -> String {
|
516 - | self.as_str().to_owned()
|
404 + | /// Returns true if this is a [`StringValue`](crate::model::MyUnion::StringValue).
|
405 + | /// :rtype bool:
|
406 + | pub fn is_string_value(&self) -> bool {
|
407 + | self.0.is_string_value()
|
517 408 | }
|
518 - | }
|
519 - | impl crate::constrained::Constrained for TestEnum {
|
520 - | type Unconstrained = ::std::string::String;
|
521 - | }
|
522 - |
|
523 - | impl ::std::convert::From<::std::string::String>
|
524 - | for crate::constrained::MaybeConstrained<crate::model::TestEnum>
|
525 - | {
|
526 - | fn from(value: ::std::string::String) -> Self {
|
527 - | Self::Unconstrained(value)
|
409 + | #[staticmethod]
|
410 + | /// Creates a new union instance of [`StructureValue`](crate::model::MyUnion::StructureValue)
|
411 + | /// :param data json_rpc10.model.GreetingStruct:
|
412 + | /// :rtype MyUnion:
|
413 + | pub fn structure_value(data: crate::model::GreetingStruct) -> Self {
|
414 + | Self(MyUnion::StructureValue(data))
|
528 415 | }
|
529 - | }
|
530 - |
|
531 - | #[::pyo3::pyclass]
|
532 - | /// :param member int:
|
533 - | /// :rtype None:
|
534 - | #[allow(missing_docs)] // documentation missing in model
|
535 - | #[derive(
|
536 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
537 - | )]
|
538 - | pub struct ClientOptionalDefaults {
|
539 - | #[pyo3(get, set)]
|
540 - | /// :type int:
|
541 - | #[allow(missing_docs)] // documentation missing in model
|
542 - | pub member: i32,
|
543 - | }
|
544 - | impl ClientOptionalDefaults {
|
545 - | #[allow(missing_docs)] // documentation missing in model
|
546 - | pub fn member(&self) -> i32 {
|
547 - | self.member
|
416 + | /// Tries to convert the enum instance into [`StructureValue`](crate::model::MyUnion::StructureValue), extracting the inner [`GreetingStruct`](crate::model::GreetingStruct).
|
417 + | /// :rtype json_rpc10.model.GreetingStruct:
|
418 + | pub fn as_structure_value(&self) -> ::pyo3::PyResult<crate::model::GreetingStruct> {
|
419 + | match self.0.as_structure_value() {
|
420 + | Ok(variant) => Ok(variant.clone()),
|
421 + | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
422 + | r"MyUnion variant is not of type json_rpc10.model.GreetingStruct",
|
423 + | )),
|
424 + | }
|
548 425 | }
|
549 - | }
|
550 - | #[allow(clippy::new_without_default)]
|
551 - | #[allow(clippy::too_many_arguments)]
|
552 - | #[::pyo3::pymethods]
|
553 - | impl ClientOptionalDefaults {
|
554 - | #[new]
|
555 - | pub fn new(member: i32) -> Self {
|
556 - | Self { member }
|
426 + | /// Returns true if this is a [`StructureValue`](crate::model::MyUnion::StructureValue).
|
427 + | /// :rtype bool:
|
428 + | pub fn is_structure_value(&self) -> bool {
|
429 + | self.0.is_structure_value()
|
557 430 | }
|
558 - | fn __repr__(&self) -> String {
|
559 - | format!("{self:?}")
|
431 + | #[staticmethod]
|
432 + | /// Creates a new union instance of [`TimestampValue`](crate::model::MyUnion::TimestampValue)
|
433 + | /// :param data json_rpc10.types.DateTime:
|
434 + | /// :rtype MyUnion:
|
435 + | pub fn timestamp_value(data: ::aws_smithy_http_server_python::types::DateTime) -> Self {
|
436 + | Self(MyUnion::TimestampValue(data))
|
560 437 | }
|
561 - | fn __str__(&self) -> String {
|
562 - | format!("{self:?}")
|
438 + | /// Tries to convert the enum instance into [`TimestampValue`](crate::model::MyUnion::TimestampValue), extracting the inner [`DateTime`](::aws_smithy_http_server_python::types::DateTime).
|
439 + | /// :rtype json_rpc10.types.DateTime:
|
440 + | pub fn as_timestamp_value(
|
441 + | &self,
|
442 + | ) -> ::pyo3::PyResult<::aws_smithy_http_server_python::types::DateTime> {
|
443 + | match self.0.as_timestamp_value() {
|
444 + | Ok(variant) => Ok(variant.clone()),
|
445 + | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
446 + | r"MyUnion variant is not of type json_rpc10.types.DateTime",
|
447 + | )),
|
448 + | }
|
563 449 | }
|
564 - | }
|
565 - | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<ClientOptionalDefaults> {
|
566 - | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
567 - | ob.extract::<ClientOptionalDefaults>().map(Box::new)
|
450 + | /// Returns true if this is a [`TimestampValue`](crate::model::MyUnion::TimestampValue).
|
451 + | /// :rtype bool:
|
452 + | pub fn is_timestamp_value(&self) -> bool {
|
453 + | self.0.is_timestamp_value()
|
568 454 | }
|
569 455 | }
|
570 - |
|
571 - | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<ClientOptionalDefaults> {
|
456 + | impl ::pyo3::IntoPy<::pyo3::PyObject> for MyUnion {
|
572 457 | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
573 - | (*self).into_py(py)
|
458 + | PyUnionMarkerMyUnion(self).into_py(py)
|
574 459 | }
|
575 460 | }
|
576 - | impl crate::constrained::Constrained for crate::model::ClientOptionalDefaults {
|
577 - | type Unconstrained = crate::model::client_optional_defaults_internal::Builder;
|
578 - | }
|
579 - | impl ClientOptionalDefaults {
|
580 - | /// Creates a new builder-style object to manufacture [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
581 - | pub fn builder() -> crate::model::client_optional_defaults::Builder {
|
582 - | crate::model::client_optional_defaults::Builder::default()
|
461 + | impl<'source> ::pyo3::FromPyObject<'source> for MyUnion {
|
462 + | fn extract(obj: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
463 + | let data: PyUnionMarkerMyUnion = obj.extract()?;
|
464 + | Ok(data.0)
|
583 465 | }
|
584 466 | }
|
585 467 |
|
586 468 | #[::pyo3::pyclass]
|
587 469 | /// :param default_string str:
|
588 470 | /// :param default_boolean bool:
|
589 471 | /// :param default_list typing.List\[str\]:
|
590 472 | /// :param default_document_map json_rpc10.types.Document:
|
591 473 | /// :param default_document_string json_rpc10.types.Document:
|
592 474 | /// :param default_document_boolean json_rpc10.types.Document:
|
940 822 | impl crate::constrained::Constrained for crate::model::Defaults {
|
941 823 | type Unconstrained = crate::model::defaults_internal::Builder;
|
942 824 | }
|
943 825 | impl Defaults {
|
944 826 | /// Creates a new builder-style object to manufacture [`Defaults`](crate::model::Defaults).
|
945 827 | pub fn builder() -> crate::model::defaults::Builder {
|
946 828 | crate::model::defaults::Builder::default()
|
947 829 | }
|
948 830 | }
|
949 831 |
|
950 - | /// A union with a representative set of types for members.
|
951 - | #[derive(::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
952 - | pub enum MyUnion {
|
953 - | #[allow(missing_docs)] // documentation missing in model
|
954 - | BlobValue(::aws_smithy_http_server_python::types::Blob),
|
955 - | #[allow(missing_docs)] // documentation missing in model
|
956 - | BooleanValue(bool),
|
957 - | #[allow(missing_docs)] // documentation missing in model
|
958 - | EnumValue(crate::model::FooEnum),
|
959 - | #[allow(missing_docs)] // documentation missing in model
|
960 - | IntEnumValue(i32),
|
961 - | #[allow(missing_docs)] // documentation missing in model
|
962 - | ListValue(::std::vec::Vec<::std::string::String>),
|
963 - | #[allow(missing_docs)] // documentation missing in model
|
964 - | MapValue(::std::collections::HashMap<::std::string::String, ::std::string::String>),
|
965 - | #[allow(missing_docs)] // documentation missing in model
|
966 - | NumberValue(i32),
|
967 - | #[allow(missing_docs)] // documentation missing in model
|
968 - | StringValue(::std::string::String),
|
969 - | #[allow(missing_docs)] // documentation missing in model
|
970 - | StructureValue(crate::model::GreetingStruct),
|
832 + | #[::pyo3::pyclass]
|
833 + | /// :param member int:
|
834 + | /// :rtype None:
|
835 + | #[allow(missing_docs)] // documentation missing in model
|
836 + | #[derive(
|
837 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
838 + | )]
|
839 + | pub struct ClientOptionalDefaults {
|
840 + | #[pyo3(get, set)]
|
841 + | /// :type int:
|
971 842 | #[allow(missing_docs)] // documentation missing in model
|
972 - | TimestampValue(::aws_smithy_http_server_python::types::DateTime),
|
843 + | pub member: i32,
|
973 844 | }
|
974 - | impl MyUnion {
|
975 - | /// Tries to convert the enum instance into [`BlobValue`](crate::model::MyUnion::BlobValue), extracting the inner [`Blob`](::aws_smithy_http_server_python::types::Blob).
|
976 - | /// Returns `Err(&Self)` if it can't be converted.
|
977 - | pub fn as_blob_value(
|
978 - | &self,
|
979 - | ) -> ::std::result::Result<&::aws_smithy_http_server_python::types::Blob, &Self> {
|
980 - | if let MyUnion::BlobValue(val) = &self {
|
981 - | ::std::result::Result::Ok(val)
|
982 - | } else {
|
983 - | ::std::result::Result::Err(self)
|
984 - | }
|
985 - | }
|
986 - | /// Returns true if this is a [`BlobValue`](crate::model::MyUnion::BlobValue).
|
987 - | pub fn is_blob_value(&self) -> bool {
|
988 - | self.as_blob_value().is_ok()
|
989 - | }
|
990 - | /// Tries to convert the enum instance into [`BooleanValue`](crate::model::MyUnion::BooleanValue), extracting the inner [`bool`](bool).
|
991 - | /// Returns `Err(&Self)` if it can't be converted.
|
992 - | pub fn as_boolean_value(&self) -> ::std::result::Result<&bool, &Self> {
|
993 - | if let MyUnion::BooleanValue(val) = &self {
|
994 - | ::std::result::Result::Ok(val)
|
995 - | } else {
|
996 - | ::std::result::Result::Err(self)
|
997 - | }
|
998 - | }
|
999 - | /// Returns true if this is a [`BooleanValue`](crate::model::MyUnion::BooleanValue).
|
1000 - | pub fn is_boolean_value(&self) -> bool {
|
1001 - | self.as_boolean_value().is_ok()
|
1002 - | }
|
1003 - | /// Tries to convert the enum instance into [`EnumValue`](crate::model::MyUnion::EnumValue), extracting the inner [`FooEnum`](crate::model::FooEnum).
|
1004 - | /// Returns `Err(&Self)` if it can't be converted.
|
1005 - | pub fn as_enum_value(&self) -> ::std::result::Result<&crate::model::FooEnum, &Self> {
|
1006 - | if let MyUnion::EnumValue(val) = &self {
|
1007 - | ::std::result::Result::Ok(val)
|
1008 - | } else {
|
1009 - | ::std::result::Result::Err(self)
|
1010 - | }
|
1011 - | }
|
1012 - | /// Returns true if this is a [`EnumValue`](crate::model::MyUnion::EnumValue).
|
1013 - | pub fn is_enum_value(&self) -> bool {
|
1014 - | self.as_enum_value().is_ok()
|
1015 - | }
|
1016 - | /// Tries to convert the enum instance into [`IntEnumValue`](crate::model::MyUnion::IntEnumValue), extracting the inner [`i32`](i32).
|
1017 - | /// Returns `Err(&Self)` if it can't be converted.
|
1018 - | pub fn as_int_enum_value(&self) -> ::std::result::Result<&i32, &Self> {
|
1019 - | if let MyUnion::IntEnumValue(val) = &self {
|
1020 - | ::std::result::Result::Ok(val)
|
1021 - | } else {
|
1022 - | ::std::result::Result::Err(self)
|
1023 - | }
|
1024 - | }
|
1025 - | /// Returns true if this is a [`IntEnumValue`](crate::model::MyUnion::IntEnumValue).
|
1026 - | pub fn is_int_enum_value(&self) -> bool {
|
1027 - | self.as_int_enum_value().is_ok()
|
1028 - | }
|
1029 - | /// Tries to convert the enum instance into [`ListValue`](crate::model::MyUnion::ListValue), extracting the inner [`Vec`](::std::vec::Vec).
|
1030 - | /// Returns `Err(&Self)` if it can't be converted.
|
1031 - | pub fn as_list_value(
|
1032 - | &self,
|
1033 - | ) -> ::std::result::Result<&::std::vec::Vec<::std::string::String>, &Self> {
|
1034 - | if let MyUnion::ListValue(val) = &self {
|
1035 - | ::std::result::Result::Ok(val)
|
1036 - | } else {
|
1037 - | ::std::result::Result::Err(self)
|
1038 - | }
|
1039 - | }
|
1040 - | /// Returns true if this is a [`ListValue`](crate::model::MyUnion::ListValue).
|
1041 - | pub fn is_list_value(&self) -> bool {
|
1042 - | self.as_list_value().is_ok()
|
1043 - | }
|
1044 - | /// Tries to convert the enum instance into [`MapValue`](crate::model::MyUnion::MapValue), extracting the inner [`HashMap`](::std::collections::HashMap).
|
1045 - | /// Returns `Err(&Self)` if it can't be converted.
|
1046 - | pub fn as_map_value(
|
1047 - | &self,
|
1048 - | ) -> ::std::result::Result<
|
1049 - | &::std::collections::HashMap<::std::string::String, ::std::string::String>,
|
1050 - | &Self,
|
1051 - | > {
|
1052 - | if let MyUnion::MapValue(val) = &self {
|
1053 - | ::std::result::Result::Ok(val)
|
1054 - | } else {
|
1055 - | ::std::result::Result::Err(self)
|
1056 - | }
|
1057 - | }
|
1058 - | /// Returns true if this is a [`MapValue`](crate::model::MyUnion::MapValue).
|
1059 - | pub fn is_map_value(&self) -> bool {
|
1060 - | self.as_map_value().is_ok()
|
845 + | impl ClientOptionalDefaults {
|
846 + | #[allow(missing_docs)] // documentation missing in model
|
847 + | pub fn member(&self) -> i32 {
|
848 + | self.member
|
1061 849 | }
|
1062 - | /// Tries to convert the enum instance into [`NumberValue`](crate::model::MyUnion::NumberValue), extracting the inner [`i32`](i32).
|
1063 - | /// Returns `Err(&Self)` if it can't be converted.
|
1064 - | pub fn as_number_value(&self) -> ::std::result::Result<&i32, &Self> {
|
1065 - | if let MyUnion::NumberValue(val) = &self {
|
1066 - | ::std::result::Result::Ok(val)
|
1067 - | } else {
|
1068 - | ::std::result::Result::Err(self)
|
1069 - | }
|
850 + | }
|
851 + | #[allow(clippy::new_without_default)]
|
852 + | #[allow(clippy::too_many_arguments)]
|
853 + | #[::pyo3::pymethods]
|
854 + | impl ClientOptionalDefaults {
|
855 + | #[new]
|
856 + | pub fn new(member: i32) -> Self {
|
857 + | Self { member }
|
1070 858 | }
|
1071 - | /// Returns true if this is a [`NumberValue`](crate::model::MyUnion::NumberValue).
|
1072 - | pub fn is_number_value(&self) -> bool {
|
1073 - | self.as_number_value().is_ok()
|
859 + | fn __repr__(&self) -> String {
|
860 + | format!("{self:?}")
|
1074 861 | }
|
1075 - | /// Tries to convert the enum instance into [`StringValue`](crate::model::MyUnion::StringValue), extracting the inner [`String`](::std::string::String).
|
1076 - | /// Returns `Err(&Self)` if it can't be converted.
|
1077 - | pub fn as_string_value(&self) -> ::std::result::Result<&::std::string::String, &Self> {
|
1078 - | if let MyUnion::StringValue(val) = &self {
|
1079 - | ::std::result::Result::Ok(val)
|
1080 - | } else {
|
1081 - | ::std::result::Result::Err(self)
|
1082 - | }
|
862 + | fn __str__(&self) -> String {
|
863 + | format!("{self:?}")
|
1083 864 | }
|
1084 - | /// Returns true if this is a [`StringValue`](crate::model::MyUnion::StringValue).
|
1085 - | pub fn is_string_value(&self) -> bool {
|
1086 - | self.as_string_value().is_ok()
|
865 + | }
|
866 + | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<ClientOptionalDefaults> {
|
867 + | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
868 + | ob.extract::<ClientOptionalDefaults>().map(Box::new)
|
1087 869 | }
|
1088 - | /// Tries to convert the enum instance into [`StructureValue`](crate::model::MyUnion::StructureValue), extracting the inner [`GreetingStruct`](crate::model::GreetingStruct).
|
1089 - | /// Returns `Err(&Self)` if it can't be converted.
|
1090 - | pub fn as_structure_value(
|
1091 - | &self,
|
1092 - | ) -> ::std::result::Result<&crate::model::GreetingStruct, &Self> {
|
1093 - | if let MyUnion::StructureValue(val) = &self {
|
1094 - | ::std::result::Result::Ok(val)
|
1095 - | } else {
|
1096 - | ::std::result::Result::Err(self)
|
1097 - | }
|
870 + | }
|
871 + |
|
872 + | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<ClientOptionalDefaults> {
|
873 + | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
874 + | (*self).into_py(py)
|
1098 875 | }
|
1099 - | /// Returns true if this is a [`StructureValue`](crate::model::MyUnion::StructureValue).
|
1100 - | pub fn is_structure_value(&self) -> bool {
|
1101 - | self.as_structure_value().is_ok()
|
876 + | }
|
877 + | impl crate::constrained::Constrained for crate::model::ClientOptionalDefaults {
|
878 + | type Unconstrained = crate::model::client_optional_defaults_internal::Builder;
|
879 + | }
|
880 + | impl ClientOptionalDefaults {
|
881 + | /// Creates a new builder-style object to manufacture [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
882 + | pub fn builder() -> crate::model::client_optional_defaults::Builder {
|
883 + | crate::model::client_optional_defaults::Builder::default()
|
1102 884 | }
|
1103 - | /// Tries to convert the enum instance into [`TimestampValue`](crate::model::MyUnion::TimestampValue), extracting the inner [`DateTime`](::aws_smithy_http_server_python::types::DateTime).
|
1104 - | /// Returns `Err(&Self)` if it can't be converted.
|
1105 - | pub fn as_timestamp_value(
|
1106 - | &self,
|
1107 - | ) -> ::std::result::Result<&::aws_smithy_http_server_python::types::DateTime, &Self> {
|
1108 - | if let MyUnion::TimestampValue(val) = &self {
|
1109 - | ::std::result::Result::Ok(val)
|
1110 - | } else {
|
1111 - | ::std::result::Result::Err(self)
|
885 + | }
|
886 + |
|
887 + | #[::pyo3::pyclass]
|
888 + | #[allow(missing_docs)] // documentation missing in model
|
889 + | #[derive(
|
890 + | ::std::clone::Clone,
|
891 + | ::std::cmp::Eq,
|
892 + | ::std::cmp::Ord,
|
893 + | ::std::cmp::PartialEq,
|
894 + | ::std::cmp::PartialOrd,
|
895 + | ::std::fmt::Debug,
|
896 + | ::std::hash::Hash,
|
897 + | )]
|
898 + | pub enum TestEnum {
|
899 + | #[allow(missing_docs)] // documentation missing in model
|
900 + | Bar,
|
901 + | #[allow(missing_docs)] // documentation missing in model
|
902 + | Baz,
|
903 + | #[allow(missing_docs)] // documentation missing in model
|
904 + | Foo,
|
905 + | }
|
906 + | pub(crate) mod test_enum_internal {
|
907 + | #[derive(Debug, PartialEq)]
|
908 + | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
909 + |
|
910 + | impl ::std::fmt::Display for ConstraintViolation {
|
911 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
912 + | write!(
|
913 + | f,
|
914 + | r#"Value provided for 'aws.protocoltests.json10#TestEnum' failed to satisfy constraint: Member must satisfy enum value set: [FOO, BAR, BAZ]"#
|
915 + | )
|
1112 916 | }
|
1113 917 | }
|
1114 - | /// Returns true if this is a [`TimestampValue`](crate::model::MyUnion::TimestampValue).
|
1115 - | pub fn is_timestamp_value(&self) -> bool {
|
1116 - | self.as_timestamp_value().is_ok()
|
918 + |
|
919 + | impl ::std::error::Error for ConstraintViolation {}
|
920 + | impl ConstraintViolation {
|
921 + | pub(crate) fn as_validation_exception_field(
|
922 + | self,
|
923 + | path: ::std::string::String,
|
924 + | ) -> crate::model::ValidationExceptionField {
|
925 + | crate::model::ValidationExceptionField {
|
926 + | message: format!(
|
927 + | r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [FOO, BAR, BAZ]"#,
|
928 + | &path
|
929 + | ),
|
930 + | path,
|
931 + | }
|
932 + | }
|
1117 933 | }
|
1118 934 | }
|
1119 - | #[pyo3::pyclass(name = "MyUnion")]
|
1120 - | #[derive(::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
1121 - | pub struct PyUnionMarkerMyUnion(pub MyUnion);
|
1122 - | #[::pyo3::pymethods]
|
1123 - | impl PyUnionMarkerMyUnion {
|
1124 - | #[staticmethod]
|
1125 - | /// Creates a new union instance of [`BlobValue`](crate::model::MyUnion::BlobValue)
|
1126 - | /// :param data json_rpc10.types.Blob:
|
1127 - | /// :rtype MyUnion:
|
1128 - | pub fn blob_value(data: ::aws_smithy_http_server_python::types::Blob) -> Self {
|
1129 - | Self(MyUnion::BlobValue(data))
|
1130 - | }
|
1131 - | /// Tries to convert the enum instance into [`BlobValue`](crate::model::MyUnion::BlobValue), extracting the inner [`Blob`](::aws_smithy_http_server_python::types::Blob).
|
1132 - | /// :rtype json_rpc10.types.Blob:
|
1133 - | pub fn as_blob_value(&self) -> ::pyo3::PyResult<::aws_smithy_http_server_python::types::Blob> {
|
1134 - | match self.0.as_blob_value() {
|
1135 - | Ok(variant) => Ok(variant.clone()),
|
1136 - | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
1137 - | r"MyUnion variant is not of type json_rpc10.types.Blob",
|
935 + | impl ::std::convert::TryFrom<&str> for TestEnum {
|
936 + | type Error = crate::model::test_enum_internal::ConstraintViolation;
|
937 + | fn try_from(
|
938 + | s: &str,
|
939 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
940 + | match s {
|
941 + | "BAR" => Ok(TestEnum::Bar),
|
942 + | "BAZ" => Ok(TestEnum::Baz),
|
943 + | "FOO" => Ok(TestEnum::Foo),
|
944 + | _ => Err(crate::model::test_enum_internal::ConstraintViolation(
|
945 + | s.to_owned(),
|
1138 946 | )),
|
1139 947 | }
|
1140 948 | }
|
1141 - | /// Returns true if this is a [`BlobValue`](crate::model::MyUnion::BlobValue).
|
1142 - | /// :rtype bool:
|
1143 - | pub fn is_blob_value(&self) -> bool {
|
1144 - | self.0.is_blob_value()
|
949 + | }
|
950 + | impl ::std::convert::TryFrom<::std::string::String> for TestEnum {
|
951 + | type Error = crate::model::test_enum_internal::ConstraintViolation;
|
952 + | fn try_from(
|
953 + | s: ::std::string::String,
|
954 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
955 + | {
|
956 + | s.as_str().try_into()
|
1145 957 | }
|
1146 - | #[staticmethod]
|
1147 - | /// Creates a new union instance of [`BooleanValue`](crate::model::MyUnion::BooleanValue)
|
1148 - | /// :param data bool:
|
1149 - | /// :rtype MyUnion:
|
1150 - | pub fn boolean_value(data: bool) -> Self {
|
1151 - | Self(MyUnion::BooleanValue(data))
|
958 + | }
|
959 + | impl std::str::FromStr for TestEnum {
|
960 + | type Err = crate::model::test_enum_internal::ConstraintViolation;
|
961 + | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
962 + | Self::try_from(s)
|
1152 963 | }
|
1153 - | /// Tries to convert the enum instance into [`BooleanValue`](crate::model::MyUnion::BooleanValue), extracting the inner [`bool`](bool).
|
1154 - | /// :rtype bool:
|
1155 - | pub fn as_boolean_value(&self) -> ::pyo3::PyResult<bool> {
|
1156 - | match self.0.as_boolean_value() {
|
1157 - | Ok(variant) => Ok(*variant),
|
1158 - | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
1159 - | r"MyUnion variant is not of type bool",
|
1160 - | )),
|
964 + | }
|
965 + | impl TestEnum {
|
966 + | /// Returns the `&str` value of the enum member.
|
967 + | pub fn as_str(&self) -> &str {
|
968 + | match self {
|
969 + | TestEnum::Bar => "BAR",
|
970 + | TestEnum::Baz => "BAZ",
|
971 + | TestEnum::Foo => "FOO",
|
1161 972 | }
|
1162 973 | }
|
1163 - | /// Returns true if this is a [`BooleanValue`](crate::model::MyUnion::BooleanValue).
|
1164 - | /// :rtype bool:
|
1165 - | pub fn is_boolean_value(&self) -> bool {
|
1166 - | self.0.is_boolean_value()
|
974 + | /// Returns all the `&str` representations of the enum members.
|
975 + | pub const fn values() -> &'static [&'static str] {
|
976 + | &["BAR", "BAZ", "FOO"]
|
1167 977 | }
|
1168 - | #[staticmethod]
|
1169 - | /// Creates a new union instance of [`EnumValue`](crate::model::MyUnion::EnumValue)
|
1170 - | /// :param data json_rpc10.model.FooEnum:
|
1171 - | /// :rtype MyUnion:
|
1172 - | pub fn enum_value(data: crate::model::FooEnum) -> Self {
|
1173 - | Self(MyUnion::EnumValue(data))
|
978 + | }
|
979 + | impl ::std::convert::AsRef<str> for TestEnum {
|
980 + | fn as_ref(&self) -> &str {
|
981 + | self.as_str()
|
1174 982 | }
|
1175 - | /// Tries to convert the enum instance into [`EnumValue`](crate::model::MyUnion::EnumValue), extracting the inner [`FooEnum`](crate::model::FooEnum).
|
1176 - | /// :rtype json_rpc10.model.FooEnum:
|
1177 - | pub fn as_enum_value(&self) -> ::pyo3::PyResult<crate::model::FooEnum> {
|
1178 - | match self.0.as_enum_value() {
|
1179 - | Ok(variant) => Ok(variant.clone()),
|
1180 - | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
1181 - | r"MyUnion variant is not of type json_rpc10.model.FooEnum",
|
1182 - | )),
|
983 + | }
|
984 + | #[::pyo3::pymethods]
|
985 + | impl TestEnum {
|
986 + | #[getter]
|
987 + | pub fn name(&self) -> &str {
|
988 + | match self {
|
989 + | TestEnum::Bar => "Bar",
|
990 + | TestEnum::Baz => "Baz",
|
991 + | TestEnum::Foo => "Foo",
|
1183 992 | }
|
1184 993 | }
|
1185 - | /// Returns true if this is a [`EnumValue`](crate::model::MyUnion::EnumValue).
|
1186 - | /// :rtype bool:
|
1187 - | pub fn is_enum_value(&self) -> bool {
|
1188 - | self.0.is_enum_value()
|
994 + | #[getter]
|
995 + | pub fn value(&self) -> &str {
|
996 + | self.as_str()
|
1189 997 | }
|
1190 - | #[staticmethod]
|
1191 - | /// Creates a new union instance of [`IntEnumValue`](crate::model::MyUnion::IntEnumValue)
|
1192 - | /// :param data int:
|
1193 - | /// :rtype MyUnion:
|
1194 - | pub fn int_enum_value(data: i32) -> Self {
|
1195 - | Self(MyUnion::IntEnumValue(data))
|
998 + | fn __repr__(&self) -> String {
|
999 + | self.as_str().to_owned()
|
1196 1000 | }
|
1197 - | /// Tries to convert the enum instance into [`IntEnumValue`](crate::model::MyUnion::IntEnumValue), extracting the inner [`i32`](i32).
|
1198 - | /// :rtype int:
|
1199 - | pub fn as_int_enum_value(&self) -> ::pyo3::PyResult<i32> {
|
1200 - | match self.0.as_int_enum_value() {
|
1201 - | Ok(variant) => Ok(*variant),
|
1202 - | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
1203 - | r"MyUnion variant is not of type int",
|
1204 - | )),
|
1205 - | }
|
1001 + | fn __str__(&self) -> String {
|
1002 + | self.as_str().to_owned()
|
1206 1003 | }
|
1207 - | /// Returns true if this is a [`IntEnumValue`](crate::model::MyUnion::IntEnumValue).
|
1208 - | /// :rtype bool:
|
1209 - | pub fn is_int_enum_value(&self) -> bool {
|
1210 - | self.0.is_int_enum_value()
|
1004 + | }
|
1005 + | impl crate::constrained::Constrained for TestEnum {
|
1006 + | type Unconstrained = ::std::string::String;
|
1007 + | }
|
1008 + |
|
1009 + | impl ::std::convert::From<::std::string::String>
|
1010 + | for crate::constrained::MaybeConstrained<crate::model::TestEnum>
|
1011 + | {
|
1012 + | fn from(value: ::std::string::String) -> Self {
|
1013 + | Self::Unconstrained(value)
|
1211 1014 | }
|
1212 - | #[staticmethod]
|
1213 - | /// Creates a new union instance of [`ListValue`](crate::model::MyUnion::ListValue)
|
1214 - | /// :param data typing.List\[str\]:
|
1215 - | /// :rtype MyUnion:
|
1216 - | pub fn list_value(data: ::std::vec::Vec<::std::string::String>) -> Self {
|
1217 - | Self(MyUnion::ListValue(data))
|
1015 + | }
|
1016 + |
|
1017 + | #[::pyo3::pyclass]
|
1018 + | /// :param dialog json_rpc10.model.Dialog:
|
1019 + | /// :param dialog_list typing.List\[json_rpc10.model.Dialog\]:
|
1020 + | /// :param dialog_map typing.Dict\[str, json_rpc10.model.Dialog\]:
|
1021 + | /// :rtype None:
|
1022 + | #[allow(missing_docs)] // documentation missing in model
|
1023 + | #[derive(::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
1024 + | pub struct TopLevel {
|
1025 + | #[pyo3(get, set)]
|
1026 + | /// :type json_rpc10.model.Dialog:
|
1027 + | #[allow(missing_docs)] // documentation missing in model
|
1028 + | pub dialog: crate::model::Dialog,
|
1029 + | #[pyo3(get, set)]
|
1030 + | /// :type typing.List\[json_rpc10.model.Dialog\]:
|
1031 + | #[allow(missing_docs)] // documentation missing in model
|
1032 + | pub dialog_list: ::std::vec::Vec<crate::model::Dialog>,
|
1033 + | #[pyo3(get, set)]
|
1034 + | /// :type typing.Dict\[str, json_rpc10.model.Dialog\]:
|
1035 + | #[allow(missing_docs)] // documentation missing in model
|
1036 + | pub dialog_map: ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
1037 + | }
|
1038 + | impl TopLevel {
|
1039 + | #[allow(missing_docs)] // documentation missing in model
|
1040 + | pub fn dialog(&self) -> &crate::model::Dialog {
|
1041 + | &self.dialog
|
1218 1042 | }
|
1219 - | /// Tries to convert the enum instance into [`ListValue`](crate::model::MyUnion::ListValue), extracting the inner [`Vec`](::std::vec::Vec).
|
1220 - | /// :rtype typing.List\[str\]:
|
1221 - | pub fn as_list_value(&self) -> ::pyo3::PyResult<::std::vec::Vec<::std::string::String>> {
|
1222 - | match self.0.as_list_value() {
|
1223 - | Ok(variant) => Ok(variant.clone()),
|
1224 - | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
1225 - | r"MyUnion variant is not of type typing.List\[str\]",
|
1226 - | )),
|
1227 - | }
|
1043 + | #[allow(missing_docs)] // documentation missing in model
|
1044 + | pub fn dialog_list(&self) -> &[crate::model::Dialog] {
|
1045 + | use std::ops::Deref;
|
1046 + | self.dialog_list.deref()
|
1228 1047 | }
|
1229 - | /// Returns true if this is a [`ListValue`](crate::model::MyUnion::ListValue).
|
1230 - | /// :rtype bool:
|
1231 - | pub fn is_list_value(&self) -> bool {
|
1232 - | self.0.is_list_value()
|
1048 + | #[allow(missing_docs)] // documentation missing in model
|
1049 + | pub fn dialog_map(
|
1050 + | &self,
|
1051 + | ) -> &::std::collections::HashMap<::std::string::String, crate::model::Dialog> {
|
1052 + | &self.dialog_map
|
1233 1053 | }
|
1234 - | #[staticmethod]
|
1235 - | /// Creates a new union instance of [`MapValue`](crate::model::MyUnion::MapValue)
|
1236 - | /// :param data typing.Dict\[str, str\]:
|
1237 - | /// :rtype MyUnion:
|
1238 - | pub fn map_value(
|
1239 - | data: ::std::collections::HashMap<::std::string::String, ::std::string::String>,
|
1054 + | }
|
1055 + | #[allow(clippy::new_without_default)]
|
1056 + | #[allow(clippy::too_many_arguments)]
|
1057 + | #[::pyo3::pymethods]
|
1058 + | impl TopLevel {
|
1059 + | #[new]
|
1060 + | pub fn new(
|
1061 + | dialog: crate::model::Dialog,
|
1062 + | dialog_list: ::std::vec::Vec<crate::model::Dialog>,
|
1063 + | dialog_map: ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
1240 1064 | ) -> Self {
|
1241 - | Self(MyUnion::MapValue(data))
|
1242 - | }
|
1243 - | /// Tries to convert the enum instance into [`MapValue`](crate::model::MyUnion::MapValue), extracting the inner [`HashMap`](::std::collections::HashMap).
|
1244 - | /// :rtype typing.Dict\[str, str\]:
|
1245 - | pub fn as_map_value(
|
1246 - | &self,
|
1247 - | ) -> ::pyo3::PyResult<::std::collections::HashMap<::std::string::String, ::std::string::String>>
|
1248 - | {
|
1249 - | match self.0.as_map_value() {
|
1250 - | Ok(variant) => Ok(variant.clone()),
|
1251 - | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
1252 - | r"MyUnion variant is not of type typing.Dict\[str, str\]",
|
1253 - | )),
|
1065 + | Self {
|
1066 + | dialog,
|
1067 + | dialog_list,
|
1068 + | dialog_map,
|
1254 1069 | }
|
1255 1070 | }
|
1256 - | /// Returns true if this is a [`MapValue`](crate::model::MyUnion::MapValue).
|
1257 - | /// :rtype bool:
|
1258 - | pub fn is_map_value(&self) -> bool {
|
1259 - | self.0.is_map_value()
|
1071 + | fn __repr__(&self) -> String {
|
1072 + | format!("{self:?}")
|
1260 1073 | }
|
1261 - | #[staticmethod]
|
1262 - | /// Creates a new union instance of [`NumberValue`](crate::model::MyUnion::NumberValue)
|
1263 - | /// :param data int:
|
1264 - | /// :rtype MyUnion:
|
1265 - | pub fn number_value(data: i32) -> Self {
|
1266 - | Self(MyUnion::NumberValue(data))
|
1074 + | fn __str__(&self) -> String {
|
1075 + | format!("{self:?}")
|
1267 1076 | }
|
1268 - | /// Tries to convert the enum instance into [`NumberValue`](crate::model::MyUnion::NumberValue), extracting the inner [`i32`](i32).
|
1269 - | /// :rtype int:
|
1270 - | pub fn as_number_value(&self) -> ::pyo3::PyResult<i32> {
|
1271 - | match self.0.as_number_value() {
|
1272 - | Ok(variant) => Ok(*variant),
|
1273 - | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
1274 - | r"MyUnion variant is not of type int",
|
1275 - | )),
|
1276 - | }
|
1077 + | }
|
1078 + | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<TopLevel> {
|
1079 + | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
1080 + | ob.extract::<TopLevel>().map(Box::new)
|
1277 1081 | }
|
1278 - | /// Returns true if this is a [`NumberValue`](crate::model::MyUnion::NumberValue).
|
1279 - | /// :rtype bool:
|
1280 - | pub fn is_number_value(&self) -> bool {
|
1281 - | self.0.is_number_value()
|
1082 + | }
|
1083 + |
|
1084 + | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<TopLevel> {
|
1085 + | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
1086 + | (*self).into_py(py)
|
1282 1087 | }
|
1283 - | #[staticmethod]
|
1284 - | /// Creates a new union instance of [`StringValue`](crate::model::MyUnion::StringValue)
|
1285 - | /// :param data str:
|
1286 - | /// :rtype MyUnion:
|
1287 - | pub fn string_value(data: ::std::string::String) -> Self {
|
1288 - | Self(MyUnion::StringValue(data))
|
1088 + | }
|
1089 + | impl crate::constrained::Constrained for crate::model::TopLevel {
|
1090 + | type Unconstrained = crate::model::top_level_internal::Builder;
|
1091 + | }
|
1092 + | impl TopLevel {
|
1093 + | /// Creates a new builder-style object to manufacture [`TopLevel`](crate::model::TopLevel).
|
1094 + | pub fn builder() -> crate::model::top_level::Builder {
|
1095 + | crate::model::top_level::Builder::default()
|
1289 1096 | }
|
1290 - | /// Tries to convert the enum instance into [`StringValue`](crate::model::MyUnion::StringValue), extracting the inner [`String`](::std::string::String).
|
1291 - | /// :rtype str:
|
1292 - | pub fn as_string_value(&self) -> ::pyo3::PyResult<::std::string::String> {
|
1293 - | match self.0.as_string_value() {
|
1294 - | Ok(variant) => Ok(variant.clone()),
|
1295 - | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
1296 - | r"MyUnion variant is not of type str",
|
1297 - | )),
|
1298 - | }
|
1097 + | }
|
1098 + |
|
1099 + | #[::pyo3::pyclass]
|
1100 + | /// :param greeting str:
|
1101 + | /// :param language typing.Optional\[str\]:
|
1102 + | /// :param farewell typing.Optional\[json_rpc10.model.Farewell\]:
|
1103 + | /// :rtype None:
|
1104 + | #[allow(missing_docs)] // documentation missing in model
|
1105 + | #[derive(
|
1106 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1107 + | )]
|
1108 + | pub struct Dialog {
|
1109 + | #[pyo3(get, set)]
|
1110 + | /// :type typing.Optional\[str\]:
|
1111 + | #[allow(missing_docs)] // documentation missing in model
|
1112 + | pub language: ::std::option::Option<::std::string::String>,
|
1113 + | #[pyo3(get, set)]
|
1114 + | /// :type str:
|
1115 + | #[allow(missing_docs)] // documentation missing in model
|
1116 + | pub greeting: ::std::string::String,
|
1117 + | #[pyo3(get, set)]
|
1118 + | /// :type typing.Optional\[json_rpc10.model.Farewell\]:
|
1119 + | #[allow(missing_docs)] // documentation missing in model
|
1120 + | pub farewell: ::std::option::Option<crate::model::Farewell>,
|
1121 + | }
|
1122 + | impl Dialog {
|
1123 + | #[allow(missing_docs)] // documentation missing in model
|
1124 + | pub fn language(&self) -> ::std::option::Option<&str> {
|
1125 + | self.language.as_deref()
|
1299 1126 | }
|
1300 - | /// Returns true if this is a [`StringValue`](crate::model::MyUnion::StringValue).
|
1301 - | /// :rtype bool:
|
1302 - | pub fn is_string_value(&self) -> bool {
|
1303 - | self.0.is_string_value()
|
1127 + | #[allow(missing_docs)] // documentation missing in model
|
1128 + | pub fn greeting(&self) -> &str {
|
1129 + | use std::ops::Deref;
|
1130 + | self.greeting.deref()
|
1304 1131 | }
|
1305 - | #[staticmethod]
|
1306 - | /// Creates a new union instance of [`StructureValue`](crate::model::MyUnion::StructureValue)
|
1307 - | /// :param data json_rpc10.model.GreetingStruct:
|
1308 - | /// :rtype MyUnion:
|
1309 - | pub fn structure_value(data: crate::model::GreetingStruct) -> Self {
|
1310 - | Self(MyUnion::StructureValue(data))
|
1132 + | #[allow(missing_docs)] // documentation missing in model
|
1133 + | pub fn farewell(&self) -> ::std::option::Option<&crate::model::Farewell> {
|
1134 + | self.farewell.as_ref()
|
1311 1135 | }
|
1312 - | /// Tries to convert the enum instance into [`StructureValue`](crate::model::MyUnion::StructureValue), extracting the inner [`GreetingStruct`](crate::model::GreetingStruct).
|
1313 - | /// :rtype json_rpc10.model.GreetingStruct:
|
1314 - | pub fn as_structure_value(&self) -> ::pyo3::PyResult<crate::model::GreetingStruct> {
|
1315 - | match self.0.as_structure_value() {
|
1316 - | Ok(variant) => Ok(variant.clone()),
|
1317 - | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
1318 - | r"MyUnion variant is not of type json_rpc10.model.GreetingStruct",
|
1319 - | )),
|
1136 + | }
|
1137 + | #[allow(clippy::new_without_default)]
|
1138 + | #[allow(clippy::too_many_arguments)]
|
1139 + | #[::pyo3::pymethods]
|
1140 + | impl Dialog {
|
1141 + | #[new]
|
1142 + | pub fn new(
|
1143 + | greeting: ::std::string::String,
|
1144 + | language: ::std::option::Option<::std::string::String>,
|
1145 + | farewell: ::std::option::Option<crate::model::Farewell>,
|
1146 + | ) -> Self {
|
1147 + | Self {
|
1148 + | greeting,
|
1149 + | language,
|
1150 + | farewell,
|
1320 1151 | }
|
1321 1152 | }
|
1322 - | /// Returns true if this is a [`StructureValue`](crate::model::MyUnion::StructureValue).
|
1323 - | /// :rtype bool:
|
1324 - | pub fn is_structure_value(&self) -> bool {
|
1325 - | self.0.is_structure_value()
|
1326 - | }
|
1327 - | #[staticmethod]
|
1328 - | /// Creates a new union instance of [`TimestampValue`](crate::model::MyUnion::TimestampValue)
|
1329 - | /// :param data json_rpc10.types.DateTime:
|
1330 - | /// :rtype MyUnion:
|
1331 - | pub fn timestamp_value(data: ::aws_smithy_http_server_python::types::DateTime) -> Self {
|
1332 - | Self(MyUnion::TimestampValue(data))
|
1153 + | fn __repr__(&self) -> String {
|
1154 + | format!("{self:?}")
|
1333 1155 | }
|
1334 - | /// Tries to convert the enum instance into [`TimestampValue`](crate::model::MyUnion::TimestampValue), extracting the inner [`DateTime`](::aws_smithy_http_server_python::types::DateTime).
|
1335 - | /// :rtype json_rpc10.types.DateTime:
|
1336 - | pub fn as_timestamp_value(
|
1337 - | &self,
|
1338 - | ) -> ::pyo3::PyResult<::aws_smithy_http_server_python::types::DateTime> {
|
1339 - | match self.0.as_timestamp_value() {
|
1340 - | Ok(variant) => Ok(variant.clone()),
|
1341 - | Err(_) => Err(::pyo3::exceptions::PyValueError::new_err(
|
1342 - | r"MyUnion variant is not of type json_rpc10.types.DateTime",
|
1343 - | )),
|
1344 - | }
|
1156 + | fn __str__(&self) -> String {
|
1157 + | format!("{self:?}")
|
1345 1158 | }
|
1346 - | /// Returns true if this is a [`TimestampValue`](crate::model::MyUnion::TimestampValue).
|
1347 - | /// :rtype bool:
|
1348 - | pub fn is_timestamp_value(&self) -> bool {
|
1349 - | self.0.is_timestamp_value()
|
1159 + | }
|
1160 + | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<Dialog> {
|
1161 + | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
1162 + | ob.extract::<Dialog>().map(Box::new)
|
1350 1163 | }
|
1351 1164 | }
|
1352 - | impl ::pyo3::IntoPy<::pyo3::PyObject> for MyUnion {
|
1165 + |
|
1166 + | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<Dialog> {
|
1353 1167 | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
1354 - | PyUnionMarkerMyUnion(self).into_py(py)
|
1168 + | (*self).into_py(py)
|
1355 1169 | }
|
1356 1170 | }
|
1357 - | impl<'source> ::pyo3::FromPyObject<'source> for MyUnion {
|
1358 - | fn extract(obj: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
1359 - | let data: PyUnionMarkerMyUnion = obj.extract()?;
|
1360 - | Ok(data.0)
|
1171 + | impl crate::constrained::Constrained for crate::model::Dialog {
|
1172 + | type Unconstrained = crate::model::dialog_internal::Builder;
|
1173 + | }
|
1174 + | impl Dialog {
|
1175 + | /// Creates a new builder-style object to manufacture [`Dialog`](crate::model::Dialog).
|
1176 + | pub fn builder() -> crate::model::dialog::Builder {
|
1177 + | crate::model::dialog::Builder::default()
|
1361 1178 | }
|
1362 1179 | }
|
1363 1180 |
|
1364 1181 | #[::pyo3::pyclass]
|
1365 - | /// :param hi typing.Optional\[str\]:
|
1366 - | /// :rtype None:
|
1367 1182 | #[allow(missing_docs)] // documentation missing in model
|
1368 1183 | #[derive(
|
1369 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1184 + | ::std::clone::Clone,
|
1185 + | ::std::cmp::Eq,
|
1186 + | ::std::cmp::Ord,
|
1187 + | ::std::cmp::PartialEq,
|
1188 + | ::std::cmp::PartialOrd,
|
1189 + | ::std::fmt::Debug,
|
1190 + | ::std::hash::Hash,
|
1370 1191 | )]
|
1371 - | pub struct GreetingStruct {
|
1372 - | #[pyo3(get, set)]
|
1373 - | /// :type typing.Optional\[str\]:
|
1192 + | pub enum RequiredEnum {
|
1374 1193 | #[allow(missing_docs)] // documentation missing in model
|
1375 - | pub hi: ::std::option::Option<::std::string::String>,
|
1376 - | }
|
1377 - | impl GreetingStruct {
|
1194 + | Bar,
|
1378 1195 | #[allow(missing_docs)] // documentation missing in model
|
1379 - | pub fn hi(&self) -> ::std::option::Option<&str> {
|
1380 - | self.hi.as_deref()
|
1196 + | Baz,
|
1197 + | #[allow(missing_docs)] // documentation missing in model
|
1198 + | Foo,
|
1199 + | }
|
1200 + | pub(crate) mod required_enum_internal {
|
1201 + | #[derive(Debug, PartialEq)]
|
1202 + | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
1203 + |
|
1204 + | impl ::std::fmt::Display for ConstraintViolation {
|
1205 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1206 + | write!(
|
1207 + | f,
|
1208 + | r#"Value provided for 'aws.protocoltests.json10#RequiredEnum' failed to satisfy constraint: Member must satisfy enum value set: [FOO, BAR, BAZ]"#
|
1209 + | )
|
1210 + | }
|
1381 1211 | }
|
1212 + |
|
1213 + | impl ::std::error::Error for ConstraintViolation {}
|
1382 1214 | }
|
1383 - | #[allow(clippy::new_without_default)]
|
1384 - | #[allow(clippy::too_many_arguments)]
|
1385 - | #[::pyo3::pymethods]
|
1386 - | impl GreetingStruct {
|
1387 - | #[new]
|
1388 - | pub fn new(hi: ::std::option::Option<::std::string::String>) -> Self {
|
1389 - | Self { hi }
|
1215 + | impl ::std::convert::TryFrom<&str> for RequiredEnum {
|
1216 + | type Error = crate::model::required_enum_internal::ConstraintViolation;
|
1217 + | fn try_from(
|
1218 + | s: &str,
|
1219 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
1220 + | match s {
|
1221 + | "BAR" => Ok(RequiredEnum::Bar),
|
1222 + | "BAZ" => Ok(RequiredEnum::Baz),
|
1223 + | "FOO" => Ok(RequiredEnum::Foo),
|
1224 + | _ => Err(crate::model::required_enum_internal::ConstraintViolation(
|
1225 + | s.to_owned(),
|
1226 + | )),
|
1227 + | }
|
1390 1228 | }
|
1391 - | fn __repr__(&self) -> String {
|
1392 - | format!("{self:?}")
|
1229 + | }
|
1230 + | impl ::std::convert::TryFrom<::std::string::String> for RequiredEnum {
|
1231 + | type Error = crate::model::required_enum_internal::ConstraintViolation;
|
1232 + | fn try_from(
|
1233 + | s: ::std::string::String,
|
1234 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
1235 + | {
|
1236 + | s.as_str().try_into()
|
1393 1237 | }
|
1394 - | fn __str__(&self) -> String {
|
1395 - | format!("{self:?}")
|
1238 + | }
|
1239 + | impl std::str::FromStr for RequiredEnum {
|
1240 + | type Err = crate::model::required_enum_internal::ConstraintViolation;
|
1241 + | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
1242 + | Self::try_from(s)
|
1396 1243 | }
|
1397 1244 | }
|
1398 - | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<GreetingStruct> {
|
1399 - | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
1400 - | ob.extract::<GreetingStruct>().map(Box::new)
|
1245 + | impl RequiredEnum {
|
1246 + | /// Returns the `&str` value of the enum member.
|
1247 + | pub fn as_str(&self) -> &str {
|
1248 + | match self {
|
1249 + | RequiredEnum::Bar => "BAR",
|
1250 + | RequiredEnum::Baz => "BAZ",
|
1251 + | RequiredEnum::Foo => "FOO",
|
1252 + | }
|
1253 + | }
|
1254 + | /// Returns all the `&str` representations of the enum members.
|
1255 + | pub const fn values() -> &'static [&'static str] {
|
1256 + | &["BAR", "BAZ", "FOO"]
|
1401 1257 | }
|
1402 1258 | }
|
1403 - |
|
1404 - | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<GreetingStruct> {
|
1405 - | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
1406 - | (*self).into_py(py)
|
1259 + | impl ::std::convert::AsRef<str> for RequiredEnum {
|
1260 + | fn as_ref(&self) -> &str {
|
1261 + | self.as_str()
|
1407 1262 | }
|
1408 1263 | }
|
1409 - | impl crate::constrained::Constrained for crate::model::GreetingStruct {
|
1410 - | type Unconstrained = crate::model::greeting_struct_internal::Builder;
|
1264 + | #[::pyo3::pymethods]
|
1265 + | impl RequiredEnum {
|
1266 + | #[getter]
|
1267 + | pub fn name(&self) -> &str {
|
1268 + | match self {
|
1269 + | RequiredEnum::Bar => "Bar",
|
1270 + | RequiredEnum::Baz => "Baz",
|
1271 + | RequiredEnum::Foo => "Foo",
|
1272 + | }
|
1273 + | }
|
1274 + | #[getter]
|
1275 + | pub fn value(&self) -> &str {
|
1276 + | self.as_str()
|
1277 + | }
|
1278 + | fn __repr__(&self) -> String {
|
1279 + | self.as_str().to_owned()
|
1280 + | }
|
1281 + | fn __str__(&self) -> String {
|
1282 + | self.as_str().to_owned()
|
1283 + | }
|
1411 1284 | }
|
1412 - | impl GreetingStruct {
|
1413 - | /// Creates a new builder-style object to manufacture [`GreetingStruct`](crate::model::GreetingStruct).
|
1414 - | pub fn builder() -> crate::model::greeting_struct::Builder {
|
1415 - | crate::model::greeting_struct::Builder::default()
|
1285 + | impl crate::constrained::Constrained for RequiredEnum {
|
1286 + | type Unconstrained = ::std::string::String;
|
1287 + | }
|
1288 + |
|
1289 + | impl ::std::convert::From<::std::string::String>
|
1290 + | for crate::constrained::MaybeConstrained<crate::model::RequiredEnum>
|
1291 + | {
|
1292 + | fn from(value: ::std::string::String) -> Self {
|
1293 + | Self::Unconstrained(value)
|
1416 1294 | }
|
1417 1295 | }
|
1418 1296 |
|
1419 1297 | #[::pyo3::pyclass]
|
1420 1298 | #[allow(missing_docs)] // documentation missing in model
|
1421 1299 | #[derive(
|
1422 1300 | ::std::clone::Clone,
|
1423 1301 | ::std::cmp::Eq,
|
1424 1302 | ::std::cmp::Ord,
|
1425 1303 | ::std::cmp::PartialEq,
|
1550 1428 |
|
1551 1429 | impl ::std::convert::From<::std::string::String>
|
1552 1430 | for crate::constrained::MaybeConstrained<crate::model::FooEnum>
|
1553 1431 | {
|
1554 1432 | fn from(value: ::std::string::String) -> Self {
|
1555 1433 | Self::Unconstrained(value)
|
1556 1434 | }
|
1557 1435 | }
|
1558 1436 |
|
1559 1437 | #[::pyo3::pyclass]
|
1560 - | /// :param foo typing.Optional\[str\]:
|
1438 + | /// :param hi typing.Optional\[str\]:
|
1439 + | /// :rtype None:
|
1440 + | #[allow(missing_docs)] // documentation missing in model
|
1441 + | #[derive(
|
1442 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1443 + | )]
|
1444 + | pub struct GreetingStruct {
|
1445 + | #[pyo3(get, set)]
|
1446 + | /// :type typing.Optional\[str\]:
|
1447 + | #[allow(missing_docs)] // documentation missing in model
|
1448 + | pub hi: ::std::option::Option<::std::string::String>,
|
1449 + | }
|
1450 + | impl GreetingStruct {
|
1451 + | #[allow(missing_docs)] // documentation missing in model
|
1452 + | pub fn hi(&self) -> ::std::option::Option<&str> {
|
1453 + | self.hi.as_deref()
|
1454 + | }
|
1455 + | }
|
1456 + | #[allow(clippy::new_without_default)]
|
1457 + | #[allow(clippy::too_many_arguments)]
|
1458 + | #[::pyo3::pymethods]
|
1459 + | impl GreetingStruct {
|
1460 + | #[new]
|
1461 + | pub fn new(hi: ::std::option::Option<::std::string::String>) -> Self {
|
1462 + | Self { hi }
|
1463 + | }
|
1464 + | fn __repr__(&self) -> String {
|
1465 + | format!("{self:?}")
|
1466 + | }
|
1467 + | fn __str__(&self) -> String {
|
1468 + | format!("{self:?}")
|
1469 + | }
|
1470 + | }
|
1471 + | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<GreetingStruct> {
|
1472 + | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
1473 + | ob.extract::<GreetingStruct>().map(Box::new)
|
1474 + | }
|
1475 + | }
|
1476 + |
|
1477 + | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<GreetingStruct> {
|
1478 + | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
1479 + | (*self).into_py(py)
|
1480 + | }
|
1481 + | }
|
1482 + | impl crate::constrained::Constrained for crate::model::GreetingStruct {
|
1483 + | type Unconstrained = crate::model::greeting_struct_internal::Builder;
|
1484 + | }
|
1485 + | impl GreetingStruct {
|
1486 + | /// Creates a new builder-style object to manufacture [`GreetingStruct`](crate::model::GreetingStruct).
|
1487 + | pub fn builder() -> crate::model::greeting_struct::Builder {
|
1488 + | crate::model::greeting_struct::Builder::default()
|
1489 + | }
|
1490 + | }
|
1491 + |
|
1492 + | #[::pyo3::pyclass]
|
1493 + | /// :param path str:
|
1494 + | /// :param message str:
|
1495 + | /// :rtype None:
|
1496 + | /// Describes one specific validation failure for an input member.
|
1497 + | #[derive(
|
1498 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1499 + | )]
|
1500 + | pub struct ValidationExceptionField {
|
1501 + | #[pyo3(get, set)]
|
1502 + | /// :type str:
|
1503 + | /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
|
1504 + | pub path: ::std::string::String,
|
1505 + | #[pyo3(get, set)]
|
1506 + | /// :type str:
|
1507 + | /// A detailed description of the validation failure.
|
1508 + | pub message: ::std::string::String,
|
1509 + | }
|
1510 + | impl ValidationExceptionField {
|
1511 + | /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
|
1512 + | pub fn path(&self) -> &str {
|
1513 + | use std::ops::Deref;
|
1514 + | self.path.deref()
|
1515 + | }
|
1516 + | /// A detailed description of the validation failure.
|
1517 + | pub fn message(&self) -> &str {
|
1518 + | use std::ops::Deref;
|
1519 + | self.message.deref()
|
1520 + | }
|
1521 + | }
|
1522 + | #[allow(clippy::new_without_default)]
|
1523 + | #[allow(clippy::too_many_arguments)]
|
1524 + | #[::pyo3::pymethods]
|
1525 + | impl ValidationExceptionField {
|
1526 + | #[new]
|
1527 + | pub fn new(path: ::std::string::String, message: ::std::string::String) -> Self {
|
1528 + | Self { path, message }
|
1529 + | }
|
1530 + | fn __repr__(&self) -> String {
|
1531 + | format!("{self:?}")
|
1532 + | }
|
1533 + | fn __str__(&self) -> String {
|
1534 + | format!("{self:?}")
|
1535 + | }
|
1536 + | }
|
1537 + | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<ValidationExceptionField> {
|
1538 + | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
1539 + | ob.extract::<ValidationExceptionField>().map(Box::new)
|
1540 + | }
|
1541 + | }
|
1542 + |
|
1543 + | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<ValidationExceptionField> {
|
1544 + | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
1545 + | (*self).into_py(py)
|
1546 + | }
|
1547 + | }
|
1548 + | impl ValidationExceptionField {
|
1549 + | /// Creates a new builder-style object to manufacture [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
1550 + | pub fn builder() -> crate::model::validation_exception_field::Builder {
|
1551 + | crate::model::validation_exception_field::Builder::default()
|
1552 + | }
|
1553 + | }
|
1554 + |
|
1555 + | #[::pyo3::pyclass]
|
1556 + | /// :param phrase str:
|
1561 1557 | /// :rtype None:
|
1562 1558 | #[allow(missing_docs)] // documentation missing in model
|
1563 1559 | #[derive(
|
1564 1560 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1565 1561 | )]
|
1566 - | pub struct ComplexNestedErrorData {
|
1562 + | pub struct Farewell {
|
1567 1563 | #[pyo3(get, set)]
|
1568 - | /// :type typing.Optional\[str\]:
|
1564 + | /// :type str:
|
1569 1565 | #[allow(missing_docs)] // documentation missing in model
|
1570 - | pub foo: ::std::option::Option<::std::string::String>,
|
1566 + | pub phrase: ::std::string::String,
|
1571 1567 | }
|
1572 - | impl ComplexNestedErrorData {
|
1568 + | impl Farewell {
|
1573 1569 | #[allow(missing_docs)] // documentation missing in model
|
1574 - | pub fn foo(&self) -> ::std::option::Option<&str> {
|
1575 - | self.foo.as_deref()
|
1570 + | pub fn phrase(&self) -> &str {
|
1571 + | use std::ops::Deref;
|
1572 + | self.phrase.deref()
|
1576 1573 | }
|
1577 1574 | }
|
1578 1575 | #[allow(clippy::new_without_default)]
|
1579 1576 | #[allow(clippy::too_many_arguments)]
|
1580 1577 | #[::pyo3::pymethods]
|
1581 - | impl ComplexNestedErrorData {
|
1578 + | impl Farewell {
|
1582 1579 | #[new]
|
1583 - | pub fn new(foo: ::std::option::Option<::std::string::String>) -> Self {
|
1584 - | Self { foo }
|
1580 + | pub fn new(phrase: ::std::string::String) -> Self {
|
1581 + | Self { phrase }
|
1585 1582 | }
|
1586 1583 | fn __repr__(&self) -> String {
|
1587 1584 | format!("{self:?}")
|
1588 1585 | }
|
1589 1586 | fn __str__(&self) -> String {
|
1590 1587 | format!("{self:?}")
|
1591 1588 | }
|
1592 1589 | }
|
1593 - | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<ComplexNestedErrorData> {
|
1590 + | impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<Farewell> {
|
1594 1591 | fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
1595 - | ob.extract::<ComplexNestedErrorData>().map(Box::new)
|
1592 + | ob.extract::<Farewell>().map(Box::new)
|
1596 1593 | }
|
1597 1594 | }
|
1598 1595 |
|
1599 - | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<ComplexNestedErrorData> {
|
1596 + | impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<Farewell> {
|
1600 1597 | fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
|
1601 1598 | (*self).into_py(py)
|
1602 1599 | }
|
1603 1600 | }
|
1604 - | impl ComplexNestedErrorData {
|
1605 - | /// Creates a new builder-style object to manufacture [`ComplexNestedErrorData`](crate::model::ComplexNestedErrorData).
|
1606 - | pub fn builder() -> crate::model::complex_nested_error_data::Builder {
|
1607 - | crate::model::complex_nested_error_data::Builder::default()
|
1608 - | }
|
1609 - | }
|
1610 - | /// See [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
1611 - | pub mod validation_exception_field {
|
1612 - |
|
1613 - | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
1614 - | /// Holds one variant for each of the ways the builder can fail.
|
1615 - | #[allow(clippy::enum_variant_names)]
|
1616 - | pub enum ConstraintViolation {
|
1617 - | /// `path` was not provided but it is required when building `ValidationExceptionField`.
|
1618 - | MissingPath,
|
1619 - | /// `message` was not provided but it is required when building `ValidationExceptionField`.
|
1620 - | MissingMessage,
|
1621 - | }
|
1622 - | impl ::std::fmt::Display for ConstraintViolation {
|
1623 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1624 - | match self {
|
1625 - | ConstraintViolation::MissingPath => write!(f, "`path` was not provided but it is required when building `ValidationExceptionField`"),
|
1626 - | ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationExceptionField`"),
|
1627 - | }
|
1628 - | }
|
1629 - | }
|
1630 - | impl ::std::error::Error for ConstraintViolation {}
|
1631 - | impl ::std::convert::TryFrom<Builder> for crate::model::ValidationExceptionField {
|
1632 - | type Error = ConstraintViolation;
|
1633 - |
|
1634 - | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
1635 - | builder.build()
|
1636 - | }
|
1637 - | }
|
1638 - | /// A builder for [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
1639 - | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
1640 - | pub struct Builder {
|
1641 - | pub(crate) path: ::std::option::Option<::std::string::String>,
|
1642 - | pub(crate) message: ::std::option::Option<::std::string::String>,
|
1643 - | }
|
1644 - | impl Builder {
|
1645 - | /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
|
1646 - | pub fn path(mut self, input: ::std::string::String) -> Self {
|
1647 - | self.path = Some(input);
|
1648 - | self
|
1649 - | }
|
1650 - | /// A detailed description of the validation failure.
|
1651 - | pub fn message(mut self, input: ::std::string::String) -> Self {
|
1652 - | self.message = Some(input);
|
1653 - | self
|
1654 - | }
|
1655 - | /// Consumes the builder and constructs a [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
1656 - | ///
|
1657 - | /// The builder fails to construct a [`ValidationExceptionField`](crate::model::ValidationExceptionField) if you do not provide a value for all non-`Option`al members.
|
1658 - | ///
|
1659 - | pub fn build(self) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
|
1660 - | self.build_enforcing_required_and_enum_traits()
|
1661 - | }
|
1662 - | fn build_enforcing_required_and_enum_traits(
|
1663 - | self,
|
1664 - | ) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
|
1665 - | Ok(crate::model::ValidationExceptionField {
|
1666 - | path: self.path.ok_or(ConstraintViolation::MissingPath)?,
|
1667 - | message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
|
1668 - | })
|
1669 - | }
|
1670 - | }
|
1601 + | impl crate::constrained::Constrained for crate::model::Farewell {
|
1602 + | type Unconstrained = crate::model::farewell_internal::Builder;
|
1671 1603 | }
|
1672 - | /// See [`Dialog`](crate::model::Dialog).
|
1673 - | pub(crate) mod dialog_internal {
|
1674 - |
|
1675 - | impl ::std::convert::From<Builder> for crate::model::Dialog {
|
1676 - | fn from(builder: Builder) -> Self {
|
1677 - | builder.build()
|
1678 - | }
|
1679 - | }
|
1680 - | /// A builder for [`Dialog`](crate::model::Dialog).
|
1681 - | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
1682 - | pub(crate) struct Builder {
|
1683 - | pub(crate) language: ::std::option::Option<::std::string::String>,
|
1684 - | pub(crate) greeting: ::std::option::Option<::std::string::String>,
|
1685 - | pub(crate) farewell: ::std::option::Option<crate::model::Farewell>,
|
1686 - | }
|
1687 - | impl Builder {
|
1688 - | #[allow(missing_docs)] // documentation missing in model
|
1689 - | pub(crate) fn set_language(
|
1690 - | mut self,
|
1691 - | input: Option<impl ::std::convert::Into<::std::string::String>>,
|
1692 - | ) -> Self {
|
1693 - | self.language = input.map(|v| v.into());
|
1694 - | self
|
1695 - | }
|
1696 - | #[allow(missing_docs)] // documentation missing in model
|
1697 - | pub(crate) fn set_greeting(
|
1698 - | mut self,
|
1699 - | input: impl ::std::convert::Into<::std::string::String>,
|
1700 - | ) -> Self {
|
1701 - | self.greeting = Some(input.into());
|
1702 - | self
|
1703 - | }
|
1704 - | #[allow(missing_docs)] // documentation missing in model
|
1705 - | pub(crate) fn set_farewell(
|
1706 - | mut self,
|
1707 - | input: Option<impl ::std::convert::Into<crate::model::Farewell>>,
|
1708 - | ) -> Self {
|
1709 - | self.farewell = input.map(|v| v.into());
|
1710 - | self
|
1711 - | }
|
1712 - | /// Consumes the builder and constructs a [`Dialog`](crate::model::Dialog).
|
1713 - | pub fn build(self) -> crate::model::Dialog {
|
1714 - | self.build_enforcing_all_constraints()
|
1715 - | }
|
1716 - | fn build_enforcing_all_constraints(self) -> crate::model::Dialog {
|
1717 - | crate::model::Dialog {
|
1718 - | language: self.language,
|
1719 - | greeting: self.greeting.unwrap_or_else(|| String::from("hi")),
|
1720 - | farewell: self.farewell,
|
1721 - | }
|
1722 - | }
|
1604 + | impl Farewell {
|
1605 + | /// Creates a new builder-style object to manufacture [`Farewell`](crate::model::Farewell).
|
1606 + | pub fn builder() -> crate::model::farewell::Builder {
|
1607 + | crate::model::farewell::Builder::default()
|
1723 1608 | }
|
1724 1609 | }
|
1725 - | /// See [`Dialog`](crate::model::Dialog).
|
1726 - | pub mod dialog {
|
1610 + | /// See [`ComplexNestedErrorData`](crate::model::ComplexNestedErrorData).
|
1611 + | pub mod complex_nested_error_data {
|
1727 1612 |
|
1728 - | impl ::std::convert::From<Builder> for crate::model::Dialog {
|
1613 + | impl ::std::convert::From<Builder> for crate::model::ComplexNestedErrorData {
|
1729 1614 | fn from(builder: Builder) -> Self {
|
1730 1615 | builder.build()
|
1731 1616 | }
|
1732 1617 | }
|
1733 - | /// A builder for [`Dialog`](crate::model::Dialog).
|
1618 + | /// A builder for [`ComplexNestedErrorData`](crate::model::ComplexNestedErrorData).
|
1734 1619 | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
1735 1620 | pub struct Builder {
|
1736 - | pub(crate) language: ::std::option::Option<::std::string::String>,
|
1737 - | pub(crate) greeting: ::std::option::Option<::std::string::String>,
|
1738 - | pub(crate) farewell: ::std::option::Option<crate::model::Farewell>,
|
1621 + | pub(crate) foo: ::std::option::Option<::std::string::String>,
|
1739 1622 | }
|
1740 1623 | impl Builder {
|
1741 1624 | #[allow(missing_docs)] // documentation missing in model
|
1742 - | pub fn language(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
|
1743 - | self.language = input;
|
1744 - | self
|
1745 - | }
|
1746 - | #[allow(missing_docs)] // documentation missing in model
|
1747 - | pub fn greeting(mut self, input: ::std::string::String) -> Self {
|
1748 - | self.greeting = Some(input);
|
1749 - | self
|
1750 - | }
|
1751 - | #[allow(missing_docs)] // documentation missing in model
|
1752 - | pub fn farewell(mut self, input: ::std::option::Option<crate::model::Farewell>) -> Self {
|
1753 - | self.farewell = input;
|
1625 + | pub fn foo(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
|
1626 + | self.foo = input;
|
1754 1627 | self
|
1755 1628 | }
|
1756 - | /// Consumes the builder and constructs a [`Dialog`](crate::model::Dialog).
|
1757 - | pub fn build(self) -> crate::model::Dialog {
|
1629 + | /// Consumes the builder and constructs a [`ComplexNestedErrorData`](crate::model::ComplexNestedErrorData).
|
1630 + | pub fn build(self) -> crate::model::ComplexNestedErrorData {
|
1758 1631 | self.build_enforcing_required_and_enum_traits()
|
1759 1632 | }
|
1760 - | fn build_enforcing_required_and_enum_traits(self) -> crate::model::Dialog {
|
1761 - | crate::model::Dialog {
|
1762 - | language: self.language,
|
1763 - | greeting: self.greeting.unwrap_or_else(|| String::from("hi")),
|
1764 - | farewell: self.farewell,
|
1765 - | }
|
1633 + | fn build_enforcing_required_and_enum_traits(self) -> crate::model::ComplexNestedErrorData {
|
1634 + | crate::model::ComplexNestedErrorData { foo: self.foo }
|
1766 1635 | }
|
1767 1636 | }
|
1768 1637 | }
|
1769 - | /// See [`Farewell`](crate::model::Farewell).
|
1770 - | pub(crate) mod farewell_internal {
|
1638 + | pub(crate) mod my_union_internal {
|
1771 1639 |
|
1772 - | impl ::std::convert::From<Builder> for crate::model::Farewell {
|
1773 - | fn from(builder: Builder) -> Self {
|
1774 - | builder.build()
|
1775 - | }
|
1776 - | }
|
1777 - | /// A builder for [`Farewell`](crate::model::Farewell).
|
1778 - | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
1779 - | pub(crate) struct Builder {
|
1780 - | pub(crate) phrase: ::std::option::Option<::std::string::String>,
|
1640 + | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
1641 + | #[allow(clippy::enum_variant_names)]
|
1642 + | pub(crate) enum ConstraintViolation {
|
1643 + | EnumValue(crate::model::foo_enum_internal::ConstraintViolation),
|
1781 1644 | }
|
1782 - | impl Builder {
|
1783 - | #[allow(missing_docs)] // documentation missing in model
|
1784 - | pub(crate) fn set_phrase(
|
1785 - | mut self,
|
1786 - | input: impl ::std::convert::Into<::std::string::String>,
|
1787 - | ) -> Self {
|
1788 - | self.phrase = Some(input.into());
|
1789 - | self
|
1790 - | }
|
1791 - | /// Consumes the builder and constructs a [`Farewell`](crate::model::Farewell).
|
1792 - | pub fn build(self) -> crate::model::Farewell {
|
1793 - | self.build_enforcing_all_constraints()
|
1794 - | }
|
1795 - | fn build_enforcing_all_constraints(self) -> crate::model::Farewell {
|
1796 - | crate::model::Farewell {
|
1797 - | phrase: self.phrase.unwrap_or_else(|| String::from("bye")),
|
1645 + | impl ::std::fmt::Display for ConstraintViolation {
|
1646 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1647 + | match self {
|
1648 + | Self::EnumValue(inner) => write!(f, "{inner}"),
|
1798 1649 | }
|
1799 1650 | }
|
1800 1651 | }
|
1801 - | }
|
1802 - | /// See [`Farewell`](crate::model::Farewell).
|
1803 - | pub mod farewell {
|
1804 1652 |
|
1805 - | impl ::std::convert::From<Builder> for crate::model::Farewell {
|
1806 - | fn from(builder: Builder) -> Self {
|
1807 - | builder.build()
|
1808 - | }
|
1809 - | }
|
1810 - | /// A builder for [`Farewell`](crate::model::Farewell).
|
1811 - | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
1812 - | pub struct Builder {
|
1813 - | pub(crate) phrase: ::std::option::Option<::std::string::String>,
|
1814 - | }
|
1815 - | impl Builder {
|
1816 - | #[allow(missing_docs)] // documentation missing in model
|
1817 - | pub fn phrase(mut self, input: ::std::string::String) -> Self {
|
1818 - | self.phrase = Some(input);
|
1819 - | self
|
1820 - | }
|
1821 - | /// Consumes the builder and constructs a [`Farewell`](crate::model::Farewell).
|
1822 - | pub fn build(self) -> crate::model::Farewell {
|
1823 - | self.build_enforcing_required_and_enum_traits()
|
1824 - | }
|
1825 - | fn build_enforcing_required_and_enum_traits(self) -> crate::model::Farewell {
|
1826 - | crate::model::Farewell {
|
1827 - | phrase: self.phrase.unwrap_or_else(|| String::from("bye")),
|
1653 + | impl ::std::error::Error for ConstraintViolation {}
|
1654 + | impl ConstraintViolation {
|
1655 + | pub(crate) fn as_validation_exception_field(
|
1656 + | self,
|
1657 + | path: ::std::string::String,
|
1658 + | ) -> crate::model::ValidationExceptionField {
|
1659 + | match self {
|
1660 + | Self::EnumValue(inner) => inner.as_validation_exception_field(path + "/enumValue"),
|
1828 1661 | }
|
1829 1662 | }
|
1830 1663 | }
|
1831 1664 | }
|
1832 - | /// See [`TopLevel`](crate::model::TopLevel).
|
1833 - | pub(crate) mod top_level_internal {
|
1665 + | /// See [`Defaults`](crate::model::Defaults).
|
1666 + | pub(crate) mod defaults_internal {
|
1834 1667 |
|
1835 1668 | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
1836 1669 | /// Holds one variant for each of the ways the builder can fail.
|
1837 1670 | #[non_exhaustive]
|
1838 1671 | #[allow(clippy::enum_variant_names)]
|
1839 1672 | pub(crate) enum ConstraintViolation {
|
1840 - | /// `dialog` was not provided but it is required when building `TopLevel`.
|
1841 - | MissingDialog,
|
1673 + | /// Constraint violation occurred building member `default_enum` when building `Defaults`.
|
1674 + | #[doc(hidden)]
|
1675 + | DefaultEnum(crate::model::test_enum_internal::ConstraintViolation),
|
1842 1676 | }
|
1843 1677 | impl ::std::fmt::Display for ConstraintViolation {
|
1844 1678 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1845 1679 | match self {
|
1846 - | ConstraintViolation::MissingDialog => write!(
|
1847 - | f,
|
1848 - | "`dialog` was not provided but it is required when building `TopLevel`"
|
1849 - | ),
|
1680 + | ConstraintViolation::DefaultEnum(_) => write!(f, "constraint violation occurred building member `default_enum` when building `Defaults`"),
|
1850 1681 | }
|
1851 1682 | }
|
1852 1683 | }
|
1853 1684 | impl ::std::error::Error for ConstraintViolation {}
|
1854 1685 | impl ConstraintViolation {
|
1855 1686 | pub(crate) fn as_validation_exception_field(
|
1856 1687 | self,
|
1857 1688 | path: ::std::string::String,
|
1858 1689 | ) -> crate::model::ValidationExceptionField {
|
1859 1690 | match self {
|
1860 - | ConstraintViolation::MissingDialog => crate::model::ValidationExceptionField {
|
1861 - | message: format!("Value at '{}/dialog' failed to satisfy constraint: Member must not be null", path),
|
1862 - | path: path + "/dialog",
|
1863 - | },
|
1864 - | }
|
1691 + | ConstraintViolation::DefaultEnum(inner) => {
|
1692 + | inner.as_validation_exception_field(path + "/defaultEnum")
|
1693 + | }
|
1694 + | }
|
1865 1695 | }
|
1866 1696 | }
|
1867 1697 | impl ::std::convert::From<Builder>
|
1868 - | for crate::constrained::MaybeConstrained<crate::model::TopLevel>
|
1698 + | for crate::constrained::MaybeConstrained<crate::model::Defaults>
|
1869 1699 | {
|
1870 1700 | fn from(builder: Builder) -> Self {
|
1871 1701 | Self::Unconstrained(builder)
|
1872 1702 | }
|
1873 1703 | }
|
1874 - | impl ::std::convert::TryFrom<Builder> for crate::model::TopLevel {
|
1704 + | impl ::std::convert::TryFrom<Builder> for crate::model::Defaults {
|
1875 1705 | type Error = ConstraintViolation;
|
1876 1706 |
|
1877 1707 | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
1878 1708 | builder.build()
|
1879 1709 | }
|
1880 1710 | }
|
1881 - | /// A builder for [`TopLevel`](crate::model::TopLevel).
|
1711 + | /// A builder for [`Defaults`](crate::model::Defaults).
|
1882 1712 | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
1883 1713 | pub(crate) struct Builder {
|
1884 - | pub(crate) dialog: ::std::option::Option<crate::model::Dialog>,
|
1885 - | pub(crate) dialog_list: ::std::option::Option<::std::vec::Vec<crate::model::Dialog>>,
|
1886 - | pub(crate) dialog_map: ::std::option::Option<
|
1887 - | ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
1714 + | pub(crate) default_string: ::std::option::Option<::std::string::String>,
|
1715 + | pub(crate) default_boolean: ::std::option::Option<bool>,
|
1716 + | pub(crate) default_list: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
|
1717 + | pub(crate) default_document_map:
|
1718 + | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
1719 + | pub(crate) default_document_string:
|
1720 + | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
1721 + | pub(crate) default_document_boolean:
|
1722 + | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
1723 + | pub(crate) default_document_list:
|
1724 + | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
1725 + | pub(crate) default_null_document:
|
1726 + | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
1727 + | pub(crate) default_timestamp:
|
1728 + | ::std::option::Option<::aws_smithy_http_server_python::types::DateTime>,
|
1729 + | pub(crate) default_blob:
|
1730 + | ::std::option::Option<::aws_smithy_http_server_python::types::Blob>,
|
1731 + | pub(crate) default_byte: ::std::option::Option<i8>,
|
1732 + | pub(crate) default_short: ::std::option::Option<i16>,
|
1733 + | pub(crate) default_integer: ::std::option::Option<i32>,
|
1734 + | pub(crate) default_long: ::std::option::Option<i64>,
|
1735 + | pub(crate) default_float: ::std::option::Option<f32>,
|
1736 + | pub(crate) default_double: ::std::option::Option<f64>,
|
1737 + | pub(crate) default_map: ::std::option::Option<
|
1738 + | ::std::collections::HashMap<::std::string::String, ::std::string::String>,
|
1888 1739 | >,
|
1740 + | pub(crate) default_enum:
|
1741 + | ::std::option::Option<crate::constrained::MaybeConstrained<crate::model::TestEnum>>,
|
1742 + | pub(crate) default_int_enum: ::std::option::Option<i32>,
|
1743 + | pub(crate) empty_string: ::std::option::Option<::std::string::String>,
|
1744 + | pub(crate) false_boolean: ::std::option::Option<bool>,
|
1745 + | pub(crate) empty_blob: ::std::option::Option<::aws_smithy_http_server_python::types::Blob>,
|
1746 + | pub(crate) zero_byte: ::std::option::Option<i8>,
|
1747 + | pub(crate) zero_short: ::std::option::Option<i16>,
|
1748 + | pub(crate) zero_integer: ::std::option::Option<i32>,
|
1749 + | pub(crate) zero_long: ::std::option::Option<i64>,
|
1750 + | pub(crate) zero_float: ::std::option::Option<f32>,
|
1751 + | pub(crate) zero_double: ::std::option::Option<f64>,
|
1889 1752 | }
|
1890 1753 | impl Builder {
|
1891 1754 | #[allow(missing_docs)] // documentation missing in model
|
1892 - | pub(crate) fn set_dialog(
|
1755 + | pub(crate) fn set_default_string(
|
1893 1756 | mut self,
|
1894 - | input: impl ::std::convert::Into<crate::model::Dialog>,
|
1757 + | input: impl ::std::convert::Into<::std::string::String>,
|
1895 1758 | ) -> Self {
|
1896 - | self.dialog = Some(input.into());
|
1759 + | self.default_string = Some(input.into());
|
1897 1760 | self
|
1898 1761 | }
|
1899 1762 | #[allow(missing_docs)] // documentation missing in model
|
1900 - | pub(crate) fn set_dialog_list(
|
1763 + | pub(crate) fn set_default_boolean(
|
1901 1764 | mut self,
|
1902 - | input: impl ::std::convert::Into<::std::vec::Vec<crate::model::Dialog>>,
|
1765 + | input: impl ::std::convert::Into<bool>,
|
1903 1766 | ) -> Self {
|
1904 - | self.dialog_list = Some(input.into());
|
1767 + | self.default_boolean = Some(input.into());
|
1905 1768 | self
|
1906 1769 | }
|
1907 1770 | #[allow(missing_docs)] // documentation missing in model
|
1908 - | pub(crate) fn set_dialog_map(
|
1771 + | pub(crate) fn set_default_list(
|
1909 1772 | mut self,
|
1910 - | input: impl ::std::convert::Into<
|
1911 - | ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
1773 + | input: impl ::std::convert::Into<::std::vec::Vec<::std::string::String>>,
|
1774 + | ) -> Self {
|
1775 + | self.default_list = Some(input.into());
|
1776 + | self
|
1777 + | }
|
1778 + | #[allow(missing_docs)] // documentation missing in model
|
1779 + | pub(crate) fn set_default_document_map(
|
1780 + | mut self,
|
1781 + | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Document>,
|
1782 + | ) -> Self {
|
1783 + | self.default_document_map = Some(input.into());
|
1784 + | self
|
1785 + | }
|
1786 + | #[allow(missing_docs)] // documentation missing in model
|
1787 + | pub(crate) fn set_default_document_string(
|
1788 + | mut self,
|
1789 + | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Document>,
|
1790 + | ) -> Self {
|
1791 + | self.default_document_string = Some(input.into());
|
1792 + | self
|
1793 + | }
|
1794 + | #[allow(missing_docs)] // documentation missing in model
|
1795 + | pub(crate) fn set_default_document_boolean(
|
1796 + | mut self,
|
1797 + | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Document>,
|
1798 + | ) -> Self {
|
1799 + | self.default_document_boolean = Some(input.into());
|
1800 + | self
|
1801 + | }
|
1802 + | #[allow(missing_docs)] // documentation missing in model
|
1803 + | pub(crate) fn set_default_document_list(
|
1804 + | mut self,
|
1805 + | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Document>,
|
1806 + | ) -> Self {
|
1807 + | self.default_document_list = Some(input.into());
|
1808 + | self
|
1809 + | }
|
1810 + | #[allow(missing_docs)] // documentation missing in model
|
1811 + | pub(crate) fn set_default_null_document(
|
1812 + | mut self,
|
1813 + | input: Option<
|
1814 + | impl ::std::convert::Into<::aws_smithy_http_server_python::types::Document>,
|
1912 1815 | >,
|
1913 1816 | ) -> Self {
|
1914 - | self.dialog_map = Some(input.into());
|
1817 + | self.default_null_document = input.map(|v| v.into());
|
1915 1818 | self
|
1916 1819 | }
|
1917 - | /// Consumes the builder and constructs a [`TopLevel`](crate::model::TopLevel).
|
1918 - | ///
|
1919 - | /// The builder fails to construct a [`TopLevel`](crate::model::TopLevel) if a [`ConstraintViolation`] occurs.
|
1920 - | ///
|
1921 - | pub fn build(self) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
1922 - | self.build_enforcing_all_constraints()
|
1820 + | #[allow(missing_docs)] // documentation missing in model
|
1821 + | pub(crate) fn set_default_timestamp(
|
1822 + | mut self,
|
1823 + | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::DateTime>,
|
1824 + | ) -> Self {
|
1825 + | self.default_timestamp = Some(input.into());
|
1826 + | self
|
1923 1827 | }
|
1924 - | fn build_enforcing_all_constraints(
|
1925 - | self,
|
1926 - | ) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
1927 - | Ok(crate::model::TopLevel {
|
1928 - | dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
|
1929 - | dialog_list: self.dialog_list.unwrap_or_default(),
|
1930 - | dialog_map: self.dialog_map.unwrap_or_default(),
|
1931 - | })
|
1828 + | #[allow(missing_docs)] // documentation missing in model
|
1829 + | pub(crate) fn set_default_blob(
|
1830 + | mut self,
|
1831 + | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Blob>,
|
1832 + | ) -> Self {
|
1833 + | self.default_blob = Some(input.into());
|
1834 + | self
|
1932 1835 | }
|
1933 - | }
|
1934 - | }
|
1935 - | /// See [`TopLevel`](crate::model::TopLevel).
|
1936 - | pub mod top_level {
|
1937 - |
|
1938 - | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
1939 - | /// Holds one variant for each of the ways the builder can fail.
|
1940 - | #[allow(clippy::enum_variant_names)]
|
1941 - | pub enum ConstraintViolation {
|
1942 - | /// `dialog` was not provided but it is required when building `TopLevel`.
|
1943 - | MissingDialog,
|
1944 - | }
|
1945 - | impl ::std::fmt::Display for ConstraintViolation {
|
1946 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1947 - | match self {
|
1948 - | ConstraintViolation::MissingDialog => write!(
|
1949 - | f,
|
1950 - | "`dialog` was not provided but it is required when building `TopLevel`"
|
1951 - | ),
|
1952 - | }
|
1836 + | #[allow(missing_docs)] // documentation missing in model
|
1837 + | pub(crate) fn set_default_byte(mut self, input: impl ::std::convert::Into<i8>) -> Self {
|
1838 + | self.default_byte = Some(input.into());
|
1839 + | self
|
1953 1840 | }
|
1954 - | }
|
1955 - | impl ::std::error::Error for ConstraintViolation {}
|
1956 - | impl ::std::convert::TryFrom<Builder> for crate::model::TopLevel {
|
1957 - | type Error = ConstraintViolation;
|
1958 - |
|
1959 - | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
1960 - | builder.build()
|
1841 + | #[allow(missing_docs)] // documentation missing in model
|
1842 + | pub(crate) fn set_default_short(mut self, input: impl ::std::convert::Into<i16>) -> Self {
|
1843 + | self.default_short = Some(input.into());
|
1844 + | self
|
1845 + | }
|
1846 + | #[allow(missing_docs)] // documentation missing in model
|
1847 + | pub(crate) fn set_default_integer(mut self, input: impl ::std::convert::Into<i32>) -> Self {
|
1848 + | self.default_integer = Some(input.into());
|
1849 + | self
|
1850 + | }
|
1851 + | #[allow(missing_docs)] // documentation missing in model
|
1852 + | pub(crate) fn set_default_long(mut self, input: impl ::std::convert::Into<i64>) -> Self {
|
1853 + | self.default_long = Some(input.into());
|
1854 + | self
|
1855 + | }
|
1856 + | #[allow(missing_docs)] // documentation missing in model
|
1857 + | pub(crate) fn set_default_float(mut self, input: impl ::std::convert::Into<f32>) -> Self {
|
1858 + | self.default_float = Some(input.into());
|
1859 + | self
|
1860 + | }
|
1861 + | #[allow(missing_docs)] // documentation missing in model
|
1862 + | pub(crate) fn set_default_double(mut self, input: impl ::std::convert::Into<f64>) -> Self {
|
1863 + | self.default_double = Some(input.into());
|
1864 + | self
|
1865 + | }
|
1866 + | #[allow(missing_docs)] // documentation missing in model
|
1867 + | pub(crate) fn set_default_map(
|
1868 + | mut self,
|
1869 + | input: impl ::std::convert::Into<
|
1870 + | ::std::collections::HashMap<::std::string::String, ::std::string::String>,
|
1871 + | >,
|
1872 + | ) -> Self {
|
1873 + | self.default_map = Some(input.into());
|
1874 + | self
|
1875 + | }
|
1876 + | #[allow(missing_docs)] // documentation missing in model
|
1877 + | pub(crate) fn set_default_enum(
|
1878 + | mut self,
|
1879 + | input: impl ::std::convert::Into<
|
1880 + | crate::constrained::MaybeConstrained<crate::model::TestEnum>,
|
1881 + | >,
|
1882 + | ) -> Self {
|
1883 + | self.default_enum = Some(input.into());
|
1884 + | self
|
1885 + | }
|
1886 + | #[allow(missing_docs)] // documentation missing in model
|
1887 + | pub(crate) fn set_default_int_enum(
|
1888 + | mut self,
|
1889 + | input: impl ::std::convert::Into<i32>,
|
1890 + | ) -> Self {
|
1891 + | self.default_int_enum = Some(input.into());
|
1892 + | self
|
1961 1893 | }
|
1962 - | }
|
1963 - | /// A builder for [`TopLevel`](crate::model::TopLevel).
|
1964 - | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
1965 - | pub struct Builder {
|
1966 - | pub(crate) dialog: ::std::option::Option<crate::model::Dialog>,
|
1967 - | pub(crate) dialog_list: ::std::option::Option<::std::vec::Vec<crate::model::Dialog>>,
|
1968 - | pub(crate) dialog_map: ::std::option::Option<
|
1969 - | ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
1970 - | >,
|
1971 - | }
|
1972 - | impl Builder {
|
1973 1894 | #[allow(missing_docs)] // documentation missing in model
|
1974 - | pub fn dialog(mut self, input: crate::model::Dialog) -> Self {
|
1975 - | self.dialog = Some(input);
|
1895 + | pub(crate) fn set_empty_string(
|
1896 + | mut self,
|
1897 + | input: impl ::std::convert::Into<::std::string::String>,
|
1898 + | ) -> Self {
|
1899 + | self.empty_string = Some(input.into());
|
1976 1900 | self
|
1977 1901 | }
|
1978 1902 | #[allow(missing_docs)] // documentation missing in model
|
1979 - | pub fn dialog_list(mut self, input: ::std::vec::Vec<crate::model::Dialog>) -> Self {
|
1980 - | self.dialog_list = Some(input);
|
1903 + | pub(crate) fn set_false_boolean(mut self, input: impl ::std::convert::Into<bool>) -> Self {
|
1904 + | self.false_boolean = Some(input.into());
|
1981 1905 | self
|
1982 1906 | }
|
1983 1907 | #[allow(missing_docs)] // documentation missing in model
|
1984 - | pub fn dialog_map(
|
1908 + | pub(crate) fn set_empty_blob(
|
1985 1909 | mut self,
|
1986 - | input: ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
1910 + | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Blob>,
|
1987 1911 | ) -> Self {
|
1988 - | self.dialog_map = Some(input);
|
1912 + | self.empty_blob = Some(input.into());
|
1989 1913 | self
|
1990 1914 | }
|
1991 - | /// Consumes the builder and constructs a [`TopLevel`](crate::model::TopLevel).
|
1992 - | ///
|
1993 - | /// The builder fails to construct a [`TopLevel`](crate::model::TopLevel) if you do not provide a value for all non-`Option`al members.
|
1994 - | ///
|
1995 - | pub fn build(self) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
1996 - | self.build_enforcing_required_and_enum_traits()
|
1997 - | }
|
1998 - | fn build_enforcing_required_and_enum_traits(
|
1999 - | self,
|
2000 - | ) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
2001 - | Ok(crate::model::TopLevel {
|
2002 - | dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
|
2003 - | dialog_list: self.dialog_list.unwrap_or_default(),
|
2004 - | dialog_map: self.dialog_map.unwrap_or_default(),
|
2005 - | })
|
2006 - | }
|
2007 - | }
|
2008 - | }
|
2009 - | /// See [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2010 - | pub(crate) mod client_optional_defaults_internal {
|
2011 - |
|
2012 - | impl ::std::convert::From<Builder> for crate::model::ClientOptionalDefaults {
|
2013 - | fn from(builder: Builder) -> Self {
|
2014 - | builder.build()
|
1915 + | #[allow(missing_docs)] // documentation missing in model
|
1916 + | pub(crate) fn set_zero_byte(mut self, input: impl ::std::convert::Into<i8>) -> Self {
|
1917 + | self.zero_byte = Some(input.into());
|
1918 + | self
|
2015 1919 | }
|
2016 - | }
|
2017 - | /// A builder for [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2018 - | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
2019 - | pub(crate) struct Builder {
|
2020 - | pub(crate) member: ::std::option::Option<i32>,
|
2021 - | }
|
2022 - | impl Builder {
|
2023 1920 | #[allow(missing_docs)] // documentation missing in model
|
2024 - | pub(crate) fn set_member(mut self, input: impl ::std::convert::Into<i32>) -> Self {
|
2025 - | self.member = Some(input.into());
|
1921 + | pub(crate) fn set_zero_short(mut self, input: impl ::std::convert::Into<i16>) -> Self {
|
1922 + | self.zero_short = Some(input.into());
|
2026 1923 | self
|
2027 1924 | }
|
2028 - | /// Consumes the builder and constructs a [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2029 - | pub fn build(self) -> crate::model::ClientOptionalDefaults {
|
2030 - | self.build_enforcing_all_constraints()
|
1925 + | #[allow(missing_docs)] // documentation missing in model
|
1926 + | pub(crate) fn set_zero_integer(mut self, input: impl ::std::convert::Into<i32>) -> Self {
|
1927 + | self.zero_integer = Some(input.into());
|
1928 + | self
|
2031 1929 | }
|
2032 - | fn build_enforcing_all_constraints(self) -> crate::model::ClientOptionalDefaults {
|
2033 - | crate::model::ClientOptionalDefaults {
|
2034 - | member: self.member.unwrap_or(0i32),
|
2035 - | }
|
1930 + | #[allow(missing_docs)] // documentation missing in model
|
1931 + | pub(crate) fn set_zero_long(mut self, input: impl ::std::convert::Into<i64>) -> Self {
|
1932 + | self.zero_long = Some(input.into());
|
1933 + | self
|
2036 1934 | }
|
2037 - | }
|
2038 - | }
|
2039 - | /// See [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2040 - | pub mod client_optional_defaults {
|
2041 - |
|
2042 - | impl ::std::convert::From<Builder> for crate::model::ClientOptionalDefaults {
|
2043 - | fn from(builder: Builder) -> Self {
|
2044 - | builder.build()
|
1935 + | #[allow(missing_docs)] // documentation missing in model
|
1936 + | pub(crate) fn set_zero_float(mut self, input: impl ::std::convert::Into<f32>) -> Self {
|
1937 + | self.zero_float = Some(input.into());
|
1938 + | self
|
2045 1939 | }
|
2046 - | }
|
2047 - | /// A builder for [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2048 - | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
2049 - | pub struct Builder {
|
2050 - | pub(crate) member: ::std::option::Option<i32>,
|
2051 - | }
|
2052 - | impl Builder {
|
2053 1940 | #[allow(missing_docs)] // documentation missing in model
|
2054 - | pub fn member(mut self, input: i32) -> Self {
|
2055 - | self.member = Some(input);
|
1941 + | pub(crate) fn set_zero_double(mut self, input: impl ::std::convert::Into<f64>) -> Self {
|
1942 + | self.zero_double = Some(input.into());
|
2056 1943 | self
|
2057 1944 | }
|
2058 - | /// Consumes the builder and constructs a [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2059 - | pub fn build(self) -> crate::model::ClientOptionalDefaults {
|
2060 - | self.build_enforcing_required_and_enum_traits()
|
1945 + | /// Consumes the builder and constructs a [`Defaults`](crate::model::Defaults).
|
1946 + | ///
|
1947 + | /// The builder fails to construct a [`Defaults`](crate::model::Defaults) if a [`ConstraintViolation`] occurs.
|
1948 + | ///
|
1949 + | pub fn build(self) -> Result<crate::model::Defaults, ConstraintViolation> {
|
1950 + | self.build_enforcing_all_constraints()
|
2061 1951 | }
|
2062 - | fn build_enforcing_required_and_enum_traits(self) -> crate::model::ClientOptionalDefaults {
|
2063 - | crate::model::ClientOptionalDefaults {
|
2064 - | member: self.member.unwrap_or(0i32),
|
2065 - | }
|
1952 + | fn build_enforcing_all_constraints(
|
1953 + | self,
|
1954 + | ) -> Result<crate::model::Defaults, ConstraintViolation> {
|
1955 + | Ok(crate::model::Defaults {
|
1956 + | default_string: self.default_string.unwrap_or_else(|| String::from("hi")),
|
1957 + | default_boolean: self.default_boolean.unwrap_or(true),
|
1958 + | default_list: self.default_list.unwrap_or_default(),
|
1959 + | default_document_map: self.default_document_map.unwrap_or_else(|| {
|
1960 + | ::aws_smithy_types::Document::Object(::std::collections::HashMap::new()).into()
|
1961 + | }),
|
1962 + | default_document_string: self.default_document_string.unwrap_or_else(|| {
|
1963 + | ::aws_smithy_types::Document::String(::std::string::String::from("hi")).into()
|
1964 + | }),
|
1965 + | default_document_boolean: self
|
1966 + | .default_document_boolean
|
1967 + | .unwrap_or(::aws_smithy_types::Document::Bool(true).into()),
|
1968 + | default_document_list: self.default_document_list.unwrap_or_else(|| {
|
1969 + | ::aws_smithy_types::Document::Array(::std::vec::Vec::new()).into()
|
1970 + | }),
|
1971 + | default_null_document: self.default_null_document,
|
1972 + | default_timestamp: self.default_timestamp.unwrap_or_else(|| {
|
1973 + | ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64).into()
|
1974 + | }),
|
1975 + | default_blob: self
|
1976 + | .default_blob
|
1977 + | .unwrap_or_else(|| ::aws_smithy_types::Blob::new("YWJj").into()),
|
1978 + | default_byte: self.default_byte.unwrap_or(1i8),
|
1979 + | default_short: self.default_short.unwrap_or(1i16),
|
1980 + | default_integer: self.default_integer.unwrap_or(10i32),
|
1981 + | default_long: self.default_long.unwrap_or(100i64),
|
1982 + | default_float: self.default_float.unwrap_or(1.0f32),
|
1983 + | default_double: self.default_double.unwrap_or(1.0f64),
|
1984 + | default_map: self.default_map.unwrap_or_default(),
|
1985 + | default_enum: self
|
1986 + | .default_enum
|
1987 + | .map(|v| match v {
|
1988 + | crate::constrained::MaybeConstrained::Constrained(x) => Ok(x),
|
1989 + | crate::constrained::MaybeConstrained::Unconstrained(x) => x.try_into(),
|
1990 + | })
|
1991 + | .map(|res| res.map_err(ConstraintViolation::DefaultEnum))
|
1992 + | .transpose()?
|
1993 + | .unwrap_or(
|
1994 + | "FOO"
|
1995 + | .parse::<crate::model::TestEnum>()
|
1996 + | .expect("static value validated to member"),
|
1997 + | ),
|
1998 + | default_int_enum: self.default_int_enum.unwrap_or(1i32),
|
1999 + | empty_string: self.empty_string.unwrap_or_else(|| String::from("")),
|
2000 + | false_boolean: self.false_boolean.unwrap_or(false),
|
2001 + | empty_blob: self
|
2002 + | .empty_blob
|
2003 + | .unwrap_or_else(|| ::aws_smithy_types::Blob::new("").into()),
|
2004 + | zero_byte: self.zero_byte.unwrap_or(0i8),
|
2005 + | zero_short: self.zero_short.unwrap_or(0i16),
|
2006 + | zero_integer: self.zero_integer.unwrap_or(0i32),
|
2007 + | zero_long: self.zero_long.unwrap_or(0i64),
|
2008 + | zero_float: self.zero_float.unwrap_or(0.0f32),
|
2009 + | zero_double: self.zero_double.unwrap_or(0.0f64),
|
2010 + | })
|
2066 2011 | }
|
2067 2012 | }
|
2068 2013 | }
|
2069 2014 | /// See [`Defaults`](crate::model::Defaults).
|
2070 - | pub(crate) mod defaults_internal {
|
2015 + | pub mod defaults {
|
2071 2016 |
|
2072 - | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
2073 - | /// Holds one variant for each of the ways the builder can fail.
|
2074 - | #[non_exhaustive]
|
2075 - | #[allow(clippy::enum_variant_names)]
|
2076 - | pub(crate) enum ConstraintViolation {
|
2077 - | /// Constraint violation occurred building member `default_enum` when building `Defaults`.
|
2078 - | #[doc(hidden)]
|
2079 - | DefaultEnum(crate::model::test_enum_internal::ConstraintViolation),
|
2080 - | }
|
2081 - | impl ::std::fmt::Display for ConstraintViolation {
|
2082 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2083 - | match self {
|
2084 - | ConstraintViolation::DefaultEnum(_) => write!(f, "constraint violation occurred building member `default_enum` when building `Defaults`"),
|
2085 - | }
|
2086 - | }
|
2087 - | }
|
2088 - | impl ::std::error::Error for ConstraintViolation {}
|
2089 - | impl ConstraintViolation {
|
2090 - | pub(crate) fn as_validation_exception_field(
|
2091 - | self,
|
2092 - | path: ::std::string::String,
|
2093 - | ) -> crate::model::ValidationExceptionField {
|
2094 - | match self {
|
2095 - | ConstraintViolation::DefaultEnum(inner) => {
|
2096 - | inner.as_validation_exception_field(path + "/defaultEnum")
|
2097 - | }
|
2098 - | }
|
2099 - | }
|
2100 - | }
|
2101 - | impl ::std::convert::From<Builder>
|
2102 - | for crate::constrained::MaybeConstrained<crate::model::Defaults>
|
2103 - | {
|
2017 + | impl ::std::convert::From<Builder> for crate::model::Defaults {
|
2104 2018 | fn from(builder: Builder) -> Self {
|
2105 - | Self::Unconstrained(builder)
|
2106 - | }
|
2107 - | }
|
2108 - | impl ::std::convert::TryFrom<Builder> for crate::model::Defaults {
|
2109 - | type Error = ConstraintViolation;
|
2110 - |
|
2111 - | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
2112 2019 | builder.build()
|
2113 2020 | }
|
2114 2021 | }
|
2115 2022 | /// A builder for [`Defaults`](crate::model::Defaults).
|
2116 2023 | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
2117 - | pub(crate) struct Builder {
|
2024 + | pub struct Builder {
|
2118 2025 | pub(crate) default_string: ::std::option::Option<::std::string::String>,
|
2119 2026 | pub(crate) default_boolean: ::std::option::Option<bool>,
|
2120 2027 | pub(crate) default_list: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
|
2121 2028 | pub(crate) default_document_map:
|
2122 2029 | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2123 2030 | pub(crate) default_document_string:
|
2124 2031 | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2125 2032 | pub(crate) default_document_boolean:
|
2126 2033 | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2127 2034 | pub(crate) default_document_list:
|
2128 2035 | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2129 2036 | pub(crate) default_null_document:
|
2130 2037 | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2131 2038 | pub(crate) default_timestamp:
|
2132 2039 | ::std::option::Option<::aws_smithy_http_server_python::types::DateTime>,
|
2133 2040 | pub(crate) default_blob:
|
2134 2041 | ::std::option::Option<::aws_smithy_http_server_python::types::Blob>,
|
2135 2042 | pub(crate) default_byte: ::std::option::Option<i8>,
|
2136 2043 | pub(crate) default_short: ::std::option::Option<i16>,
|
2137 2044 | pub(crate) default_integer: ::std::option::Option<i32>,
|
2138 2045 | pub(crate) default_long: ::std::option::Option<i64>,
|
2139 2046 | pub(crate) default_float: ::std::option::Option<f32>,
|
2140 2047 | pub(crate) default_double: ::std::option::Option<f64>,
|
2141 2048 | pub(crate) default_map: ::std::option::Option<
|
2142 2049 | ::std::collections::HashMap<::std::string::String, ::std::string::String>,
|
2143 2050 | >,
|
2144 - | pub(crate) default_enum:
|
2145 - | ::std::option::Option<crate::constrained::MaybeConstrained<crate::model::TestEnum>>,
|
2051 + | pub(crate) default_enum: ::std::option::Option<crate::model::TestEnum>,
|
2146 2052 | pub(crate) default_int_enum: ::std::option::Option<i32>,
|
2147 2053 | pub(crate) empty_string: ::std::option::Option<::std::string::String>,
|
2148 2054 | pub(crate) false_boolean: ::std::option::Option<bool>,
|
2149 2055 | pub(crate) empty_blob: ::std::option::Option<::aws_smithy_http_server_python::types::Blob>,
|
2150 2056 | pub(crate) zero_byte: ::std::option::Option<i8>,
|
2151 2057 | pub(crate) zero_short: ::std::option::Option<i16>,
|
2152 2058 | pub(crate) zero_integer: ::std::option::Option<i32>,
|
2153 2059 | pub(crate) zero_long: ::std::option::Option<i64>,
|
2154 2060 | pub(crate) zero_float: ::std::option::Option<f32>,
|
2155 2061 | pub(crate) zero_double: ::std::option::Option<f64>,
|
2156 2062 | }
|
2157 2063 | impl Builder {
|
2158 2064 | #[allow(missing_docs)] // documentation missing in model
|
2159 - | pub(crate) fn set_default_string(
|
2160 - | mut self,
|
2161 - | input: impl ::std::convert::Into<::std::string::String>,
|
2162 - | ) -> Self {
|
2163 - | self.default_string = Some(input.into());
|
2164 - | self
|
2165 - | }
|
2166 - | #[allow(missing_docs)] // documentation missing in model
|
2167 - | pub(crate) fn set_default_boolean(
|
2168 - | mut self,
|
2169 - | input: impl ::std::convert::Into<bool>,
|
2170 - | ) -> Self {
|
2171 - | self.default_boolean = Some(input.into());
|
2065 + | pub fn default_string(mut self, input: ::std::string::String) -> Self {
|
2066 + | self.default_string = Some(input);
|
2172 2067 | self
|
2173 2068 | }
|
2174 2069 | #[allow(missing_docs)] // documentation missing in model
|
2175 - | pub(crate) fn set_default_list(
|
2176 - | mut self,
|
2177 - | input: impl ::std::convert::Into<::std::vec::Vec<::std::string::String>>,
|
2178 - | ) -> Self {
|
2179 - | self.default_list = Some(input.into());
|
2070 + | pub fn default_boolean(mut self, input: bool) -> Self {
|
2071 + | self.default_boolean = Some(input);
|
2180 2072 | self
|
2181 2073 | }
|
2182 2074 | #[allow(missing_docs)] // documentation missing in model
|
2183 - | pub(crate) fn set_default_document_map(
|
2184 - | mut self,
|
2185 - | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Document>,
|
2186 - | ) -> Self {
|
2187 - | self.default_document_map = Some(input.into());
|
2075 + | pub fn default_list(mut self, input: ::std::vec::Vec<::std::string::String>) -> Self {
|
2076 + | self.default_list = Some(input);
|
2188 2077 | self
|
2189 2078 | }
|
2190 2079 | #[allow(missing_docs)] // documentation missing in model
|
2191 - | pub(crate) fn set_default_document_string(
|
2080 + | pub fn default_document_map(
|
2192 2081 | mut self,
|
2193 - | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Document>,
|
2082 + | input: ::aws_smithy_http_server_python::types::Document,
|
2194 2083 | ) -> Self {
|
2195 - | self.default_document_string = Some(input.into());
|
2084 + | self.default_document_map = Some(input);
|
2196 2085 | self
|
2197 2086 | }
|
2198 2087 | #[allow(missing_docs)] // documentation missing in model
|
2199 - | pub(crate) fn set_default_document_boolean(
|
2088 + | pub fn default_document_string(
|
2200 2089 | mut self,
|
2201 - | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Document>,
|
2090 + | input: ::aws_smithy_http_server_python::types::Document,
|
2202 2091 | ) -> Self {
|
2203 - | self.default_document_boolean = Some(input.into());
|
2092 + | self.default_document_string = Some(input);
|
2204 2093 | self
|
2205 2094 | }
|
2206 2095 | #[allow(missing_docs)] // documentation missing in model
|
2207 - | pub(crate) fn set_default_document_list(
|
2096 + | pub fn default_document_boolean(
|
2208 2097 | mut self,
|
2209 - | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Document>,
|
2098 + | input: ::aws_smithy_http_server_python::types::Document,
|
2210 2099 | ) -> Self {
|
2211 - | self.default_document_list = Some(input.into());
|
2100 + | self.default_document_boolean = Some(input);
|
2212 2101 | self
|
2213 2102 | }
|
2214 2103 | #[allow(missing_docs)] // documentation missing in model
|
2215 - | pub(crate) fn set_default_null_document(
|
2104 + | pub fn default_document_list(
|
2216 2105 | mut self,
|
2217 - | input: Option<
|
2218 - | impl ::std::convert::Into<::aws_smithy_http_server_python::types::Document>,
|
2219 - | >,
|
2106 + | input: ::aws_smithy_http_server_python::types::Document,
|
2220 2107 | ) -> Self {
|
2221 - | self.default_null_document = input.map(|v| v.into());
|
2108 + | self.default_document_list = Some(input);
|
2222 2109 | self
|
2223 2110 | }
|
2224 2111 | #[allow(missing_docs)] // documentation missing in model
|
2225 - | pub(crate) fn set_default_timestamp(
|
2112 + | pub fn default_null_document(
|
2226 2113 | mut self,
|
2227 - | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::DateTime>,
|
2114 + | input: ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2228 2115 | ) -> Self {
|
2229 - | self.default_timestamp = Some(input.into());
|
2116 + | self.default_null_document = input;
|
2230 2117 | self
|
2231 2118 | }
|
2232 2119 | #[allow(missing_docs)] // documentation missing in model
|
2233 - | pub(crate) fn set_default_blob(
|
2120 + | pub fn default_timestamp(
|
2234 2121 | mut self,
|
2235 - | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Blob>,
|
2122 + | input: ::aws_smithy_http_server_python::types::DateTime,
|
2236 2123 | ) -> Self {
|
2237 - | self.default_blob = Some(input.into());
|
2124 + | self.default_timestamp = Some(input);
|
2238 2125 | self
|
2239 2126 | }
|
2240 2127 | #[allow(missing_docs)] // documentation missing in model
|
2241 - | pub(crate) fn set_default_byte(mut self, input: impl ::std::convert::Into<i8>) -> Self {
|
2242 - | self.default_byte = Some(input.into());
|
2128 + | pub fn default_blob(mut self, input: ::aws_smithy_http_server_python::types::Blob) -> Self {
|
2129 + | self.default_blob = Some(input);
|
2243 2130 | self
|
2244 2131 | }
|
2245 2132 | #[allow(missing_docs)] // documentation missing in model
|
2246 - | pub(crate) fn set_default_short(mut self, input: impl ::std::convert::Into<i16>) -> Self {
|
2247 - | self.default_short = Some(input.into());
|
2133 + | pub fn default_byte(mut self, input: i8) -> Self {
|
2134 + | self.default_byte = Some(input);
|
2248 2135 | self
|
2249 2136 | }
|
2250 2137 | #[allow(missing_docs)] // documentation missing in model
|
2251 - | pub(crate) fn set_default_integer(mut self, input: impl ::std::convert::Into<i32>) -> Self {
|
2252 - | self.default_integer = Some(input.into());
|
2138 + | pub fn default_short(mut self, input: i16) -> Self {
|
2139 + | self.default_short = Some(input);
|
2253 2140 | self
|
2254 2141 | }
|
2255 2142 | #[allow(missing_docs)] // documentation missing in model
|
2256 - | pub(crate) fn set_default_long(mut self, input: impl ::std::convert::Into<i64>) -> Self {
|
2257 - | self.default_long = Some(input.into());
|
2143 + | pub fn default_integer(mut self, input: i32) -> Self {
|
2144 + | self.default_integer = Some(input);
|
2258 2145 | self
|
2259 2146 | }
|
2260 2147 | #[allow(missing_docs)] // documentation missing in model
|
2261 - | pub(crate) fn set_default_float(mut self, input: impl ::std::convert::Into<f32>) -> Self {
|
2262 - | self.default_float = Some(input.into());
|
2148 + | pub fn default_long(mut self, input: i64) -> Self {
|
2149 + | self.default_long = Some(input);
|
2263 2150 | self
|
2264 2151 | }
|
2265 2152 | #[allow(missing_docs)] // documentation missing in model
|
2266 - | pub(crate) fn set_default_double(mut self, input: impl ::std::convert::Into<f64>) -> Self {
|
2267 - | self.default_double = Some(input.into());
|
2153 + | pub fn default_float(mut self, input: f32) -> Self {
|
2154 + | self.default_float = Some(input);
|
2268 2155 | self
|
2269 2156 | }
|
2270 2157 | #[allow(missing_docs)] // documentation missing in model
|
2271 - | pub(crate) fn set_default_map(
|
2272 - | mut self,
|
2273 - | input: impl ::std::convert::Into<
|
2274 - | ::std::collections::HashMap<::std::string::String, ::std::string::String>,
|
2275 - | >,
|
2276 - | ) -> Self {
|
2277 - | self.default_map = Some(input.into());
|
2158 + | pub fn default_double(mut self, input: f64) -> Self {
|
2159 + | self.default_double = Some(input);
|
2278 2160 | self
|
2279 2161 | }
|
2280 2162 | #[allow(missing_docs)] // documentation missing in model
|
2281 - | pub(crate) fn set_default_enum(
|
2163 + | pub fn default_map(
|
2282 2164 | mut self,
|
2283 - | input: impl ::std::convert::Into<
|
2284 - | crate::constrained::MaybeConstrained<crate::model::TestEnum>,
|
2285 - | >,
|
2165 + | input: ::std::collections::HashMap<::std::string::String, ::std::string::String>,
|
2286 2166 | ) -> Self {
|
2287 - | self.default_enum = Some(input.into());
|
2167 + | self.default_map = Some(input);
|
2288 2168 | self
|
2289 2169 | }
|
2290 2170 | #[allow(missing_docs)] // documentation missing in model
|
2291 - | pub(crate) fn set_default_int_enum(
|
2292 - | mut self,
|
2293 - | input: impl ::std::convert::Into<i32>,
|
2294 - | ) -> Self {
|
2295 - | self.default_int_enum = Some(input.into());
|
2171 + | pub fn default_enum(mut self, input: crate::model::TestEnum) -> Self {
|
2172 + | self.default_enum = Some(input);
|
2296 2173 | self
|
2297 2174 | }
|
2298 2175 | #[allow(missing_docs)] // documentation missing in model
|
2299 - | pub(crate) fn set_empty_string(
|
2300 - | mut self,
|
2301 - | input: impl ::std::convert::Into<::std::string::String>,
|
2302 - | ) -> Self {
|
2303 - | self.empty_string = Some(input.into());
|
2176 + | pub fn default_int_enum(mut self, input: i32) -> Self {
|
2177 + | self.default_int_enum = Some(input);
|
2304 2178 | self
|
2305 2179 | }
|
2306 2180 | #[allow(missing_docs)] // documentation missing in model
|
2307 - | pub(crate) fn set_false_boolean(mut self, input: impl ::std::convert::Into<bool>) -> Self {
|
2308 - | self.false_boolean = Some(input.into());
|
2181 + | pub fn empty_string(mut self, input: ::std::string::String) -> Self {
|
2182 + | self.empty_string = Some(input);
|
2309 2183 | self
|
2310 2184 | }
|
2311 2185 | #[allow(missing_docs)] // documentation missing in model
|
2312 - | pub(crate) fn set_empty_blob(
|
2313 - | mut self,
|
2314 - | input: impl ::std::convert::Into<::aws_smithy_http_server_python::types::Blob>,
|
2315 - | ) -> Self {
|
2316 - | self.empty_blob = Some(input.into());
|
2186 + | pub fn false_boolean(mut self, input: bool) -> Self {
|
2187 + | self.false_boolean = Some(input);
|
2317 2188 | self
|
2318 2189 | }
|
2319 2190 | #[allow(missing_docs)] // documentation missing in model
|
2320 - | pub(crate) fn set_zero_byte(mut self, input: impl ::std::convert::Into<i8>) -> Self {
|
2321 - | self.zero_byte = Some(input.into());
|
2191 + | pub fn empty_blob(mut self, input: ::aws_smithy_http_server_python::types::Blob) -> Self {
|
2192 + | self.empty_blob = Some(input);
|
2322 2193 | self
|
2323 2194 | }
|
2324 2195 | #[allow(missing_docs)] // documentation missing in model
|
2325 - | pub(crate) fn set_zero_short(mut self, input: impl ::std::convert::Into<i16>) -> Self {
|
2326 - | self.zero_short = Some(input.into());
|
2196 + | pub fn zero_byte(mut self, input: i8) -> Self {
|
2197 + | self.zero_byte = Some(input);
|
2327 2198 | self
|
2328 2199 | }
|
2329 2200 | #[allow(missing_docs)] // documentation missing in model
|
2330 - | pub(crate) fn set_zero_integer(mut self, input: impl ::std::convert::Into<i32>) -> Self {
|
2331 - | self.zero_integer = Some(input.into());
|
2201 + | pub fn zero_short(mut self, input: i16) -> Self {
|
2202 + | self.zero_short = Some(input);
|
2332 2203 | self
|
2333 2204 | }
|
2334 2205 | #[allow(missing_docs)] // documentation missing in model
|
2335 - | pub(crate) fn set_zero_long(mut self, input: impl ::std::convert::Into<i64>) -> Self {
|
2336 - | self.zero_long = Some(input.into());
|
2206 + | pub fn zero_integer(mut self, input: i32) -> Self {
|
2207 + | self.zero_integer = Some(input);
|
2337 2208 | self
|
2338 2209 | }
|
2339 2210 | #[allow(missing_docs)] // documentation missing in model
|
2340 - | pub(crate) fn set_zero_float(mut self, input: impl ::std::convert::Into<f32>) -> Self {
|
2341 - | self.zero_float = Some(input.into());
|
2211 + | pub fn zero_long(mut self, input: i64) -> Self {
|
2212 + | self.zero_long = Some(input);
|
2342 2213 | self
|
2343 2214 | }
|
2344 2215 | #[allow(missing_docs)] // documentation missing in model
|
2345 - | pub(crate) fn set_zero_double(mut self, input: impl ::std::convert::Into<f64>) -> Self {
|
2346 - | self.zero_double = Some(input.into());
|
2216 + | pub fn zero_float(mut self, input: f32) -> Self {
|
2217 + | self.zero_float = Some(input);
|
2218 + | self
|
2219 + | }
|
2220 + | #[allow(missing_docs)] // documentation missing in model
|
2221 + | pub fn zero_double(mut self, input: f64) -> Self {
|
2222 + | self.zero_double = Some(input);
|
2347 2223 | self
|
2348 2224 | }
|
2349 2225 | /// Consumes the builder and constructs a [`Defaults`](crate::model::Defaults).
|
2350 - | ///
|
2351 - | /// The builder fails to construct a [`Defaults`](crate::model::Defaults) if a [`ConstraintViolation`] occurs.
|
2352 - | ///
|
2353 - | pub fn build(self) -> Result<crate::model::Defaults, ConstraintViolation> {
|
2354 - | self.build_enforcing_all_constraints()
|
2226 + | pub fn build(self) -> crate::model::Defaults {
|
2227 + | self.build_enforcing_required_and_enum_traits()
|
2355 2228 | }
|
2356 - | fn build_enforcing_all_constraints(
|
2357 - | self,
|
2358 - | ) -> Result<crate::model::Defaults, ConstraintViolation> {
|
2359 - | Ok(crate::model::Defaults {
|
2229 + | fn build_enforcing_required_and_enum_traits(self) -> crate::model::Defaults {
|
2230 + | crate::model::Defaults {
|
2360 2231 | default_string: self.default_string.unwrap_or_else(|| String::from("hi")),
|
2361 2232 | default_boolean: self.default_boolean.unwrap_or(true),
|
2362 2233 | default_list: self.default_list.unwrap_or_default(),
|
2363 2234 | default_document_map: self.default_document_map.unwrap_or_else(|| {
|
2364 2235 | ::aws_smithy_types::Document::Object(::std::collections::HashMap::new()).into()
|
2365 2236 | }),
|
2366 2237 | default_document_string: self.default_document_string.unwrap_or_else(|| {
|
2367 2238 | ::aws_smithy_types::Document::String(::std::string::String::from("hi")).into()
|
2368 2239 | }),
|
2369 2240 | default_document_boolean: self
|
2370 2241 | .default_document_boolean
|
2371 2242 | .unwrap_or(::aws_smithy_types::Document::Bool(true).into()),
|
2372 2243 | default_document_list: self.default_document_list.unwrap_or_else(|| {
|
2373 2244 | ::aws_smithy_types::Document::Array(::std::vec::Vec::new()).into()
|
2374 2245 | }),
|
2375 2246 | default_null_document: self.default_null_document,
|
2376 2247 | default_timestamp: self.default_timestamp.unwrap_or_else(|| {
|
2377 2248 | ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64).into()
|
2378 2249 | }),
|
2379 2250 | default_blob: self
|
2380 2251 | .default_blob
|
2381 2252 | .unwrap_or_else(|| ::aws_smithy_types::Blob::new("YWJj").into()),
|
2382 2253 | default_byte: self.default_byte.unwrap_or(1i8),
|
2383 2254 | default_short: self.default_short.unwrap_or(1i16),
|
2384 2255 | default_integer: self.default_integer.unwrap_or(10i32),
|
2385 2256 | default_long: self.default_long.unwrap_or(100i64),
|
2386 2257 | default_float: self.default_float.unwrap_or(1.0f32),
|
2387 2258 | default_double: self.default_double.unwrap_or(1.0f64),
|
2388 2259 | default_map: self.default_map.unwrap_or_default(),
|
2389 - | default_enum: self
|
2390 - | .default_enum
|
2391 - | .map(|v| match v {
|
2392 - | crate::constrained::MaybeConstrained::Constrained(x) => Ok(x),
|
2393 - | crate::constrained::MaybeConstrained::Unconstrained(x) => x.try_into(),
|
2394 - | })
|
2395 - | .map(|res| res.map_err(ConstraintViolation::DefaultEnum))
|
2396 - | .transpose()?
|
2397 - | .unwrap_or(
|
2398 - | "FOO"
|
2399 - | .parse::<crate::model::TestEnum>()
|
2400 - | .expect("static value validated to member"),
|
2401 - | ),
|
2260 + | default_enum: self.default_enum.unwrap_or(
|
2261 + | "FOO"
|
2262 + | .parse::<crate::model::TestEnum>()
|
2263 + | .expect("static value validated to member"),
|
2264 + | ),
|
2402 2265 | default_int_enum: self.default_int_enum.unwrap_or(1i32),
|
2403 2266 | empty_string: self.empty_string.unwrap_or_else(|| String::from("")),
|
2404 2267 | false_boolean: self.false_boolean.unwrap_or(false),
|
2405 2268 | empty_blob: self
|
2406 2269 | .empty_blob
|
2407 2270 | .unwrap_or_else(|| ::aws_smithy_types::Blob::new("").into()),
|
2408 2271 | zero_byte: self.zero_byte.unwrap_or(0i8),
|
2409 2272 | zero_short: self.zero_short.unwrap_or(0i16),
|
2410 2273 | zero_integer: self.zero_integer.unwrap_or(0i32),
|
2411 2274 | zero_long: self.zero_long.unwrap_or(0i64),
|
2412 2275 | zero_float: self.zero_float.unwrap_or(0.0f32),
|
2413 2276 | zero_double: self.zero_double.unwrap_or(0.0f64),
|
2414 - | })
|
2277 + | }
|
2415 2278 | }
|
2416 2279 | }
|
2417 2280 | }
|
2418 - | /// See [`Defaults`](crate::model::Defaults).
|
2419 - | pub mod defaults {
|
2281 + | /// See [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2282 + | pub(crate) mod client_optional_defaults_internal {
|
2420 2283 |
|
2421 - | impl ::std::convert::From<Builder> for crate::model::Defaults {
|
2284 + | impl ::std::convert::From<Builder> for crate::model::ClientOptionalDefaults {
|
2422 2285 | fn from(builder: Builder) -> Self {
|
2423 2286 | builder.build()
|
2424 2287 | }
|
2425 2288 | }
|
2426 - | /// A builder for [`Defaults`](crate::model::Defaults).
|
2289 + | /// A builder for [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2290 + | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
2291 + | pub(crate) struct Builder {
|
2292 + | pub(crate) member: ::std::option::Option<i32>,
|
2293 + | }
|
2294 + | impl Builder {
|
2295 + | #[allow(missing_docs)] // documentation missing in model
|
2296 + | pub(crate) fn set_member(mut self, input: impl ::std::convert::Into<i32>) -> Self {
|
2297 + | self.member = Some(input.into());
|
2298 + | self
|
2299 + | }
|
2300 + | /// Consumes the builder and constructs a [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2301 + | pub fn build(self) -> crate::model::ClientOptionalDefaults {
|
2302 + | self.build_enforcing_all_constraints()
|
2303 + | }
|
2304 + | fn build_enforcing_all_constraints(self) -> crate::model::ClientOptionalDefaults {
|
2305 + | crate::model::ClientOptionalDefaults {
|
2306 + | member: self.member.unwrap_or(0i32),
|
2307 + | }
|
2308 + | }
|
2309 + | }
|
2310 + | }
|
2311 + | /// See [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2312 + | pub mod client_optional_defaults {
|
2313 + |
|
2314 + | impl ::std::convert::From<Builder> for crate::model::ClientOptionalDefaults {
|
2315 + | fn from(builder: Builder) -> Self {
|
2316 + | builder.build()
|
2317 + | }
|
2318 + | }
|
2319 + | /// A builder for [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2427 2320 | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
2428 2321 | pub struct Builder {
|
2429 - | pub(crate) default_string: ::std::option::Option<::std::string::String>,
|
2430 - | pub(crate) default_boolean: ::std::option::Option<bool>,
|
2431 - | pub(crate) default_list: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
|
2432 - | pub(crate) default_document_map:
|
2433 - | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2434 - | pub(crate) default_document_string:
|
2435 - | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2436 - | pub(crate) default_document_boolean:
|
2437 - | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2438 - | pub(crate) default_document_list:
|
2439 - | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2440 - | pub(crate) default_null_document:
|
2441 - | ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2442 - | pub(crate) default_timestamp:
|
2443 - | ::std::option::Option<::aws_smithy_http_server_python::types::DateTime>,
|
2444 - | pub(crate) default_blob:
|
2445 - | ::std::option::Option<::aws_smithy_http_server_python::types::Blob>,
|
2446 - | pub(crate) default_byte: ::std::option::Option<i8>,
|
2447 - | pub(crate) default_short: ::std::option::Option<i16>,
|
2448 - | pub(crate) default_integer: ::std::option::Option<i32>,
|
2449 - | pub(crate) default_long: ::std::option::Option<i64>,
|
2450 - | pub(crate) default_float: ::std::option::Option<f32>,
|
2451 - | pub(crate) default_double: ::std::option::Option<f64>,
|
2452 - | pub(crate) default_map: ::std::option::Option<
|
2453 - | ::std::collections::HashMap<::std::string::String, ::std::string::String>,
|
2454 - | >,
|
2455 - | pub(crate) default_enum: ::std::option::Option<crate::model::TestEnum>,
|
2456 - | pub(crate) default_int_enum: ::std::option::Option<i32>,
|
2457 - | pub(crate) empty_string: ::std::option::Option<::std::string::String>,
|
2458 - | pub(crate) false_boolean: ::std::option::Option<bool>,
|
2459 - | pub(crate) empty_blob: ::std::option::Option<::aws_smithy_http_server_python::types::Blob>,
|
2460 - | pub(crate) zero_byte: ::std::option::Option<i8>,
|
2461 - | pub(crate) zero_short: ::std::option::Option<i16>,
|
2462 - | pub(crate) zero_integer: ::std::option::Option<i32>,
|
2463 - | pub(crate) zero_long: ::std::option::Option<i64>,
|
2464 - | pub(crate) zero_float: ::std::option::Option<f32>,
|
2465 - | pub(crate) zero_double: ::std::option::Option<f64>,
|
2322 + | pub(crate) member: ::std::option::Option<i32>,
|
2323 + | }
|
2324 + | impl Builder {
|
2325 + | #[allow(missing_docs)] // documentation missing in model
|
2326 + | pub fn member(mut self, input: i32) -> Self {
|
2327 + | self.member = Some(input);
|
2328 + | self
|
2329 + | }
|
2330 + | /// Consumes the builder and constructs a [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
2331 + | pub fn build(self) -> crate::model::ClientOptionalDefaults {
|
2332 + | self.build_enforcing_required_and_enum_traits()
|
2333 + | }
|
2334 + | fn build_enforcing_required_and_enum_traits(self) -> crate::model::ClientOptionalDefaults {
|
2335 + | crate::model::ClientOptionalDefaults {
|
2336 + | member: self.member.unwrap_or(0i32),
|
2337 + | }
|
2338 + | }
|
2339 + | }
|
2340 + | }
|
2341 + | /// See [`TopLevel`](crate::model::TopLevel).
|
2342 + | pub(crate) mod top_level_internal {
|
2343 + |
|
2344 + | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
2345 + | /// Holds one variant for each of the ways the builder can fail.
|
2346 + | #[non_exhaustive]
|
2347 + | #[allow(clippy::enum_variant_names)]
|
2348 + | pub(crate) enum ConstraintViolation {
|
2349 + | /// `dialog` was not provided but it is required when building `TopLevel`.
|
2350 + | MissingDialog,
|
2466 2351 | }
|
2467 - | impl Builder {
|
2468 - | #[allow(missing_docs)] // documentation missing in model
|
2469 - | pub fn default_string(mut self, input: ::std::string::String) -> Self {
|
2470 - | self.default_string = Some(input);
|
2471 - | self
|
2472 - | }
|
2473 - | #[allow(missing_docs)] // documentation missing in model
|
2474 - | pub fn default_boolean(mut self, input: bool) -> Self {
|
2475 - | self.default_boolean = Some(input);
|
2476 - | self
|
2352 + | impl ::std::fmt::Display for ConstraintViolation {
|
2353 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2354 + | match self {
|
2355 + | ConstraintViolation::MissingDialog => write!(
|
2356 + | f,
|
2357 + | "`dialog` was not provided but it is required when building `TopLevel`"
|
2358 + | ),
|
2359 + | }
|
2477 2360 | }
|
2478 - | #[allow(missing_docs)] // documentation missing in model
|
2479 - | pub fn default_list(mut self, input: ::std::vec::Vec<::std::string::String>) -> Self {
|
2480 - | self.default_list = Some(input);
|
2481 - | self
|
2361 + | }
|
2362 + | impl ::std::error::Error for ConstraintViolation {}
|
2363 + | impl ConstraintViolation {
|
2364 + | pub(crate) fn as_validation_exception_field(
|
2365 + | self,
|
2366 + | path: ::std::string::String,
|
2367 + | ) -> crate::model::ValidationExceptionField {
|
2368 + | match self {
|
2369 + | ConstraintViolation::MissingDialog => crate::model::ValidationExceptionField {
|
2370 + | message: format!("Value at '{}/dialog' failed to satisfy constraint: Member must not be null", path),
|
2371 + | path: path + "/dialog",
|
2372 + | },
|
2482 2373 | }
|
2483 - | #[allow(missing_docs)] // documentation missing in model
|
2484 - | pub fn default_document_map(
|
2485 - | mut self,
|
2486 - | input: ::aws_smithy_http_server_python::types::Document,
|
2487 - | ) -> Self {
|
2488 - | self.default_document_map = Some(input);
|
2489 - | self
|
2490 2374 | }
|
2491 - | #[allow(missing_docs)] // documentation missing in model
|
2492 - | pub fn default_document_string(
|
2493 - | mut self,
|
2494 - | input: ::aws_smithy_http_server_python::types::Document,
|
2495 - | ) -> Self {
|
2496 - | self.default_document_string = Some(input);
|
2497 - | self
|
2375 + | }
|
2376 + | impl ::std::convert::From<Builder>
|
2377 + | for crate::constrained::MaybeConstrained<crate::model::TopLevel>
|
2378 + | {
|
2379 + | fn from(builder: Builder) -> Self {
|
2380 + | Self::Unconstrained(builder)
|
2498 2381 | }
|
2499 - | #[allow(missing_docs)] // documentation missing in model
|
2500 - | pub fn default_document_boolean(
|
2501 - | mut self,
|
2502 - | input: ::aws_smithy_http_server_python::types::Document,
|
2503 - | ) -> Self {
|
2504 - | self.default_document_boolean = Some(input);
|
2505 - | self
|
2382 + | }
|
2383 + | impl ::std::convert::TryFrom<Builder> for crate::model::TopLevel {
|
2384 + | type Error = ConstraintViolation;
|
2385 + |
|
2386 + | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
2387 + | builder.build()
|
2506 2388 | }
|
2389 + | }
|
2390 + | /// A builder for [`TopLevel`](crate::model::TopLevel).
|
2391 + | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
2392 + | pub(crate) struct Builder {
|
2393 + | pub(crate) dialog: ::std::option::Option<crate::model::Dialog>,
|
2394 + | pub(crate) dialog_list: ::std::option::Option<::std::vec::Vec<crate::model::Dialog>>,
|
2395 + | pub(crate) dialog_map: ::std::option::Option<
|
2396 + | ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
2397 + | >,
|
2398 + | }
|
2399 + | impl Builder {
|
2507 2400 | #[allow(missing_docs)] // documentation missing in model
|
2508 - | pub fn default_document_list(
|
2401 + | pub(crate) fn set_dialog(
|
2509 2402 | mut self,
|
2510 - | input: ::aws_smithy_http_server_python::types::Document,
|
2403 + | input: impl ::std::convert::Into<crate::model::Dialog>,
|
2511 2404 | ) -> Self {
|
2512 - | self.default_document_list = Some(input);
|
2405 + | self.dialog = Some(input.into());
|
2513 2406 | self
|
2514 2407 | }
|
2515 2408 | #[allow(missing_docs)] // documentation missing in model
|
2516 - | pub fn default_null_document(
|
2409 + | pub(crate) fn set_dialog_list(
|
2517 2410 | mut self,
|
2518 - | input: ::std::option::Option<::aws_smithy_http_server_python::types::Document>,
|
2411 + | input: impl ::std::convert::Into<::std::vec::Vec<crate::model::Dialog>>,
|
2519 2412 | ) -> Self {
|
2520 - | self.default_null_document = input;
|
2413 + | self.dialog_list = Some(input.into());
|
2521 2414 | self
|
2522 2415 | }
|
2523 2416 | #[allow(missing_docs)] // documentation missing in model
|
2524 - | pub fn default_timestamp(
|
2417 + | pub(crate) fn set_dialog_map(
|
2525 2418 | mut self,
|
2526 - | input: ::aws_smithy_http_server_python::types::DateTime,
|
2419 + | input: impl ::std::convert::Into<
|
2420 + | ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
2421 + | >,
|
2527 2422 | ) -> Self {
|
2528 - | self.default_timestamp = Some(input);
|
2529 - | self
|
2530 - | }
|
2531 - | #[allow(missing_docs)] // documentation missing in model
|
2532 - | pub fn default_blob(mut self, input: ::aws_smithy_http_server_python::types::Blob) -> Self {
|
2533 - | self.default_blob = Some(input);
|
2423 + | self.dialog_map = Some(input.into());
|
2534 2424 | self
|
2535 2425 | }
|
2536 - | #[allow(missing_docs)] // documentation missing in model
|
2537 - | pub fn default_byte(mut self, input: i8) -> Self {
|
2538 - | self.default_byte = Some(input);
|
2539 - | self
|
2426 + | /// Consumes the builder and constructs a [`TopLevel`](crate::model::TopLevel).
|
2427 + | ///
|
2428 + | /// The builder fails to construct a [`TopLevel`](crate::model::TopLevel) if a [`ConstraintViolation`] occurs.
|
2429 + | ///
|
2430 + | pub fn build(self) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
2431 + | self.build_enforcing_all_constraints()
|
2540 2432 | }
|
2541 - | #[allow(missing_docs)] // documentation missing in model
|
2542 - | pub fn default_short(mut self, input: i16) -> Self {
|
2543 - | self.default_short = Some(input);
|
2544 - | self
|
2433 + | fn build_enforcing_all_constraints(
|
2434 + | self,
|
2435 + | ) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
2436 + | Ok(crate::model::TopLevel {
|
2437 + | dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
|
2438 + | dialog_list: self.dialog_list.unwrap_or_default(),
|
2439 + | dialog_map: self.dialog_map.unwrap_or_default(),
|
2440 + | })
|
2545 2441 | }
|
2546 - | #[allow(missing_docs)] // documentation missing in model
|
2547 - | pub fn default_integer(mut self, input: i32) -> Self {
|
2548 - | self.default_integer = Some(input);
|
2549 - | self
|
2442 + | }
|
2443 + | }
|
2444 + | /// See [`TopLevel`](crate::model::TopLevel).
|
2445 + | pub mod top_level {
|
2446 + |
|
2447 + | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
2448 + | /// Holds one variant for each of the ways the builder can fail.
|
2449 + | #[allow(clippy::enum_variant_names)]
|
2450 + | pub enum ConstraintViolation {
|
2451 + | /// `dialog` was not provided but it is required when building `TopLevel`.
|
2452 + | MissingDialog,
|
2453 + | }
|
2454 + | impl ::std::fmt::Display for ConstraintViolation {
|
2455 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2456 + | match self {
|
2457 + | ConstraintViolation::MissingDialog => write!(
|
2458 + | f,
|
2459 + | "`dialog` was not provided but it is required when building `TopLevel`"
|
2460 + | ),
|
2461 + | }
|
2550 2462 | }
|
2551 - | #[allow(missing_docs)] // documentation missing in model
|
2552 - | pub fn default_long(mut self, input: i64) -> Self {
|
2553 - | self.default_long = Some(input);
|
2554 - | self
|
2463 + | }
|
2464 + | impl ::std::error::Error for ConstraintViolation {}
|
2465 + | impl ::std::convert::TryFrom<Builder> for crate::model::TopLevel {
|
2466 + | type Error = ConstraintViolation;
|
2467 + |
|
2468 + | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
2469 + | builder.build()
|
2555 2470 | }
|
2471 + | }
|
2472 + | /// A builder for [`TopLevel`](crate::model::TopLevel).
|
2473 + | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
2474 + | pub struct Builder {
|
2475 + | pub(crate) dialog: ::std::option::Option<crate::model::Dialog>,
|
2476 + | pub(crate) dialog_list: ::std::option::Option<::std::vec::Vec<crate::model::Dialog>>,
|
2477 + | pub(crate) dialog_map: ::std::option::Option<
|
2478 + | ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
2479 + | >,
|
2480 + | }
|
2481 + | impl Builder {
|
2556 2482 | #[allow(missing_docs)] // documentation missing in model
|
2557 - | pub fn default_float(mut self, input: f32) -> Self {
|
2558 - | self.default_float = Some(input);
|
2483 + | pub fn dialog(mut self, input: crate::model::Dialog) -> Self {
|
2484 + | self.dialog = Some(input);
|
2559 2485 | self
|
2560 2486 | }
|
2561 2487 | #[allow(missing_docs)] // documentation missing in model
|
2562 - | pub fn default_double(mut self, input: f64) -> Self {
|
2563 - | self.default_double = Some(input);
|
2488 + | pub fn dialog_list(mut self, input: ::std::vec::Vec<crate::model::Dialog>) -> Self {
|
2489 + | self.dialog_list = Some(input);
|
2564 2490 | self
|
2565 2491 | }
|
2566 2492 | #[allow(missing_docs)] // documentation missing in model
|
2567 - | pub fn default_map(
|
2493 + | pub fn dialog_map(
|
2568 2494 | mut self,
|
2569 - | input: ::std::collections::HashMap<::std::string::String, ::std::string::String>,
|
2495 + | input: ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
2570 2496 | ) -> Self {
|
2571 - | self.default_map = Some(input);
|
2572 - | self
|
2573 - | }
|
2574 - | #[allow(missing_docs)] // documentation missing in model
|
2575 - | pub fn default_enum(mut self, input: crate::model::TestEnum) -> Self {
|
2576 - | self.default_enum = Some(input);
|
2577 - | self
|
2578 - | }
|
2579 - | #[allow(missing_docs)] // documentation missing in model
|
2580 - | pub fn default_int_enum(mut self, input: i32) -> Self {
|
2581 - | self.default_int_enum = Some(input);
|
2582 - | self
|
2583 - | }
|
2584 - | #[allow(missing_docs)] // documentation missing in model
|
2585 - | pub fn empty_string(mut self, input: ::std::string::String) -> Self {
|
2586 - | self.empty_string = Some(input);
|
2587 - | self
|
2588 - | }
|
2589 - | #[allow(missing_docs)] // documentation missing in model
|
2590 - | pub fn false_boolean(mut self, input: bool) -> Self {
|
2591 - | self.false_boolean = Some(input);
|
2592 - | self
|
2593 - | }
|
2594 - | #[allow(missing_docs)] // documentation missing in model
|
2595 - | pub fn empty_blob(mut self, input: ::aws_smithy_http_server_python::types::Blob) -> Self {
|
2596 - | self.empty_blob = Some(input);
|
2497 + | self.dialog_map = Some(input);
|
2597 2498 | self
|
2598 2499 | }
|
2599 - | #[allow(missing_docs)] // documentation missing in model
|
2600 - | pub fn zero_byte(mut self, input: i8) -> Self {
|
2601 - | self.zero_byte = Some(input);
|
2602 - | self
|
2500 + | /// Consumes the builder and constructs a [`TopLevel`](crate::model::TopLevel).
|
2501 + | ///
|
2502 + | /// The builder fails to construct a [`TopLevel`](crate::model::TopLevel) if you do not provide a value for all non-`Option`al members.
|
2503 + | ///
|
2504 + | pub fn build(self) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
2505 + | self.build_enforcing_required_and_enum_traits()
|
2603 2506 | }
|
2604 - | #[allow(missing_docs)] // documentation missing in model
|
2605 - | pub fn zero_short(mut self, input: i16) -> Self {
|
2606 - | self.zero_short = Some(input);
|
2607 - | self
|
2507 + | fn build_enforcing_required_and_enum_traits(
|
2508 + | self,
|
2509 + | ) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
2510 + | Ok(crate::model::TopLevel {
|
2511 + | dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
|
2512 + | dialog_list: self.dialog_list.unwrap_or_default(),
|
2513 + | dialog_map: self.dialog_map.unwrap_or_default(),
|
2514 + | })
|
2608 2515 | }
|
2609 - | #[allow(missing_docs)] // documentation missing in model
|
2610 - | pub fn zero_integer(mut self, input: i32) -> Self {
|
2611 - | self.zero_integer = Some(input);
|
2612 - | self
|
2516 + | }
|
2517 + | }
|
2518 + | /// See [`Dialog`](crate::model::Dialog).
|
2519 + | pub(crate) mod dialog_internal {
|
2520 + |
|
2521 + | impl ::std::convert::From<Builder> for crate::model::Dialog {
|
2522 + | fn from(builder: Builder) -> Self {
|
2523 + | builder.build()
|
2613 2524 | }
|
2525 + | }
|
2526 + | /// A builder for [`Dialog`](crate::model::Dialog).
|
2527 + | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
2528 + | pub(crate) struct Builder {
|
2529 + | pub(crate) language: ::std::option::Option<::std::string::String>,
|
2530 + | pub(crate) greeting: ::std::option::Option<::std::string::String>,
|
2531 + | pub(crate) farewell: ::std::option::Option<crate::model::Farewell>,
|
2532 + | }
|
2533 + | impl Builder {
|
2614 2534 | #[allow(missing_docs)] // documentation missing in model
|
2615 - | pub fn zero_long(mut self, input: i64) -> Self {
|
2616 - | self.zero_long = Some(input);
|
2535 + | pub(crate) fn set_language(
|
2536 + | mut self,
|
2537 + | input: Option<impl ::std::convert::Into<::std::string::String>>,
|
2538 + | ) -> Self {
|
2539 + | self.language = input.map(|v| v.into());
|
2617 2540 | self
|
2618 2541 | }
|
2619 2542 | #[allow(missing_docs)] // documentation missing in model
|
2620 - | pub fn zero_float(mut self, input: f32) -> Self {
|
2621 - | self.zero_float = Some(input);
|
2543 + | pub(crate) fn set_greeting(
|
2544 + | mut self,
|
2545 + | input: impl ::std::convert::Into<::std::string::String>,
|
2546 + | ) -> Self {
|
2547 + | self.greeting = Some(input.into());
|
2622 2548 | self
|
2623 2549 | }
|
2624 2550 | #[allow(missing_docs)] // documentation missing in model
|
2625 - | pub fn zero_double(mut self, input: f64) -> Self {
|
2626 - | self.zero_double = Some(input);
|
2551 + | pub(crate) fn set_farewell(
|
2552 + | mut self,
|
2553 + | input: Option<impl ::std::convert::Into<crate::model::Farewell>>,
|
2554 + | ) -> Self {
|
2555 + | self.farewell = input.map(|v| v.into());
|
2627 2556 | self
|
2628 2557 | }
|
2629 - | /// Consumes the builder and constructs a [`Defaults`](crate::model::Defaults).
|
2630 - | pub fn build(self) -> crate::model::Defaults {
|
2631 - | self.build_enforcing_required_and_enum_traits()
|
2558 + | /// Consumes the builder and constructs a [`Dialog`](crate::model::Dialog).
|
2559 + | pub fn build(self) -> crate::model::Dialog {
|
2560 + | self.build_enforcing_all_constraints()
|
2632 2561 | }
|
2633 - | fn build_enforcing_required_and_enum_traits(self) -> crate::model::Defaults {
|
2634 - | crate::model::Defaults {
|
2635 - | default_string: self.default_string.unwrap_or_else(|| String::from("hi")),
|
2636 - | default_boolean: self.default_boolean.unwrap_or(true),
|
2637 - | default_list: self.default_list.unwrap_or_default(),
|
2638 - | default_document_map: self.default_document_map.unwrap_or_else(|| {
|
2639 - | ::aws_smithy_types::Document::Object(::std::collections::HashMap::new()).into()
|
2640 - | }),
|
2641 - | default_document_string: self.default_document_string.unwrap_or_else(|| {
|
2642 - | ::aws_smithy_types::Document::String(::std::string::String::from("hi")).into()
|
2643 - | }),
|
2644 - | default_document_boolean: self
|
2645 - | .default_document_boolean
|
2646 - | .unwrap_or(::aws_smithy_types::Document::Bool(true).into()),
|
2647 - | default_document_list: self.default_document_list.unwrap_or_else(|| {
|
2648 - | ::aws_smithy_types::Document::Array(::std::vec::Vec::new()).into()
|
2649 - | }),
|
2650 - | default_null_document: self.default_null_document,
|
2651 - | default_timestamp: self.default_timestamp.unwrap_or_else(|| {
|
2652 - | ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64).into()
|
2653 - | }),
|
2654 - | default_blob: self
|
2655 - | .default_blob
|
2656 - | .unwrap_or_else(|| ::aws_smithy_types::Blob::new("YWJj").into()),
|
2657 - | default_byte: self.default_byte.unwrap_or(1i8),
|
2658 - | default_short: self.default_short.unwrap_or(1i16),
|
2659 - | default_integer: self.default_integer.unwrap_or(10i32),
|
2660 - | default_long: self.default_long.unwrap_or(100i64),
|
2661 - | default_float: self.default_float.unwrap_or(1.0f32),
|
2662 - | default_double: self.default_double.unwrap_or(1.0f64),
|
2663 - | default_map: self.default_map.unwrap_or_default(),
|
2664 - | default_enum: self.default_enum.unwrap_or(
|
2665 - | "FOO"
|
2666 - | .parse::<crate::model::TestEnum>()
|
2667 - | .expect("static value validated to member"),
|
2668 - | ),
|
2669 - | default_int_enum: self.default_int_enum.unwrap_or(1i32),
|
2670 - | empty_string: self.empty_string.unwrap_or_else(|| String::from("")),
|
2671 - | false_boolean: self.false_boolean.unwrap_or(false),
|
2672 - | empty_blob: self
|
2673 - | .empty_blob
|
2674 - | .unwrap_or_else(|| ::aws_smithy_types::Blob::new("").into()),
|
2675 - | zero_byte: self.zero_byte.unwrap_or(0i8),
|
2676 - | zero_short: self.zero_short.unwrap_or(0i16),
|
2677 - | zero_integer: self.zero_integer.unwrap_or(0i32),
|
2678 - | zero_long: self.zero_long.unwrap_or(0i64),
|
2679 - | zero_float: self.zero_float.unwrap_or(0.0f32),
|
2680 - | zero_double: self.zero_double.unwrap_or(0.0f64),
|
2562 + | fn build_enforcing_all_constraints(self) -> crate::model::Dialog {
|
2563 + | crate::model::Dialog {
|
2564 + | language: self.language,
|
2565 + | greeting: self.greeting.unwrap_or_else(|| String::from("hi")),
|
2566 + | farewell: self.farewell,
|
2681 2567 | }
|
2682 2568 | }
|
2683 2569 | }
|
2684 2570 | }
|
2685 - | pub(crate) mod my_union_internal {
|
2571 + | /// See [`Dialog`](crate::model::Dialog).
|
2572 + | pub mod dialog {
|
2686 2573 |
|
2687 - | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
2688 - | #[allow(clippy::enum_variant_names)]
|
2689 - | pub(crate) enum ConstraintViolation {
|
2690 - | EnumValue(crate::model::foo_enum_internal::ConstraintViolation),
|
2691 - | }
|
2692 - | impl ::std::fmt::Display for ConstraintViolation {
|
2693 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2694 - | match self {
|
2695 - | Self::EnumValue(inner) => write!(f, "{inner}"),
|
2696 - | }
|
2574 + | impl ::std::convert::From<Builder> for crate::model::Dialog {
|
2575 + | fn from(builder: Builder) -> Self {
|
2576 + | builder.build()
|
2697 2577 | }
|
2698 2578 | }
|
2699 - |
|
2700 - | impl ::std::error::Error for ConstraintViolation {}
|
2701 - | impl ConstraintViolation {
|
2702 - | pub(crate) fn as_validation_exception_field(
|
2703 - | self,
|
2704 - | path: ::std::string::String,
|
2705 - | ) -> crate::model::ValidationExceptionField {
|
2706 - | match self {
|
2707 - | Self::EnumValue(inner) => inner.as_validation_exception_field(path + "/enumValue"),
|
2579 + | /// A builder for [`Dialog`](crate::model::Dialog).
|
2580 + | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
2581 + | pub struct Builder {
|
2582 + | pub(crate) language: ::std::option::Option<::std::string::String>,
|
2583 + | pub(crate) greeting: ::std::option::Option<::std::string::String>,
|
2584 + | pub(crate) farewell: ::std::option::Option<crate::model::Farewell>,
|
2585 + | }
|
2586 + | impl Builder {
|
2587 + | #[allow(missing_docs)] // documentation missing in model
|
2588 + | pub fn language(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
|
2589 + | self.language = input;
|
2590 + | self
|
2591 + | }
|
2592 + | #[allow(missing_docs)] // documentation missing in model
|
2593 + | pub fn greeting(mut self, input: ::std::string::String) -> Self {
|
2594 + | self.greeting = Some(input);
|
2595 + | self
|
2596 + | }
|
2597 + | #[allow(missing_docs)] // documentation missing in model
|
2598 + | pub fn farewell(mut self, input: ::std::option::Option<crate::model::Farewell>) -> Self {
|
2599 + | self.farewell = input;
|
2600 + | self
|
2601 + | }
|
2602 + | /// Consumes the builder and constructs a [`Dialog`](crate::model::Dialog).
|
2603 + | pub fn build(self) -> crate::model::Dialog {
|
2604 + | self.build_enforcing_required_and_enum_traits()
|
2605 + | }
|
2606 + | fn build_enforcing_required_and_enum_traits(self) -> crate::model::Dialog {
|
2607 + | crate::model::Dialog {
|
2608 + | language: self.language,
|
2609 + | greeting: self.greeting.unwrap_or_else(|| String::from("hi")),
|
2610 + | farewell: self.farewell,
|
2708 2611 | }
|
2709 2612 | }
|
2710 2613 | }
|
2711 2614 | }
|
2712 2615 | /// See [`GreetingStruct`](crate::model::GreetingStruct).
|
2713 2616 | pub(crate) mod greeting_struct_internal {
|
2714 2617 |
|
2715 2618 | impl ::std::convert::From<Builder> for crate::model::GreetingStruct {
|
2716 2619 | fn from(builder: Builder) -> Self {
|
2717 2620 | builder.build()
|