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