// 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" ) // CommonUpdateManifest common update manifest // // swagger:model common.UpdateManifest type CommonUpdateManifest 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"` // 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"` // 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 update manifest func (m *CommonUpdateManifest) 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 *CommonUpdateManifest) 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 *CommonUpdateManifest) 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 *CommonUpdateManifest) 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 *CommonUpdateManifest) 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 *CommonUpdateManifest) 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 *CommonUpdateManifest) 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 *CommonUpdateManifest) 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 update manifest based on the context it is used func (m *CommonUpdateManifest) 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 *CommonUpdateManifest) 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 *CommonUpdateManifest) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *CommonUpdateManifest) UnmarshalBinary(b []byte) error { var res CommonUpdateManifest if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }