Files
cloud-services/pkg/ota_api/models/common_status_manifest.go

312 lines
6.8 KiB
Go

// 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"
)
// CommonStatusManifest common status manifest
//
// swagger:model common.StatusManifest
type CommonStatusManifest struct {
// Use a pointer so we know when we want to change the value
Active bool `json:"active,omitempty"`
// body type
BodyType string `json:"body_type,omitempty"`
// car update id
CarUpdateID int64 `json:"car_update_id,omitempty"`
// country
Country string `json:"country,omitempty"`
// description
// Max Length: 5120
Description string `json:"description,omitempty"`
// ecu list
EcuList string `json:"ecu_list,omitempty"`
// ecu updates
// Min Items: 1
EcuUpdates []*CommonUpdateManifestECU `json:"ecu_updates"`
// Environment of ECC keys to include
Env string `json:"env,omitempty"`
// fingerprint
// Max Length: 5000
Fingerprint string `json:"fingerprint,omitempty"`
// id
ID int64 `json:"id,omitempty"`
// manifest created
ManifestCreated string `json:"manifest_created,omitempty"`
// max attempts
MaxAttempts int64 `json:"max_attempts,omitempty"`
// model
Model string `json:"model,omitempty"`
// name
// Required: true
// Max Length: 255
Name *string `json:"name"`
// powertrain
Powertrain string `json:"powertrain,omitempty"`
// release notes
// Max Length: 32768
ReleaseNotes string `json:"release_notes,omitempty"`
// restraint
Restraint string `json:"restraint,omitempty"`
// rollback
Rollback bool `json:"rollback,omitempty"`
// status
Status string `json:"status,omitempty"`
// status updated
StatusUpdated string `json:"status_updated,omitempty"`
// Software Update Management System
Sums string `json:"sums,omitempty"`
// trim
Trim string `json:"trim,omitempty"`
// type
// Max Length: 100
Type string `json:"type,omitempty"`
// Duration of update in minutes
UpdateDuration int64 `json:"update_duration,omitempty"`
// version
// Max Length: 255
Version string `json:"version,omitempty"`
// vod
Vod string `json:"vod,omitempty"`
// year
Year int64 `json:"year,omitempty"`
}
// Validate validates this common status manifest
func (m *CommonStatusManifest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDescription(formats); err != nil {
res = append(res, err)
}
if err := m.validateEcuUpdates(formats); err != nil {
res = append(res, err)
}
if err := m.validateFingerprint(formats); err != nil {
res = append(res, err)
}
if err := m.validateName(formats); err != nil {
res = append(res, err)
}
if err := m.validateReleaseNotes(formats); err != nil {
res = append(res, err)
}
if err := m.validateType(formats); err != nil {
res = append(res, err)
}
if err := m.validateVersion(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *CommonStatusManifest) validateDescription(formats strfmt.Registry) error {
if swag.IsZero(m.Description) { // not required
return nil
}
if err := validate.MaxLength("description", "body", m.Description, 5120); err != nil {
return err
}
return nil
}
func (m *CommonStatusManifest) 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 *CommonStatusManifest) validateFingerprint(formats strfmt.Registry) error {
if swag.IsZero(m.Fingerprint) { // not required
return nil
}
if err := validate.MaxLength("fingerprint", "body", m.Fingerprint, 5000); err != nil {
return err
}
return nil
}
func (m *CommonStatusManifest) validateName(formats strfmt.Registry) error {
if err := validate.Required("name", "body", m.Name); err != nil {
return err
}
if err := validate.MaxLength("name", "body", *m.Name, 255); err != nil {
return err
}
return nil
}
func (m *CommonStatusManifest) validateReleaseNotes(formats strfmt.Registry) error {
if swag.IsZero(m.ReleaseNotes) { // not required
return nil
}
if err := validate.MaxLength("release_notes", "body", m.ReleaseNotes, 32768); err != nil {
return err
}
return nil
}
func (m *CommonStatusManifest) 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
}
func (m *CommonStatusManifest) validateVersion(formats strfmt.Registry) error {
if swag.IsZero(m.Version) { // not required
return nil
}
if err := validate.MaxLength("version", "body", m.Version, 255); err != nil {
return err
}
return nil
}
// ContextValidate validate this common status manifest based on the context it is used
func (m *CommonStatusManifest) 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 *CommonStatusManifest) 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 *CommonStatusManifest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *CommonStatusManifest) UnmarshalBinary(b []byte) error {
var res CommonStatusManifest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}