package models

import (
	"context"

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

type ConntrackTimeouts struct {

	Icmp *int64 `json:"icmp"`

	Other *int64 `json:"other"`

	TCPClose *int64 `json:"tcpClose"`

	TCPCloseWait *int64 `json:"tcpCloseWait"`

	TCPEstablished *int64 `json:"tcpEstablished"`

	TCPFinWait *int64 `json:"tcpFinWait"`

	TCPLastAck *int64 `json:"tcpLastAck"`

	TCPSynRecv *int64 `json:"tcpSynRecv"`

	TCPSynSent *int64 `json:"tcpSynSent"`

	TCPTimeWait *int64 `json:"tcpTimeWait"`

	UDPOther *int64 `json:"udpOther"`

	UDPStream *int64 `json:"udpStream"`
}

func (m *ConntrackTimeouts) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *ConntrackTimeouts) validateIcmp(formats strfmt.Registry) error {

	if err := validate.Required("icmp", "body", m.Icmp); err != nil {
		return err
	}

	if err := validate.MinimumInt("icmp", "body", *m.Icmp, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("icmp", "body", *m.Icmp, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateOther(formats strfmt.Registry) error {

	if err := validate.Required("other", "body", m.Other); err != nil {
		return err
	}

	if err := validate.MinimumInt("other", "body", *m.Other, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("other", "body", *m.Other, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPClose(formats strfmt.Registry) error {

	if err := validate.Required("tcpClose", "body", m.TCPClose); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpClose", "body", *m.TCPClose, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpClose", "body", *m.TCPClose, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPCloseWait(formats strfmt.Registry) error {

	if err := validate.Required("tcpCloseWait", "body", m.TCPCloseWait); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpCloseWait", "body", *m.TCPCloseWait, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpCloseWait", "body", *m.TCPCloseWait, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPEstablished(formats strfmt.Registry) error {

	if err := validate.Required("tcpEstablished", "body", m.TCPEstablished); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpEstablished", "body", *m.TCPEstablished, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpEstablished", "body", *m.TCPEstablished, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPFinWait(formats strfmt.Registry) error {

	if err := validate.Required("tcpFinWait", "body", m.TCPFinWait); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpFinWait", "body", *m.TCPFinWait, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpFinWait", "body", *m.TCPFinWait, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPLastAck(formats strfmt.Registry) error {

	if err := validate.Required("tcpLastAck", "body", m.TCPLastAck); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpLastAck", "body", *m.TCPLastAck, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpLastAck", "body", *m.TCPLastAck, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPSynRecv(formats strfmt.Registry) error {

	if err := validate.Required("tcpSynRecv", "body", m.TCPSynRecv); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpSynRecv", "body", *m.TCPSynRecv, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpSynRecv", "body", *m.TCPSynRecv, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPSynSent(formats strfmt.Registry) error {

	if err := validate.Required("tcpSynSent", "body", m.TCPSynSent); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpSynSent", "body", *m.TCPSynSent, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpSynSent", "body", *m.TCPSynSent, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPTimeWait(formats strfmt.Registry) error {

	if err := validate.Required("tcpTimeWait", "body", m.TCPTimeWait); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpTimeWait", "body", *m.TCPTimeWait, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpTimeWait", "body", *m.TCPTimeWait, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateUDPOther(formats strfmt.Registry) error {

	if err := validate.Required("udpOther", "body", m.UDPOther); err != nil {
		return err
	}

	if err := validate.MinimumInt("udpOther", "body", *m.UDPOther, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("udpOther", "body", *m.UDPOther, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateUDPStream(formats strfmt.Registry) error {

	if err := validate.Required("udpStream", "body", m.UDPStream); err != nil {
		return err
	}

	if err := validate.MinimumInt("udpStream", "body", *m.UDPStream, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("udpStream", "body", *m.UDPStream, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

func (m *ConntrackTimeouts) UnmarshalBinary(b []byte) error {
	var res ConntrackTimeouts
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
// 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"

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

// ConntrackTimeouts conntrack timeouts
//
// swagger:model conntrackTimeouts
type ConntrackTimeouts struct {

	// icmp
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	Icmp *int64 `json:"icmp"`

	// other
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	Other *int64 `json:"other"`

	// tcp close
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	TCPClose *int64 `json:"tcpClose"`

	// tcp close wait
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	TCPCloseWait *int64 `json:"tcpCloseWait"`

	// tcp established
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	TCPEstablished *int64 `json:"tcpEstablished"`

	// tcp fin wait
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	TCPFinWait *int64 `json:"tcpFinWait"`

	// tcp last ack
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	TCPLastAck *int64 `json:"tcpLastAck"`

	// tcp syn recv
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	TCPSynRecv *int64 `json:"tcpSynRecv"`

	// tcp syn sent
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	TCPSynSent *int64 `json:"tcpSynSent"`

	// tcp time wait
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	TCPTimeWait *int64 `json:"tcpTimeWait"`

	// udp other
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	UDPOther *int64 `json:"udpOther"`

	// udp stream
	// Required: true
	// Maximum: 1.2096e+06
	// Minimum: 1
	UDPStream *int64 `json:"udpStream"`
}

// Validate validates this conntrack timeouts
func (m *ConntrackTimeouts) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *ConntrackTimeouts) validateIcmp(formats strfmt.Registry) error {

	if err := validate.Required("icmp", "body", m.Icmp); err != nil {
		return err
	}

	if err := validate.MinimumInt("icmp", "body", *m.Icmp, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("icmp", "body", *m.Icmp, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateOther(formats strfmt.Registry) error {

	if err := validate.Required("other", "body", m.Other); err != nil {
		return err
	}

	if err := validate.MinimumInt("other", "body", *m.Other, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("other", "body", *m.Other, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPClose(formats strfmt.Registry) error {

	if err := validate.Required("tcpClose", "body", m.TCPClose); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpClose", "body", *m.TCPClose, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpClose", "body", *m.TCPClose, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPCloseWait(formats strfmt.Registry) error {

	if err := validate.Required("tcpCloseWait", "body", m.TCPCloseWait); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpCloseWait", "body", *m.TCPCloseWait, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpCloseWait", "body", *m.TCPCloseWait, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPEstablished(formats strfmt.Registry) error {

	if err := validate.Required("tcpEstablished", "body", m.TCPEstablished); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpEstablished", "body", *m.TCPEstablished, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpEstablished", "body", *m.TCPEstablished, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPFinWait(formats strfmt.Registry) error {

	if err := validate.Required("tcpFinWait", "body", m.TCPFinWait); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpFinWait", "body", *m.TCPFinWait, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpFinWait", "body", *m.TCPFinWait, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPLastAck(formats strfmt.Registry) error {

	if err := validate.Required("tcpLastAck", "body", m.TCPLastAck); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpLastAck", "body", *m.TCPLastAck, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpLastAck", "body", *m.TCPLastAck, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPSynRecv(formats strfmt.Registry) error {

	if err := validate.Required("tcpSynRecv", "body", m.TCPSynRecv); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpSynRecv", "body", *m.TCPSynRecv, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpSynRecv", "body", *m.TCPSynRecv, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPSynSent(formats strfmt.Registry) error {

	if err := validate.Required("tcpSynSent", "body", m.TCPSynSent); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpSynSent", "body", *m.TCPSynSent, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpSynSent", "body", *m.TCPSynSent, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateTCPTimeWait(formats strfmt.Registry) error {

	if err := validate.Required("tcpTimeWait", "body", m.TCPTimeWait); err != nil {
		return err
	}

	if err := validate.MinimumInt("tcpTimeWait", "body", *m.TCPTimeWait, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("tcpTimeWait", "body", *m.TCPTimeWait, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateUDPOther(formats strfmt.Registry) error {

	if err := validate.Required("udpOther", "body", m.UDPOther); err != nil {
		return err
	}

	if err := validate.MinimumInt("udpOther", "body", *m.UDPOther, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("udpOther", "body", *m.UDPOther, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

func (m *ConntrackTimeouts) validateUDPStream(formats strfmt.Registry) error {

	if err := validate.Required("udpStream", "body", m.UDPStream); err != nil {
		return err
	}

	if err := validate.MinimumInt("udpStream", "body", *m.UDPStream, 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("udpStream", "body", *m.UDPStream, 1.2096e+06, false); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this conntrack timeouts based on context it is used
func (m *ConntrackTimeouts) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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