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

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)

// DataflowImportGetResp dataflow import get resp
//
// swagger:model dataflowImportGetResp
type DataflowImportGetResp struct {

	// all completed tables
	AllCompletedTables []*DataflowImportTableCompletionInfo `json:"all_completed_tables"`

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

	// completed percent
	// Required: true
	CompletedPercent *int64 `json:"completed_percent"`

	// completed tables
	// Required: true
	CompletedTables *int64 `json:"completed_tables"`

	// created at
	// Required: true
	// Format: date-time
	CreatedAt *strfmt.DateTime `json:"created_at"`

	// current tables
	// Required: true
	CurrentTables []*DataflowCurrentTable `json:"current_tables"`

	// data format
	// Required: true
	DataFormat *int64 `json:"data_format"`

	// data source type
	// Required: true
	DataSourceType *int64 `json:"data_source_type"`

	// elapsed time seconds
	// Required: true
	ElapsedTimeSeconds *int64 `json:"elapsed_time_seconds"`

	// id
	ID string `json:"id,omitempty"`

	// import create req
	ImportCreateReq *DataflowImportCreateReq `json:"import_create_req,omitempty"`

	// message
	// Required: true
	Message *string `json:"message"`

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

	// pending tables
	// Required: true
	PendingTables *int64 `json:"pending_tables"`

	// post import completed percent
	PostImportCompletedPercent int64 `json:"post_import_completed_percent,omitempty"`

	// processed source data size
	ProcessedSourceDataSize string `json:"processed_source_data_size,omitempty"`

	// source url
	// Required: true
	SourceURL *string `json:"source_url"`

	// status
	// Required: true
	Status *DataflowImportGetRespStatus `json:"status"`

	// total files
	// Required: true
	TotalFiles *int64 `json:"total_files"`

	// total size
	// Required: true
	TotalSize *string `json:"total_size"`

	// total tables count
	TotalTablesCount int64 `json:"total_tables_count,omitempty"`
}

// Validate validates this dataflow import get resp
func (m *DataflowImportGetResp) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *DataflowImportGetResp) validateAllCompletedTables(formats strfmt.Registry) error {
	if swag.IsZero(m.AllCompletedTables) { // not required
		return nil
	}

	for i := 0; i < len(m.AllCompletedTables); i++ {
		if swag.IsZero(m.AllCompletedTables[i]) { // not required
			continue
		}

		if m.AllCompletedTables[i] != nil {
			if err := m.AllCompletedTables[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("all_completed_tables" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("all_completed_tables" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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

	return nil
}

func (m *DataflowImportGetResp) validateCompletedPercent(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowImportGetResp) validateCompletedTables(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowImportGetResp) validateCreatedAt(formats strfmt.Registry) error {

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

	if err := validate.FormatOf("created_at", "body", "date-time", m.CreatedAt.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *DataflowImportGetResp) validateCurrentTables(formats strfmt.Registry) error {

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

	for i := 0; i < len(m.CurrentTables); i++ {
		if swag.IsZero(m.CurrentTables[i]) { // not required
			continue
		}

		if m.CurrentTables[i] != nil {
			if err := m.CurrentTables[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("current_tables" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("current_tables" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DataflowImportGetResp) validateDataFormat(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowImportGetResp) validateDataSourceType(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowImportGetResp) validateElapsedTimeSeconds(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowImportGetResp) validateImportCreateReq(formats strfmt.Registry) error {
	if swag.IsZero(m.ImportCreateReq) { // not required
		return nil
	}

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

	return nil
}

func (m *DataflowImportGetResp) validateMessage(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowImportGetResp) validatePendingTables(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowImportGetResp) validateSourceURL(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowImportGetResp) validateStatus(formats strfmt.Registry) error {

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

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

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

	return nil
}

func (m *DataflowImportGetResp) validateTotalFiles(formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowImportGetResp) validateTotalSize(formats strfmt.Registry) error {

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

	return nil
}

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

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

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

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

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

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

func (m *DataflowImportGetResp) contextValidateAllCompletedTables(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.AllCompletedTables); i++ {

		if m.AllCompletedTables[i] != nil {
			if err := m.AllCompletedTables[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("all_completed_tables" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("all_completed_tables" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DataflowImportGetResp) contextValidateCurrentTables(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.CurrentTables); i++ {

		if m.CurrentTables[i] != nil {
			if err := m.CurrentTables[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("current_tables" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("current_tables" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DataflowImportGetResp) contextValidateImportCreateReq(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *DataflowImportGetResp) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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