// 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"
)

// APIGetGatewayMetricsResponse api get gateway metrics response
//
// swagger:model apiGetGatewayMetricsResponse
type APIGetGatewayMetricsResponse struct {

	// RX packets.
	RxPackets *CommonMetric `json:"rxPackets,omitempty"`

	// RX packets / DR.
	RxPacketsPerDr *CommonMetric `json:"rxPacketsPerDr,omitempty"`

	// RX packets / frequency.
	RxPacketsPerFreq *CommonMetric `json:"rxPacketsPerFreq,omitempty"`

	// TX packets.
	TxPackets *CommonMetric `json:"txPackets,omitempty"`

	// TX packets / DR.
	TxPacketsPerDr *CommonMetric `json:"txPacketsPerDr,omitempty"`

	// TX packets / frequency.
	TxPacketsPerFreq *CommonMetric `json:"txPacketsPerFreq,omitempty"`

	// TX packets per status.
	TxPacketsPerStatus *CommonMetric `json:"txPacketsPerStatus,omitempty"`
}

// Validate validates this api get gateway metrics response
func (m *APIGetGatewayMetricsResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

func (m *APIGetGatewayMetricsResponse) validateRxPackets(formats strfmt.Registry) error {
	if swag.IsZero(m.RxPackets) { // not required
		return nil
	}

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) validateRxPacketsPerDr(formats strfmt.Registry) error {
	if swag.IsZero(m.RxPacketsPerDr) { // not required
		return nil
	}

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) validateRxPacketsPerFreq(formats strfmt.Registry) error {
	if swag.IsZero(m.RxPacketsPerFreq) { // not required
		return nil
	}

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) validateTxPackets(formats strfmt.Registry) error {
	if swag.IsZero(m.TxPackets) { // not required
		return nil
	}

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) validateTxPacketsPerDr(formats strfmt.Registry) error {
	if swag.IsZero(m.TxPacketsPerDr) { // not required
		return nil
	}

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) validateTxPacketsPerFreq(formats strfmt.Registry) error {
	if swag.IsZero(m.TxPacketsPerFreq) { // not required
		return nil
	}

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) validateTxPacketsPerStatus(formats strfmt.Registry) error {
	if swag.IsZero(m.TxPacketsPerStatus) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this api get gateway metrics response based on the context it is used
func (m *APIGetGatewayMetricsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

func (m *APIGetGatewayMetricsResponse) contextValidateRxPackets(ctx context.Context, formats strfmt.Registry) error {

	if m.RxPackets != nil {

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

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) contextValidateRxPacketsPerDr(ctx context.Context, formats strfmt.Registry) error {

	if m.RxPacketsPerDr != nil {

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

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) contextValidateRxPacketsPerFreq(ctx context.Context, formats strfmt.Registry) error {

	if m.RxPacketsPerFreq != nil {

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

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) contextValidateTxPackets(ctx context.Context, formats strfmt.Registry) error {

	if m.TxPackets != nil {

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

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) contextValidateTxPacketsPerDr(ctx context.Context, formats strfmt.Registry) error {

	if m.TxPacketsPerDr != nil {

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

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) contextValidateTxPacketsPerFreq(ctx context.Context, formats strfmt.Registry) error {

	if m.TxPacketsPerFreq != nil {

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

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

	return nil
}

func (m *APIGetGatewayMetricsResponse) contextValidateTxPacketsPerStatus(ctx context.Context, formats strfmt.Registry) error {

	if m.TxPacketsPerStatus != nil {

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

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

	return nil
}

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

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