| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
|
|
| package models |
|
|
| |
| |
|
|
| import ( |
| "context" |
| "strconv" |
|
|
| "github.com/go-openapi/errors" |
| "github.com/go-openapi/strfmt" |
| "github.com/go-openapi/swag" |
| "github.com/go-openapi/validate" |
| ) |
|
|
| |
| |
| |
| type Class struct { |
|
|
| |
| Class string `json:"class,omitempty"` |
|
|
| |
| Description string `json:"description,omitempty"` |
|
|
| |
| InvertedIndexConfig *InvertedIndexConfig `json:"invertedIndexConfig,omitempty"` |
|
|
| |
| ModuleConfig interface{} `json:"moduleConfig,omitempty"` |
|
|
| |
| MultiTenancyConfig *MultiTenancyConfig `json:"multiTenancyConfig,omitempty"` |
|
|
| |
| Properties []*Property `json:"properties"` |
|
|
| |
| ReplicationConfig *ReplicationConfig `json:"replicationConfig,omitempty"` |
|
|
| |
| ShardingConfig interface{} `json:"shardingConfig,omitempty"` |
|
|
| |
| VectorConfig map[string]VectorConfig `json:"vectorConfig,omitempty"` |
|
|
| |
| VectorIndexConfig interface{} `json:"vectorIndexConfig,omitempty"` |
|
|
| |
| VectorIndexType string `json:"vectorIndexType,omitempty"` |
|
|
| |
| Vectorizer string `json:"vectorizer,omitempty"` |
| } |
|
|
| |
| func (m *Class) Validate(formats strfmt.Registry) error { |
| var res []error |
|
|
| if err := m.validateInvertedIndexConfig(formats); err != nil { |
| res = append(res, err) |
| } |
|
|
| if err := m.validateMultiTenancyConfig(formats); err != nil { |
| res = append(res, err) |
| } |
|
|
| if err := m.validateProperties(formats); err != nil { |
| res = append(res, err) |
| } |
|
|
| if err := m.validateReplicationConfig(formats); err != nil { |
| res = append(res, err) |
| } |
|
|
| if err := m.validateVectorConfig(formats); err != nil { |
| res = append(res, err) |
| } |
|
|
| if len(res) > 0 { |
| return errors.CompositeValidationError(res...) |
| } |
| return nil |
| } |
|
|
| func (m *Class) validateInvertedIndexConfig(formats strfmt.Registry) error { |
| if swag.IsZero(m.InvertedIndexConfig) { |
| return nil |
| } |
|
|
| if m.InvertedIndexConfig != nil { |
| if err := m.InvertedIndexConfig.Validate(formats); err != nil { |
| if ve, ok := err.(*errors.Validation); ok { |
| return ve.ValidateName("invertedIndexConfig") |
| } else if ce, ok := err.(*errors.CompositeError); ok { |
| return ce.ValidateName("invertedIndexConfig") |
| } |
| return err |
| } |
| } |
|
|
| return nil |
| } |
|
|
| func (m *Class) validateMultiTenancyConfig(formats strfmt.Registry) error { |
| if swag.IsZero(m.MultiTenancyConfig) { |
| return nil |
| } |
|
|
| if m.MultiTenancyConfig != nil { |
| if err := m.MultiTenancyConfig.Validate(formats); err != nil { |
| if ve, ok := err.(*errors.Validation); ok { |
| return ve.ValidateName("multiTenancyConfig") |
| } else if ce, ok := err.(*errors.CompositeError); ok { |
| return ce.ValidateName("multiTenancyConfig") |
| } |
| return err |
| } |
| } |
|
|
| return nil |
| } |
|
|
| func (m *Class) validateProperties(formats strfmt.Registry) error { |
| if swag.IsZero(m.Properties) { |
| return nil |
| } |
|
|
| for i := 0; i < len(m.Properties); i++ { |
| if swag.IsZero(m.Properties[i]) { |
| continue |
| } |
|
|
| if m.Properties[i] != nil { |
| if err := m.Properties[i].Validate(formats); err != nil { |
| if ve, ok := err.(*errors.Validation); ok { |
| return ve.ValidateName("properties" + "." + strconv.Itoa(i)) |
| } else if ce, ok := err.(*errors.CompositeError); ok { |
| return ce.ValidateName("properties" + "." + strconv.Itoa(i)) |
| } |
| return err |
| } |
| } |
|
|
| } |
|
|
| return nil |
| } |
|
|
| func (m *Class) validateReplicationConfig(formats strfmt.Registry) error { |
| if swag.IsZero(m.ReplicationConfig) { |
| return nil |
| } |
|
|
| if m.ReplicationConfig != nil { |
| if err := m.ReplicationConfig.Validate(formats); err != nil { |
| if ve, ok := err.(*errors.Validation); ok { |
| return ve.ValidateName("replicationConfig") |
| } else if ce, ok := err.(*errors.CompositeError); ok { |
| return ce.ValidateName("replicationConfig") |
| } |
| return err |
| } |
| } |
|
|
| return nil |
| } |
|
|
| func (m *Class) validateVectorConfig(formats strfmt.Registry) error { |
| if swag.IsZero(m.VectorConfig) { |
| return nil |
| } |
|
|
| for k := range m.VectorConfig { |
|
|
| if err := validate.Required("vectorConfig"+"."+k, "body", m.VectorConfig[k]); err != nil { |
| return err |
| } |
| if val, ok := m.VectorConfig[k]; ok { |
| if err := val.Validate(formats); err != nil { |
| if ve, ok := err.(*errors.Validation); ok { |
| return ve.ValidateName("vectorConfig" + "." + k) |
| } else if ce, ok := err.(*errors.CompositeError); ok { |
| return ce.ValidateName("vectorConfig" + "." + k) |
| } |
| return err |
| } |
| } |
|
|
| } |
|
|
| return nil |
| } |
|
|
| |
| func (m *Class) ContextValidate(ctx context.Context, formats strfmt.Registry) error { |
| var res []error |
|
|
| if err := m.contextValidateInvertedIndexConfig(ctx, formats); err != nil { |
| res = append(res, err) |
| } |
|
|
| if err := m.contextValidateMultiTenancyConfig(ctx, formats); err != nil { |
| res = append(res, err) |
| } |
|
|
| if err := m.contextValidateProperties(ctx, formats); err != nil { |
| res = append(res, err) |
| } |
|
|
| if err := m.contextValidateReplicationConfig(ctx, formats); err != nil { |
| res = append(res, err) |
| } |
|
|
| if err := m.contextValidateVectorConfig(ctx, formats); err != nil { |
| res = append(res, err) |
| } |
|
|
| if len(res) > 0 { |
| return errors.CompositeValidationError(res...) |
| } |
| return nil |
| } |
|
|
| func (m *Class) contextValidateInvertedIndexConfig(ctx context.Context, formats strfmt.Registry) error { |
|
|
| if m.InvertedIndexConfig != nil { |
| if err := m.InvertedIndexConfig.ContextValidate(ctx, formats); err != nil { |
| if ve, ok := err.(*errors.Validation); ok { |
| return ve.ValidateName("invertedIndexConfig") |
| } else if ce, ok := err.(*errors.CompositeError); ok { |
| return ce.ValidateName("invertedIndexConfig") |
| } |
| return err |
| } |
| } |
|
|
| return nil |
| } |
|
|
| func (m *Class) contextValidateMultiTenancyConfig(ctx context.Context, formats strfmt.Registry) error { |
|
|
| if m.MultiTenancyConfig != nil { |
| if err := m.MultiTenancyConfig.ContextValidate(ctx, formats); err != nil { |
| if ve, ok := err.(*errors.Validation); ok { |
| return ve.ValidateName("multiTenancyConfig") |
| } else if ce, ok := err.(*errors.CompositeError); ok { |
| return ce.ValidateName("multiTenancyConfig") |
| } |
| return err |
| } |
| } |
|
|
| return nil |
| } |
|
|
| func (m *Class) contextValidateProperties(ctx context.Context, formats strfmt.Registry) error { |
|
|
| for i := 0; i < len(m.Properties); i++ { |
|
|
| if m.Properties[i] != nil { |
| if err := m.Properties[i].ContextValidate(ctx, formats); err != nil { |
| if ve, ok := err.(*errors.Validation); ok { |
| return ve.ValidateName("properties" + "." + strconv.Itoa(i)) |
| } else if ce, ok := err.(*errors.CompositeError); ok { |
| return ce.ValidateName("properties" + "." + strconv.Itoa(i)) |
| } |
| return err |
| } |
| } |
|
|
| } |
|
|
| return nil |
| } |
|
|
| func (m *Class) contextValidateReplicationConfig(ctx context.Context, formats strfmt.Registry) error { |
|
|
| if m.ReplicationConfig != nil { |
| if err := m.ReplicationConfig.ContextValidate(ctx, formats); err != nil { |
| if ve, ok := err.(*errors.Validation); ok { |
| return ve.ValidateName("replicationConfig") |
| } else if ce, ok := err.(*errors.CompositeError); ok { |
| return ce.ValidateName("replicationConfig") |
| } |
| return err |
| } |
| } |
|
|
| return nil |
| } |
|
|
| func (m *Class) contextValidateVectorConfig(ctx context.Context, formats strfmt.Registry) error { |
|
|
| for k := range m.VectorConfig { |
|
|
| if val, ok := m.VectorConfig[k]; ok { |
| if err := val.ContextValidate(ctx, formats); err != nil { |
| return err |
| } |
| } |
|
|
| } |
|
|
| return nil |
| } |
|
|
| |
| func (m *Class) MarshalBinary() ([]byte, error) { |
| if m == nil { |
| return nil, nil |
| } |
| return swag.WriteJSON(m) |
| } |
|
|
| |
| func (m *Class) UnmarshalBinary(b []byte) error { |
| var res Class |
| if err := swag.ReadJSON(b, &res); err != nil { |
| return err |
| } |
| *m = res |
| return nil |
| } |
|
|