Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
251
pkg/ota_api/models/common_car_to_driver.go
Normal file
251
pkg/ota_api/models/common_car_to_driver.go
Normal file
@@ -0,0 +1,251 @@
|
||||
// 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"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// CommonCarToDriver common car to driver
|
||||
//
|
||||
// swagger:model common.CarToDriver
|
||||
type CommonCarToDriver struct {
|
||||
|
||||
// ble key
|
||||
BleKey string `json:"ble_key,omitempty"`
|
||||
|
||||
// driverid
|
||||
// Required: true
|
||||
// Max Length: 256
|
||||
Driverid *string `json:"driverid"`
|
||||
|
||||
// id
|
||||
ID int64 `json:"id,omitempty"`
|
||||
|
||||
// role
|
||||
// Required: true
|
||||
// Max Length: 100
|
||||
Role *string `json:"role"`
|
||||
|
||||
// settings
|
||||
Settings []*CommonCarSetting `json:"settings"`
|
||||
|
||||
// subscriptions
|
||||
Subscriptions []*CommonSubscription `json:"subscriptions"`
|
||||
|
||||
// vin
|
||||
// Required: true
|
||||
Vin *string `json:"vin"`
|
||||
}
|
||||
|
||||
// Validate validates this common car to driver
|
||||
func (m *CommonCarToDriver) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateDriverid(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRole(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateSettings(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateSubscriptions(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 *CommonCarToDriver) validateDriverid(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("driverid", "body", m.Driverid); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.MaxLength("driverid", "body", *m.Driverid, 256); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CommonCarToDriver) validateRole(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("role", "body", m.Role); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.MaxLength("role", "body", *m.Role, 100); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CommonCarToDriver) validateSettings(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Settings) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Settings); i++ {
|
||||
if swag.IsZero(m.Settings[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Settings[i] != nil {
|
||||
if err := m.Settings[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("settings" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("settings" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CommonCarToDriver) validateSubscriptions(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Subscriptions) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Subscriptions); i++ {
|
||||
if swag.IsZero(m.Subscriptions[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Subscriptions[i] != nil {
|
||||
if err := m.Subscriptions[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("subscriptions" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("subscriptions" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CommonCarToDriver) validateVin(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("vin", "body", m.Vin); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this common car to driver based on the context it is used
|
||||
func (m *CommonCarToDriver) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateSettings(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.contextValidateSubscriptions(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CommonCarToDriver) contextValidateSettings(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Settings); i++ {
|
||||
|
||||
if m.Settings[i] != nil {
|
||||
|
||||
if swag.IsZero(m.Settings[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Settings[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("settings" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("settings" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CommonCarToDriver) contextValidateSubscriptions(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Subscriptions); i++ {
|
||||
|
||||
if m.Subscriptions[i] != nil {
|
||||
|
||||
if swag.IsZero(m.Subscriptions[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Subscriptions[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("subscriptions" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("subscriptions" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *CommonCarToDriver) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *CommonCarToDriver) UnmarshalBinary(b []byte) error {
|
||||
var res CommonCarToDriver
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user