Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
190
pkg/ota_api/models/mongo_vehicle.go
Normal file
190
pkg/ota_api/models/mongo_vehicle.go
Normal file
@@ -0,0 +1,190 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// MongoVehicle mongo vehicle
|
||||
//
|
||||
// swagger:model mongo.Vehicle
|
||||
type MongoVehicle struct {
|
||||
|
||||
// canbus
|
||||
Canbus *CommonCANBus `json:"canbus,omitempty"`
|
||||
|
||||
// debug mask
|
||||
DebugMask string `json:"debug_mask,omitempty"`
|
||||
|
||||
// dlt enabled
|
||||
DltEnabled bool `json:"dlt_enabled,omitempty"`
|
||||
|
||||
// dlt level
|
||||
DltLevel int64 `json:"dlt_level,omitempty"`
|
||||
|
||||
// fleets
|
||||
Fleets []*MongoFleet `json:"fleets"`
|
||||
|
||||
// idps enabled
|
||||
IdpsEnabled bool `json:"idps_enabled,omitempty"`
|
||||
|
||||
// log level
|
||||
LogLevel int64 `json:"log_level,omitempty"`
|
||||
|
||||
// vin
|
||||
Vin string `json:"vin,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this mongo vehicle
|
||||
func (m *MongoVehicle) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateCanbus(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateFleets(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MongoVehicle) 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
|
||||
}
|
||||
|
||||
func (m *MongoVehicle) validateFleets(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Fleets) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Fleets); i++ {
|
||||
if swag.IsZero(m.Fleets[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Fleets[i] != nil {
|
||||
if err := m.Fleets[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("fleets" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("fleets" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this mongo vehicle based on the context it is used
|
||||
func (m *MongoVehicle) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateCanbus(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.contextValidateFleets(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MongoVehicle) 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
|
||||
}
|
||||
|
||||
func (m *MongoVehicle) contextValidateFleets(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Fleets); i++ {
|
||||
|
||||
if m.Fleets[i] != nil {
|
||||
|
||||
if swag.IsZero(m.Fleets[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Fleets[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("fleets" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("fleets" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *MongoVehicle) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *MongoVehicle) UnmarshalBinary(b []byte) error {
|
||||
var res MongoVehicle
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user