blob: 0149233d492c3cc6df6c2c94d3c623313e06da79 [file] [log] [blame]
Serge Bazanskicc25bdf2018-10-25 14:02:58 +02001// Code generated by go-swagger; DO NOT EDIT.
2
3// Copyright 2018 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
17package models
18
19// This file was generated by the swagger tool.
20// Editing this file might prove futile when you re-run the swagger generate command
21
22import (
23 strfmt "github.com/go-openapi/strfmt"
24
25 "github.com/go-openapi/errors"
26 "github.com/go-openapi/swag"
27 "github.com/go-openapi/validate"
28)
29
30// ImageAttachment image attachment
31// swagger:model ImageAttachment
32type ImageAttachment struct {
33
34 // Created
35 // Read Only: true
36 Created strfmt.DateTime `json:"created,omitempty"`
37
38 // ID
39 // Read Only: true
40 ID int64 `json:"id,omitempty"`
41
42 // Image
43 // Required: true
44 // Read Only: true
45 Image strfmt.URI `json:"image"`
46
47 // Image height
48 // Required: true
49 // Maximum: 32767
50 // Minimum: 0
51 ImageHeight *int64 `json:"image_height"`
52
53 // Image width
54 // Required: true
55 // Maximum: 32767
56 // Minimum: 0
57 ImageWidth *int64 `json:"image_width"`
58
59 // Name
60 // Max Length: 50
61 Name string `json:"name,omitempty"`
62
63 // Parent
64 // Read Only: true
65 Parent string `json:"parent,omitempty"`
66}
67
68// Validate validates this image attachment
69func (m *ImageAttachment) Validate(formats strfmt.Registry) error {
70 var res []error
71
72 if err := m.validateImage(formats); err != nil {
73 // prop
74 res = append(res, err)
75 }
76
77 if err := m.validateImageHeight(formats); err != nil {
78 // prop
79 res = append(res, err)
80 }
81
82 if err := m.validateImageWidth(formats); err != nil {
83 // prop
84 res = append(res, err)
85 }
86
87 if err := m.validateName(formats); err != nil {
88 // prop
89 res = append(res, err)
90 }
91
92 if len(res) > 0 {
93 return errors.CompositeValidationError(res...)
94 }
95 return nil
96}
97
98func (m *ImageAttachment) validateImage(formats strfmt.Registry) error {
99
100 if err := validate.Required("image", "body", strfmt.URI(m.Image)); err != nil {
101 return err
102 }
103
104 if err := validate.FormatOf("image", "body", "uri", m.Image.String(), formats); err != nil {
105 return err
106 }
107
108 return nil
109}
110
111func (m *ImageAttachment) validateImageHeight(formats strfmt.Registry) error {
112
113 if err := validate.Required("image_height", "body", m.ImageHeight); err != nil {
114 return err
115 }
116
117 if err := validate.MinimumInt("image_height", "body", int64(*m.ImageHeight), 0, false); err != nil {
118 return err
119 }
120
121 if err := validate.MaximumInt("image_height", "body", int64(*m.ImageHeight), 32767, false); err != nil {
122 return err
123 }
124
125 return nil
126}
127
128func (m *ImageAttachment) validateImageWidth(formats strfmt.Registry) error {
129
130 if err := validate.Required("image_width", "body", m.ImageWidth); err != nil {
131 return err
132 }
133
134 if err := validate.MinimumInt("image_width", "body", int64(*m.ImageWidth), 0, false); err != nil {
135 return err
136 }
137
138 if err := validate.MaximumInt("image_width", "body", int64(*m.ImageWidth), 32767, false); err != nil {
139 return err
140 }
141
142 return nil
143}
144
145func (m *ImageAttachment) validateName(formats strfmt.Registry) error {
146
147 if swag.IsZero(m.Name) { // not required
148 return nil
149 }
150
151 if err := validate.MaxLength("name", "body", string(m.Name), 50); err != nil {
152 return err
153 }
154
155 return nil
156}
157
158// MarshalBinary interface implementation
159func (m *ImageAttachment) MarshalBinary() ([]byte, error) {
160 if m == nil {
161 return nil, nil
162 }
163 return swag.WriteJSON(m)
164}
165
166// UnmarshalBinary interface implementation
167func (m *ImageAttachment) UnmarshalBinary(b []byte) error {
168 var res ImageAttachment
169 if err := swag.ReadJSON(b, &res); err != nil {
170 return err
171 }
172 *m = res
173 return nil
174}