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