Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
155
pkg/ota_api/models/common_update_config_manifest.go
Normal file
155
pkg/ota_api/models/common_update_config_manifest.go
Normal file
@@ -0,0 +1,155 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// CommonUpdateConfigManifest common update config manifest
|
||||
//
|
||||
// swagger:model common.UpdateConfigManifest
|
||||
type CommonUpdateConfigManifest struct {
|
||||
|
||||
// car update id
|
||||
CarUpdateID int64 `json:"car_update_id,omitempty"`
|
||||
|
||||
// ecu updates
|
||||
// Min Items: 1
|
||||
EcuUpdates []*CommonUpdateConfigManifestECU `json:"ecu_updates"`
|
||||
|
||||
// This can be maybe removed, since only one type of update will be sent with this\
|
||||
// Max Length: 100
|
||||
Type string `json:"type,omitempty"`
|
||||
|
||||
// vod
|
||||
Vod string `json:"vod,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this common update config manifest
|
||||
func (m *CommonUpdateConfigManifest) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateEcuUpdates(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateType(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CommonUpdateConfigManifest) validateEcuUpdates(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.EcuUpdates) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
iEcuUpdatesSize := int64(len(m.EcuUpdates))
|
||||
|
||||
if err := validate.MinItems("ecu_updates", "body", iEcuUpdatesSize, 1); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.EcuUpdates); i++ {
|
||||
if swag.IsZero(m.EcuUpdates[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.EcuUpdates[i] != nil {
|
||||
if err := m.EcuUpdates[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("ecu_updates" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("ecu_updates" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CommonUpdateConfigManifest) validateType(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Type) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validate.MaxLength("type", "body", m.Type, 100); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this common update config manifest based on the context it is used
|
||||
func (m *CommonUpdateConfigManifest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateEcuUpdates(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CommonUpdateConfigManifest) contextValidateEcuUpdates(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.EcuUpdates); i++ {
|
||||
|
||||
if m.EcuUpdates[i] != nil {
|
||||
|
||||
if swag.IsZero(m.EcuUpdates[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.EcuUpdates[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("ecu_updates" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("ecu_updates" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *CommonUpdateConfigManifest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *CommonUpdateConfigManifest) UnmarshalBinary(b []byte) error {
|
||||
var res CommonUpdateConfigManifest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user