github.com/crowdsecurity/crowdsec@v1.6.1/pkg/models/watcher_auth_request.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 "github.com/go-openapi/validate" 15 ) 16 17 // WatcherAuthRequest WatcherAuthRequest 18 // 19 // swagger:model WatcherAuthRequest 20 type WatcherAuthRequest struct { 21 22 // machine id 23 // Required: true 24 MachineID *string `json:"machine_id"` 25 26 // password 27 // Required: true 28 // Format: password 29 Password *strfmt.Password `json:"password"` 30 31 // the list of scenarios enabled on the watcher 32 Scenarios []string `json:"scenarios"` 33 } 34 35 // Validate validates this watcher auth request 36 func (m *WatcherAuthRequest) Validate(formats strfmt.Registry) error { 37 var res []error 38 39 if err := m.validateMachineID(formats); err != nil { 40 res = append(res, err) 41 } 42 43 if err := m.validatePassword(formats); err != nil { 44 res = append(res, err) 45 } 46 47 if len(res) > 0 { 48 return errors.CompositeValidationError(res...) 49 } 50 return nil 51 } 52 53 func (m *WatcherAuthRequest) validateMachineID(formats strfmt.Registry) error { 54 55 if err := validate.Required("machine_id", "body", m.MachineID); err != nil { 56 return err 57 } 58 59 return nil 60 } 61 62 func (m *WatcherAuthRequest) validatePassword(formats strfmt.Registry) error { 63 64 if err := validate.Required("password", "body", m.Password); err != nil { 65 return err 66 } 67 68 if err := validate.FormatOf("password", "body", "password", m.Password.String(), formats); err != nil { 69 return err 70 } 71 72 return nil 73 } 74 75 // ContextValidate validates this watcher auth request based on context it is used 76 func (m *WatcherAuthRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 77 return nil 78 } 79 80 // MarshalBinary interface implementation 81 func (m *WatcherAuthRequest) MarshalBinary() ([]byte, error) { 82 if m == nil { 83 return nil, nil 84 } 85 return swag.WriteJSON(m) 86 } 87 88 // UnmarshalBinary interface implementation 89 func (m *WatcherAuthRequest) UnmarshalBinary(b []byte) error { 90 var res WatcherAuthRequest 91 if err := swag.ReadJSON(b, &res); err != nil { 92 return err 93 } 94 *m = res 95 return nil 96 }