2020-03-24 09:14:39 +00:00
|
|
|
package grpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/errors"
|
2020-04-21 15:00:32 +00:00
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
2020-03-24 09:14:39 +00:00
|
|
|
)
|
|
|
|
|
2020-04-21 15:00:32 +00:00
|
|
|
func (s *Server) SearchApplications(ctx context.Context, in *ApplicationSearchRequest) (*ApplicationSearchResponse, error) {
|
2020-03-24 09:14:39 +00:00
|
|
|
return nil, errors.ThrowUnimplemented(nil, "GRPC-yW23f", "Not implemented")
|
|
|
|
}
|
|
|
|
|
2020-04-21 15:00:32 +00:00
|
|
|
func (s *Server) ApplicationByID(ctx context.Context, in *ApplicationID) (*Application, error) {
|
|
|
|
app, err := s.project.ApplicationByID(ctx, in.ProjectId, in.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return appFromModel(app), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) CreateOIDCApplication(ctx context.Context, in *OIDCApplicationCreate) (*Application, error) {
|
2020-04-21 15:00:32 +00:00
|
|
|
app, err := s.project.AddApplication(ctx, oidcAppCreateToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return appFromModel(app), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
func (s *Server) UpdateApplication(ctx context.Context, in *ApplicationUpdate) (*Application, error) {
|
2020-04-21 15:00:32 +00:00
|
|
|
app, err := s.project.ChangeApplication(ctx, appUpdateToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return appFromModel(app), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
func (s *Server) DeactivateApplication(ctx context.Context, in *ApplicationID) (*Application, error) {
|
2020-04-21 15:00:32 +00:00
|
|
|
app, err := s.project.DeactivateApplication(ctx, in.ProjectId, in.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return appFromModel(app), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
func (s *Server) ReactivateApplication(ctx context.Context, in *ApplicationID) (*Application, error) {
|
2020-04-21 15:00:32 +00:00
|
|
|
app, err := s.project.ReactivateApplication(ctx, in.ProjectId, in.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return appFromModel(app), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
2020-04-21 15:00:32 +00:00
|
|
|
|
|
|
|
func (s *Server) RemoveApplication(ctx context.Context, in *ApplicationID) (*empty.Empty, error) {
|
|
|
|
err := s.project.RemoveApplication(ctx, in.ProjectId, in.Id)
|
|
|
|
return &empty.Empty{}, err
|
|
|
|
}
|
|
|
|
|
2020-03-24 09:14:39 +00:00
|
|
|
func (s *Server) UpdateApplicationOIDCConfig(ctx context.Context, in *OIDCConfigUpdate) (*OIDCConfig, error) {
|
2020-04-21 15:00:32 +00:00
|
|
|
config, err := s.project.ChangeOIDCConfig(ctx, oidcConfigUpdateToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return oidcConfigFromModel(config), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
2020-04-21 15:00:32 +00:00
|
|
|
|
2020-03-24 09:14:39 +00:00
|
|
|
func (s *Server) RegenerateOIDCClientSecret(ctx context.Context, in *ApplicationID) (*ClientSecret, error) {
|
2020-04-21 15:00:32 +00:00
|
|
|
config, err := s.project.ChangeOIDConfigSecret(ctx, in.ProjectId, in.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &ClientSecret{ClientSecret: config.ClientSecretString}, nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) ApplicationChanges(ctx context.Context, changesRequest *ChangeRequest) (*Changes, error) {
|
|
|
|
return nil, errors.ThrowUnimplemented(nil, "GRPC-due45", "Not implemented")
|
|
|
|
}
|