blob: 4ba7fe767675b7d79b0b874e538b539b436489c2 [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// WritableVirtualMachine writable virtual machine
33// swagger:model WritableVirtualMachine
34type WritableVirtualMachine struct {
35
36 // Cluster
37 // Required: true
38 Cluster *int64 `json:"cluster"`
39
40 // Comments
41 Comments string `json:"comments,omitempty"`
42
43 // Created
44 // Read Only: true
45 Created strfmt.Date `json:"created,omitempty"`
46
47 // Custom fields
48 CustomFields interface{} `json:"custom_fields,omitempty"`
49
50 // Disk (GB)
51 // Maximum: 2.147483647e+09
52 // Minimum: 0
53 Disk *int64 `json:"disk,omitempty"`
54
55 // ID
56 // Read Only: true
57 ID int64 `json:"id,omitempty"`
58
59 // Last updated
60 // Read Only: true
61 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
62
63 // Memory (MB)
64 // Maximum: 2.147483647e+09
65 // Minimum: 0
66 Memory *int64 `json:"memory,omitempty"`
67
68 // Name
69 // Required: true
70 // Max Length: 64
71 Name *string `json:"name"`
72
73 // Platform
74 Platform int64 `json:"platform,omitempty"`
75
76 // Primary IPv4
77 PrimaryIp4 int64 `json:"primary_ip4,omitempty"`
78
79 // Primary IPv6
80 PrimaryIp6 int64 `json:"primary_ip6,omitempty"`
81
82 // Role
83 Role int64 `json:"role,omitempty"`
84
85 // Status
86 Status int64 `json:"status,omitempty"`
87
88 // Tenant
89 Tenant int64 `json:"tenant,omitempty"`
90
91 // VCPUs
92 // Maximum: 32767
93 // Minimum: 0
94 Vcpus *int64 `json:"vcpus,omitempty"`
95}
96
97// Validate validates this writable virtual machine
98func (m *WritableVirtualMachine) Validate(formats strfmt.Registry) error {
99 var res []error
100
101 if err := m.validateCluster(formats); err != nil {
102 // prop
103 res = append(res, err)
104 }
105
106 if err := m.validateDisk(formats); err != nil {
107 // prop
108 res = append(res, err)
109 }
110
111 if err := m.validateMemory(formats); err != nil {
112 // prop
113 res = append(res, err)
114 }
115
116 if err := m.validateName(formats); err != nil {
117 // prop
118 res = append(res, err)
119 }
120
121 if err := m.validateStatus(formats); err != nil {
122 // prop
123 res = append(res, err)
124 }
125
126 if err := m.validateVcpus(formats); err != nil {
127 // prop
128 res = append(res, err)
129 }
130
131 if len(res) > 0 {
132 return errors.CompositeValidationError(res...)
133 }
134 return nil
135}
136
137func (m *WritableVirtualMachine) validateCluster(formats strfmt.Registry) error {
138
139 if err := validate.Required("cluster", "body", m.Cluster); err != nil {
140 return err
141 }
142
143 return nil
144}
145
146func (m *WritableVirtualMachine) validateDisk(formats strfmt.Registry) error {
147
148 if swag.IsZero(m.Disk) { // not required
149 return nil
150 }
151
152 if err := validate.MinimumInt("disk", "body", int64(*m.Disk), 0, false); err != nil {
153 return err
154 }
155
156 if err := validate.MaximumInt("disk", "body", int64(*m.Disk), 2.147483647e+09, false); err != nil {
157 return err
158 }
159
160 return nil
161}
162
163func (m *WritableVirtualMachine) validateMemory(formats strfmt.Registry) error {
164
165 if swag.IsZero(m.Memory) { // not required
166 return nil
167 }
168
169 if err := validate.MinimumInt("memory", "body", int64(*m.Memory), 0, false); err != nil {
170 return err
171 }
172
173 if err := validate.MaximumInt("memory", "body", int64(*m.Memory), 2.147483647e+09, false); err != nil {
174 return err
175 }
176
177 return nil
178}
179
180func (m *WritableVirtualMachine) validateName(formats strfmt.Registry) error {
181
182 if err := validate.Required("name", "body", m.Name); err != nil {
183 return err
184 }
185
186 if err := validate.MaxLength("name", "body", string(*m.Name), 64); err != nil {
187 return err
188 }
189
190 return nil
191}
192
193var writableVirtualMachineTypeStatusPropEnum []interface{}
194
195func init() {
196 var res []int64
197 if err := json.Unmarshal([]byte(`[1,0,3]`), &res); err != nil {
198 panic(err)
199 }
200 for _, v := range res {
201 writableVirtualMachineTypeStatusPropEnum = append(writableVirtualMachineTypeStatusPropEnum, v)
202 }
203}
204
205// prop value enum
206func (m *WritableVirtualMachine) validateStatusEnum(path, location string, value int64) error {
207 if err := validate.Enum(path, location, value, writableVirtualMachineTypeStatusPropEnum); err != nil {
208 return err
209 }
210 return nil
211}
212
213func (m *WritableVirtualMachine) validateStatus(formats strfmt.Registry) error {
214
215 if swag.IsZero(m.Status) { // not required
216 return nil
217 }
218
219 // value enum
220 if err := m.validateStatusEnum("status", "body", m.Status); err != nil {
221 return err
222 }
223
224 return nil
225}
226
227func (m *WritableVirtualMachine) validateVcpus(formats strfmt.Registry) error {
228
229 if swag.IsZero(m.Vcpus) { // not required
230 return nil
231 }
232
233 if err := validate.MinimumInt("vcpus", "body", int64(*m.Vcpus), 0, false); err != nil {
234 return err
235 }
236
237 if err := validate.MaximumInt("vcpus", "body", int64(*m.Vcpus), 32767, false); err != nil {
238 return err
239 }
240
241 return nil
242}
243
244// MarshalBinary interface implementation
245func (m *WritableVirtualMachine) MarshalBinary() ([]byte, error) {
246 if m == nil {
247 return nil, nil
248 }
249 return swag.WriteJSON(m)
250}
251
252// UnmarshalBinary interface implementation
253func (m *WritableVirtualMachine) UnmarshalBinary(b []byte) error {
254 var res WritableVirtualMachine
255 if err := swag.ReadJSON(b, &res); err != nil {
256 return err
257 }
258 *m = res
259 return nil
260}