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

116 lines
2.5 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"
)
// NodeInfoUsage NodeInfoUsage contains usage statistics for this server
//
// swagger:model NodeInfoUsage
type NodeInfoUsage struct {
// local comments
LocalComments int64 `json:"localComments,omitempty"`
// local posts
LocalPosts int64 `json:"localPosts,omitempty"`
// users
Users *NodeInfoUsageUsers `json:"users,omitempty"`
}
// Validate validates this node info usage
func (m *NodeInfoUsage) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateUsers(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *NodeInfoUsage) validateUsers(formats strfmt.Registry) error {
if swag.IsZero(m.Users) { // not required
return nil
}
if m.Users != nil {
if err := m.Users.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("users")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("users")
}
return err
}
}
return nil
}
// ContextValidate validate this node info usage based on the context it is used
func (m *NodeInfoUsage) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateUsers(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *NodeInfoUsage) contextValidateUsers(ctx context.Context, formats strfmt.Registry) error {
if m.Users != nil {
if swag.IsZero(m.Users) { // not required
return nil
}
if err := m.Users.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("users")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("users")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *NodeInfoUsage) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *NodeInfoUsage) UnmarshalBinary(b []byte) error {
var res NodeInfoUsage
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}