github.com/crowdsecurity/crowdsec@v1.6.1/pkg/modelscapi/decisions_sync_request_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  // DecisionsSyncRequestItem Signal
    18  //
    19  // swagger:model DecisionsSyncRequestItem
    20  type DecisionsSyncRequestItem struct {
    21  
    22  	// alert id
    23  	AlertID int64 `json:"alert_id,omitempty"`
    24  
    25  	// created at
    26  	CreatedAt string `json:"created_at,omitempty"`
    27  
    28  	// decisions
    29  	Decisions DecisionsSyncRequestItemDecisions `json:"decisions,omitempty"`
    30  
    31  	// machine id
    32  	MachineID string `json:"machine_id,omitempty"`
    33  
    34  	// a human readable message
    35  	// Required: true
    36  	Message *string `json:"message"`
    37  
    38  	// scenario
    39  	// Required: true
    40  	Scenario *string `json:"scenario"`
    41  
    42  	// scenario hash
    43  	// Required: true
    44  	ScenarioHash *string `json:"scenario_hash"`
    45  
    46  	// scenario trust
    47  	ScenarioTrust string `json:"scenario_trust,omitempty"`
    48  
    49  	// scenario version
    50  	// Required: true
    51  	ScenarioVersion *string `json:"scenario_version"`
    52  
    53  	// source
    54  	// Required: true
    55  	Source *DecisionsSyncRequestItemSource `json:"source"`
    56  
    57  	// start at
    58  	// Required: true
    59  	StartAt *string `json:"start_at"`
    60  
    61  	// stop at
    62  	// Required: true
    63  	StopAt *string `json:"stop_at"`
    64  }
    65  
    66  // Validate validates this decisions sync request item
    67  func (m *DecisionsSyncRequestItem) Validate(formats strfmt.Registry) error {
    68  	var res []error
    69  
    70  	if err := m.validateDecisions(formats); err != nil {
    71  		res = append(res, err)
    72  	}
    73  
    74  	if err := m.validateMessage(formats); err != nil {
    75  		res = append(res, err)
    76  	}
    77  
    78  	if err := m.validateScenario(formats); err != nil {
    79  		res = append(res, err)
    80  	}
    81  
    82  	if err := m.validateScenarioHash(formats); err != nil {
    83  		res = append(res, err)
    84  	}
    85  
    86  	if err := m.validateScenarioVersion(formats); err != nil {
    87  		res = append(res, err)
    88  	}
    89  
    90  	if err := m.validateSource(formats); err != nil {
    91  		res = append(res, err)
    92  	}
    93  
    94  	if err := m.validateStartAt(formats); err != nil {
    95  		res = append(res, err)
    96  	}
    97  
    98  	if err := m.validateStopAt(formats); err != nil {
    99  		res = append(res, err)
   100  	}
   101  
   102  	if len(res) > 0 {
   103  		return errors.CompositeValidationError(res...)
   104  	}
   105  	return nil
   106  }
   107  
   108  func (m *DecisionsSyncRequestItem) validateDecisions(formats strfmt.Registry) error {
   109  	if swag.IsZero(m.Decisions) { // not required
   110  		return nil
   111  	}
   112  
   113  	if err := m.Decisions.Validate(formats); err != nil {
   114  		if ve, ok := err.(*errors.Validation); ok {
   115  			return ve.ValidateName("decisions")
   116  		} else if ce, ok := err.(*errors.CompositeError); ok {
   117  			return ce.ValidateName("decisions")
   118  		}
   119  		return err
   120  	}
   121  
   122  	return nil
   123  }
   124  
   125  func (m *DecisionsSyncRequestItem) validateMessage(formats strfmt.Registry) error {
   126  
   127  	if err := validate.Required("message", "body", m.Message); err != nil {
   128  		return err
   129  	}
   130  
   131  	return nil
   132  }
   133  
   134  func (m *DecisionsSyncRequestItem) validateScenario(formats strfmt.Registry) error {
   135  
   136  	if err := validate.Required("scenario", "body", m.Scenario); err != nil {
   137  		return err
   138  	}
   139  
   140  	return nil
   141  }
   142  
   143  func (m *DecisionsSyncRequestItem) validateScenarioHash(formats strfmt.Registry) error {
   144  
   145  	if err := validate.Required("scenario_hash", "body", m.ScenarioHash); err != nil {
   146  		return err
   147  	}
   148  
   149  	return nil
   150  }
   151  
   152  func (m *DecisionsSyncRequestItem) validateScenarioVersion(formats strfmt.Registry) error {
   153  
   154  	if err := validate.Required("scenario_version", "body", m.ScenarioVersion); err != nil {
   155  		return err
   156  	}
   157  
   158  	return nil
   159  }
   160  
   161  func (m *DecisionsSyncRequestItem) validateSource(formats strfmt.Registry) error {
   162  
   163  	if err := validate.Required("source", "body", m.Source); err != nil {
   164  		return err
   165  	}
   166  
   167  	if m.Source != nil {
   168  		if err := m.Source.Validate(formats); err != nil {
   169  			if ve, ok := err.(*errors.Validation); ok {
   170  				return ve.ValidateName("source")
   171  			} else if ce, ok := err.(*errors.CompositeError); ok {
   172  				return ce.ValidateName("source")
   173  			}
   174  			return err
   175  		}
   176  	}
   177  
   178  	return nil
   179  }
   180  
   181  func (m *DecisionsSyncRequestItem) validateStartAt(formats strfmt.Registry) error {
   182  
   183  	if err := validate.Required("start_at", "body", m.StartAt); err != nil {
   184  		return err
   185  	}
   186  
   187  	return nil
   188  }
   189  
   190  func (m *DecisionsSyncRequestItem) validateStopAt(formats strfmt.Registry) error {
   191  
   192  	if err := validate.Required("stop_at", "body", m.StopAt); err != nil {
   193  		return err
   194  	}
   195  
   196  	return nil
   197  }
   198  
   199  // ContextValidate validate this decisions sync request item based on the context it is used
   200  func (m *DecisionsSyncRequestItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   201  	var res []error
   202  
   203  	if err := m.contextValidateDecisions(ctx, formats); err != nil {
   204  		res = append(res, err)
   205  	}
   206  
   207  	if err := m.contextValidateSource(ctx, formats); err != nil {
   208  		res = append(res, err)
   209  	}
   210  
   211  	if len(res) > 0 {
   212  		return errors.CompositeValidationError(res...)
   213  	}
   214  	return nil
   215  }
   216  
   217  func (m *DecisionsSyncRequestItem) contextValidateDecisions(ctx context.Context, formats strfmt.Registry) error {
   218  
   219  	if err := m.Decisions.ContextValidate(ctx, formats); err != nil {
   220  		if ve, ok := err.(*errors.Validation); ok {
   221  			return ve.ValidateName("decisions")
   222  		} else if ce, ok := err.(*errors.CompositeError); ok {
   223  			return ce.ValidateName("decisions")
   224  		}
   225  		return err
   226  	}
   227  
   228  	return nil
   229  }
   230  
   231  func (m *DecisionsSyncRequestItem) contextValidateSource(ctx context.Context, formats strfmt.Registry) error {
   232  
   233  	if m.Source != nil {
   234  		if err := m.Source.ContextValidate(ctx, formats); err != nil {
   235  			if ve, ok := err.(*errors.Validation); ok {
   236  				return ve.ValidateName("source")
   237  			} else if ce, ok := err.(*errors.CompositeError); ok {
   238  				return ce.ValidateName("source")
   239  			}
   240  			return err
   241  		}
   242  	}
   243  
   244  	return nil
   245  }
   246  
   247  // MarshalBinary interface implementation
   248  func (m *DecisionsSyncRequestItem) MarshalBinary() ([]byte, error) {
   249  	if m == nil {
   250  		return nil, nil
   251  	}
   252  	return swag.WriteJSON(m)
   253  }
   254  
   255  // UnmarshalBinary interface implementation
   256  func (m *DecisionsSyncRequestItem) UnmarshalBinary(b []byte) error {
   257  	var res DecisionsSyncRequestItem
   258  	if err := swag.ReadJSON(b, &res); err != nil {
   259  		return err
   260  	}
   261  	*m = res
   262  	return nil
   263  }