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