blob: e66d7c3843439e041e65918193880e8fc93462a9 [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 "strconv"
24
25 strfmt "github.com/go-openapi/strfmt"
26
27 "github.com/go-openapi/errors"
28 "github.com/go-openapi/swag"
29 "github.com/go-openapi/validate"
30)
31
32// WritableRackReservation writable rack reservation
33// swagger:model WritableRackReservation
34type WritableRackReservation struct {
35
36 // Description
37 // Required: true
38 // Max Length: 100
39 Description *string `json:"description"`
40
41 // ID
42 // Read Only: true
43 ID int64 `json:"id,omitempty"`
44
45 // Rack
46 // Required: true
47 Rack *int64 `json:"rack"`
48
49 // units
50 // Required: true
51 Units []*int64 `json:"units"`
52
53 // User
54 // Required: true
55 User *int64 `json:"user"`
56}
57
58// Validate validates this writable rack reservation
59func (m *WritableRackReservation) Validate(formats strfmt.Registry) error {
60 var res []error
61
62 if err := m.validateDescription(formats); err != nil {
63 // prop
64 res = append(res, err)
65 }
66
67 if err := m.validateRack(formats); err != nil {
68 // prop
69 res = append(res, err)
70 }
71
72 if err := m.validateUnits(formats); err != nil {
73 // prop
74 res = append(res, err)
75 }
76
77 if err := m.validateUser(formats); err != nil {
78 // prop
79 res = append(res, err)
80 }
81
82 if len(res) > 0 {
83 return errors.CompositeValidationError(res...)
84 }
85 return nil
86}
87
88func (m *WritableRackReservation) validateDescription(formats strfmt.Registry) error {
89
90 if err := validate.Required("description", "body", m.Description); err != nil {
91 return err
92 }
93
94 if err := validate.MaxLength("description", "body", string(*m.Description), 100); err != nil {
95 return err
96 }
97
98 return nil
99}
100
101func (m *WritableRackReservation) validateRack(formats strfmt.Registry) error {
102
103 if err := validate.Required("rack", "body", m.Rack); err != nil {
104 return err
105 }
106
107 return nil
108}
109
110func (m *WritableRackReservation) validateUnits(formats strfmt.Registry) error {
111
112 if err := validate.Required("units", "body", m.Units); err != nil {
113 return err
114 }
115
116 for i := 0; i < len(m.Units); i++ {
117
118 if swag.IsZero(m.Units[i]) { // not required
119 continue
120 }
121
122 if err := validate.MinimumInt("units"+"."+strconv.Itoa(i), "body", int64(*m.Units[i]), 0, false); err != nil {
123 return err
124 }
125
126 if err := validate.MaximumInt("units"+"."+strconv.Itoa(i), "body", int64(*m.Units[i]), 32767, false); err != nil {
127 return err
128 }
129
130 }
131
132 return nil
133}
134
135func (m *WritableRackReservation) validateUser(formats strfmt.Registry) error {
136
137 if err := validate.Required("user", "body", m.User); err != nil {
138 return err
139 }
140
141 return nil
142}
143
144// MarshalBinary interface implementation
145func (m *WritableRackReservation) MarshalBinary() ([]byte, error) {
146 if m == nil {
147 return nil, nil
148 }
149 return swag.WriteJSON(m)
150}
151
152// UnmarshalBinary interface implementation
153func (m *WritableRackReservation) UnmarshalBinary(b []byte) error {
154 var res WritableRackReservation
155 if err := swag.ReadJSON(b, &res); err != nil {
156 return err
157 }
158 *m = res
159 return nil
160}