crowdsec/pkg/models/get_allowlist_response.go

174 lines
4 KiB
Go

// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// GetAllowlistResponse GetAllowlistResponse
//
// swagger:model GetAllowlistResponse
type GetAllowlistResponse struct {
// id of the allowlist
AllowlistID string `json:"allowlist_id,omitempty"`
// true if the allowlist is managed by the console
ConsoleManaged bool `json:"console_managed,omitempty"`
// creation date of the allowlist
// Format: date-time
CreatedAt strfmt.DateTime `json:"created_at,omitempty"`
// description of the allowlist
Description string `json:"description,omitempty"`
// items in the allowlist
Items []*AllowlistItem `json:"items"`
// name of the allowlist
Name string `json:"name,omitempty"`
// last update date of the allowlist
// Format: date-time
UpdatedAt strfmt.DateTime `json:"updated_at,omitempty"`
}
// Validate validates this get allowlist response
func (m *GetAllowlistResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCreatedAt(formats); err != nil {
res = append(res, err)
}
if err := m.validateItems(formats); err != nil {
res = append(res, err)
}
if err := m.validateUpdatedAt(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *GetAllowlistResponse) validateCreatedAt(formats strfmt.Registry) error {
if swag.IsZero(m.CreatedAt) { // not required
return nil
}
if err := validate.FormatOf("created_at", "body", "date-time", m.CreatedAt.String(), formats); err != nil {
return err
}
return nil
}
func (m *GetAllowlistResponse) validateItems(formats strfmt.Registry) error {
if swag.IsZero(m.Items) { // not required
return nil
}
for i := 0; i < len(m.Items); i++ {
if swag.IsZero(m.Items[i]) { // not required
continue
}
if m.Items[i] != nil {
if err := m.Items[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("items" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("items" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *GetAllowlistResponse) validateUpdatedAt(formats strfmt.Registry) error {
if swag.IsZero(m.UpdatedAt) { // not required
return nil
}
if err := validate.FormatOf("updated_at", "body", "date-time", m.UpdatedAt.String(), formats); err != nil {
return err
}
return nil
}
// ContextValidate validate this get allowlist response based on the context it is used
func (m *GetAllowlistResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateItems(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *GetAllowlistResponse) contextValidateItems(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Items); i++ {
if m.Items[i] != nil {
if swag.IsZero(m.Items[i]) { // not required
return nil
}
if err := m.Items[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("items" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("items" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *GetAllowlistResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *GetAllowlistResponse) UnmarshalBinary(b []byte) error {
var res GetAllowlistResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}