chronograf/models/source.go

127 lines
2.3 KiB
Go

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 (
"encoding/json"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
/*Source source
swagger:model Source
*/
type Source struct {
/* Unique identifier representing a specific data source.
Read Only: true
*/
ID string `json:"id,omitempty"`
/* link
*/
Link *Link `json:"link,omitempty"`
/* User facing name of data source
Required: true
*/
Name *string `json:"name"`
/* Format of the data source
Required: true
*/
Type *string `json:"type"`
}
// Validate validates this source
func (m *Source) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateLink(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateName(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateType(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Source) validateLink(formats strfmt.Registry) error {
if swag.IsZero(m.Link) { // not required
return nil
}
if m.Link != nil {
if err := m.Link.Validate(formats); err != nil {
return err
}
}
return nil
}
func (m *Source) validateName(formats strfmt.Registry) error {
if err := validate.Required("name", "body", m.Name); err != nil {
return err
}
return nil
}
var sourceTypeTypePropEnum []interface{}
// prop value enum
func (m *Source) validateTypeEnum(path, location string, value string) error {
if sourceTypeTypePropEnum == nil {
var res []string
if err := json.Unmarshal([]byte(`["influx","influx-enterprise"]`), &res); err != nil {
return err
}
for _, v := range res {
sourceTypeTypePropEnum = append(sourceTypeTypePropEnum, v)
}
}
if err := validate.Enum(path, location, value, sourceTypeTypePropEnum); err != nil {
return err
}
return nil
}
func (m *Source) validateType(formats strfmt.Registry) error {
if err := validate.Required("type", "body", m.Type); err != nil {
return err
}
// value enum
if err := m.validateTypeEnum("type", "body", *m.Type); err != nil {
return err
}
return nil
}