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

194 lines
4.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"
)
// NotificationThread NotificationThread expose Notification on API
//
// swagger:model NotificationThread
type NotificationThread struct {
// ID
ID int64 `json:"id,omitempty"`
// pinned
Pinned bool `json:"pinned,omitempty"`
// URL
URL string `json:"url,omitempty"`
// unread
Unread bool `json:"unread,omitempty"`
// updated at
// Format: date-time
UpdatedAt strfmt.DateTime `json:"updated_at,omitempty"`
// repository
Repository *Repository `json:"repository,omitempty"`
// subject
Subject *NotificationSubject `json:"subject,omitempty"`
}
// Validate validates this notification thread
func (m *NotificationThread) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateUpdatedAt(formats); err != nil {
res = append(res, err)
}
if err := m.validateRepository(formats); err != nil {
res = append(res, err)
}
if err := m.validateSubject(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *NotificationThread) validateUpdatedAt(formats strfmt.Registry) error {
if swag.IsZero(m.UpdatedAt) { // not required
return nil
}
if err := validate.FormatOf("updated_at", "body", "date-time", m.UpdatedAt.String(), formats); err != nil {
return err
}
return nil
}
func (m *NotificationThread) 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
}
func (m *NotificationThread) validateSubject(formats strfmt.Registry) error {
if swag.IsZero(m.Subject) { // not required
return nil
}
if m.Subject != nil {
if err := m.Subject.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("subject")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("subject")
}
return err
}
}
return nil
}
// ContextValidate validate this notification thread based on the context it is used
func (m *NotificationThread) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateRepository(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateSubject(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *NotificationThread) 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
}
func (m *NotificationThread) contextValidateSubject(ctx context.Context, formats strfmt.Registry) error {
if m.Subject != nil {
if swag.IsZero(m.Subject) { // not required
return nil
}
if err := m.Subject.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("subject")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("subject")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *NotificationThread) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *NotificationThread) UnmarshalBinary(b []byte) error {
var res NotificationThread
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}