github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/system_info.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 "strconv" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/strfmt" 14 "github.com/go-openapi/swag" 15 ) 16 17 // SystemInfo system info 18 // 19 // swagger:model SystemInfo 20 type SystemInfo struct { 21 22 // The storage of system. 23 Storage []*Storage `json:"storage"` 24 } 25 26 // Validate validates this system info 27 func (m *SystemInfo) Validate(formats strfmt.Registry) error { 28 var res []error 29 30 if err := m.validateStorage(formats); err != nil { 31 res = append(res, err) 32 } 33 34 if len(res) > 0 { 35 return errors.CompositeValidationError(res...) 36 } 37 return nil 38 } 39 40 func (m *SystemInfo) validateStorage(formats strfmt.Registry) error { 41 if swag.IsZero(m.Storage) { // not required 42 return nil 43 } 44 45 for i := 0; i < len(m.Storage); i++ { 46 if swag.IsZero(m.Storage[i]) { // not required 47 continue 48 } 49 50 if m.Storage[i] != nil { 51 if err := m.Storage[i].Validate(formats); err != nil { 52 if ve, ok := err.(*errors.Validation); ok { 53 return ve.ValidateName("storage" + "." + strconv.Itoa(i)) 54 } else if ce, ok := err.(*errors.CompositeError); ok { 55 return ce.ValidateName("storage" + "." + strconv.Itoa(i)) 56 } 57 return err 58 } 59 } 60 61 } 62 63 return nil 64 } 65 66 // ContextValidate validate this system info based on the context it is used 67 func (m *SystemInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 68 var res []error 69 70 if err := m.contextValidateStorage(ctx, formats); err != nil { 71 res = append(res, err) 72 } 73 74 if len(res) > 0 { 75 return errors.CompositeValidationError(res...) 76 } 77 return nil 78 } 79 80 func (m *SystemInfo) contextValidateStorage(ctx context.Context, formats strfmt.Registry) error { 81 82 for i := 0; i < len(m.Storage); i++ { 83 84 if m.Storage[i] != nil { 85 if err := m.Storage[i].ContextValidate(ctx, formats); err != nil { 86 if ve, ok := err.(*errors.Validation); ok { 87 return ve.ValidateName("storage" + "." + strconv.Itoa(i)) 88 } else if ce, ok := err.(*errors.CompositeError); ok { 89 return ce.ValidateName("storage" + "." + strconv.Itoa(i)) 90 } 91 return err 92 } 93 } 94 95 } 96 97 return nil 98 } 99 100 // MarshalBinary interface implementation 101 func (m *SystemInfo) MarshalBinary() ([]byte, error) { 102 if m == nil { 103 return nil, nil 104 } 105 return swag.WriteJSON(m) 106 } 107 108 // UnmarshalBinary interface implementation 109 func (m *SystemInfo) UnmarshalBinary(b []byte) error { 110 var res SystemInfo 111 if err := swag.ReadJSON(b, &res); err != nil { 112 return err 113 } 114 *m = res 115 return nil 116 }