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

// MongoFleet mongo fleet
//
// swagger:model mongo.Fleet
type MongoFleet struct {

	// canbus
	Canbus *CommonCANBus `json:"canbus,omitempty"`

	// debug mask
	DebugMask string `json:"debug_mask,omitempty"`

	// idps enabled
	IdpsEnabled bool `json:"idps_enabled,omitempty"`

	// log level
	LogLevel int64 `json:"log_level,omitempty"`

	// name
	Name string `json:"name,omitempty"`

	// tags
	Tags []string `json:"tags"`

	// vehicles
	Vehicles []string `json:"vehicles"`

	// vehicles count
	VehiclesCount int64 `json:"vehicles_count,omitempty"`
}

// Validate validates this mongo fleet
func (m *MongoFleet) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *MongoFleet) validateCanbus(formats strfmt.Registry) error {
	if swag.IsZero(m.Canbus) { // not required
		return nil
	}

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

	return nil
}

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

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

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

func (m *MongoFleet) contextValidateCanbus(ctx context.Context, formats strfmt.Registry) error {

	if m.Canbus != nil {

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

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

	return nil
}

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

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