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