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

// OpenapiTiDBProfile openapi ti d b profile
//
// swagger:model openapiTiDBProfile
type OpenapiTiDBProfile struct {

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

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

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

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

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

func (m *OpenapiTiDBProfile) 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
}

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

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

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

func (m *OpenapiTiDBProfile) 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
}

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

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

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

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

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

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