// Code generated by go-swagger; DO NOT EDIT.

package model

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

// DataflowS3Info dataflow s3 info
//
// swagger:model dataflowS3Info
type DataflowS3Info struct {

	// data format
	DataFormat *DataflowS3Dataformat `json:"data_format,omitempty"`

	// endpoint
	Endpoint *DataflowS3Endpoint `json:"endpoint,omitempty"`

	// start position
	StartPosition *DataflowStartPosition `json:"start_position,omitempty"`

	// storage flush config
	StorageFlushConfig *DataflowStorageFlushConfig `json:"storage_flush_config,omitempty"`

	// table config
	TableConfig *DataflowTableConfig `json:"table_config,omitempty"`
}

// Validate validates this dataflow s3 info
func (m *DataflowS3Info) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

func (m *DataflowS3Info) validateDataFormat(formats strfmt.Registry) error {
	if swag.IsZero(m.DataFormat) { // not required
		return nil
	}

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

	return nil
}

func (m *DataflowS3Info) validateEndpoint(formats strfmt.Registry) error {
	if swag.IsZero(m.Endpoint) { // not required
		return nil
	}

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

	return nil
}

func (m *DataflowS3Info) validateStartPosition(formats strfmt.Registry) error {
	if swag.IsZero(m.StartPosition) { // not required
		return nil
	}

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

	return nil
}

func (m *DataflowS3Info) validateStorageFlushConfig(formats strfmt.Registry) error {
	if swag.IsZero(m.StorageFlushConfig) { // not required
		return nil
	}

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

	return nil
}

func (m *DataflowS3Info) validateTableConfig(formats strfmt.Registry) error {
	if swag.IsZero(m.TableConfig) { // not required
		return nil
	}

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

	return nil
}

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

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

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

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

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

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

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

func (m *DataflowS3Info) contextValidateDataFormat(ctx context.Context, formats strfmt.Registry) error {

	if m.DataFormat != nil {

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

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

	return nil
}

func (m *DataflowS3Info) contextValidateEndpoint(ctx context.Context, formats strfmt.Registry) error {

	if m.Endpoint != nil {

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

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

	return nil
}

func (m *DataflowS3Info) contextValidateStartPosition(ctx context.Context, formats strfmt.Registry) error {

	if m.StartPosition != nil {

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

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

	return nil
}

func (m *DataflowS3Info) contextValidateStorageFlushConfig(ctx context.Context, formats strfmt.Registry) error {

	if m.StorageFlushConfig != nil {

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

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

	return nil
}

func (m *DataflowS3Info) contextValidateTableConfig(ctx context.Context, formats strfmt.Registry) error {

	if m.TableConfig != nil {

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

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

	return nil
}

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

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