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

package ops

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

import (
	"context"

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

// EntityConfigAttributes entity config attributes
//
// swagger:model entity.ConfigAttributes
type EntityConfigAttributes struct {

	// apply policy
	ApplyPolicy EntityApplyStrategy `json:"apply_policy,omitempty"`

	// id
	ID int64 `json:"id,omitempty"`

	// param name
	ParamName string `json:"param_name,omitempty"`

	// version
	Version int64 `json:"version,omitempty"`
}

// Validate validates this entity config attributes
func (m *EntityConfigAttributes) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateApplyPolicy(formats); err != nil {
		res = append(res, err)
	}

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

func (m *EntityConfigAttributes) validateApplyPolicy(formats strfmt.Registry) error {
	if swag.IsZero(m.ApplyPolicy) { // not required
		return nil
	}

	if err := m.ApplyPolicy.Validate(formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("apply_policy")
		} else if ce, ok := err.(*errors.CompositeError); ok {
			return ce.ValidateName("apply_policy")
		}
		return err
	}

	return nil
}

// ContextValidate validate this entity config attributes based on the context it is used
func (m *EntityConfigAttributes) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateApplyPolicy(ctx, formats); err != nil {
		res = append(res, err)
	}

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

func (m *EntityConfigAttributes) contextValidateApplyPolicy(ctx context.Context, formats strfmt.Registry) error {

	if swag.IsZero(m.ApplyPolicy) { // not required
		return nil
	}

	if err := m.ApplyPolicy.ContextValidate(ctx, formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("apply_policy")
		} else if ce, ok := err.(*errors.CompositeError); ok {
			return ce.ValidateName("apply_policy")
		}
		return err
	}

	return nil
}

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

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