// 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 (
	"context"
	"strconv"

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

// NetflowFilters netflow filters
//
// swagger:model NetflowFilters
type NetflowFilters struct {

	// conversation
	Conversation []*ConversationFilter `json:"conversation,omitempty"`

	// direction
	Direction string `json:"direction,omitempty"`

	// if idx
	IfIdx int32 `json:"ifIdx,omitempty"`

	// if name
	IfName string `json:"ifName,omitempty"`

	// ip version
	IPVersion string `json:"ipVersion,omitempty"`

	// node a
	NodeA string `json:"nodeA,omitempty"`

	// node b
	NodeB string `json:"nodeB,omitempty"`

	// ports
	Ports string `json:"ports,omitempty"`

	// protocol
	Protocol string `json:"protocol,omitempty"`

	// qos type
	QosType string `json:"qosType,omitempty"`

	// top
	Top int32 `json:"top,omitempty"`
}

// Validate validates this netflow filters
func (m *NetflowFilters) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *NetflowFilters) validateConversation(formats strfmt.Registry) error {
	if swag.IsZero(m.Conversation) { // not required
		return nil
	}

	for i := 0; i < len(m.Conversation); i++ {
		if swag.IsZero(m.Conversation[i]) { // not required
			continue
		}

		if m.Conversation[i] != nil {
			if err := m.Conversation[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("conversation" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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

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

func (m *NetflowFilters) contextValidateConversation(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.Conversation); i++ {

		if m.Conversation[i] != nil {
			if err := m.Conversation[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("conversation" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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