github.com/crowdsecurity/crowdsec@v1.6.1/pkg/modelscapi/add_signals_request_item_decisions_item.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  // AddSignalsRequestItemDecisionsItem Decision
    18  //
    19  // swagger:model AddSignalsRequestItemDecisionsItem
    20  type AddSignalsRequestItemDecisionsItem struct {
    21  
    22  	// duration
    23  	// Required: true
    24  	Duration *string `json:"duration"`
    25  
    26  	// (only relevant for GET ops) the unique id
    27  	// Required: true
    28  	ID *int64 `json:"id"`
    29  
    30  	// the origin of the decision : cscli, crowdsec
    31  	// Required: true
    32  	Origin *string `json:"origin"`
    33  
    34  	// scenario
    35  	// Required: true
    36  	Scenario *string `json:"scenario"`
    37  
    38  	// the scope of decision : does it apply to an IP, a range, a username, etc
    39  	// Required: true
    40  	Scope *string `json:"scope"`
    41  
    42  	// simulated
    43  	Simulated bool `json:"simulated,omitempty"`
    44  
    45  	// the type of decision, might be 'ban', 'captcha' or something custom. Ignored when watcher (cscli/crowdsec) is pushing to APIL.
    46  	// Required: true
    47  	Type *string `json:"type"`
    48  
    49  	// until
    50  	Until string `json:"until,omitempty"`
    51  
    52  	// the value of the decision scope : an IP, a range, a username, etc
    53  	// Required: true
    54  	Value *string `json:"value"`
    55  }
    56  
    57  // Validate validates this add signals request item decisions item
    58  func (m *AddSignalsRequestItemDecisionsItem) Validate(formats strfmt.Registry) error {
    59  	var res []error
    60  
    61  	if err := m.validateDuration(formats); err != nil {
    62  		res = append(res, err)
    63  	}
    64  
    65  	if err := m.validateID(formats); err != nil {
    66  		res = append(res, err)
    67  	}
    68  
    69  	if err := m.validateOrigin(formats); err != nil {
    70  		res = append(res, err)
    71  	}
    72  
    73  	if err := m.validateScenario(formats); err != nil {
    74  		res = append(res, err)
    75  	}
    76  
    77  	if err := m.validateScope(formats); err != nil {
    78  		res = append(res, err)
    79  	}
    80  
    81  	if err := m.validateType(formats); err != nil {
    82  		res = append(res, err)
    83  	}
    84  
    85  	if err := m.validateValue(formats); err != nil {
    86  		res = append(res, err)
    87  	}
    88  
    89  	if len(res) > 0 {
    90  		return errors.CompositeValidationError(res...)
    91  	}
    92  	return nil
    93  }
    94  
    95  func (m *AddSignalsRequestItemDecisionsItem) validateDuration(formats strfmt.Registry) error {
    96  
    97  	if err := validate.Required("duration", "body", m.Duration); err != nil {
    98  		return err
    99  	}
   100  
   101  	return nil
   102  }
   103  
   104  func (m *AddSignalsRequestItemDecisionsItem) validateID(formats strfmt.Registry) error {
   105  
   106  	if err := validate.Required("id", "body", m.ID); err != nil {
   107  		return err
   108  	}
   109  
   110  	return nil
   111  }
   112  
   113  func (m *AddSignalsRequestItemDecisionsItem) validateOrigin(formats strfmt.Registry) error {
   114  
   115  	if err := validate.Required("origin", "body", m.Origin); err != nil {
   116  		return err
   117  	}
   118  
   119  	return nil
   120  }
   121  
   122  func (m *AddSignalsRequestItemDecisionsItem) validateScenario(formats strfmt.Registry) error {
   123  
   124  	if err := validate.Required("scenario", "body", m.Scenario); err != nil {
   125  		return err
   126  	}
   127  
   128  	return nil
   129  }
   130  
   131  func (m *AddSignalsRequestItemDecisionsItem) validateScope(formats strfmt.Registry) error {
   132  
   133  	if err := validate.Required("scope", "body", m.Scope); err != nil {
   134  		return err
   135  	}
   136  
   137  	return nil
   138  }
   139  
   140  func (m *AddSignalsRequestItemDecisionsItem) validateType(formats strfmt.Registry) error {
   141  
   142  	if err := validate.Required("type", "body", m.Type); err != nil {
   143  		return err
   144  	}
   145  
   146  	return nil
   147  }
   148  
   149  func (m *AddSignalsRequestItemDecisionsItem) validateValue(formats strfmt.Registry) error {
   150  
   151  	if err := validate.Required("value", "body", m.Value); err != nil {
   152  		return err
   153  	}
   154  
   155  	return nil
   156  }
   157  
   158  // ContextValidate validates this add signals request item decisions item based on context it is used
   159  func (m *AddSignalsRequestItemDecisionsItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   160  	return nil
   161  }
   162  
   163  // MarshalBinary interface implementation
   164  func (m *AddSignalsRequestItemDecisionsItem) MarshalBinary() ([]byte, error) {
   165  	if m == nil {
   166  		return nil, nil
   167  	}
   168  	return swag.WriteJSON(m)
   169  }
   170  
   171  // UnmarshalBinary interface implementation
   172  func (m *AddSignalsRequestItemDecisionsItem) UnmarshalBinary(b []byte) error {
   173  	var res AddSignalsRequestItemDecisionsItem
   174  	if err := swag.ReadJSON(b, &res); err != nil {
   175  		return err
   176  	}
   177  	*m = res
   178  	return nil
   179  }