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