// 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"
	"github.com/go-openapi/validate"
)

// GroupNetFlowRecord group net flow record
//
// swagger:model GroupNetFlowRecord
type GroupNetFlowRecord struct {

	// destination m bytes
	// Read Only: true
	DestinationMBytes float64 `json:"destinationMBytes,omitempty"`

	// device display name
	DeviceDisplayName string `json:"deviceDisplayName,omitempty"`

	// dst DNS
	// Read Only: true
	DstDNS string `json:"dstDNS,omitempty"`

	// dst IP
	// Read Only: true
	DstIP string `json:"dstIP,omitempty"`

	// dst port
	// Read Only: true
	DstPort int32 `json:"dstPort,omitempty"`

	// first epoch in sec
	// Read Only: true
	FirstEpochInSec int64 `json:"firstEpochInSec,omitempty"`

	// if in
	// Read Only: true
	IfIn int64 `json:"ifIn,omitempty"`

	// if in display name
	IfInDisplayName string `json:"ifInDisplayName,omitempty"`

	// if out
	// Read Only: true
	IfOut int64 `json:"ifOut,omitempty"`

	// if out display name
	IfOutDisplayName string `json:"ifOutDisplayName,omitempty"`

	// last epoch in sec
	// Read Only: true
	LastEpochInSec int64 `json:"lastEpochInSec,omitempty"`

	// percent usage
	// Read Only: true
	PercentUsage float64 `json:"percentUsage,omitempty"`

	// protocol
	// Read Only: true
	Protocol string `json:"protocol,omitempty"`

	// source m bytes
	// Read Only: true
	SourceMBytes float64 `json:"sourceMBytes,omitempty"`

	// src DNS
	// Read Only: true
	SrcDNS string `json:"srcDNS,omitempty"`

	// src IP
	// Read Only: true
	SrcIP string `json:"srcIP,omitempty"`

	// src port
	// Read Only: true
	SrcPort int32 `json:"srcPort,omitempty"`

	// usage
	// Read Only: true
	Usage float64 `json:"usage,omitempty"`
}

// DataType gets the data type of this subtype
func (m *GroupNetFlowRecord) DataType() string {
	return "groupFlowRecord"
}

