blob: a9863622f3d9776d07ece460a10f09c9ba7cab7d [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 "encoding/json"
24
25 strfmt "github.com/go-openapi/strfmt"
26
27 "github.com/go-openapi/errors"
28 "github.com/go-openapi/swag"
29 "github.com/go-openapi/validate"
30)
31
32// WritableGraph writable graph
33// swagger:model WritableGraph
34type WritableGraph struct {
35
36 // ID
37 // Read Only: true
38 ID int64 `json:"id,omitempty"`
39
40 // Link URL
41 // Max Length: 200
42 Link strfmt.URI `json:"link,omitempty"`
43
44 // Name
45 // Required: true
46 // Max Length: 100
47 Name *string `json:"name"`
48
49 // Source URL
50 // Required: true
51 // Max Length: 500
52 Source *string `json:"source"`
53
54 // Type
55 // Required: true
56 Type *int64 `json:"type"`
57
58 // Weight
59 // Maximum: 32767
60 // Minimum: 0
61 Weight *int64 `json:"weight,omitempty"`
62}
63
64// Validate validates this writable graph
65func (m *WritableGraph) Validate(formats strfmt.Registry) error {
66 var res []error
67
68 if err := m.validateLink(formats); err != nil {
69 // prop
70 res = append(res, err)
71 }
72
73 if err := m.validateName(formats); err != nil {
74 // prop
75 res = append(res, err)
76 }
77
78 if err := m.validateSource(formats); err != nil {
79 // prop
80 res = append(res, err)
81 }
82
83 if err := m.validateType(formats); err != nil {
84 // prop
85 res = append(res, err)
86 }
87
88 if err := m.validateWeight(formats); err != nil {
89 // prop
90 res = append(res, err)
91 }
92
93 if len(res) > 0 {
94 return errors.CompositeValidationError(res...)
95 }
96 return nil
97}
98
99func (m *WritableGraph) validateLink(formats strfmt.Registry) error {
100
101 if swag.IsZero(m.Link) { // not required
102 return nil
103 }
104
105 if err := validate.MaxLength("link", "body", string(m.Link), 200); err != nil {
106 return err
107 }
108
109 if err := validate.FormatOf("link", "body", "uri", m.Link.String(), formats); err != nil {
110 return err
111 }
112
113 return nil
114}
115
116func (m *WritableGraph) validateName(formats strfmt.Registry) error {
117
118 if err := validate.Required("name", "body", m.Name); err != nil {
119 return err
120 }
121
122 if err := validate.MaxLength("name", "body", string(*m.Name), 100); err != nil {
123 return err
124 }
125
126 return nil
127}
128
129func (m *WritableGraph) validateSource(formats strfmt.Registry) error {
130
131 if err := validate.Required("source", "body", m.Source); err != nil {
132 return err
133 }
134
135 if err := validate.MaxLength("source", "body", string(*m.Source), 500); err != nil {
136 return err
137 }
138
139 return nil
140}
141
142var writableGraphTypeTypePropEnum []interface{}
143
144func init() {
145 var res []int64
146 if err := json.Unmarshal([]byte(`[100,200,300]`), &res); err != nil {
147 panic(err)
148 }
149 for _, v := range res {
150 writableGraphTypeTypePropEnum = append(writableGraphTypeTypePropEnum, v)
151 }
152}
153
154// prop value enum
155func (m *WritableGraph) validateTypeEnum(path, location string, value int64) error {
156 if err := validate.Enum(path, location, value, writableGraphTypeTypePropEnum); err != nil {
157 return err
158 }
159 return nil
160}
161
162func (m *WritableGraph) validateType(formats strfmt.Registry) error {
163
164 if err := validate.Required("type", "body", m.Type); err != nil {
165 return err
166 }
167
168 // value enum
169 if err := m.validateTypeEnum("type", "body", *m.Type); err != nil {
170 return err
171 }
172
173 return nil
174}
175
176func (m *WritableGraph) validateWeight(formats strfmt.Registry) error {
177
178 if swag.IsZero(m.Weight) { // not required
179 return nil
180 }
181
182 if err := validate.MinimumInt("weight", "body", int64(*m.Weight), 0, false); err != nil {
183 return err
184 }
185
186 if err := validate.MaximumInt("weight", "body", int64(*m.Weight), 32767, false); err != nil {
187 return err
188 }
189
190 return nil
191}
192
193// MarshalBinary interface implementation
194func (m *WritableGraph) MarshalBinary() ([]byte, error) {
195 if m == nil {
196 return nil, nil
197 }
198 return swag.WriteJSON(m)
199}
200
201// UnmarshalBinary interface implementation
202func (m *WritableGraph) UnmarshalBinary(b []byte) error {
203 var res WritableGraph
204 if err := swag.ReadJSON(b, &res); err != nil {
205 return err
206 }
207 *m = res
208 return nil
209}