1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package restxmlwithnamespace
4
5import (
6	"bytes"
7	"context"
8	"fmt"
9	"github.com/aws/aws-sdk-go-v2/internal/protocoltest/restxmlwithnamespace/types"
10	smithy "github.com/aws/smithy-go"
11	"github.com/aws/smithy-go/encoding/httpbinding"
12	smithyxml "github.com/aws/smithy-go/encoding/xml"
13	"github.com/aws/smithy-go/middleware"
14	smithyhttp "github.com/aws/smithy-go/transport/http"
15)
16
17type awsRestxml_serializeOpSimpleScalarProperties struct {
18}
19
20func (*awsRestxml_serializeOpSimpleScalarProperties) ID() string {
21	return "OperationSerializer"
22}
23
24func (m *awsRestxml_serializeOpSimpleScalarProperties) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
25	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
26) {
27	request, ok := in.Request.(*smithyhttp.Request)
28	if !ok {
29		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
30	}
31
32	input, ok := in.Parameters.(*SimpleScalarPropertiesInput)
33	_ = input
34	if !ok {
35		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
36	}
37
38	opPath, opQuery := httpbinding.SplitURI("/SimpleScalarProperties")
39	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
40	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
41	request.Method = "PUT"
42	restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
43	if err != nil {
44		return out, metadata, &smithy.SerializationError{Err: err}
45	}
46
47	if err := awsRestxml_serializeOpHttpBindingsSimpleScalarPropertiesInput(input, restEncoder); err != nil {
48		return out, metadata, &smithy.SerializationError{Err: err}
49	}
50
51	restEncoder.SetHeader("Content-Type").String("application/xml")
52
53	xmlEncoder := smithyxml.NewEncoder(bytes.NewBuffer(nil))
54	rootAttr := []smithyxml.Attr{}
55	root := smithyxml.StartElement{
56		Name: smithyxml.Name{
57			Local: "SimpleScalarPropertiesInputOutput",
58		},
59		Attr: rootAttr,
60	}
61	root.Attr = append(root.Attr, smithyxml.NewNamespaceAttribute("", "https://example.com"))
62	if err := awsRestxml_serializeOpDocumentSimpleScalarPropertiesInput(input, xmlEncoder.RootElement(root)); err != nil {
63		return out, metadata, &smithy.SerializationError{Err: err}
64	}
65	if request, err = request.SetStream(bytes.NewReader(xmlEncoder.Bytes())); err != nil {
66		return out, metadata, &smithy.SerializationError{Err: err}
67	}
68
69	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
70		return out, metadata, &smithy.SerializationError{Err: err}
71	}
72	in.Request = request
73
74	return next.HandleSerialize(ctx, in)
75}
76func awsRestxml_serializeOpHttpBindingsSimpleScalarPropertiesInput(v *SimpleScalarPropertiesInput, encoder *httpbinding.Encoder) error {
77	if v == nil {
78		return fmt.Errorf("unsupported serialization of nil %T", v)
79	}
80
81	if v.Foo != nil && len(*v.Foo) > 0 {
82		locationName := "X-Foo"
83		encoder.SetHeader(locationName).String(*v.Foo)
84	}
85
86	return nil
87}
88
89func awsRestxml_serializeOpDocumentSimpleScalarPropertiesInput(v *SimpleScalarPropertiesInput, value smithyxml.Value) error {
90	defer value.Close()
91	if v.ByteValue != nil {
92		rootAttr := []smithyxml.Attr{}
93		root := smithyxml.StartElement{
94			Name: smithyxml.Name{
95				Local: "byteValue",
96			},
97			Attr: rootAttr,
98		}
99		el := value.MemberElement(root)
100		el.Byte(*v.ByteValue)
101	}
102	if v.DoubleValue != nil {
103		rootAttr := []smithyxml.Attr{}
104		root := smithyxml.StartElement{
105			Name: smithyxml.Name{
106				Local: "DoubleDribble",
107			},
108			Attr: rootAttr,
109		}
110		el := value.MemberElement(root)
111		el.Double(*v.DoubleValue)
112	}
113	if v.FalseBooleanValue != nil {
114		rootAttr := []smithyxml.Attr{}
115		root := smithyxml.StartElement{
116			Name: smithyxml.Name{
117				Local: "falseBooleanValue",
118			},
119			Attr: rootAttr,
120		}
121		el := value.MemberElement(root)
122		el.Boolean(*v.FalseBooleanValue)
123	}
124	if v.FloatValue != nil {
125		rootAttr := []smithyxml.Attr{}
126		root := smithyxml.StartElement{
127			Name: smithyxml.Name{
128				Local: "floatValue",
129			},
130			Attr: rootAttr,
131		}
132		el := value.MemberElement(root)
133		el.Float(*v.FloatValue)
134	}
135	if v.IntegerValue != nil {
136		rootAttr := []smithyxml.Attr{}
137		root := smithyxml.StartElement{
138			Name: smithyxml.Name{
139				Local: "integerValue",
140			},
141			Attr: rootAttr,
142		}
143		el := value.MemberElement(root)
144		el.Integer(*v.IntegerValue)
145	}
146	if v.LongValue != nil {
147		rootAttr := []smithyxml.Attr{}
148		root := smithyxml.StartElement{
149			Name: smithyxml.Name{
150				Local: "longValue",
151			},
152			Attr: rootAttr,
153		}
154		el := value.MemberElement(root)
155		el.Long(*v.LongValue)
156	}
157	if v.Nested != nil {
158		rootAttr := []smithyxml.Attr{}
159		rootAttr = append(rootAttr, smithyxml.NewNamespaceAttribute("xsi", "https://example.com"))
160		if v.Nested.AttrField != nil {
161			var av string
162			av = *v.Nested.AttrField
163			rootAttr = append(rootAttr, smithyxml.NewAttribute("xsi:someName", av))
164		}
165		root := smithyxml.StartElement{
166			Name: smithyxml.Name{
167				Local: "Nested",
168			},
169			Attr: rootAttr,
170		}
171		el := value.MemberElement(root)
172		if err := awsRestxml_serializeDocumentNestedWithNamespace(v.Nested, el); err != nil {
173			return err
174		}
175	}
176	if v.ShortValue != nil {
177		rootAttr := []smithyxml.Attr{}
178		root := smithyxml.StartElement{
179			Name: smithyxml.Name{
180				Local: "shortValue",
181			},
182			Attr: rootAttr,
183		}
184		el := value.MemberElement(root)
185		el.Short(*v.ShortValue)
186	}
187	if v.StringValue != nil {
188		rootAttr := []smithyxml.Attr{}
189		root := smithyxml.StartElement{
190			Name: smithyxml.Name{
191				Local: "stringValue",
192			},
193			Attr: rootAttr,
194		}
195		el := value.MemberElement(root)
196		el.String(*v.StringValue)
197	}
198	if v.TrueBooleanValue != nil {
199		rootAttr := []smithyxml.Attr{}
200		root := smithyxml.StartElement{
201			Name: smithyxml.Name{
202				Local: "trueBooleanValue",
203			},
204			Attr: rootAttr,
205		}
206		el := value.MemberElement(root)
207		el.Boolean(*v.TrueBooleanValue)
208	}
209	return nil
210}
211
212func awsRestxml_serializeDocumentNestedWithNamespace(v *types.NestedWithNamespace, value smithyxml.Value) error {
213	defer value.Close()
214	return nil
215}
216