1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package iotfleethub
4
5import (
6	"bytes"
7	"context"
8	"fmt"
9	smithy "github.com/aws/smithy-go"
10	"github.com/aws/smithy-go/encoding/httpbinding"
11	smithyjson "github.com/aws/smithy-go/encoding/json"
12	"github.com/aws/smithy-go/middleware"
13	smithyhttp "github.com/aws/smithy-go/transport/http"
14)
15
16type awsRestjson1_serializeOpCreateApplication struct {
17}
18
19func (*awsRestjson1_serializeOpCreateApplication) ID() string {
20	return "OperationSerializer"
21}
22
23func (m *awsRestjson1_serializeOpCreateApplication) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
24	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
25) {
26	request, ok := in.Request.(*smithyhttp.Request)
27	if !ok {
28		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
29	}
30
31	input, ok := in.Parameters.(*CreateApplicationInput)
32	_ = input
33	if !ok {
34		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
35	}
36
37	opPath, opQuery := httpbinding.SplitURI("/applications")
38	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
39	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
40	request.Method = "POST"
41	restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
42	if err != nil {
43		return out, metadata, &smithy.SerializationError{Err: err}
44	}
45
46	restEncoder.SetHeader("Content-Type").String("application/json")
47
48	jsonEncoder := smithyjson.NewEncoder()
49	if err := awsRestjson1_serializeOpDocumentCreateApplicationInput(input, jsonEncoder.Value); err != nil {
50		return out, metadata, &smithy.SerializationError{Err: err}
51	}
52
53	if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil {
54		return out, metadata, &smithy.SerializationError{Err: err}
55	}
56
57	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
58		return out, metadata, &smithy.SerializationError{Err: err}
59	}
60	in.Request = request
61
62	return next.HandleSerialize(ctx, in)
63}
64func awsRestjson1_serializeOpHttpBindingsCreateApplicationInput(v *CreateApplicationInput, encoder *httpbinding.Encoder) error {
65	if v == nil {
66		return fmt.Errorf("unsupported serialization of nil %T", v)
67	}
68
69	return nil
70}
71
72func awsRestjson1_serializeOpDocumentCreateApplicationInput(v *CreateApplicationInput, value smithyjson.Value) error {
73	object := value.Object()
74	defer object.Close()
75
76	if v.ApplicationDescription != nil {
77		ok := object.Key("applicationDescription")
78		ok.String(*v.ApplicationDescription)
79	}
80
81	if v.ApplicationName != nil {
82		ok := object.Key("applicationName")
83		ok.String(*v.ApplicationName)
84	}
85
86	if v.ClientToken != nil {
87		ok := object.Key("clientToken")
88		ok.String(*v.ClientToken)
89	}
90
91	if v.RoleArn != nil {
92		ok := object.Key("roleArn")
93		ok.String(*v.RoleArn)
94	}
95
96	if v.Tags != nil {
97		ok := object.Key("tags")
98		if err := awsRestjson1_serializeDocumentTagMap(v.Tags, ok); err != nil {
99			return err
100		}
101	}
102
103	return nil
104}
105
106type awsRestjson1_serializeOpDeleteApplication struct {
107}
108
109func (*awsRestjson1_serializeOpDeleteApplication) ID() string {
110	return "OperationSerializer"
111}
112
113func (m *awsRestjson1_serializeOpDeleteApplication) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
114	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
115) {
116	request, ok := in.Request.(*smithyhttp.Request)
117	if !ok {
118		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
119	}
120
121	input, ok := in.Parameters.(*DeleteApplicationInput)
122	_ = input
123	if !ok {
124		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
125	}
126
127	opPath, opQuery := httpbinding.SplitURI("/applications/{applicationId}")
128	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
129	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
130	request.Method = "DELETE"
131	restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
132	if err != nil {
133		return out, metadata, &smithy.SerializationError{Err: err}
134	}
135
136	if err := awsRestjson1_serializeOpHttpBindingsDeleteApplicationInput(input, restEncoder); err != nil {
137		return out, metadata, &smithy.SerializationError{Err: err}
138	}
139
140	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
141		return out, metadata, &smithy.SerializationError{Err: err}
142	}
143	in.Request = request
144
145	return next.HandleSerialize(ctx, in)
146}
147func awsRestjson1_serializeOpHttpBindingsDeleteApplicationInput(v *DeleteApplicationInput, encoder *httpbinding.Encoder) error {
148	if v == nil {
149		return fmt.Errorf("unsupported serialization of nil %T", v)
150	}
151
152	if v.ApplicationId == nil || len(*v.ApplicationId) == 0 {
153		return &smithy.SerializationError{Err: fmt.Errorf("input member applicationId must not be empty")}
154	}
155	if v.ApplicationId != nil {
156		if err := encoder.SetURI("applicationId").String(*v.ApplicationId); err != nil {
157			return err
158		}
159	}
160
161	if v.ClientToken != nil {
162		encoder.SetQuery("clientToken").String(*v.ClientToken)
163	}
164
165	return nil
166}
167
168type awsRestjson1_serializeOpDescribeApplication struct {
169}
170
171func (*awsRestjson1_serializeOpDescribeApplication) ID() string {
172	return "OperationSerializer"
173}
174
175func (m *awsRestjson1_serializeOpDescribeApplication) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
176	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
177) {
178	request, ok := in.Request.(*smithyhttp.Request)
179	if !ok {
180		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
181	}
182
183	input, ok := in.Parameters.(*DescribeApplicationInput)
184	_ = input
185	if !ok {
186		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
187	}
188
189	opPath, opQuery := httpbinding.SplitURI("/applications/{applicationId}")
190	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
191	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
192	request.Method = "GET"
193	restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
194	if err != nil {
195		return out, metadata, &smithy.SerializationError{Err: err}
196	}
197
198	if err := awsRestjson1_serializeOpHttpBindingsDescribeApplicationInput(input, restEncoder); err != nil {
199		return out, metadata, &smithy.SerializationError{Err: err}
200	}
201
202	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
203		return out, metadata, &smithy.SerializationError{Err: err}
204	}
205	in.Request = request
206
207	return next.HandleSerialize(ctx, in)
208}
209func awsRestjson1_serializeOpHttpBindingsDescribeApplicationInput(v *DescribeApplicationInput, encoder *httpbinding.Encoder) error {
210	if v == nil {
211		return fmt.Errorf("unsupported serialization of nil %T", v)
212	}
213
214	if v.ApplicationId == nil || len(*v.ApplicationId) == 0 {
215		return &smithy.SerializationError{Err: fmt.Errorf("input member applicationId must not be empty")}
216	}
217	if v.ApplicationId != nil {
218		if err := encoder.SetURI("applicationId").String(*v.ApplicationId); err != nil {
219			return err
220		}
221	}
222
223	return nil
224}
225
226type awsRestjson1_serializeOpListApplications struct {
227}
228
229func (*awsRestjson1_serializeOpListApplications) ID() string {
230	return "OperationSerializer"
231}
232
233func (m *awsRestjson1_serializeOpListApplications) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
234	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
235) {
236	request, ok := in.Request.(*smithyhttp.Request)
237	if !ok {
238		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
239	}
240
241	input, ok := in.Parameters.(*ListApplicationsInput)
242	_ = input
243	if !ok {
244		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
245	}
246
247	opPath, opQuery := httpbinding.SplitURI("/applications")
248	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
249	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
250	request.Method = "GET"
251	restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
252	if err != nil {
253		return out, metadata, &smithy.SerializationError{Err: err}
254	}
255
256	if err := awsRestjson1_serializeOpHttpBindingsListApplicationsInput(input, restEncoder); err != nil {
257		return out, metadata, &smithy.SerializationError{Err: err}
258	}
259
260	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
261		return out, metadata, &smithy.SerializationError{Err: err}
262	}
263	in.Request = request
264
265	return next.HandleSerialize(ctx, in)
266}
267func awsRestjson1_serializeOpHttpBindingsListApplicationsInput(v *ListApplicationsInput, encoder *httpbinding.Encoder) error {
268	if v == nil {
269		return fmt.Errorf("unsupported serialization of nil %T", v)
270	}
271
272	if v.NextToken != nil {
273		encoder.SetQuery("nextToken").String(*v.NextToken)
274	}
275
276	return nil
277}
278
279type awsRestjson1_serializeOpListTagsForResource struct {
280}
281
282func (*awsRestjson1_serializeOpListTagsForResource) ID() string {
283	return "OperationSerializer"
284}
285
286func (m *awsRestjson1_serializeOpListTagsForResource) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
287	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
288) {
289	request, ok := in.Request.(*smithyhttp.Request)
290	if !ok {
291		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
292	}
293
294	input, ok := in.Parameters.(*ListTagsForResourceInput)
295	_ = input
296	if !ok {
297		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
298	}
299
300	opPath, opQuery := httpbinding.SplitURI("/tags/{resourceArn}")
301	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
302	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
303	request.Method = "GET"
304	restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
305	if err != nil {
306		return out, metadata, &smithy.SerializationError{Err: err}
307	}
308
309	if err := awsRestjson1_serializeOpHttpBindingsListTagsForResourceInput(input, restEncoder); err != nil {
310		return out, metadata, &smithy.SerializationError{Err: err}
311	}
312
313	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
314		return out, metadata, &smithy.SerializationError{Err: err}
315	}
316	in.Request = request
317
318	return next.HandleSerialize(ctx, in)
319}
320func awsRestjson1_serializeOpHttpBindingsListTagsForResourceInput(v *ListTagsForResourceInput, encoder *httpbinding.Encoder) error {
321	if v == nil {
322		return fmt.Errorf("unsupported serialization of nil %T", v)
323	}
324
325	if v.ResourceArn == nil || len(*v.ResourceArn) == 0 {
326		return &smithy.SerializationError{Err: fmt.Errorf("input member resourceArn must not be empty")}
327	}
328	if v.ResourceArn != nil {
329		if err := encoder.SetURI("resourceArn").String(*v.ResourceArn); err != nil {
330			return err
331		}
332	}
333
334	return nil
335}
336
337type awsRestjson1_serializeOpTagResource struct {
338}
339
340func (*awsRestjson1_serializeOpTagResource) ID() string {
341	return "OperationSerializer"
342}
343
344func (m *awsRestjson1_serializeOpTagResource) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
345	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
346) {
347	request, ok := in.Request.(*smithyhttp.Request)
348	if !ok {
349		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
350	}
351
352	input, ok := in.Parameters.(*TagResourceInput)
353	_ = input
354	if !ok {
355		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
356	}
357
358	opPath, opQuery := httpbinding.SplitURI("/tags/{resourceArn}")
359	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
360	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
361	request.Method = "POST"
362	restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
363	if err != nil {
364		return out, metadata, &smithy.SerializationError{Err: err}
365	}
366
367	if err := awsRestjson1_serializeOpHttpBindingsTagResourceInput(input, restEncoder); err != nil {
368		return out, metadata, &smithy.SerializationError{Err: err}
369	}
370
371	restEncoder.SetHeader("Content-Type").String("application/json")
372
373	jsonEncoder := smithyjson.NewEncoder()
374	if err := awsRestjson1_serializeOpDocumentTagResourceInput(input, jsonEncoder.Value); err != nil {
375		return out, metadata, &smithy.SerializationError{Err: err}
376	}
377
378	if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil {
379		return out, metadata, &smithy.SerializationError{Err: err}
380	}
381
382	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
383		return out, metadata, &smithy.SerializationError{Err: err}
384	}
385	in.Request = request
386
387	return next.HandleSerialize(ctx, in)
388}
389func awsRestjson1_serializeOpHttpBindingsTagResourceInput(v *TagResourceInput, encoder *httpbinding.Encoder) error {
390	if v == nil {
391		return fmt.Errorf("unsupported serialization of nil %T", v)
392	}
393
394	if v.ResourceArn == nil || len(*v.ResourceArn) == 0 {
395		return &smithy.SerializationError{Err: fmt.Errorf("input member resourceArn must not be empty")}
396	}
397	if v.ResourceArn != nil {
398		if err := encoder.SetURI("resourceArn").String(*v.ResourceArn); err != nil {
399			return err
400		}
401	}
402
403	return nil
404}
405
406func awsRestjson1_serializeOpDocumentTagResourceInput(v *TagResourceInput, value smithyjson.Value) error {
407	object := value.Object()
408	defer object.Close()
409
410	if v.Tags != nil {
411		ok := object.Key("tags")
412		if err := awsRestjson1_serializeDocumentTagMap(v.Tags, ok); err != nil {
413			return err
414		}
415	}
416
417	return nil
418}
419
420type awsRestjson1_serializeOpUntagResource struct {
421}
422
423func (*awsRestjson1_serializeOpUntagResource) ID() string {
424	return "OperationSerializer"
425}
426
427func (m *awsRestjson1_serializeOpUntagResource) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
428	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
429) {
430	request, ok := in.Request.(*smithyhttp.Request)
431	if !ok {
432		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
433	}
434
435	input, ok := in.Parameters.(*UntagResourceInput)
436	_ = input
437	if !ok {
438		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
439	}
440
441	opPath, opQuery := httpbinding.SplitURI("/tags/{resourceArn}")
442	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
443	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
444	request.Method = "DELETE"
445	restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
446	if err != nil {
447		return out, metadata, &smithy.SerializationError{Err: err}
448	}
449
450	if err := awsRestjson1_serializeOpHttpBindingsUntagResourceInput(input, restEncoder); err != nil {
451		return out, metadata, &smithy.SerializationError{Err: err}
452	}
453
454	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
455		return out, metadata, &smithy.SerializationError{Err: err}
456	}
457	in.Request = request
458
459	return next.HandleSerialize(ctx, in)
460}
461func awsRestjson1_serializeOpHttpBindingsUntagResourceInput(v *UntagResourceInput, encoder *httpbinding.Encoder) error {
462	if v == nil {
463		return fmt.Errorf("unsupported serialization of nil %T", v)
464	}
465
466	if v.ResourceArn == nil || len(*v.ResourceArn) == 0 {
467		return &smithy.SerializationError{Err: fmt.Errorf("input member resourceArn must not be empty")}
468	}
469	if v.ResourceArn != nil {
470		if err := encoder.SetURI("resourceArn").String(*v.ResourceArn); err != nil {
471			return err
472		}
473	}
474
475	if v.TagKeys != nil {
476		for i := range v.TagKeys {
477			encoder.AddQuery("tagKeys").String(v.TagKeys[i])
478		}
479	}
480
481	return nil
482}
483
484type awsRestjson1_serializeOpUpdateApplication struct {
485}
486
487func (*awsRestjson1_serializeOpUpdateApplication) ID() string {
488	return "OperationSerializer"
489}
490
491func (m *awsRestjson1_serializeOpUpdateApplication) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
492	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
493) {
494	request, ok := in.Request.(*smithyhttp.Request)
495	if !ok {
496		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
497	}
498
499	input, ok := in.Parameters.(*UpdateApplicationInput)
500	_ = input
501	if !ok {
502		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
503	}
504
505	opPath, opQuery := httpbinding.SplitURI("/applications/{applicationId}")
506	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
507	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
508	request.Method = "PATCH"
509	restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
510	if err != nil {
511		return out, metadata, &smithy.SerializationError{Err: err}
512	}
513
514	if err := awsRestjson1_serializeOpHttpBindingsUpdateApplicationInput(input, restEncoder); err != nil {
515		return out, metadata, &smithy.SerializationError{Err: err}
516	}
517
518	restEncoder.SetHeader("Content-Type").String("application/json")
519
520	jsonEncoder := smithyjson.NewEncoder()
521	if err := awsRestjson1_serializeOpDocumentUpdateApplicationInput(input, jsonEncoder.Value); err != nil {
522		return out, metadata, &smithy.SerializationError{Err: err}
523	}
524
525	if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil {
526		return out, metadata, &smithy.SerializationError{Err: err}
527	}
528
529	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
530		return out, metadata, &smithy.SerializationError{Err: err}
531	}
532	in.Request = request
533
534	return next.HandleSerialize(ctx, in)
535}
536func awsRestjson1_serializeOpHttpBindingsUpdateApplicationInput(v *UpdateApplicationInput, encoder *httpbinding.Encoder) error {
537	if v == nil {
538		return fmt.Errorf("unsupported serialization of nil %T", v)
539	}
540
541	if v.ApplicationId == nil || len(*v.ApplicationId) == 0 {
542		return &smithy.SerializationError{Err: fmt.Errorf("input member applicationId must not be empty")}
543	}
544	if v.ApplicationId != nil {
545		if err := encoder.SetURI("applicationId").String(*v.ApplicationId); err != nil {
546			return err
547		}
548	}
549
550	return nil
551}
552
553func awsRestjson1_serializeOpDocumentUpdateApplicationInput(v *UpdateApplicationInput, value smithyjson.Value) error {
554	object := value.Object()
555	defer object.Close()
556
557	if v.ApplicationDescription != nil {
558		ok := object.Key("applicationDescription")
559		ok.String(*v.ApplicationDescription)
560	}
561
562	if v.ApplicationName != nil {
563		ok := object.Key("applicationName")
564		ok.String(*v.ApplicationName)
565	}
566
567	if v.ClientToken != nil {
568		ok := object.Key("clientToken")
569		ok.String(*v.ClientToken)
570	}
571
572	return nil
573}
574
575func awsRestjson1_serializeDocumentTagMap(v map[string]string, value smithyjson.Value) error {
576	object := value.Object()
577	defer object.Close()
578
579	for key := range v {
580		om := object.Key(key)
581		om.String(v[key])
582	}
583	return nil
584}
585