Serge Bazanski | cc25bdf | 2018-10-25 14:02:58 +0200 | [diff] [blame] | 1 | // 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 | |
| 17 | package 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 | |
| 22 | import ( |
| 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 | // WritablePowerPort writable power port |
| 33 | // swagger:model WritablePowerPort |
| 34 | type WritablePowerPort struct { |
| 35 | |
| 36 | // Connection status |
| 37 | ConnectionStatus bool `json:"connection_status,omitempty"` |
| 38 | |
| 39 | // Device |
| 40 | // Required: true |
| 41 | Device *int64 `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 | PowerOutlet int64 `json:"power_outlet,omitempty"` |
| 54 | } |
| 55 | |
| 56 | // Validate validates this writable power port |
| 57 | func (m *WritablePowerPort) Validate(formats strfmt.Registry) error { |
| 58 | var res []error |
| 59 | |
| 60 | if err := m.validateConnectionStatus(formats); err != nil { |
| 61 | // prop |
| 62 | res = append(res, err) |
| 63 | } |
| 64 | |
| 65 | if err := m.validateDevice(formats); err != nil { |
| 66 | // prop |
| 67 | res = append(res, err) |
| 68 | } |
| 69 | |
| 70 | if err := m.validateName(formats); err != nil { |
| 71 | // prop |
| 72 | res = append(res, err) |
| 73 | } |
| 74 | |
| 75 | if len(res) > 0 { |
| 76 | return errors.CompositeValidationError(res...) |
| 77 | } |
| 78 | return nil |
| 79 | } |
| 80 | |
| 81 | var writablePowerPortTypeConnectionStatusPropEnum []interface{} |
| 82 | |
| 83 | func init() { |
| 84 | var res []bool |
| 85 | if err := json.Unmarshal([]byte(`[false,true]`), &res); err != nil { |
| 86 | panic(err) |
| 87 | } |
| 88 | for _, v := range res { |
| 89 | writablePowerPortTypeConnectionStatusPropEnum = append(writablePowerPortTypeConnectionStatusPropEnum, v) |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // prop value enum |
| 94 | func (m *WritablePowerPort) validateConnectionStatusEnum(path, location string, value bool) error { |
| 95 | if err := validate.Enum(path, location, value, writablePowerPortTypeConnectionStatusPropEnum); err != nil { |
| 96 | return err |
| 97 | } |
| 98 | return nil |
| 99 | } |
| 100 | |
| 101 | func (m *WritablePowerPort) validateConnectionStatus(formats strfmt.Registry) error { |
| 102 | |
| 103 | if swag.IsZero(m.ConnectionStatus) { // not required |
| 104 | return nil |
| 105 | } |
| 106 | |
| 107 | // value enum |
| 108 | if err := m.validateConnectionStatusEnum("connection_status", "body", m.ConnectionStatus); err != nil { |
| 109 | return err |
| 110 | } |
| 111 | |
| 112 | return nil |
| 113 | } |
| 114 | |
| 115 | func (m *WritablePowerPort) validateDevice(formats strfmt.Registry) error { |
| 116 | |
| 117 | if err := validate.Required("device", "body", m.Device); err != nil { |
| 118 | return err |
| 119 | } |
| 120 | |
| 121 | return nil |
| 122 | } |
| 123 | |
| 124 | func (m *WritablePowerPort) validateName(formats strfmt.Registry) error { |
| 125 | |
| 126 | if err := validate.Required("name", "body", m.Name); err != nil { |
| 127 | return err |
| 128 | } |
| 129 | |
| 130 | if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil { |
| 131 | return err |
| 132 | } |
| 133 | |
| 134 | return nil |
| 135 | } |
| 136 | |
| 137 | // MarshalBinary interface implementation |
| 138 | func (m *WritablePowerPort) MarshalBinary() ([]byte, error) { |
| 139 | if m == nil { |
| 140 | return nil, nil |
| 141 | } |
| 142 | return swag.WriteJSON(m) |
| 143 | } |
| 144 | |
| 145 | // UnmarshalBinary interface implementation |
| 146 | func (m *WritablePowerPort) UnmarshalBinary(b []byte) error { |
| 147 | var res WritablePowerPort |
| 148 | if err := swag.ReadJSON(b, &res); err != nil { |
| 149 | return err |
| 150 | } |
| 151 | *m = res |
| 152 | return nil |
| 153 | } |