2020-07-08 11:56:37 +00:00
|
|
|
package admin
|
2020-06-25 06:01:13 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-07-08 11:56:37 +00:00
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
2020-07-08 11:56:37 +00:00
|
|
|
|
|
|
|
view_model "github.com/caos/zitadel/internal/view/model"
|
|
|
|
"github.com/caos/zitadel/pkg/grpc/admin"
|
2020-06-25 06:01:13 +00:00
|
|
|
)
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) GetViews(ctx context.Context, _ *empty.Empty) (_ *admin.Views, err error) {
|
2020-06-25 06:01:13 +00:00
|
|
|
views, err := s.administrator.GetViews(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-07-08 11:56:37 +00:00
|
|
|
return &admin.Views{Views: viewsFromModel(views)}, nil
|
2020-06-25 06:01:13 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) ClearView(ctx context.Context, viewID *admin.ViewID) (_ *empty.Empty, err error) {
|
2020-06-25 06:01:13 +00:00
|
|
|
err = s.administrator.ClearView(ctx, viewID.Database, viewID.ViewName)
|
|
|
|
return &empty.Empty{}, err
|
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) GetFailedEvents(ctx context.Context, _ *empty.Empty) (_ *admin.FailedEvents, err error) {
|
2020-06-25 06:01:13 +00:00
|
|
|
failedEvents, err := s.administrator.GetFailedEvents(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-07-08 11:56:37 +00:00
|
|
|
return &admin.FailedEvents{FailedEvents: failedEventsFromModel(failedEvents)}, nil
|
2020-06-25 06:01:13 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) RemoveFailedEvent(ctx context.Context, failedEventID *admin.FailedEventID) (_ *empty.Empty, err error) {
|
2020-06-25 06:01:13 +00:00
|
|
|
err = s.administrator.RemoveFailedEvent(ctx, &view_model.FailedEvent{Database: failedEventID.Database, ViewName: failedEventID.ViewName, FailedSequence: failedEventID.FailedSequence})
|
|
|
|
return &empty.Empty{}, err
|
|
|
|
}
|