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