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

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

	// changefeed instance type
	ChangefeedInstanceType string `json:"changefeed_instance_type,omitempty"`

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

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

	// gcs info
	GcsInfo *DataflowGcsInfo `json:"gcs_info,omitempty"`

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

	// internal
	Internal bool `json:"internal,omitempty"`

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

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

	// name
	Name string `json:"name,omitempty"`

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

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

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

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

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

	// 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"`
}

// 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.validateGcsInfo(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.validateS3Info(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateServerlessTidbInfo(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) validateGcsInfo(formats strfmt.Registry) error {
	if swag.IsZero(m.GcsInfo) { // not required
		return nil
	}

	if m.GcsInfo != nil {
		if err := m.GcsInfo.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("gcs_info")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("gcs_info")
			}
			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) validateS3Info(formats strfmt.Registry) error {
	if swag.IsZero(m.S3Info) { // not required
		return nil
	}

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

	return nil
}

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

	if m.ServerlessTidbInfo != nil {
		if err := m.ServerlessTidbInfo.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("serverless_tidb_info")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("serverless_tidb_info")
			}
			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.contextValidateGcsInfo(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 err := m.contextValidateS3Info(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateServerlessTidbInfo(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) contextValidateGcsInfo(ctx context.Context, formats strfmt.Registry) error {

	if m.GcsInfo != nil {

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

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

	return nil
}

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

	if m.KafkaInfo != nil {

		if swag.IsZero(m.KafkaInfo) { // not required
			return 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 swag.IsZero(m.MysqlInfo) { // not required
			return 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
}

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

	if m.S3Info != nil {

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

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

	return nil
}

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

	if m.ServerlessTidbInfo != nil {

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

		if err := m.ServerlessTidbInfo.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("serverless_tidb_info")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("serverless_tidb_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
}
