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