@@ -131,4 +131,263 @@ protocol is:
131131 MyStruct.foo=baz
132132
133133
134+ .. _aws.protocols#ec2QueryName-query-key-naming :
135+
136+ Query key resolution
137+ --------------------
138+
139+ The key component used to serialize a member in a request in ``ec2Query `` is
140+ resolved using the following process:
141+
142+ 1. Use the value of the :ref: `aws.protocols#ec2QueryName-trait ` applied to the
143+ member, if present.
144+ 2. Use the value of the :ref: `xmlName trait <xmlName-trait >` applied to the
145+ member with the first letter capitalized, if present.
146+ 3. Use the default value for the member:
147+
148+ .. list-table ::
149+ :header-rows: 1
150+ :widths: 50 50
151+
152+ * - Member location
153+ - Default value
154+ * - ``list `` member
155+ - The string literal "member"
156+ * - ``set `` member
157+ - The string literal "member"
158+ * - ``map `` key
159+ - The string literal "key"
160+ * - ``map `` value
161+ - The string literal "value"
162+ * - ``structure `` member
163+ - The :token: `member name <shape_id_member> `
164+ * - ``union `` member
165+ - The :token: `member name <shape_id_member> `
166+
167+
168+ ----------------
169+ Supported traits
170+ ----------------
171+
172+ The ``aws.protocols#ec2Query `` protocol supports the following traits
173+ that affect serialization:
174+
175+ .. list-table ::
176+ :header-rows: 1
177+ :widths: 20 80
178+
179+ * - Trait
180+ - Description
181+ * - :ref: `cors <cors-trait >`
182+ - Indicates that the service supports CORS.
183+ * - :ref: `ec2QueryName <xmlName-trait >`
184+ - By default, the form-urlencoded key segments used in serialized
185+ structures are the same as a structure member name. The ``ec2QueryName ``
186+ changes the key segment name to a custom value. See
187+ :ref: `aws.protocols#ec2QueryName-query-key-naming ` for more information.
188+ * - :ref: `xmlAttrubute <xmlAttribute-trait >`
189+ - Serializes an object property as an XML attribute rather than a nested
190+ XML element.
191+ * - :ref: `xmlFlattened <xmlFlattened-trait >`
192+ - By default, entries in lists, sets, and maps have values serialized in
193+ nested elements specific to their type. The ``xmlFlattened `` trait
194+ unwraps these elements into the containing structure.
195+ * - :ref: `xmlName <xmlName-trait >`
196+ - By default, the XML element names and form-urlencoded key segments used
197+ in serialized structures are the same as a structure member name. The
198+ ``xmlName `` trait changes the these names to a custom value. See
199+ :ref: `aws.protocols#ec2QueryName-query-key-naming ` for more information.
200+ * - :ref: `xmlNamespace <xmlNamespace-trait >`
201+ - Adds an xmlns namespace definition URI to XML element(s) generated
202+ for the targeted shape.
203+ * - :ref: `timestampFormat <timestampFormat-trait >`
204+ - Defines a custom timestamp serialization format.
205+
206+ .. important ::
207+
208+ This protocol does not support document types.
209+
210+
211+ .. |quoted shape name | replace :: ``ec2Query ``
212+ .. |name resolution text | replace :: See :ref: `aws.protocols#ec2QueryName-query-key-naming `
213+ for how to serialize a property using a custom name
214+ .. include :: aws-query-serialization.rst.template
215+
216+
217+ Examples
218+ --------
219+
220+ .. important ::
221+
222+ These examples are non-exhaustive. See the :ref: `ec2Query-compliance-tests `
223+ for a suite of compliance tests for the ``ec2Query `` protocol.
224+
225+
226+ Structures and Unions
227+ =====================
228+
229+ |query aggregate text |
230+
231+ For example, given the following:
232+
233+ .. code-block :: smithy
234+
235+ structure Ec2QueryStructuresInput {
236+ foo: String,
237+
238+ @ec2QueryName("A")
239+ HasQueryName: String,
240+
241+ @ec2QueryName("B")
242+ @xmlName("IgnoreMe")
243+ HasQueryAndXmlName: String,
244+
245+ @xmlName("c")
246+ UsesXmlName: String,
247+
248+ baz: MyStructure,
249+ }
250+
251+ structure MyStructure {
252+ temp: String,
253+ }
254+
255+ The ``x-www-form-urlencoded `` serialization is:
256+
257+ .. code-block :: text
258+
259+ Action=Ec2QueryStructures
260+ &Version=2020-07-02
261+ &foo=bar
262+ &A=example0
263+ &B=example1
264+ &C=example2
265+ &baz.temp=example3
266+
267+
268+ Collections
269+ ===========
270+
271+ |query collection text |
272+
273+ For example, given the following:
274+
275+ .. code-block :: smithy
276+
277+ structure Ec2QueryListsInput {
278+ ListArg: StringList,
279+
280+ @xmlFlattened
281+ ComplexListArg: GreetingList,
282+
283+ // Notice that the xmlName on the targeted list member is ignored.
284+ ListArgWithXmlNameMember: ListWithXmlName,
285+
286+ @ec2QueryName("Hi")
287+ @xmlName("IgnoreMe")
288+ ListArgWithXmlName: ListWithXmlName,
289+ }
290+
291+ list ListWithXmlName {
292+ @xmlName("item")
293+ member: String
294+ }
295+
296+ list StringList {
297+ member: String
298+ }
299+
300+ list GreetingList {
301+ member: GreetingStruct
302+ }
303+
304+ structure GreetingStruct {
305+ hi: String,
306+ }
307+
308+ The ``x-www-form-urlencoded `` serialization is:
309+
310+ .. code-block :: text
311+
312+ Action=Ec2QueryLists
313+ &Version=2020-07-02
314+ &ListArg.member.1=foo
315+ &ListArg.member.2=bar
316+ &ListArg.member.3=baz
317+ &ComplexListArg.1.hi=hello
318+ &ComplexListArg.2.hi=hola
319+ &ListArgWithXmlNameMember.1=A
320+ &ListArgWithXmlNameMember.2=B
321+ &Hi.1=A
322+ &Hi.2=B
323+
324+
325+ ----------------------
326+ Response serialization
327+ ----------------------
328+
329+ The ``ec2Query `` protocol serializes XML responses within an XML root node with
330+ the name of the operation's output suffixed with "Response". A nested element,
331+ with the name of the operation's output suffixed with "Result", contains the
332+ contents of the successful response.
333+
334+ The value of the ``uri `` member of the :ref: `xmlNamespace trait <xmlNamespace-trait >`
335+ is serialized in an ``xmlns `` attribute on the response's XML root node. The
336+ following is a sample response to an operation named ``XmlTest ``.
337+
338+ .. code-block :: xml
339+
340+ <XmlTestResponse xmlns =" https://example.com/" >
341+ <XmlTestResult >
342+ <testValue >Hello!</testValue >
343+ </XmlTestResult >
344+ </XmlTestResponse >
345+
346+ XML shape serialization
347+ -----------------------
348+
349+ .. include :: aws-xml-serialization.rst.template
350+
351+
352+ .. _ec2Query-errors :
353+
354+ -----------------------------
355+ Operation error serialization
356+ -----------------------------
357+
358+ Error responses in the ``ec2Query `` protocol are wrapped within an XML root
359+ node named ``Errors ``. A nested element, named ``Error ``, contains the
360+ serialized error structure members.
361+
362+ Serialized error shapes MUST also contain an additional child element ``Code ``
363+ that contains only the :token: `shape name <identifier> ` of the error's
364+ :ref: `shape-id `. This can be used to distinguish which specific error has been
365+ serialized in the response.
366+
367+ .. code-block :: xml
368+
369+ <Errors >
370+ <Error >
371+ <Type >Sender</Type >
372+ <Code >InvalidGreeting</Code >
373+ <Message >Hi</Message >
374+ <AnotherSetting >setting</AnotherSetting >
375+ </Error >
376+ <RequestId >foo-id</RequestId >
377+ </Errors >
378+
379+
380+ .. _ec2Query-compliance-tests :
381+
382+ -------------------------
383+ Protocol compliance tests
384+ -------------------------
385+
386+ A full compliance test suite is provided and SHALL be considered a normative
387+ reference: https://github.com/awslabs/smithy/tree/main/smithy-aws-protocol-tests/model/ec2Query
388+
389+ These compliance tests define a model that is used to define test cases and
390+ the expected serialized HTTP requests and responses for each case.
391+
392+
134393*TODO: Add specifications, protocol examples, etc. *
0 commit comments