// SetDataType sets the data type of this subtype
func (m *GroupNetFlowRecord) SetDataType(val string) {
}

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

		// destination m bytes
		// Read Only: true
		DestinationMBytes float64 `json:"destinationMBytes,omitempty"`

		// device display name
		DeviceDisplayName string `json:"deviceDisplayName,omitempty"`

		// dst DNS
		// Read Only: true
		DstDNS string `json:"dstDNS,omitempty"`

		// dst IP
		// Read Only: true
		DstIP string `json:"dstIP,omitempty"`

		// dst port
		// Read Only: true
		DstPort int32 `json:"dstPort,omitempty"`

		// first epoch in sec
		// Read Only: true
		FirstEpochInSec int64 `json:"firstEpochInSec,omitempty"`

		// if in
		// Read Only: true
		IfIn int64 `json:"ifIn,omitempty"`

		// if in display name
		IfInDisplayName string `json:"ifInDisplayName,omitempty"`

		// if out
		// Read Only: true
		IfOut int64 `json:"ifOut,omitempty"`

		// if out display name
		IfOutDisplayName string `json:"ifOutDisplayName,omitempty"`

		// last epoch in sec
		// Read Only: true
		LastEpochInSec int64 `json:"lastEpochInSec,omitempty"`

		// percent usage
		// Read Only: true
		PercentUsage float64 `json:"percentUsage,omitempty"`

		// protocol
		// Read Only: true
		Protocol string `json:"protocol,omitempty"`

		// source m bytes
		// Read Only: true
		SourceMBytes float64 `json:"sourceMBytes,omitempty"`

		// src DNS
		// Read Only: true
		SrcDNS string `json:"srcDNS,omitempty"`

		// src IP
		// Read Only: true
		SrcIP string `json:"srcIP,omitempty"`

		// src port
		// Read Only: true
		SrcPort int32 `json:"srcPort,omitempty"`

		// usage
		// Read Only: true
		Usage float64 `json:"usage,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.*/

		DataType string `json:"dataType,omitempty"`
	}
	buf = bytes.NewBuffer(raw)
	dec = json.NewDecoder(buf)
	dec.UseNumber()

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

	var result GroupNetFlowRecord

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

	result.DestinationMBytes = data.DestinationMBytes
	result.DeviceDisplayName = data.DeviceDisplayName
	result.DstDNS = data.DstDNS
	result.DstIP = data.DstIP
	result.DstPort = data.DstPort
	result.FirstEpochInSec = data.FirstEpochInSec
	result.IfIn = data.IfIn
	result.IfInDisplayName = data.IfInDisplayName
	result.IfOut = data.IfOut
	result.IfOutDisplayName = data.IfOutDisplayName
	result.LastEpochInSec = data.LastEpochInSec
	result.PercentUsage = data.PercentUsage
	result.Protocol = data.Protocol
	result.SourceMBytes = data.SourceMBytes
	result.SrcDNS = data.SrcDNS
	result.SrcIP = data.SrcIP
	result.SrcPort = data.SrcPort
	result.Usage = data.Usage

	*m = result

	return nil
}

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

		// destination m bytes
		// Read Only: true
		DestinationMBytes float64 `json:"destinationMBytes,omitempty"`

		// device display name
		DeviceDisplayName string `json:"deviceDisplayName,omitempty"`

		// dst DNS
		// Read Only: true
		DstDNS string `json:"dstDNS,omitempty"`

		// dst IP
		// Read Only: true
		DstIP string `json:"dstIP,omitempty"`

		// dst port
		// Read Only: true
		DstPort int32 `json:"dstPort,omitempty"`

		// first epoch in sec
		// Read Only: true
		FirstEpochInSec int64 `json:"firstEpochInSec,omitempty"`

		// if in
		// Read Only: true
		IfIn int64 `json:"ifIn,omitempty"`

		// if in display name
		IfInDisplayName string `json:"ifInDisplayName,omitempty"`

		// if out
		// Read Only: true
		IfOut int64 `json:"ifOut,omitempty"`

		// if out display name
		IfOutDisplayName string `json:"ifOutDisplayName,omitempty"`

		// last epoch in sec
		// Read Only: true
		LastEpochInSec int64 `json:"lastEpochInSec,omitempty"`

		// percent usage
		// Read Only: true
		PercentUsage float64 `json:"percentUsage,omitempty"`

		// protocol
		// Read Only: true
		Protocol string `json:"protocol,omitempty"`

		// source m bytes
		// Read Only: true
		SourceMBytes float64 `json:"sourceMBytes,omitempty"`

		// src DNS
		// Read Only: true
		SrcDNS string `json:"srcDNS,omitempty"`

		// src IP
		// Read Only: true
		SrcIP string `json:"srcIP,omitempty"`

		// src port
		// Read Only: true
		SrcPort int32 `json:"srcPort,omitempty"`

		// usage
		// Read Only: true
		Usage float64 `json:"usage,omitempty"`
	}{

		DestinationMBytes: m.DestinationMBytes,

		DeviceDisplayName: m.DeviceDisplayName,

		DstDNS: m.DstDNS,

		DstIP: m.DstIP,

		DstPort: m.DstPort,

		FirstEpochInSec: m.FirstEpochInSec,

		IfIn: m.IfIn,

		IfInDisplayName: m.IfInDisplayName,

		IfOut: m.IfOut,

		IfOutDisplayName: m.IfOutDisplayName,

		LastEpochInSec: m.LastEpochInSec,

		PercentUsage: m.PercentUsage,

		Protocol: m.Protocol,

		SourceMBytes: m.SourceMBytes,

		SrcDNS: m.SrcDNS,

		SrcIP: m.SrcIP,

		SrcPort: m.SrcPort,

		Usage: m.Usage,
	})
	if err != nil {
		return nil, err
	}
	b2, err = json.Marshal(struct {
		DataType string `json:"dataType,omitempty"`
	}{

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

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

// Validate validates this group net flow record
func (m *GroupNetFlowRecord) Validate(formats strfmt.Registry) error {
	var res []error

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

// ContextValidate validate this group net flow record based on the context it is used
func (m *GroupNetFlowRecord) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *GroupNetFlowRecord) contextValidateDataType(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "dataType", "body", string(m.DataType())); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateDestinationMBytes(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "destinationMBytes", "body", float64(m.DestinationMBytes)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateDstDNS(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "dstDNS", "body", string(m.DstDNS)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateDstIP(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "dstIP", "body", string(m.DstIP)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateDstPort(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "dstPort", "body", int32(m.DstPort)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateFirstEpochInSec(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "firstEpochInSec", "body", int64(m.FirstEpochInSec)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateIfIn(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "ifIn", "body", int64(m.IfIn)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateIfOut(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "ifOut", "body", int64(m.IfOut)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateLastEpochInSec(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "lastEpochInSec", "body", int64(m.LastEpochInSec)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidatePercentUsage(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "percentUsage", "body", float64(m.PercentUsage)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateProtocol(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "protocol", "body", string(m.Protocol)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateSourceMBytes(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "sourceMBytes", "body", float64(m.SourceMBytes)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateSrcDNS(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "srcDNS", "body", string(m.SrcDNS)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateSrcIP(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "srcIP", "body", string(m.SrcIP)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateSrcPort(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "srcPort", "body", int32(m.SrcPort)); err != nil {
		return err
	}

	return nil
}

func (m *GroupNetFlowRecord) contextValidateUsage(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "usage", "body", float64(m.Usage)); err != nil {
		return err
	}

	return nil
}

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

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