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