blob: fadd59e0d37608c9008bb6d120f3193f893f7116 [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// RackGroup rack group
31// swagger:model RackGroup
32type RackGroup struct {
33
34 // ID
35 // Read Only: true
36 ID int64 `json:"id,omitempty"`
37
38 // Name
39 // Required: true
40 // Max Length: 50
41 Name *string `json:"name"`
42
43 // site
44 // Required: true
45 Site *NestedSite `json:"site"`
46
47 // Slug
48 // Required: true
49 // Max Length: 50
50 // Pattern: ^[-a-zA-Z0-9_]+$
51 Slug *string `json:"slug"`
52}
53
54// Validate validates this rack group
55func (m *RackGroup) Validate(formats strfmt.Registry) error {
56 var res []error
57
58 if err := m.validateName(formats); err != nil {
59 // prop
60 res = append(res, err)
61 }
62
63 if err := m.validateSite(formats); err != nil {
64 // prop
65 res = append(res, err)
66 }
67
68 if err := m.validateSlug(formats); err != nil {
69 // prop
70 res = append(res, err)
71 }
72
73 if len(res) > 0 {
74 return errors.CompositeValidationError(res...)
75 }
76 return nil
77}
78
79func (m *RackGroup) validateName(formats strfmt.Registry) error {
80
81 if err := validate.Required("name", "body", m.Name); err != nil {
82 return err
83 }
84
85 if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil {
86 return err
87 }
88
89 return nil
90}
91
92func (m *RackGroup) validateSite(formats strfmt.Registry) error {
93
94 if err := validate.Required("site", "body", m.Site); err != nil {
95 return err
96 }
97
98 if m.Site != nil {
99
100 if err := m.Site.Validate(formats); err != nil {
101 if ve, ok := err.(*errors.Validation); ok {
102 return ve.ValidateName("site")
103 }
104 return err
105 }
106 }
107
108 return nil
109}
110
111func (m *RackGroup) validateSlug(formats strfmt.Registry) error {
112
113 if err := validate.Required("slug", "body", m.Slug); err != nil {
114 return err
115 }
116
117 if err := validate.MaxLength("slug", "body", string(*m.Slug), 50); err != nil {
118 return err
119 }
120
121 if err := validate.Pattern("slug", "body", string(*m.Slug), `^[-a-zA-Z0-9_]+$`); err != nil {
122 return err
123 }
124
125 return nil
126}
127
128// MarshalBinary interface implementation
129func (m *RackGroup) MarshalBinary() ([]byte, error) {
130 if m == nil {
131 return nil, nil
132 }
133 return swag.WriteJSON(m)
134}
135
136// UnmarshalBinary interface implementation
137func (m *RackGroup) UnmarshalBinary(b []byte) error {
138 var res RackGroup
139 if err := swag.ReadJSON(b, &res); err != nil {
140 return err
141 }
142 *m = res
143 return nil
144}