github.com/digitalocean/go-netbox@v0.0.2/netbox/models/nested_virtual_machine.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright 2020 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 18 package models 19 20 // This file was generated by the swagger tool. 21 // Editing this file might prove futile when you re-run the swagger generate command 22 23 import ( 24 "context" 25 26 "github.com/go-openapi/errors" 27 "github.com/go-openapi/strfmt" 28 "github.com/go-openapi/swag" 29 "github.com/go-openapi/validate" 30 ) 31 32 // NestedVirtualMachine nested virtual machine 33 // 34 // swagger:model NestedVirtualMachine 35 type NestedVirtualMachine struct { 36 37 // Display 38 // Read Only: true 39 Display string `json:"display,omitempty"` 40 41 // Id 42 // Read Only: true 43 ID int64 `json:"id,omitempty"` 44 45 // Name 46 // Required: true 47 // Max Length: 64 48 // Min Length: 1 49 Name *string `json:"name"` 50 51 // Url 52 // Read Only: true 53 // Format: uri 54 URL strfmt.URI `json:"url,omitempty"` 55 } 56 57 // Validate validates this nested virtual machine 58 func (m *NestedVirtualMachine) Validate(formats strfmt.Registry) error { 59 var res []error 60 61 if err := m.validateName(formats); err != nil { 62 res = append(res, err) 63 } 64 65 if err := m.validateURL(formats); err != nil { 66 res = append(res, err) 67 } 68 69 if len(res) > 0 { 70 return errors.CompositeValidationError(res...) 71 } 72 return nil 73 } 74 75 func (m *NestedVirtualMachine) validateName(formats strfmt.Registry) error { 76 77 if err := validate.Required("name", "body", m.Name); err != nil { 78 return err 79 } 80 81 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 82 return err 83 } 84 85 if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil { 86 return err 87 } 88 89 return nil 90 } 91 92 func (m *NestedVirtualMachine) validateURL(formats strfmt.Registry) error { 93 if swag.IsZero(m.URL) { // not required 94 return nil 95 } 96 97 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 98 return err 99 } 100 101 return nil 102 } 103 104 // ContextValidate validate this nested virtual machine based on the context it is used 105 func (m *NestedVirtualMachine) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 106 var res []error 107 108 if err := m.contextValidateDisplay(ctx, formats); err != nil { 109 res = append(res, err) 110 } 111 112 if err := m.contextValidateID(ctx, formats); err != nil { 113 res = append(res, err) 114 } 115 116 if err := m.contextValidateURL(ctx, formats); err != nil { 117 res = append(res, err) 118 } 119 120 if len(res) > 0 { 121 return errors.CompositeValidationError(res...) 122 } 123 return nil 124 } 125 126 func (m *NestedVirtualMachine) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 127 128 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 129 return err 130 } 131 132 return nil 133 } 134 135 func (m *NestedVirtualMachine) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 136 137 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 138 return err 139 } 140 141 return nil 142 } 143 144 func (m *NestedVirtualMachine) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 145 146 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 147 return err 148 } 149 150 return nil 151 } 152 153 // MarshalBinary interface implementation 154 func (m *NestedVirtualMachine) MarshalBinary() ([]byte, error) { 155 if m == nil { 156 return nil, nil 157 } 158 return swag.WriteJSON(m) 159 } 160 161 // UnmarshalBinary interface implementation 162 func (m *NestedVirtualMachine) UnmarshalBinary(b []byte) error { 163 var res NestedVirtualMachine 164 if err := swag.ReadJSON(b, &res); err != nil { 165 return err 166 } 167 *m = res 168 return nil 169 }