blob: c78e654fde1efbe55890352201cc50f3131d54af [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// WritableTopologyMap writable topology map
31// swagger:model WritableTopologyMap
32type WritableTopologyMap 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 Site int64 `json:"site,omitempty"`
55
56 // Slug
57 // Required: true
58 // Max Length: 50
59 // Pattern: ^[-a-zA-Z0-9_]+$
60 Slug *string `json:"slug"`
61}
62
63// Validate validates this writable topology map
64func (m *WritableTopologyMap) Validate(formats strfmt.Registry) error {
65 var res []error
66
67 if err := m.validateDescription(formats); err != nil {
68 // prop
69 res = append(res, err)
70 }
71
72 if err := m.validateDevicePatterns(formats); err != nil {
73 // prop
74 res = append(res, err)
75 }
76
77 if err := m.validateName(formats); err != nil {
78 // prop
79 res = append(res, err)
80 }
81
82 if err := m.validateSlug(formats); err != nil {
83 // prop
84 res = append(res, err)
85 }
86
87 if len(res) > 0 {
88 return errors.CompositeValidationError(res...)
89 }
90 return nil
91}
92
93func (m *WritableTopologyMap) validateDescription(formats strfmt.Registry) error {
94
95 if swag.IsZero(m.Description) { // not required
96 return nil
97 }
98
99 if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil {
100 return err
101 }
102
103 return nil
104}
105
106func (m *WritableTopologyMap) validateDevicePatterns(formats strfmt.Registry) error {
107
108 if err := validate.Required("device_patterns", "body", m.DevicePatterns); err != nil {
109 return err
110 }
111
112 return nil
113}
114
115func (m *WritableTopologyMap) validateName(formats strfmt.Registry) error {
116
117 if err := validate.Required("name", "body", m.Name); err != nil {
118 return err
119 }
120
121 if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil {
122 return err
123 }
124
125 return nil
126}
127
128func (m *WritableTopologyMap) validateSlug(formats strfmt.Registry) error {
129
130 if err := validate.Required("slug", "body", m.Slug); err != nil {
131 return err
132 }
133
134 if err := validate.MaxLength("slug", "body", string(*m.Slug), 50); err != nil {
135 return err
136 }
137
138 if err := validate.Pattern("slug", "body", string(*m.Slug), `^[-a-zA-Z0-9_]+$`); err != nil {
139 return err
140 }
141
142 return nil
143}
144
145// MarshalBinary interface implementation
146func (m *WritableTopologyMap) MarshalBinary() ([]byte, error) {
147 if m == nil {
148 return nil, nil
149 }
150 return swag.WriteJSON(m)
151}
152
153// UnmarshalBinary interface implementation
154func (m *WritableTopologyMap) UnmarshalBinary(b []byte) error {
155 var res WritableTopologyMap
156 if err := swag.ReadJSON(b, &res); err != nil {
157 return err
158 }
159 *m = res
160 return nil
161}