serializers.go

  1// Code generated by smithy-go-codegen DO NOT EDIT.
  2
  3package ssooidc
  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_serializeOpCreateToken struct {
 17}
 18
 19func (*awsRestjson1_serializeOpCreateToken) ID() string {
 20	return "OperationSerializer"
 21}
 22
 23func (m *awsRestjson1_serializeOpCreateToken) 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.(*CreateTokenInput)
 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("/token")
 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	var restEncoder *httpbinding.Encoder
 42	if request.URL.RawPath == "" {
 43		restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
 44	} else {
 45		request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath)
 46		restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header)
 47	}
 48
 49	if err != nil {
 50		return out, metadata, &smithy.SerializationError{Err: err}
 51	}
 52
 53	restEncoder.SetHeader("Content-Type").String("application/json")
 54
 55	jsonEncoder := smithyjson.NewEncoder()
 56	if err := awsRestjson1_serializeOpDocumentCreateTokenInput(input, jsonEncoder.Value); err != nil {
 57		return out, metadata, &smithy.SerializationError{Err: err}
 58	}
 59
 60	if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil {
 61		return out, metadata, &smithy.SerializationError{Err: err}
 62	}
 63
 64	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
 65		return out, metadata, &smithy.SerializationError{Err: err}
 66	}
 67	in.Request = request
 68
 69	return next.HandleSerialize(ctx, in)
 70}
 71func awsRestjson1_serializeOpHttpBindingsCreateTokenInput(v *CreateTokenInput, encoder *httpbinding.Encoder) error {
 72	if v == nil {
 73		return fmt.Errorf("unsupported serialization of nil %T", v)
 74	}
 75
 76	return nil
 77}
 78
 79func awsRestjson1_serializeOpDocumentCreateTokenInput(v *CreateTokenInput, value smithyjson.Value) error {
 80	object := value.Object()
 81	defer object.Close()
 82
 83	if v.ClientId != nil {
 84		ok := object.Key("clientId")
 85		ok.String(*v.ClientId)
 86	}
 87
 88	if v.ClientSecret != nil {
 89		ok := object.Key("clientSecret")
 90		ok.String(*v.ClientSecret)
 91	}
 92
 93	if v.Code != nil {
 94		ok := object.Key("code")
 95		ok.String(*v.Code)
 96	}
 97
 98	if v.CodeVerifier != nil {
 99		ok := object.Key("codeVerifier")
100		ok.String(*v.CodeVerifier)
101	}
102
103	if v.DeviceCode != nil {
104		ok := object.Key("deviceCode")
105		ok.String(*v.DeviceCode)
106	}
107
108	if v.GrantType != nil {
109		ok := object.Key("grantType")
110		ok.String(*v.GrantType)
111	}
112
113	if v.RedirectUri != nil {
114		ok := object.Key("redirectUri")
115		ok.String(*v.RedirectUri)
116	}
117
118	if v.RefreshToken != nil {
119		ok := object.Key("refreshToken")
120		ok.String(*v.RefreshToken)
121	}
122
123	if v.Scope != nil {
124		ok := object.Key("scope")
125		if err := awsRestjson1_serializeDocumentScopes(v.Scope, ok); err != nil {
126			return err
127		}
128	}
129
130	return nil
131}
132
133type awsRestjson1_serializeOpCreateTokenWithIAM struct {
134}
135
136func (*awsRestjson1_serializeOpCreateTokenWithIAM) ID() string {
137	return "OperationSerializer"
138}
139
140func (m *awsRestjson1_serializeOpCreateTokenWithIAM) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
141	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
142) {
143	request, ok := in.Request.(*smithyhttp.Request)
144	if !ok {
145		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
146	}
147
148	input, ok := in.Parameters.(*CreateTokenWithIAMInput)
149	_ = input
150	if !ok {
151		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
152	}
153
154	opPath, opQuery := httpbinding.SplitURI("/token?aws_iam=t")
155	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
156	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
157	request.Method = "POST"
158	var restEncoder *httpbinding.Encoder
159	if request.URL.RawPath == "" {
160		restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
161	} else {
162		request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath)
163		restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header)
164	}
165
166	if err != nil {
167		return out, metadata, &smithy.SerializationError{Err: err}
168	}
169
170	restEncoder.SetHeader("Content-Type").String("application/json")
171
172	jsonEncoder := smithyjson.NewEncoder()
173	if err := awsRestjson1_serializeOpDocumentCreateTokenWithIAMInput(input, jsonEncoder.Value); err != nil {
174		return out, metadata, &smithy.SerializationError{Err: err}
175	}
176
177	if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil {
178		return out, metadata, &smithy.SerializationError{Err: err}
179	}
180
181	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
182		return out, metadata, &smithy.SerializationError{Err: err}
183	}
184	in.Request = request
185
186	return next.HandleSerialize(ctx, in)
187}
188func awsRestjson1_serializeOpHttpBindingsCreateTokenWithIAMInput(v *CreateTokenWithIAMInput, encoder *httpbinding.Encoder) error {
189	if v == nil {
190		return fmt.Errorf("unsupported serialization of nil %T", v)
191	}
192
193	return nil
194}
195
196func awsRestjson1_serializeOpDocumentCreateTokenWithIAMInput(v *CreateTokenWithIAMInput, value smithyjson.Value) error {
197	object := value.Object()
198	defer object.Close()
199
200	if v.Assertion != nil {
201		ok := object.Key("assertion")
202		ok.String(*v.Assertion)
203	}
204
205	if v.ClientId != nil {
206		ok := object.Key("clientId")
207		ok.String(*v.ClientId)
208	}
209
210	if v.Code != nil {
211		ok := object.Key("code")
212		ok.String(*v.Code)
213	}
214
215	if v.CodeVerifier != nil {
216		ok := object.Key("codeVerifier")
217		ok.String(*v.CodeVerifier)
218	}
219
220	if v.GrantType != nil {
221		ok := object.Key("grantType")
222		ok.String(*v.GrantType)
223	}
224
225	if v.RedirectUri != nil {
226		ok := object.Key("redirectUri")
227		ok.String(*v.RedirectUri)
228	}
229
230	if v.RefreshToken != nil {
231		ok := object.Key("refreshToken")
232		ok.String(*v.RefreshToken)
233	}
234
235	if v.RequestedTokenType != nil {
236		ok := object.Key("requestedTokenType")
237		ok.String(*v.RequestedTokenType)
238	}
239
240	if v.Scope != nil {
241		ok := object.Key("scope")
242		if err := awsRestjson1_serializeDocumentScopes(v.Scope, ok); err != nil {
243			return err
244		}
245	}
246
247	if v.SubjectToken != nil {
248		ok := object.Key("subjectToken")
249		ok.String(*v.SubjectToken)
250	}
251
252	if v.SubjectTokenType != nil {
253		ok := object.Key("subjectTokenType")
254		ok.String(*v.SubjectTokenType)
255	}
256
257	return nil
258}
259
260type awsRestjson1_serializeOpRegisterClient struct {
261}
262
263func (*awsRestjson1_serializeOpRegisterClient) ID() string {
264	return "OperationSerializer"
265}
266
267func (m *awsRestjson1_serializeOpRegisterClient) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
268	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
269) {
270	request, ok := in.Request.(*smithyhttp.Request)
271	if !ok {
272		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
273	}
274
275	input, ok := in.Parameters.(*RegisterClientInput)
276	_ = input
277	if !ok {
278		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
279	}
280
281	opPath, opQuery := httpbinding.SplitURI("/client/register")
282	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
283	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
284	request.Method = "POST"
285	var restEncoder *httpbinding.Encoder
286	if request.URL.RawPath == "" {
287		restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
288	} else {
289		request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath)
290		restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header)
291	}
292
293	if err != nil {
294		return out, metadata, &smithy.SerializationError{Err: err}
295	}
296
297	restEncoder.SetHeader("Content-Type").String("application/json")
298
299	jsonEncoder := smithyjson.NewEncoder()
300	if err := awsRestjson1_serializeOpDocumentRegisterClientInput(input, jsonEncoder.Value); err != nil {
301		return out, metadata, &smithy.SerializationError{Err: err}
302	}
303
304	if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil {
305		return out, metadata, &smithy.SerializationError{Err: err}
306	}
307
308	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
309		return out, metadata, &smithy.SerializationError{Err: err}
310	}
311	in.Request = request
312
313	return next.HandleSerialize(ctx, in)
314}
315func awsRestjson1_serializeOpHttpBindingsRegisterClientInput(v *RegisterClientInput, encoder *httpbinding.Encoder) error {
316	if v == nil {
317		return fmt.Errorf("unsupported serialization of nil %T", v)
318	}
319
320	return nil
321}
322
323func awsRestjson1_serializeOpDocumentRegisterClientInput(v *RegisterClientInput, value smithyjson.Value) error {
324	object := value.Object()
325	defer object.Close()
326
327	if v.ClientName != nil {
328		ok := object.Key("clientName")
329		ok.String(*v.ClientName)
330	}
331
332	if v.ClientType != nil {
333		ok := object.Key("clientType")
334		ok.String(*v.ClientType)
335	}
336
337	if v.EntitledApplicationArn != nil {
338		ok := object.Key("entitledApplicationArn")
339		ok.String(*v.EntitledApplicationArn)
340	}
341
342	if v.GrantTypes != nil {
343		ok := object.Key("grantTypes")
344		if err := awsRestjson1_serializeDocumentGrantTypes(v.GrantTypes, ok); err != nil {
345			return err
346		}
347	}
348
349	if v.IssuerUrl != nil {
350		ok := object.Key("issuerUrl")
351		ok.String(*v.IssuerUrl)
352	}
353
354	if v.RedirectUris != nil {
355		ok := object.Key("redirectUris")
356		if err := awsRestjson1_serializeDocumentRedirectUris(v.RedirectUris, ok); err != nil {
357			return err
358		}
359	}
360
361	if v.Scopes != nil {
362		ok := object.Key("scopes")
363		if err := awsRestjson1_serializeDocumentScopes(v.Scopes, ok); err != nil {
364			return err
365		}
366	}
367
368	return nil
369}
370
371type awsRestjson1_serializeOpStartDeviceAuthorization struct {
372}
373
374func (*awsRestjson1_serializeOpStartDeviceAuthorization) ID() string {
375	return "OperationSerializer"
376}
377
378func (m *awsRestjson1_serializeOpStartDeviceAuthorization) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
379	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
380) {
381	request, ok := in.Request.(*smithyhttp.Request)
382	if !ok {
383		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)}
384	}
385
386	input, ok := in.Parameters.(*StartDeviceAuthorizationInput)
387	_ = input
388	if !ok {
389		return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)}
390	}
391
392	opPath, opQuery := httpbinding.SplitURI("/device_authorization")
393	request.URL.Path = smithyhttp.JoinPath(request.URL.Path, opPath)
394	request.URL.RawQuery = smithyhttp.JoinRawQuery(request.URL.RawQuery, opQuery)
395	request.Method = "POST"
396	var restEncoder *httpbinding.Encoder
397	if request.URL.RawPath == "" {
398		restEncoder, err = httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header)
399	} else {
400		request.URL.RawPath = smithyhttp.JoinPath(request.URL.RawPath, opPath)
401		restEncoder, err = httpbinding.NewEncoderWithRawPath(request.URL.Path, request.URL.RawPath, request.URL.RawQuery, request.Header)
402	}
403
404	if err != nil {
405		return out, metadata, &smithy.SerializationError{Err: err}
406	}
407
408	restEncoder.SetHeader("Content-Type").String("application/json")
409
410	jsonEncoder := smithyjson.NewEncoder()
411	if err := awsRestjson1_serializeOpDocumentStartDeviceAuthorizationInput(input, jsonEncoder.Value); err != nil {
412		return out, metadata, &smithy.SerializationError{Err: err}
413	}
414
415	if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil {
416		return out, metadata, &smithy.SerializationError{Err: err}
417	}
418
419	if request.Request, err = restEncoder.Encode(request.Request); err != nil {
420		return out, metadata, &smithy.SerializationError{Err: err}
421	}
422	in.Request = request
423
424	return next.HandleSerialize(ctx, in)
425}
426func awsRestjson1_serializeOpHttpBindingsStartDeviceAuthorizationInput(v *StartDeviceAuthorizationInput, encoder *httpbinding.Encoder) error {
427	if v == nil {
428		return fmt.Errorf("unsupported serialization of nil %T", v)
429	}
430
431	return nil
432}
433
434func awsRestjson1_serializeOpDocumentStartDeviceAuthorizationInput(v *StartDeviceAuthorizationInput, value smithyjson.Value) error {
435	object := value.Object()
436	defer object.Close()
437
438	if v.ClientId != nil {
439		ok := object.Key("clientId")
440		ok.String(*v.ClientId)
441	}
442
443	if v.ClientSecret != nil {
444		ok := object.Key("clientSecret")
445		ok.String(*v.ClientSecret)
446	}
447
448	if v.StartUrl != nil {
449		ok := object.Key("startUrl")
450		ok.String(*v.StartUrl)
451	}
452
453	return nil
454}
455
456func awsRestjson1_serializeDocumentGrantTypes(v []string, value smithyjson.Value) error {
457	array := value.Array()
458	defer array.Close()
459
460	for i := range v {
461		av := array.Value()
462		av.String(v[i])
463	}
464	return nil
465}
466
467func awsRestjson1_serializeDocumentRedirectUris(v []string, value smithyjson.Value) error {
468	array := value.Array()
469	defer array.Close()
470
471	for i := range v {
472		av := array.Value()
473		av.String(v[i])
474	}
475	return nil
476}
477
478func awsRestjson1_serializeDocumentScopes(v []string, value smithyjson.Value) error {
479	array := value.Array()
480	defer array.Close()
481
482	for i := range v {
483		av := array.Value()
484		av.String(v[i])
485	}
486	return nil
487}