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

// DataflowClusterComponent dataflow cluster component
//
// swagger:model dataflowClusterComponent
type DataflowClusterComponent struct {

	// node profile
	// Required: true
	NodeProfile *DataflowNodeProfile `json:"node_profile"`

	// replicas
	// Required: true
	Replicas *int64 `json:"replicas"`
}

// Validate validates this dataflow cluster component
func (m *DataflowClusterComponent) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *DataflowClusterComponent) validateNodeProfile(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *DataflowClusterComponent) validateReplicas(formats strfmt.Registry) error {

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

	return nil
}

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

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

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

func (m *DataflowClusterComponent) contextValidateNodeProfile(ctx context.Context, formats strfmt.Registry) error {

	if m.NodeProfile != nil {

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

	return nil
}

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

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