blob: c03f79558ebc47a8a9894461a0ae80c7118bc888 [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// WritableIPAddress writable IP address
33// swagger:model WritableIPAddress
34type WritableIPAddress struct {
35
36 // Address
37 //
38 // IPv4 or IPv6 address (with mask)
39 // Required: true
40 Address *string `json:"address"`
41
42 // Created
43 // Read Only: true
44 Created strfmt.Date `json:"created,omitempty"`
45
46 // Custom fields
47 CustomFields interface{} `json:"custom_fields,omitempty"`
48
49 // Description
50 // Max Length: 100
51 Description string `json:"description,omitempty"`
52
53 // ID
54 // Read Only: true
55 ID int64 `json:"id,omitempty"`
56
57 // Interface
58 Interface int64 `json:"interface,omitempty"`
59
60 // Last updated
61 // Read Only: true
62 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
63
64 // NAT (Inside)
65 //
66 // The IP for which this address is the "outside" IP
67 NatInside int64 `json:"nat_inside,omitempty"`
68
69 // Role
70 //
71 // The functional role of this IP
72 Role int64 `json:"role,omitempty"`
73
74 // Status
75 //
76 // The operational status of this IP
77 Status int64 `json:"status,omitempty"`
78
79 // Tenant
80 Tenant int64 `json:"tenant,omitempty"`
81
82 // VRF
83 Vrf int64 `json:"vrf,omitempty"`
84}
85
86// Validate validates this writable IP address
87func (m *WritableIPAddress) Validate(formats strfmt.Registry) error {
88 var res []error
89
90 if err := m.validateAddress(formats); err != nil {
91 // prop
92 res = append(res, err)
93 }
94
95 if err := m.validateDescription(formats); err != nil {
96 // prop
97 res = append(res, err)
98 }
99
100 if err := m.validateRole(formats); err != nil {
101 // prop
102 res = append(res, err)
103 }
104
105 if err := m.validateStatus(formats); err != nil {
106 // prop
107 res = append(res, err)
108 }
109
110 if len(res) > 0 {
111 return errors.CompositeValidationError(res...)
112 }
113 return nil
114}
115
116func (m *WritableIPAddress) validateAddress(formats strfmt.Registry) error {
117
118 if err := validate.Required("address", "body", m.Address); err != nil {
119 return err
120 }
121
122 return nil
123}
124
125func (m *WritableIPAddress) validateDescription(formats strfmt.Registry) error {
126
127 if swag.IsZero(m.Description) { // not required
128 return nil
129 }
130
131 if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil {
132 return err
133 }
134
135 return nil
136}
137
138var writableIpAddressTypeRolePropEnum []interface{}
139
140func init() {
141 var res []int64
142 if err := json.Unmarshal([]byte(`[10,20,30,40,41,42,43,44]`), &res); err != nil {
143 panic(err)
144 }
145 for _, v := range res {
146 writableIpAddressTypeRolePropEnum = append(writableIpAddressTypeRolePropEnum, v)
147 }
148}
149
150// prop value enum
151func (m *WritableIPAddress) validateRoleEnum(path, location string, value int64) error {
152 if err := validate.Enum(path, location, value, writableIpAddressTypeRolePropEnum); err != nil {
153 return err
154 }
155 return nil
156}
157
158func (m *WritableIPAddress) validateRole(formats strfmt.Registry) error {
159
160 if swag.IsZero(m.Role) { // not required
161 return nil
162 }
163
164 // value enum
165 if err := m.validateRoleEnum("role", "body", m.Role); err != nil {
166 return err
167 }
168
169 return nil
170}
171
172var writableIpAddressTypeStatusPropEnum []interface{}
173
174func init() {
175 var res []int64
176 if err := json.Unmarshal([]byte(`[1,2,3,5]`), &res); err != nil {
177 panic(err)
178 }
179 for _, v := range res {
180 writableIpAddressTypeStatusPropEnum = append(writableIpAddressTypeStatusPropEnum, v)
181 }
182}
183
184// prop value enum
185func (m *WritableIPAddress) validateStatusEnum(path, location string, value int64) error {
186 if err := validate.Enum(path, location, value, writableIpAddressTypeStatusPropEnum); err != nil {
187 return err
188 }
189 return nil
190}
191
192func (m *WritableIPAddress) validateStatus(formats strfmt.Registry) error {
193
194 if swag.IsZero(m.Status) { // not required
195 return nil
196 }
197
198 // value enum
199 if err := m.validateStatusEnum("status", "body", m.Status); err != nil {
200 return err
201 }
202
203 return nil
204}
205
206// MarshalBinary interface implementation
207func (m *WritableIPAddress) MarshalBinary() ([]byte, error) {
208 if m == nil {
209 return nil, nil
210 }
211 return swag.WriteJSON(m)
212}
213
214// UnmarshalBinary interface implementation
215func (m *WritableIPAddress) UnmarshalBinary(b []byte) error {
216 var res WritableIPAddress
217 if err := swag.ReadJSON(b, &res); err != nil {
218 return err
219 }
220 *m = res
221 return nil
222}