blob: 6b1fc4b5e611ca3ee4212e2e40f5d55943b3547f [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 "encoding/json"
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// PowerPort power port
33// swagger:model PowerPort
34type PowerPort struct {
35
36 // Connection status
37 ConnectionStatus bool `json:"connection_status,omitempty"`
38
39 // device
40 // Required: true
41 Device *NestedDevice `json:"device"`
42
43 // ID
44 // Read Only: true
45 ID int64 `json:"id,omitempty"`
46
47 // Name
48 // Required: true
49 // Max Length: 50
50 Name *string `json:"name"`
51
52 // power outlet
53 // Required: true
54 PowerOutlet *PowerOutlet `json:"power_outlet"`
55}
56
57// Validate validates this power port
58func (m *PowerPort) Validate(formats strfmt.Registry) error {
59 var res []error
60
61 if err := m.validateConnectionStatus(formats); err != nil {
62 // prop
63 res = append(res, err)
64 }
65
66 if err := m.validateDevice(formats); err != nil {
67 // prop
68 res = append(res, err)
69 }
70
71 if err := m.validateName(formats); err != nil {
72 // prop
73 res = append(res, err)
74 }
75
76 if err := m.validatePowerOutlet(formats); err != nil {
77 // prop
78 res = append(res, err)
79 }
80
81 if len(res) > 0 {
82 return errors.CompositeValidationError(res...)
83 }
84 return nil
85}
86
87var powerPortTypeConnectionStatusPropEnum []interface{}
88
89func init() {
90 var res []bool
91 if err := json.Unmarshal([]byte(`[false,true]`), &res); err != nil {
92 panic(err)
93 }
94 for _, v := range res {
95 powerPortTypeConnectionStatusPropEnum = append(powerPortTypeConnectionStatusPropEnum, v)
96 }
97}
98
99// prop value enum
100func (m *PowerPort) validateConnectionStatusEnum(path, location string, value bool) error {
101 if err := validate.Enum(path, location, value, powerPortTypeConnectionStatusPropEnum); err != nil {
102 return err
103 }
104 return nil
105}
106
107func (m *PowerPort) validateConnectionStatus(formats strfmt.Registry) error {
108
109 if swag.IsZero(m.ConnectionStatus) { // not required
110 return nil
111 }
112
113 // value enum
114 if err := m.validateConnectionStatusEnum("connection_status", "body", m.ConnectionStatus); err != nil {
115 return err
116 }
117
118 return nil
119}
120
121func (m *PowerPort) validateDevice(formats strfmt.Registry) error {
122
123 if err := validate.Required("device", "body", m.Device); err != nil {
124 return err
125 }
126
127 if m.Device != nil {
128
129 if err := m.Device.Validate(formats); err != nil {
130 if ve, ok := err.(*errors.Validation); ok {
131 return ve.ValidateName("device")
132 }
133 return err
134 }
135 }
136
137 return nil
138}
139
140func (m *PowerPort) validateName(formats strfmt.Registry) error {
141
142 if err := validate.Required("name", "body", m.Name); err != nil {
143 return err
144 }
145
146 if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil {
147 return err
148 }
149
150 return nil
151}
152
153func (m *PowerPort) validatePowerOutlet(formats strfmt.Registry) error {
154
155 if err := validate.Required("power_outlet", "body", m.PowerOutlet); err != nil {
156 return err
157 }
158
159 if m.PowerOutlet != nil {
160
161 if err := m.PowerOutlet.Validate(formats); err != nil {
162 if ve, ok := err.(*errors.Validation); ok {
163 return ve.ValidateName("power_outlet")
164 }
165 return err
166 }
167 }
168
169 return nil
170}
171
172// MarshalBinary interface implementation
173func (m *PowerPort) MarshalBinary() ([]byte, error) {
174 if m == nil {
175 return nil, nil
176 }
177 return swag.WriteJSON(m)
178}
179
180// UnmarshalBinary interface implementation
181func (m *PowerPort) UnmarshalBinary(b []byte) error {
182 var res PowerPort
183 if err := swag.ReadJSON(b, &res); err != nil {
184 return err
185 }
186 *m = res
187 return nil
188}