register_request.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Code generated by go-swagger; DO NOT EDIT.
  2. package modelscapi
  3. // This file was generated by the swagger tool.
  4. // Editing this file might prove futile when you re-run the swagger generate command
  5. import (
  6. "context"
  7. "github.com/go-openapi/errors"
  8. "github.com/go-openapi/strfmt"
  9. "github.com/go-openapi/swag"
  10. "github.com/go-openapi/validate"
  11. )
  12. // RegisterRequest register request
  13. //
  14. // # Register request model
  15. //
  16. // swagger:model RegisterRequest
  17. type RegisterRequest struct {
  18. // machine_id is a (username) generated by crowdsec
  19. // Required: true
  20. // Pattern: ^[a-zA-Z0-9]+$
  21. MachineID *string `json:"machine_id"`
  22. // Password, should respect the password policy (link to add)
  23. // Required: true
  24. Password *string `json:"password"`
  25. }
  26. // Validate validates this register request
  27. func (m *RegisterRequest) Validate(formats strfmt.Registry) error {
  28. var res []error
  29. if err := m.validateMachineID(formats); err != nil {
  30. res = append(res, err)
  31. }
  32. if err := m.validatePassword(formats); err != nil {
  33. res = append(res, err)
  34. }
  35. if len(res) > 0 {
  36. return errors.CompositeValidationError(res...)
  37. }
  38. return nil
  39. }
  40. func (m *RegisterRequest) validateMachineID(formats strfmt.Registry) error {
  41. if err := validate.Required("machine_id", "body", m.MachineID); err != nil {
  42. return err
  43. }
  44. if err := validate.Pattern("machine_id", "body", *m.MachineID, `^[a-zA-Z0-9]+$`); err != nil {
  45. return err
  46. }
  47. return nil
  48. }
  49. func (m *RegisterRequest) validatePassword(formats strfmt.Registry) error {
  50. if err := validate.Required("password", "body", m.Password); err != nil {
  51. return err
  52. }
  53. return nil
  54. }
  55. // ContextValidate validates this register request based on context it is used
  56. func (m *RegisterRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
  57. return nil
  58. }
  59. // MarshalBinary interface implementation
  60. func (m *RegisterRequest) MarshalBinary() ([]byte, error) {
  61. if m == nil {
  62. return nil, nil
  63. }
  64. return swag.WriteJSON(m)
  65. }
  66. // UnmarshalBinary interface implementation
  67. func (m *RegisterRequest) UnmarshalBinary(b []byte) error {
  68. var res RegisterRequest
  69. if err := swag.ReadJSON(b, &res); err != nil {
  70. return err
  71. }
  72. *m = res
  73. return nil
  74. }