github.com/digitalocean/go-netbox@v0.0.2/netbox/models/interface_connection.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright 2020 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 18 package models 19 20 // This file was generated by the swagger tool. 21 // Editing this file might prove futile when you re-run the swagger generate command 22 23 import ( 24 "context" 25 26 "github.com/go-openapi/errors" 27 "github.com/go-openapi/strfmt" 28 "github.com/go-openapi/swag" 29 "github.com/go-openapi/validate" 30 ) 31 32 // InterfaceConnection interface connection 33 // 34 // swagger:model InterfaceConnection 35 type InterfaceConnection struct { 36 37 // Connected endpoint reachable 38 // Read Only: true 39 ConnectedEndpointReachable *bool `json:"connected_endpoint_reachable,omitempty"` 40 41 // interface a 42 Interfacea *NestedInterface `json:"interface_a,omitempty"` 43 44 // interface b 45 // Required: true 46 Interfaceb *NestedInterface `json:"interface_b"` 47 } 48 49 // Validate validates this interface connection 50 func (m *InterfaceConnection) Validate(formats strfmt.Registry) error { 51 var res []error 52 53 if err := m.validateInterfacea(formats); err != nil { 54 res = append(res, err) 55 } 56 57 if err := m.validateInterfaceb(formats); err != nil { 58 res = append(res, err) 59 } 60 61 if len(res) > 0 { 62 return errors.CompositeValidationError(res...) 63 } 64 return nil 65 } 66 67 func (m *InterfaceConnection) validateInterfacea(formats strfmt.Registry) error { 68 if swag.IsZero(m.Interfacea) { // not required 69 return nil 70 } 71 72 if m.Interfacea != nil { 73 if err := m.Interfacea.Validate(formats); err != nil { 74 if ve, ok := err.(*errors.Validation); ok { 75 return ve.ValidateName("interface_a") 76 } else if ce, ok := err.(*errors.CompositeError); ok { 77 return ce.ValidateName("interface_a") 78 } 79 return err 80 } 81 } 82 83 return nil 84 } 85 86 func (m *InterfaceConnection) validateInterfaceb(formats strfmt.Registry) error { 87 88 if err := validate.Required("interface_b", "body", m.Interfaceb); err != nil { 89 return err 90 } 91 92 if m.Interfaceb != nil { 93 if err := m.Interfaceb.Validate(formats); err != nil { 94 if ve, ok := err.(*errors.Validation); ok { 95 return ve.ValidateName("interface_b") 96 } else if ce, ok := err.(*errors.CompositeError); ok { 97 return ce.ValidateName("interface_b") 98 } 99 return err 100 } 101 } 102 103 return nil 104 } 105 106 // ContextValidate validate this interface connection based on the context it is used 107 func (m *InterfaceConnection) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 108 var res []error 109 110 if err := m.contextValidateConnectedEndpointReachable(ctx, formats); err != nil { 111 res = append(res, err) 112 } 113 114 if err := m.contextValidateInterfacea(ctx, formats); err != nil { 115 res = append(res, err) 116 } 117 118 if err := m.contextValidateInterfaceb(ctx, formats); err != nil { 119 res = append(res, err) 120 } 121 122 if len(res) > 0 { 123 return errors.CompositeValidationError(res...) 124 } 125 return nil 126 } 127 128 func (m *InterfaceConnection) contextValidateConnectedEndpointReachable(ctx context.Context, formats strfmt.Registry) error { 129 130 if err := validate.ReadOnly(ctx, "connected_endpoint_reachable", "body", m.ConnectedEndpointReachable); err != nil { 131 return err 132 } 133 134 return nil 135 } 136 137 func (m *InterfaceConnection) contextValidateInterfacea(ctx context.Context, formats strfmt.Registry) error { 138 139 if m.Interfacea != nil { 140 if err := m.Interfacea.ContextValidate(ctx, formats); err != nil { 141 if ve, ok := err.(*errors.Validation); ok { 142 return ve.ValidateName("interface_a") 143 } else if ce, ok := err.(*errors.CompositeError); ok { 144 return ce.ValidateName("interface_a") 145 } 146 return err 147 } 148 } 149 150 return nil 151 } 152 153 func (m *InterfaceConnection) contextValidateInterfaceb(ctx context.Context, formats strfmt.Registry) error { 154 155 if m.Interfaceb != nil { 156 if err := m.Interfaceb.ContextValidate(ctx, formats); err != nil { 157 if ve, ok := err.(*errors.Validation); ok { 158 return ve.ValidateName("interface_b") 159 } else if ce, ok := err.(*errors.CompositeError); ok { 160 return ce.ValidateName("interface_b") 161 } 162 return err 163 } 164 } 165 166 return nil 167 } 168 169 // MarshalBinary interface implementation 170 func (m *InterfaceConnection) MarshalBinary() ([]byte, error) { 171 if m == nil { 172 return nil, nil 173 } 174 return swag.WriteJSON(m) 175 } 176 177 // UnmarshalBinary interface implementation 178 func (m *InterfaceConnection) UnmarshalBinary(b []byte) error { 179 var res InterfaceConnection 180 if err := swag.ReadJSON(b, &res); err != nil { 181 return err 182 } 183 *m = res 184 return nil 185 }