src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

deserializers.go (29284B)


      1 // Code generated by smithy-go-codegen DO NOT EDIT.
      2 
      3 package sso
      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/sso/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 	"io/ioutil"
     19 	"strings"
     20 )
     21 
     22 type awsRestjson1_deserializeOpGetRoleCredentials struct {
     23 }
     24 
     25 func (*awsRestjson1_deserializeOpGetRoleCredentials) ID() string {
     26 	return "OperationDeserializer"
     27 }
     28 
     29 func (m *awsRestjson1_deserializeOpGetRoleCredentials) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) (
     30 	out middleware.DeserializeOutput, metadata middleware.Metadata, err error,
     31 ) {
     32 	out, metadata, err = next.HandleDeserialize(ctx, in)
     33 	if err != nil {
     34 		return out, metadata, err
     35 	}
     36 
     37 	response, ok := out.RawResponse.(*smithyhttp.Response)
     38 	if !ok {
     39 		return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)}
     40 	}
     41 
     42 	if response.StatusCode < 200 || response.StatusCode >= 300 {
     43 		return out, metadata, awsRestjson1_deserializeOpErrorGetRoleCredentials(response, &metadata)
     44 	}
     45 	output := &GetRoleCredentialsOutput{}
     46 	out.Result = output
     47 
     48 	var buff [1024]byte
     49 	ringBuffer := smithyio.NewRingBuffer(buff[:])
     50 
     51 	body := io.TeeReader(response.Body, ringBuffer)
     52 
     53 	decoder := json.NewDecoder(body)
     54 	decoder.UseNumber()
     55 	var shape interface{}
     56 	if err := decoder.Decode(&shape); err != nil && err != io.EOF {
     57 		var snapshot bytes.Buffer
     58 		io.Copy(&snapshot, ringBuffer)
     59 		err = &smithy.DeserializationError{
     60 			Err:      fmt.Errorf("failed to decode response body, %w", err),
     61 			Snapshot: snapshot.Bytes(),
     62 		}
     63 		return out, metadata, err
     64 	}
     65 
     66 	err = awsRestjson1_deserializeOpDocumentGetRoleCredentialsOutput(&output, shape)
     67 	if err != nil {
     68 		var snapshot bytes.Buffer
     69 		io.Copy(&snapshot, ringBuffer)
     70 		return out, metadata, &smithy.DeserializationError{
     71 			Err:      fmt.Errorf("failed to decode response body with invalid JSON, %w", err),
     72 			Snapshot: snapshot.Bytes(),
     73 		}
     74 	}
     75 
     76 	return out, metadata, err
     77 }
     78 
     79 func awsRestjson1_deserializeOpErrorGetRoleCredentials(response *smithyhttp.Response, metadata *middleware.Metadata) error {
     80 	var errorBuffer bytes.Buffer
     81 	if _, err := io.Copy(&errorBuffer, response.Body); err != nil {
     82 		return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)}
     83 	}
     84 	errorBody := bytes.NewReader(errorBuffer.Bytes())
     85 
     86 	errorCode := "UnknownError"
     87 	errorMessage := errorCode
     88 
     89 	headerCode := response.Header.Get("X-Amzn-ErrorType")
     90 	if len(headerCode) != 0 {
     91 		errorCode = restjson.SanitizeErrorCode(headerCode)
     92 	}
     93 
     94 	var buff [1024]byte
     95 	ringBuffer := smithyio.NewRingBuffer(buff[:])
     96 
     97 	body := io.TeeReader(errorBody, ringBuffer)
     98 	decoder := json.NewDecoder(body)
     99 	decoder.UseNumber()
    100 	jsonCode, message, err := restjson.GetErrorInfo(decoder)
    101 	if err != nil {
    102 		var snapshot bytes.Buffer
    103 		io.Copy(&snapshot, ringBuffer)
    104 		err = &smithy.DeserializationError{
    105 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    106 			Snapshot: snapshot.Bytes(),
    107 		}
    108 		return err
    109 	}
    110 
    111 	errorBody.Seek(0, io.SeekStart)
    112 	if len(headerCode) == 0 && len(jsonCode) != 0 {
    113 		errorCode = restjson.SanitizeErrorCode(jsonCode)
    114 	}
    115 	if len(message) != 0 {
    116 		errorMessage = message
    117 	}
    118 
    119 	switch {
    120 	case strings.EqualFold("InvalidRequestException", errorCode):
    121 		return awsRestjson1_deserializeErrorInvalidRequestException(response, errorBody)
    122 
    123 	case strings.EqualFold("ResourceNotFoundException", errorCode):
    124 		return awsRestjson1_deserializeErrorResourceNotFoundException(response, errorBody)
    125 
    126 	case strings.EqualFold("TooManyRequestsException", errorCode):
    127 		return awsRestjson1_deserializeErrorTooManyRequestsException(response, errorBody)
    128 
    129 	case strings.EqualFold("UnauthorizedException", errorCode):
    130 		return awsRestjson1_deserializeErrorUnauthorizedException(response, errorBody)
    131 
    132 	default:
    133 		genericError := &smithy.GenericAPIError{
    134 			Code:    errorCode,
    135 			Message: errorMessage,
    136 		}
    137 		return genericError
    138 
    139 	}
    140 }
    141 
    142 func awsRestjson1_deserializeOpDocumentGetRoleCredentialsOutput(v **GetRoleCredentialsOutput, value interface{}) error {
    143 	if v == nil {
    144 		return fmt.Errorf("unexpected nil of type %T", v)
    145 	}
    146 	if value == nil {
    147 		return nil
    148 	}
    149 
    150 	shape, ok := value.(map[string]interface{})
    151 	if !ok {
    152 		return fmt.Errorf("unexpected JSON type %v", value)
    153 	}
    154 
    155 	var sv *GetRoleCredentialsOutput
    156 	if *v == nil {
    157 		sv = &GetRoleCredentialsOutput{}
    158 	} else {
    159 		sv = *v
    160 	}
    161 
    162 	for key, value := range shape {
    163 		switch key {
    164 		case "roleCredentials":
    165 			if err := awsRestjson1_deserializeDocumentRoleCredentials(&sv.RoleCredentials, value); err != nil {
    166 				return err
    167 			}
    168 
    169 		default:
    170 			_, _ = key, value
    171 
    172 		}
    173 	}
    174 	*v = sv
    175 	return nil
    176 }
    177 
    178 type awsRestjson1_deserializeOpListAccountRoles struct {
    179 }
    180 
    181 func (*awsRestjson1_deserializeOpListAccountRoles) ID() string {
    182 	return "OperationDeserializer"
    183 }
    184 
    185 func (m *awsRestjson1_deserializeOpListAccountRoles) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) (
    186 	out middleware.DeserializeOutput, metadata middleware.Metadata, err error,
    187 ) {
    188 	out, metadata, err = next.HandleDeserialize(ctx, in)
    189 	if err != nil {
    190 		return out, metadata, err
    191 	}
    192 
    193 	response, ok := out.RawResponse.(*smithyhttp.Response)
    194 	if !ok {
    195 		return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)}
    196 	}
    197 
    198 	if response.StatusCode < 200 || response.StatusCode >= 300 {
    199 		return out, metadata, awsRestjson1_deserializeOpErrorListAccountRoles(response, &metadata)
    200 	}
    201 	output := &ListAccountRolesOutput{}
    202 	out.Result = output
    203 
    204 	var buff [1024]byte
    205 	ringBuffer := smithyio.NewRingBuffer(buff[:])
    206 
    207 	body := io.TeeReader(response.Body, ringBuffer)
    208 
    209 	decoder := json.NewDecoder(body)
    210 	decoder.UseNumber()
    211 	var shape interface{}
    212 	if err := decoder.Decode(&shape); err != nil && err != io.EOF {
    213 		var snapshot bytes.Buffer
    214 		io.Copy(&snapshot, ringBuffer)
    215 		err = &smithy.DeserializationError{
    216 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    217 			Snapshot: snapshot.Bytes(),
    218 		}
    219 		return out, metadata, err
    220 	}
    221 
    222 	err = awsRestjson1_deserializeOpDocumentListAccountRolesOutput(&output, shape)
    223 	if err != nil {
    224 		var snapshot bytes.Buffer
    225 		io.Copy(&snapshot, ringBuffer)
    226 		return out, metadata, &smithy.DeserializationError{
    227 			Err:      fmt.Errorf("failed to decode response body with invalid JSON, %w", err),
    228 			Snapshot: snapshot.Bytes(),
    229 		}
    230 	}
    231 
    232 	return out, metadata, err
    233 }
    234 
    235 func awsRestjson1_deserializeOpErrorListAccountRoles(response *smithyhttp.Response, metadata *middleware.Metadata) error {
    236 	var errorBuffer bytes.Buffer
    237 	if _, err := io.Copy(&errorBuffer, response.Body); err != nil {
    238 		return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)}
    239 	}
    240 	errorBody := bytes.NewReader(errorBuffer.Bytes())
    241 
    242 	errorCode := "UnknownError"
    243 	errorMessage := errorCode
    244 
    245 	headerCode := response.Header.Get("X-Amzn-ErrorType")
    246 	if len(headerCode) != 0 {
    247 		errorCode = restjson.SanitizeErrorCode(headerCode)
    248 	}
    249 
    250 	var buff [1024]byte
    251 	ringBuffer := smithyio.NewRingBuffer(buff[:])
    252 
    253 	body := io.TeeReader(errorBody, ringBuffer)
    254 	decoder := json.NewDecoder(body)
    255 	decoder.UseNumber()
    256 	jsonCode, message, err := restjson.GetErrorInfo(decoder)
    257 	if err != nil {
    258 		var snapshot bytes.Buffer
    259 		io.Copy(&snapshot, ringBuffer)
    260 		err = &smithy.DeserializationError{
    261 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    262 			Snapshot: snapshot.Bytes(),
    263 		}
    264 		return err
    265 	}
    266 
    267 	errorBody.Seek(0, io.SeekStart)
    268 	if len(headerCode) == 0 && len(jsonCode) != 0 {
    269 		errorCode = restjson.SanitizeErrorCode(jsonCode)
    270 	}
    271 	if len(message) != 0 {
    272 		errorMessage = message
    273 	}
    274 
    275 	switch {
    276 	case strings.EqualFold("InvalidRequestException", errorCode):
    277 		return awsRestjson1_deserializeErrorInvalidRequestException(response, errorBody)
    278 
    279 	case strings.EqualFold("ResourceNotFoundException", errorCode):
    280 		return awsRestjson1_deserializeErrorResourceNotFoundException(response, errorBody)
    281 
    282 	case strings.EqualFold("TooManyRequestsException", errorCode):
    283 		return awsRestjson1_deserializeErrorTooManyRequestsException(response, errorBody)
    284 
    285 	case strings.EqualFold("UnauthorizedException", errorCode):
    286 		return awsRestjson1_deserializeErrorUnauthorizedException(response, errorBody)
    287 
    288 	default:
    289 		genericError := &smithy.GenericAPIError{
    290 			Code:    errorCode,
    291 			Message: errorMessage,
    292 		}
    293 		return genericError
    294 
    295 	}
    296 }
    297 
    298 func awsRestjson1_deserializeOpDocumentListAccountRolesOutput(v **ListAccountRolesOutput, value interface{}) error {
    299 	if v == nil {
    300 		return fmt.Errorf("unexpected nil of type %T", v)
    301 	}
    302 	if value == nil {
    303 		return nil
    304 	}
    305 
    306 	shape, ok := value.(map[string]interface{})
    307 	if !ok {
    308 		return fmt.Errorf("unexpected JSON type %v", value)
    309 	}
    310 
    311 	var sv *ListAccountRolesOutput
    312 	if *v == nil {
    313 		sv = &ListAccountRolesOutput{}
    314 	} else {
    315 		sv = *v
    316 	}
    317 
    318 	for key, value := range shape {
    319 		switch key {
    320 		case "nextToken":
    321 			if value != nil {
    322 				jtv, ok := value.(string)
    323 				if !ok {
    324 					return fmt.Errorf("expected NextTokenType to be of type string, got %T instead", value)
    325 				}
    326 				sv.NextToken = ptr.String(jtv)
    327 			}
    328 
    329 		case "roleList":
    330 			if err := awsRestjson1_deserializeDocumentRoleListType(&sv.RoleList, value); err != nil {
    331 				return err
    332 			}
    333 
    334 		default:
    335 			_, _ = key, value
    336 
    337 		}
    338 	}
    339 	*v = sv
    340 	return nil
    341 }
    342 
    343 type awsRestjson1_deserializeOpListAccounts struct {
    344 }
    345 
    346 func (*awsRestjson1_deserializeOpListAccounts) ID() string {
    347 	return "OperationDeserializer"
    348 }
    349 
    350 func (m *awsRestjson1_deserializeOpListAccounts) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) (
    351 	out middleware.DeserializeOutput, metadata middleware.Metadata, err error,
    352 ) {
    353 	out, metadata, err = next.HandleDeserialize(ctx, in)
    354 	if err != nil {
    355 		return out, metadata, err
    356 	}
    357 
    358 	response, ok := out.RawResponse.(*smithyhttp.Response)
    359 	if !ok {
    360 		return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)}
    361 	}
    362 
    363 	if response.StatusCode < 200 || response.StatusCode >= 300 {
    364 		return out, metadata, awsRestjson1_deserializeOpErrorListAccounts(response, &metadata)
    365 	}
    366 	output := &ListAccountsOutput{}
    367 	out.Result = output
    368 
    369 	var buff [1024]byte
    370 	ringBuffer := smithyio.NewRingBuffer(buff[:])
    371 
    372 	body := io.TeeReader(response.Body, ringBuffer)
    373 
    374 	decoder := json.NewDecoder(body)
    375 	decoder.UseNumber()
    376 	var shape interface{}
    377 	if err := decoder.Decode(&shape); err != nil && err != io.EOF {
    378 		var snapshot bytes.Buffer
    379 		io.Copy(&snapshot, ringBuffer)
    380 		err = &smithy.DeserializationError{
    381 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    382 			Snapshot: snapshot.Bytes(),
    383 		}
    384 		return out, metadata, err
    385 	}
    386 
    387 	err = awsRestjson1_deserializeOpDocumentListAccountsOutput(&output, shape)
    388 	if err != nil {
    389 		var snapshot bytes.Buffer
    390 		io.Copy(&snapshot, ringBuffer)
    391 		return out, metadata, &smithy.DeserializationError{
    392 			Err:      fmt.Errorf("failed to decode response body with invalid JSON, %w", err),
    393 			Snapshot: snapshot.Bytes(),
    394 		}
    395 	}
    396 
    397 	return out, metadata, err
    398 }
    399 
    400 func awsRestjson1_deserializeOpErrorListAccounts(response *smithyhttp.Response, metadata *middleware.Metadata) error {
    401 	var errorBuffer bytes.Buffer
    402 	if _, err := io.Copy(&errorBuffer, response.Body); err != nil {
    403 		return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)}
    404 	}
    405 	errorBody := bytes.NewReader(errorBuffer.Bytes())
    406 
    407 	errorCode := "UnknownError"
    408 	errorMessage := errorCode
    409 
    410 	headerCode := response.Header.Get("X-Amzn-ErrorType")
    411 	if len(headerCode) != 0 {
    412 		errorCode = restjson.SanitizeErrorCode(headerCode)
    413 	}
    414 
    415 	var buff [1024]byte
    416 	ringBuffer := smithyio.NewRingBuffer(buff[:])
    417 
    418 	body := io.TeeReader(errorBody, ringBuffer)
    419 	decoder := json.NewDecoder(body)
    420 	decoder.UseNumber()
    421 	jsonCode, message, err := restjson.GetErrorInfo(decoder)
    422 	if err != nil {
    423 		var snapshot bytes.Buffer
    424 		io.Copy(&snapshot, ringBuffer)
    425 		err = &smithy.DeserializationError{
    426 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    427 			Snapshot: snapshot.Bytes(),
    428 		}
    429 		return err
    430 	}
    431 
    432 	errorBody.Seek(0, io.SeekStart)
    433 	if len(headerCode) == 0 && len(jsonCode) != 0 {
    434 		errorCode = restjson.SanitizeErrorCode(jsonCode)
    435 	}
    436 	if len(message) != 0 {
    437 		errorMessage = message
    438 	}
    439 
    440 	switch {
    441 	case strings.EqualFold("InvalidRequestException", errorCode):
    442 		return awsRestjson1_deserializeErrorInvalidRequestException(response, errorBody)
    443 
    444 	case strings.EqualFold("ResourceNotFoundException", errorCode):
    445 		return awsRestjson1_deserializeErrorResourceNotFoundException(response, errorBody)
    446 
    447 	case strings.EqualFold("TooManyRequestsException", errorCode):
    448 		return awsRestjson1_deserializeErrorTooManyRequestsException(response, errorBody)
    449 
    450 	case strings.EqualFold("UnauthorizedException", errorCode):
    451 		return awsRestjson1_deserializeErrorUnauthorizedException(response, errorBody)
    452 
    453 	default:
    454 		genericError := &smithy.GenericAPIError{
    455 			Code:    errorCode,
    456 			Message: errorMessage,
    457 		}
    458 		return genericError
    459 
    460 	}
    461 }
    462 
    463 func awsRestjson1_deserializeOpDocumentListAccountsOutput(v **ListAccountsOutput, value interface{}) error {
    464 	if v == nil {
    465 		return fmt.Errorf("unexpected nil of type %T", v)
    466 	}
    467 	if value == nil {
    468 		return nil
    469 	}
    470 
    471 	shape, ok := value.(map[string]interface{})
    472 	if !ok {
    473 		return fmt.Errorf("unexpected JSON type %v", value)
    474 	}
    475 
    476 	var sv *ListAccountsOutput
    477 	if *v == nil {
    478 		sv = &ListAccountsOutput{}
    479 	} else {
    480 		sv = *v
    481 	}
    482 
    483 	for key, value := range shape {
    484 		switch key {
    485 		case "accountList":
    486 			if err := awsRestjson1_deserializeDocumentAccountListType(&sv.AccountList, value); err != nil {
    487 				return err
    488 			}
    489 
    490 		case "nextToken":
    491 			if value != nil {
    492 				jtv, ok := value.(string)
    493 				if !ok {
    494 					return fmt.Errorf("expected NextTokenType to be of type string, got %T instead", value)
    495 				}
    496 				sv.NextToken = ptr.String(jtv)
    497 			}
    498 
    499 		default:
    500 			_, _ = key, value
    501 
    502 		}
    503 	}
    504 	*v = sv
    505 	return nil
    506 }
    507 
    508 type awsRestjson1_deserializeOpLogout struct {
    509 }
    510 
    511 func (*awsRestjson1_deserializeOpLogout) ID() string {
    512 	return "OperationDeserializer"
    513 }
    514 
    515 func (m *awsRestjson1_deserializeOpLogout) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) (
    516 	out middleware.DeserializeOutput, metadata middleware.Metadata, err error,
    517 ) {
    518 	out, metadata, err = next.HandleDeserialize(ctx, in)
    519 	if err != nil {
    520 		return out, metadata, err
    521 	}
    522 
    523 	response, ok := out.RawResponse.(*smithyhttp.Response)
    524 	if !ok {
    525 		return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)}
    526 	}
    527 
    528 	if response.StatusCode < 200 || response.StatusCode >= 300 {
    529 		return out, metadata, awsRestjson1_deserializeOpErrorLogout(response, &metadata)
    530 	}
    531 	output := &LogoutOutput{}
    532 	out.Result = output
    533 
    534 	if _, err = io.Copy(ioutil.Discard, response.Body); err != nil {
    535 		return out, metadata, &smithy.DeserializationError{
    536 			Err: fmt.Errorf("failed to discard response body, %w", err),
    537 		}
    538 	}
    539 
    540 	return out, metadata, err
    541 }
    542 
    543 func awsRestjson1_deserializeOpErrorLogout(response *smithyhttp.Response, metadata *middleware.Metadata) error {
    544 	var errorBuffer bytes.Buffer
    545 	if _, err := io.Copy(&errorBuffer, response.Body); err != nil {
    546 		return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)}
    547 	}
    548 	errorBody := bytes.NewReader(errorBuffer.Bytes())
    549 
    550 	errorCode := "UnknownError"
    551 	errorMessage := errorCode
    552 
    553 	headerCode := response.Header.Get("X-Amzn-ErrorType")
    554 	if len(headerCode) != 0 {
    555 		errorCode = restjson.SanitizeErrorCode(headerCode)
    556 	}
    557 
    558 	var buff [1024]byte
    559 	ringBuffer := smithyio.NewRingBuffer(buff[:])
    560 
    561 	body := io.TeeReader(errorBody, ringBuffer)
    562 	decoder := json.NewDecoder(body)
    563 	decoder.UseNumber()
    564 	jsonCode, message, err := restjson.GetErrorInfo(decoder)
    565 	if err != nil {
    566 		var snapshot bytes.Buffer
    567 		io.Copy(&snapshot, ringBuffer)
    568 		err = &smithy.DeserializationError{
    569 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    570 			Snapshot: snapshot.Bytes(),
    571 		}
    572 		return err
    573 	}
    574 
    575 	errorBody.Seek(0, io.SeekStart)
    576 	if len(headerCode) == 0 && len(jsonCode) != 0 {
    577 		errorCode = restjson.SanitizeErrorCode(jsonCode)
    578 	}
    579 	if len(message) != 0 {
    580 		errorMessage = message
    581 	}
    582 
    583 	switch {
    584 	case strings.EqualFold("InvalidRequestException", errorCode):
    585 		return awsRestjson1_deserializeErrorInvalidRequestException(response, errorBody)
    586 
    587 	case strings.EqualFold("TooManyRequestsException", errorCode):
    588 		return awsRestjson1_deserializeErrorTooManyRequestsException(response, errorBody)
    589 
    590 	case strings.EqualFold("UnauthorizedException", errorCode):
    591 		return awsRestjson1_deserializeErrorUnauthorizedException(response, errorBody)
    592 
    593 	default:
    594 		genericError := &smithy.GenericAPIError{
    595 			Code:    errorCode,
    596 			Message: errorMessage,
    597 		}
    598 		return genericError
    599 
    600 	}
    601 }
    602 
    603 func awsRestjson1_deserializeErrorInvalidRequestException(response *smithyhttp.Response, errorBody *bytes.Reader) error {
    604 	output := &types.InvalidRequestException{}
    605 	var buff [1024]byte
    606 	ringBuffer := smithyio.NewRingBuffer(buff[:])
    607 
    608 	body := io.TeeReader(errorBody, ringBuffer)
    609 	decoder := json.NewDecoder(body)
    610 	decoder.UseNumber()
    611 	var shape interface{}
    612 	if err := decoder.Decode(&shape); err != nil && err != io.EOF {
    613 		var snapshot bytes.Buffer
    614 		io.Copy(&snapshot, ringBuffer)
    615 		err = &smithy.DeserializationError{
    616 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    617 			Snapshot: snapshot.Bytes(),
    618 		}
    619 		return err
    620 	}
    621 
    622 	err := awsRestjson1_deserializeDocumentInvalidRequestException(&output, shape)
    623 
    624 	if err != nil {
    625 		var snapshot bytes.Buffer
    626 		io.Copy(&snapshot, ringBuffer)
    627 		err = &smithy.DeserializationError{
    628 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    629 			Snapshot: snapshot.Bytes(),
    630 		}
    631 		return err
    632 	}
    633 
    634 	errorBody.Seek(0, io.SeekStart)
    635 
    636 	return output
    637 }
    638 
    639 func awsRestjson1_deserializeErrorResourceNotFoundException(response *smithyhttp.Response, errorBody *bytes.Reader) error {
    640 	output := &types.ResourceNotFoundException{}
    641 	var buff [1024]byte
    642 	ringBuffer := smithyio.NewRingBuffer(buff[:])
    643 
    644 	body := io.TeeReader(errorBody, ringBuffer)
    645 	decoder := json.NewDecoder(body)
    646 	decoder.UseNumber()
    647 	var shape interface{}
    648 	if err := decoder.Decode(&shape); err != nil && err != io.EOF {
    649 		var snapshot bytes.Buffer
    650 		io.Copy(&snapshot, ringBuffer)
    651 		err = &smithy.DeserializationError{
    652 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    653 			Snapshot: snapshot.Bytes(),
    654 		}
    655 		return err
    656 	}
    657 
    658 	err := awsRestjson1_deserializeDocumentResourceNotFoundException(&output, shape)
    659 
    660 	if err != nil {
    661 		var snapshot bytes.Buffer
    662 		io.Copy(&snapshot, ringBuffer)
    663 		err = &smithy.DeserializationError{
    664 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    665 			Snapshot: snapshot.Bytes(),
    666 		}
    667 		return err
    668 	}
    669 
    670 	errorBody.Seek(0, io.SeekStart)
    671 
    672 	return output
    673 }
    674 
    675 func awsRestjson1_deserializeErrorTooManyRequestsException(response *smithyhttp.Response, errorBody *bytes.Reader) error {
    676 	output := &types.TooManyRequestsException{}
    677 	var buff [1024]byte
    678 	ringBuffer := smithyio.NewRingBuffer(buff[:])
    679 
    680 	body := io.TeeReader(errorBody, ringBuffer)
    681 	decoder := json.NewDecoder(body)
    682 	decoder.UseNumber()
    683 	var shape interface{}
    684 	if err := decoder.Decode(&shape); err != nil && err != io.EOF {
    685 		var snapshot bytes.Buffer
    686 		io.Copy(&snapshot, ringBuffer)
    687 		err = &smithy.DeserializationError{
    688 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    689 			Snapshot: snapshot.Bytes(),
    690 		}
    691 		return err
    692 	}
    693 
    694 	err := awsRestjson1_deserializeDocumentTooManyRequestsException(&output, shape)
    695 
    696 	if err != nil {
    697 		var snapshot bytes.Buffer
    698 		io.Copy(&snapshot, ringBuffer)
    699 		err = &smithy.DeserializationError{
    700 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    701 			Snapshot: snapshot.Bytes(),
    702 		}
    703 		return err
    704 	}
    705 
    706 	errorBody.Seek(0, io.SeekStart)
    707 
    708 	return output
    709 }
    710 
    711 func awsRestjson1_deserializeErrorUnauthorizedException(response *smithyhttp.Response, errorBody *bytes.Reader) error {
    712 	output := &types.UnauthorizedException{}
    713 	var buff [1024]byte
    714 	ringBuffer := smithyio.NewRingBuffer(buff[:])
    715 
    716 	body := io.TeeReader(errorBody, ringBuffer)
    717 	decoder := json.NewDecoder(body)
    718 	decoder.UseNumber()
    719 	var shape interface{}
    720 	if err := decoder.Decode(&shape); err != nil && err != io.EOF {
    721 		var snapshot bytes.Buffer
    722 		io.Copy(&snapshot, ringBuffer)
    723 		err = &smithy.DeserializationError{
    724 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    725 			Snapshot: snapshot.Bytes(),
    726 		}
    727 		return err
    728 	}
    729 
    730 	err := awsRestjson1_deserializeDocumentUnauthorizedException(&output, shape)
    731 
    732 	if err != nil {
    733 		var snapshot bytes.Buffer
    734 		io.Copy(&snapshot, ringBuffer)
    735 		err = &smithy.DeserializationError{
    736 			Err:      fmt.Errorf("failed to decode response body, %w", err),
    737 			Snapshot: snapshot.Bytes(),
    738 		}
    739 		return err
    740 	}
    741 
    742 	errorBody.Seek(0, io.SeekStart)
    743 
    744 	return output
    745 }
    746 
    747 func awsRestjson1_deserializeDocumentAccountInfo(v **types.AccountInfo, value interface{}) error {
    748 	if v == nil {
    749 		return fmt.Errorf("unexpected nil of type %T", v)
    750 	}
    751 	if value == nil {
    752 		return nil
    753 	}
    754 
    755 	shape, ok := value.(map[string]interface{})
    756 	if !ok {
    757 		return fmt.Errorf("unexpected JSON type %v", value)
    758 	}
    759 
    760 	var sv *types.AccountInfo
    761 	if *v == nil {
    762 		sv = &types.AccountInfo{}
    763 	} else {
    764 		sv = *v
    765 	}
    766 
    767 	for key, value := range shape {
    768 		switch key {
    769 		case "accountId":
    770 			if value != nil {
    771 				jtv, ok := value.(string)
    772 				if !ok {
    773 					return fmt.Errorf("expected AccountIdType to be of type string, got %T instead", value)
    774 				}
    775 				sv.AccountId = ptr.String(jtv)
    776 			}
    777 
    778 		case "accountName":
    779 			if value != nil {
    780 				jtv, ok := value.(string)
    781 				if !ok {
    782 					return fmt.Errorf("expected AccountNameType to be of type string, got %T instead", value)
    783 				}
    784 				sv.AccountName = ptr.String(jtv)
    785 			}
    786 
    787 		case "emailAddress":
    788 			if value != nil {
    789 				jtv, ok := value.(string)
    790 				if !ok {
    791 					return fmt.Errorf("expected EmailAddressType to be of type string, got %T instead", value)
    792 				}
    793 				sv.EmailAddress = ptr.String(jtv)
    794 			}
    795 
    796 		default:
    797 			_, _ = key, value
    798 
    799 		}
    800 	}
    801 	*v = sv
    802 	return nil
    803 }
    804 
    805 func awsRestjson1_deserializeDocumentAccountListType(v *[]types.AccountInfo, value interface{}) error {
    806 	if v == nil {
    807 		return fmt.Errorf("unexpected nil of type %T", v)
    808 	}
    809 	if value == nil {
    810 		return nil
    811 	}
    812 
    813 	shape, ok := value.([]interface{})
    814 	if !ok {
    815 		return fmt.Errorf("unexpected JSON type %v", value)
    816 	}
    817 
    818 	var cv []types.AccountInfo
    819 	if *v == nil {
    820 		cv = []types.AccountInfo{}
    821 	} else {
    822 		cv = *v
    823 	}
    824 
    825 	for _, value := range shape {
    826 		var col types.AccountInfo
    827 		destAddr := &col
    828 		if err := awsRestjson1_deserializeDocumentAccountInfo(&destAddr, value); err != nil {
    829 			return err
    830 		}
    831 		col = *destAddr
    832 		cv = append(cv, col)
    833 
    834 	}
    835 	*v = cv
    836 	return nil
    837 }
    838 
    839 func awsRestjson1_deserializeDocumentInvalidRequestException(v **types.InvalidRequestException, value interface{}) error {
    840 	if v == nil {
    841 		return fmt.Errorf("unexpected nil of type %T", v)
    842 	}
    843 	if value == nil {
    844 		return nil
    845 	}
    846 
    847 	shape, ok := value.(map[string]interface{})
    848 	if !ok {
    849 		return fmt.Errorf("unexpected JSON type %v", value)
    850 	}
    851 
    852 	var sv *types.InvalidRequestException
    853 	if *v == nil {
    854 		sv = &types.InvalidRequestException{}
    855 	} else {
    856 		sv = *v
    857 	}
    858 
    859 	for key, value := range shape {
    860 		switch key {
    861 		case "message":
    862 			if value != nil {
    863 				jtv, ok := value.(string)
    864 				if !ok {
    865 					return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value)
    866 				}
    867 				sv.Message = ptr.String(jtv)
    868 			}
    869 
    870 		default:
    871 			_, _ = key, value
    872 
    873 		}
    874 	}
    875 	*v = sv
    876 	return nil
    877 }
    878 
    879 func awsRestjson1_deserializeDocumentResourceNotFoundException(v **types.ResourceNotFoundException, value interface{}) error {
    880 	if v == nil {
    881 		return fmt.Errorf("unexpected nil of type %T", v)
    882 	}
    883 	if value == nil {
    884 		return nil
    885 	}
    886 
    887 	shape, ok := value.(map[string]interface{})
    888 	if !ok {
    889 		return fmt.Errorf("unexpected JSON type %v", value)
    890 	}
    891 
    892 	var sv *types.ResourceNotFoundException
    893 	if *v == nil {
    894 		sv = &types.ResourceNotFoundException{}
    895 	} else {
    896 		sv = *v
    897 	}
    898 
    899 	for key, value := range shape {
    900 		switch key {
    901 		case "message":
    902 			if value != nil {
    903 				jtv, ok := value.(string)
    904 				if !ok {
    905 					return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value)
    906 				}
    907 				sv.Message = ptr.String(jtv)
    908 			}
    909 
    910 		default:
    911 			_, _ = key, value
    912 
    913 		}
    914 	}
    915 	*v = sv
    916 	return nil
    917 }
    918 
    919 func awsRestjson1_deserializeDocumentRoleCredentials(v **types.RoleCredentials, value interface{}) error {
    920 	if v == nil {
    921 		return fmt.Errorf("unexpected nil of type %T", v)
    922 	}
    923 	if value == nil {
    924 		return nil
    925 	}
    926 
    927 	shape, ok := value.(map[string]interface{})
    928 	if !ok {
    929 		return fmt.Errorf("unexpected JSON type %v", value)
    930 	}
    931 
    932 	var sv *types.RoleCredentials
    933 	if *v == nil {
    934 		sv = &types.RoleCredentials{}
    935 	} else {
    936 		sv = *v
    937 	}
    938 
    939 	for key, value := range shape {
    940 		switch key {
    941 		case "accessKeyId":
    942 			if value != nil {
    943 				jtv, ok := value.(string)
    944 				if !ok {
    945 					return fmt.Errorf("expected AccessKeyType to be of type string, got %T instead", value)
    946 				}
    947 				sv.AccessKeyId = ptr.String(jtv)
    948 			}
    949 
    950 		case "expiration":
    951 			if value != nil {
    952 				jtv, ok := value.(json.Number)
    953 				if !ok {
    954 					return fmt.Errorf("expected ExpirationTimestampType to be json.Number, got %T instead", value)
    955 				}
    956 				i64, err := jtv.Int64()
    957 				if err != nil {
    958 					return err
    959 				}
    960 				sv.Expiration = i64
    961 			}
    962 
    963 		case "secretAccessKey":
    964 			if value != nil {
    965 				jtv, ok := value.(string)
    966 				if !ok {
    967 					return fmt.Errorf("expected SecretAccessKeyType to be of type string, got %T instead", value)
    968 				}
    969 				sv.SecretAccessKey = ptr.String(jtv)
    970 			}
    971 
    972 		case "sessionToken":
    973 			if value != nil {
    974 				jtv, ok := value.(string)
    975 				if !ok {
    976 					return fmt.Errorf("expected SessionTokenType to be of type string, got %T instead", value)
    977 				}
    978 				sv.SessionToken = ptr.String(jtv)
    979 			}
    980 
    981 		default:
    982 			_, _ = key, value
    983 
    984 		}
    985 	}
    986 	*v = sv
    987 	return nil
    988 }
    989 
    990 func awsRestjson1_deserializeDocumentRoleInfo(v **types.RoleInfo, value interface{}) error {
    991 	if v == nil {
    992 		return fmt.Errorf("unexpected nil of type %T", v)
    993 	}
    994 	if value == nil {
    995 		return nil
    996 	}
    997 
    998 	shape, ok := value.(map[string]interface{})
    999 	if !ok {
   1000 		return fmt.Errorf("unexpected JSON type %v", value)
   1001 	}
   1002 
   1003 	var sv *types.RoleInfo
   1004 	if *v == nil {
   1005 		sv = &types.RoleInfo{}
   1006 	} else {
   1007 		sv = *v
   1008 	}
   1009 
   1010 	for key, value := range shape {
   1011 		switch key {
   1012 		case "accountId":
   1013 			if value != nil {
   1014 				jtv, ok := value.(string)
   1015 				if !ok {
   1016 					return fmt.Errorf("expected AccountIdType to be of type string, got %T instead", value)
   1017 				}
   1018 				sv.AccountId = ptr.String(jtv)
   1019 			}
   1020 
   1021 		case "roleName":
   1022 			if value != nil {
   1023 				jtv, ok := value.(string)
   1024 				if !ok {
   1025 					return fmt.Errorf("expected RoleNameType to be of type string, got %T instead", value)
   1026 				}
   1027 				sv.RoleName = ptr.String(jtv)
   1028 			}
   1029 
   1030 		default:
   1031 			_, _ = key, value
   1032 
   1033 		}
   1034 	}
   1035 	*v = sv
   1036 	return nil
   1037 }
   1038 
   1039 func awsRestjson1_deserializeDocumentRoleListType(v *[]types.RoleInfo, value interface{}) error {
   1040 	if v == nil {
   1041 		return fmt.Errorf("unexpected nil of type %T", v)
   1042 	}
   1043 	if value == nil {
   1044 		return nil
   1045 	}
   1046 
   1047 	shape, ok := value.([]interface{})
   1048 	if !ok {
   1049 		return fmt.Errorf("unexpected JSON type %v", value)
   1050 	}
   1051 
   1052 	var cv []types.RoleInfo
   1053 	if *v == nil {
   1054 		cv = []types.RoleInfo{}
   1055 	} else {
   1056 		cv = *v
   1057 	}
   1058 
   1059 	for _, value := range shape {
   1060 		var col types.RoleInfo
   1061 		destAddr := &col
   1062 		if err := awsRestjson1_deserializeDocumentRoleInfo(&destAddr, value); err != nil {
   1063 			return err
   1064 		}
   1065 		col = *destAddr
   1066 		cv = append(cv, col)
   1067 
   1068 	}
   1069 	*v = cv
   1070 	return nil
   1071 }
   1072 
   1073 func awsRestjson1_deserializeDocumentTooManyRequestsException(v **types.TooManyRequestsException, value interface{}) error {
   1074 	if v == nil {
   1075 		return fmt.Errorf("unexpected nil of type %T", v)
   1076 	}
   1077 	if value == nil {
   1078 		return nil
   1079 	}
   1080 
   1081 	shape, ok := value.(map[string]interface{})
   1082 	if !ok {
   1083 		return fmt.Errorf("unexpected JSON type %v", value)
   1084 	}
   1085 
   1086 	var sv *types.TooManyRequestsException
   1087 	if *v == nil {
   1088 		sv = &types.TooManyRequestsException{}
   1089 	} else {
   1090 		sv = *v
   1091 	}
   1092 
   1093 	for key, value := range shape {
   1094 		switch key {
   1095 		case "message":
   1096 			if value != nil {
   1097 				jtv, ok := value.(string)
   1098 				if !ok {
   1099 					return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value)
   1100 				}
   1101 				sv.Message = ptr.String(jtv)
   1102 			}
   1103 
   1104 		default:
   1105 			_, _ = key, value
   1106 
   1107 		}
   1108 	}
   1109 	*v = sv
   1110 	return nil
   1111 }
   1112 
   1113 func awsRestjson1_deserializeDocumentUnauthorizedException(v **types.UnauthorizedException, value interface{}) error {
   1114 	if v == nil {
   1115 		return fmt.Errorf("unexpected nil of type %T", v)
   1116 	}
   1117 	if value == nil {
   1118 		return nil
   1119 	}
   1120 
   1121 	shape, ok := value.(map[string]interface{})
   1122 	if !ok {
   1123 		return fmt.Errorf("unexpected JSON type %v", value)
   1124 	}
   1125 
   1126 	var sv *types.UnauthorizedException
   1127 	if *v == nil {
   1128 		sv = &types.UnauthorizedException{}
   1129 	} else {
   1130 		sv = *v
   1131 	}
   1132 
   1133 	for key, value := range shape {
   1134 		switch key {
   1135 		case "message":
   1136 			if value != nil {
   1137 				jtv, ok := value.(string)
   1138 				if !ok {
   1139 					return fmt.Errorf("expected ErrorDescription to be of type string, got %T instead", value)
   1140 				}
   1141 				sv.Message = ptr.String(jtv)
   1142 			}
   1143 
   1144 		default:
   1145 			_, _ = key, value
   1146 
   1147 		}
   1148 	}
   1149 	*v = sv
   1150 	return nil
   1151 }