github.com/digitalocean/go-netbox@v0.0.2/netbox/models/nested_ip_address.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 // NestedIPAddress nested IP address 33 // 34 // swagger:model NestedIPAddress 35 type NestedIPAddress struct { 36 37 // Address 38 // 39 // IPv4 or IPv6 address (with mask) 40 // Required: true 41 Address *string `json:"address"` 42 43 // Display 44 // Read Only: true 45 Display string `json:"display,omitempty"` 46 47 // Family 48 // Read Only: true 49 Family int64 `json:"family,omitempty"` 50 51 // Id 52 // Read Only: true 53 ID int64 `json:"id,omitempty"` 54 55 // Url 56 // Read Only: true 57 // Format: uri 58 URL strfmt.URI `json:"url,omitempty"` 59 } 60 61 // Validate validates this nested IP address 62 func (m *NestedIPAddress) Validate(formats strfmt.Registry) error { 63 var res []error 64 65 if err := m.validateAddress(formats); err != nil { 66 res = append(res, err) 67 } 68 69 if err := m.validateURL(formats); err != nil { 70 res = append(res, err) 71 } 72 73 if len(res) > 0 { 74 return errors.CompositeValidationError(res...) 75 } 76 return nil 77 } 78 79 func (m *NestedIPAddress) validateAddress(formats strfmt.Registry) error { 80 81 if err := validate.Required("address", "body", m.Address); err != nil { 82 return err 83 } 84 85 return nil 86 } 87 88 func (m *NestedIPAddress) validateURL(formats strfmt.Registry) error { 89 if swag.IsZero(m.URL) { // not required 90 return nil 91 } 92 93 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 94 return err 95 } 96 97 return nil 98 } 99 100 // ContextValidate validate this nested IP address based on the context it is used 101 func (m *NestedIPAddress) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 102 var res []error 103 104 if err := m.contextValidateDisplay(ctx, formats); err != nil { 105 res = append(res, err) 106 } 107 108 if err := m.contextValidateFamily(ctx, formats); err != nil { 109 res = append(res, err) 110 } 111 112 if err := m.contextValidateID(ctx, formats); err != nil { 113 res = append(res, err) 114 } 115 116 if err := m.contextValidateURL(ctx, formats); err != nil { 117 res = append(res, err) 118 } 119 120 if len(res) > 0 { 121 return errors.CompositeValidationError(res...) 122 } 123 return nil 124 } 125 126 func (m *NestedIPAddress) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 127 128 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 129 return err 130 } 131 132 return nil 133 } 134 135 func (m *NestedIPAddress) contextValidateFamily(ctx context.Context, formats strfmt.Registry) error { 136 137 if err := validate.ReadOnly(ctx, "family", "body", int64(m.Family)); err != nil { 138 return err 139 } 140 141 return nil 142 } 143 144 func (m *NestedIPAddress) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 145 146 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 147 return err 148 } 149 150 return nil 151 } 152 153 func (m *NestedIPAddress) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 154 155 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 156 return err 157 } 158 159 return nil 160 } 161 162 // MarshalBinary interface implementation 163 func (m *NestedIPAddress) MarshalBinary() ([]byte, error) { 164 if m == nil { 165 return nil, nil 166 } 167 return swag.WriteJSON(m) 168 } 169 170 // UnmarshalBinary interface implementation 171 func (m *NestedIPAddress) UnmarshalBinary(b []byte) error { 172 var res NestedIPAddress 173 if err := swag.ReadJSON(b, &res); err != nil { 174 return err 175 } 176 *m = res 177 return nil 178 }