blob: e338136329e603722b1a1225ab3785154377c377 [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// TopologyMap topology map
31// swagger:model TopologyMap
32type TopologyMap struct {
33
34 // Description
35 // Max Length: 100
36 Description string `json:"description,omitempty"`
37
38 // Device patterns
39 //
40 // Identify devices to include in the diagram using regular expressions, one per line. Each line will result in a new tier of the drawing. Separate multiple regexes within a line using semicolons. Devices will be rendered in the order they are defined.
41 // Required: true
42 DevicePatterns *string `json:"device_patterns"`
43
44 // ID
45 // Read Only: true
46 ID int64 `json:"id,omitempty"`
47
48 // Name
49 // Required: true
50 // Max Length: 50
51 Name *string `json:"name"`
52
53 // site
54 // Required: true
55 Site *NestedSite `json:"site"`
56
57 // Slug
58 // Required: true
59 // Max Length: 50
60 // Pattern: ^[-a-zA-Z0-9_]+$
61 Slug *string `json:"slug"`
62}
63
64// Validate validates this topology map
65func (m *TopologyMap) Validate(formats strfmt.Registry) error {
66 var res []error
67
68 if err := m.validateDescription(formats); err != nil {
69 // prop
70 res = append(res, err)
71 }
72
73 if err := m.validateDevicePatterns(formats); err != nil {
74 // prop
75 res = append(res, err)
76 }
77
78 if err := m.validateName(formats); err != nil {
79 // prop
80 res = append(res, err)
81 }
82
83 if err := m.validateSite(formats); err != nil {
84 // prop
85 res = append(res, err)
86 }
87
88 if err := m.validateSlug(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 *TopologyMap) validateDescription(formats strfmt.Registry) error {
100
101 if swag.IsZero(m.Description) { // not required
102 return nil
103 }
104
105 if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil {
106 return err
107 }
108
109 return nil
110}
111
112func (m *TopologyMap) validateDevicePatterns(formats strfmt.Registry) error {
113
114 if err := validate.Required("device_patterns", "body", m.DevicePatterns); err != nil {
115 return err
116 }
117
118 return nil
119}
120
121func (m *TopologyMap) validateName(formats strfmt.Registry) error {
122
123 if err := validate.Required("name", "body", m.Name); err != nil {
124 return err
125 }
126
127 if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil {
128 return err
129 }
130
131 return nil
132}
133
134func (m *TopologyMap) validateSite(formats strfmt.Registry) error {
135
136 if err := validate.Required("site", "body", m.Site); err != nil {
137 return err
138 }
139
140 if m.Site != nil {
141
142 if err := m.Site.Validate(formats); err != nil {
143 if ve, ok := err.(*errors.Validation); ok {
144 return ve.ValidateName("site")
145 }
146 return err
147 }
148 }
149
150 return nil
151}
152
153func (m *TopologyMap) validateSlug(formats strfmt.Registry) error {
154
155 if err := validate.Required("slug", "body", m.Slug); err != nil {
156 return err
157 }
158
159 if err := validate.MaxLength("slug", "body", string(*m.Slug), 50); err != nil {
160 return err
161 }
162
163 if err := validate.Pattern("slug", "body", string(*m.Slug), `^[-a-zA-Z0-9_]+$`); err != nil {
164 return err
165 }
166
167 return nil
168}
169
170// MarshalBinary interface implementation
171func (m *TopologyMap) 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 *TopologyMap) UnmarshalBinary(b []byte) error {
180 var res TopologyMap
181 if err := swag.ReadJSON(b, &res); err != nil {
182 return err
183 }
184 *m = res
185 return nil
186}