This repository has been archived on 2024-09-11. You can view files and clone it, but cannot push or open issues or pull requests.
frostfs-rest-gw/gen/models/target.go
Denis Kirillov 47e061a440 [#54] Support keys in eacl
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2022-08-30 10:00:41 +03:00

129 lines
2.8 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"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// Target Target to apply the ACL rule. Can be a subject's role class or a list of public keys to match (KEYS role).
// Example: {"keys":["021dc56fc6d81d581ae7605a8e00e0e0bab6cbad566a924a527339475a97a8e38e"],"role":"KEYS"}
//
// swagger:model Target
type Target struct {
// keys
// Required: true
Keys []string `json:"keys"`
// role
// Required: true
Role *Role `json:"role"`
}
// Validate validates this target
func (m *Target) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateKeys(formats); err != nil {
res = append(res, err)
}
if err := m.validateRole(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Target) validateKeys(formats strfmt.Registry) error {
if err := validate.Required("keys", "body", m.Keys); err != nil {
return err
}
return nil
}
func (m *Target) validateRole(formats strfmt.Registry) error {
if err := validate.Required("role", "body", m.Role); err != nil {
return err
}
if err := validate.Required("role", "body", m.Role); err != nil {
return err
}
if m.Role != nil {
if err := m.Role.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("role")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("role")
}
return err
}
}
return nil
}
// ContextValidate validate this target based on the context it is used
func (m *Target) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateRole(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Target) contextValidateRole(ctx context.Context, formats strfmt.Registry) error {
if m.Role != nil {
if err := m.Role.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("role")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("role")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *Target) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Target) UnmarshalBinary(b []byte) error {
var res Target
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}