// Code generated by go-swagger; DO NOT EDIT.

package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"bytes"
	"context"
	"encoding/json"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// AwsDynamodbCollectorAttribute aws dynamodb collector attribute
//
// swagger:model AwsDynamodbCollectorAttribute
type AwsDynamodbCollectorAttribute struct {

	// aws attribute name
	AwsAttributeName string `json:"awsAttributeName,omitempty"`

	// aws dynamodb attr type
	AwsDynamodbAttrType string `json:"awsDynamodbAttrType,omitempty"`

	// aws key value
	AwsKeyValue string `json:"awsKeyValue,omitempty"`

	// aws query index name
	AwsQueryIndexName string `json:"awsQueryIndexName,omitempty"`

	// aws query index type
	AwsQueryIndexType string `json:"awsQueryIndexType,omitempty"`

	// aws query key value
	AwsQueryKeyValue string `json:"awsQueryKeyValue,omitempty"`

	// aws query range op
	AwsQueryRangeOp string `json:"awsQueryRangeOp,omitempty"`

	// aws query range value
	AwsQueryRangeValue string `json:"awsQueryRangeValue,omitempty"`

	// aws range value
	AwsRangeValue string `json:"awsRangeValue,omitempty"`
}

// Name gets the name of this subtype
func (m *AwsDynamodbCollectorAttribute) Name() string {
	return "awsdynamodb"
}

// SetName sets the name of this subtype
func (m *AwsDynamodbCollectorAttribute) SetName(val string) {
}

// UnmarshalJSON unmarshals this object with a polymorphic type from a JSON structure
func (m *AwsDynamodbCollectorAttribute) UnmarshalJSON(raw []byte) error {
	var data struct {

		// aws attribute name
		AwsAttributeName string `json:"awsAttributeName,omitempty"`

		// aws dynamodb attr type
		AwsDynamodbAttrType string `json:"awsDynamodbAttrType,omitempty"`

		// aws key value
		AwsKeyValue string `json:"awsKeyValue,omitempty"`

		// aws query index name
		AwsQueryIndexName string `json:"awsQueryIndexName,omitempty"`

		// aws query index type
		AwsQueryIndexType string `json:"awsQueryIndexType,omitempty"`

		// aws query key value
		AwsQueryKeyValue string `json:"awsQueryKeyValue,omitempty"`

		// aws query range op
		AwsQueryRangeOp string `json:"awsQueryRangeOp,omitempty"`

		// aws query range value
		AwsQueryRangeValue string `json:"awsQueryRangeValue,omitempty"`

		// aws range value
		AwsRangeValue string `json:"awsRangeValue,omitempty"`
	}
	buf := bytes.NewBuffer(raw)
	dec := json.NewDecoder(buf)
	dec.UseNumber()

	if err := dec.Decode(&data); err != nil {
		return err
	}

	var base struct {
		/* Just the base type fields. Used for unmashalling polymorphic types.*/

		Name string `json:"name"`
	}
	buf = bytes.NewBuffer(raw)
	dec = json.NewDecoder(buf)
	dec.UseNumber()

	if err := dec.Decode(&base); err != nil {
		return err
	}

	var result AwsDynamodbCollectorAttribute

	if base.Name != result.Name() {
		/* Not the type we're looking for. */
		return errors.New(422, "invalid name value: %q", base.Name)
	}

	result.AwsAttributeName = data.AwsAttributeName
	result.AwsDynamodbAttrType = data.AwsDynamodbAttrType
	result.AwsKeyValue = data.AwsKeyValue
	result.AwsQueryIndexName = data.AwsQueryIndexName
	result.AwsQueryIndexType = data.AwsQueryIndexType
	result.AwsQueryKeyValue = data.AwsQueryKeyValue
	result.AwsQueryRangeOp = data.AwsQueryRangeOp
	result.AwsQueryRangeValue = data.AwsQueryRangeValue
	result.AwsRangeValue = data.AwsRangeValue

	*m = result

	return nil
}

// MarshalJSON marshals this object with a polymorphic type to a JSON structure
func (m AwsDynamodbCollectorAttribute) MarshalJSON() ([]byte, error) {
	var b1, b2, b3 []byte
	var err error
	b1, err = json.Marshal(struct {

		// aws attribute name
		AwsAttributeName string `json:"awsAttributeName,omitempty"`

		// aws dynamodb attr type
		AwsDynamodbAttrType string `json:"awsDynamodbAttrType,omitempty"`

		// aws key value
		AwsKeyValue string `json:"awsKeyValue,omitempty"`

		// aws query index name
		AwsQueryIndexName string `json:"awsQueryIndexName,omitempty"`

		// aws query index type
		AwsQueryIndexType string `json:"awsQueryIndexType,omitempty"`

		// aws query key value
		AwsQueryKeyValue string `json:"awsQueryKeyValue,omitempty"`

		// aws query range op
		AwsQueryRangeOp string `json:"awsQueryRangeOp,omitempty"`

		// aws query range value
		AwsQueryRangeValue string `json:"awsQueryRangeValue,omitempty"`

		// aws range value
		AwsRangeValue string `json:"awsRangeValue,omitempty"`
	}{

		AwsAttributeName: m.AwsAttributeName,

		AwsDynamodbAttrType: m.AwsDynamodbAttrType,

		AwsKeyValue: m.AwsKeyValue,

		AwsQueryIndexName: m.AwsQueryIndexName,

		AwsQueryIndexType: m.AwsQueryIndexType,

		AwsQueryKeyValue: m.AwsQueryKeyValue,

		AwsQueryRangeOp: m.AwsQueryRangeOp,

		AwsQueryRangeValue: m.AwsQueryRangeValue,

		AwsRangeValue: m.AwsRangeValue,
	})
	if err != nil {
		return nil, err
	}
	b2, err = json.Marshal(struct {
		Name string `json:"name"`
	}{

		Name: m.Name(),
	})
	if err != nil {
		return nil, err
	}

	return swag.ConcatJSON(b1, b2, b3), nil
}

// Validate validates this aws dynamodb collector attribute
func (m *AwsDynamodbCollectorAttribute) Validate(formats strfmt.Registry) error {
	var res []error

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

// ContextValidate validate this aws dynamodb collector attribute based on the context it is used
func (m *AwsDynamodbCollectorAttribute) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

// MarshalBinary interface implementation
func (m *AwsDynamodbCollectorAttribute) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *AwsDynamodbCollectorAttribute) UnmarshalBinary(b []byte) error {
	var res AwsDynamodbCollectorAttribute
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
