blob: a2b07782d974299fbe370c7d801e9632c0de5ac9 [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// WritableImageAttachment writable image attachment
31// swagger:model WritableImageAttachment
32type WritableImageAttachment struct {
33
34 // Content type
35 // Required: true
36 ContentType *string `json:"content_type"`
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 // Name
48 // Max Length: 50
49 Name string `json:"name,omitempty"`
50
51 // Object id
52 // Required: true
53 // Maximum: 2.147483647e+09
54 // Minimum: 0
55 ObjectID *int64 `json:"object_id"`
56}
57
58// Validate validates this writable image attachment
59func (m *WritableImageAttachment) Validate(formats strfmt.Registry) error {
60 var res []error
61
62 if err := m.validateContentType(formats); err != nil {
63 // prop
64 res = append(res, err)
65 }
66
67 if err := m.validateImage(formats); err != nil {
68 // prop
69 res = append(res, err)
70 }
71
72 if err := m.validateName(formats); err != nil {
73 // prop
74 res = append(res, err)
75 }
76
77 if err := m.validateObjectID(formats); err != nil {
78 // prop
79 res = append(res, err)
80 }
81
82 if len(res) > 0 {
83 return errors.CompositeValidationError(res...)
84 }
85 return nil
86}
87
88func (m *WritableImageAttachment) validateContentType(formats strfmt.Registry) error {
89
90 if err := validate.Required("content_type", "body", m.ContentType); err != nil {
91 return err
92 }
93
94 return nil
95}
96
97func (m *WritableImageAttachment) validateImage(formats strfmt.Registry) error {
98
99 if err := validate.Required("image", "body", strfmt.URI(m.Image)); err != nil {
100 return err
101 }
102
103 if err := validate.FormatOf("image", "body", "uri", m.Image.String(), formats); err != nil {
104 return err
105 }
106
107 return nil
108}
109
110func (m *WritableImageAttachment) validateName(formats strfmt.Registry) error {
111
112 if swag.IsZero(m.Name) { // not required
113 return nil
114 }
115
116 if err := validate.MaxLength("name", "body", string(m.Name), 50); err != nil {
117 return err
118 }
119
120 return nil
121}
122
123func (m *WritableImageAttachment) validateObjectID(formats strfmt.Registry) error {
124
125 if err := validate.Required("object_id", "body", m.ObjectID); err != nil {
126 return err
127 }
128
129 if err := validate.MinimumInt("object_id", "body", int64(*m.ObjectID), 0, false); err != nil {
130 return err
131 }
132
133 if err := validate.MaximumInt("object_id", "body", int64(*m.ObjectID), 2.147483647e+09, false); err != nil {
134 return err
135 }
136
137 return nil
138}
139
140// MarshalBinary interface implementation
141func (m *WritableImageAttachment) MarshalBinary() ([]byte, error) {
142 if m == nil {
143 return nil, nil
144 }
145 return swag.WriteJSON(m)
146}
147
148// UnmarshalBinary interface implementation
149func (m *WritableImageAttachment) UnmarshalBinary(b []byte) error {
150 var res WritableImageAttachment
151 if err := swag.ReadJSON(b, &res); err != nil {
152 return err
153 }
154 *m = res
155 return nil
156}