github.com/digitalocean/go-netbox@v0.0.2/netbox/models/image_attachment.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright 2020 The go-netbox Authors. 4 // 5 // Licensed under the Apache License, Version 2.0 (the "License"); 6 // you may not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 // 17 18 package models 19 20 // This file was generated by the swagger tool. 21 // Editing this file might prove futile when you re-run the swagger generate command 22 23 import ( 24 "context" 25 26 "github.com/go-openapi/errors" 27 "github.com/go-openapi/strfmt" 28 "github.com/go-openapi/swag" 29 "github.com/go-openapi/validate" 30 ) 31 32 // ImageAttachment image attachment 33 // 34 // swagger:model ImageAttachment 35 type ImageAttachment struct { 36 37 // Content type 38 // Required: true 39 ContentType *string `json:"content_type"` 40 41 // Created 42 // Read Only: true 43 // Format: date-time 44 Created strfmt.DateTime `json:"created,omitempty"` 45 46 // Display 47 // Read Only: true 48 Display string `json:"display,omitempty"` 49 50 // Id 51 // Read Only: true 52 ID int64 `json:"id,omitempty"` 53 54 // Image 55 // Read Only: true 56 // Format: uri 57 Image strfmt.URI `json:"image,omitempty"` 58 59 // Image height 60 // Required: true 61 // Maximum: 32767 62 // Minimum: 0 63 ImageHeight *int64 `json:"image_height"` 64 65 // Image width 66 // Required: true 67 // Maximum: 32767 68 // Minimum: 0 69 ImageWidth *int64 `json:"image_width"` 70 71 // Name 72 // Max Length: 50 73 Name string `json:"name,omitempty"` 74 75 // Object id 76 // Required: true 77 // Maximum: 2.147483647e+09 78 // Minimum: 0 79 ObjectID *int64 `json:"object_id"` 80 81 // Parent 82 // Read Only: true 83 Parent map[string]*string `json:"parent,omitempty"` 84 85 // Url 86 // Read Only: true 87 // Format: uri 88 URL strfmt.URI `json:"url,omitempty"` 89 } 90 91 // Validate validates this image attachment 92 func (m *ImageAttachment) Validate(formats strfmt.Registry) error { 93 var res []error 94 95 if err := m.validateContentType(formats); err != nil { 96 res = append(res, err) 97 } 98 99 if err := m.validateCreated(formats); err != nil { 100 res = append(res, err) 101 } 102 103 if err := m.validateImage(formats); err != nil { 104 res = append(res, err) 105 } 106 107 if err := m.validateImageHeight(formats); err != nil { 108 res = append(res, err) 109 } 110 111 if err := m.validateImageWidth(formats); err != nil { 112 res = append(res, err) 113 } 114 115 if err := m.validateName(formats); err != nil { 116 res = append(res, err) 117 } 118 119 if err := m.validateObjectID(formats); err != nil { 120 res = append(res, err) 121 } 122 123 if err := m.validateURL(formats); err != nil { 124 res = append(res, err) 125 } 126 127 if len(res) > 0 { 128 return errors.CompositeValidationError(res...) 129 } 130 return nil 131 } 132 133 func (m *ImageAttachment) validateContentType(formats strfmt.Registry) error { 134 135 if err := validate.Required("content_type", "body", m.ContentType); err != nil { 136 return err 137 } 138 139 return nil 140 } 141 142 func (m *ImageAttachment) validateCreated(formats strfmt.Registry) error { 143 if swag.IsZero(m.Created) { // not required 144 return nil 145 } 146 147 if err := validate.FormatOf("created", "body", "date-time", m.Created.String(), formats); err != nil { 148 return err 149 } 150 151 return nil 152 } 153 154 func (m *ImageAttachment) validateImage(formats strfmt.Registry) error { 155 if swag.IsZero(m.Image) { // not required 156 return nil 157 } 158 159 if err := validate.FormatOf("image", "body", "uri", m.Image.String(), formats); err != nil { 160 return err 161 } 162 163 return nil 164 } 165 166 func (m *ImageAttachment) validateImageHeight(formats strfmt.Registry) error { 167 168 if err := validate.Required("image_height", "body", m.ImageHeight); err != nil { 169 return err 170 } 171 172 if err := validate.MinimumInt("image_height", "body", *m.ImageHeight, 0, false); err != nil { 173 return err 174 } 175 176 if err := validate.MaximumInt("image_height", "body", *m.ImageHeight, 32767, false); err != nil { 177 return err 178 } 179 180 return nil 181 } 182 183 func (m *ImageAttachment) validateImageWidth(formats strfmt.Registry) error { 184 185 if err := validate.Required("image_width", "body", m.ImageWidth); err != nil { 186 return err 187 } 188 189 if err := validate.MinimumInt("image_width", "body", *m.ImageWidth, 0, false); err != nil { 190 return err 191 } 192 193 if err := validate.MaximumInt("image_width", "body", *m.ImageWidth, 32767, false); err != nil { 194 return err 195 } 196 197 return nil 198 } 199 200 func (m *ImageAttachment) validateName(formats strfmt.Registry) error { 201 if swag.IsZero(m.Name) { // not required 202 return nil 203 } 204 205 if err := validate.MaxLength("name", "body", m.Name, 50); err != nil { 206 return err 207 } 208 209 return nil 210 } 211 212 func (m *ImageAttachment) validateObjectID(formats strfmt.Registry) error { 213 214 if err := validate.Required("object_id", "body", m.ObjectID); err != nil { 215 return err 216 } 217 218 if err := validate.MinimumInt("object_id", "body", *m.ObjectID, 0, false); err != nil { 219 return err 220 } 221 222 if err := validate.MaximumInt("object_id", "body", *m.ObjectID, 2.147483647e+09, false); err != nil { 223 return err 224 } 225 226 return nil 227 } 228 229 func (m *ImageAttachment) validateURL(formats strfmt.Registry) error { 230 if swag.IsZero(m.URL) { // not required 231 return nil 232 } 233 234 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 235 return err 236 } 237 238 return nil 239 } 240 241 // ContextValidate validate this image attachment based on the context it is used 242 func (m *ImageAttachment) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 243 var res []error 244 245 if err := m.contextValidateCreated(ctx, formats); err != nil { 246 res = append(res, err) 247 } 248 249 if err := m.contextValidateDisplay(ctx, formats); err != nil { 250 res = append(res, err) 251 } 252 253 if err := m.contextValidateID(ctx, formats); err != nil { 254 res = append(res, err) 255 } 256 257 if err := m.contextValidateImage(ctx, formats); err != nil { 258 res = append(res, err) 259 } 260 261 if err := m.contextValidateParent(ctx, formats); err != nil { 262 res = append(res, err) 263 } 264 265 if err := m.contextValidateURL(ctx, formats); err != nil { 266 res = append(res, err) 267 } 268 269 if len(res) > 0 { 270 return errors.CompositeValidationError(res...) 271 } 272 return nil 273 } 274 275 func (m *ImageAttachment) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 276 277 if err := validate.ReadOnly(ctx, "created", "body", strfmt.DateTime(m.Created)); err != nil { 278 return err 279 } 280 281 return nil 282 } 283 284 func (m *ImageAttachment) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 285 286 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 287 return err 288 } 289 290 return nil 291 } 292 293 func (m *ImageAttachment) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 294 295 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 296 return err 297 } 298 299 return nil 300 } 301 302 func (m *ImageAttachment) contextValidateImage(ctx context.Context, formats strfmt.Registry) error { 303 304 if err := validate.ReadOnly(ctx, "image", "body", strfmt.URI(m.Image)); err != nil { 305 return err 306 } 307 308 return nil 309 } 310 311 func (m *ImageAttachment) contextValidateParent(ctx context.Context, formats strfmt.Registry) error { 312 313 return nil 314 } 315 316 func (m *ImageAttachment) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 317 318 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 319 return err 320 } 321 322 return nil 323 } 324 325 // MarshalBinary interface implementation 326 func (m *ImageAttachment) MarshalBinary() ([]byte, error) { 327 if m == nil { 328 return nil, nil 329 } 330 return swag.WriteJSON(m) 331 } 332 333 // UnmarshalBinary interface implementation 334 func (m *ImageAttachment) UnmarshalBinary(b []byte) error { 335 var res ImageAttachment 336 if err := swag.ReadJSON(b, &res); err != nil { 337 return err 338 } 339 *m = res 340 return nil 341 }