github.com/crowdsecurity/crowdsec@v1.6.1/pkg/modelscapi/reset_password_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  // ResetPasswordRequest resetPassword
    18  //
    19  // # ResetPassword request model
    20  //
    21  // swagger:model ResetPasswordRequest
    22  type ResetPasswordRequest 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  
    36  // Validate validates this reset password request
    37  func (m *ResetPasswordRequest) Validate(formats strfmt.Registry) error {
    38  	var res []error
    39  
    40  	if err := m.validateMachineID(formats); err != nil {
    41  		res = append(res, err)
    42  	}
    43  
    44  	if err := m.validatePassword(formats); err != nil {
    45  		res = append(res, err)
    46  	}
    47  
    48  	if len(res) > 0 {
    49  		return errors.CompositeValidationError(res...)
    50  	}
    51  	return nil
    52  }
    53  
    54  func (m *ResetPasswordRequest) validateMachineID(formats strfmt.Registry) error {
    55  
    56  	if err := validate.Required("machine_id", "body", m.MachineID); err != nil {
    57  		return err
    58  	}
    59  
    60  	if err := validate.MinLength("machine_id", "body", *m.MachineID, 48); err != nil {
    61  		return err
    62  	}
    63  
    64  	if err := validate.MaxLength("machine_id", "body", *m.MachineID, 48); err != nil {
    65  		return err
    66  	}
    67  
    68  	if err := validate.Pattern("machine_id", "body", *m.MachineID, `^[a-zA-Z0-9]+$`); err != nil {
    69  		return err
    70  	}
    71  
    72  	return nil
    73  }
    74  
    75  func (m *ResetPasswordRequest) validatePassword(formats strfmt.Registry) error {
    76  
    77  	if err := validate.Required("password", "body", m.Password); err != nil {
    78  		return err
    79  	}
    80  
    81  	return nil
    82  }
    83  
    84  // ContextValidate validates this reset password request based on context it is used
    85  func (m *ResetPasswordRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    86  	return nil
    87  }
    88  
    89  // MarshalBinary interface implementation
    90  func (m *ResetPasswordRequest) MarshalBinary() ([]byte, error) {
    91  	if m == nil {
    92  		return nil, nil
    93  	}
    94  	return swag.WriteJSON(m)
    95  }
    96  
    97  // UnmarshalBinary interface implementation
    98  func (m *ResetPasswordRequest) UnmarshalBinary(b []byte) error {
    99  	var res ResetPasswordRequest
   100  	if err := swag.ReadJSON(b, &res); err != nil {
   101  		return err
   102  	}
   103  	*m = res
   104  	return nil
   105  }