| 
									
										
										
										
											2020-03-24 10:14:39 +01:00
										 |  |  | package grpc | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"context" | 
					
						
							|  |  |  | 	"github.com/caos/zitadel/internal/errors" | 
					
						
							| 
									
										
										
										
											2020-04-21 17:00:32 +02:00
										 |  |  | 	"github.com/golang/protobuf/ptypes/empty" | 
					
						
							| 
									
										
										
										
											2020-03-24 10:14:39 +01:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-21 17:00:32 +02:00
										 |  |  | func (s *Server) SearchApplications(ctx context.Context, in *ApplicationSearchRequest) (*ApplicationSearchResponse, error) { | 
					
						
							| 
									
										
										
										
											2020-05-11 12:16:29 +02:00
										 |  |  | 	response, err := s.project.SearchApplications(ctx, applicationSearchRequestsToModel(in)) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return applicationSearchResponseFromModel(response), nil | 
					
						
							| 
									
										
										
										
											2020-03-24 10:14:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-21 17:00:32 +02: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 10:14:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (s *Server) CreateOIDCApplication(ctx context.Context, in *OIDCApplicationCreate) (*Application, error) { | 
					
						
							| 
									
										
										
										
											2020-04-21 17:00:32 +02:00
										 |  |  | 	app, err := s.project.AddApplication(ctx, oidcAppCreateToModel(in)) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return appFromModel(app), nil | 
					
						
							| 
									
										
										
										
											2020-03-24 10:14:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | func (s *Server) UpdateApplication(ctx context.Context, in *ApplicationUpdate) (*Application, error) { | 
					
						
							| 
									
										
										
										
											2020-04-21 17:00:32 +02:00
										 |  |  | 	app, err := s.project.ChangeApplication(ctx, appUpdateToModel(in)) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return appFromModel(app), nil | 
					
						
							| 
									
										
										
										
											2020-03-24 10:14:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | func (s *Server) DeactivateApplication(ctx context.Context, in *ApplicationID) (*Application, error) { | 
					
						
							| 
									
										
										
										
											2020-04-21 17:00:32 +02:00
										 |  |  | 	app, err := s.project.DeactivateApplication(ctx, in.ProjectId, in.Id) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return appFromModel(app), nil | 
					
						
							| 
									
										
										
										
											2020-03-24 10:14:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | func (s *Server) ReactivateApplication(ctx context.Context, in *ApplicationID) (*Application, error) { | 
					
						
							| 
									
										
										
										
											2020-04-21 17:00:32 +02:00
										 |  |  | 	app, err := s.project.ReactivateApplication(ctx, in.ProjectId, in.Id) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return appFromModel(app), nil | 
					
						
							| 
									
										
										
										
											2020-03-24 10:14:39 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-04-21 17:00:32 +02: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 10:14:39 +01:00
										 |  |  | func (s *Server) UpdateApplicationOIDCConfig(ctx context.Context, in *OIDCConfigUpdate) (*OIDCConfig, error) { | 
					
						
							| 
									
										
										
										
											2020-04-21 17:00:32 +02:00
										 |  |  | 	config, err := s.project.ChangeOIDCConfig(ctx, oidcConfigUpdateToModel(in)) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return oidcConfigFromModel(config), nil | 
					
						
							| 
									
										
										
										
											2020-03-24 10:14:39 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-04-21 17:00:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-24 10:14:39 +01:00
										 |  |  | func (s *Server) RegenerateOIDCClientSecret(ctx context.Context, in *ApplicationID) (*ClientSecret, error) { | 
					
						
							| 
									
										
										
										
											2020-04-21 17:00:32 +02: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 10:14:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (s *Server) ApplicationChanges(ctx context.Context, changesRequest *ChangeRequest) (*Changes, error) { | 
					
						
							|  |  |  | 	return nil, errors.ThrowUnimplemented(nil, "GRPC-due45", "Not implemented") | 
					
						
							|  |  |  | } |