// 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"
	"github.com/go-openapi/validate"
)

// DataflowDumplingConfig dataflow dumpling config
//
// swagger:model dataflowDumplingConfig
type DataflowDumplingConfig struct {

	// Valid values includes:
	//  flush: Use FTWRL before dumping
	//  snapshot: Specify dumping TiDB data at a specific snapshot time using TSO
	//  lock: Execute 'lock tables read' command on all tables that need to be dumped
	//  none: Dump without locking, data consistency cannot be guaranteed
	//  auto(default value): Same as snapshot
	Consistency string `json:"consistency,omitempty"`

	// csv delimiter
	CsvDelimiter string `json:"csv_delimiter,omitempty"`

	// csv null value
	CsvNullValue string `json:"csv_null_value,omitempty"`

	// csv output dialect
	CsvOutputDialect string `json:"csv_output_dialect,omitempty"`

	// csv separator
	CsvSeparator string `json:"csv_separator,omitempty"`

	// The file size resulting from the partitioning of table data
	// must specify the unit (such as 128B, 64KiB, 32MiB, 1.5GiB)
	FileSize string `json:"file_size,omitempty"`

	// rows
	Rows string `json:"rows,omitempty"`

	// Only useful when consistency is 'snapshot'
	SnapshotTso string `json:"snapshot_tso,omitempty"`

	// source filters
	SourceFilters string `json:"source_filters,omitempty"`

	// source password
	// Required: true
	SourcePassword *string `json:"source_password"`

	// source username
	// Required: true
	SourceUsername *string `json:"source_username"`

	// thread num
	ThreadNum int64 `json:"thread_num,omitempty"`
}

// Validate validates this dataflow dumpling config
func (m *DataflowDumplingConfig) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *DataflowDumplingConfig) validateSourcePassword(formats strfmt.Registry) error {

	if err := validate.Required("source_password", "body", m.SourcePassword); err != nil {
		return err
	}

	return nil
}

func (m *DataflowDumplingConfig) validateSourceUsername(formats strfmt.Registry) error {

	if err := validate.Required("source_username", "body", m.SourceUsername); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this dataflow dumpling config based on context it is used
func (m *DataflowDumplingConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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