github.com/minio/console@v1.3.0/models/server_properties.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // This file is part of MinIO Console Server 4 // Copyright (c) 2023 MinIO, Inc. 5 // 6 // This program is free software: you can redistribute it and/or modify 7 // it under the terms of the GNU Affero General Public License as published by 8 // the Free Software Foundation, either version 3 of the License, or 9 // (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU Affero General Public License for more details. 15 // 16 // You should have received a copy of the GNU Affero General Public License 17 // along with this program. If not, see <http://www.gnu.org/licenses/>. 18 // 19 20 package models 21 22 // This file was generated by the swagger tool. 23 // Editing this file might prove futile when you re-run the swagger generate command 24 25 import ( 26 "context" 27 "strconv" 28 29 "github.com/go-openapi/errors" 30 "github.com/go-openapi/strfmt" 31 "github.com/go-openapi/swag" 32 ) 33 34 // ServerProperties server properties 35 // 36 // swagger:model serverProperties 37 type ServerProperties struct { 38 39 // commit ID 40 CommitID string `json:"commitID,omitempty"` 41 42 // drives 43 Drives []*ServerDrives `json:"drives"` 44 45 // endpoint 46 Endpoint string `json:"endpoint,omitempty"` 47 48 // network 49 Network map[string]string `json:"network,omitempty"` 50 51 // pool number 52 PoolNumber int64 `json:"poolNumber,omitempty"` 53 54 // state 55 State string `json:"state,omitempty"` 56 57 // uptime 58 Uptime int64 `json:"uptime,omitempty"` 59 60 // version 61 Version string `json:"version,omitempty"` 62 } 63 64 // Validate validates this server properties 65 func (m *ServerProperties) Validate(formats strfmt.Registry) error { 66 var res []error 67 68 if err := m.validateDrives(formats); err != nil { 69 res = append(res, err) 70 } 71 72 if len(res) > 0 { 73 return errors.CompositeValidationError(res...) 74 } 75 return nil 76 } 77 78 func (m *ServerProperties) validateDrives(formats strfmt.Registry) error { 79 if swag.IsZero(m.Drives) { // not required 80 return nil 81 } 82 83 for i := 0; i < len(m.Drives); i++ { 84 if swag.IsZero(m.Drives[i]) { // not required 85 continue 86 } 87 88 if m.Drives[i] != nil { 89 if err := m.Drives[i].Validate(formats); err != nil { 90 if ve, ok := err.(*errors.Validation); ok { 91 return ve.ValidateName("drives" + "." + strconv.Itoa(i)) 92 } else if ce, ok := err.(*errors.CompositeError); ok { 93 return ce.ValidateName("drives" + "." + strconv.Itoa(i)) 94 } 95 return err 96 } 97 } 98 99 } 100 101 return nil 102 } 103 104 // ContextValidate validate this server properties based on the context it is used 105 func (m *ServerProperties) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 106 var res []error 107 108 if err := m.contextValidateDrives(ctx, formats); err != nil { 109 res = append(res, err) 110 } 111 112 if len(res) > 0 { 113 return errors.CompositeValidationError(res...) 114 } 115 return nil 116 } 117 118 func (m *ServerProperties) contextValidateDrives(ctx context.Context, formats strfmt.Registry) error { 119 120 for i := 0; i < len(m.Drives); i++ { 121 122 if m.Drives[i] != nil { 123 124 if swag.IsZero(m.Drives[i]) { // not required 125 return nil 126 } 127 128 if err := m.Drives[i].ContextValidate(ctx, formats); err != nil { 129 if ve, ok := err.(*errors.Validation); ok { 130 return ve.ValidateName("drives" + "." + strconv.Itoa(i)) 131 } else if ce, ok := err.(*errors.CompositeError); ok { 132 return ce.ValidateName("drives" + "." + strconv.Itoa(i)) 133 } 134 return err 135 } 136 } 137 138 } 139 140 return nil 141 } 142 143 // MarshalBinary interface implementation 144 func (m *ServerProperties) MarshalBinary() ([]byte, error) { 145 if m == nil { 146 return nil, nil 147 } 148 return swag.WriteJSON(m) 149 } 150 151 // UnmarshalBinary interface implementation 152 func (m *ServerProperties) UnmarshalBinary(b []byte) error { 153 var res ServerProperties 154 if err := swag.ReadJSON(b, &res); err != nil { 155 return err 156 } 157 *m = res 158 return nil 159 }