blob: e3a4446d790c7875f5ce36416a1432f61227cdc9 [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// Tenant tenant
31// swagger:model Tenant
32type Tenant 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 // Description
45 //
46 // Long-form name (optional)
47 // Max Length: 100
48 Description string `json:"description,omitempty"`
49
50 // group
51 // Required: true
52 Group *NestedTenantGroup `json:"group"`
53
54 // ID
55 // Read Only: true
56 ID int64 `json:"id,omitempty"`
57
58 // Last updated
59 // Read Only: true
60 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
61
62 // Name
63 // Required: true
64 // Max Length: 30
65 Name *string `json:"name"`
66
67 // Slug
68 // Required: true
69 // Max Length: 50
70 // Pattern: ^[-a-zA-Z0-9_]+$
71 Slug *string `json:"slug"`
72}
73
74// Validate validates this tenant
75func (m *Tenant) Validate(formats strfmt.Registry) error {
76 var res []error
77
78 if err := m.validateDescription(formats); err != nil {
79 // prop
80 res = append(res, err)
81 }
82
83 if err := m.validateGroup(formats); err != nil {
84 // prop
85 res = append(res, err)
86 }
87
88 if err := m.validateName(formats); err != nil {
89 // prop
90 res = append(res, err)
91 }
92
93 if err := m.validateSlug(formats); err != nil {
94 // prop
95 res = append(res, err)
96 }
97
98 if len(res) > 0 {
99 return errors.CompositeValidationError(res...)
100 }
101 return nil
102}
103
104func (m *Tenant) validateDescription(formats strfmt.Registry) error {
105
106 if swag.IsZero(m.Description) { // not required
107 return nil
108 }
109
110 if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil {
111 return err
112 }
113
114 return nil
115}
116
117func (m *Tenant) validateGroup(formats strfmt.Registry) error {
118
119 if err := validate.Required("group", "body", m.Group); err != nil {
120 return err
121 }
122
123 if m.Group != nil {
124
125 if err := m.Group.Validate(formats); err != nil {
126 if ve, ok := err.(*errors.Validation); ok {
127 return ve.ValidateName("group")
128 }
129 return err
130 }
131 }
132
133 return nil
134}
135
136func (m *Tenant) validateName(formats strfmt.Registry) error {
137
138 if err := validate.Required("name", "body", m.Name); err != nil {
139 return err
140 }
141
142 if err := validate.MaxLength("name", "body", string(*m.Name), 30); err != nil {
143 return err
144 }
145
146 return nil
147}
148
149func (m *Tenant) validateSlug(formats strfmt.Registry) error {
150
151 if err := validate.Required("slug", "body", m.Slug); err != nil {
152 return err
153 }
154
155 if err := validate.MaxLength("slug", "body", string(*m.Slug), 50); err != nil {
156 return err
157 }
158
159 if err := validate.Pattern("slug", "body", string(*m.Slug), `^[-a-zA-Z0-9_]+$`); err != nil {
160 return err
161 }
162
163 return nil
164}
165
166// MarshalBinary interface implementation
167func (m *Tenant) MarshalBinary() ([]byte, error) {
168 if m == nil {
169 return nil, nil
170 }
171 return swag.WriteJSON(m)
172}
173
174// UnmarshalBinary interface implementation
175func (m *Tenant) UnmarshalBinary(b []byte) error {
176 var res Tenant
177 if err := swag.ReadJSON(b, &res); err != nil {
178 return err
179 }
180 *m = res
181 return nil
182}