Serge Bazanski | cc25bdf | 2018-10-25 14:02:58 +0200 | [diff] [blame] | 1 | // 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 | |
| 17 | package 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 | |
| 22 | import ( |
| 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 | // WritablePrefix writable prefix |
| 33 | // swagger:model WritablePrefix |
| 34 | type WritablePrefix 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 | // ID |
| 48 | // Read Only: true |
| 49 | ID int64 `json:"id,omitempty"` |
| 50 | |
| 51 | // Is a pool |
| 52 | // |
| 53 | // All IP addresses within this prefix are considered usable |
| 54 | IsPool bool `json:"is_pool,omitempty"` |
| 55 | |
| 56 | // Last updated |
| 57 | // Read Only: true |
| 58 | LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` |
| 59 | |
| 60 | // Prefix |
| 61 | // |
| 62 | // IPv4 or IPv6 network with mask |
| 63 | // Required: true |
| 64 | Prefix *string `json:"prefix"` |
| 65 | |
| 66 | // Role |
| 67 | // |
| 68 | // The primary function of this prefix |
| 69 | Role int64 `json:"role,omitempty"` |
| 70 | |
| 71 | // Site |
| 72 | Site int64 `json:"site,omitempty"` |
| 73 | |
| 74 | // Status |
| 75 | // |
| 76 | // Operational status of this prefix |
| 77 | Status int64 `json:"status,omitempty"` |
| 78 | |
| 79 | // Tenant |
| 80 | Tenant int64 `json:"tenant,omitempty"` |
| 81 | |
| 82 | // VLAN |
| 83 | Vlan int64 `json:"vlan,omitempty"` |
| 84 | |
| 85 | // VRF |
| 86 | Vrf int64 `json:"vrf,omitempty"` |
| 87 | } |
| 88 | |
| 89 | // Validate validates this writable prefix |
| 90 | func (m *WritablePrefix) Validate(formats strfmt.Registry) error { |
| 91 | var res []error |
| 92 | |
| 93 | if err := m.validateDescription(formats); err != nil { |
| 94 | // prop |
| 95 | res = append(res, err) |
| 96 | } |
| 97 | |
| 98 | if err := m.validatePrefix(formats); err != nil { |
| 99 | // prop |
| 100 | res = append(res, err) |
| 101 | } |
| 102 | |
| 103 | if err := m.validateStatus(formats); err != nil { |
| 104 | // prop |
| 105 | res = append(res, err) |
| 106 | } |
| 107 | |
| 108 | if len(res) > 0 { |
| 109 | return errors.CompositeValidationError(res...) |
| 110 | } |
| 111 | return nil |
| 112 | } |
| 113 | |
| 114 | func (m *WritablePrefix) validateDescription(formats strfmt.Registry) error { |
| 115 | |
| 116 | if swag.IsZero(m.Description) { // not required |
| 117 | return nil |
| 118 | } |
| 119 | |
| 120 | if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil { |
| 121 | return err |
| 122 | } |
| 123 | |
| 124 | return nil |
| 125 | } |
| 126 | |
| 127 | func (m *WritablePrefix) validatePrefix(formats strfmt.Registry) error { |
| 128 | |
| 129 | if err := validate.Required("prefix", "body", m.Prefix); err != nil { |
| 130 | return err |
| 131 | } |
| 132 | |
| 133 | return nil |
| 134 | } |
| 135 | |
| 136 | var writablePrefixTypeStatusPropEnum []interface{} |
| 137 | |
| 138 | func init() { |
| 139 | var res []int64 |
| 140 | if err := json.Unmarshal([]byte(`[0,1,2,3]`), &res); err != nil { |
| 141 | panic(err) |
| 142 | } |
| 143 | for _, v := range res { |
| 144 | writablePrefixTypeStatusPropEnum = append(writablePrefixTypeStatusPropEnum, v) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // prop value enum |
| 149 | func (m *WritablePrefix) validateStatusEnum(path, location string, value int64) error { |
| 150 | if err := validate.Enum(path, location, value, writablePrefixTypeStatusPropEnum); err != nil { |
| 151 | return err |
| 152 | } |
| 153 | return nil |
| 154 | } |
| 155 | |
| 156 | func (m *WritablePrefix) validateStatus(formats strfmt.Registry) error { |
| 157 | |
| 158 | if swag.IsZero(m.Status) { // not required |
| 159 | return nil |
| 160 | } |
| 161 | |
| 162 | // value enum |
| 163 | if err := m.validateStatusEnum("status", "body", m.Status); err != nil { |
| 164 | return err |
| 165 | } |
| 166 | |
| 167 | return nil |
| 168 | } |
| 169 | |
| 170 | // MarshalBinary interface implementation |
| 171 | func (m *WritablePrefix) MarshalBinary() ([]byte, error) { |
| 172 | if m == nil { |
| 173 | return nil, nil |
| 174 | } |
| 175 | return swag.WriteJSON(m) |
| 176 | } |
| 177 | |
| 178 | // UnmarshalBinary interface implementation |
| 179 | func (m *WritablePrefix) UnmarshalBinary(b []byte) error { |
| 180 | var res WritablePrefix |
| 181 | if err := swag.ReadJSON(b, &res); err != nil { |
| 182 | return err |
| 183 | } |
| 184 | *m = res |
| 185 | return nil |
| 186 | } |