224 lines
4.9 KiB
Go
224 lines
4.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"
|
||
|
)
|
||
|
|
||
|
// NodeInfo NodeInfo contains standardized way of exposing metadata about a server running one of the distributed social networks
|
||
|
//
|
||
|
// swagger:model NodeInfo
|
||
|
type NodeInfo struct {
|
||
|
|
||
|
// metadata
|
||
|
Metadata interface{} `json:"metadata,omitempty"`
|
||
|
|
||
|
// open registrations
|
||
|
OpenRegistrations bool `json:"openRegistrations,omitempty"`
|
||
|
|
||
|
// protocols
|
||
|
Protocols []string `json:"protocols"`
|
||
|
|
||
|
// version
|
||
|
Version string `json:"version,omitempty"`
|
||
|
|
||
|
// services
|
||
|
Services *NodeInfoServices `json:"services,omitempty"`
|
||
|
|
||
|
// software
|
||
|
Software *NodeInfoSoftware `json:"software,omitempty"`
|
||
|
|
||
|
// usage
|
||
|
Usage *NodeInfoUsage `json:"usage,omitempty"`
|
||
|
}
|
||
|
|
||
|
// Validate validates this node info
|
||
|
func (m *NodeInfo) Validate(formats strfmt.Registry) error {
|
||
|
var res []error
|
||
|
|
||
|
if err := m.validateServices(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.validateSoftware(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.validateUsage(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if len(res) > 0 {
|
||
|
return errors.CompositeValidationError(res...)
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *NodeInfo) validateServices(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.Services) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if m.Services != nil {
|
||
|
if err := m.Services.Validate(formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("services")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("services")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *NodeInfo) validateSoftware(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.Software) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if m.Software != nil {
|
||
|
if err := m.Software.Validate(formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("software")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("software")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *NodeInfo) validateUsage(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.Usage) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if m.Usage != nil {
|
||
|
if err := m.Usage.Validate(formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("usage")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("usage")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// ContextValidate validate this node info based on the context it is used
|
||
|
func (m *NodeInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||
|
var res []error
|
||
|
|
||
|
if err := m.contextValidateServices(ctx, formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.contextValidateSoftware(ctx, formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.contextValidateUsage(ctx, formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if len(res) > 0 {
|
||
|
return errors.CompositeValidationError(res...)
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *NodeInfo) contextValidateServices(ctx context.Context, formats strfmt.Registry) error {
|
||
|
|
||
|
if m.Services != nil {
|
||
|
|
||
|
if swag.IsZero(m.Services) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := m.Services.ContextValidate(ctx, formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("services")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("services")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *NodeInfo) contextValidateSoftware(ctx context.Context, formats strfmt.Registry) error {
|
||
|
|
||
|
if m.Software != nil {
|
||
|
|
||
|
if swag.IsZero(m.Software) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := m.Software.ContextValidate(ctx, formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("software")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("software")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *NodeInfo) contextValidateUsage(ctx context.Context, formats strfmt.Registry) error {
|
||
|
|
||
|
if m.Usage != nil {
|
||
|
|
||
|
if swag.IsZero(m.Usage) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := m.Usage.ContextValidate(ctx, formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("usage")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("usage")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// MarshalBinary interface implementation
|
||
|
func (m *NodeInfo) MarshalBinary() ([]byte, error) {
|
||
|
if m == nil {
|
||
|
return nil, nil
|
||
|
}
|
||
|
return swag.WriteJSON(m)
|
||
|
}
|
||
|
|
||
|
// UnmarshalBinary interface implementation
|
||
|
func (m *NodeInfo) UnmarshalBinary(b []byte) error {
|
||
|
var res NodeInfo
|
||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
*m = res
|
||
|
return nil
|
||
|
}
|