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

134 lines
2.9 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"
)
// Branch Branch represents a repository branch
//
// swagger:model Branch
type Branch struct {
// effective branch protection name
EffectiveBranchProtectionName string `json:"effective_branch_protection_name,omitempty"`
// enable status check
EnableStatusCheck bool `json:"enable_status_check,omitempty"`
// name
Name string `json:"name,omitempty"`
// protected
Protected bool `json:"protected,omitempty"`
// required approvals
RequiredApprovals int64 `json:"required_approvals,omitempty"`
// status check contexts
StatusCheckContexts []string `json:"status_check_contexts"`
// user can merge
UserCanMerge bool `json:"user_can_merge,omitempty"`
// user can push
UserCanPush bool `json:"user_can_push,omitempty"`
// commit
Commit *PayloadCommit `json:"commit,omitempty"`
}
// Validate validates this branch
func (m *Branch) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCommit(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Branch) validateCommit(formats strfmt.Registry) error {
if swag.IsZero(m.Commit) { // not required
return nil
}
if m.Commit != nil {
if err := m.Commit.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("commit")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("commit")
}
return err
}
}
return nil
}
// ContextValidate validate this branch based on the context it is used
func (m *Branch) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateCommit(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Branch) contextValidateCommit(ctx context.Context, formats strfmt.Registry) error {
if m.Commit != nil {
if swag.IsZero(m.Commit) { // not required
return nil
}
if err := m.Commit.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("commit")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("commit")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *Branch) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Branch) UnmarshalBinary(b []byte) error {
var res Branch
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}