github.com/crowdsecurity/crowdsec@v1.6.1/pkg/models/watcher_registration_request.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     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  // WatcherRegistrationRequest WatcherRegistrationRequest
    18  //
    19  // swagger:model WatcherRegistrationRequest
    20  type WatcherRegistrationRequest struct {
    21  
    22  	// machine id
    23  	// Required: true
    24  	MachineID *string `json:"machine_id"`
    25  
    26  	// password
    27  	// Required: true
    28  	// Format: password
    29  	Password *strfmt.Password `json:"password"`
    30  }
    31  
    32  // Validate validates this watcher registration request
    33  func (m *WatcherRegistrationRequest) Validate(formats strfmt.Registry) error {
    34  	var res []error
    35  
    36  	if err := m.validateMachineID(formats); err != nil {
    37  		res = append(res, err)
    38  	}
    39  
    40  	if err := m.validatePassword(formats); err != nil {
    41  		res = append(res, err)
    42  	}
    43  
    44  	if len(res) > 0 {
    45  		return errors.CompositeValidationError(res...)
    46  	}
    47  	return nil
    48  }
    49  
    50  func (m *WatcherRegistrationRequest) validateMachineID(formats strfmt.Registry) error {
    51  
    52  	if err := validate.Required("machine_id", "body", m.MachineID); err != nil {
    53  		return err
    54  	}
    55  
    56  	return nil
    57  }
    58  
    59  func (m *WatcherRegistrationRequest) validatePassword(formats strfmt.Registry) error {
    60  
    61  	if err := validate.Required("password", "body", m.Password); err != nil {
    62  		return err
    63  	}
    64  
    65  	if err := validate.FormatOf("password", "body", "password", m.Password.String(), formats); err != nil {
    66  		return err
    67  	}
    68  
    69  	return nil
    70  }
    71  
    72  // ContextValidate validates this watcher registration request based on context it is used
    73  func (m *WatcherRegistrationRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    74  	return nil
    75  }
    76  
    77  // MarshalBinary interface implementation
    78  func (m *WatcherRegistrationRequest) MarshalBinary() ([]byte, error) {
    79  	if m == nil {
    80  		return nil, nil
    81  	}
    82  	return swag.WriteJSON(m)
    83  }
    84  
    85  // UnmarshalBinary interface implementation
    86  func (m *WatcherRegistrationRequest) UnmarshalBinary(b []byte) error {
    87  	var res WatcherRegistrationRequest
    88  	if err := swag.ReadJSON(b, &res); err != nil {
    89  		return err
    90  	}
    91  	*m = res
    92  	return nil
    93  }