blob: 7b628bba0649cb7f5ce1a94b2375ac51c551c421 [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// PowerPortTemplate power port template
31// swagger:model PowerPortTemplate
32type PowerPortTemplate struct {
33
34 // device type
35 // Required: true
36 DeviceType *NestedDeviceType `json:"device_type"`
37
38 // ID
39 // Read Only: true
40 ID int64 `json:"id,omitempty"`
41
42 // Name
43 // Required: true
44 // Max Length: 50
45 Name *string `json:"name"`
46}
47
48// Validate validates this power port template
49func (m *PowerPortTemplate) Validate(formats strfmt.Registry) error {
50 var res []error
51
52 if err := m.validateDeviceType(formats); err != nil {
53 // prop
54 res = append(res, err)
55 }
56
57 if err := m.validateName(formats); err != nil {
58 // prop
59 res = append(res, err)
60 }
61
62 if len(res) > 0 {
63 return errors.CompositeValidationError(res...)
64 }
65 return nil
66}
67
68func (m *PowerPortTemplate) validateDeviceType(formats strfmt.Registry) error {
69
70 if err := validate.Required("device_type", "body", m.DeviceType); err != nil {
71 return err
72 }
73
74 if m.DeviceType != nil {
75
76 if err := m.DeviceType.Validate(formats); err != nil {
77 if ve, ok := err.(*errors.Validation); ok {
78 return ve.ValidateName("device_type")
79 }
80 return err
81 }
82 }
83
84 return nil
85}
86
87func (m *PowerPortTemplate) validateName(formats strfmt.Registry) error {
88
89 if err := validate.Required("name", "body", m.Name); err != nil {
90 return err
91 }
92
93 if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil {
94 return err
95 }
96
97 return nil
98}
99
100// MarshalBinary interface implementation
101func (m *PowerPortTemplate) MarshalBinary() ([]byte, error) {
102 if m == nil {
103 return nil, nil
104 }
105 return swag.WriteJSON(m)
106}
107
108// UnmarshalBinary interface implementation
109func (m *PowerPortTemplate) UnmarshalBinary(b []byte) error {
110 var res PowerPortTemplate
111 if err := swag.ReadJSON(b, &res); err != nil {
112 return err
113 }
114 *m = res
115 return nil
116}