github.com/crowdsecurity/crowdsec@v1.6.1/pkg/modelscapi/login_request.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package modelscapi 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 // LoginRequest login request 18 // 19 // # Login request model 20 // 21 // swagger:model LoginRequest 22 type LoginRequest struct { 23 24 // machine_id is a (username) generated by crowdsec 25 // Required: true 26 // Max Length: 48 27 // Min Length: 48 28 // Pattern: ^[a-zA-Z0-9]+$ 29 MachineID *string `json:"machine_id"` 30 31 // Password, should respect the password policy (link to add) 32 // Required: true 33 Password *string `json:"password"` 34 35 // all scenarios installed 36 Scenarios []string `json:"scenarios"` 37 } 38 39 // Validate validates this login request 40 func (m *LoginRequest) Validate(formats strfmt.Registry) error { 41 var res []error 42 43 if err := m.validateMachineID(formats); err != nil { 44 res = append(res, err) 45 } 46 47 if err := m.validatePassword(formats); err != nil { 48 res = append(res, err) 49 } 50 51 if len(res) > 0 { 52 return errors.CompositeValidationError(res...) 53 } 54 return nil 55 } 56 57 func (m *LoginRequest) validateMachineID(formats strfmt.Registry) error { 58 59 if err := validate.Required("machine_id", "body", m.MachineID); err != nil { 60 return err 61 } 62 63 if err := validate.MinLength("machine_id", "body", *m.MachineID, 48); err != nil { 64 return err 65 } 66 67 if err := validate.MaxLength("machine_id", "body", *m.MachineID, 48); err != nil { 68 return err 69 } 70 71 if err := validate.Pattern("machine_id", "body", *m.MachineID, `^[a-zA-Z0-9]+$`); err != nil { 72 return err 73 } 74 75 return nil 76 } 77 78 func (m *LoginRequest) validatePassword(formats strfmt.Registry) error { 79 80 if err := validate.Required("password", "body", m.Password); err != nil { 81 return err 82 } 83 84 return nil 85 } 86 87 // ContextValidate validates this login request based on context it is used 88 func (m *LoginRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 89 return nil 90 } 91 92 // MarshalBinary interface implementation 93 func (m *LoginRequest) MarshalBinary() ([]byte, error) { 94 if m == nil { 95 return nil, nil 96 } 97 return swag.WriteJSON(m) 98 } 99 100 // UnmarshalBinary interface implementation 101 func (m *LoginRequest) UnmarshalBinary(b []byte) error { 102 var res LoginRequest 103 if err := swag.ReadJSON(b, &res); err != nil { 104 return err 105 } 106 *m = res 107 return nil 108 }