blob: 65af6ed195239bfad47c3ae526e05a2848217500 [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// WritableProvider writable provider
31// swagger:model WritableProvider
32type WritableProvider struct {
33
34 // Account number
35 // Max Length: 30
36 Account string `json:"account,omitempty"`
37
38 // Admin contact
39 AdminContact string `json:"admin_contact,omitempty"`
40
41 // ASN
42 // Maximum: 4.294967295e+09
43 // Minimum: 1
44 Asn int64 `json:"asn,omitempty"`
45
46 // Comments
47 Comments string `json:"comments,omitempty"`
48
49 // Created
50 // Read Only: true
51 Created strfmt.Date `json:"created,omitempty"`
52
53 // Custom fields
54 CustomFields interface{} `json:"custom_fields,omitempty"`
55
56 // ID
57 // Read Only: true
58 ID int64 `json:"id,omitempty"`
59
60 // Last updated
61 // Read Only: true
62 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
63
64 // Name
65 // Required: true
66 // Max Length: 50
67 Name *string `json:"name"`
68
69 // NOC contact
70 NocContact string `json:"noc_contact,omitempty"`
71
72 // Portal
73 // Max Length: 200
74 PortalURL strfmt.URI `json:"portal_url,omitempty"`
75
76 // Slug
77 // Required: true
78 // Max Length: 50
79 // Pattern: ^[-a-zA-Z0-9_]+$
80 Slug *string `json:"slug"`
81}
82
83// Validate validates this writable provider
84func (m *WritableProvider) Validate(formats strfmt.Registry) error {
85 var res []error
86
87 if err := m.validateAccount(formats); err != nil {
88 // prop
89 res = append(res, err)
90 }
91
92 if err := m.validateAsn(formats); err != nil {
93 // prop
94 res = append(res, err)
95 }
96
97 if err := m.validateName(formats); err != nil {
98 // prop
99 res = append(res, err)
100 }
101
102 if err := m.validatePortalURL(formats); err != nil {
103 // prop
104 res = append(res, err)
105 }
106
107 if err := m.validateSlug(formats); err != nil {
108 // prop
109 res = append(res, err)
110 }
111
112 if len(res) > 0 {
113 return errors.CompositeValidationError(res...)
114 }
115 return nil
116}
117
118func (m *WritableProvider) validateAccount(formats strfmt.Registry) error {
119
120 if swag.IsZero(m.Account) { // not required
121 return nil
122 }
123
124 if err := validate.MaxLength("account", "body", string(m.Account), 30); err != nil {
125 return err
126 }
127
128 return nil
129}
130
131func (m *WritableProvider) validateAsn(formats strfmt.Registry) error {
132
133 if swag.IsZero(m.Asn) { // not required
134 return nil
135 }
136
137 if err := validate.MinimumInt("asn", "body", int64(m.Asn), 1, false); err != nil {
138 return err
139 }
140
141 if err := validate.MaximumInt("asn", "body", int64(m.Asn), 4.294967295e+09, false); err != nil {
142 return err
143 }
144
145 return nil
146}
147
148func (m *WritableProvider) validateName(formats strfmt.Registry) error {
149
150 if err := validate.Required("name", "body", m.Name); err != nil {
151 return err
152 }
153
154 if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil {
155 return err
156 }
157
158 return nil
159}
160
161func (m *WritableProvider) validatePortalURL(formats strfmt.Registry) error {
162
163 if swag.IsZero(m.PortalURL) { // not required
164 return nil
165 }
166
167 if err := validate.MaxLength("portal_url", "body", string(m.PortalURL), 200); err != nil {
168 return err
169 }
170
171 if err := validate.FormatOf("portal_url", "body", "uri", m.PortalURL.String(), formats); err != nil {
172 return err
173 }
174
175 return nil
176}
177
178func (m *WritableProvider) validateSlug(formats strfmt.Registry) error {
179
180 if err := validate.Required("slug", "body", m.Slug); err != nil {
181 return err
182 }
183
184 if err := validate.MaxLength("slug", "body", string(*m.Slug), 50); err != nil {
185 return err
186 }
187
188 if err := validate.Pattern("slug", "body", string(*m.Slug), `^[-a-zA-Z0-9_]+$`); err != nil {
189 return err
190 }
191
192 return nil
193}
194
195// MarshalBinary interface implementation
196func (m *WritableProvider) MarshalBinary() ([]byte, error) {
197 if m == nil {
198 return nil, nil
199 }
200 return swag.WriteJSON(m)
201}
202
203// UnmarshalBinary interface implementation
204func (m *WritableProvider) UnmarshalBinary(b []byte) error {
205 var res WritableProvider
206 if err := swag.ReadJSON(b, &res); err != nil {
207 return err
208 }
209 *m = res
210 return nil
211}