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

// DataflowConnectorCreateReq dataflow connector create req
//
// swagger:model dataflowConnectorCreateReq
type DataflowConnectorCreateReq struct {

	// cluster id
	// Required: true
	ClusterID *string `json:"cluster_id"`

	// connector type
	// Required: true
	ConnectorType *DataflowConnectorType `json:"connector_type"`

	// ignore replication
	IgnoreReplication bool `json:"ignore_replication,omitempty"`

	// kafka info
	KafkaInfo *DataflowKafkaInfo `json:"kafka_info,omitempty"`

	// mysql info
	MysqlInfo *DataflowMySQLInfo `json:"mysql_info,omitempty"`

	// gcs info
	GCSInfo *DataflowGCSInfo `json:"gcs_info,omitempty"`

	// gcs info
	S3Info *DataflowS3Info `json:"s3_info,omitempty"`

	// serverless tidb info
	ServerlessTidbInfo *DataflowServerlessTidbInfo `json:"serverless_tidb_info,omitempty"`

	// rcu instance type
	ChangefeedInstanceType string `json:"changefeed_instance_type"`

	// org id
	// Required: true
	OrgID *string `json:"org_id"`

	// password
	Password string `json:"password,omitempty"`

	// project id
	// Required: true
	ProjectID *string `json:"project_id"`

	// start tso
	StartTso string `json:"start_tso,omitempty"`

	// topic
	Topic string `json:"topic,omitempty"`

	// url
	// Required: true
	URL *string `json:"url"`

	// user
	User string `json:"user,omitempty"`
}

type DataflowServerlessTidbInfo struct {
	ClusterId *string            `json:"cluster_id,omitempty"`
	MysqlInfo *DataflowMySQLInfo `json:"mysql_info,omitempty"`
}

// Validate validates this dataflow connector create req
func (m *DataflowConnectorCreateReq) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

func (m *DataflowConnectorCreateReq) validateClusterID(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowConnectorCreateReq) validateConnectorType(formats strfmt.Registry) error {

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

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

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

	return nil
}

func (m *DataflowConnectorCreateReq) validateKafkaInfo(formats strfmt.Registry) error {
	if swag.IsZero(m.KafkaInfo) { // not required
		return nil
	}

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

	return nil
}

func (m *DataflowConnectorCreateReq) validateMysqlInfo(formats strfmt.Registry) error {
	if swag.IsZero(m.MysqlInfo) { // not required
		return nil
	}

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

	return nil
}

func (m *DataflowConnectorCreateReq) validateOrgID(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowConnectorCreateReq) validateProjectID(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowConnectorCreateReq) validateURL(formats strfmt.Registry) error {

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

	return nil
}

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

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

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

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

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

func (m *DataflowConnectorCreateReq) contextValidateConnectorType(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowConnectorCreateReq) contextValidateKafkaInfo(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowConnectorCreateReq) contextValidateMysqlInfo(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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

type DataflowGCSInfo struct {
	EndPoint      *DataflowEndPoint          `json:"endpoint,omitempty"`
	DataFormat    *DataflowStorageDataFormat `json:"data_format,omitempty"`
	StartPosition *DataflowStartPosition     `json:"start_position,omitempty"`
	// table config
	TableConfig        *DataflowTableConfig        `json:"table_config,omitempty"`
	StorageFlushConfig *DataflowStorageFlushConfig `json:"storage_flush_config,omitempty"`
}

type DataflowEndPoint struct {
	GcsUri string `json:"gcsUri,omitempty"`
}

type DataflowStorageDataFormat struct {
	BinaryEncodingMethod string `json:"binary_encoding_method,omitempty"`
	DateSeparator        string `json:"date_separator,omitempty"`
	Delimiter            string `json:"delimiter,omitempty"`
	IncludeCommitTs      bool   `json:"include_commit_ts,omitempty"`
	Null                 string `json:"null,omitempty"`
	Protocol             string `json:"protocol,omitempty"`
	Quote                string `json:"quote,omitempty"`
}

type DataflowStorageFlushConfig struct {
	FileSize      string `json:"file_size,omitempty"`
	FlushInterval string `json:"flush_interval,omitempty"`
}

type DataflowS3Info struct {
	S3EndPoint    *DataflowS3EndPoint        `json:"endpoint,omitempty"`
	DataFormat    *DataflowStorageDataFormat `json:"data_format,omitempty"`
	StartPosition *DataflowStartPosition     `json:"start_position,omitempty"`
	// table config
	TableConfig        *DataflowTableConfig        `json:"table_config,omitempty"`
	StorageFlushConfig *DataflowStorageFlushConfig `json:"storage_flush_config,omitempty"`
}

type DataflowS3EndPoint struct {
	S3Uri     string `json:"s3Uri,omitempty"`
	AccessKey string `json:"access_key,omitempty"`
	SecretKey string `json:"secret_key,omitempty"`
}
