autogits/bots-common/gitea-generated/models/repo_transfer.go

224 lines
4.8 KiB
Go
Raw Normal View History

2024-07-07 21:08:41 +02:00
// 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"
)
// RepoTransfer RepoTransfer represents a pending repo transfer
//
// swagger:model RepoTransfer
type RepoTransfer struct {
// teams
Teams []*Team `json:"teams"`
// doer
Doer *User `json:"doer,omitempty"`
// recipient
Recipient *User `json:"recipient,omitempty"`
}
// Validate validates this repo transfer
func (m *RepoTransfer) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateTeams(formats); err != nil {
res = append(res, err)
}
if err := m.validateDoer(formats); err != nil {
res = append(res, err)
}
if err := m.validateRecipient(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *RepoTransfer) validateTeams(formats strfmt.Registry) error {
if swag.IsZero(m.Teams) { // not required
return nil
}
for i := 0; i < len(m.Teams); i++ {
if swag.IsZero(m.Teams[i]) { // not required
continue
}
if m.Teams[i] != nil {
if err := m.Teams[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("teams" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("teams" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *RepoTransfer) validateDoer(formats strfmt.Registry) error {
if swag.IsZero(m.Doer) { // not required
return nil
}
if m.Doer != nil {
if err := m.Doer.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("doer")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("doer")
}
return err
}
}
return nil
}
func (m *RepoTransfer) validateRecipient(formats strfmt.Registry) error {
if swag.IsZero(m.Recipient) { // not required
return nil
}
if m.Recipient != nil {
if err := m.Recipient.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("recipient")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("recipient")
}
return err
}
}
return nil
}
// ContextValidate validate this repo transfer based on the context it is used
func (m *RepoTransfer) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateTeams(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateDoer(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateRecipient(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *RepoTransfer) contextValidateTeams(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Teams); i++ {
if m.Teams[i] != nil {
if swag.IsZero(m.Teams[i]) { // not required
return nil
}
if err := m.Teams[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("teams" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("teams" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *RepoTransfer) contextValidateDoer(ctx context.Context, formats strfmt.Registry) error {
if m.Doer != nil {
if swag.IsZero(m.Doer) { // not required
return nil
}
if err := m.Doer.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("doer")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("doer")
}
return err
}
}
return nil
}
func (m *RepoTransfer) contextValidateRecipient(ctx context.Context, formats strfmt.Registry) error {
if m.Recipient != nil {
if swag.IsZero(m.Recipient) { // not required
return nil
}
if err := m.Recipient.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("recipient")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("recipient")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *RepoTransfer) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *RepoTransfer) UnmarshalBinary(b []byte) error {
var res RepoTransfer
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}