reset_password_request.go 2.4 KB

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