package scopes

import (
	"errors"
	"fmt"

	"code.secondbit.org/scopes.hg/types"

	"golang.org/x/net/context"
)

var (
	ErrNoStorer      = errors.New("Storer not set in Context")
	ErrScopeNotFound = errors.New("Scope not found")
)

type ErrScopeAlreadyExists string

func (e ErrScopeAlreadyExists) Error() string {
	return fmt.Sprintf("scope %s already exists", string(e))
}

type Storer interface {
	CreateScopes(scopes []scopeTypes.Scope, ctx context.Context) error
	GetScopes(ids []string, ctx context.Context) (map[string]scopeTypes.Scope, error)
	UpdateScope(change scopeTypes.ScopeChange, ctx context.Context) error
	RemoveScopes(ids []string, ctx context.Context) error
	ListScopes(ctx context.Context) ([]scopeTypes.Scope, error)
}
