blob: 28320bfde4e8ff176a2cfa29e2edd16b3e8cc059 [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// Secret secret
31// swagger:model Secret
32type Secret struct {
33
34 // Created
35 // Read Only: true
36 Created strfmt.Date `json:"created,omitempty"`
37
38 // device
39 // Required: true
40 Device *NestedDevice `json:"device"`
41
42 // Hash
43 // Read Only: true
44 Hash string `json:"hash,omitempty"`
45
46 // ID
47 // Read Only: true
48 ID int64 `json:"id,omitempty"`
49
50 // Last updated
51 // Read Only: true
52 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
53
54 // Name
55 // Required: true
56 // Max Length: 100
57 Name *string `json:"name"`
58
59 // Plaintext
60 // Read Only: true
61 Plaintext string `json:"plaintext,omitempty"`
62
63 // role
64 // Required: true
65 Role *NestedSecretRole `json:"role"`
66}
67
68// Validate validates this secret
69func (m *Secret) Validate(formats strfmt.Registry) error {
70 var res []error
71
72 if err := m.validateDevice(formats); err != nil {
73 // prop
74 res = append(res, err)
75 }
76
77 if err := m.validateName(formats); err != nil {
78 // prop
79 res = append(res, err)
80 }
81
82 if err := m.validateRole(formats); err != nil {
83 // prop
84 res = append(res, err)
85 }
86
87 if len(res) > 0 {
88 return errors.CompositeValidationError(res...)
89 }
90 return nil
91}
92
93func (m *Secret) validateDevice(formats strfmt.Registry) error {
94
95 if err := validate.Required("device", "body", m.Device); err != nil {
96 return err
97 }
98
99 if m.Device != nil {
100
101 if err := m.Device.Validate(formats); err != nil {
102 if ve, ok := err.(*errors.Validation); ok {
103 return ve.ValidateName("device")
104 }
105 return err
106 }
107 }
108
109 return nil
110}
111
112func (m *Secret) validateName(formats strfmt.Registry) error {
113
114 if err := validate.Required("name", "body", m.Name); err != nil {
115 return err
116 }
117
118 if err := validate.MaxLength("name", "body", string(*m.Name), 100); err != nil {
119 return err
120 }
121
122 return nil
123}
124
125func (m *Secret) validateRole(formats strfmt.Registry) error {
126
127 if err := validate.Required("role", "body", m.Role); err != nil {
128 return err
129 }
130
131 if m.Role != nil {
132
133 if err := m.Role.Validate(formats); err != nil {
134 if ve, ok := err.(*errors.Validation); ok {
135 return ve.ValidateName("role")
136 }
137 return err
138 }
139 }
140
141 return nil
142}
143
144// MarshalBinary interface implementation
145func (m *Secret) 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 *Secret) UnmarshalBinary(b []byte) error {
154 var res Secret
155 if err := swag.ReadJSON(b, &res); err != nil {
156 return err
157 }
158 *m = res
159 return nil
160}