autogits/bots-common/gitea-generated/models/create_file_options.go
Adam Majer 598ecbbd5a .
2024-07-07 21:12:40 +02:00

243 lines
5.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"
)
// CreateFileOptions CreateFileOptions options for creating files
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
//
// swagger:model CreateFileOptions
type CreateFileOptions struct {
// branch (optional) to base this file from. if not given, the default branch is used
BranchName string `json:"branch,omitempty"`
// content must be base64 encoded
// Required: true
ContentBase64 *string `json:"content"`
// message (optional) for the commit of this file. if not supplied, a default message will be used
Message string `json:"message,omitempty"`
// new_branch (optional) will make a new branch from `branch` before creating the file
NewBranchName string `json:"new_branch,omitempty"`
// Add a Signed-off-by trailer by the committer at the end of the commit log message.
Signoff bool `json:"signoff,omitempty"`
// author
Author *Identity `json:"author,omitempty"`
// committer
Committer *Identity `json:"committer,omitempty"`
// dates
Dates *CommitDateOptions `json:"dates,omitempty"`
}
// Validate validates this create file options
func (m *CreateFileOptions) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateContentBase64(formats); err != nil {
res = append(res, err)
}
if err := m.validateAuthor(formats); err != nil {
res = append(res, err)
}
if err := m.validateCommitter(formats); err != nil {
res = append(res, err)
}
if err := m.validateDates(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *CreateFileOptions) validateContentBase64(formats strfmt.Registry) error {
if err := validate.Required("content", "body", m.ContentBase64); err != nil {
return err
}
return nil
}
func (m *CreateFileOptions) validateAuthor(formats strfmt.Registry) error {
if swag.IsZero(m.Author) { // not required
return nil
}
if m.Author != nil {
if err := m.Author.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("author")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("author")
}
return err
}
}
return nil
}
func (m *CreateFileOptions) validateCommitter(formats strfmt.Registry) error {
if swag.IsZero(m.Committer) { // not required
return nil
}
if m.Committer != nil {
if err := m.Committer.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("committer")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("committer")
}
return err
}
}
return nil
}
func (m *CreateFileOptions) validateDates(formats strfmt.Registry) error {
if swag.IsZero(m.Dates) { // not required
return nil
}
if m.Dates != nil {
if err := m.Dates.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("dates")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("dates")
}
return err
}
}
return nil
}
// ContextValidate validate this create file options based on the context it is used
func (m *CreateFileOptions) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateAuthor(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateCommitter(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateDates(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *CreateFileOptions) contextValidateAuthor(ctx context.Context, formats strfmt.Registry) error {
if m.Author != nil {
if swag.IsZero(m.Author) { // not required
return nil
}
if err := m.Author.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("author")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("author")
}
return err
}
}
return nil
}
func (m *CreateFileOptions) contextValidateCommitter(ctx context.Context, formats strfmt.Registry) error {
if m.Committer != nil {
if swag.IsZero(m.Committer) { // not required
return nil
}
if err := m.Committer.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("committer")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("committer")
}
return err
}
}
return nil
}
func (m *CreateFileOptions) contextValidateDates(ctx context.Context, formats strfmt.Registry) error {
if m.Dates != nil {
if swag.IsZero(m.Dates) { // not required
return nil
}
if err := m.Dates.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("dates")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("dates")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *CreateFileOptions) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *CreateFileOptions) UnmarshalBinary(b []byte) error {
var res CreateFileOptions
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}