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