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

260 lines
5.4 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"
)
// Activity activity
//
// swagger:model Activity
type Activity struct {
// act user ID
ActUserID int64 `json:"act_user_id,omitempty"`
// comment ID
CommentID int64 `json:"comment_id,omitempty"`
// content
Content string `json:"content,omitempty"`
// created
// Format: date-time
Created strfmt.DateTime `json:"created,omitempty"`
// ID
ID int64 `json:"id,omitempty"`
// is private
IsPrivate bool `json:"is_private,omitempty"`
// op type
OpType string `json:"op_type,omitempty"`
// ref name
RefName string `json:"ref_name,omitempty"`
// repo ID
RepoID int64 `json:"repo_id,omitempty"`
// user ID
UserID int64 `json:"user_id,omitempty"`
// act user
ActUser *User `json:"act_user,omitempty"`
// comment
Comment *Comment `json:"comment,omitempty"`
// repo
Repo *Repository `json:"repo,omitempty"`
}
// Validate validates this activity
func (m *Activity) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCreated(formats); err != nil {
res = append(res, err)
}
if err := m.validateActUser(formats); err != nil {
res = append(res, err)
}
if err := m.validateComment(formats); err != nil {
res = append(res, err)
}
if err := m.validateRepo(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Activity) validateCreated(formats strfmt.Registry) error {
if swag.IsZero(m.Created) { // not required
return nil
}
if err := validate.FormatOf("created", "body", "date-time", m.Created.String(), formats); err != nil {
return err
}
return nil
}
func (m *Activity) validateActUser(formats strfmt.Registry) error {
if swag.IsZero(m.ActUser) { // not required
return nil
}
if m.ActUser != nil {
if err := m.ActUser.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("act_user")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("act_user")
}
return err
}
}
return nil
}
func (m *Activity) validateComment(formats strfmt.Registry) error {
if swag.IsZero(m.Comment) { // not required
return nil
}
if m.Comment != nil {
if err := m.Comment.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("comment")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("comment")
}
return err
}
}
return nil
}
func (m *Activity) validateRepo(formats strfmt.Registry) error {
if swag.IsZero(m.Repo) { // not required
return nil
}
if m.Repo != nil {
if err := m.Repo.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("repo")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("repo")
}
return err
}
}
return nil
}
// ContextValidate validate this activity based on the context it is used
func (m *Activity) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateActUser(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateComment(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateRepo(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Activity) contextValidateActUser(ctx context.Context, formats strfmt.Registry) error {
if m.ActUser != nil {
if swag.IsZero(m.ActUser) { // not required
return nil
}
if err := m.ActUser.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("act_user")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("act_user")
}
return err
}
}
return nil
}
func (m *Activity) contextValidateComment(ctx context.Context, formats strfmt.Registry) error {
if m.Comment != nil {
if swag.IsZero(m.Comment) { // not required
return nil
}
if err := m.Comment.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("comment")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("comment")
}
return err
}
}
return nil
}
func (m *Activity) contextValidateRepo(ctx context.Context, formats strfmt.Registry) error {
if m.Repo != nil {
if swag.IsZero(m.Repo) { // not required
return nil
}
if err := m.Repo.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("repo")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("repo")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *Activity) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Activity) UnmarshalBinary(b []byte) error {
var res Activity
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}