github.com/digitalocean/go-netbox@v0.0.2/netbox/models/export_template.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 // ExportTemplate export template 33 // 34 // swagger:model ExportTemplate 35 type ExportTemplate struct { 36 37 // As attachment 38 // 39 // Download file as attachment 40 AsAttachment bool `json:"as_attachment,omitempty"` 41 42 // Content type 43 // Required: true 44 ContentType *string `json:"content_type"` 45 46 // Description 47 // Max Length: 200 48 Description string `json:"description,omitempty"` 49 50 // Display 51 // Read Only: true 52 Display string `json:"display,omitempty"` 53 54 // File extension 55 // 56 // Extension to append to the rendered filename 57 // Max Length: 15 58 FileExtension string `json:"file_extension,omitempty"` 59 60 // Id 61 // Read Only: true 62 ID int64 `json:"id,omitempty"` 63 64 // MIME type 65 // 66 // Defaults to <code>text/plain</code> 67 // Max Length: 50 68 MimeType string `json:"mime_type,omitempty"` 69 70 // Name 71 // Required: true 72 // Max Length: 100 73 // Min Length: 1 74 Name *string `json:"name"` 75 76 // Template code 77 // 78 // The list of objects being exported is passed as a context variable named <code>queryset</code>. 79 // Required: true 80 // Min Length: 1 81 TemplateCode *string `json:"template_code"` 82 83 // Url 84 // Read Only: true 85 // Format: uri 86 URL strfmt.URI `json:"url,omitempty"` 87 } 88 89 // Validate validates this export template 90 func (m *ExportTemplate) Validate(formats strfmt.Registry) error { 91 var res []error 92 93 if err := m.validateContentType(formats); err != nil { 94 res = append(res, err) 95 } 96 97 if err := m.validateDescription(formats); err != nil { 98 res = append(res, err) 99 } 100 101 if err := m.validateFileExtension(formats); err != nil { 102 res = append(res, err) 103 } 104 105 if err := m.validateMimeType(formats); err != nil { 106 res = append(res, err) 107 } 108 109 if err := m.validateName(formats); err != nil { 110 res = append(res, err) 111 } 112 113 if err := m.validateTemplateCode(formats); err != nil { 114 res = append(res, err) 115 } 116 117 if err := m.validateURL(formats); err != nil { 118 res = append(res, err) 119 } 120 121 if len(res) > 0 { 122 return errors.CompositeValidationError(res...) 123 } 124 return nil 125 } 126 127 func (m *ExportTemplate) validateContentType(formats strfmt.Registry) error { 128 129 if err := validate.Required("content_type", "body", m.ContentType); err != nil { 130 return err 131 } 132 133 return nil 134 } 135 136 func (m *ExportTemplate) validateDescription(formats strfmt.Registry) error { 137 if swag.IsZero(m.Description) { // not required 138 return nil 139 } 140 141 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 142 return err 143 } 144 145 return nil 146 } 147 148 func (m *ExportTemplate) validateFileExtension(formats strfmt.Registry) error { 149 if swag.IsZero(m.FileExtension) { // not required 150 return nil 151 } 152 153 if err := validate.MaxLength("file_extension", "body", m.FileExtension, 15); err != nil { 154 return err 155 } 156 157 return nil 158 } 159 160 func (m *ExportTemplate) validateMimeType(formats strfmt.Registry) error { 161 if swag.IsZero(m.MimeType) { // not required 162 return nil 163 } 164 165 if err := validate.MaxLength("mime_type", "body", m.MimeType, 50); err != nil { 166 return err 167 } 168 169 return nil 170 } 171 172 func (m *ExportTemplate) validateName(formats strfmt.Registry) error { 173 174 if err := validate.Required("name", "body", m.Name); err != nil { 175 return err 176 } 177 178 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 179 return err 180 } 181 182 if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil { 183 return err 184 } 185 186 return nil 187 } 188 189 func (m *ExportTemplate) validateTemplateCode(formats strfmt.Registry) error { 190 191 if err := validate.Required("template_code", "body", m.TemplateCode); err != nil { 192 return err 193 } 194 195 if err := validate.MinLength("template_code", "body", *m.TemplateCode, 1); err != nil { 196 return err 197 } 198 199 return nil 200 } 201 202 func (m *ExportTemplate) validateURL(formats strfmt.Registry) error { 203 if swag.IsZero(m.URL) { // not required 204 return nil 205 } 206 207 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 208 return err 209 } 210 211 return nil 212 } 213 214 // ContextValidate validate this export template based on the context it is used 215 func (m *ExportTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 216 var res []error 217 218 if err := m.contextValidateDisplay(ctx, formats); err != nil { 219 res = append(res, err) 220 } 221 222 if err := m.contextValidateID(ctx, formats); err != nil { 223 res = append(res, err) 224 } 225 226 if err := m.contextValidateURL(ctx, formats); err != nil { 227 res = append(res, err) 228 } 229 230 if len(res) > 0 { 231 return errors.CompositeValidationError(res...) 232 } 233 return nil 234 } 235 236 func (m *ExportTemplate) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 237 238 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 239 return err 240 } 241 242 return nil 243 } 244 245 func (m *ExportTemplate) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 246 247 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 248 return err 249 } 250 251 return nil 252 } 253 254 func (m *ExportTemplate) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 255 256 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 257 return err 258 } 259 260 return nil 261 } 262 263 // MarshalBinary interface implementation 264 func (m *ExportTemplate) MarshalBinary() ([]byte, error) { 265 if m == nil { 266 return nil, nil 267 } 268 return swag.WriteJSON(m) 269 } 270 271 // UnmarshalBinary interface implementation 272 func (m *ExportTemplate) UnmarshalBinary(b []byte) error { 273 var res ExportTemplate 274 if err := swag.ReadJSON(b, &res); err != nil { 275 return err 276 } 277 *m = res 278 return nil 279 }