github.com/crowdsecurity/crowdsec@v1.6.1/pkg/modelscapi/get_decisions_stream_response_new_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  	"strconv"
    11  
    12  	"github.com/go-openapi/errors"
    13  	"github.com/go-openapi/strfmt"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  )
    17  
    18  // GetDecisionsStreamResponseNewItem New Decisions
    19  //
    20  // swagger:model GetDecisionsStreamResponseNewItem
    21  type GetDecisionsStreamResponseNewItem struct {
    22  
    23  	// decisions
    24  	// Required: true
    25  	Decisions []*GetDecisionsStreamResponseNewItemDecisionsItems0 `json:"decisions"`
    26  
    27  	// scenario
    28  	// Required: true
    29  	Scenario *string `json:"scenario"`
    30  
    31  	// the scope of decision : does it apply to an IP, a range, a username, etc
    32  	// Required: true
    33  	Scope *string `json:"scope"`
    34  }
    35  
    36  // Validate validates this get decisions stream response new item
    37  func (m *GetDecisionsStreamResponseNewItem) Validate(formats strfmt.Registry) error {
    38  	var res []error
    39  
    40  	if err := m.validateDecisions(formats); err != nil {
    41  		res = append(res, err)
    42  	}
    43  
    44  	if err := m.validateScenario(formats); err != nil {
    45  		res = append(res, err)
    46  	}
    47  
    48  	if err := m.validateScope(formats); err != nil {
    49  		res = append(res, err)
    50  	}
    51  
    52  	if len(res) > 0 {
    53  		return errors.CompositeValidationError(res...)
    54  	}
    55  	return nil
    56  }
    57  
    58  func (m *GetDecisionsStreamResponseNewItem) validateDecisions(formats strfmt.Registry) error {
    59  
    60  	if err := validate.Required("decisions", "body", m.Decisions); err != nil {
    61  		return err
    62  	}
    63  
    64  	for i := 0; i < len(m.Decisions); i++ {
    65  		if swag.IsZero(m.Decisions[i]) { // not required
    66  			continue
    67  		}
    68  
    69  		if m.Decisions[i] != nil {
    70  			if err := m.Decisions[i].Validate(formats); err != nil {
    71  				if ve, ok := err.(*errors.Validation); ok {
    72  					return ve.ValidateName("decisions" + "." + strconv.Itoa(i))
    73  				} else if ce, ok := err.(*errors.CompositeError); ok {
    74  					return ce.ValidateName("decisions" + "." + strconv.Itoa(i))
    75  				}
    76  				return err
    77  			}
    78  		}
    79  
    80  	}
    81  
    82  	return nil
    83  }
    84  
    85  func (m *GetDecisionsStreamResponseNewItem) validateScenario(formats strfmt.Registry) error {
    86  
    87  	if err := validate.Required("scenario", "body", m.Scenario); err != nil {
    88  		return err
    89  	}
    90  
    91  	return nil
    92  }
    93  
    94  func (m *GetDecisionsStreamResponseNewItem) validateScope(formats strfmt.Registry) error {
    95  
    96  	if err := validate.Required("scope", "body", m.Scope); err != nil {
    97  		return err
    98  	}
    99  
   100  	return nil
   101  }
   102  
   103  // ContextValidate validate this get decisions stream response new item based on the context it is used
   104  func (m *GetDecisionsStreamResponseNewItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   105  	var res []error
   106  
   107  	if err := m.contextValidateDecisions(ctx, formats); err != nil {
   108  		res = append(res, err)
   109  	}
   110  
   111  	if len(res) > 0 {
   112  		return errors.CompositeValidationError(res...)
   113  	}
   114  	return nil
   115  }
   116  
   117  func (m *GetDecisionsStreamResponseNewItem) contextValidateDecisions(ctx context.Context, formats strfmt.Registry) error {
   118  
   119  	for i := 0; i < len(m.Decisions); i++ {
   120  
   121  		if m.Decisions[i] != nil {
   122  			if err := m.Decisions[i].ContextValidate(ctx, formats); err != nil {
   123  				if ve, ok := err.(*errors.Validation); ok {
   124  					return ve.ValidateName("decisions" + "." + strconv.Itoa(i))
   125  				} else if ce, ok := err.(*errors.CompositeError); ok {
   126  					return ce.ValidateName("decisions" + "." + strconv.Itoa(i))
   127  				}
   128  				return err
   129  			}
   130  		}
   131  
   132  	}
   133  
   134  	return nil
   135  }
   136  
   137  // MarshalBinary interface implementation
   138  func (m *GetDecisionsStreamResponseNewItem) MarshalBinary() ([]byte, error) {
   139  	if m == nil {
   140  		return nil, nil
   141  	}
   142  	return swag.WriteJSON(m)
   143  }
   144  
   145  // UnmarshalBinary interface implementation
   146  func (m *GetDecisionsStreamResponseNewItem) UnmarshalBinary(b []byte) error {
   147  	var res GetDecisionsStreamResponseNewItem
   148  	if err := swag.ReadJSON(b, &res); err != nil {
   149  		return err
   150  	}
   151  	*m = res
   152  	return nil
   153  }
   154  
   155  // GetDecisionsStreamResponseNewItemDecisionsItems0 get decisions stream response new item decisions items0
   156  //
   157  // swagger:model GetDecisionsStreamResponseNewItemDecisionsItems0
   158  type GetDecisionsStreamResponseNewItemDecisionsItems0 struct {
   159  
   160  	// duration
   161  	// Required: true
   162  	Duration *string `json:"duration"`
   163  
   164  	// the value of the decision scope : an IP, a range, a username, etc
   165  	// Required: true
   166  	Value *string `json:"value"`
   167  }
   168  
   169  // Validate validates this get decisions stream response new item decisions items0
   170  func (m *GetDecisionsStreamResponseNewItemDecisionsItems0) Validate(formats strfmt.Registry) error {
   171  	var res []error
   172  
   173  	if err := m.validateDuration(formats); err != nil {
   174  		res = append(res, err)
   175  	}
   176  
   177  	if err := m.validateValue(formats); err != nil {
   178  		res = append(res, err)
   179  	}
   180  
   181  	if len(res) > 0 {
   182  		return errors.CompositeValidationError(res...)
   183  	}
   184  	return nil
   185  }
   186  
   187  func (m *GetDecisionsStreamResponseNewItemDecisionsItems0) validateDuration(formats strfmt.Registry) error {
   188  
   189  	if err := validate.Required("duration", "body", m.Duration); err != nil {
   190  		return err
   191  	}
   192  
   193  	return nil
   194  }
   195  
   196  func (m *GetDecisionsStreamResponseNewItemDecisionsItems0) validateValue(formats strfmt.Registry) error {
   197  
   198  	if err := validate.Required("value", "body", m.Value); err != nil {
   199  		return err
   200  	}
   201  
   202  	return nil
   203  }
   204  
   205  // ContextValidate validates this get decisions stream response new item decisions items0 based on context it is used
   206  func (m *GetDecisionsStreamResponseNewItemDecisionsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   207  	return nil
   208  }
   209  
   210  // MarshalBinary interface implementation
   211  func (m *GetDecisionsStreamResponseNewItemDecisionsItems0) MarshalBinary() ([]byte, error) {
   212  	if m == nil {
   213  		return nil, nil
   214  	}
   215  	return swag.WriteJSON(m)
   216  }
   217  
   218  // UnmarshalBinary interface implementation
   219  func (m *GetDecisionsStreamResponseNewItemDecisionsItems0) UnmarshalBinary(b []byte) error {
   220  	var res GetDecisionsStreamResponseNewItemDecisionsItems0
   221  	if err := swag.ReadJSON(b, &res); err != nil {
   222  		return err
   223  	}
   224  	*m = res
   225  	return nil
   226  }