package platformoverview

import (
	"context"

	"github.com/pingcap/tep/pkg/apis/apiserver"
	store "github.com/pingcap/tep/pkg/registry/apiserver"
	"k8s.io/apimachinery/pkg/api/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime"
)

const basicInformation = "basic-information"

type Storage struct {
	store *store.Store
}

func NewStorage(store *store.Store) *Storage {
	return &Storage{
		store: store,
	}
}

func (s *Storage) Kind() string {
	return "PlatformOverview"
}

func (s *Storage) New() runtime.Object {
	return &apiserver.PlatformOverview{}
}

func (s *Storage) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
	if name != basicInformation {
		return nil, errors.NewBadRequest("not supported URL")
	}
	return s.GetBasicInformation()
}

func (s *Storage) NamespaceScoped() bool {
	return false
}
