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

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

// 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.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) 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 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
}

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