package rest

import (
	
	
	
	
	
	
	
	
	
	

	
	
	
	awsStrings 
	
)
UnmarshalHandler is a named request handler for unmarshaling rest protocol requests
var UnmarshalHandler = request.NamedHandler{Name: "awssdk.rest.Unmarshal", Fn: Unmarshal}
UnmarshalMetaHandler is a named request handler for unmarshaling rest protocol request metadata
var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.rest.UnmarshalMeta", Fn: UnmarshalMeta}
Unmarshal unmarshals the REST component of a response in a REST service.
func ( *request.Request) {
	if .DataFilled() {
		 := reflect.Indirect(reflect.ValueOf(.Data))
		if  := unmarshalBody(, );  != nil {
			.Error = 
		}
	}
}
UnmarshalMeta unmarshals the REST metadata of a response in a REST service
func ( *request.Request) {
	.RequestID = .HTTPResponse.Header.Get("X-Amzn-Requestid")
Alternative version of request id in the header
		.RequestID = .HTTPResponse.Header.Get("X-Amz-Request-Id")
	}
	if .DataFilled() {
		if  := UnmarshalResponse(.HTTPResponse, .Data, aws.BoolValue(.Config.LowerCaseHeaderMaps));  != nil {
			.Error = 
		}
	}
}
UnmarshalResponse attempts to unmarshal the REST response headers to the data type passed in. The type must be a pointer. An error is returned with any error unmarshaling the response into the target datatype.
func ( *http.Response,  interface{},  bool) error {
	 := reflect.Indirect(reflect.ValueOf())
	return unmarshalLocationElements(, , )
}

func ( *request.Request,  reflect.Value) error {
	if ,  := .Type().FieldByName("_");  {
		if  := .Tag.Get("payload");  != "" {
			,  := .Type().FieldByName()
			if  := .Tag.Get("type");  != "" &&  != "structure" {
				 := .FieldByName()
				if .IsValid() {
					switch .Interface().(type) {
					case []byte:
						defer .HTTPResponse.Body.Close()
						,  := ioutil.ReadAll(.HTTPResponse.Body)
						if  != nil {
							return awserr.New(request.ErrCodeSerialization, "failed to decode REST response", )
						}

						.Set(reflect.ValueOf())

					case *string:
						defer .HTTPResponse.Body.Close()
						,  := ioutil.ReadAll(.HTTPResponse.Body)
						if  != nil {
							return awserr.New(request.ErrCodeSerialization, "failed to decode REST response", )
						}

						 := string()
						.Set(reflect.ValueOf(&))

					default:
						switch .Type().String() {
						case "io.ReadCloser":
							.Set(reflect.ValueOf(.HTTPResponse.Body))

						case "io.ReadSeeker":
							,  := ioutil.ReadAll(.HTTPResponse.Body)
							if  != nil {
								return awserr.New(request.ErrCodeSerialization,
									"failed to read response body", )
							}
							.Set(reflect.ValueOf(ioutil.NopCloser(bytes.NewReader())))

						default:
							io.Copy(ioutil.Discard, .HTTPResponse.Body)
							.HTTPResponse.Body.Close()
							return awserr.New(request.ErrCodeSerialization,
								"failed to decode REST response",
								fmt.Errorf("unknown payload type %s", .Type()))
						}
					}
				}
			}
		}
	}

	return nil
}

func ( *http.Response,  reflect.Value,  bool) error {
	for  := 0;  < .NumField(); ++ {
		,  := .Field(), .Type().Field()
		if  := .Name; [0:1] == strings.ToLower([0:1]) {
			continue
		}

		if .IsValid() {
			 := .Tag.Get("locationName")
			if  == "" {
				 = .Name
			}

			switch .Tag.Get("location") {
			case "statusCode":
				unmarshalStatusCode(, .StatusCode)

			case "header":
				 := unmarshalHeader(, .Header.Get(), .Tag)
				if  != nil {
					return awserr.New(request.ErrCodeSerialization, "failed to decode REST response", )
				}

			case "headers":
				 := .Tag.Get("locationName")
				 := unmarshalHeaderMap(, .Header, , )
				if  != nil {
					awserr.New(request.ErrCodeSerialization, "failed to decode REST response", )
				}
			}
		}
	}

	return nil
}

func ( reflect.Value,  int) {
	if !.IsValid() {
		return
	}

	switch .Interface().(type) {
	case *int64:
		 := int64()
		.Set(reflect.ValueOf(&))
	}
}

func ( reflect.Value,  http.Header,  string,  bool) error {
	if len() == 0 {
		return nil
	}
	switch .Interface().(type) {
	case map[string]*string: // we only support string map value types
		 := map[string]*string{}
		for ,  := range  {
			if awsStrings.HasPrefixFold(, ) {
				if  == true {
					 = strings.ToLower()
				} else {
					 = http.CanonicalHeaderKey()
				}
				[[len():]] = &[0]
			}
		}
		if len() != 0 {
			.Set(reflect.ValueOf())
		}

	}
	return nil
}

func ( reflect.Value,  string,  reflect.StructTag) error {
	switch .Get("type") {
	case "jsonvalue":
		if len() == 0 {
			return nil
		}
	case "blob":
		if len() == 0 {
			return nil
		}
	default:
		if !.IsValid() || ( == "" && .Elem().Kind() != reflect.String) {
			return nil
		}
	}

	switch .Interface().(type) {
	case *string:
		.Set(reflect.ValueOf(&))
	case []byte:
		,  := base64.StdEncoding.DecodeString()
		if  != nil {
			return 
		}
		.Set(reflect.ValueOf())
	case *bool:
		,  := strconv.ParseBool()
		if  != nil {
			return 
		}
		.Set(reflect.ValueOf(&))
	case *int64:
		,  := strconv.ParseInt(, 10, 64)
		if  != nil {
			return 
		}
		.Set(reflect.ValueOf(&))
	case *float64:
		,  := strconv.ParseFloat(, 64)
		if  != nil {
			return 
		}
		.Set(reflect.ValueOf(&))
	case *time.Time:
		 := .Get("timestampFormat")
		if len() == 0 {
			 = protocol.RFC822TimeFormatName
		}
		,  := protocol.ParseTime(, )
		if  != nil {
			return 
		}
		.Set(reflect.ValueOf(&))
	case aws.JSONValue:
		 := protocol.NoEscape
		if .Get("location") == "header" {
			 = protocol.Base64Escape
		}
		,  := protocol.DecodeJSONValue(, )
		if  != nil {
			return 
		}
		.Set(reflect.ValueOf())
	default:
		 := fmt.Errorf("Unsupported value for param %v (%s)", .Interface(), .Type())
		return 
	}
	return nil