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 | 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 | // WritableSecret writable secret |
| 31 | // swagger:model WritableSecret |
| 32 | type WritableSecret struct { |
| 33 | |
| 34 | // Created |
| 35 | // Read Only: true |
| 36 | Created strfmt.Date `json:"created,omitempty"` |
| 37 | |
| 38 | // Device |
| 39 | // Required: true |
| 40 | Device *int64 `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 | // Max Length: 100 |
| 56 | Name string `json:"name,omitempty"` |
| 57 | |
| 58 | // Plaintext |
| 59 | // Required: true |
| 60 | Plaintext *string `json:"plaintext"` |
| 61 | |
| 62 | // Role |
| 63 | // Required: true |
| 64 | Role *int64 `json:"role"` |
| 65 | } |
| 66 | |
| 67 | // Validate validates this writable secret |
| 68 | func (m *WritableSecret) Validate(formats strfmt.Registry) error { |
| 69 | var res []error |
| 70 | |
| 71 | if err := m.validateDevice(formats); err != nil { |
| 72 | // prop |
| 73 | res = append(res, err) |
| 74 | } |
| 75 | |
| 76 | if err := m.validateName(formats); err != nil { |
| 77 | // prop |
| 78 | res = append(res, err) |
| 79 | } |
| 80 | |
| 81 | if err := m.validatePlaintext(formats); err != nil { |
| 82 | // prop |
| 83 | res = append(res, err) |
| 84 | } |
| 85 | |
| 86 | if err := m.validateRole(formats); err != nil { |
| 87 | // prop |
| 88 | res = append(res, err) |
| 89 | } |
| 90 | |
| 91 | if len(res) > 0 { |
| 92 | return errors.CompositeValidationError(res...) |
| 93 | } |
| 94 | return nil |
| 95 | } |
| 96 | |
| 97 | func (m *WritableSecret) validateDevice(formats strfmt.Registry) error { |
| 98 | |
| 99 | if err := validate.Required("device", "body", m.Device); err != nil { |
| 100 | return err |
| 101 | } |
| 102 | |
| 103 | return nil |
| 104 | } |
| 105 | |
| 106 | func (m *WritableSecret) validateName(formats strfmt.Registry) error { |
| 107 | |
| 108 | if swag.IsZero(m.Name) { // not required |
| 109 | return nil |
| 110 | } |
| 111 | |
| 112 | if err := validate.MaxLength("name", "body", string(m.Name), 100); err != nil { |
| 113 | return err |
| 114 | } |
| 115 | |
| 116 | return nil |
| 117 | } |
| 118 | |
| 119 | func (m *WritableSecret) validatePlaintext(formats strfmt.Registry) error { |
| 120 | |
| 121 | if err := validate.Required("plaintext", "body", m.Plaintext); err != nil { |
| 122 | return err |
| 123 | } |
| 124 | |
| 125 | return nil |
| 126 | } |
| 127 | |
| 128 | func (m *WritableSecret) validateRole(formats strfmt.Registry) error { |
| 129 | |
| 130 | if err := validate.Required("role", "body", m.Role); err != nil { |
| 131 | return err |
| 132 | } |
| 133 | |
| 134 | return nil |
| 135 | } |
| 136 | |
| 137 | // MarshalBinary interface implementation |
| 138 | func (m *WritableSecret) 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 *WritableSecret) UnmarshalBinary(b []byte) error { |
| 147 | var res WritableSecret |
| 148 | if err := swag.ReadJSON(b, &res); err != nil { |
| 149 | return err |
| 150 | } |
| 151 | *m = res |
| 152 | return nil |
| 153 | } |