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 | // WritablePlatform writable platform |
| 33 | // swagger:model WritablePlatform |
| 34 | type WritablePlatform struct { |
| 35 | |
| 36 | // ID |
| 37 | // Read Only: true |
| 38 | ID int64 `json:"id,omitempty"` |
| 39 | |
| 40 | // Manufacturer |
| 41 | // |
| 42 | // Optionally limit this platform to devices of a certain manufacturer |
| 43 | Manufacturer int64 `json:"manufacturer,omitempty"` |
| 44 | |
| 45 | // Name |
| 46 | // Required: true |
| 47 | // Max Length: 50 |
| 48 | Name *string `json:"name"` |
| 49 | |
| 50 | // NAPALM driver |
| 51 | // |
| 52 | // The name of the NAPALM driver to use when interacting with devices |
| 53 | // Max Length: 50 |
| 54 | NapalmDriver string `json:"napalm_driver,omitempty"` |
| 55 | |
| 56 | // Legacy RPC client |
| 57 | RPCClient string `json:"rpc_client,omitempty"` |
| 58 | |
| 59 | // Slug |
| 60 | // Required: true |
| 61 | // Max Length: 50 |
| 62 | // Pattern: ^[-a-zA-Z0-9_]+$ |
| 63 | Slug *string `json:"slug"` |
| 64 | } |
| 65 | |
| 66 | // Validate validates this writable platform |
| 67 | func (m *WritablePlatform) Validate(formats strfmt.Registry) error { |
| 68 | var res []error |
| 69 | |
| 70 | if err := m.validateName(formats); err != nil { |
| 71 | // prop |
| 72 | res = append(res, err) |
| 73 | } |
| 74 | |
| 75 | if err := m.validateNapalmDriver(formats); err != nil { |
| 76 | // prop |
| 77 | res = append(res, err) |
| 78 | } |
| 79 | |
| 80 | if err := m.validateRPCClient(formats); err != nil { |
| 81 | // prop |
| 82 | res = append(res, err) |
| 83 | } |
| 84 | |
| 85 | if err := m.validateSlug(formats); err != nil { |
| 86 | // prop |
| 87 | res = append(res, err) |
| 88 | } |
| 89 | |
| 90 | if len(res) > 0 { |
| 91 | return errors.CompositeValidationError(res...) |
| 92 | } |
| 93 | return nil |
| 94 | } |
| 95 | |
| 96 | func (m *WritablePlatform) validateName(formats strfmt.Registry) error { |
| 97 | |
| 98 | if err := validate.Required("name", "body", m.Name); err != nil { |
| 99 | return err |
| 100 | } |
| 101 | |
| 102 | if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil { |
| 103 | return err |
| 104 | } |
| 105 | |
| 106 | return nil |
| 107 | } |
| 108 | |
| 109 | func (m *WritablePlatform) validateNapalmDriver(formats strfmt.Registry) error { |
| 110 | |
| 111 | if swag.IsZero(m.NapalmDriver) { // not required |
| 112 | return nil |
| 113 | } |
| 114 | |
| 115 | if err := validate.MaxLength("napalm_driver", "body", string(m.NapalmDriver), 50); err != nil { |
| 116 | return err |
| 117 | } |
| 118 | |
| 119 | return nil |
| 120 | } |
| 121 | |
| 122 | var writablePlatformTypeRPCClientPropEnum []interface{} |
| 123 | |
| 124 | func init() { |
| 125 | var res []string |
| 126 | if err := json.Unmarshal([]byte(`["juniper-junos","cisco-ios","opengear"]`), &res); err != nil { |
| 127 | panic(err) |
| 128 | } |
| 129 | for _, v := range res { |
| 130 | writablePlatformTypeRPCClientPropEnum = append(writablePlatformTypeRPCClientPropEnum, v) |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | const ( |
| 135 | // WritablePlatformRPCClientJuniperJunos captures enum value "juniper-junos" |
| 136 | WritablePlatformRPCClientJuniperJunos string = "juniper-junos" |
| 137 | // WritablePlatformRPCClientCiscoIos captures enum value "cisco-ios" |
| 138 | WritablePlatformRPCClientCiscoIos string = "cisco-ios" |
| 139 | // WritablePlatformRPCClientOpengear captures enum value "opengear" |
| 140 | WritablePlatformRPCClientOpengear string = "opengear" |
| 141 | ) |
| 142 | |
| 143 | // prop value enum |
| 144 | func (m *WritablePlatform) validateRPCClientEnum(path, location string, value string) error { |
| 145 | if err := validate.Enum(path, location, value, writablePlatformTypeRPCClientPropEnum); err != nil { |
| 146 | return err |
| 147 | } |
| 148 | return nil |
| 149 | } |
| 150 | |
| 151 | func (m *WritablePlatform) validateRPCClient(formats strfmt.Registry) error { |
| 152 | |
| 153 | if swag.IsZero(m.RPCClient) { // not required |
| 154 | return nil |
| 155 | } |
| 156 | |
| 157 | // value enum |
| 158 | if err := m.validateRPCClientEnum("rpc_client", "body", m.RPCClient); err != nil { |
| 159 | return err |
| 160 | } |
| 161 | |
| 162 | return nil |
| 163 | } |
| 164 | |
| 165 | func (m *WritablePlatform) validateSlug(formats strfmt.Registry) error { |
| 166 | |
| 167 | if err := validate.Required("slug", "body", m.Slug); err != nil { |
| 168 | return err |
| 169 | } |
| 170 | |
| 171 | if err := validate.MaxLength("slug", "body", string(*m.Slug), 50); err != nil { |
| 172 | return err |
| 173 | } |
| 174 | |
| 175 | if err := validate.Pattern("slug", "body", string(*m.Slug), `^[-a-zA-Z0-9_]+$`); err != nil { |
| 176 | return err |
| 177 | } |
| 178 | |
| 179 | return nil |
| 180 | } |
| 181 | |
| 182 | // MarshalBinary interface implementation |
| 183 | func (m *WritablePlatform) MarshalBinary() ([]byte, error) { |
| 184 | if m == nil { |
| 185 | return nil, nil |
| 186 | } |
| 187 | return swag.WriteJSON(m) |
| 188 | } |
| 189 | |
| 190 | // UnmarshalBinary interface implementation |
| 191 | func (m *WritablePlatform) UnmarshalBinary(b []byte) error { |
| 192 | var res WritablePlatform |
| 193 | if err := swag.ReadJSON(b, &res); err != nil { |
| 194 | return err |
| 195 | } |
| 196 | *m = res |
| 197 | return nil |
| 198 | } |