package app

import "github.com/dexidp/dex/storage"

type Service interface {
	ListApps() ([]storage.Client, error)
	GetApp(id string) (storage.Client, error)
	AddApp(config storage.Client) error
	RemoveApp(id string) error
}

type concreteAppService struct {
	s storage.Storage
}

func (cas *concreteAppService) ListApps() ([]storage.Client, error) {
	return cas.s.ListClients()
}

func (cas *concreteAppService) GetApp(id string) (storage.Client, error) {
	return cas.s.GetClient(id)
}

func (cas *concreteAppService) AddApp(config storage.Client) error {
	return cas.s.CreateClient(config)
}

func (cas *concreteAppService) RemoveApp(id string) error {
	return cas.s.DeleteClient(id)
}

func New(s storage.Storage) Service {
	return &concreteAppService{s}
}
