blob: 9a0feabcdcbff04bbab6cc747dbb8b66b7c90dc6 [file] [log] [blame]
Serge Bazanskicc25bdf2018-10-25 14:02:58 +02001// Code generated by go-swagger; DO NOT EDIT.
2
3// Copyright 2018 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
17package models
18
19// This file was generated by the swagger tool.
20// Editing this file might prove futile when you re-run the swagger generate command
21
22import (
23 "encoding/json"
24
25 strfmt "github.com/go-openapi/strfmt"
26
27 "github.com/go-openapi/errors"
28 "github.com/go-openapi/swag"
29 "github.com/go-openapi/validate"
30)
31
32// WritableVLAN writable v l a n
33// swagger:model WritableVLAN
34type WritableVLAN struct {
35
36 // Created
37 // Read Only: true
38 Created strfmt.Date `json:"created,omitempty"`
39
40 // Custom fields
41 CustomFields interface{} `json:"custom_fields,omitempty"`
42
43 // Description
44 // Max Length: 100
45 Description string `json:"description,omitempty"`
46
47 // Group
48 Group int64 `json:"group,omitempty"`
49
50 // ID
51 // Read Only: true
52 ID int64 `json:"id,omitempty"`
53
54 // Last updated
55 // Read Only: true
56 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
57
58 // Name
59 // Required: true
60 // Max Length: 64
61 Name *string `json:"name"`
62
63 // Role
64 Role int64 `json:"role,omitempty"`
65
66 // Site
67 Site int64 `json:"site,omitempty"`
68
69 // Status
70 Status int64 `json:"status,omitempty"`
71
72 // Tenant
73 Tenant int64 `json:"tenant,omitempty"`
74
75 // ID
76 // Required: true
77 // Maximum: 4094
78 // Minimum: 1
79 Vid *int64 `json:"vid"`
80}
81
82// Validate validates this writable v l a n
83func (m *WritableVLAN) Validate(formats strfmt.Registry) error {
84 var res []error
85
86 if err := m.validateDescription(formats); err != nil {
87 // prop
88 res = append(res, err)
89 }
90
91 if err := m.validateName(formats); err != nil {
92 // prop
93 res = append(res, err)
94 }
95
96 if err := m.validateStatus(formats); err != nil {
97 // prop
98 res = append(res, err)
99 }
100
101 if err := m.validateVid(formats); err != nil {
102 // prop
103 res = append(res, err)
104 }
105
106 if len(res) > 0 {
107 return errors.CompositeValidationError(res...)
108 }
109 return nil
110}
111
112func (m *WritableVLAN) validateDescription(formats strfmt.Registry) error {
113
114 if swag.IsZero(m.Description) { // not required
115 return nil
116 }
117
118 if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil {
119 return err
120 }
121
122 return nil
123}
124
125func (m *WritableVLAN) validateName(formats strfmt.Registry) error {
126
127 if err := validate.Required("name", "body", m.Name); err != nil {
128 return err
129 }
130
131 if err := validate.MaxLength("name", "body", string(*m.Name), 64); err != nil {
132 return err
133 }
134
135 return nil
136}
137
138var writableVLANTypeStatusPropEnum []interface{}
139
140func init() {
141 var res []int64
142 if err := json.Unmarshal([]byte(`[1,2,3]`), &res); err != nil {
143 panic(err)
144 }
145 for _, v := range res {
146 writableVLANTypeStatusPropEnum = append(writableVLANTypeStatusPropEnum, v)
147 }
148}
149
150// prop value enum
151func (m *WritableVLAN) validateStatusEnum(path, location string, value int64) error {
152 if err := validate.Enum(path, location, value, writableVLANTypeStatusPropEnum); err != nil {
153 return err
154 }
155 return nil
156}
157
158func (m *WritableVLAN) validateStatus(formats strfmt.Registry) error {
159
160 if swag.IsZero(m.Status) { // not required
161 return nil
162 }
163
164 // value enum
165 if err := m.validateStatusEnum("status", "body", m.Status); err != nil {
166 return err
167 }
168
169 return nil
170}
171
172func (m *WritableVLAN) validateVid(formats strfmt.Registry) error {
173
174 if err := validate.Required("vid", "body", m.Vid); err != nil {
175 return err
176 }
177
178 if err := validate.MinimumInt("vid", "body", int64(*m.Vid), 1, false); err != nil {
179 return err
180 }
181
182 if err := validate.MaximumInt("vid", "body", int64(*m.Vid), 4094, false); err != nil {
183 return err
184 }
185
186 return nil
187}
188
189// MarshalBinary interface implementation
190func (m *WritableVLAN) MarshalBinary() ([]byte, error) {
191 if m == nil {
192 return nil, nil
193 }
194 return swag.WriteJSON(m)
195}
196
197// UnmarshalBinary interface implementation
198func (m *WritableVLAN) UnmarshalBinary(b []byte) error {
199 var res WritableVLAN
200 if err := swag.ReadJSON(b, &res); err != nil {
201 return err
202 }
203 *m = res
204 return nil
205}