Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
133
pkg/ota_api/models/common_add_car_request.go
Normal file
133
pkg/ota_api/models/common_add_car_request.go
Normal file
@@ -0,0 +1,133 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// CommonAddCarRequest common add car request
|
||||
//
|
||||
// swagger:model common.AddCarRequest
|
||||
type CommonAddCarRequest struct {
|
||||
|
||||
// canbus
|
||||
Canbus *CommonCANBus `json:"canbus,omitempty"`
|
||||
|
||||
// idps enabled
|
||||
IdpsEnabled bool `json:"idps_enabled,omitempty"`
|
||||
|
||||
// log level
|
||||
LogLevel string `json:"log_level,omitempty"`
|
||||
|
||||
// vin
|
||||
// Required: true
|
||||
Vin *string `json:"vin"`
|
||||
}
|
||||
|
||||
// Validate validates this common add car request
|
||||
func (m *CommonAddCarRequest) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateCanbus(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateVin(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CommonAddCarRequest) 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 *CommonAddCarRequest) validateVin(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("vin", "body", m.Vin); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this common add car request based on the context it is used
|
||||
func (m *CommonAddCarRequest) 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 *CommonAddCarRequest) 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 *CommonAddCarRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *CommonAddCarRequest) UnmarshalBinary(b []byte) error {
|
||||
var res CommonAddCarRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user