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/bearer.go
Denis Kirillov b412af2e22 [#24] Update examples and description in spec
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2022-07-22 12:19:33 +03:00

166 lines
3.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"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// Bearer Bearer token that is expected to be formed.
// Example: [{"name":"my-bearer-token","object":[{"action":"ALLOW","filters":[],"operation":"GET","targets":[{"keys":[],"role":"OTHERS"}]}]},{"container":{"verb":"PUT"},"name":"my token to create container"}]
//
// swagger:model Bearer
type Bearer struct {
// container
Container *Rule `json:"container,omitempty"`
// name
Name string `json:"name,omitempty"`
// object
Object []*Record `json:"object"`
}
// Validate validates this bearer
func (m *Bearer) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateContainer(formats); err != nil {
res = append(res, err)
}
if err := m.validateObject(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Bearer) validateContainer(formats strfmt.Registry) error {
if swag.IsZero(m.Container) { // not required
return nil
}
if m.Container != nil {
if err := m.Container.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("container")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("container")
}
return err
}
}
return nil
}
func (m *Bearer) validateObject(formats strfmt.Registry) error {
if swag.IsZero(m.Object) { // not required
return nil
}
for i := 0; i < len(m.Object); i++ {
if swag.IsZero(m.Object[i]) { // not required
continue
}
if m.Object[i] != nil {
if err := m.Object[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("object" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("object" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this bearer based on the context it is used
func (m *Bearer) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateContainer(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateObject(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Bearer) contextValidateContainer(ctx context.Context, formats strfmt.Registry) error {
if m.Container != nil {
if err := m.Container.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("container")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("container")
}
return err
}
}
return nil
}
func (m *Bearer) contextValidateObject(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Object); i++ {
if m.Object[i] != nil {
if err := m.Object[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("object" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("object" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *Bearer) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Bearer) UnmarshalBinary(b []byte) error {
var res Bearer
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}