mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 03:54:21 +00:00
6e105f662e
* init for views (spooler, handler) * init for views (spooler, handler) * start view in management * granted project * implement granted project view * search granted projects * fix search column * update all projects on project change * search roles * filter org * project members * project grant members * fix tests * application view * project grant search * mock * test appendevents * test appendevents * Update internal/view/query.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/eventstore/spooler/spooler.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/view/query.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * merge request changes * Update internal/project/repository/view/model/application.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * merge request changes * Project view sql (#92) * sql and configs * error handling * sql start in eventstore * on error handling, config * read user on members * Update internal/project/repository/view/application_view.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/application.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/application.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/application.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/application.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/application.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/application_query.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update pkg/management/api/grpc/project_grant_converter.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update pkg/management/api/grpc/project_grant_member_converter.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update pkg/management/api/grpc/project_grant_member_converter.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update pkg/management/api/grpc/project_member_converter.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update pkg/management/api/grpc/project_member_converter.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/granted_project.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * return caos errors * Update internal/project/repository/view/model/granted_project_query.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/project_grant_member.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/project_grant_member_query.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/project_member.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/project_member_query.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/project_role.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update internal/project/repository/view/model/project_role_query.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update pkg/management/api/grpc/application_converter.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update pkg/management/api/grpc/application_converter.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update pkg/management/api/grpc/project_converter.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update pkg/management/api/grpc/project_converter.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update pkg/management/api/grpc/project_converter.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * Update pkg/management/api/grpc/project_converter.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * converter fix Co-authored-by: Livio Amstutz <livio.a@gmail.com> Co-authored-by: Silvan <silvan.reusser@gmail.com>
125 lines
4.1 KiB
Go
125 lines
4.1 KiB
Go
package grpc
|
|
|
|
import (
|
|
"github.com/caos/logging"
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
|
"github.com/caos/zitadel/internal/model"
|
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
|
"github.com/golang/protobuf/ptypes"
|
|
)
|
|
|
|
func projectGrantFromModel(grant *proj_model.ProjectGrant) *ProjectGrant {
|
|
creationDate, err := ptypes.TimestampProto(grant.CreationDate)
|
|
logging.Log("GRPC-8d73s").OnError(err).Debug("unable to parse timestamp")
|
|
|
|
changeDate, err := ptypes.TimestampProto(grant.ChangeDate)
|
|
logging.Log("GRPC-dlso3").OnError(err).Debug("unable to parse timestamp")
|
|
|
|
return &ProjectGrant{
|
|
Id: grant.GrantID,
|
|
State: projectGrantStateFromModel(grant.State),
|
|
CreationDate: creationDate,
|
|
ChangeDate: changeDate,
|
|
GrantedOrgId: grant.GrantedOrgID,
|
|
RoleKeys: grant.RoleKeys,
|
|
Sequence: grant.Sequence,
|
|
}
|
|
}
|
|
|
|
func projectGrantCreateToModel(grant *ProjectGrantCreate) *proj_model.ProjectGrant {
|
|
return &proj_model.ProjectGrant{
|
|
ObjectRoot: models.ObjectRoot{
|
|
AggregateID: grant.ProjectId,
|
|
},
|
|
GrantedOrgID: grant.GrantedOrgId,
|
|
RoleKeys: grant.RoleKeys,
|
|
}
|
|
}
|
|
|
|
func projectGrantUpdateToModel(grant *ProjectGrantUpdate) *proj_model.ProjectGrant {
|
|
return &proj_model.ProjectGrant{
|
|
ObjectRoot: models.ObjectRoot{
|
|
AggregateID: grant.ProjectId,
|
|
},
|
|
GrantID: grant.Id,
|
|
RoleKeys: grant.RoleKeys,
|
|
}
|
|
}
|
|
|
|
func projectGrantSearchRequestsToModel(request *ProjectGrantSearchRequest) *proj_model.GrantedProjectSearchRequest {
|
|
return &proj_model.GrantedProjectSearchRequest{
|
|
Offset: request.Offset,
|
|
Limit: request.Limit,
|
|
Queries: projectGrantSearchQueriesToModel(request.ProjectId),
|
|
}
|
|
}
|
|
|
|
func projectGrantSearchQueriesToModel(projectId string) []*proj_model.GrantedProjectSearchQuery {
|
|
converted := make([]*proj_model.GrantedProjectSearchQuery, 0)
|
|
return append(converted, &proj_model.GrantedProjectSearchQuery{
|
|
Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID,
|
|
Method: model.SEARCHMETHOD_EQUALS,
|
|
Value: projectId,
|
|
})
|
|
}
|
|
|
|
func projectGrantSearchResponseFromModel(response *proj_model.GrantedProjectSearchResponse) *ProjectGrantSearchResponse {
|
|
return &ProjectGrantSearchResponse{
|
|
Offset: response.Offset,
|
|
Limit: response.Limit,
|
|
TotalResult: response.TotalResult,
|
|
Result: projectGrantsFromGrantedProjectModel(response.Result),
|
|
}
|
|
}
|
|
|
|
func projectGrantsFromGrantedProjectModel(projects []*proj_model.GrantedProjectView) []*ProjectGrantView {
|
|
converted := make([]*ProjectGrantView, len(projects))
|
|
for i, project := range projects {
|
|
converted[i] = projectGrantFromGrantedProjectModel(project)
|
|
}
|
|
return converted
|
|
}
|
|
|
|
func projectGrantFromGrantedProjectModel(project *proj_model.GrantedProjectView) *ProjectGrantView {
|
|
creationDate, err := ptypes.TimestampProto(project.CreationDate)
|
|
logging.Log("GRPC-dlso3").OnError(err).Debug("unable to parse timestamp")
|
|
|
|
changeDate, err := ptypes.TimestampProto(project.ChangeDate)
|
|
logging.Log("GRPC-sope3").OnError(err).Debug("unable to parse timestamp")
|
|
|
|
return &ProjectGrantView{
|
|
ProjectId: project.ProjectID,
|
|
State: projectGrantStateFromProjectStateModel(project.State),
|
|
CreationDate: creationDate,
|
|
ChangeDate: changeDate,
|
|
ProjectName: project.Name,
|
|
Sequence: project.Sequence,
|
|
GrantedOrgId: project.OrgID,
|
|
GrantedOrgName: project.OrgName,
|
|
GrantedOrgDomain: project.OrgDomain,
|
|
Id: project.GrantID,
|
|
}
|
|
}
|
|
|
|
func projectGrantStateFromModel(state proj_model.ProjectGrantState) ProjectGrantState {
|
|
switch state {
|
|
case proj_model.PROJECTGRANTSTATE_ACTIVE:
|
|
return ProjectGrantState_PROJECTGRANTSTATE_ACTIVE
|
|
case proj_model.PROJECTGRANTSTATE_INACTIVE:
|
|
return ProjectGrantState_PROJECTGRANTSTATE_INACTIVE
|
|
default:
|
|
return ProjectGrantState_PROJECTGRANTSTATE_UNSPECIFIED
|
|
}
|
|
}
|
|
|
|
func projectGrantStateFromProjectStateModel(state proj_model.ProjectState) ProjectGrantState {
|
|
switch state {
|
|
case proj_model.PROJECTSTATE_ACTIVE:
|
|
return ProjectGrantState_PROJECTGRANTSTATE_ACTIVE
|
|
case proj_model.PROJECTSTATE_INACTIVE:
|
|
return ProjectGrantState_PROJECTGRANTSTATE_INACTIVE
|
|
default:
|
|
return ProjectGrantState_PROJECTGRANTSTATE_UNSPECIFIED
|
|
}
|
|
}
|