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

// OpenapiTiFlashProfile openapi ti flash profile
//
// swagger:model openapiTiFlashProfile
type OpenapiTiFlashProfile struct {

	// node quantity range
	NodeQuantityRange *OpenapiTiFlashProfileNodeQuantityRange `json:"node_quantity_range,omitempty"`

	// The size of the TiFlash component in the cluster.
	// Example: 8C64G
	NodeSize string `json:"node_size,omitempty"`

	// storage size gib range
	StorageSizeGibRange *OpenapiTiFlashProfileStorageSizeGibRange `json:"storage_size_gib_range,omitempty"`
}

// Validate validates this openapi ti flash profile
func (m *OpenapiTiFlashProfile) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *OpenapiTiFlashProfile) validateNodeQuantityRange(formats strfmt.Registry) error {
	if swag.IsZero(m.NodeQuantityRange) { // not required
		return nil
	}

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

	return nil
}

func (m *OpenapiTiFlashProfile) validateStorageSizeGibRange(formats strfmt.Registry) error {
	if swag.IsZero(m.StorageSizeGibRange) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this openapi ti flash profile based on the context it is used
func (m *OpenapiTiFlashProfile) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *OpenapiTiFlashProfile) contextValidateNodeQuantityRange(ctx context.Context, formats strfmt.Registry) error {

	if m.NodeQuantityRange != nil {

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

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

	return nil
}

func (m *OpenapiTiFlashProfile) contextValidateStorageSizeGibRange(ctx context.Context, formats strfmt.Registry) error {

	if m.StorageSizeGibRange != nil {

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

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

	return nil
}

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

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

// OpenapiTiFlashProfileNodeQuantityRange The range and step of node quantity of the TiFlash component in the cluster.
//
// swagger:model OpenapiTiFlashProfileNodeQuantityRange
type OpenapiTiFlashProfileNodeQuantityRange struct {

	// The minimum node quantity of the component in the cluster.
	Min int32 `json:"min,omitempty"`

	// The step of node quantity of the component in the cluster.
	Step int32 `json:"step,omitempty"`
}

// Validate validates this openapi ti flash profile node quantity range
func (m *OpenapiTiFlashProfileNodeQuantityRange) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validates this openapi ti flash profile node quantity range based on context it is used
func (m *OpenapiTiFlashProfileNodeQuantityRange) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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

// OpenapiTiFlashProfileStorageSizeGibRange The storage size range for each node of the TiFlash component in the cluster.
//
// swagger:model OpenapiTiFlashProfileStorageSizeGibRange
type OpenapiTiFlashProfileStorageSizeGibRange struct {

	// The maximum storage size for each node of the component in the cluster.
	Max int32 `json:"max,omitempty"`

	// The minimum storage size for each node of the component in the cluster.
	Min int32 `json:"min,omitempty"`
}

// Validate validates this openapi ti flash profile storage size gib range
func (m *OpenapiTiFlashProfileStorageSizeGibRange) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validates this openapi ti flash profile storage size gib range based on context it is used
func (m *OpenapiTiFlashProfileStorageSizeGibRange) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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