github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_location.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 // WritableLocation writable location 33 // 34 // swagger:model WritableLocation 35 type WritableLocation struct { 36 37 // depth 38 // Read Only: true 39 Depth int64 `json:"_depth,omitempty"` 40 41 // Created 42 // Read Only: true 43 // Format: date 44 Created strfmt.Date `json:"created,omitempty"` 45 46 // Custom fields 47 CustomFields interface{} `json:"custom_fields,omitempty"` 48 49 // Description 50 // Max Length: 200 51 Description string `json:"description,omitempty"` 52 53 // Device count 54 // Read Only: true 55 DeviceCount int64 `json:"device_count,omitempty"` 56 57 // Display 58 // Read Only: true 59 Display string `json:"display,omitempty"` 60 61 // Id 62 // Read Only: true 63 ID int64 `json:"id,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: 100 73 // Min Length: 1 74 Name *string `json:"name"` 75 76 // Parent 77 Parent *int64 `json:"parent,omitempty"` 78 79 // Rack count 80 // Read Only: true 81 RackCount int64 `json:"rack_count,omitempty"` 82 83 // Site 84 // Required: true 85 Site *int64 `json:"site"` 86 87 // Slug 88 // Required: true 89 // Max Length: 100 90 // Min Length: 1 91 // Pattern: ^[-a-zA-Z0-9_]+$ 92 Slug *string `json:"slug"` 93 94 // Url 95 // Read Only: true 96 // Format: uri 97 URL strfmt.URI `json:"url,omitempty"` 98 } 99 100 // Validate validates this writable location 101 func (m *WritableLocation) Validate(formats strfmt.Registry) error { 102 var res []error 103 104 if err := m.validateCreated(formats); err != nil { 105 res = append(res, err) 106 } 107 108 if err := m.validateDescription(formats); err != nil { 109 res = append(res, err) 110 } 111 112 if err := m.validateLastUpdated(formats); err != nil { 113 res = append(res, err) 114 } 115 116 if err := m.validateName(formats); err != nil { 117 res = append(res, err) 118 } 119 120 if err := m.validateSite(formats); err != nil { 121 res = append(res, err) 122 } 123 124 if err := m.validateSlug(formats); err != nil { 125 res = append(res, err) 126 } 127 128 if err := m.validateURL(formats); err != nil { 129 res = append(res, err) 130 } 131 132 if len(res) > 0 { 133 return errors.CompositeValidationError(res...) 134 } 135 return nil 136 } 137 138 func (m *WritableLocation) validateCreated(formats strfmt.Registry) error { 139 if swag.IsZero(m.Created) { // not required 140 return nil 141 } 142 143 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 144 return err 145 } 146 147 return nil 148 } 149 150 func (m *WritableLocation) validateDescription(formats strfmt.Registry) error { 151 if swag.IsZero(m.Description) { // not required 152 return nil 153 } 154 155 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 156 return err 157 } 158 159 return nil 160 } 161 162 func (m *WritableLocation) validateLastUpdated(formats strfmt.Registry) error { 163 if swag.IsZero(m.LastUpdated) { // not required 164 return nil 165 } 166 167 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 168 return err 169 } 170 171 return nil 172 } 173 174 func (m *WritableLocation) validateName(formats strfmt.Registry) error { 175 176 if err := validate.Required("name", "body", m.Name); err != nil { 177 return err 178 } 179 180 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 181 return err 182 } 183 184 if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil { 185 return err 186 } 187 188 return nil 189 } 190 191 func (m *WritableLocation) validateSite(formats strfmt.Registry) error { 192 193 if err := validate.Required("site", "body", m.Site); err != nil { 194 return err 195 } 196 197 return nil 198 } 199 200 func (m *WritableLocation) validateSlug(formats strfmt.Registry) error { 201 202 if err := validate.Required("slug", "body", m.Slug); err != nil { 203 return err 204 } 205 206 if err := validate.MinLength("slug", "body", *m.Slug, 1); err != nil { 207 return err 208 } 209 210 if err := validate.MaxLength("slug", "body", *m.Slug, 100); err != nil { 211 return err 212 } 213 214 if err := validate.Pattern("slug", "body", *m.Slug, `^[-a-zA-Z0-9_]+$`); err != nil { 215 return err 216 } 217 218 return nil 219 } 220 221 func (m *WritableLocation) validateURL(formats strfmt.Registry) error { 222 if swag.IsZero(m.URL) { // not required 223 return nil 224 } 225 226 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 227 return err 228 } 229 230 return nil 231 } 232 233 // ContextValidate validate this writable location based on the context it is used 234 func (m *WritableLocation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 235 var res []error 236 237 if err := m.contextValidateDepth(ctx, formats); err != nil { 238 res = append(res, err) 239 } 240 241 if err := m.contextValidateCreated(ctx, formats); err != nil { 242 res = append(res, err) 243 } 244 245 if err := m.contextValidateDeviceCount(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.contextValidateLastUpdated(ctx, formats); err != nil { 258 res = append(res, err) 259 } 260 261 if err := m.contextValidateRackCount(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 *WritableLocation) contextValidateDepth(ctx context.Context, formats strfmt.Registry) error { 276 277 if err := validate.ReadOnly(ctx, "_depth", "body", int64(m.Depth)); err != nil { 278 return err 279 } 280 281 return nil 282 } 283 284 func (m *WritableLocation) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 285 286 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 287 return err 288 } 289 290 return nil 291 } 292 293 func (m *WritableLocation) contextValidateDeviceCount(ctx context.Context, formats strfmt.Registry) error { 294 295 if err := validate.ReadOnly(ctx, "device_count", "body", int64(m.DeviceCount)); err != nil { 296 return err 297 } 298 299 return nil 300 } 301 302 func (m *WritableLocation) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 303 304 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 305 return err 306 } 307 308 return nil 309 } 310 311 func (m *WritableLocation) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 312 313 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 314 return err 315 } 316 317 return nil 318 } 319 320 func (m *WritableLocation) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 321 322 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 323 return err 324 } 325 326 return nil 327 } 328 329 func (m *WritableLocation) contextValidateRackCount(ctx context.Context, formats strfmt.Registry) error { 330 331 if err := validate.ReadOnly(ctx, "rack_count", "body", int64(m.RackCount)); err != nil { 332 return err 333 } 334 335 return nil 336 } 337 338 func (m *WritableLocation) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 339 340 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 341 return err 342 } 343 344 return nil 345 } 346 347 // MarshalBinary interface implementation 348 func (m *WritableLocation) MarshalBinary() ([]byte, error) { 349 if m == nil { 350 return nil, nil 351 } 352 return swag.WriteJSON(m) 353 } 354 355 // UnmarshalBinary interface implementation 356 func (m *WritableLocation) UnmarshalBinary(b []byte) error { 357 var res WritableLocation 358 if err := swag.ReadJSON(b, &res); err != nil { 359 return err 360 } 361 *m = res 362 return nil 363 }