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

// OpenapiTiKVProfile openapi ti k v profile
//
// swagger:model openapiTiKVProfile
type OpenapiTiKVProfile struct {

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

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

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

// Validate validates this openapi ti k v profile
func (m *OpenapiTiKVProfile) 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 *OpenapiTiKVProfile) 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 *OpenapiTiKVProfile) 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 k v profile based on the context it is used
func (m *OpenapiTiKVProfile) 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 *OpenapiTiKVProfile) 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 *OpenapiTiKVProfile) 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 *OpenapiTiKVProfile) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

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

// OpenapiTiKVProfileNodeQuantityRange The range and step of node quantity of the TiKV component in the cluster.
//
// swagger:model OpenapiTiKVProfileNodeQuantityRange
type OpenapiTiKVProfileNodeQuantityRange 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 k v profile node quantity range
func (m *OpenapiTiKVProfileNodeQuantityRange) Validate(formats strfmt.Registry) error {
	return nil
}

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

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

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

// OpenapiTiKVProfileStorageSizeGibRange The storage size range for each node of the TiKV component in the cluster.
//
// swagger:model OpenapiTiKVProfileStorageSizeGibRange
type OpenapiTiKVProfileStorageSizeGibRange 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 k v profile storage size gib range
func (m *OpenapiTiKVProfileStorageSizeGibRange) Validate(formats strfmt.Registry) error {
	return nil
}

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

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

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