github.com/crowdsecurity/crowdsec@v1.6.1/pkg/modelscapi/add_signals_request_item_source.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  // AddSignalsRequestItemSource Source
    18  //
    19  // swagger:model AddSignalsRequestItemSource
    20  type AddSignalsRequestItemSource struct {
    21  
    22  	// provided as a convenience when the source is an IP
    23  	AsName string `json:"as_name,omitempty"`
    24  
    25  	// provided as a convenience when the source is an IP
    26  	AsNumber string `json:"as_number,omitempty"`
    27  
    28  	// cn
    29  	Cn string `json:"cn,omitempty"`
    30  
    31  	// provided as a convenience when the source is an IP
    32  	IP string `json:"ip,omitempty"`
    33  
    34  	// latitude
    35  	Latitude float32 `json:"latitude,omitempty"`
    36  
    37  	// longitude
    38  	Longitude float32 `json:"longitude,omitempty"`
    39  
    40  	// provided as a convenience when the source is an IP
    41  	Range string `json:"range,omitempty"`
    42  
    43  	// the scope of a source : ip,range,username,etc
    44  	// Required: true
    45  	Scope *string `json:"scope"`
    46  
    47  	// the value of a source : the ip, the range, the username,etc
    48  	// Required: true
    49  	Value *string `json:"value"`
    50  }
    51  
    52  // Validate validates this add signals request item source
    53  func (m *AddSignalsRequestItemSource) Validate(formats strfmt.Registry) error {
    54  	var res []error
    55  
    56  	if err := m.validateScope(formats); err != nil {
    57  		res = append(res, err)
    58  	}
    59  
    60  	if err := m.validateValue(formats); err != nil {
    61  		res = append(res, err)
    62  	}
    63  
    64  	if len(res) > 0 {
    65  		return errors.CompositeValidationError(res...)
    66  	}
    67  	return nil
    68  }
    69  
    70  func (m *AddSignalsRequestItemSource) validateScope(formats strfmt.Registry) error {
    71  
    72  	if err := validate.Required("scope", "body", m.Scope); err != nil {
    73  		return err
    74  	}
    75  
    76  	return nil
    77  }
    78  
    79  func (m *AddSignalsRequestItemSource) validateValue(formats strfmt.Registry) error {
    80  
    81  	if err := validate.Required("value", "body", m.Value); err != nil {
    82  		return err
    83  	}
    84  
    85  	return nil
    86  }
    87  
    88  // ContextValidate validates this add signals request item source based on context it is used
    89  func (m *AddSignalsRequestItemSource) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    90  	return nil
    91  }
    92  
    93  // MarshalBinary interface implementation
    94  func (m *AddSignalsRequestItemSource) MarshalBinary() ([]byte, error) {
    95  	if m == nil {
    96  		return nil, nil
    97  	}
    98  	return swag.WriteJSON(m)
    99  }
   100  
   101  // UnmarshalBinary interface implementation
   102  func (m *AddSignalsRequestItemSource) UnmarshalBinary(b []byte) error {
   103  	var res AddSignalsRequestItemSource
   104  	if err := swag.ReadJSON(b, &res); err != nil {
   105  		return err
   106  	}
   107  	*m = res
   108  	return nil
   109  }