deserializers.go (53350B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package ssooidc 4 5 import ( 6 "bytes" 7 "context" 8 "encoding/json" 9 "fmt" 10 "github.com/aws/aws-sdk-go-v2/aws/protocol/restjson" 11 "github.com/aws/aws-sdk-go-v2/service/ssooidc/types" 12 smithy "github.com/aws/smithy-go" 13 smithyio "github.com/aws/smithy-go/io" 14 "github.com/aws/smithy-go/middleware" 15 "github.com/aws/smithy-go/ptr" 16 smithyhttp "github.com/aws/smithy-go/transport/http" 17 "io" 18 "strings" 19 ) 20 21 type awsRestjson1_deserializeOpCreateToken struct { 22 } 23 24 func (*awsRestjson1_deserializeOpCreateToken) ID() string { 25 return "OperationDeserializer" 26 } 27 28 func (m *awsRestjson1_deserializeOpCreateToken) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( 29 out middleware.DeserializeOutput, metadata middleware.Metadata, err error, 30 ) { 31 out, metadata, err = next.HandleDeserialize(ctx, in) 32 if err != nil { 33 return out, metadata, err 34 } 35 36 response, ok := out.RawResponse.(*smithyhttp.Response) 37 if !ok { 38 return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} 39 } 40 41 if response.StatusCode < 200 || response.StatusCode >= 300 { 42 return out, metadata, awsRestjson1_deserializeOpErrorCreateToken(response, &metadata) 43 } 44 output := &CreateTokenOutput{} 45 out.Result = output 46 47 var buff [1024]byte 48 ringBuffer := smithyio.NewRingBuffer(buff[:]) 49 50 body := io.TeeReader(response.Body, ringBuffer) 51 52 decoder := json.NewDecoder(body) 53 decoder.UseNumber() 54 var shape interface{} 55 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 56 var snapshot bytes.Buffer 57 io.Copy(&snapshot, ringBuffer) 58 err = &smithy.DeserializationError{ 59 Err: fmt.Errorf("failed to decode response body, %w", err), 60 Snapshot: snapshot.Bytes(), 61 } 62 return out, metadata, err 63 } 64 65 err = awsRestjson1_deserializeOpDocumentCreateTokenOutput(&output, shape) 66 if err != nil { 67 var snapshot bytes.Buffer 68 io.Copy(&snapshot, ringBuffer) 69 return out, metadata, &smithy.DeserializationError{ 70 Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), 71 Snapshot: snapshot.Bytes(), 72 } 73 } 74 75 return out, metadata, err 76 } 77 78 func awsRestjson1_deserializeOpErrorCreateToken(response *smithyhttp.Response, metadata *middleware.Metadata) error { 79 var errorBuffer bytes.Buffer 80 if _, err := io.Copy(&errorBuffer, response.Body); err != nil { 81 return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} 82 } 83 errorBody := bytes.NewReader(errorBuffer.Bytes()) 84 85 errorCode := "UnknownError" 86 errorMessage := errorCode 87 88 headerCode := response.Header.Get("X-Amzn-ErrorType") 89 if len(headerCode) != 0 { 90 errorCode = restjson.SanitizeErrorCode(headerCode) 91 } 92 93 var buff [1024]byte 94 ringBuffer := smithyio.NewRingBuffer(buff[:]) 95 96 body := io.TeeReader(errorBody, ringBuffer) 97 decoder := json.NewDecoder(body) 98 decoder.UseNumber() 99 jsonCode, message, err := restjson.GetErrorInfo(decoder) 100 if err != nil { 101 var snapshot bytes.Buffer 102 io.Copy(&snapshot, ringBuffer) 103 err = &smithy.DeserializationError{ 104 Err: fmt.Errorf("failed to decode response body, %w", err), 105 Snapshot: snapshot.Bytes(), 106 } 107 return err 108 } 109 110 errorBody.Seek(0, io.SeekStart) 111 if len(headerCode) == 0 && len(jsonCode) != 0 { 112 errorCode = restjson.SanitizeErrorCode(jsonCode) 113 } 114 if len(message) != 0 { 115 errorMessage = message 116 } 117 118 switch { 119 case strings.EqualFold("AccessDeniedException", errorCode): 120 return awsRestjson1_deserializeErrorAccessDeniedException(response, errorBody) 121 122 case strings.EqualFold("AuthorizationPendingException", errorCode): 123 return awsRestjson1_deserializeErrorAuthorizationPendingException(response, errorBody) 124 125 case strings.EqualFold("ExpiredTokenException", errorCode): 126 return awsRestjson1_deserializeErrorExpiredTokenException(response, errorBody) 127 128 case strings.EqualFold("InternalServerException", errorCode): 129 return awsRestjson1_deserializeErrorInternalServerException(response, errorBody) 130 131 case strings.EqualFold("InvalidClientException", errorCode): 132 return awsRestjson1_deserializeErrorInvalidClientException(response, errorBody) 133 134 case strings.EqualFold("InvalidGrantException", errorCode): 135 return awsRestjson1_deserializeErrorInvalidGrantException(response, errorBody) 136 137 case strings.EqualFold("InvalidRequestException", errorCode): 138 return awsRestjson1_deserializeErrorInvalidRequestException(response, errorBody) 139 140 case strings.EqualFold("InvalidScopeException", errorCode): 141 return awsRestjson1_deserializeErrorInvalidScopeException(response, errorBody) 142 143 case strings.EqualFold("SlowDownException", errorCode): 144 return awsRestjson1_deserializeErrorSlowDownException(response, errorBody) 145 146 case strings.EqualFold("UnauthorizedClientException", errorCode): 147 return awsRestjson1_deserializeErrorUnauthorizedClientException(response, errorBody) 148 149 case strings.EqualFold("UnsupportedGrantTypeException", errorCode): 150 return awsRestjson1_deserializeErrorUnsupportedGrantTypeException(response, errorBody) 151 152 default: 153 genericError := &smithy.GenericAPIError{ 154 Code: errorCode, 155 Message: errorMessage, 156 } 157 return genericError 158 159 } 160 } 161 162 func awsRestjson1_deserializeOpDocumentCreateTokenOutput(v **CreateTokenOutput, value interface{}) error { 163 if v == nil { 164 return fmt.Errorf("unexpected nil of type %T", v) 165 } 166 if value == nil { 167 return nil 168 } 169 170 shape, ok := value.(map[string]interface{}) 171 if !ok { 172 return fmt.Errorf("unexpected JSON type %v", value) 173 } 174 175 var sv *CreateTokenOutput 176 if *v == nil { 177 sv = &CreateTokenOutput{} 178 } else { 179 sv = *v 180 } 181 182 for key, value := range shape { 183 switch key { 184 case "accessToken": 185 if value != nil { 186 jtv, ok := value.(string) 187 if !ok { 188 return fmt.Errorf("expected AccessToken to be of type string, got %T instead", value) 189 } 190 sv.AccessToken = ptr.String(jtv) 191 } 192 193 case "expiresIn": 194 if value != nil { 195 jtv, ok := value.(json.Number) 196 if !ok { 197 return fmt.Errorf("expected ExpirationInSeconds to be json.Number, got %T instead", value) 198 } 199 i64, err := jtv.Int64() 200 if err != nil { 201 return err 202 } 203 sv.ExpiresIn = int32(i64) 204 } 205 206 case "idToken": 207 if value != nil { 208 jtv, ok := value.(string) 209 if !ok { 210 return fmt.Errorf("expected IdToken to be of type string, got %T instead", value) 211 } 212 sv.IdToken = ptr.String(jtv) 213 } 214 215 case "refreshToken": 216 if value != nil { 217 jtv, ok := value.(string) 218 if !ok { 219 return fmt.Errorf("expected RefreshToken to be of type string, got %T instead", value) 220 } 221 sv.RefreshToken = ptr.String(jtv) 222 } 223 224 case "tokenType": 225 if value != nil { 226 jtv, ok := value.(string) 227 if !ok { 228 return fmt.Errorf("expected TokenType to be of type string, got %T instead", value) 229 } 230 sv.TokenType = ptr.String(jtv) 231 } 232 233 default: 234 _, _ = key, value 235 236 } 237 } 238 *v = sv 239 return nil 240 } 241 242 type awsRestjson1_deserializeOpCreateTokenWithIAM struct { 243 } 244 245 func (*awsRestjson1_deserializeOpCreateTokenWithIAM) ID() string { 246 return "OperationDeserializer" 247 } 248 249 func (m *awsRestjson1_deserializeOpCreateTokenWithIAM) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( 250 out middleware.DeserializeOutput, metadata middleware.Metadata, err error, 251 ) { 252 out, metadata, err = next.HandleDeserialize(ctx, in) 253 if err != nil { 254 return out, metadata, err 255 } 256 257 response, ok := out.RawResponse.(*smithyhttp.Response) 258 if !ok { 259 return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} 260 } 261 262 if response.StatusCode < 200 || response.StatusCode >= 300 { 263 return out, metadata, awsRestjson1_deserializeOpErrorCreateTokenWithIAM(response, &metadata) 264 } 265 output := &CreateTokenWithIAMOutput{} 266 out.Result = output 267 268 var buff [1024]byte 269 ringBuffer := smithyio.NewRingBuffer(buff[:]) 270 271 body := io.TeeReader(response.Body, ringBuffer) 272 273 decoder := json.NewDecoder(body) 274 decoder.UseNumber() 275 var shape interface{} 276 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 277 var snapshot bytes.Buffer 278 io.Copy(&snapshot, ringBuffer) 279 err = &smithy.DeserializationError{ 280 Err: fmt.Errorf("failed to decode response body, %w", err), 281 Snapshot: snapshot.Bytes(), 282 } 283 return out, metadata, err 284 } 285 286 err = awsRestjson1_deserializeOpDocumentCreateTokenWithIAMOutput(&output, shape) 287 if err != nil { 288 var snapshot bytes.Buffer 289 io.Copy(&snapshot, ringBuffer) 290 return out, metadata, &smithy.DeserializationError{ 291 Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), 292 Snapshot: snapshot.Bytes(), 293 } 294 } 295 296 return out, metadata, err 297 } 298 299 func awsRestjson1_deserializeOpErrorCreateTokenWithIAM(response *smithyhttp.Response, metadata *middleware.Metadata) error { 300 var errorBuffer bytes.Buffer 301 if _, err := io.Copy(&errorBuffer, response.Body); err != nil { 302 return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} 303 } 304 errorBody := bytes.NewReader(errorBuffer.Bytes()) 305 306 errorCode := "UnknownError" 307 errorMessage := errorCode 308 309 headerCode := response.Header.Get("X-Amzn-ErrorType") 310 if len(headerCode) != 0 { 311 errorCode = restjson.SanitizeErrorCode(headerCode) 312 } 313 314 var buff [1024]byte 315 ringBuffer := smithyio.NewRingBuffer(buff[:]) 316 317 body := io.TeeReader(errorBody, ringBuffer) 318 decoder := json.NewDecoder(body) 319 decoder.UseNumber() 320 jsonCode, message, err := restjson.GetErrorInfo(decoder) 321 if err != nil { 322 var snapshot bytes.Buffer 323 io.Copy(&snapshot, ringBuffer) 324 err = &smithy.DeserializationError{ 325 Err: fmt.Errorf("failed to decode response body, %w", err), 326 Snapshot: snapshot.Bytes(), 327 } 328 return err 329 } 330 331 errorBody.Seek(0, io.SeekStart) 332 if len(headerCode) == 0 && len(jsonCode) != 0 { 333 errorCode = restjson.SanitizeErrorCode(jsonCode) 334 } 335 if len(message) != 0 { 336 errorMessage = message 337 } 338 339 switch { 340 case strings.EqualFold("AccessDeniedException", errorCode): 341 return awsRestjson1_deserializeErrorAccessDeniedException(response, errorBody) 342 343 case strings.EqualFold("AuthorizationPendingException", errorCode): 344 return awsRestjson1_deserializeErrorAuthorizationPendingException(response, errorBody) 345 346 case strings.EqualFold("ExpiredTokenException", errorCode): 347 return awsRestjson1_deserializeErrorExpiredTokenException(response, errorBody) 348 349 case strings.EqualFold("InternalServerException", errorCode): 350 return awsRestjson1_deserializeErrorInternalServerException(response, errorBody) 351 352 case strings.EqualFold("InvalidClientException", errorCode): 353 return awsRestjson1_deserializeErrorInvalidClientException(response, errorBody) 354 355 case strings.EqualFold("InvalidGrantException", errorCode): 356 return awsRestjson1_deserializeErrorInvalidGrantException(response, errorBody) 357 358 case strings.EqualFold("InvalidRequestException", errorCode): 359 return awsRestjson1_deserializeErrorInvalidRequestException(response, errorBody) 360 361 case strings.EqualFold("InvalidRequestRegionException", errorCode): 362 return awsRestjson1_deserializeErrorInvalidRequestRegionException(response, errorBody) 363 364 case strings.EqualFold("InvalidScopeException", errorCode): 365 return awsRestjson1_deserializeErrorInvalidScopeException(response, errorBody) 366 367 case strings.EqualFold("SlowDownException", errorCode): 368 return awsRestjson1_deserializeErrorSlowDownException(response, errorBody) 369 370 case strings.EqualFold("UnauthorizedClientException", errorCode): 371 return awsRestjson1_deserializeErrorUnauthorizedClientException(response, errorBody) 372 373 case strings.EqualFold("UnsupportedGrantTypeException", errorCode): 374 return awsRestjson1_deserializeErrorUnsupportedGrantTypeException(response, errorBody) 375 376 default: 377 genericError := &smithy.GenericAPIError{ 378 Code: errorCode, 379 Message: errorMessage, 380 } 381 return genericError 382 383 } 384 } 385 386 func awsRestjson1_deserializeOpDocumentCreateTokenWithIAMOutput(v **CreateTokenWithIAMOutput, value interface{}) error { 387 if v == nil { 388 return fmt.Errorf("unexpected nil of type %T", v) 389 } 390 if value == nil { 391 return nil 392 } 393 394 shape, ok := value.(map[string]interface{}) 395 if !ok { 396 return fmt.Errorf("unexpected JSON type %v", value) 397 } 398 399 var sv *CreateTokenWithIAMOutput 400 if *v == nil { 401 sv = &CreateTokenWithIAMOutput{} 402 } else { 403 sv = *v 404 } 405 406 for key, value := range shape { 407 switch key { 408 case "accessToken": 409 if value != nil { 410 jtv, ok := value.(string) 411 if !ok { 412 return fmt.Errorf("expected AccessToken to be of type string, got %T instead", value) 413 } 414 sv.AccessToken = ptr.String(jtv) 415 } 416 417 case "expiresIn": 418 if value != nil { 419 jtv, ok := value.(json.Number) 420 if !ok { 421 return fmt.Errorf("expected ExpirationInSeconds to be json.Number, got %T instead", value) 422 } 423 i64, err := jtv.Int64() 424 if err != nil { 425 return err 426 } 427 sv.ExpiresIn = int32(i64) 428 } 429 430 case "idToken": 431 if value != nil { 432 jtv, ok := value.(string) 433 if !ok { 434 return fmt.Errorf("expected IdToken to be of type string, got %T instead", value) 435 } 436 sv.IdToken = ptr.String(jtv) 437 } 438 439 case "issuedTokenType": 440 if value != nil { 441 jtv, ok := value.(string) 442 if !ok { 443 return fmt.Errorf("expected TokenTypeURI to be of type string, got %T instead", value) 444 } 445 sv.IssuedTokenType = ptr.String(jtv) 446 } 447 448 case "refreshToken": 449 if value != nil { 450 jtv, ok := value.(string) 451 if !ok { 452 return fmt.Errorf("expected RefreshToken to be of type string, got %T instead", value) 453 } 454 sv.RefreshToken = ptr.String(jtv) 455 } 456 457 case "scope": 458 if err := awsRestjson1_deserializeDocumentScopes(&sv.Scope, value); err != nil { 459 return err 460 } 461 462 case "tokenType": 463 if value != nil { 464 jtv, ok := value.(string) 465 if !ok { 466 return fmt.Errorf("expected TokenType to be of type string, got %T instead", value) 467 } 468 sv.TokenType = ptr.String(jtv) 469 } 470 471 default: 472 _, _ = key, value 473 474 } 475 } 476 *v = sv 477 return nil 478 } 479 480 type awsRestjson1_deserializeOpRegisterClient struct { 481 } 482 483 func (*awsRestjson1_deserializeOpRegisterClient) ID() string { 484 return "OperationDeserializer" 485 } 486 487 func (m *awsRestjson1_deserializeOpRegisterClient) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( 488 out middleware.DeserializeOutput, metadata middleware.Metadata, err error, 489 ) { 490 out, metadata, err = next.HandleDeserialize(ctx, in) 491 if err != nil { 492 return out, metadata, err 493 } 494 495 response, ok := out.RawResponse.(*smithyhttp.Response) 496 if !ok { 497 return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} 498 } 499 500 if response.StatusCode < 200 || response.StatusCode >= 300 { 501 return out, metadata, awsRestjson1_deserializeOpErrorRegisterClient(response, &metadata) 502 } 503 output := &RegisterClientOutput{} 504 out.Result = output 505 506 var buff [1024]byte 507 ringBuffer := smithyio.NewRingBuffer(buff[:]) 508 509 body := io.TeeReader(response.Body, ringBuffer) 510 511 decoder := json.NewDecoder(body) 512 decoder.UseNumber() 513 var shape interface{} 514 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 515 var snapshot bytes.Buffer 516 io.Copy(&snapshot, ringBuffer) 517 err = &smithy.DeserializationError{ 518 Err: fmt.Errorf("failed to decode response body, %w", err), 519 Snapshot: snapshot.Bytes(), 520 } 521 return out, metadata, err 522 } 523 524 err = awsRestjson1_deserializeOpDocumentRegisterClientOutput(&output, shape) 525 if err != nil { 526 var snapshot bytes.Buffer 527 io.Copy(&snapshot, ringBuffer) 528 return out, metadata, &smithy.DeserializationError{ 529 Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), 530 Snapshot: snapshot.Bytes(), 531 } 532 } 533 534 return out, metadata, err 535 } 536 537 func awsRestjson1_deserializeOpErrorRegisterClient(response *smithyhttp.Response, metadata *middleware.Metadata) error { 538 var errorBuffer bytes.Buffer 539 if _, err := io.Copy(&errorBuffer, response.Body); err != nil { 540 return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} 541 } 542 errorBody := bytes.NewReader(errorBuffer.Bytes()) 543 544 errorCode := "UnknownError" 545 errorMessage := errorCode 546 547 headerCode := response.Header.Get("X-Amzn-ErrorType") 548 if len(headerCode) != 0 { 549 errorCode = restjson.SanitizeErrorCode(headerCode) 550 } 551 552 var buff [1024]byte 553 ringBuffer := smithyio.NewRingBuffer(buff[:]) 554 555 body := io.TeeReader(errorBody, ringBuffer) 556 decoder := json.NewDecoder(body) 557 decoder.UseNumber() 558 jsonCode, message, err := restjson.GetErrorInfo(decoder) 559 if err != nil { 560 var snapshot bytes.Buffer 561 io.Copy(&snapshot, ringBuffer) 562 err = &smithy.DeserializationError{ 563 Err: fmt.Errorf("failed to decode response body, %w", err), 564 Snapshot: snapshot.Bytes(), 565 } 566 return err 567 } 568 569 errorBody.Seek(0, io.SeekStart) 570 if len(headerCode) == 0 && len(jsonCode) != 0 { 571 errorCode = restjson.SanitizeErrorCode(jsonCode) 572 } 573 if len(message) != 0 { 574 errorMessage = message 575 } 576 577 switch { 578 case strings.EqualFold("InternalServerException", errorCode): 579 return awsRestjson1_deserializeErrorInternalServerException(response, errorBody) 580 581 case strings.EqualFold("InvalidClientMetadataException", errorCode): 582 return awsRestjson1_deserializeErrorInvalidClientMetadataException(response, errorBody) 583 584 case strings.EqualFold("InvalidRequestException", errorCode): 585 return awsRestjson1_deserializeErrorInvalidRequestException(response, errorBody) 586 587 case strings.EqualFold("InvalidScopeException", errorCode): 588 return awsRestjson1_deserializeErrorInvalidScopeException(response, errorBody) 589 590 default: 591 genericError := &smithy.GenericAPIError{ 592 Code: errorCode, 593 Message: errorMessage, 594 } 595 return genericError 596 597 } 598 } 599 600 func awsRestjson1_deserializeOpDocumentRegisterClientOutput(v **RegisterClientOutput, value interface{}) error { 601 if v == nil { 602 return fmt.Errorf("unexpected nil of type %T", v) 603 } 604 if value == nil { 605 return nil 606 } 607 608 shape, ok := value.(map[string]interface{}) 609 if !ok { 610 return fmt.Errorf("unexpected JSON type %v", value) 611 } 612 613 var sv *RegisterClientOutput 614 if *v == nil { 615 sv = &RegisterClientOutput{} 616 } else { 617 sv = *v 618 } 619 620 for key, value := range shape { 621 switch key { 622 case "authorizationEndpoint": 623 if value != nil { 624 jtv, ok := value.(string) 625 if !ok { 626 return fmt.Errorf("expected URI to be of type string, got %T instead", value) 627 } 628 sv.AuthorizationEndpoint = ptr.String(jtv) 629 } 630 631 case "clientId": 632 if value != nil { 633 jtv, ok := value.(string) 634 if !ok { 635 return fmt.Errorf("expected ClientId to be of type string, got %T instead", value) 636 } 637 sv.ClientId = ptr.String(jtv) 638 } 639 640 case "clientIdIssuedAt": 641 if value != nil { 642 jtv, ok := value.(json.Number) 643 if !ok { 644 return fmt.Errorf("expected LongTimeStampType to be json.Number, got %T instead", value) 645 } 646 i64, err := jtv.Int64() 647 if err != nil { 648 return err 649 } 650 sv.ClientIdIssuedAt = i64 651 } 652 653 case "clientSecret": 654 if value != nil { 655 jtv, ok := value.(string) 656 if !ok { 657 return fmt.Errorf("expected ClientSecret to be of type string, got %T instead", value) 658 } 659 sv.ClientSecret = ptr.String(jtv) 660 } 661 662 case "clientSecretExpiresAt": 663 if value != nil { 664 jtv, ok := value.(json.Number) 665 if !ok { 666 return fmt.Errorf("expected LongTimeStampType to be json.Number, got %T instead", value) 667 } 668 i64, err := jtv.Int64() 669 if err != nil { 670 return err 671 } 672 sv.ClientSecretExpiresAt = i64 673 } 674 675 case "tokenEndpoint": 676 if value != nil { 677 jtv, ok := value.(string) 678 if !ok { 679 return fmt.Errorf("expected URI to be of type string, got %T instead", value) 680 } 681 sv.TokenEndpoint = ptr.String(jtv) 682 } 683 684 default: 685 _, _ = key, value 686 687 } 688 } 689 *v = sv 690 return nil 691 } 692 693 type awsRestjson1_deserializeOpStartDeviceAuthorization struct { 694 } 695 696 func (*awsRestjson1_deserializeOpStartDeviceAuthorization) ID() string { 697 return "OperationDeserializer" 698 } 699 700 func (m *awsRestjson1_deserializeOpStartDeviceAuthorization) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( 701 out middleware.DeserializeOutput, metadata middleware.Metadata, err error, 702 ) { 703 out, metadata, err = next.HandleDeserialize(ctx, in) 704 if err != nil { 705 return out, metadata, err 706 } 707 708 response, ok := out.RawResponse.(*smithyhttp.Response) 709 if !ok { 710 return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} 711 } 712 713 if response.StatusCode < 200 || response.StatusCode >= 300 { 714 return out, metadata, awsRestjson1_deserializeOpErrorStartDeviceAuthorization(response, &metadata) 715 } 716 output := &StartDeviceAuthorizationOutput{} 717 out.Result = output 718 719 var buff [1024]byte 720 ringBuffer := smithyio.NewRingBuffer(buff[:]) 721 722 body := io.TeeReader(response.Body, ringBuffer) 723 724 decoder := json.NewDecoder(body) 725 decoder.UseNumber() 726 var shape interface{} 727 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 728 var snapshot bytes.Buffer 729 io.Copy(&snapshot, ringBuffer) 730 err = &smithy.DeserializationError{ 731 Err: fmt.Errorf("failed to decode response body, %w", err), 732 Snapshot: snapshot.Bytes(), 733 } 734 return out, metadata, err 735 } 736 737 err = awsRestjson1_deserializeOpDocumentStartDeviceAuthorizationOutput(&output, shape) 738 if err != nil { 739 var snapshot bytes.Buffer 740 io.Copy(&snapshot, ringBuffer) 741 return out, metadata, &smithy.DeserializationError{ 742 Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), 743 Snapshot: snapshot.Bytes(), 744 } 745 } 746 747 return out, metadata, err 748 } 749 750 func awsRestjson1_deserializeOpErrorStartDeviceAuthorization(response *smithyhttp.Response, metadata *middleware.Metadata) error { 751 var errorBuffer bytes.Buffer 752 if _, err := io.Copy(&errorBuffer, response.Body); err != nil { 753 return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} 754 } 755 errorBody := bytes.NewReader(errorBuffer.Bytes()) 756 757 errorCode := "UnknownError" 758 errorMessage := errorCode 759 760 headerCode := response.Header.Get("X-Amzn-ErrorType") 761 if len(headerCode) != 0 { 762 errorCode = restjson.SanitizeErrorCode(headerCode) 763 } 764 765 var buff [1024]byte 766 ringBuffer := smithyio.NewRingBuffer(buff[:]) 767 768 body := io.TeeReader(errorBody, ringBuffer) 769 decoder := json.NewDecoder(body) 770 decoder.UseNumber() 771 jsonCode, message, err := restjson.GetErrorInfo(decoder) 772 if err != nil { 773 var snapshot bytes.Buffer 774 io.Copy(&snapshot, ringBuffer) 775 err = &smithy.DeserializationError{ 776 Err: fmt.Errorf("failed to decode response body, %w", err), 777 Snapshot: snapshot.Bytes(), 778 } 779 return err 780 } 781 782 errorBody.Seek(0, io.SeekStart) 783 if len(headerCode) == 0 && len(jsonCode) != 0 { 784 errorCode = restjson.SanitizeErrorCode(jsonCode) 785 } 786 if len(message) != 0 { 787 errorMessage = message 788 } 789 790 switch { 791 case strings.EqualFold("InternalServerException", errorCode): 792 return awsRestjson1_deserializeErrorInternalServerException(response, errorBody) 793 794 case strings.EqualFold("InvalidClientException", errorCode): 795 return awsRestjson1_deserializeErrorInvalidClientException(response, errorBody) 796 797 case strings.EqualFold("InvalidRequestException", errorCode): 798 return awsRestjson1_deserializeErrorInvalidRequestException(response, errorBody) 799 800 case strings.EqualFold("SlowDownException", errorCode): 801 return awsRestjson1_deserializeErrorSlowDownException(response, errorBody) 802 803 case strings.EqualFold("UnauthorizedClientException", errorCode): 804 return awsRestjson1_deserializeErrorUnauthorizedClientException(response, errorBody) 805 806 default: 807 genericError := &smithy.GenericAPIError{ 808 Code: errorCode, 809 Message: errorMessage, 810 } 811 return genericError 812 813 } 814 } 815 816 func awsRestjson1_deserializeOpDocumentStartDeviceAuthorizationOutput(v **StartDeviceAuthorizationOutput, value interface{}) error { 817 if v == nil { 818 return fmt.Errorf("unexpected nil of type %T", v) 819 } 820 if value == nil { 821 return nil 822 } 823 824 shape, ok := value.(map[string]interface{}) 825 if !ok { 826 return fmt.Errorf("unexpected JSON type %v", value) 827 } 828 829 var sv *StartDeviceAuthorizationOutput 830 if *v == nil { 831 sv = &StartDeviceAuthorizationOutput{} 832 } else { 833 sv = *v 834 } 835 836 for key, value := range shape { 837 switch key { 838 case "deviceCode": 839 if value != nil { 840 jtv, ok := value.(string) 841 if !ok { 842 return fmt.Errorf("expected DeviceCode to be of type string, got %T instead", value) 843 } 844 sv.DeviceCode = ptr.String(jtv) 845 } 846 847 case "expiresIn": 848 if value != nil { 849 jtv, ok := value.(json.Number) 850 if !ok { 851 return fmt.Errorf("expected ExpirationInSeconds to be json.Number, got %T instead", value) 852 } 853 i64, err := jtv.Int64() 854 if err != nil { 855 return err 856 } 857 sv.ExpiresIn = int32(i64) 858 } 859 860 case "interval": 861 if value != nil { 862 jtv, ok := value.(json.Number) 863 if !ok { 864 return fmt.Errorf("expected IntervalInSeconds to be json.Number, got %T instead", value) 865 } 866 i64, err := jtv.Int64() 867 if err != nil { 868 return err 869 } 870 sv.Interval = int32(i64) 871 } 872 873 case "userCode": 874 if value != nil { 875 jtv, ok := value.(string) 876 if !ok { 877 return fmt.Errorf("expected UserCode to be of type string, got %T instead", value) 878 } 879 sv.UserCode = ptr.String(jtv) 880 } 881 882 case "verificationUri": 883 if value != nil { 884 jtv, ok := value.(string) 885 if !ok { 886 return fmt.Errorf("expected URI to be of type string, got %T instead", value) 887 } 888 sv.VerificationUri = ptr.String(jtv) 889 } 890 891 case "verificationUriComplete": 892 if value != nil { 893 jtv, ok := value.(string) 894 if !ok { 895 return fmt.Errorf("expected URI to be of type string, got %T instead", value) 896 } 897 sv.VerificationUriComplete = ptr.String(jtv) 898 } 899 900 default: 901 _, _ = key, value 902 903 } 904 } 905 *v = sv 906 return nil 907 } 908 909 func awsRestjson1_deserializeErrorAccessDeniedException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 910 output := &types.AccessDeniedException{} 911 var buff [1024]byte 912 ringBuffer := smithyio.NewRingBuffer(buff[:]) 913 914 body := io.TeeReader(errorBody, ringBuffer) 915 decoder := json.NewDecoder(body) 916 decoder.UseNumber() 917 var shape interface{} 918 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 919 var snapshot bytes.Buffer 920 io.Copy(&snapshot, ringBuffer) 921 err = &smithy.DeserializationError{ 922 Err: fmt.Errorf("failed to decode response body, %w", err), 923 Snapshot: snapshot.Bytes(), 924 } 925 return err 926 } 927 928 err := awsRestjson1_deserializeDocumentAccessDeniedException(&output, shape) 929 930 if err != nil { 931 var snapshot bytes.Buffer 932 io.Copy(&snapshot, ringBuffer) 933 err = &smithy.DeserializationError{ 934 Err: fmt.Errorf("failed to decode response body, %w", err), 935 Snapshot: snapshot.Bytes(), 936 } 937 return err 938 } 939 940 errorBody.Seek(0, io.SeekStart) 941 942 return output 943 } 944 945 func awsRestjson1_deserializeErrorAuthorizationPendingException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 946 output := &types.AuthorizationPendingException{} 947 var buff [1024]byte 948 ringBuffer := smithyio.NewRingBuffer(buff[:]) 949 950 body := io.TeeReader(errorBody, ringBuffer) 951 decoder := json.NewDecoder(body) 952 decoder.UseNumber() 953 var shape interface{} 954 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 955 var snapshot bytes.Buffer 956 io.Copy(&snapshot, ringBuffer) 957 err = &smithy.DeserializationError{ 958 Err: fmt.Errorf("failed to decode response body, %w", err), 959 Snapshot: snapshot.Bytes(), 960 } 961 return err 962 } 963 964 err := awsRestjson1_deserializeDocumentAuthorizationPendingException(&output, shape) 965 966 if err != nil { 967 var snapshot bytes.Buffer 968 io.Copy(&snapshot, ringBuffer) 969 err = &smithy.DeserializationError{ 970 Err: fmt.Errorf("failed to decode response body, %w", err), 971 Snapshot: snapshot.Bytes(), 972 } 973 return err 974 } 975 976 errorBody.Seek(0, io.SeekStart) 977 978 return output 979 } 980 981 func awsRestjson1_deserializeErrorExpiredTokenException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 982 output := &types.ExpiredTokenException{} 983 var buff [1024]byte 984 ringBuffer := smithyio.NewRingBuffer(buff[:]) 985 986 body := io.TeeReader(errorBody, ringBuffer) 987 decoder := json.NewDecoder(body) 988 decoder.UseNumber() 989 var shape interface{} 990 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 991 var snapshot bytes.Buffer 992 io.Copy(&snapshot, ringBuffer) 993 err = &smithy.DeserializationError{ 994 Err: fmt.Errorf("failed to decode response body, %w", err), 995 Snapshot: snapshot.Bytes(), 996 } 997 return err 998 } 999 1000 err := awsRestjson1_deserializeDocumentExpiredTokenException(&output, shape) 1001 1002 if err != nil { 1003 var snapshot bytes.Buffer 1004 io.Copy(&snapshot, ringBuffer) 1005 err = &smithy.DeserializationError{ 1006 Err: fmt.Errorf("failed to decode response body, %w", err), 1007 Snapshot: snapshot.Bytes(), 1008 } 1009 return err 1010 } 1011 1012 errorBody.Seek(0, io.SeekStart) 1013 1014 return output 1015 } 1016 1017 func awsRestjson1_deserializeErrorInternalServerException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 1018 output := &types.InternalServerException{} 1019 var buff [1024]byte 1020 ringBuffer := smithyio.NewRingBuffer(buff[:]) 1021 1022 body := io.TeeReader(errorBody, ringBuffer) 1023 decoder := json.NewDecoder(body) 1024 decoder.UseNumber() 1025 var shape interface{} 1026 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 1027 var snapshot bytes.Buffer 1028 io.Copy(&snapshot, ringBuffer) 1029 err = &smithy.DeserializationError{ 1030 Err: fmt.Errorf("failed to decode response body, %w", err), 1031 Snapshot: snapshot.Bytes(), 1032 } 1033 return err 1034 } 1035 1036 err := awsRestjson1_deserializeDocumentInternalServerException(&output, shape) 1037 1038 if err != nil { 1039 var snapshot bytes.Buffer 1040 io.Copy(&snapshot, ringBuffer) 1041 err = &smithy.DeserializationError{ 1042 Err: fmt.Errorf("failed to decode response body, %w", err), 1043 Snapshot: snapshot.Bytes(), 1044 } 1045 return err 1046 } 1047 1048 errorBody.Seek(0, io.SeekStart) 1049 1050 return output 1051 } 1052 1053 func awsRestjson1_deserializeErrorInvalidClientException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 1054 output := &types.InvalidClientException{} 1055 var buff [1024]byte 1056 ringBuffer := smithyio.NewRingBuffer(buff[:]) 1057 1058 body := io.TeeReader(errorBody, ringBuffer) 1059 decoder := json.NewDecoder(body) 1060 decoder.UseNumber() 1061 var shape interface{} 1062 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 1063 var snapshot bytes.Buffer 1064 io.Copy(&snapshot, ringBuffer) 1065 err = &smithy.DeserializationError{ 1066 Err: fmt.Errorf("failed to decode response body, %w", err), 1067 Snapshot: snapshot.Bytes(), 1068 } 1069 return err 1070 } 1071 1072 err := awsRestjson1_deserializeDocumentInvalidClientException(&output, shape) 1073 1074 if err != nil { 1075 var snapshot bytes.Buffer 1076 io.Copy(&snapshot, ringBuffer) 1077 err = &smithy.DeserializationError{ 1078 Err: fmt.Errorf("failed to decode response body, %w", err), 1079 Snapshot: snapshot.Bytes(), 1080 } 1081 return err 1082 } 1083 1084 errorBody.Seek(0, io.SeekStart) 1085 1086 return output 1087 } 1088 1089 func awsRestjson1_deserializeErrorInvalidClientMetadataException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 1090 output := &types.InvalidClientMetadataException{} 1091 var buff [1024]byte 1092 ringBuffer := smithyio.NewRingBuffer(buff[:]) 1093 1094 body := io.TeeReader(errorBody, ringBuffer) 1095 decoder := json.NewDecoder(body) 1096 decoder.UseNumber() 1097 var shape interface{} 1098 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 1099 var snapshot bytes.Buffer 1100 io.Copy(&snapshot, ringBuffer) 1101 err = &smithy.DeserializationError{ 1102 Err: fmt.Errorf("failed to decode response body, %w", err), 1103 Snapshot: snapshot.Bytes(), 1104 } 1105 return err 1106 } 1107 1108 err := awsRestjson1_deserializeDocumentInvalidClientMetadataException(&output, shape) 1109 1110 if err != nil { 1111 var snapshot bytes.Buffer 1112 io.Copy(&snapshot, ringBuffer) 1113 err = &smithy.DeserializationError{ 1114 Err: fmt.Errorf("failed to decode response body, %w", err), 1115 Snapshot: snapshot.Bytes(), 1116 } 1117 return err 1118 } 1119 1120 errorBody.Seek(0, io.SeekStart) 1121 1122 return output 1123 } 1124 1125 func awsRestjson1_deserializeErrorInvalidGrantException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 1126 output := &types.InvalidGrantException{} 1127 var buff [1024]byte 1128 ringBuffer := smithyio.NewRingBuffer(buff[:]) 1129 1130 body := io.TeeReader(errorBody, ringBuffer) 1131 decoder := json.NewDecoder(body) 1132 decoder.UseNumber() 1133 var shape interface{} 1134 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 1135 var snapshot bytes.Buffer 1136 io.Copy(&snapshot, ringBuffer) 1137 err = &smithy.DeserializationError{ 1138 Err: fmt.Errorf("failed to decode response body, %w", err), 1139 Snapshot: snapshot.Bytes(), 1140 } 1141 return err 1142 } 1143 1144 err := awsRestjson1_deserializeDocumentInvalidGrantException(&output, shape) 1145 1146 if err != nil { 1147 var snapshot bytes.Buffer 1148 io.Copy(&snapshot, ringBuffer) 1149 err = &smithy.DeserializationError{ 1150 Err: fmt.Errorf("failed to decode response body, %w", err), 1151 Snapshot: snapshot.Bytes(), 1152 } 1153 return err 1154 } 1155 1156 errorBody.Seek(0, io.SeekStart) 1157 1158 return output 1159 } 1160 1161 func awsRestjson1_deserializeErrorInvalidRequestException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 1162 output := &types.InvalidRequestException{} 1163 var buff [1024]byte 1164 ringBuffer := smithyio.NewRingBuffer(buff[:]) 1165 1166 body := io.TeeReader(errorBody, ringBuffer) 1167 decoder := json.NewDecoder(body) 1168 decoder.UseNumber() 1169 var shape interface{} 1170 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 1171 var snapshot bytes.Buffer 1172 io.Copy(&snapshot, ringBuffer) 1173 err = &smithy.DeserializationError{ 1174 Err: fmt.Errorf("failed to decode response body, %w", err), 1175 Snapshot: snapshot.Bytes(), 1176 } 1177 return err 1178 } 1179 1180 err := awsRestjson1_deserializeDocumentInvalidRequestException(&output, shape) 1181 1182 if err != nil { 1183 var snapshot bytes.Buffer 1184 io.Copy(&snapshot, ringBuffer) 1185 err = &smithy.DeserializationError{ 1186 Err: fmt.Errorf("failed to decode response body, %w", err), 1187 Snapshot: snapshot.Bytes(), 1188 } 1189 return err 1190 } 1191 1192 errorBody.Seek(0, io.SeekStart) 1193 1194 return output 1195 } 1196 1197 func awsRestjson1_deserializeErrorInvalidRequestRegionException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 1198 output := &types.InvalidRequestRegionException{} 1199 var buff [1024]byte 1200 ringBuffer := smithyio.NewRingBuffer(buff[:]) 1201 1202 body := io.TeeReader(errorBody, ringBuffer) 1203 decoder := json.NewDecoder(body) 1204 decoder.UseNumber() 1205 var shape interface{} 1206 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 1207 var snapshot bytes.Buffer 1208 io.Copy(&snapshot, ringBuffer) 1209 err = &smithy.DeserializationError{ 1210 Err: fmt.Errorf("failed to decode response body, %w", err), 1211 Snapshot: snapshot.Bytes(), 1212 } 1213 return err 1214 } 1215 1216 err := awsRestjson1_deserializeDocumentInvalidRequestRegionException(&output, shape) 1217 1218 if err != nil { 1219 var snapshot bytes.Buffer 1220 io.Copy(&snapshot, ringBuffer) 1221 err = &smithy.DeserializationError{ 1222 Err: fmt.Errorf("failed to decode response body, %w", err), 1223 Snapshot: snapshot.Bytes(), 1224 } 1225 return err 1226 } 1227 1228 errorBody.Seek(0, io.SeekStart) 1229 1230 return output 1231 } 1232 1233 func awsRestjson1_deserializeErrorInvalidScopeException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 1234 output := &types.InvalidScopeException{} 1235 var buff [1024]byte 1236 ringBuffer := smithyio.NewRingBuffer(buff[:]) 1237 1238 body := io.TeeReader(errorBody, ringBuffer) 1239 decoder := json.NewDecoder(body) 1240 decoder.UseNumber() 1241 var shape interface{} 1242 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 1243 var snapshot bytes.Buffer 1244 io.Copy(&snapshot, ringBuffer) 1245 err = &smithy.DeserializationError{ 1246 Err: fmt.Errorf("failed to decode response body, %w", err), 1247 Snapshot: snapshot.Bytes(), 1248 } 1249 return err 1250 } 1251 1252 err := awsRestjson1_deserializeDocumentInvalidScopeException(&output, shape) 1253 1254 if err != nil { 1255 var snapshot bytes.Buffer 1256 io.Copy(&snapshot, ringBuffer) 1257 err = &smithy.DeserializationError{ 1258 Err: fmt.Errorf("failed to decode response body, %w", err), 1259 Snapshot: snapshot.Bytes(), 1260 } 1261 return err 1262 } 1263 1264 errorBody.Seek(0, io.SeekStart) 1265 1266 return output 1267 } 1268 1269 func awsRestjson1_deserializeErrorSlowDownException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 1270 output := &types.SlowDownException{} 1271 var buff [1024]byte 1272 ringBuffer := smithyio.NewRingBuffer(buff[:]) 1273 1274 body := io.TeeReader(errorBody, ringBuffer) 1275 decoder := json.NewDecoder(body) 1276 decoder.UseNumber() 1277 var shape interface{} 1278 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 1279 var snapshot bytes.Buffer 1280 io.Copy(&snapshot, ringBuffer) 1281 err = &smithy.DeserializationError{ 1282 Err: fmt.Errorf("failed to decode response body, %w", err), 1283 Snapshot: snapshot.Bytes(), 1284 } 1285 return err 1286 } 1287 1288 err := awsRestjson1_deserializeDocumentSlowDownException(&output, shape) 1289 1290 if err != nil { 1291 var snapshot bytes.Buffer 1292 io.Copy(&snapshot, ringBuffer) 1293 err = &smithy.DeserializationError{ 1294 Err: fmt.Errorf("failed to decode response body, %w", err), 1295 Snapshot: snapshot.Bytes(), 1296 } 1297 return err 1298 } 1299 1300 errorBody.Seek(0, io.SeekStart) 1301 1302 return output 1303 } 1304 1305 func awsRestjson1_deserializeErrorUnauthorizedClientException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 1306 output := &types.UnauthorizedClientException{} 1307 var buff [1024]byte 1308 ringBuffer := smithyio.NewRingBuffer(buff[:]) 1309 1310 body := io.TeeReader(errorBody, ringBuffer) 1311 decoder := json.NewDecoder(body) 1312 decoder.UseNumber() 1313 var shape interface{} 1314 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 1315 var snapshot bytes.Buffer 1316 io.Copy(&snapshot, ringBuffer) 1317 err = &smithy.DeserializationError{ 1318 Err: fmt.Errorf("failed to decode response body, %w", err), 1319 Snapshot: snapshot.Bytes(), 1320 } 1321 return err 1322 } 1323 1324 err := awsRestjson1_deserializeDocumentUnauthorizedClientException(&output, shape) 1325 1326 if err != nil { 1327 var snapshot bytes.Buffer 1328 io.Copy(&snapshot, ringBuffer) 1329 err = &smithy.DeserializationError{ 1330 Err: fmt.Errorf("failed to decode response body, %w", err), 1331 Snapshot: snapshot.Bytes(), 1332 } 1333 return err 1334 } 1335 1336 errorBody.Seek(0, io.SeekStart) 1337 1338 return output 1339 } 1340 1341 func awsRestjson1_deserializeErrorUnsupportedGrantTypeException(response *smithyhttp.Response, errorBody *bytes.Reader) error { 1342 output := &types.UnsupportedGrantTypeException{} 1343 var buff [1024]byte 1344 ringBuffer := smithyio.NewRingBuffer(buff[:]) 1345 1346 body := io.TeeReader(errorBody, ringBuffer) 1347 decoder := json.NewDecoder(body) 1348 decoder.UseNumber() 1349 var shape interface{} 1350 if err := decoder.Decode(&shape); err != nil && err != io.EOF { 1351 var snapshot bytes.Buffer 1352 io.Copy(&snapshot, ringBuffer) 1353 err = &smithy.DeserializationError{ 1354 Err: fmt.Errorf("failed to decode response body, %w", err), 1355 Snapshot: snapshot.Bytes(), 1356 } 1357 return err 1358 } 1359 1360 err := awsRestjson1_deserializeDocumentUnsupportedGrantTypeException(&output, shape) 1361 1362 if err != nil { 1363 var snapshot bytes.Buffer 1364 io.Copy(&snapshot, ringBuffer) 1365 err = &smithy.DeserializationError{ 1366 Err: fmt.Errorf("failed to decode response body, %w", err), 1367 Snapshot: snapshot.Bytes(), 1368 } 1369 return err 1370 } 1371 1372 errorBody.Seek(0, io.SeekStart) 1373 1374 return output 1375 } 1376 1377 func awsRestjson1_deserializeDocumentAccessDeniedException(v **types.AccessDeniedException, value interface{}) error { 1378 if v == nil { 1379 return fmt.Errorf("unexpected nil of type %T", v) 1380 } 1381 if value == nil { 1382 return nil 1383 } 1384 1385 shape, ok := value.(map[string]interface{}) 1386 if !ok { 1387 return fmt.Errorf("unexpected JSON type %v", value) 1388 } 1389 1390 var sv *types.AccessDeniedException 1391 if *v == nil { 1392 sv = &types.AccessDeniedException{} 1393 } else { 1394 sv = *v 1395 } 1396 1397 for key, value := range shape { 1398 switch key { 1399 case "error": 1400 if value != nil { 1401 jtv, ok := value.(string) 1402 if !ok { 1403 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1404 } 1405 sv.Error_ = ptr.String(jtv) 1406 } 1407 1408 case "error_description": 1409 if value != nil { 1410 jtv, ok := value.(string) 1411 if !ok { 1412 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 1413 } 1414 sv.Error_description = ptr.String(jtv) 1415 } 1416 1417 default: 1418 _, _ = key, value 1419 1420 } 1421 } 1422 *v = sv 1423 return nil 1424 } 1425 1426 func awsRestjson1_deserializeDocumentAuthorizationPendingException(v **types.AuthorizationPendingException, value interface{}) error { 1427 if v == nil { 1428 return fmt.Errorf("unexpected nil of type %T", v) 1429 } 1430 if value == nil { 1431 return nil 1432 } 1433 1434 shape, ok := value.(map[string]interface{}) 1435 if !ok { 1436 return fmt.Errorf("unexpected JSON type %v", value) 1437 } 1438 1439 var sv *types.AuthorizationPendingException 1440 if *v == nil { 1441 sv = &types.AuthorizationPendingException{} 1442 } else { 1443 sv = *v 1444 } 1445 1446 for key, value := range shape { 1447 switch key { 1448 case "error": 1449 if value != nil { 1450 jtv, ok := value.(string) 1451 if !ok { 1452 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1453 } 1454 sv.Error_ = ptr.String(jtv) 1455 } 1456 1457 case "error_description": 1458 if value != nil { 1459 jtv, ok := value.(string) 1460 if !ok { 1461 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 1462 } 1463 sv.Error_description = ptr.String(jtv) 1464 } 1465 1466 default: 1467 _, _ = key, value 1468 1469 } 1470 } 1471 *v = sv 1472 return nil 1473 } 1474 1475 func awsRestjson1_deserializeDocumentExpiredTokenException(v **types.ExpiredTokenException, value interface{}) error { 1476 if v == nil { 1477 return fmt.Errorf("unexpected nil of type %T", v) 1478 } 1479 if value == nil { 1480 return nil 1481 } 1482 1483 shape, ok := value.(map[string]interface{}) 1484 if !ok { 1485 return fmt.Errorf("unexpected JSON type %v", value) 1486 } 1487 1488 var sv *types.ExpiredTokenException 1489 if *v == nil { 1490 sv = &types.ExpiredTokenException{} 1491 } else { 1492 sv = *v 1493 } 1494 1495 for key, value := range shape { 1496 switch key { 1497 case "error": 1498 if value != nil { 1499 jtv, ok := value.(string) 1500 if !ok { 1501 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1502 } 1503 sv.Error_ = ptr.String(jtv) 1504 } 1505 1506 case "error_description": 1507 if value != nil { 1508 jtv, ok := value.(string) 1509 if !ok { 1510 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 1511 } 1512 sv.Error_description = ptr.String(jtv) 1513 } 1514 1515 default: 1516 _, _ = key, value 1517 1518 } 1519 } 1520 *v = sv 1521 return nil 1522 } 1523 1524 func awsRestjson1_deserializeDocumentInternalServerException(v **types.InternalServerException, value interface{}) error { 1525 if v == nil { 1526 return fmt.Errorf("unexpected nil of type %T", v) 1527 } 1528 if value == nil { 1529 return nil 1530 } 1531 1532 shape, ok := value.(map[string]interface{}) 1533 if !ok { 1534 return fmt.Errorf("unexpected JSON type %v", value) 1535 } 1536 1537 var sv *types.InternalServerException 1538 if *v == nil { 1539 sv = &types.InternalServerException{} 1540 } else { 1541 sv = *v 1542 } 1543 1544 for key, value := range shape { 1545 switch key { 1546 case "error": 1547 if value != nil { 1548 jtv, ok := value.(string) 1549 if !ok { 1550 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1551 } 1552 sv.Error_ = ptr.String(jtv) 1553 } 1554 1555 case "error_description": 1556 if value != nil { 1557 jtv, ok := value.(string) 1558 if !ok { 1559 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 1560 } 1561 sv.Error_description = ptr.String(jtv) 1562 } 1563 1564 default: 1565 _, _ = key, value 1566 1567 } 1568 } 1569 *v = sv 1570 return nil 1571 } 1572 1573 func awsRestjson1_deserializeDocumentInvalidClientException(v **types.InvalidClientException, value interface{}) error { 1574 if v == nil { 1575 return fmt.Errorf("unexpected nil of type %T", v) 1576 } 1577 if value == nil { 1578 return nil 1579 } 1580 1581 shape, ok := value.(map[string]interface{}) 1582 if !ok { 1583 return fmt.Errorf("unexpected JSON type %v", value) 1584 } 1585 1586 var sv *types.InvalidClientException 1587 if *v == nil { 1588 sv = &types.InvalidClientException{} 1589 } else { 1590 sv = *v 1591 } 1592 1593 for key, value := range shape { 1594 switch key { 1595 case "error": 1596 if value != nil { 1597 jtv, ok := value.(string) 1598 if !ok { 1599 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1600 } 1601 sv.Error_ = ptr.String(jtv) 1602 } 1603 1604 case "error_description": 1605 if value != nil { 1606 jtv, ok := value.(string) 1607 if !ok { 1608 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 1609 } 1610 sv.Error_description = ptr.String(jtv) 1611 } 1612 1613 default: 1614 _, _ = key, value 1615 1616 } 1617 } 1618 *v = sv 1619 return nil 1620 } 1621 1622 func awsRestjson1_deserializeDocumentInvalidClientMetadataException(v **types.InvalidClientMetadataException, value interface{}) error { 1623 if v == nil { 1624 return fmt.Errorf("unexpected nil of type %T", v) 1625 } 1626 if value == nil { 1627 return nil 1628 } 1629 1630 shape, ok := value.(map[string]interface{}) 1631 if !ok { 1632 return fmt.Errorf("unexpected JSON type %v", value) 1633 } 1634 1635 var sv *types.InvalidClientMetadataException 1636 if *v == nil { 1637 sv = &types.InvalidClientMetadataException{} 1638 } else { 1639 sv = *v 1640 } 1641 1642 for key, value := range shape { 1643 switch key { 1644 case "error": 1645 if value != nil { 1646 jtv, ok := value.(string) 1647 if !ok { 1648 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1649 } 1650 sv.Error_ = ptr.String(jtv) 1651 } 1652 1653 case "error_description": 1654 if value != nil { 1655 jtv, ok := value.(string) 1656 if !ok { 1657 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 1658 } 1659 sv.Error_description = ptr.String(jtv) 1660 } 1661 1662 default: 1663 _, _ = key, value 1664 1665 } 1666 } 1667 *v = sv 1668 return nil 1669 } 1670 1671 func awsRestjson1_deserializeDocumentInvalidGrantException(v **types.InvalidGrantException, value interface{}) error { 1672 if v == nil { 1673 return fmt.Errorf("unexpected nil of type %T", v) 1674 } 1675 if value == nil { 1676 return nil 1677 } 1678 1679 shape, ok := value.(map[string]interface{}) 1680 if !ok { 1681 return fmt.Errorf("unexpected JSON type %v", value) 1682 } 1683 1684 var sv *types.InvalidGrantException 1685 if *v == nil { 1686 sv = &types.InvalidGrantException{} 1687 } else { 1688 sv = *v 1689 } 1690 1691 for key, value := range shape { 1692 switch key { 1693 case "error": 1694 if value != nil { 1695 jtv, ok := value.(string) 1696 if !ok { 1697 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1698 } 1699 sv.Error_ = ptr.String(jtv) 1700 } 1701 1702 case "error_description": 1703 if value != nil { 1704 jtv, ok := value.(string) 1705 if !ok { 1706 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 1707 } 1708 sv.Error_description = ptr.String(jtv) 1709 } 1710 1711 default: 1712 _, _ = key, value 1713 1714 } 1715 } 1716 *v = sv 1717 return nil 1718 } 1719 1720 func awsRestjson1_deserializeDocumentInvalidRequestException(v **types.InvalidRequestException, value interface{}) error { 1721 if v == nil { 1722 return fmt.Errorf("unexpected nil of type %T", v) 1723 } 1724 if value == nil { 1725 return nil 1726 } 1727 1728 shape, ok := value.(map[string]interface{}) 1729 if !ok { 1730 return fmt.Errorf("unexpected JSON type %v", value) 1731 } 1732 1733 var sv *types.InvalidRequestException 1734 if *v == nil { 1735 sv = &types.InvalidRequestException{} 1736 } else { 1737 sv = *v 1738 } 1739 1740 for key, value := range shape { 1741 switch key { 1742 case "error": 1743 if value != nil { 1744 jtv, ok := value.(string) 1745 if !ok { 1746 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1747 } 1748 sv.Error_ = ptr.String(jtv) 1749 } 1750 1751 case "error_description": 1752 if value != nil { 1753 jtv, ok := value.(string) 1754 if !ok { 1755 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 1756 } 1757 sv.Error_description = ptr.String(jtv) 1758 } 1759 1760 default: 1761 _, _ = key, value 1762 1763 } 1764 } 1765 *v = sv 1766 return nil 1767 } 1768 1769 func awsRestjson1_deserializeDocumentInvalidRequestRegionException(v **types.InvalidRequestRegionException, value interface{}) error { 1770 if v == nil { 1771 return fmt.Errorf("unexpected nil of type %T", v) 1772 } 1773 if value == nil { 1774 return nil 1775 } 1776 1777 shape, ok := value.(map[string]interface{}) 1778 if !ok { 1779 return fmt.Errorf("unexpected JSON type %v", value) 1780 } 1781 1782 var sv *types.InvalidRequestRegionException 1783 if *v == nil { 1784 sv = &types.InvalidRequestRegionException{} 1785 } else { 1786 sv = *v 1787 } 1788 1789 for key, value := range shape { 1790 switch key { 1791 case "endpoint": 1792 if value != nil { 1793 jtv, ok := value.(string) 1794 if !ok { 1795 return fmt.Errorf("expected Location to be of type string, got %T instead", value) 1796 } 1797 sv.Endpoint = ptr.String(jtv) 1798 } 1799 1800 case "error": 1801 if value != nil { 1802 jtv, ok := value.(string) 1803 if !ok { 1804 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1805 } 1806 sv.Error_ = ptr.String(jtv) 1807 } 1808 1809 case "error_description": 1810 if value != nil { 1811 jtv, ok := value.(string) 1812 if !ok { 1813 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 1814 } 1815 sv.Error_description = ptr.String(jtv) 1816 } 1817 1818 case "region": 1819 if value != nil { 1820 jtv, ok := value.(string) 1821 if !ok { 1822 return fmt.Errorf("expected Region to be of type string, got %T instead", value) 1823 } 1824 sv.Region = ptr.String(jtv) 1825 } 1826 1827 default: 1828 _, _ = key, value 1829 1830 } 1831 } 1832 *v = sv 1833 return nil 1834 } 1835 1836 func awsRestjson1_deserializeDocumentInvalidScopeException(v **types.InvalidScopeException, value interface{}) error { 1837 if v == nil { 1838 return fmt.Errorf("unexpected nil of type %T", v) 1839 } 1840 if value == nil { 1841 return nil 1842 } 1843 1844 shape, ok := value.(map[string]interface{}) 1845 if !ok { 1846 return fmt.Errorf("unexpected JSON type %v", value) 1847 } 1848 1849 var sv *types.InvalidScopeException 1850 if *v == nil { 1851 sv = &types.InvalidScopeException{} 1852 } else { 1853 sv = *v 1854 } 1855 1856 for key, value := range shape { 1857 switch key { 1858 case "error": 1859 if value != nil { 1860 jtv, ok := value.(string) 1861 if !ok { 1862 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1863 } 1864 sv.Error_ = ptr.String(jtv) 1865 } 1866 1867 case "error_description": 1868 if value != nil { 1869 jtv, ok := value.(string) 1870 if !ok { 1871 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 1872 } 1873 sv.Error_description = ptr.String(jtv) 1874 } 1875 1876 default: 1877 _, _ = key, value 1878 1879 } 1880 } 1881 *v = sv 1882 return nil 1883 } 1884 1885 func awsRestjson1_deserializeDocumentScopes(v *[]string, value interface{}) error { 1886 if v == nil { 1887 return fmt.Errorf("unexpected nil of type %T", v) 1888 } 1889 if value == nil { 1890 return nil 1891 } 1892 1893 shape, ok := value.([]interface{}) 1894 if !ok { 1895 return fmt.Errorf("unexpected JSON type %v", value) 1896 } 1897 1898 var cv []string 1899 if *v == nil { 1900 cv = []string{} 1901 } else { 1902 cv = *v 1903 } 1904 1905 for _, value := range shape { 1906 var col string 1907 if value != nil { 1908 jtv, ok := value.(string) 1909 if !ok { 1910 return fmt.Errorf("expected Scope to be of type string, got %T instead", value) 1911 } 1912 col = jtv 1913 } 1914 cv = append(cv, col) 1915 1916 } 1917 *v = cv 1918 return nil 1919 } 1920 1921 func awsRestjson1_deserializeDocumentSlowDownException(v **types.SlowDownException, value interface{}) error { 1922 if v == nil { 1923 return fmt.Errorf("unexpected nil of type %T", v) 1924 } 1925 if value == nil { 1926 return nil 1927 } 1928 1929 shape, ok := value.(map[string]interface{}) 1930 if !ok { 1931 return fmt.Errorf("unexpected JSON type %v", value) 1932 } 1933 1934 var sv *types.SlowDownException 1935 if *v == nil { 1936 sv = &types.SlowDownException{} 1937 } else { 1938 sv = *v 1939 } 1940 1941 for key, value := range shape { 1942 switch key { 1943 case "error": 1944 if value != nil { 1945 jtv, ok := value.(string) 1946 if !ok { 1947 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1948 } 1949 sv.Error_ = ptr.String(jtv) 1950 } 1951 1952 case "error_description": 1953 if value != nil { 1954 jtv, ok := value.(string) 1955 if !ok { 1956 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 1957 } 1958 sv.Error_description = ptr.String(jtv) 1959 } 1960 1961 default: 1962 _, _ = key, value 1963 1964 } 1965 } 1966 *v = sv 1967 return nil 1968 } 1969 1970 func awsRestjson1_deserializeDocumentUnauthorizedClientException(v **types.UnauthorizedClientException, value interface{}) error { 1971 if v == nil { 1972 return fmt.Errorf("unexpected nil of type %T", v) 1973 } 1974 if value == nil { 1975 return nil 1976 } 1977 1978 shape, ok := value.(map[string]interface{}) 1979 if !ok { 1980 return fmt.Errorf("unexpected JSON type %v", value) 1981 } 1982 1983 var sv *types.UnauthorizedClientException 1984 if *v == nil { 1985 sv = &types.UnauthorizedClientException{} 1986 } else { 1987 sv = *v 1988 } 1989 1990 for key, value := range shape { 1991 switch key { 1992 case "error": 1993 if value != nil { 1994 jtv, ok := value.(string) 1995 if !ok { 1996 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 1997 } 1998 sv.Error_ = ptr.String(jtv) 1999 } 2000 2001 case "error_description": 2002 if value != nil { 2003 jtv, ok := value.(string) 2004 if !ok { 2005 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 2006 } 2007 sv.Error_description = ptr.String(jtv) 2008 } 2009 2010 default: 2011 _, _ = key, value 2012 2013 } 2014 } 2015 *v = sv 2016 return nil 2017 } 2018 2019 func awsRestjson1_deserializeDocumentUnsupportedGrantTypeException(v **types.UnsupportedGrantTypeException, value interface{}) error { 2020 if v == nil { 2021 return fmt.Errorf("unexpected nil of type %T", v) 2022 } 2023 if value == nil { 2024 return nil 2025 } 2026 2027 shape, ok := value.(map[string]interface{}) 2028 if !ok { 2029 return fmt.Errorf("unexpected JSON type %v", value) 2030 } 2031 2032 var sv *types.UnsupportedGrantTypeException 2033 if *v == nil { 2034 sv = &types.UnsupportedGrantTypeException{} 2035 } else { 2036 sv = *v 2037 } 2038 2039 for key, value := range shape { 2040 switch key { 2041 case "error": 2042 if value != nil { 2043 jtv, ok := value.(string) 2044 if !ok { 2045 return fmt.Errorf("expected Error to be of type string, got %T instead", value) 2046 } 2047 sv.Error_ = ptr.String(jtv) 2048 } 2049 2050 case "error_description": 2051 if value != nil { 2052 jtv, ok := value.(string) 2053 if !ok { 2054 return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value) 2055 } 2056 sv.Error_description = ptr.String(jtv) 2057 } 2058 2059 default: 2060 _, _ = key, value 2061 2062 } 2063 } 2064 *v = sv 2065 return nil 2066 }