github.com/crowdsecurity/crowdsec@v1.6.1/pkg/models/add_signals_request_item_decisions_item.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  // 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  	// only relevant for LAPI->CAPI, ignored for cscli->LAPI and crowdsec->LAPI
    53  	// Read Only: true
    54  	UUID string `json:"uuid,omitempty"`
    55  
    56  	// the value of the decision scope : an IP, a range, a username, etc
    57  	// Required: true
    58  	Value *string `json:"value"`
    59  }
    60  
    61  // Validate validates this add signals request item decisions item
    62  func (m *AddSignalsRequestItemDecisionsItem) Validate(formats strfmt.Registry) error {
    63  	var res []error
    64  
    65  	if err := m.validateDuration(formats); err != nil {
    66  		res = append(res, err)
    67  	}
    68  
    69  	if err := m.validateID(formats); err != nil {
    70  		res = append(res, err)
    71  	}
    72  
    73  	if err := m.validateOrigin(formats); err != nil {
    74  		res = append(res, err)
    75  	}
    76  
    77  	if err := m.validateScenario(formats); err != nil {
    78  		res = append(res, err)
    79  	}
    80  
    81  	if err := m.validateScope(formats); err != nil {
    82  		res = append(res, err)
    83  	}
    84  
    85  	if err := m.validateType(formats); err != nil {
    86  		res = append(res, err)
    87  	}
    88  
    89  	if err := m.validateValue(formats); err != nil {
    90  		res = append(res, err)
    91  	}
    92  
    93  	if len(res) > 0 {
    94  		return errors.CompositeValidationError(res...)
    95  	}
    96  	return nil
    97  }
    98  
    99  func (m *AddSignalsRequestItemDecisionsItem) validateDuration(formats strfmt.Registry) error {
   100  
   101  	if err := validate.Required("duration", "body", m.Duration); err != nil {
   102  		return err
   103  	}
   104  
   105  	return nil
   106  }
   107  
   108  func (m *AddSignalsRequestItemDecisionsItem) validateID(formats strfmt.Registry) error {
   109  
   110  	if err := validate.Required("id", "body", m.ID); err != nil {
   111  		return err
   112  	}
   113  
   114  	return nil
   115  }
   116  
   117  func (m *AddSignalsRequestItemDecisionsItem) validateOrigin(formats strfmt.Registry) error {
   118  
   119  	if err := validate.Required("origin", "body", m.Origin); err != nil {
   120  		return err
   121  	}
   122  
   123  	return nil
   124  }
   125  
   126  func (m *AddSignalsRequestItemDecisionsItem) validateScenario(formats strfmt.Registry) error {
   127  
   128  	if err := validate.Required("scenario", "body", m.Scenario); err != nil {
   129  		return err
   130  	}
   131  
   132  	return nil
   133  }
   134  
   135  func (m *AddSignalsRequestItemDecisionsItem) validateScope(formats strfmt.Registry) error {
   136  
   137  	if err := validate.Required("scope", "body", m.Scope); err != nil {
   138  		return err
   139  	}
   140  
   141  	return nil
   142  }
   143  
   144  func (m *AddSignalsRequestItemDecisionsItem) validateType(formats strfmt.Registry) error {
   145  
   146  	if err := validate.Required("type", "body", m.Type); err != nil {
   147  		return err
   148  	}
   149  
   150  	return nil
   151  }
   152  
   153  func (m *AddSignalsRequestItemDecisionsItem) validateValue(formats strfmt.Registry) error {
   154  
   155  	if err := validate.Required("value", "body", m.Value); err != nil {
   156  		return err
   157  	}
   158  
   159  	return nil
   160  }
   161  
   162  // ContextValidate validate this add signals request item decisions item based on the context it is used
   163  func (m *AddSignalsRequestItemDecisionsItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   164  	var res []error
   165  
   166  	if err := m.contextValidateUUID(ctx, formats); err != nil {
   167  		res = append(res, err)
   168  	}
   169  
   170  	if len(res) > 0 {
   171  		return errors.CompositeValidationError(res...)
   172  	}
   173  	return nil
   174  }
   175  
   176  func (m *AddSignalsRequestItemDecisionsItem) contextValidateUUID(ctx context.Context, formats strfmt.Registry) error {
   177  
   178  	if err := validate.ReadOnly(ctx, "uuid", "body", string(m.UUID)); err != nil {
   179  		return err
   180  	}
   181  
   182  	return nil
   183  }
   184  
   185  // MarshalBinary interface implementation
   186  func (m *AddSignalsRequestItemDecisionsItem) MarshalBinary() ([]byte, error) {
   187  	if m == nil {
   188  		return nil, nil
   189  	}
   190  	return swag.WriteJSON(m)
   191  }
   192  
   193  // UnmarshalBinary interface implementation
   194  func (m *AddSignalsRequestItemDecisionsItem) UnmarshalBinary(b []byte) error {
   195  	var res AddSignalsRequestItemDecisionsItem
   196  	if err := swag.ReadJSON(b, &res); err != nil {
   197  		return err
   198  	}
   199  	*m = res
   200  	return nil
   201  }