github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_console_port_template.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 "encoding/json" 26 27 "github.com/go-openapi/errors" 28 "github.com/go-openapi/strfmt" 29 "github.com/go-openapi/swag" 30 "github.com/go-openapi/validate" 31 ) 32 33 // WritableConsolePortTemplate writable console port template 34 // 35 // swagger:model WritableConsolePortTemplate 36 type WritableConsolePortTemplate struct { 37 38 // Created 39 // Read Only: true 40 // Format: date 41 Created strfmt.Date `json:"created,omitempty"` 42 43 // Description 44 // Max Length: 200 45 Description string `json:"description,omitempty"` 46 47 // Device type 48 // Required: true 49 DeviceType *int64 `json:"device_type"` 50 51 // Display 52 // Read Only: true 53 Display string `json:"display,omitempty"` 54 55 // Id 56 // Read Only: true 57 ID int64 `json:"id,omitempty"` 58 59 // Label 60 // 61 // Physical label 62 // Max Length: 64 63 Label string `json:"label,omitempty"` 64 65 // Last updated 66 // Read Only: true 67 // Format: date-time 68 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 69 70 // Name 71 // Required: true 72 // Max Length: 64 73 // Min Length: 1 74 Name *string `json:"name"` 75 76 // Type 77 // Enum: [de-9 db-25 rj-11 rj-12 rj-45 usb-a usb-b usb-c usb-mini-a usb-mini-b usb-micro-a usb-micro-b other] 78 Type string `json:"type,omitempty"` 79 80 // Url 81 // Read Only: true 82 // Format: uri 83 URL strfmt.URI `json:"url,omitempty"` 84 } 85 86 // Validate validates this writable console port template 87 func (m *WritableConsolePortTemplate) Validate(formats strfmt.Registry) error { 88 var res []error 89 90 if err := m.validateCreated(formats); err != nil { 91 res = append(res, err) 92 } 93 94 if err := m.validateDescription(formats); err != nil { 95 res = append(res, err) 96 } 97 98 if err := m.validateDeviceType(formats); err != nil { 99 res = append(res, err) 100 } 101 102 if err := m.validateLabel(formats); err != nil { 103 res = append(res, err) 104 } 105 106 if err := m.validateLastUpdated(formats); err != nil { 107 res = append(res, err) 108 } 109 110 if err := m.validateName(formats); err != nil { 111 res = append(res, err) 112 } 113 114 if err := m.validateType(formats); err != nil { 115 res = append(res, err) 116 } 117 118 if err := m.validateURL(formats); err != nil { 119 res = append(res, err) 120 } 121 122 if len(res) > 0 { 123 return errors.CompositeValidationError(res...) 124 } 125 return nil 126 } 127 128 func (m *WritableConsolePortTemplate) validateCreated(formats strfmt.Registry) error { 129 if swag.IsZero(m.Created) { // not required 130 return nil 131 } 132 133 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 134 return err 135 } 136 137 return nil 138 } 139 140 func (m *WritableConsolePortTemplate) validateDescription(formats strfmt.Registry) error { 141 if swag.IsZero(m.Description) { // not required 142 return nil 143 } 144 145 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 146 return err 147 } 148 149 return nil 150 } 151 152 func (m *WritableConsolePortTemplate) validateDeviceType(formats strfmt.Registry) error { 153 154 if err := validate.Required("device_type", "body", m.DeviceType); err != nil { 155 return err 156 } 157 158 return nil 159 } 160 161 func (m *WritableConsolePortTemplate) validateLabel(formats strfmt.Registry) error { 162 if swag.IsZero(m.Label) { // not required 163 return nil 164 } 165 166 if err := validate.MaxLength("label", "body", m.Label, 64); err != nil { 167 return err 168 } 169 170 return nil 171 } 172 173 func (m *WritableConsolePortTemplate) validateLastUpdated(formats strfmt.Registry) error { 174 if swag.IsZero(m.LastUpdated) { // not required 175 return nil 176 } 177 178 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 179 return err 180 } 181 182 return nil 183 } 184 185 func (m *WritableConsolePortTemplate) validateName(formats strfmt.Registry) error { 186 187 if err := validate.Required("name", "body", m.Name); err != nil { 188 return err 189 } 190 191 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 192 return err 193 } 194 195 if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil { 196 return err 197 } 198 199 return nil 200 } 201 202 var writableConsolePortTemplateTypeTypePropEnum []interface{} 203 204 func init() { 205 var res []string 206 if err := json.Unmarshal([]byte(`["de-9","db-25","rj-11","rj-12","rj-45","usb-a","usb-b","usb-c","usb-mini-a","usb-mini-b","usb-micro-a","usb-micro-b","other"]`), &res); err != nil { 207 panic(err) 208 } 209 for _, v := range res { 210 writableConsolePortTemplateTypeTypePropEnum = append(writableConsolePortTemplateTypeTypePropEnum, v) 211 } 212 } 213 214 const ( 215 216 // WritableConsolePortTemplateTypeDeDash9 captures enum value "de-9" 217 WritableConsolePortTemplateTypeDeDash9 string = "de-9" 218 219 // WritableConsolePortTemplateTypeDbDash25 captures enum value "db-25" 220 WritableConsolePortTemplateTypeDbDash25 string = "db-25" 221 222 // WritableConsolePortTemplateTypeRjDash11 captures enum value "rj-11" 223 WritableConsolePortTemplateTypeRjDash11 string = "rj-11" 224 225 // WritableConsolePortTemplateTypeRjDash12 captures enum value "rj-12" 226 WritableConsolePortTemplateTypeRjDash12 string = "rj-12" 227 228 // WritableConsolePortTemplateTypeRjDash45 captures enum value "rj-45" 229 WritableConsolePortTemplateTypeRjDash45 string = "rj-45" 230 231 // WritableConsolePortTemplateTypeUsbDasha captures enum value "usb-a" 232 WritableConsolePortTemplateTypeUsbDasha string = "usb-a" 233 234 // WritableConsolePortTemplateTypeUsbDashb captures enum value "usb-b" 235 WritableConsolePortTemplateTypeUsbDashb string = "usb-b" 236 237 // WritableConsolePortTemplateTypeUsbDashc captures enum value "usb-c" 238 WritableConsolePortTemplateTypeUsbDashc string = "usb-c" 239 240 // WritableConsolePortTemplateTypeUsbDashMiniDasha captures enum value "usb-mini-a" 241 WritableConsolePortTemplateTypeUsbDashMiniDasha string = "usb-mini-a" 242 243 // WritableConsolePortTemplateTypeUsbDashMiniDashb captures enum value "usb-mini-b" 244 WritableConsolePortTemplateTypeUsbDashMiniDashb string = "usb-mini-b" 245 246 // WritableConsolePortTemplateTypeUsbDashMicroDasha captures enum value "usb-micro-a" 247 WritableConsolePortTemplateTypeUsbDashMicroDasha string = "usb-micro-a" 248 249 // WritableConsolePortTemplateTypeUsbDashMicroDashb captures enum value "usb-micro-b" 250 WritableConsolePortTemplateTypeUsbDashMicroDashb string = "usb-micro-b" 251 252 // WritableConsolePortTemplateTypeOther captures enum value "other" 253 WritableConsolePortTemplateTypeOther string = "other" 254 ) 255 256 // prop value enum 257 func (m *WritableConsolePortTemplate) validateTypeEnum(path, location string, value string) error { 258 if err := validate.EnumCase(path, location, value, writableConsolePortTemplateTypeTypePropEnum, true); err != nil { 259 return err 260 } 261 return nil 262 } 263 264 func (m *WritableConsolePortTemplate) validateType(formats strfmt.Registry) error { 265 if swag.IsZero(m.Type) { // not required 266 return nil 267 } 268 269 // value enum 270 if err := m.validateTypeEnum("type", "body", m.Type); err != nil { 271 return err 272 } 273 274 return nil 275 } 276 277 func (m *WritableConsolePortTemplate) validateURL(formats strfmt.Registry) error { 278 if swag.IsZero(m.URL) { // not required 279 return nil 280 } 281 282 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 283 return err 284 } 285 286 return nil 287 } 288 289 // ContextValidate validate this writable console port template based on the context it is used 290 func (m *WritableConsolePortTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 291 var res []error 292 293 if err := m.contextValidateCreated(ctx, formats); err != nil { 294 res = append(res, err) 295 } 296 297 if err := m.contextValidateDisplay(ctx, formats); err != nil { 298 res = append(res, err) 299 } 300 301 if err := m.contextValidateID(ctx, formats); err != nil { 302 res = append(res, err) 303 } 304 305 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 306 res = append(res, err) 307 } 308 309 if err := m.contextValidateURL(ctx, formats); err != nil { 310 res = append(res, err) 311 } 312 313 if len(res) > 0 { 314 return errors.CompositeValidationError(res...) 315 } 316 return nil 317 } 318 319 func (m *WritableConsolePortTemplate) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 320 321 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 322 return err 323 } 324 325 return nil 326 } 327 328 func (m *WritableConsolePortTemplate) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 329 330 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 331 return err 332 } 333 334 return nil 335 } 336 337 func (m *WritableConsolePortTemplate) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 338 339 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 340 return err 341 } 342 343 return nil 344 } 345 346 func (m *WritableConsolePortTemplate) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 347 348 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 349 return err 350 } 351 352 return nil 353 } 354 355 func (m *WritableConsolePortTemplate) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 356 357 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 358 return err 359 } 360 361 return nil 362 } 363 364 // MarshalBinary interface implementation 365 func (m *WritableConsolePortTemplate) MarshalBinary() ([]byte, error) { 366 if m == nil { 367 return nil, nil 368 } 369 return swag.WriteJSON(m) 370 } 371 372 // UnmarshalBinary interface implementation 373 func (m *WritableConsolePortTemplate) UnmarshalBinary(b []byte) error { 374 var res WritableConsolePortTemplate 375 if err := swag.ReadJSON(b, &res); err != nil { 376 return err 377 } 378 *m = res 379 return nil 380 }