github.com/crowdsecurity/crowdsec@v1.6.1/pkg/modelscapi/get_decisions_stream_response_links.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  )
    16  
    17  // GetDecisionsStreamResponseLinks Decisions list
    18  //
    19  // swagger:model GetDecisionsStreamResponseLinks
    20  type GetDecisionsStreamResponseLinks struct {
    21  
    22  	// blocklists
    23  	Blocklists []*BlocklistLink `json:"blocklists"`
    24  }
    25  
    26  // Validate validates this get decisions stream response links
    27  func (m *GetDecisionsStreamResponseLinks) Validate(formats strfmt.Registry) error {
    28  	var res []error
    29  
    30  	if err := m.validateBlocklists(formats); err != nil {
    31  		res = append(res, err)
    32  	}
    33  
    34  	if len(res) > 0 {
    35  		return errors.CompositeValidationError(res...)
    36  	}
    37  	return nil
    38  }
    39  
    40  func (m *GetDecisionsStreamResponseLinks) validateBlocklists(formats strfmt.Registry) error {
    41  	if swag.IsZero(m.Blocklists) { // not required
    42  		return nil
    43  	}
    44  
    45  	for i := 0; i < len(m.Blocklists); i++ {
    46  		if swag.IsZero(m.Blocklists[i]) { // not required
    47  			continue
    48  		}
    49  
    50  		if m.Blocklists[i] != nil {
    51  			if err := m.Blocklists[i].Validate(formats); err != nil {
    52  				if ve, ok := err.(*errors.Validation); ok {
    53  					return ve.ValidateName("blocklists" + "." + strconv.Itoa(i))
    54  				} else if ce, ok := err.(*errors.CompositeError); ok {
    55  					return ce.ValidateName("blocklists" + "." + strconv.Itoa(i))
    56  				}
    57  				return err
    58  			}
    59  		}
    60  
    61  	}
    62  
    63  	return nil
    64  }
    65  
    66  // ContextValidate validate this get decisions stream response links based on the context it is used
    67  func (m *GetDecisionsStreamResponseLinks) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    68  	var res []error
    69  
    70  	if err := m.contextValidateBlocklists(ctx, formats); err != nil {
    71  		res = append(res, err)
    72  	}
    73  
    74  	if len(res) > 0 {
    75  		return errors.CompositeValidationError(res...)
    76  	}
    77  	return nil
    78  }
    79  
    80  func (m *GetDecisionsStreamResponseLinks) contextValidateBlocklists(ctx context.Context, formats strfmt.Registry) error {
    81  
    82  	for i := 0; i < len(m.Blocklists); i++ {
    83  
    84  		if m.Blocklists[i] != nil {
    85  			if err := m.Blocklists[i].ContextValidate(ctx, formats); err != nil {
    86  				if ve, ok := err.(*errors.Validation); ok {
    87  					return ve.ValidateName("blocklists" + "." + strconv.Itoa(i))
    88  				} else if ce, ok := err.(*errors.CompositeError); ok {
    89  					return ce.ValidateName("blocklists" + "." + strconv.Itoa(i))
    90  				}
    91  				return err
    92  			}
    93  		}
    94  
    95  	}
    96  
    97  	return nil
    98  }
    99  
   100  // MarshalBinary interface implementation
   101  func (m *GetDecisionsStreamResponseLinks) MarshalBinary() ([]byte, error) {
   102  	if m == nil {
   103  		return nil, nil
   104  	}
   105  	return swag.WriteJSON(m)
   106  }
   107  
   108  // UnmarshalBinary interface implementation
   109  func (m *GetDecisionsStreamResponseLinks) UnmarshalBinary(b []byte) error {
   110  	var res GetDecisionsStreamResponseLinks
   111  	if err := swag.ReadJSON(b, &res); err != nil {
   112  		return err
   113  	}
   114  	*m = res
   115  	return nil
   116  }