b412af2e22
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
283 lines
6.4 KiB
Go
283 lines
6.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"
|
|
)
|
|
|
|
// Record A single NeoFS EACL rule.
|
|
// Example: {"action":"ALLOW","filters":[],"operation":"GET","targets":[{"keys":[],"role":"OTHERS"}]}
|
|
//
|
|
// swagger:model Record
|
|
type Record struct {
|
|
|
|
// action
|
|
// Required: true
|
|
Action *Action `json:"action"`
|
|
|
|
// filters
|
|
// Required: true
|
|
Filters []*Filter `json:"filters"`
|
|
|
|
// operation
|
|
// Required: true
|
|
Operation *Operation `json:"operation"`
|
|
|
|
// targets
|
|
// Required: true
|
|
Targets []*Target `json:"targets"`
|
|
}
|
|
|
|
// Validate validates this record
|
|
func (m *Record) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validateAction(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateFilters(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateOperation(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateTargets(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Record) validateAction(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("action", "body", m.Action); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.Required("action", "body", m.Action); err != nil {
|
|
return err
|
|
}
|
|
|
|
if m.Action != nil {
|
|
if err := m.Action.Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("action")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("action")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Record) validateFilters(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("filters", "body", m.Filters); err != nil {
|
|
return err
|
|
}
|
|
|
|
for i := 0; i < len(m.Filters); i++ {
|
|
if swag.IsZero(m.Filters[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Filters[i] != nil {
|
|
if err := m.Filters[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("filters" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("filters" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Record) validateOperation(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("operation", "body", m.Operation); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.Required("operation", "body", m.Operation); err != nil {
|
|
return err
|
|
}
|
|
|
|
if m.Operation != nil {
|
|
if err := m.Operation.Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("operation")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("operation")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Record) validateTargets(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("targets", "body", m.Targets); err != nil {
|
|
return err
|
|
}
|
|
|
|
for i := 0; i < len(m.Targets); i++ {
|
|
if swag.IsZero(m.Targets[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Targets[i] != nil {
|
|
if err := m.Targets[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("targets" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("targets" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ContextValidate validate this record based on the context it is used
|
|
func (m *Record) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.contextValidateAction(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateFilters(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateOperation(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateTargets(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Record) contextValidateAction(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if m.Action != nil {
|
|
if err := m.Action.ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("action")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("action")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Record) contextValidateFilters(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
for i := 0; i < len(m.Filters); i++ {
|
|
|
|
if m.Filters[i] != nil {
|
|
if err := m.Filters[i].ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("filters" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("filters" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Record) contextValidateOperation(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if m.Operation != nil {
|
|
if err := m.Operation.ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("operation")
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("operation")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Record) contextValidateTargets(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
for i := 0; i < len(m.Targets); i++ {
|
|
|
|
if m.Targets[i] != nil {
|
|
if err := m.Targets[i].ContextValidate(ctx, formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("targets" + "." + strconv.Itoa(i))
|
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
|
return ce.ValidateName("targets" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *Record) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *Record) UnmarshalBinary(b []byte) error {
|
|
var res Record
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|