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