// 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"
)

// DataResponse DataResponse contains the results from a DataQuery.
//
// A map of RefIDs (unique query identifiers) to this type makes up the Responses property of a QueryDataResponse.
// The Error property is used to allow for partial success responses from the containing QueryDataResponse.
//
// swagger:model DataResponse
type DataResponse struct {

	// Error is a property to be set if the corresponding DataQuery has an error.
	Error string `json:"Error,omitempty"`

	// error source
	ErrorSource Source `json:"ErrorSource,omitempty"`

	// frames
	Frames Frames `json:"Frames,omitempty"`

	// status
	Status Status `json:"Status,omitempty"`
}

// Validate validates this data response
func (m *DataResponse) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateErrorSource(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateFrames(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateStatus(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *DataResponse) validateErrorSource(formats strfmt.Registry) error {
	if swag.IsZero(m.ErrorSource) { // not required
		return nil
	}

	if err := m.ErrorSource.Validate(formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("ErrorSource")
		} else if ce, ok := err.(*errors.CompositeError); ok {
			return ce.ValidateName("ErrorSource")
		}
		return err
	}

	return nil
}

func (m *DataResponse) validateFrames(formats strfmt.Registry) error {
	if swag.IsZero(m.Frames) { // not required
		return nil
	}

	if err := m.Frames.Validate(formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("Frames")
		} else if ce, ok := err.(*errors.CompositeError); ok {
			return ce.ValidateName("Frames")
		}
		return err
	}

	return nil
}

func (m *DataResponse) validateStatus(formats strfmt.Registry) error {
	if swag.IsZero(m.Status) { // not required
		return nil
	}

	if err := m.Status.Validate(formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("Status")
		} else if ce, ok := err.(*errors.CompositeError); ok {
			return ce.ValidateName("Status")
		}
		return err
	}

	return nil
}

// ContextValidate validate this data response based on the context it is used
func (m *DataResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateErrorSource(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateFrames(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateStatus(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *DataResponse) contextValidateErrorSource(ctx context.Context, formats strfmt.Registry) error {

	if swag.IsZero(m.ErrorSource) { // not required
		return nil
	}

	if err := m.ErrorSource.ContextValidate(ctx, formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("ErrorSource")
		} else if ce, ok := err.(*errors.CompositeError); ok {
			return ce.ValidateName("ErrorSource")
		}
		return err
	}

	return nil
}

func (m *DataResponse) contextValidateFrames(ctx context.Context, formats strfmt.Registry) error {

	if err := m.Frames.ContextValidate(ctx, formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("Frames")
		} else if ce, ok := err.(*errors.CompositeError); ok {
			return ce.ValidateName("Frames")
		}
		return err
	}

	return nil
}

func (m *DataResponse) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {

	if swag.IsZero(m.Status) { // not required
		return nil
	}

	if err := m.Status.ContextValidate(ctx, formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("Status")
		} else if ce, ok := err.(*errors.CompositeError); ok {
			return ce.ValidateName("Status")
		}
		return err
	}

	return nil
}

// MarshalBinary interface implementation
func (m *DataResponse) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *DataResponse) UnmarshalBinary(b []byte) error {
	var res DataResponse
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
