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

248 lines
5.3 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"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// Package Package represents a package
//
// swagger:model Package
type Package struct {
// created at
// Format: date-time
CreatedAt strfmt.DateTime `json:"created_at,omitempty"`
// HTML URL
HTMLURL string `json:"html_url,omitempty"`
// ID
ID int64 `json:"id,omitempty"`
// name
Name string `json:"name,omitempty"`
// type
Type string `json:"type,omitempty"`
// version
Version string `json:"version,omitempty"`
// creator
Creator *User `json:"creator,omitempty"`
// owner
Owner *User `json:"owner,omitempty"`
// repository
Repository *Repository `json:"repository,omitempty"`
}
// Validate validates this package
func (m *Package) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCreatedAt(formats); err != nil {
res = append(res, err)
}
if err := m.validateCreator(formats); err != nil {
res = append(res, err)
}
if err := m.validateOwner(formats); err != nil {
res = append(res, err)
}
if err := m.validateRepository(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Package) validateCreatedAt(formats strfmt.Registry) error {
if swag.IsZero(m.CreatedAt) { // not required
return nil
}
if err := validate.FormatOf("created_at", "body", "date-time", m.CreatedAt.String(), formats); err != nil {
return err
}
return nil
}
func (m *Package) validateCreator(formats strfmt.Registry) error {
if swag.IsZero(m.Creator) { // not required
return nil
}
if m.Creator != nil {
if err := m.Creator.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("creator")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("creator")
}
return err
}
}
return nil
}
func (m *Package) validateOwner(formats strfmt.Registry) error {
if swag.IsZero(m.Owner) { // not required
return nil
}
if m.Owner != nil {
if err := m.Owner.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("owner")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("owner")
}
return err
}
}
return nil
}
func (m *Package) validateRepository(formats strfmt.Registry) error {
if swag.IsZero(m.Repository) { // not required
return nil
}
if m.Repository != nil {
if err := m.Repository.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("repository")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("repository")
}
return err
}
}
return nil
}
// ContextValidate validate this package based on the context it is used
func (m *Package) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateCreator(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateOwner(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateRepository(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Package) contextValidateCreator(ctx context.Context, formats strfmt.Registry) error {
if m.Creator != nil {
if swag.IsZero(m.Creator) { // not required
return nil
}
if err := m.Creator.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("creator")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("creator")
}
return err
}
}
return nil
}
func (m *Package) contextValidateOwner(ctx context.Context, formats strfmt.Registry) error {
if m.Owner != nil {
if swag.IsZero(m.Owner) { // not required
return nil
}
if err := m.Owner.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("owner")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("owner")
}
return err
}
}
return nil
}
func (m *Package) contextValidateRepository(ctx context.Context, formats strfmt.Registry) error {
if m.Repository != nil {
if swag.IsZero(m.Repository) { // not required
return nil
}
if err := m.Repository.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("repository")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("repository")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *Package) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Package) UnmarshalBinary(b []byte) error {
var res Package
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}