package cloudproviderhandler

import (
	"fmt"

	"github.com/pingcap/dbaas/billing2/billing_errors"
	"github.com/pingcap/dbaas/billing2/forms"
)

const (
	PriceHandler_AWS   = "aws"
	PriceHandler_Azure = "azure"
	PriceHandler_GCP   = "gcp"
)

type ProviderPriceHandler interface {
	GetPrice(params map[string]string) (res *forms.ProviderPriceRes, err error)
}

func GetPriceHandler(provider string) (ProviderPriceHandler, error) {
	switch provider {
	case PriceHandler_AWS:
		return &AwsPriceHandlerImpl{}, nil
	case PriceHandler_Azure:
		return &AzurePriceHandlerImpl{}, nil
	case PriceHandler_GCP:
		return &GcpPriceHandlerImpl{}, nil
	default:
		return nil, billing_errors.NewInvalidInputError(fmt.Errorf("invalid price handler:%s", provider))
	}
}
