blob: d3d4ad66f9bc7eed926109a6411a3b351ba792e0 [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// Cluster cluster
31// swagger:model Cluster
32type Cluster struct {
33
34 // Comments
35 Comments string `json:"comments,omitempty"`
36
37 // Created
38 // Read Only: true
39 Created strfmt.Date `json:"created,omitempty"`
40
41 // Custom fields
42 CustomFields interface{} `json:"custom_fields,omitempty"`
43
44 // group
45 // Required: true
46 Group *NestedClusterGroup `json:"group"`
47
48 // ID
49 // Read Only: true
50 ID int64 `json:"id,omitempty"`
51
52 // Last updated
53 // Read Only: true
54 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
55
56 // Name
57 // Required: true
58 // Max Length: 100
59 Name *string `json:"name"`
60
61 // site
62 // Required: true
63 Site *NestedSite `json:"site"`
64
65 // type
66 // Required: true
67 Type *NestedClusterType `json:"type"`
68}
69
70// Validate validates this cluster
71func (m *Cluster) Validate(formats strfmt.Registry) error {
72 var res []error
73
74 if err := m.validateGroup(formats); err != nil {
75 // prop
76 res = append(res, err)
77 }
78
79 if err := m.validateName(formats); err != nil {
80 // prop
81 res = append(res, err)
82 }
83
84 if err := m.validateSite(formats); err != nil {
85 // prop
86 res = append(res, err)
87 }
88
89 if err := m.validateType(formats); err != nil {
90 // prop
91 res = append(res, err)
92 }
93
94 if len(res) > 0 {
95 return errors.CompositeValidationError(res...)
96 }
97 return nil
98}
99
100func (m *Cluster) validateGroup(formats strfmt.Registry) error {
101
102 if err := validate.Required("group", "body", m.Group); err != nil {
103 return err
104 }
105
106 if m.Group != nil {
107
108 if err := m.Group.Validate(formats); err != nil {
109 if ve, ok := err.(*errors.Validation); ok {
110 return ve.ValidateName("group")
111 }
112 return err
113 }
114 }
115
116 return nil
117}
118
119func (m *Cluster) validateName(formats strfmt.Registry) error {
120
121 if err := validate.Required("name", "body", m.Name); err != nil {
122 return err
123 }
124
125 if err := validate.MaxLength("name", "body", string(*m.Name), 100); err != nil {
126 return err
127 }
128
129 return nil
130}
131
132func (m *Cluster) validateSite(formats strfmt.Registry) error {
133
134 if err := validate.Required("site", "body", m.Site); err != nil {
135 return err
136 }
137
138 if m.Site != nil {
139
140 if err := m.Site.Validate(formats); err != nil {
141 if ve, ok := err.(*errors.Validation); ok {
142 return ve.ValidateName("site")
143 }
144 return err
145 }
146 }
147
148 return nil
149}
150
151func (m *Cluster) validateType(formats strfmt.Registry) error {
152
153 if err := validate.Required("type", "body", m.Type); err != nil {
154 return err
155 }
156
157 if m.Type != nil {
158
159 if err := m.Type.Validate(formats); err != nil {
160 if ve, ok := err.(*errors.Validation); ok {
161 return ve.ValidateName("type")
162 }
163 return err
164 }
165 }
166
167 return nil
168}
169
170// MarshalBinary interface implementation
171func (m *Cluster) MarshalBinary() ([]byte, error) {
172 if m == nil {
173 return nil, nil
174 }
175 return swag.WriteJSON(m)
176}
177
178// UnmarshalBinary interface implementation
179func (m *Cluster) UnmarshalBinary(b []byte) error {
180 var res Cluster
181 if err := swag.ReadJSON(b, &res); err != nil {
182 return err
183 }
184 *m = res
185 return nil
186}