blob: d3f7ed8a4bf90605721aa5047ee2ca2d93a65889 [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 strfmt "github.com/go-openapi/strfmt"
24
25 "github.com/go-openapi/errors"
26 "github.com/go-openapi/swag"
27 "github.com/go-openapi/validate"
28)
29
30// InterfaceTemplate interface template
31// swagger:model InterfaceTemplate
32type InterfaceTemplate struct {
33
34 // device type
35 // Required: true
36 DeviceType *NestedDeviceType `json:"device_type"`
37
38 // form factor
39 // Required: true
40 FormFactor *InterfaceTemplateFormFactor `json:"form_factor"`
41
42 // ID
43 // Read Only: true
44 ID int64 `json:"id,omitempty"`
45
46 // Management only
47 MgmtOnly bool `json:"mgmt_only,omitempty"`
48
49 // Name
50 // Required: true
51 // Max Length: 64
52 Name *string `json:"name"`
53}
54
55// Validate validates this interface template
56func (m *InterfaceTemplate) Validate(formats strfmt.Registry) error {
57 var res []error
58
59 if err := m.validateDeviceType(formats); err != nil {
60 // prop
61 res = append(res, err)
62 }
63
64 if err := m.validateFormFactor(formats); err != nil {
65 // prop
66 res = append(res, err)
67 }
68
69 if err := m.validateName(formats); err != nil {
70 // prop
71 res = append(res, err)
72 }
73
74 if len(res) > 0 {
75 return errors.CompositeValidationError(res...)
76 }
77 return nil
78}
79
80func (m *InterfaceTemplate) validateDeviceType(formats strfmt.Registry) error {
81
82 if err := validate.Required("device_type", "body", m.DeviceType); err != nil {
83 return err
84 }
85
86 if m.DeviceType != nil {
87
88 if err := m.DeviceType.Validate(formats); err != nil {
89 if ve, ok := err.(*errors.Validation); ok {
90 return ve.ValidateName("device_type")
91 }
92 return err
93 }
94 }
95
96 return nil
97}
98
99func (m *InterfaceTemplate) validateFormFactor(formats strfmt.Registry) error {
100
101 if err := validate.Required("form_factor", "body", m.FormFactor); err != nil {
102 return err
103 }
104
105 if m.FormFactor != nil {
106
107 if err := m.FormFactor.Validate(formats); err != nil {
108 if ve, ok := err.(*errors.Validation); ok {
109 return ve.ValidateName("form_factor")
110 }
111 return err
112 }
113 }
114
115 return nil
116}
117
118func (m *InterfaceTemplate) validateName(formats strfmt.Registry) error {
119
120 if err := validate.Required("name", "body", m.Name); err != nil {
121 return err
122 }
123
124 if err := validate.MaxLength("name", "body", string(*m.Name), 64); err != nil {
125 return err
126 }
127
128 return nil
129}
130
131// MarshalBinary interface implementation
132func (m *InterfaceTemplate) MarshalBinary() ([]byte, error) {
133 if m == nil {
134 return nil, nil
135 }
136 return swag.WriteJSON(m)
137}
138
139// UnmarshalBinary interface implementation
140func (m *InterfaceTemplate) UnmarshalBinary(b []byte) error {
141 var res InterfaceTemplate
142 if err := swag.ReadJSON(b, &res); err != nil {
143 return err
144 }
145 *m = res
146 return nil
147}