mirror of
https://github.com/zitadel/zitadel.git
synced 2025-05-22 18:28:25 +00:00
fix: projects (#221)
* feat: projects and project grants seperated * fix: tests * fix: add mock
This commit is contained in:
parent
c4eaeee7af
commit
e63179514c
@ -41,33 +41,33 @@ func (repo *ProjectRepo) ReactivateProject(ctx context.Context, id string) (*pro
|
|||||||
return repo.ProjectEvents.ReactivateProject(ctx, id)
|
return repo.ProjectEvents.ReactivateProject(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *ProjectRepo) SearchGrantedProjects(ctx context.Context, request *proj_model.GrantedProjectSearchRequest) (*proj_model.GrantedProjectSearchResponse, error) {
|
func (repo *ProjectRepo) SearchProjects(ctx context.Context, request *proj_model.ProjectViewSearchRequest) (*proj_model.ProjectViewSearchResponse, error) {
|
||||||
request.EnsureLimit(repo.SearchLimit)
|
request.EnsureLimit(repo.SearchLimit)
|
||||||
|
|
||||||
permissions := auth.GetPermissionsFromCtx(ctx)
|
permissions := auth.GetPermissionsFromCtx(ctx)
|
||||||
if !auth.HasGlobalPermission(permissions) {
|
if !auth.HasGlobalPermission(permissions) {
|
||||||
ids := auth.GetPermissionCtxIDs(permissions)
|
ids := auth.GetPermissionCtxIDs(permissions)
|
||||||
request.Queries = append(request.Queries, &proj_model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Method: global_model.SEARCHMETHOD_IN, Value: ids})
|
request.Queries = append(request.Queries, &proj_model.ProjectViewSearchQuery{Key: proj_model.PROJECTSEARCHKEY_PROJECTID, Method: global_model.SEARCHMETHOD_IN, Value: ids})
|
||||||
}
|
}
|
||||||
|
|
||||||
projects, count, err := repo.View.SearchGrantedProjects(request)
|
projects, count, err := repo.View.SearchProjects(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &proj_model.GrantedProjectSearchResponse{
|
return &proj_model.ProjectViewSearchResponse{
|
||||||
Offset: request.Offset,
|
Offset: request.Offset,
|
||||||
Limit: request.Limit,
|
Limit: request.Limit,
|
||||||
TotalResult: uint64(count),
|
TotalResult: uint64(count),
|
||||||
Result: model.GrantedProjectsToModel(projects),
|
Result: model.ProjectsToModel(projects),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *ProjectRepo) GetGrantedProjectGrantByIDs(ctx context.Context, projectID, grantID string) (project *proj_model.GrantedProjectView, err error) {
|
func (repo *ProjectRepo) ProjectGrantViewByID(ctx context.Context, grantID string) (project *proj_model.ProjectGrantView, err error) {
|
||||||
p, err := repo.View.GrantedProjectGrantByIDs(projectID, grantID)
|
p, err := repo.View.ProjectGrantByID(grantID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return model.GrantedProjectToModel(p), nil
|
return model.ProjectGrantToModel(p), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *ProjectRepo) ProjectMemberByID(ctx context.Context, projectID, userID string) (member *proj_model.ProjectMember, err error) {
|
func (repo *ProjectRepo) ProjectMemberByID(ctx context.Context, projectID, userID string) (member *proj_model.ProjectMember, err error) {
|
||||||
@ -180,6 +180,20 @@ func (repo *ProjectRepo) ProjectGrantByID(ctx context.Context, projectID, appID
|
|||||||
return repo.ProjectEvents.ProjectGrantByIDs(ctx, projectID, appID)
|
return repo.ProjectEvents.ProjectGrantByIDs(ctx, projectID, appID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (repo *ProjectRepo) SearchProjectGrants(ctx context.Context, request *proj_model.ProjectGrantViewSearchRequest) (*proj_model.ProjectGrantViewSearchResponse, error) {
|
||||||
|
request.EnsureLimit(repo.SearchLimit)
|
||||||
|
projects, count, err := repo.View.SearchProjectGrants(request)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &proj_model.ProjectGrantViewSearchResponse{
|
||||||
|
Offset: request.Offset,
|
||||||
|
Limit: request.Limit,
|
||||||
|
TotalResult: uint64(count),
|
||||||
|
Result: model.ProjectGrantsToModel(projects),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (repo *ProjectRepo) AddProjectGrant(ctx context.Context, app *proj_model.ProjectGrant) (*proj_model.ProjectGrant, error) {
|
func (repo *ProjectRepo) AddProjectGrant(ctx context.Context, app *proj_model.ProjectGrant) (*proj_model.ProjectGrant, error) {
|
||||||
return repo.ProjectEvents.AddProjectGrant(ctx, app)
|
return repo.ProjectEvents.AddProjectGrant(ctx, app)
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,8 @@ type EventstoreRepos struct {
|
|||||||
|
|
||||||
func Register(configs Configs, bulkLimit, errorCount uint64, view *view.View, eventstore eventstore.Eventstore, repos EventstoreRepos) []spooler.Handler {
|
func Register(configs Configs, bulkLimit, errorCount uint64, view *view.View, eventstore eventstore.Eventstore, repos EventstoreRepos) []spooler.Handler {
|
||||||
return []spooler.Handler{
|
return []spooler.Handler{
|
||||||
&GrantedProject{handler: handler{view, bulkLimit, configs.cycleDuration("GrantedProject"), errorCount}, eventstore: eventstore, projectEvents: repos.ProjectEvents, orgEvents: repos.OrgEvents},
|
&Project{handler: handler{view, bulkLimit, configs.cycleDuration("Project"), errorCount}, eventstore: eventstore},
|
||||||
|
&ProjectGrant{handler: handler{view, bulkLimit, configs.cycleDuration("ProjectGrant"), errorCount}, eventstore: eventstore, projectEvents: repos.ProjectEvents, orgEvents: repos.OrgEvents},
|
||||||
&ProjectRole{handler: handler{view, bulkLimit, configs.cycleDuration("ProjectRole"), errorCount}, projectEvents: repos.ProjectEvents},
|
&ProjectRole{handler: handler{view, bulkLimit, configs.cycleDuration("ProjectRole"), errorCount}, projectEvents: repos.ProjectEvents},
|
||||||
&ProjectMember{handler: handler{view, bulkLimit, configs.cycleDuration("ProjectMember"), errorCount}, userEvents: repos.UserEvents},
|
&ProjectMember{handler: handler{view, bulkLimit, configs.cycleDuration("ProjectMember"), errorCount}, userEvents: repos.UserEvents},
|
||||||
&ProjectGrantMember{handler: handler{view, bulkLimit, configs.cycleDuration("ProjectGrantMember"), errorCount}, userEvents: repos.UserEvents},
|
&ProjectGrantMember{handler: handler{view, bulkLimit, configs.cycleDuration("ProjectGrantMember"), errorCount}, userEvents: repos.UserEvents},
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/caos/logging"
|
||||||
|
|
||||||
|
"github.com/caos/zitadel/internal/eventstore"
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/models"
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/spooler"
|
||||||
|
proj_event "github.com/caos/zitadel/internal/project/repository/eventsourcing"
|
||||||
|
es_model "github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
|
||||||
|
view_model "github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Project struct {
|
||||||
|
handler
|
||||||
|
eventstore eventstore.Eventstore
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
projectTable = "management.projects"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *Project) MinimumCycleDuration() time.Duration { return p.cycleDuration }
|
||||||
|
|
||||||
|
func (p *Project) ViewModel() string {
|
||||||
|
return projectTable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Project) EventQuery() (*models.SearchQuery, error) {
|
||||||
|
sequence, err := p.view.GetLatestProjectSequence()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return proj_event.ProjectQuery(sequence), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Project) Process(event *models.Event) (err error) {
|
||||||
|
project := new(view_model.ProjectView)
|
||||||
|
switch event.Type {
|
||||||
|
case es_model.ProjectAdded:
|
||||||
|
project.AppendEvent(event)
|
||||||
|
case es_model.ProjectChanged,
|
||||||
|
es_model.ProjectDeactivated,
|
||||||
|
es_model.ProjectReactivated:
|
||||||
|
project, err = p.view.ProjectByID(event.AggregateID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = project.AppendEvent(event)
|
||||||
|
default:
|
||||||
|
return p.view.ProcessedProjectSequence(event.Sequence)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return p.view.PutProject(project)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Project) OnError(event *models.Event, err error) error {
|
||||||
|
logging.LogWithFields("SPOOL-dLsop3", "id", event.AggregateID).WithError(err).Warn("something went wrong in projecthandler")
|
||||||
|
return spooler.HandleError(event, err, p.view.GetLatestProjectFailedEvent, p.view.ProcessedProjectFailedEvent, p.view.ProcessedProjectSequence, p.errorCountUntilSkip)
|
||||||
|
}
|
@ -17,7 +17,7 @@ import (
|
|||||||
view_model "github.com/caos/zitadel/internal/project/repository/view/model"
|
view_model "github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GrantedProject struct {
|
type ProjectGrant struct {
|
||||||
handler
|
handler
|
||||||
eventstore eventstore.Eventstore
|
eventstore eventstore.Eventstore
|
||||||
projectEvents *proj_event.ProjectEventstore
|
projectEvents *proj_event.ProjectEventstore
|
||||||
@ -25,44 +25,32 @@ type GrantedProject struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
grantedProjectTable = "management.granted_projects"
|
grantedProjectTable = "management.project_grants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *GrantedProject) MinimumCycleDuration() time.Duration { return p.cycleDuration }
|
func (p *ProjectGrant) MinimumCycleDuration() time.Duration { return p.cycleDuration }
|
||||||
|
|
||||||
func (p *GrantedProject) ViewModel() string {
|
func (p *ProjectGrant) ViewModel() string {
|
||||||
return grantedProjectTable
|
return grantedProjectTable
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GrantedProject) EventQuery() (*models.SearchQuery, error) {
|
func (p *ProjectGrant) EventQuery() (*models.SearchQuery, error) {
|
||||||
sequence, err := p.view.GetLatestGrantedProjectSequence()
|
sequence, err := p.view.GetLatestProjectGrantSequence()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return proj_event.ProjectQuery(sequence), nil
|
return proj_event.ProjectQuery(sequence), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GrantedProject) Process(event *models.Event) (err error) {
|
func (p *ProjectGrant) Process(event *models.Event) (err error) {
|
||||||
grantedProject := new(view_model.GrantedProjectView)
|
grantedProject := new(view_model.ProjectGrantView)
|
||||||
switch event.Type {
|
switch event.Type {
|
||||||
case es_model.ProjectAdded:
|
|
||||||
grantedProject.AppendEvent(event)
|
|
||||||
case es_model.ProjectChanged:
|
case es_model.ProjectChanged:
|
||||||
grantedProject, err = p.view.GrantedProjectByIDs(event.AggregateID, event.ResourceOwner)
|
project, err := p.view.ProjectByID(event.AggregateID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = grantedProject.AppendEvent(event)
|
p.updateExistingProjects(project)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
p.updateExistingProjects(grantedProject)
|
|
||||||
case es_model.ProjectDeactivated, es_model.ProjectReactivated:
|
|
||||||
grantedProject, err = p.view.GrantedProjectByIDs(event.AggregateID, event.ResourceOwner)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = grantedProject.AppendEvent(event)
|
|
||||||
case es_model.ProjectGrantAdded:
|
case es_model.ProjectGrantAdded:
|
||||||
err = grantedProject.AppendEvent(event)
|
err = grantedProject.AppendEvent(event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -85,7 +73,7 @@ func (p *GrantedProject) Process(event *models.Event) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
grantedProject, err = p.view.GrantedProjectByIDs(event.AggregateID, grant.GrantedOrgID)
|
grantedProject, err = p.view.ProjectGrantByID(grant.GrantID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -96,38 +84,38 @@ func (p *GrantedProject) Process(event *models.Event) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return p.view.DeleteGrantedProject(event.AggregateID, grant.GrantedOrgID, event.Sequence)
|
return p.view.DeleteProjectGrant(grant.GrantID, event.Sequence)
|
||||||
default:
|
default:
|
||||||
return p.view.ProcessedGrantedProjectSequence(event.Sequence)
|
return p.view.ProcessedProjectGrantSequence(event.Sequence)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return p.view.PutGrantedProject(grantedProject)
|
return p.view.PutProjectGrant(grantedProject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GrantedProject) fillOrgData(grantedProject *view_model.GrantedProjectView, org *org_model.Org) {
|
func (p *ProjectGrant) fillOrgData(grantedProject *view_model.ProjectGrantView, org *org_model.Org) {
|
||||||
grantedProject.OrgDomain = org.Domain
|
grantedProject.OrgDomain = org.Domain
|
||||||
grantedProject.OrgName = org.Name
|
grantedProject.OrgName = org.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GrantedProject) getProject(projectID string) (*proj_model.Project, error) {
|
func (p *ProjectGrant) getProject(projectID string) (*proj_model.Project, error) {
|
||||||
return p.projectEvents.ProjectByID(context.Background(), projectID)
|
return p.projectEvents.ProjectByID(context.Background(), projectID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GrantedProject) updateExistingProjects(project *view_model.GrantedProjectView) {
|
func (p *ProjectGrant) updateExistingProjects(project *view_model.ProjectView) {
|
||||||
projects, err := p.view.GrantedProjectsByID(project.ProjectID)
|
projects, err := p.view.ProjectGrantsByProjectID(project.ProjectID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.LogWithFields("SPOOL-los03", "id", project.ProjectID).WithError(err).Warn("could not update existing projects")
|
logging.LogWithFields("SPOOL-los03", "id", project.ProjectID).WithError(err).Warn("could not update existing projects")
|
||||||
}
|
}
|
||||||
for _, existing := range projects {
|
for _, existing := range projects {
|
||||||
existing.Name = project.Name
|
existing.Name = project.Name
|
||||||
err := p.view.PutGrantedProject(existing)
|
err := p.view.PutProjectGrant(existing)
|
||||||
logging.LogWithFields("SPOOL-sjwi3", "id", existing.ProjectID).WithError(err).Warn("could not update existing project")
|
logging.LogWithFields("SPOOL-sjwi3", "id", existing.ProjectID).WithError(err).Warn("could not update existing project")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GrantedProject) OnError(event *models.Event, err error) error {
|
func (p *ProjectGrant) OnError(event *models.Event, err error) error {
|
||||||
logging.LogWithFields("SPOOL-is8wa", "id", event.AggregateID).WithError(err).Warn("something went wrong in granted projecthandler")
|
logging.LogWithFields("SPOOL-is8wa", "id", event.AggregateID).WithError(err).Warn("something went wrong in granted projecthandler")
|
||||||
return spooler.HandleError(event, err, p.view.GetLatestGrantedProjectFailedEvent, p.view.ProcessedGrantedProjectFailedEvent, p.view.ProcessedGrantedProjectSequence, p.errorCountUntilSkip)
|
return spooler.HandleError(event, err, p.view.GetLatestProjectGrantFailedEvent, p.view.ProcessedProjectGrantFailedEvent, p.view.ProcessedProjectGrantSequence, p.errorCountUntilSkip)
|
||||||
}
|
}
|
@ -1,60 +0,0 @@
|
|||||||
package view
|
|
||||||
|
|
||||||
import (
|
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
|
||||||
"github.com/caos/zitadel/internal/project/repository/view"
|
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
grantedProjectTable = "management.granted_projects"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (v *View) GrantedProjectByIDs(projectID, orgID string) (*model.GrantedProjectView, error) {
|
|
||||||
return view.GrantedProjectByIDs(v.Db, grantedProjectTable, projectID, orgID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *View) GrantedProjectGrantByIDs(projectID, grantID string) (*model.GrantedProjectView, error) {
|
|
||||||
return view.GrantedProjectGrantByIDs(v.Db, grantedProjectTable, projectID, grantID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *View) GrantedProjectsByID(projectID string) ([]*model.GrantedProjectView, error) {
|
|
||||||
return view.GrantedProjectsByID(v.Db, grantedProjectTable, projectID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *View) SearchGrantedProjects(request *proj_model.GrantedProjectSearchRequest) ([]*model.GrantedProjectView, int, error) {
|
|
||||||
return view.SearchGrantedProjects(v.Db, grantedProjectTable, request)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *View) PutGrantedProject(project *model.GrantedProjectView) error {
|
|
||||||
err := view.PutGrantedProject(v.Db, grantedProjectTable, project)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return v.ProcessedGrantedProjectSequence(project.Sequence)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *View) DeleteGrantedProject(projectID, orgID string, eventSequence uint64) error {
|
|
||||||
err := view.DeleteGrantedProject(v.Db, grantedProjectTable, projectID, orgID)
|
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return v.ProcessedGrantedProjectSequence(eventSequence)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *View) GetLatestGrantedProjectSequence() (uint64, error) {
|
|
||||||
return v.latestSequence(grantedProjectTable)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *View) ProcessedGrantedProjectSequence(eventSequence uint64) error {
|
|
||||||
return v.saveCurrentSequence(grantedProjectTable, eventSequence)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *View) GetLatestGrantedProjectFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
|
||||||
return v.latestFailedEvent(grantedProjectTable, sequence)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *View) ProcessedGrantedProjectFailedEvent(failedEvent *global_view.FailedEvent) error {
|
|
||||||
return v.saveFailedEvent(failedEvent)
|
|
||||||
}
|
|
52
internal/management/repository/eventsourcing/view/project.go
Normal file
52
internal/management/repository/eventsourcing/view/project.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package view
|
||||||
|
|
||||||
|
import (
|
||||||
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
|
"github.com/caos/zitadel/internal/project/repository/view"
|
||||||
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
|
global_view "github.com/caos/zitadel/internal/view"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
projectTable = "management.projects"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (v *View) ProjectByID(projectID string) (*model.ProjectView, error) {
|
||||||
|
return view.ProjectByID(v.Db, projectTable, projectID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) SearchProjects(request *proj_model.ProjectViewSearchRequest) ([]*model.ProjectView, int, error) {
|
||||||
|
return view.SearchProjects(v.Db, projectTable, request)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) PutProject(project *model.ProjectView) error {
|
||||||
|
err := view.PutProject(v.Db, projectTable, project)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return v.ProcessedProjectSequence(project.Sequence)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) DeleteProject(projectID string, eventSequence uint64) error {
|
||||||
|
err := view.DeleteProject(v.Db, projectTable, projectID)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return v.ProcessedProjectSequence(eventSequence)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) GetLatestProjectSequence() (uint64, error) {
|
||||||
|
return v.latestSequence(projectTable)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) ProcessedProjectSequence(eventSequence uint64) error {
|
||||||
|
return v.saveCurrentSequence(projectTable, eventSequence)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) GetLatestProjectFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
||||||
|
return v.latestFailedEvent(projectTable, sequence)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) ProcessedProjectFailedEvent(failedEvent *global_view.FailedEvent) error {
|
||||||
|
return v.saveFailedEvent(failedEvent)
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package view
|
||||||
|
|
||||||
|
import (
|
||||||
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
|
"github.com/caos/zitadel/internal/project/repository/view"
|
||||||
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
|
global_view "github.com/caos/zitadel/internal/view"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
grantedProjectTable = "management.project_grants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (v *View) ProjectGrantByID(grantID string) (*model.ProjectGrantView, error) {
|
||||||
|
return view.ProjectGrantByID(v.Db, grantedProjectTable, grantID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) ProjectGrantByProjectAndOrg(projectID, orgID string) (*model.ProjectGrantView, error) {
|
||||||
|
return view.ProjectGrantByProjectAndOrg(v.Db, grantedProjectTable, projectID, orgID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) ProjectGrantsByProjectID(projectID string) ([]*model.ProjectGrantView, error) {
|
||||||
|
return view.ProjectGrantsByProjectID(v.Db, grantedProjectTable, projectID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) SearchProjectGrants(request *proj_model.ProjectGrantViewSearchRequest) ([]*model.ProjectGrantView, int, error) {
|
||||||
|
return view.SearchProjectGrants(v.Db, grantedProjectTable, request)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) PutProjectGrant(project *model.ProjectGrantView) error {
|
||||||
|
err := view.PutProjectGrant(v.Db, grantedProjectTable, project)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return v.ProcessedProjectGrantSequence(project.Sequence)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) DeleteProjectGrant(grantID string, eventSequence uint64) error {
|
||||||
|
err := view.DeleteProjectGrant(v.Db, grantedProjectTable, grantID)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return v.ProcessedProjectGrantSequence(eventSequence)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) GetLatestProjectGrantSequence() (uint64, error) {
|
||||||
|
return v.latestSequence(grantedProjectTable)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) ProcessedProjectGrantSequence(eventSequence uint64) error {
|
||||||
|
return v.saveCurrentSequence(grantedProjectTable, eventSequence)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) GetLatestProjectGrantFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
||||||
|
return v.latestFailedEvent(grantedProjectTable, sequence)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) ProcessedProjectGrantFailedEvent(failedEvent *global_view.FailedEvent) error {
|
||||||
|
return v.saveFailedEvent(failedEvent)
|
||||||
|
}
|
@ -12,8 +12,9 @@ type ProjectRepository interface {
|
|||||||
UpdateProject(ctx context.Context, project *model.Project) (*model.Project, error)
|
UpdateProject(ctx context.Context, project *model.Project) (*model.Project, error)
|
||||||
DeactivateProject(ctx context.Context, id string) (*model.Project, error)
|
DeactivateProject(ctx context.Context, id string) (*model.Project, error)
|
||||||
ReactivateProject(ctx context.Context, id string) (*model.Project, error)
|
ReactivateProject(ctx context.Context, id string) (*model.Project, error)
|
||||||
SearchGrantedProjects(ctx context.Context, request *model.GrantedProjectSearchRequest) (*model.GrantedProjectSearchResponse, error)
|
SearchProjects(ctx context.Context, request *model.ProjectViewSearchRequest) (*model.ProjectViewSearchResponse, error)
|
||||||
GetGrantedProjectGrantByIDs(ctx context.Context, projectID, grantID string) (*model.GrantedProjectView, error)
|
SearchProjectGrants(ctx context.Context, request *model.ProjectGrantViewSearchRequest) (*model.ProjectGrantViewSearchResponse, error)
|
||||||
|
ProjectGrantViewByID(ctx context.Context, grantID string) (*model.ProjectGrantView, error)
|
||||||
|
|
||||||
ProjectMemberByID(ctx context.Context, projectID, userID string) (*model.ProjectMember, error)
|
ProjectMemberByID(ctx context.Context, projectID, userID string) (*model.ProjectMember, error)
|
||||||
AddProjectMember(ctx context.Context, member *model.ProjectMember) (*model.ProjectMember, error)
|
AddProjectMember(ctx context.Context, member *model.ProjectMember) (*model.ProjectMember, error)
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/caos/zitadel/internal/model"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GrantedProjectView struct {
|
|
||||||
ProjectID string
|
|
||||||
Name string
|
|
||||||
CreationDate time.Time
|
|
||||||
ChangeDate time.Time
|
|
||||||
State ProjectState
|
|
||||||
Type ProjectType
|
|
||||||
ResourceOwner string
|
|
||||||
OrgID string
|
|
||||||
OrgName string
|
|
||||||
OrgDomain string
|
|
||||||
Sequence uint64
|
|
||||||
GrantID string
|
|
||||||
GrantedRoleKeys []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProjectType int32
|
|
||||||
|
|
||||||
const (
|
|
||||||
PROJECTTYPE_OWNED ProjectType = iota
|
|
||||||
PROJECTTYPE_GRANTED
|
|
||||||
)
|
|
||||||
|
|
||||||
type GrantedProjectSearchRequest struct {
|
|
||||||
Offset uint64
|
|
||||||
Limit uint64
|
|
||||||
SortingColumn GrantedProjectSearchKey
|
|
||||||
Asc bool
|
|
||||||
Queries []*GrantedProjectSearchQuery
|
|
||||||
}
|
|
||||||
|
|
||||||
type GrantedProjectSearchKey int32
|
|
||||||
|
|
||||||
const (
|
|
||||||
GRANTEDPROJECTSEARCHKEY_UNSPECIFIED GrantedProjectSearchKey = iota
|
|
||||||
GRANTEDPROJECTSEARCHKEY_NAME
|
|
||||||
GRANTEDPROJECTSEARCHKEY_PROJECTID
|
|
||||||
GRANTEDPROJECTSEARCHKEY_GRANTID
|
|
||||||
GRANTEDPROJECTSEARCHKEY_ORGID
|
|
||||||
GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER
|
|
||||||
)
|
|
||||||
|
|
||||||
type GrantedProjectSearchQuery struct {
|
|
||||||
Key GrantedProjectSearchKey
|
|
||||||
Method model.SearchMethod
|
|
||||||
Value interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
type GrantedProjectSearchResponse struct {
|
|
||||||
Offset uint64
|
|
||||||
Limit uint64
|
|
||||||
TotalResult uint64
|
|
||||||
Result []*GrantedProjectView
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *GrantedProjectSearchRequest) AppendMyOrgQuery(orgID string) {
|
|
||||||
r.Queries = append(r.Queries, &GrantedProjectSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *GrantedProjectSearchRequest) AppendNotMyOrgQuery(orgID string) {
|
|
||||||
r.Queries = append(r.Queries, &GrantedProjectSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_NOT_EQUALS, Value: orgID})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *GrantedProjectSearchRequest) AppendMyResourceOwnerQuery(orgID string) {
|
|
||||||
r.Queries = append(r.Queries, &GrantedProjectSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *GrantedProjectSearchRequest) EnsureLimit(limit uint64) {
|
|
||||||
if r.Limit == 0 || r.Limit > limit {
|
|
||||||
r.Limit = limit
|
|
||||||
}
|
|
||||||
}
|
|
71
internal/project/model/project_grant_view.go
Normal file
71
internal/project/model/project_grant_view.go
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/caos/zitadel/internal/model"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProjectGrantView struct {
|
||||||
|
ProjectID string
|
||||||
|
Name string
|
||||||
|
CreationDate time.Time
|
||||||
|
ChangeDate time.Time
|
||||||
|
State ProjectState
|
||||||
|
ResourceOwner string
|
||||||
|
OrgID string
|
||||||
|
OrgName string
|
||||||
|
OrgDomain string
|
||||||
|
Sequence uint64
|
||||||
|
GrantID string
|
||||||
|
GrantedRoleKeys []string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProjectGrantViewSearchRequest struct {
|
||||||
|
Offset uint64
|
||||||
|
Limit uint64
|
||||||
|
SortingColumn ProjectGrantViewSearchKey
|
||||||
|
Asc bool
|
||||||
|
Queries []*ProjectGrantViewSearchQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProjectGrantViewSearchKey int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
GRANTEDPROJECTSEARCHKEY_UNSPECIFIED ProjectGrantViewSearchKey = iota
|
||||||
|
GRANTEDPROJECTSEARCHKEY_NAME
|
||||||
|
GRANTEDPROJECTSEARCHKEY_PROJECTID
|
||||||
|
GRANTEDPROJECTSEARCHKEY_GRANTID
|
||||||
|
GRANTEDPROJECTSEARCHKEY_ORGID
|
||||||
|
GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProjectGrantViewSearchQuery struct {
|
||||||
|
Key ProjectGrantViewSearchKey
|
||||||
|
Method model.SearchMethod
|
||||||
|
Value interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProjectGrantViewSearchResponse struct {
|
||||||
|
Offset uint64
|
||||||
|
Limit uint64
|
||||||
|
TotalResult uint64
|
||||||
|
Result []*ProjectGrantView
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *ProjectGrantViewSearchRequest) AppendMyOrgQuery(orgID string) {
|
||||||
|
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *ProjectGrantViewSearchRequest) AppendNotMyOrgQuery(orgID string) {
|
||||||
|
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_NOT_EQUALS, Value: orgID})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *ProjectGrantViewSearchRequest) AppendMyResourceOwnerQuery(orgID string) {
|
||||||
|
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *ProjectGrantViewSearchRequest) EnsureLimit(limit uint64) {
|
||||||
|
if r.Limit == 0 || r.Limit > limit {
|
||||||
|
r.Limit = limit
|
||||||
|
}
|
||||||
|
}
|
56
internal/project/model/project_view.go
Normal file
56
internal/project/model/project_view.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/caos/zitadel/internal/model"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProjectView struct {
|
||||||
|
ProjectID string
|
||||||
|
Name string
|
||||||
|
CreationDate time.Time
|
||||||
|
ChangeDate time.Time
|
||||||
|
State ProjectState
|
||||||
|
ResourceOwner string
|
||||||
|
Sequence uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProjectViewSearchRequest struct {
|
||||||
|
Offset uint64
|
||||||
|
Limit uint64
|
||||||
|
SortingColumn ProjectViewSearchKey
|
||||||
|
Asc bool
|
||||||
|
Queries []*ProjectViewSearchQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProjectViewSearchKey int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
PROJECTSEARCHKEY_UNSPECIFIED ProjectViewSearchKey = iota
|
||||||
|
PROJECTSEARCHKEY_NAME
|
||||||
|
PROJECTSEARCHKEY_PROJECTID
|
||||||
|
PROJECTSEARCHKEY_RESOURCE_OWNER
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProjectViewSearchQuery struct {
|
||||||
|
Key ProjectViewSearchKey
|
||||||
|
Method model.SearchMethod
|
||||||
|
Value interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProjectViewSearchResponse struct {
|
||||||
|
Offset uint64
|
||||||
|
Limit uint64
|
||||||
|
TotalResult uint64
|
||||||
|
Result []*ProjectView
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *ProjectViewSearchRequest) AppendMyResourceOwnerQuery(orgID string) {
|
||||||
|
r.Queries = append(r.Queries, &ProjectViewSearchQuery{Key: PROJECTSEARCHKEY_RESOURCE_OWNER, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *ProjectViewSearchRequest) EnsureLimit(limit uint64) {
|
||||||
|
if r.Limit == 0 || r.Limit > limit {
|
||||||
|
r.Limit = limit
|
||||||
|
}
|
||||||
|
}
|
@ -1,65 +0,0 @@
|
|||||||
package view
|
|
||||||
|
|
||||||
import (
|
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
|
||||||
"github.com/caos/zitadel/internal/view"
|
|
||||||
"github.com/jinzhu/gorm"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GrantedProjectByIDs(db *gorm.DB, table, projectID, orgID string) (*model.GrantedProjectView, error) {
|
|
||||||
project := new(model.GrantedProjectView)
|
|
||||||
|
|
||||||
projectIDQuery := model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
|
||||||
orgIDQuery := model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_ORGID, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS}
|
|
||||||
query := view.PrepareGetByQuery(table, projectIDQuery, orgIDQuery)
|
|
||||||
err := query(db, project)
|
|
||||||
return project, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func GrantedProjectGrantByIDs(db *gorm.DB, table, projectID, grantID string) (*model.GrantedProjectView, error) {
|
|
||||||
project := new(model.GrantedProjectView)
|
|
||||||
|
|
||||||
projectIDQuery := model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
|
||||||
grantIDQuery := model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_GRANTID, Value: grantID, Method: global_model.SEARCHMETHOD_EQUALS}
|
|
||||||
query := view.PrepareGetByQuery(table, projectIDQuery, grantIDQuery)
|
|
||||||
err := query(db, project)
|
|
||||||
return project, err
|
|
||||||
}
|
|
||||||
func GrantedProjectsByID(db *gorm.DB, table, projectID string) ([]*model.GrantedProjectView, error) {
|
|
||||||
projects := make([]*model.GrantedProjectView, 0)
|
|
||||||
queries := []*proj_model.GrantedProjectSearchQuery{
|
|
||||||
&proj_model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS},
|
|
||||||
}
|
|
||||||
query := view.PrepareSearchQuery(table, model.GrantedProjectSearchRequest{Queries: queries})
|
|
||||||
_, err := query(db, &projects)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return projects, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func SearchGrantedProjects(db *gorm.DB, table string, req *proj_model.GrantedProjectSearchRequest) ([]*model.GrantedProjectView, int, error) {
|
|
||||||
projects := make([]*model.GrantedProjectView, 0)
|
|
||||||
query := view.PrepareSearchQuery(table, model.GrantedProjectSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
|
||||||
count, err := query(db, &projects)
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
return projects, count, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func PutGrantedProject(db *gorm.DB, table string, project *model.GrantedProjectView) error {
|
|
||||||
save := view.PrepareSave(table)
|
|
||||||
return save(db, project)
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeleteGrantedProject(db *gorm.DB, table, projectID, orgID string) error {
|
|
||||||
project, err := GrantedProjectByIDs(db, table, projectID, orgID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
delete := view.PrepareDeleteByObject(table, project)
|
|
||||||
return delete(db)
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
|
||||||
"github.com/caos/zitadel/internal/view"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GrantedProjectSearchRequest proj_model.GrantedProjectSearchRequest
|
|
||||||
type GrantedProjectSearchQuery proj_model.GrantedProjectSearchQuery
|
|
||||||
type GrantedProjectSearchKey proj_model.GrantedProjectSearchKey
|
|
||||||
|
|
||||||
func (req GrantedProjectSearchRequest) GetLimit() uint64 {
|
|
||||||
return req.Limit
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req GrantedProjectSearchRequest) GetOffset() uint64 {
|
|
||||||
return req.Offset
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req GrantedProjectSearchRequest) GetSortingColumn() view.ColumnKey {
|
|
||||||
if req.SortingColumn == proj_model.GRANTEDPROJECTSEARCHKEY_UNSPECIFIED {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return GrantedProjectSearchKey(req.SortingColumn)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req GrantedProjectSearchRequest) GetAsc() bool {
|
|
||||||
return req.Asc
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req GrantedProjectSearchRequest) GetQueries() []view.SearchQuery {
|
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
|
||||||
for i, q := range req.Queries {
|
|
||||||
result[i] = GrantedProjectSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req GrantedProjectSearchQuery) GetKey() view.ColumnKey {
|
|
||||||
return GrantedProjectSearchKey(req.Key)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req GrantedProjectSearchQuery) GetMethod() global_model.SearchMethod {
|
|
||||||
return req.Method
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req GrantedProjectSearchQuery) GetValue() interface{} {
|
|
||||||
return req.Value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (key GrantedProjectSearchKey) ToColumnName() string {
|
|
||||||
switch proj_model.GrantedProjectSearchKey(key) {
|
|
||||||
case proj_model.GRANTEDPROJECTSEARCHKEY_NAME:
|
|
||||||
return GrantedProjectKeyName
|
|
||||||
case proj_model.GRANTEDPROJECTSEARCHKEY_GRANTID:
|
|
||||||
return GrantedProjectKeyGrantID
|
|
||||||
case proj_model.GRANTEDPROJECTSEARCHKEY_ORGID:
|
|
||||||
return GrantedProjectKeyOrgID
|
|
||||||
case proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID:
|
|
||||||
return GrantedProjectKeyProjectID
|
|
||||||
case proj_model.GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER:
|
|
||||||
return GrantedProjectKeyResourceOwner
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
108
internal/project/repository/view/model/project.go
Normal file
108
internal/project/repository/view/model/project.go
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/caos/logging"
|
||||||
|
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/models"
|
||||||
|
"github.com/caos/zitadel/internal/project/model"
|
||||||
|
es_model "github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ProjectKeyProjectID = "project_id"
|
||||||
|
ProjectKeyResourceOwner = "resource_owner"
|
||||||
|
ProjectKeyName = "project_name"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProjectView struct {
|
||||||
|
ProjectID string `json:"-" gorm:"column:project_id;primary_key"`
|
||||||
|
Name string `json:"name" gorm:"column:project_name"`
|
||||||
|
CreationDate time.Time `json:"-" gorm:"column:creation_date"`
|
||||||
|
ChangeDate time.Time `json:"-" gorm:"column:change_date"`
|
||||||
|
State int32 `json:"-" gorm:"column:project_state"`
|
||||||
|
ResourceOwner string `json:"-" gorm:"column:resource_owner"`
|
||||||
|
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func ProjectFromModel(project *model.ProjectView) *ProjectView {
|
||||||
|
return &ProjectView{
|
||||||
|
ProjectID: project.ProjectID,
|
||||||
|
Name: project.Name,
|
||||||
|
ChangeDate: project.ChangeDate,
|
||||||
|
CreationDate: project.CreationDate,
|
||||||
|
State: int32(project.State),
|
||||||
|
ResourceOwner: project.ResourceOwner,
|
||||||
|
Sequence: project.Sequence,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ProjectToModel(project *ProjectView) *model.ProjectView {
|
||||||
|
return &model.ProjectView{
|
||||||
|
ProjectID: project.ProjectID,
|
||||||
|
Name: project.Name,
|
||||||
|
ChangeDate: project.ChangeDate,
|
||||||
|
CreationDate: project.CreationDate,
|
||||||
|
State: model.ProjectState(project.State),
|
||||||
|
ResourceOwner: project.ResourceOwner,
|
||||||
|
Sequence: project.Sequence,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ProjectsToModel(projects []*ProjectView) []*model.ProjectView {
|
||||||
|
result := make([]*model.ProjectView, len(projects))
|
||||||
|
for i, p := range projects {
|
||||||
|
result[i] = ProjectToModel(p)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ProjectView) AppendEvent(event *models.Event) (err error) {
|
||||||
|
p.ChangeDate = event.CreationDate
|
||||||
|
p.Sequence = event.Sequence
|
||||||
|
switch event.Type {
|
||||||
|
case es_model.ProjectAdded:
|
||||||
|
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||||
|
p.CreationDate = event.CreationDate
|
||||||
|
p.setRootData(event)
|
||||||
|
err = p.setData(event)
|
||||||
|
case es_model.ProjectChanged:
|
||||||
|
err = p.setData(event)
|
||||||
|
case es_model.ProjectDeactivated:
|
||||||
|
p.State = int32(model.PROJECTSTATE_INACTIVE)
|
||||||
|
case es_model.ProjectReactivated:
|
||||||
|
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ProjectView) setRootData(event *models.Event) {
|
||||||
|
p.ProjectID = event.AggregateID
|
||||||
|
p.ResourceOwner = event.ResourceOwner
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ProjectView) setData(event *models.Event) error {
|
||||||
|
if err := json.Unmarshal(event.Data, p); err != nil {
|
||||||
|
logging.Log("EVEN-dlo92").WithError(err).Error("could not unmarshal event data")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ProjectView) setProjectData(event *models.Event) error {
|
||||||
|
project := new(ProjectView)
|
||||||
|
err := project.SetData(event)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ProjectView) SetData(event *models.Event) error {
|
||||||
|
if err := json.Unmarshal(event.Data, p); err != nil {
|
||||||
|
logging.Log("EVEN-sk9Sj").WithError(err).Error("could not unmarshal event data")
|
||||||
|
return caos_errs.ThrowInternal(err, "MODEL-s9ols", "Could not unmarshal data")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
@ -12,26 +12,25 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
GrantedProjectKeyProjectID = "project_id"
|
ProjectGrantKeyProjectID = "project_id"
|
||||||
GrantedProjectKeyGrantID = "grant_id"
|
ProjectGrantKeyGrantID = "grant_id"
|
||||||
GrantedProjectKeyOrgID = "org_id"
|
ProjectGrantKeyOrgID = "org_id"
|
||||||
GrantedProjectKeyResourceOwner = "resource_owner"
|
ProjectGrantKeyResourceOwner = "resource_owner"
|
||||||
GrantedProjectKeyName = "project_name"
|
ProjectGrantKeyName = "project_name"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GrantedProjectView struct {
|
type ProjectGrantView struct {
|
||||||
ProjectID string `json:"-" gorm:"column:project_id;primary_key"`
|
GrantID string `json:"-" gorm:"column:grant_id;primary_key"`
|
||||||
OrgID string `json:"-" gorm:"column:org_id;primary_key"`
|
ProjectID string `json:"-" gorm:"column:project_id"`
|
||||||
|
OrgID string `json:"-" gorm:"column:org_id"`
|
||||||
Name string `json:"name" gorm:"column:project_name"`
|
Name string `json:"name" gorm:"column:project_name"`
|
||||||
CreationDate time.Time `json:"-" gorm:"column:creation_date"`
|
CreationDate time.Time `json:"-" gorm:"column:creation_date"`
|
||||||
ChangeDate time.Time `json:"-" gorm:"column:change_date"`
|
ChangeDate time.Time `json:"-" gorm:"column:change_date"`
|
||||||
State int32 `json:"-" gorm:"column:project_state"`
|
State int32 `json:"-" gorm:"column:project_state"`
|
||||||
Type int32 `json:"-" gorm:"column:project_type"`
|
|
||||||
ResourceOwner string `json:"-" gorm:"column:resource_owner"`
|
ResourceOwner string `json:"-" gorm:"column:resource_owner"`
|
||||||
OrgName string `json:"-" gorm:"column:org_name"`
|
OrgName string `json:"-" gorm:"column:org_name"`
|
||||||
OrgDomain string `json:"-" gorm:"column:org_domain"`
|
OrgDomain string `json:"-" gorm:"column:org_domain"`
|
||||||
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
||||||
GrantID string `json:"-" gorm:"column:grant_id"`
|
|
||||||
GrantedRoleKeys pq.StringArray `json:"-" gorm:"column:granted_role_keys"`
|
GrantedRoleKeys pq.StringArray `json:"-" gorm:"column:granted_role_keys"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,15 +40,14 @@ type ProjectGrant struct {
|
|||||||
RoleKeys []string `json:"roleKeys"`
|
RoleKeys []string `json:"roleKeys"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GrantedProjectFromModel(project *model.GrantedProjectView) *GrantedProjectView {
|
func ProjectGrantFromModel(project *model.ProjectGrantView) *ProjectGrantView {
|
||||||
return &GrantedProjectView{
|
return &ProjectGrantView{
|
||||||
ProjectID: project.ProjectID,
|
ProjectID: project.ProjectID,
|
||||||
OrgID: project.OrgID,
|
OrgID: project.OrgID,
|
||||||
Name: project.Name,
|
Name: project.Name,
|
||||||
ChangeDate: project.ChangeDate,
|
ChangeDate: project.ChangeDate,
|
||||||
CreationDate: project.CreationDate,
|
CreationDate: project.CreationDate,
|
||||||
State: int32(project.State),
|
State: int32(project.State),
|
||||||
Type: int32(project.Type),
|
|
||||||
ResourceOwner: project.ResourceOwner,
|
ResourceOwner: project.ResourceOwner,
|
||||||
OrgName: project.OrgName,
|
OrgName: project.OrgName,
|
||||||
GrantID: project.GrantID,
|
GrantID: project.GrantID,
|
||||||
@ -58,15 +56,14 @@ func GrantedProjectFromModel(project *model.GrantedProjectView) *GrantedProjectV
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GrantedProjectToModel(project *GrantedProjectView) *model.GrantedProjectView {
|
func ProjectGrantToModel(project *ProjectGrantView) *model.ProjectGrantView {
|
||||||
return &model.GrantedProjectView{
|
return &model.ProjectGrantView{
|
||||||
ProjectID: project.ProjectID,
|
ProjectID: project.ProjectID,
|
||||||
OrgID: project.OrgID,
|
OrgID: project.OrgID,
|
||||||
Name: project.Name,
|
Name: project.Name,
|
||||||
ChangeDate: project.ChangeDate,
|
ChangeDate: project.ChangeDate,
|
||||||
CreationDate: project.CreationDate,
|
CreationDate: project.CreationDate,
|
||||||
State: model.ProjectState(project.State),
|
State: model.ProjectState(project.State),
|
||||||
Type: model.ProjectType(project.Type),
|
|
||||||
ResourceOwner: project.ResourceOwner,
|
ResourceOwner: project.ResourceOwner,
|
||||||
OrgName: project.OrgName,
|
OrgName: project.OrgName,
|
||||||
GrantID: project.GrantID,
|
GrantID: project.GrantID,
|
||||||
@ -74,34 +71,21 @@ func GrantedProjectToModel(project *GrantedProjectView) *model.GrantedProjectVie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GrantedProjectsToModel(projects []*GrantedProjectView) []*model.GrantedProjectView {
|
func ProjectGrantsToModel(projects []*ProjectGrantView) []*model.ProjectGrantView {
|
||||||
result := make([]*model.GrantedProjectView, len(projects))
|
result := make([]*model.ProjectGrantView, len(projects))
|
||||||
for i, p := range projects {
|
for i, p := range projects {
|
||||||
result[i] = GrantedProjectToModel(p)
|
result[i] = ProjectGrantToModel(p)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GrantedProjectView) AppendEvent(event *models.Event) (err error) {
|
func (p *ProjectGrantView) AppendEvent(event *models.Event) (err error) {
|
||||||
p.ChangeDate = event.CreationDate
|
p.ChangeDate = event.CreationDate
|
||||||
p.Sequence = event.Sequence
|
p.Sequence = event.Sequence
|
||||||
switch event.Type {
|
switch event.Type {
|
||||||
case es_model.ProjectAdded:
|
|
||||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
|
||||||
p.CreationDate = event.CreationDate
|
|
||||||
p.Type = int32(model.PROJECTTYPE_OWNED)
|
|
||||||
p.setRootData(event)
|
|
||||||
err = p.setData(event)
|
|
||||||
case es_model.ProjectChanged:
|
|
||||||
err = p.setData(event)
|
|
||||||
case es_model.ProjectDeactivated:
|
|
||||||
p.State = int32(model.PROJECTSTATE_INACTIVE)
|
|
||||||
case es_model.ProjectReactivated:
|
|
||||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
|
||||||
case es_model.ProjectGrantAdded:
|
case es_model.ProjectGrantAdded:
|
||||||
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
p.State = int32(model.PROJECTSTATE_ACTIVE)
|
||||||
p.CreationDate = event.CreationDate
|
p.CreationDate = event.CreationDate
|
||||||
p.Type = int32(model.PROJECTTYPE_GRANTED)
|
|
||||||
p.setRootData(event)
|
p.setRootData(event)
|
||||||
err = p.setProjectGrantData(event)
|
err = p.setProjectGrantData(event)
|
||||||
case es_model.ProjectGrantChanged:
|
case es_model.ProjectGrantChanged:
|
||||||
@ -114,13 +98,12 @@ func (p *GrantedProjectView) AppendEvent(event *models.Event) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GrantedProjectView) setRootData(event *models.Event) {
|
func (p *ProjectGrantView) setRootData(event *models.Event) {
|
||||||
p.ProjectID = event.AggregateID
|
p.ProjectID = event.AggregateID
|
||||||
p.OrgID = event.ResourceOwner
|
|
||||||
p.ResourceOwner = event.ResourceOwner
|
p.ResourceOwner = event.ResourceOwner
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GrantedProjectView) setData(event *models.Event) error {
|
func (p *ProjectGrantView) setData(event *models.Event) error {
|
||||||
if err := json.Unmarshal(event.Data, p); err != nil {
|
if err := json.Unmarshal(event.Data, p); err != nil {
|
||||||
logging.Log("EVEN-dlo92").WithError(err).Error("could not unmarshal event data")
|
logging.Log("EVEN-dlo92").WithError(err).Error("could not unmarshal event data")
|
||||||
return err
|
return err
|
||||||
@ -128,7 +111,7 @@ func (p *GrantedProjectView) setData(event *models.Event) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GrantedProjectView) setProjectGrantData(event *models.Event) error {
|
func (p *ProjectGrantView) setProjectGrantData(event *models.Event) error {
|
||||||
grant := new(ProjectGrant)
|
grant := new(ProjectGrant)
|
||||||
err := grant.SetData(event)
|
err := grant.SetData(event)
|
||||||
if err != nil {
|
if err != nil {
|
@ -0,0 +1,67 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
|
"github.com/caos/zitadel/internal/view"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProjectGrantSearchRequest proj_model.ProjectGrantViewSearchRequest
|
||||||
|
type ProjectGrantSearchQuery proj_model.ProjectGrantViewSearchQuery
|
||||||
|
type ProjectGrantSearchKey proj_model.ProjectGrantViewSearchKey
|
||||||
|
|
||||||
|
func (req ProjectGrantSearchRequest) GetLimit() uint64 {
|
||||||
|
return req.Limit
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectGrantSearchRequest) GetOffset() uint64 {
|
||||||
|
return req.Offset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectGrantSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||||
|
if req.SortingColumn == proj_model.GRANTEDPROJECTSEARCHKEY_UNSPECIFIED {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return ProjectGrantSearchKey(req.SortingColumn)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectGrantSearchRequest) GetAsc() bool {
|
||||||
|
return req.Asc
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectGrantSearchRequest) GetQueries() []view.SearchQuery {
|
||||||
|
result := make([]view.SearchQuery, len(req.Queries))
|
||||||
|
for i, q := range req.Queries {
|
||||||
|
result[i] = ProjectGrantSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectGrantSearchQuery) GetKey() view.ColumnKey {
|
||||||
|
return ProjectGrantSearchKey(req.Key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectGrantSearchQuery) GetMethod() global_model.SearchMethod {
|
||||||
|
return req.Method
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectGrantSearchQuery) GetValue() interface{} {
|
||||||
|
return req.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (key ProjectGrantSearchKey) ToColumnName() string {
|
||||||
|
switch proj_model.ProjectGrantViewSearchKey(key) {
|
||||||
|
case proj_model.GRANTEDPROJECTSEARCHKEY_NAME:
|
||||||
|
return ProjectGrantKeyName
|
||||||
|
case proj_model.GRANTEDPROJECTSEARCHKEY_GRANTID:
|
||||||
|
return ProjectGrantKeyGrantID
|
||||||
|
case proj_model.GRANTEDPROJECTSEARCHKEY_ORGID:
|
||||||
|
return ProjectGrantKeyOrgID
|
||||||
|
case proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID:
|
||||||
|
return ProjectGrantKeyProjectID
|
||||||
|
case proj_model.GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER:
|
||||||
|
return ProjectGrantKeyResourceOwner
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
@ -20,79 +20,47 @@ func mockProjectGrantData(grant *es_model.ProjectGrant) []byte {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGrantedProjectAppendEvent(t *testing.T) {
|
func TestProjectGrantAppendEvent(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
event *es_models.Event
|
event *es_models.Event
|
||||||
project *GrantedProjectView
|
project *ProjectGrantView
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
args args
|
args args
|
||||||
result *GrantedProjectView
|
result *ProjectGrantView
|
||||||
}{
|
}{
|
||||||
{
|
|
||||||
name: "append added project event",
|
|
||||||
args: args{
|
|
||||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectAdded, ResourceOwner: "OrgID", Data: mockProjectData(&es_model.Project{Name: "ProjectName"})},
|
|
||||||
project: &GrantedProjectView{},
|
|
||||||
},
|
|
||||||
result: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "append change project event",
|
|
||||||
args: args{
|
|
||||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectChanged, ResourceOwner: "OrgID", Data: mockProjectData(&es_model.Project{Name: "ProjectNameChanged"})},
|
|
||||||
project: &GrantedProjectView{ProjectID: "AggregateID", OrgID: "OrgID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
|
||||||
},
|
|
||||||
result: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "OrgID", Name: "ProjectNameChanged", State: int32(model.PROJECTSTATE_ACTIVE)},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "append project deactivate event",
|
|
||||||
args: args{
|
|
||||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectDeactivated, ResourceOwner: "OrgID"},
|
|
||||||
project: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
|
||||||
},
|
|
||||||
result: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_INACTIVE)},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "append project reactivate event",
|
|
||||||
args: args{
|
|
||||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectReactivated, ResourceOwner: "OrgID"},
|
|
||||||
project: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_INACTIVE)},
|
|
||||||
},
|
|
||||||
result: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "append added project grant event",
|
name: "append added project grant event",
|
||||||
args: args{
|
args: args{
|
||||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantAdded, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID", RoleKeys: pq.StringArray{"Role"}})},
|
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantAdded, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID", GrantedOrgID: "GrantedOrgID", RoleKeys: pq.StringArray{"Role"}})},
|
||||||
project: &GrantedProjectView{},
|
project: &ProjectGrantView{},
|
||||||
},
|
},
|
||||||
result: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "append change project grant event",
|
name: "append change project grant event",
|
||||||
args: args{
|
args: args{
|
||||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantChanged, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID", RoleKeys: pq.StringArray{"RoleChanged"}})},
|
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantChanged, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID", RoleKeys: pq.StringArray{"RoleChanged"}})},
|
||||||
project: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||||
},
|
},
|
||||||
result: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"RoleChanged"}},
|
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"RoleChanged"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "append deactivate project grant event",
|
name: "append deactivate project grant event",
|
||||||
args: args{
|
args: args{
|
||||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantDeactivated, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID"})},
|
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantDeactivated, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID"})},
|
||||||
project: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||||
},
|
},
|
||||||
result: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_INACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_INACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "append reactivate project grant event",
|
name: "append reactivate project grant event",
|
||||||
args: args{
|
args: args{
|
||||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantReactivated, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID"})},
|
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectGrantReactivated, ResourceOwner: "OrgID", Data: mockProjectGrantData(&es_model.ProjectGrant{GrantID: "GrantID"})},
|
||||||
project: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_INACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
project: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_INACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||||
},
|
},
|
||||||
result: &GrantedProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
result: &ProjectGrantView{ProjectID: "AggregateID", ResourceOwner: "OrgID", OrgID: "GrantedOrgID", State: int32(model.PROJECTSTATE_ACTIVE), GrantedRoleKeys: pq.StringArray{"Role"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
63
internal/project/repository/view/model/project_query.go
Normal file
63
internal/project/repository/view/model/project_query.go
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
|
"github.com/caos/zitadel/internal/view"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProjectSearchRequest proj_model.ProjectViewSearchRequest
|
||||||
|
type ProjectSearchQuery proj_model.ProjectViewSearchQuery
|
||||||
|
type ProjectSearchKey proj_model.ProjectViewSearchKey
|
||||||
|
|
||||||
|
func (req ProjectSearchRequest) GetLimit() uint64 {
|
||||||
|
return req.Limit
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectSearchRequest) GetOffset() uint64 {
|
||||||
|
return req.Offset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||||
|
if req.SortingColumn == proj_model.PROJECTSEARCHKEY_UNSPECIFIED {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return ProjectSearchKey(req.SortingColumn)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectSearchRequest) GetAsc() bool {
|
||||||
|
return req.Asc
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectSearchRequest) GetQueries() []view.SearchQuery {
|
||||||
|
result := make([]view.SearchQuery, len(req.Queries))
|
||||||
|
for i, q := range req.Queries {
|
||||||
|
result[i] = ProjectSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectSearchQuery) GetKey() view.ColumnKey {
|
||||||
|
return ProjectSearchKey(req.Key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectSearchQuery) GetMethod() global_model.SearchMethod {
|
||||||
|
return req.Method
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req ProjectSearchQuery) GetValue() interface{} {
|
||||||
|
return req.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (key ProjectSearchKey) ToColumnName() string {
|
||||||
|
switch proj_model.ProjectViewSearchKey(key) {
|
||||||
|
case proj_model.PROJECTSEARCHKEY_NAME:
|
||||||
|
return ProjectKeyName
|
||||||
|
case proj_model.PROJECTSEARCHKEY_PROJECTID:
|
||||||
|
return ProjectKeyProjectID
|
||||||
|
case proj_model.PROJECTSEARCHKEY_RESOURCE_OWNER:
|
||||||
|
return ProjectKeyResourceOwner
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
70
internal/project/repository/view/model/project_test.go
Normal file
70
internal/project/repository/view/model/project_test.go
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
es_models "github.com/caos/zitadel/internal/eventstore/models"
|
||||||
|
"github.com/caos/zitadel/internal/project/model"
|
||||||
|
es_model "github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestProjectAppendEvent(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
event *es_models.Event
|
||||||
|
project *ProjectView
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
result *ProjectView
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "append added project event",
|
||||||
|
args: args{
|
||||||
|
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectAdded, ResourceOwner: "OrgID", Data: mockProjectData(&es_model.Project{Name: "ProjectName"})},
|
||||||
|
project: &ProjectView{},
|
||||||
|
},
|
||||||
|
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "append change project event",
|
||||||
|
args: args{
|
||||||
|
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectChanged, ResourceOwner: "OrgID", Data: mockProjectData(&es_model.Project{Name: "ProjectNameChanged"})},
|
||||||
|
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||||
|
},
|
||||||
|
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectNameChanged", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "append project deactivate event",
|
||||||
|
args: args{
|
||||||
|
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectDeactivated, ResourceOwner: "OrgID"},
|
||||||
|
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||||
|
},
|
||||||
|
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_INACTIVE)},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "append project reactivate event",
|
||||||
|
args: args{
|
||||||
|
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.ProjectReactivated, ResourceOwner: "OrgID"},
|
||||||
|
project: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_INACTIVE)},
|
||||||
|
},
|
||||||
|
result: &ProjectView{ProjectID: "AggregateID", ResourceOwner: "OrgID", Name: "ProjectName", State: int32(model.PROJECTSTATE_ACTIVE)},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
tt.args.project.AppendEvent(tt.args.event)
|
||||||
|
if tt.args.project.ProjectID != tt.result.ProjectID {
|
||||||
|
t.Errorf("got wrong result projectID: expected: %v, actual: %v ", tt.result.ProjectID, tt.args.project.ProjectID)
|
||||||
|
}
|
||||||
|
if tt.args.project.ResourceOwner != tt.result.ResourceOwner {
|
||||||
|
t.Errorf("got wrong result ResourceOwner: expected: %v, actual: %v ", tt.result.ResourceOwner, tt.args.project.ResourceOwner)
|
||||||
|
}
|
||||||
|
if tt.args.project.Name != tt.result.Name {
|
||||||
|
t.Errorf("got wrong result name: expected: %v, actual: %v ", tt.result.Name, tt.args.project.Name)
|
||||||
|
}
|
||||||
|
if tt.args.project.State != tt.result.State {
|
||||||
|
t.Errorf("got wrong result state: expected: %v, actual: %v ", tt.result.State, tt.args.project.State)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
60
internal/project/repository/view/project_grant_view.go
Normal file
60
internal/project/repository/view/project_grant_view.go
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package view
|
||||||
|
|
||||||
|
import (
|
||||||
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
|
"github.com/caos/zitadel/internal/view"
|
||||||
|
"github.com/jinzhu/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ProjectGrantByProjectAndOrg(db *gorm.DB, table, projectID, orgID string) (*model.ProjectGrantView, error) {
|
||||||
|
project := new(model.ProjectGrantView)
|
||||||
|
|
||||||
|
projectIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||||
|
orgIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_ORGID, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||||
|
query := view.PrepareGetByQuery(table, projectIDQuery, orgIDQuery)
|
||||||
|
err := query(db, project)
|
||||||
|
return project, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func ProjectGrantByID(db *gorm.DB, table, grantID string) (*model.ProjectGrantView, error) {
|
||||||
|
project := new(model.ProjectGrantView)
|
||||||
|
grantIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_GRANTID, Value: grantID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||||
|
query := view.PrepareGetByQuery(table, grantIDQuery)
|
||||||
|
err := query(db, project)
|
||||||
|
return project, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func ProjectGrantsByProjectID(db *gorm.DB, table, projectID string) ([]*model.ProjectGrantView, error) {
|
||||||
|
projects := make([]*model.ProjectGrantView, 0)
|
||||||
|
queries := []*proj_model.ProjectGrantViewSearchQuery{
|
||||||
|
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||||
|
}
|
||||||
|
query := view.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Queries: queries})
|
||||||
|
_, err := query(db, &projects)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return projects, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SearchProjectGrants(db *gorm.DB, table string, req *proj_model.ProjectGrantViewSearchRequest) ([]*model.ProjectGrantView, int, error) {
|
||||||
|
projects := make([]*model.ProjectGrantView, 0)
|
||||||
|
query := view.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
|
count, err := query(db, &projects)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
return projects, count, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func PutProjectGrant(db *gorm.DB, table string, project *model.ProjectGrantView) error {
|
||||||
|
save := view.PrepareSave(table)
|
||||||
|
return save(db, project)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteProjectGrant(db *gorm.DB, table, grantID string) error {
|
||||||
|
delete := view.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.PROJECTGRANTMEMBERSEARCHKEY_GRANT_ID), grantID)
|
||||||
|
return delete(db)
|
||||||
|
}
|
51
internal/project/repository/view/project_view.go
Normal file
51
internal/project/repository/view/project_view.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package view
|
||||||
|
|
||||||
|
import (
|
||||||
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
|
"github.com/caos/zitadel/internal/view"
|
||||||
|
"github.com/jinzhu/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ProjectByID(db *gorm.DB, table, projectID string) (*model.ProjectView, error) {
|
||||||
|
project := new(model.ProjectView)
|
||||||
|
|
||||||
|
projectIDQuery := model.ProjectSearchQuery{Key: proj_model.PROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||||
|
query := view.PrepareGetByQuery(table, projectIDQuery)
|
||||||
|
err := query(db, project)
|
||||||
|
return project, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func ProjectsByResourceOwner(db *gorm.DB, table, orgID string) ([]*model.ProjectView, error) {
|
||||||
|
projects := make([]*model.ProjectView, 0)
|
||||||
|
queries := []*proj_model.ProjectViewSearchQuery{
|
||||||
|
&proj_model.ProjectViewSearchQuery{Key: proj_model.PROJECTSEARCHKEY_RESOURCE_OWNER, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||||
|
}
|
||||||
|
query := view.PrepareSearchQuery(table, model.ProjectSearchRequest{Queries: queries})
|
||||||
|
_, err := query(db, &projects)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return projects, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SearchProjects(db *gorm.DB, table string, req *proj_model.ProjectViewSearchRequest) ([]*model.ProjectView, int, error) {
|
||||||
|
projects := make([]*model.ProjectView, 0)
|
||||||
|
query := view.PrepareSearchQuery(table, model.ProjectSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
|
count, err := query(db, &projects)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
return projects, count, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func PutProject(db *gorm.DB, table string, project *model.ProjectView) error {
|
||||||
|
save := view.PrepareSave(table)
|
||||||
|
return save(db, project)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteProject(db *gorm.DB, table, projectID string) error {
|
||||||
|
delete := view.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.PROJECTSEARCHKEY_PROJECTID), projectID)
|
||||||
|
return delete(db)
|
||||||
|
}
|
109
internal/user/model/user_test.go
Normal file
109
internal/user/model/user_test.go
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsUserValid(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
user *User
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
result bool
|
||||||
|
errFunc func(err error) bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "user with minimal data",
|
||||||
|
args: args{
|
||||||
|
user: &User{
|
||||||
|
Profile: &Profile{
|
||||||
|
UserName: "UserName",
|
||||||
|
FirstName: "FirstName",
|
||||||
|
LastName: "LastName",
|
||||||
|
},
|
||||||
|
Email: &Email{
|
||||||
|
EmailAddress: "Email",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
result: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "user with phone data",
|
||||||
|
args: args{
|
||||||
|
user: &User{
|
||||||
|
Profile: &Profile{
|
||||||
|
UserName: "UserName",
|
||||||
|
FirstName: "FirstName",
|
||||||
|
LastName: "LastName",
|
||||||
|
},
|
||||||
|
Email: &Email{
|
||||||
|
EmailAddress: "Email",
|
||||||
|
},
|
||||||
|
Phone: &Phone{
|
||||||
|
PhoneNumber: "+41711234569",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
result: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "user with address data",
|
||||||
|
args: args{
|
||||||
|
user: &User{
|
||||||
|
Profile: &Profile{
|
||||||
|
UserName: "UserName",
|
||||||
|
FirstName: "FirstName",
|
||||||
|
LastName: "LastName",
|
||||||
|
},
|
||||||
|
Email: &Email{
|
||||||
|
EmailAddress: "Email",
|
||||||
|
},
|
||||||
|
Address: &Address{
|
||||||
|
StreetAddress: "Teufenerstrasse 19",
|
||||||
|
PostalCode: "9000",
|
||||||
|
Locality: "St. Gallen",
|
||||||
|
Country: "Switzerland",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
result: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "user with all data",
|
||||||
|
args: args{
|
||||||
|
user: &User{
|
||||||
|
Profile: &Profile{
|
||||||
|
UserName: "UserName",
|
||||||
|
FirstName: "FirstName",
|
||||||
|
LastName: "LastName",
|
||||||
|
},
|
||||||
|
Email: &Email{
|
||||||
|
EmailAddress: "Email",
|
||||||
|
},
|
||||||
|
Phone: &Phone{
|
||||||
|
PhoneNumber: "+41711234569",
|
||||||
|
},
|
||||||
|
Address: &Address{
|
||||||
|
StreetAddress: "Teufenerstrasse 19",
|
||||||
|
PostalCode: "9000",
|
||||||
|
Locality: "St. Gallen",
|
||||||
|
Country: "Switzerland",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
result: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
isValid := tt.args.user.IsValid()
|
||||||
|
|
||||||
|
if tt.result != isValid {
|
||||||
|
t.Errorf("got wrong result: expected: %v, actual: %v ", tt.result, isValid)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
36
migrations/cockroach/V1.15__management_project_view.sql
Normal file
36
migrations/cockroach/V1.15__management_project_view.sql
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
DROP TABLE management.granted_projects;
|
||||||
|
|
||||||
|
CREATE TABLE management.projects (
|
||||||
|
project_id TEXT,
|
||||||
|
|
||||||
|
creation_date TIMESTAMPTZ,
|
||||||
|
change_date TIMESTAMPTZ,
|
||||||
|
project_name TEXT,
|
||||||
|
project_state SMALLINT,
|
||||||
|
resource_owner TEXT,
|
||||||
|
sequence BIGINT,
|
||||||
|
|
||||||
|
PRIMARY KEY (project_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE management.project_grants (
|
||||||
|
grant_id TEXT,
|
||||||
|
|
||||||
|
creation_date TIMESTAMPTZ,
|
||||||
|
change_date TIMESTAMPTZ,
|
||||||
|
project_id TEXT,
|
||||||
|
project_name TEXT,
|
||||||
|
org_name TEXT,
|
||||||
|
org_domain TEXT,
|
||||||
|
project_state SMALLINT,
|
||||||
|
resource_owner TEXT,
|
||||||
|
org_id TEXT,
|
||||||
|
granted_role_keys TEXT Array,
|
||||||
|
sequence BIGINT,
|
||||||
|
|
||||||
|
PRIMARY KEY (grant_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMIT;
|
@ -255,7 +255,7 @@ var ManagementService_AuthMethods = utils_auth.MethodMapping{
|
|||||||
CheckParam: "",
|
CheckParam: "",
|
||||||
},
|
},
|
||||||
|
|
||||||
"/caos.zitadel.management.api.v1.ManagementService/SearchGrantedProjects": utils_auth.Option{
|
"/caos.zitadel.management.api.v1.ManagementService/SearchProjects": utils_auth.Option{
|
||||||
Permission: "project.read",
|
Permission: "project.read",
|
||||||
CheckParam: "",
|
CheckParam: "",
|
||||||
},
|
},
|
||||||
@ -285,7 +285,12 @@ var ManagementService_AuthMethods = utils_auth.MethodMapping{
|
|||||||
CheckParam: "Id",
|
CheckParam: "Id",
|
||||||
},
|
},
|
||||||
|
|
||||||
"/caos.zitadel.management.api.v1.ManagementService/GetGrantedProjectGrantByID": utils_auth.Option{
|
"/caos.zitadel.management.api.v1.ManagementService/SearchGrantedProjects": utils_auth.Option{
|
||||||
|
Permission: "project.read",
|
||||||
|
CheckParam: "ProjectId",
|
||||||
|
},
|
||||||
|
|
||||||
|
"/caos.zitadel.management.api.v1.ManagementService/GetGrantedProjectByID": utils_auth.Option{
|
||||||
Permission: "project.read",
|
Permission: "project.read",
|
||||||
CheckParam: "",
|
CheckParam: "",
|
||||||
},
|
},
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1292,8 +1292,8 @@ func request_ManagementService_SearchMyOrgMembers_0(ctx context.Context, marshal
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func request_ManagementService_SearchGrantedProjects_0(ctx context.Context, marshaler runtime.Marshaler, client ManagementServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_ManagementService_SearchProjects_0(ctx context.Context, marshaler runtime.Marshaler, client ManagementServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq GrantedProjectSearchRequest
|
var protoReq ProjectSearchRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||||
@ -1304,7 +1304,7 @@ func request_ManagementService_SearchGrantedProjects_0(ctx context.Context, mars
|
|||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := client.SearchGrantedProjects(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
msg, err := client.SearchProjects(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1458,7 +1458,24 @@ func request_ManagementService_ReactivateProject_0(ctx context.Context, marshale
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func request_ManagementService_GetGrantedProjectGrantByID_0(ctx context.Context, marshaler runtime.Marshaler, client ManagementServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_ManagementService_SearchGrantedProjects_0(ctx context.Context, marshaler runtime.Marshaler, client ManagementServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq GrantedProjectSearchRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||||
|
if berr != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||||
|
}
|
||||||
|
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.SearchGrantedProjects(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func request_ManagementService_GetGrantedProjectByID_0(ctx context.Context, marshaler runtime.Marshaler, client ManagementServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq ProjectGrantID
|
var protoReq ProjectGrantID
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
@ -1491,7 +1508,7 @@ func request_ManagementService_GetGrantedProjectGrantByID_0(ctx context.Context,
|
|||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := client.GetGrantedProjectGrantByID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
msg, err := client.GetGrantedProjectByID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -4623,7 +4640,7 @@ func RegisterManagementServiceHandlerClient(ctx context.Context, mux *runtime.Se
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.Handle("POST", pattern_ManagementService_SearchGrantedProjects_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle("POST", pattern_ManagementService_SearchProjects_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
@ -4632,14 +4649,14 @@ func RegisterManagementServiceHandlerClient(ctx context.Context, mux *runtime.Se
|
|||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := request_ManagementService_SearchGrantedProjects_0(rctx, inboundMarshaler, client, req, pathParams)
|
resp, md, err := request_ManagementService_SearchProjects_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
forward_ManagementService_SearchGrantedProjects_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_ManagementService_SearchProjects_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -4743,7 +4760,7 @@ func RegisterManagementServiceHandlerClient(ctx context.Context, mux *runtime.Se
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.Handle("GET", pattern_ManagementService_GetGrantedProjectGrantByID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle("POST", pattern_ManagementService_SearchGrantedProjects_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
@ -4752,14 +4769,34 @@ func RegisterManagementServiceHandlerClient(ctx context.Context, mux *runtime.Se
|
|||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := request_ManagementService_GetGrantedProjectGrantByID_0(rctx, inboundMarshaler, client, req, pathParams)
|
resp, md, err := request_ManagementService_SearchGrantedProjects_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
forward_ManagementService_GetGrantedProjectGrantByID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_ManagementService_SearchGrantedProjects_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_ManagementService_GetGrantedProjectByID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_ManagementService_GetGrantedProjectByID_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_ManagementService_GetGrantedProjectByID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -5869,7 +5906,7 @@ var (
|
|||||||
|
|
||||||
pattern_ManagementService_SearchMyOrgMembers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"orgs", "me", "members", "_search"}, ""))
|
pattern_ManagementService_SearchMyOrgMembers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"orgs", "me", "members", "_search"}, ""))
|
||||||
|
|
||||||
pattern_ManagementService_SearchGrantedProjects_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"grantedprojects", "_search"}, ""))
|
pattern_ManagementService_SearchProjects_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"projects", "_search"}, ""))
|
||||||
|
|
||||||
pattern_ManagementService_ProjectByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"projects", "id"}, ""))
|
pattern_ManagementService_ProjectByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"projects", "id"}, ""))
|
||||||
|
|
||||||
@ -5881,7 +5918,9 @@ var (
|
|||||||
|
|
||||||
pattern_ManagementService_ReactivateProject_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"projects", "id", "_reactivate"}, ""))
|
pattern_ManagementService_ReactivateProject_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"projects", "id", "_reactivate"}, ""))
|
||||||
|
|
||||||
pattern_ManagementService_GetGrantedProjectGrantByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"grantedprojects", "project_id", "grants", "id"}, ""))
|
pattern_ManagementService_SearchGrantedProjects_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"grantedprojects", "_search"}, ""))
|
||||||
|
|
||||||
|
pattern_ManagementService_GetGrantedProjectByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"grantedprojects", "project_id", "grants", "id"}, ""))
|
||||||
|
|
||||||
pattern_ManagementService_GetProjectMemberRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"projects", "members", "roles"}, ""))
|
pattern_ManagementService_GetProjectMemberRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"projects", "members", "roles"}, ""))
|
||||||
|
|
||||||
@ -6087,7 +6126,7 @@ var (
|
|||||||
|
|
||||||
forward_ManagementService_SearchMyOrgMembers_0 = runtime.ForwardResponseMessage
|
forward_ManagementService_SearchMyOrgMembers_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_ManagementService_SearchGrantedProjects_0 = runtime.ForwardResponseMessage
|
forward_ManagementService_SearchProjects_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_ManagementService_ProjectByID_0 = runtime.ForwardResponseMessage
|
forward_ManagementService_ProjectByID_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
@ -6099,7 +6138,9 @@ var (
|
|||||||
|
|
||||||
forward_ManagementService_ReactivateProject_0 = runtime.ForwardResponseMessage
|
forward_ManagementService_ReactivateProject_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_ManagementService_GetGrantedProjectGrantByID_0 = runtime.ForwardResponseMessage
|
forward_ManagementService_SearchGrantedProjects_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_ManagementService_GetGrantedProjectByID_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_ManagementService_GetProjectMemberRoles_0 = runtime.ForwardResponseMessage
|
forward_ManagementService_GetProjectMemberRoles_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
@ -134,13 +134,13 @@
|
|||||||
},
|
},
|
||||||
"/grantedprojects/_search": {
|
"/grantedprojects/_search": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "PROJECTS",
|
"summary": "GRANTED_PROJECT_GRANTS",
|
||||||
"operationId": "SearchGrantedProjects",
|
"operationId": "SearchGrantedProjects",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "A successful response.",
|
"description": "A successful response.",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/v1GrantedProjectSearchResponse"
|
"$ref": "#/definitions/v1ProjectGrantSearchResponse"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -161,13 +161,12 @@
|
|||||||
},
|
},
|
||||||
"/grantedprojects/{project_id}/grants/{id}": {
|
"/grantedprojects/{project_id}/grants/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "GRANTED_PROJECT_GRANTS",
|
"operationId": "GetGrantedProjectByID",
|
||||||
"operationId": "GetGrantedProjectGrantByID",
|
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "A successful response.",
|
"description": "A successful response.",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/v1GrantedProject"
|
"$ref": "#/definitions/v1ProjectGrantView"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -981,6 +980,33 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/projects/_search": {
|
||||||
|
"post": {
|
||||||
|
"summary": "PROJECTS",
|
||||||
|
"operationId": "SearchProjects",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A successful response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/v1ProjectSearchResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "body",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/v1ProjectSearchRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"ManagementService"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/projects/grants/members/roles": {
|
"/projects/grants/members/roles": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "PROJECT_GRANT_MEMBER",
|
"summary": "PROJECT_GRANT_MEMBER",
|
||||||
@ -3765,72 +3791,6 @@
|
|||||||
],
|
],
|
||||||
"default": "GENDER_UNSPECIFIED"
|
"default": "GENDER_UNSPECIFIED"
|
||||||
},
|
},
|
||||||
"v1GrantedProject": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"state": {
|
|
||||||
"$ref": "#/definitions/v1ProjectState"
|
|
||||||
},
|
|
||||||
"change_date": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "date-time"
|
|
||||||
},
|
|
||||||
"creation_date": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "date-time"
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"$ref": "#/definitions/v1ProjectType"
|
|
||||||
},
|
|
||||||
"resource_owner": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"org_id": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"org_name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"org_domain": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"grant_id": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"sequence": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "uint64"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"v1GrantedProjectSearchKey": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"PROJECTSEARCHKEY_UNSPECIFIED",
|
|
||||||
"PROJECTSEARCHKEY_PROJECT_NAME"
|
|
||||||
],
|
|
||||||
"default": "PROJECTSEARCHKEY_UNSPECIFIED"
|
|
||||||
},
|
|
||||||
"v1GrantedProjectSearchQuery": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"key": {
|
|
||||||
"$ref": "#/definitions/v1GrantedProjectSearchKey"
|
|
||||||
},
|
|
||||||
"method": {
|
|
||||||
"$ref": "#/definitions/v1SearchMethod"
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"v1GrantedProjectSearchRequest": {
|
"v1GrantedProjectSearchRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -3845,30 +3805,7 @@
|
|||||||
"queries": {
|
"queries": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/v1GrantedProjectSearchQuery"
|
"$ref": "#/definitions/v1ProjectSearchQuery"
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"v1GrantedProjectSearchResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"offset": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "uint64"
|
|
||||||
},
|
|
||||||
"limit": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "uint64"
|
|
||||||
},
|
|
||||||
"total_result": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "uint64"
|
|
||||||
},
|
|
||||||
"result": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/v1GrantedProject"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5363,6 +5300,70 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"v1ProjectSearchKey": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"PROJECTSEARCHKEY_UNSPECIFIED",
|
||||||
|
"PROJECTSEARCHKEY_PROJECT_NAME"
|
||||||
|
],
|
||||||
|
"default": "PROJECTSEARCHKEY_UNSPECIFIED"
|
||||||
|
},
|
||||||
|
"v1ProjectSearchQuery": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"key": {
|
||||||
|
"$ref": "#/definitions/v1ProjectSearchKey"
|
||||||
|
},
|
||||||
|
"method": {
|
||||||
|
"$ref": "#/definitions/v1SearchMethod"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"v1ProjectSearchRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"offset": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64"
|
||||||
|
},
|
||||||
|
"limit": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64"
|
||||||
|
},
|
||||||
|
"queries": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/v1ProjectSearchQuery"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"v1ProjectSearchResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"offset": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64"
|
||||||
|
},
|
||||||
|
"limit": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64"
|
||||||
|
},
|
||||||
|
"total_result": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64"
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/v1ProjectView"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"v1ProjectState": {
|
"v1ProjectState": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
@ -5372,15 +5373,6 @@
|
|||||||
],
|
],
|
||||||
"default": "PROJECTSTATE_UNSPECIFIED"
|
"default": "PROJECTSTATE_UNSPECIFIED"
|
||||||
},
|
},
|
||||||
"v1ProjectType": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"PROJECTTYPE_UNSPECIFIED",
|
|
||||||
"PROJECTTYPE_OWNED",
|
|
||||||
"PROJECTTYPE_GRANTED"
|
|
||||||
],
|
|
||||||
"default": "PROJECTTYPE_UNSPECIFIED"
|
|
||||||
},
|
|
||||||
"v1ProjectUpdateRequest": {
|
"v1ProjectUpdateRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -5448,6 +5440,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"v1ProjectView": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"project_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"$ref": "#/definitions/v1ProjectState"
|
||||||
|
},
|
||||||
|
"change_date": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"creation_date": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"resource_owner": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"sequence": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"v1SearchMethod": {
|
"v1SearchMethod": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
|
@ -37,24 +37,24 @@ func (m *MockManagementServiceClient) EXPECT() *MockManagementServiceClientMockR
|
|||||||
return m.recorder
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddOrgMember mocks base method
|
// AddMyOrgMember mocks base method
|
||||||
func (m *MockManagementServiceClient) AddOrgMember(arg0 context.Context, arg1 *grpc.AddOrgMemberRequest, arg2 ...grpc0.CallOption) (*grpc.OrgMember, error) {
|
func (m *MockManagementServiceClient) AddMyOrgMember(arg0 context.Context, arg1 *grpc.AddOrgMemberRequest, arg2 ...grpc0.CallOption) (*grpc.OrgMember, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
varargs := []interface{}{arg0, arg1}
|
varargs := []interface{}{arg0, arg1}
|
||||||
for _, a := range arg2 {
|
for _, a := range arg2 {
|
||||||
varargs = append(varargs, a)
|
varargs = append(varargs, a)
|
||||||
}
|
}
|
||||||
ret := m.ctrl.Call(m, "AddOrgMember", varargs...)
|
ret := m.ctrl.Call(m, "AddMyOrgMember", varargs...)
|
||||||
ret0, _ := ret[0].(*grpc.OrgMember)
|
ret0, _ := ret[0].(*grpc.OrgMember)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddOrgMember indicates an expected call of AddOrgMember
|
// AddMyOrgMember indicates an expected call of AddMyOrgMember
|
||||||
func (mr *MockManagementServiceClientMockRecorder) AddOrgMember(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
|
func (mr *MockManagementServiceClientMockRecorder) AddMyOrgMember(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
varargs := append([]interface{}{arg0, arg1}, arg2...)
|
varargs := append([]interface{}{arg0, arg1}, arg2...)
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddOrgMember", reflect.TypeOf((*MockManagementServiceClient)(nil).AddOrgMember), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddMyOrgMember", reflect.TypeOf((*MockManagementServiceClient)(nil).AddMyOrgMember), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddProjectGrantMember mocks base method
|
// AddProjectGrantMember mocks base method
|
||||||
@ -157,24 +157,24 @@ func (mr *MockManagementServiceClientMockRecorder) ApplicationChanges(arg0, arg1
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplicationChanges", reflect.TypeOf((*MockManagementServiceClient)(nil).ApplicationChanges), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplicationChanges", reflect.TypeOf((*MockManagementServiceClient)(nil).ApplicationChanges), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeOrgMember mocks base method
|
// ChangeMyOrgMember mocks base method
|
||||||
func (m *MockManagementServiceClient) ChangeOrgMember(arg0 context.Context, arg1 *grpc.ChangeOrgMemberRequest, arg2 ...grpc0.CallOption) (*grpc.OrgMember, error) {
|
func (m *MockManagementServiceClient) ChangeMyOrgMember(arg0 context.Context, arg1 *grpc.ChangeOrgMemberRequest, arg2 ...grpc0.CallOption) (*grpc.OrgMember, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
varargs := []interface{}{arg0, arg1}
|
varargs := []interface{}{arg0, arg1}
|
||||||
for _, a := range arg2 {
|
for _, a := range arg2 {
|
||||||
varargs = append(varargs, a)
|
varargs = append(varargs, a)
|
||||||
}
|
}
|
||||||
ret := m.ctrl.Call(m, "ChangeOrgMember", varargs...)
|
ret := m.ctrl.Call(m, "ChangeMyOrgMember", varargs...)
|
||||||
ret0, _ := ret[0].(*grpc.OrgMember)
|
ret0, _ := ret[0].(*grpc.OrgMember)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeOrgMember indicates an expected call of ChangeOrgMember
|
// ChangeMyOrgMember indicates an expected call of ChangeMyOrgMember
|
||||||
func (mr *MockManagementServiceClientMockRecorder) ChangeOrgMember(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
|
func (mr *MockManagementServiceClientMockRecorder) ChangeMyOrgMember(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
varargs := append([]interface{}{arg0, arg1}, arg2...)
|
varargs := append([]interface{}{arg0, arg1}, arg2...)
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChangeOrgMember", reflect.TypeOf((*MockManagementServiceClient)(nil).ChangeOrgMember), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChangeMyOrgMember", reflect.TypeOf((*MockManagementServiceClient)(nil).ChangeMyOrgMember), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeProjectGrantMember mocks base method
|
// ChangeProjectGrantMember mocks base method
|
||||||
@ -717,24 +717,24 @@ func (mr *MockManagementServiceClientMockRecorder) DeleteUser(arg0, arg1 interfa
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteUser", reflect.TypeOf((*MockManagementServiceClient)(nil).DeleteUser), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteUser", reflect.TypeOf((*MockManagementServiceClient)(nil).DeleteUser), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGrantedProjectGrantByID mocks base method
|
// GetGrantedProjectByID mocks base method
|
||||||
func (m *MockManagementServiceClient) GetGrantedProjectGrantByID(arg0 context.Context, arg1 *grpc.ProjectGrantID, arg2 ...grpc0.CallOption) (*grpc.ProjectGrant, error) {
|
func (m *MockManagementServiceClient) GetGrantedProjectByID(arg0 context.Context, arg1 *grpc.ProjectGrantID, arg2 ...grpc0.CallOption) (*grpc.ProjectGrantView, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
varargs := []interface{}{arg0, arg1}
|
varargs := []interface{}{arg0, arg1}
|
||||||
for _, a := range arg2 {
|
for _, a := range arg2 {
|
||||||
varargs = append(varargs, a)
|
varargs = append(varargs, a)
|
||||||
}
|
}
|
||||||
ret := m.ctrl.Call(m, "GetGrantedProjectGrantByID", varargs...)
|
ret := m.ctrl.Call(m, "GetGrantedProjectByID", varargs...)
|
||||||
ret0, _ := ret[0].(*grpc.ProjectGrant)
|
ret0, _ := ret[0].(*grpc.ProjectGrantView)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGrantedProjectGrantByID indicates an expected call of GetGrantedProjectGrantByID
|
// GetGrantedProjectByID indicates an expected call of GetGrantedProjectByID
|
||||||
func (mr *MockManagementServiceClientMockRecorder) GetGrantedProjectGrantByID(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
|
func (mr *MockManagementServiceClientMockRecorder) GetGrantedProjectByID(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
varargs := append([]interface{}{arg0, arg1}, arg2...)
|
varargs := append([]interface{}{arg0, arg1}, arg2...)
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGrantedProjectGrantByID", reflect.TypeOf((*MockManagementServiceClient)(nil).GetGrantedProjectGrantByID), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGrantedProjectByID", reflect.TypeOf((*MockManagementServiceClient)(nil).GetGrantedProjectByID), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrgByDomainGlobal mocks base method
|
// GetOrgByDomainGlobal mocks base method
|
||||||
@ -1437,24 +1437,24 @@ func (mr *MockManagementServiceClientMockRecorder) RemoveApplication(arg0, arg1
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveApplication", reflect.TypeOf((*MockManagementServiceClient)(nil).RemoveApplication), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveApplication", reflect.TypeOf((*MockManagementServiceClient)(nil).RemoveApplication), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveOrgMember mocks base method
|
// RemoveMyOrgMember mocks base method
|
||||||
func (m *MockManagementServiceClient) RemoveOrgMember(arg0 context.Context, arg1 *grpc.RemoveOrgMemberRequest, arg2 ...grpc0.CallOption) (*emptypb.Empty, error) {
|
func (m *MockManagementServiceClient) RemoveMyOrgMember(arg0 context.Context, arg1 *grpc.RemoveOrgMemberRequest, arg2 ...grpc0.CallOption) (*emptypb.Empty, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
varargs := []interface{}{arg0, arg1}
|
varargs := []interface{}{arg0, arg1}
|
||||||
for _, a := range arg2 {
|
for _, a := range arg2 {
|
||||||
varargs = append(varargs, a)
|
varargs = append(varargs, a)
|
||||||
}
|
}
|
||||||
ret := m.ctrl.Call(m, "RemoveOrgMember", varargs...)
|
ret := m.ctrl.Call(m, "RemoveMyOrgMember", varargs...)
|
||||||
ret0, _ := ret[0].(*emptypb.Empty)
|
ret0, _ := ret[0].(*emptypb.Empty)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveOrgMember indicates an expected call of RemoveOrgMember
|
// RemoveMyOrgMember indicates an expected call of RemoveMyOrgMember
|
||||||
func (mr *MockManagementServiceClientMockRecorder) RemoveOrgMember(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
|
func (mr *MockManagementServiceClientMockRecorder) RemoveMyOrgMember(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
varargs := append([]interface{}{arg0, arg1}, arg2...)
|
varargs := append([]interface{}{arg0, arg1}, arg2...)
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveOrgMember", reflect.TypeOf((*MockManagementServiceClient)(nil).RemoveOrgMember), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveMyOrgMember", reflect.TypeOf((*MockManagementServiceClient)(nil).RemoveMyOrgMember), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveProjectGrant mocks base method
|
// RemoveProjectGrant mocks base method
|
||||||
@ -1638,14 +1638,14 @@ func (mr *MockManagementServiceClientMockRecorder) SearchAuthGrant(arg0, arg1 in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SearchGrantedProjects mocks base method
|
// SearchGrantedProjects mocks base method
|
||||||
func (m *MockManagementServiceClient) SearchGrantedProjects(arg0 context.Context, arg1 *grpc.GrantedProjectSearchRequest, arg2 ...grpc0.CallOption) (*grpc.GrantedProjectSearchResponse, error) {
|
func (m *MockManagementServiceClient) SearchGrantedProjects(arg0 context.Context, arg1 *grpc.GrantedProjectSearchRequest, arg2 ...grpc0.CallOption) (*grpc.ProjectGrantSearchResponse, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
varargs := []interface{}{arg0, arg1}
|
varargs := []interface{}{arg0, arg1}
|
||||||
for _, a := range arg2 {
|
for _, a := range arg2 {
|
||||||
varargs = append(varargs, a)
|
varargs = append(varargs, a)
|
||||||
}
|
}
|
||||||
ret := m.ctrl.Call(m, "SearchGrantedProjects", varargs...)
|
ret := m.ctrl.Call(m, "SearchGrantedProjects", varargs...)
|
||||||
ret0, _ := ret[0].(*grpc.GrantedProjectSearchResponse)
|
ret0, _ := ret[0].(*grpc.ProjectGrantSearchResponse)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
@ -1657,24 +1657,24 @@ func (mr *MockManagementServiceClientMockRecorder) SearchGrantedProjects(arg0, a
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchGrantedProjects", reflect.TypeOf((*MockManagementServiceClient)(nil).SearchGrantedProjects), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchGrantedProjects", reflect.TypeOf((*MockManagementServiceClient)(nil).SearchGrantedProjects), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchOrgMembers mocks base method
|
// SearchMyOrgMembers mocks base method
|
||||||
func (m *MockManagementServiceClient) SearchOrgMembers(arg0 context.Context, arg1 *grpc.OrgMemberSearchRequest, arg2 ...grpc0.CallOption) (*grpc.OrgMemberSearchResponse, error) {
|
func (m *MockManagementServiceClient) SearchMyOrgMembers(arg0 context.Context, arg1 *grpc.OrgMemberSearchRequest, arg2 ...grpc0.CallOption) (*grpc.OrgMemberSearchResponse, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
varargs := []interface{}{arg0, arg1}
|
varargs := []interface{}{arg0, arg1}
|
||||||
for _, a := range arg2 {
|
for _, a := range arg2 {
|
||||||
varargs = append(varargs, a)
|
varargs = append(varargs, a)
|
||||||
}
|
}
|
||||||
ret := m.ctrl.Call(m, "SearchOrgMembers", varargs...)
|
ret := m.ctrl.Call(m, "SearchMyOrgMembers", varargs...)
|
||||||
ret0, _ := ret[0].(*grpc.OrgMemberSearchResponse)
|
ret0, _ := ret[0].(*grpc.OrgMemberSearchResponse)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchOrgMembers indicates an expected call of SearchOrgMembers
|
// SearchMyOrgMembers indicates an expected call of SearchMyOrgMembers
|
||||||
func (mr *MockManagementServiceClientMockRecorder) SearchOrgMembers(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
|
func (mr *MockManagementServiceClientMockRecorder) SearchMyOrgMembers(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
varargs := append([]interface{}{arg0, arg1}, arg2...)
|
varargs := append([]interface{}{arg0, arg1}, arg2...)
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchOrgMembers", reflect.TypeOf((*MockManagementServiceClient)(nil).SearchOrgMembers), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchMyOrgMembers", reflect.TypeOf((*MockManagementServiceClient)(nil).SearchMyOrgMembers), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchProjectGrantMembers mocks base method
|
// SearchProjectGrantMembers mocks base method
|
||||||
@ -1797,6 +1797,26 @@ func (mr *MockManagementServiceClientMockRecorder) SearchProjectUserGrants(arg0,
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchProjectUserGrants", reflect.TypeOf((*MockManagementServiceClient)(nil).SearchProjectUserGrants), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchProjectUserGrants", reflect.TypeOf((*MockManagementServiceClient)(nil).SearchProjectUserGrants), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SearchProjects mocks base method
|
||||||
|
func (m *MockManagementServiceClient) SearchProjects(arg0 context.Context, arg1 *grpc.ProjectSearchRequest, arg2 ...grpc0.CallOption) (*grpc.ProjectSearchResponse, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
varargs := []interface{}{arg0, arg1}
|
||||||
|
for _, a := range arg2 {
|
||||||
|
varargs = append(varargs, a)
|
||||||
|
}
|
||||||
|
ret := m.ctrl.Call(m, "SearchProjects", varargs...)
|
||||||
|
ret0, _ := ret[0].(*grpc.ProjectSearchResponse)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// SearchProjects indicates an expected call of SearchProjects
|
||||||
|
func (mr *MockManagementServiceClientMockRecorder) SearchProjects(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
varargs := append([]interface{}{arg0, arg1}, arg2...)
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchProjects", reflect.TypeOf((*MockManagementServiceClient)(nil).SearchProjects), varargs...)
|
||||||
|
}
|
||||||
|
|
||||||
// SearchUserGrants mocks base method
|
// SearchUserGrants mocks base method
|
||||||
func (m *MockManagementServiceClient) SearchUserGrants(arg0 context.Context, arg1 *grpc.UserGrantSearchRequest, arg2 ...grpc0.CallOption) (*grpc.UserGrantSearchResponse, error) {
|
func (m *MockManagementServiceClient) SearchUserGrants(arg0 context.Context, arg1 *grpc.UserGrantSearchRequest, arg2 ...grpc0.CallOption) (*grpc.UserGrantSearchResponse, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
@ -47,15 +47,14 @@ func (s *Server) ReactivateProject(ctx context.Context, in *ProjectID) (*Project
|
|||||||
return projectFromModel(project), nil
|
return projectFromModel(project), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) SearchGrantedProjects(ctx context.Context, in *GrantedProjectSearchRequest) (*GrantedProjectSearchResponse, error) {
|
func (s *Server) SearchProjects(ctx context.Context, in *ProjectSearchRequest) (*ProjectSearchResponse, error) {
|
||||||
request := grantedProjectSearchRequestsToModel(in)
|
request := projectSearchRequestsToModel(in)
|
||||||
orgID := grpc_util.GetHeader(ctx, api.ZitadelOrgID)
|
request.AppendMyResourceOwnerQuery(grpc_util.GetHeader(ctx, api.ZitadelOrgID))
|
||||||
request.AppendMyOrgQuery(orgID)
|
response, err := s.project.SearchProjects(ctx, request)
|
||||||
response, err := s.project.SearchGrantedProjects(ctx, request)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return grantedProjectSearchResponseFromModel(response), nil
|
return projectSearchResponseFromModel(response), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) ProjectByID(ctx context.Context, id *ProjectID) (*Project, error) {
|
func (s *Server) ProjectByID(ctx context.Context, id *ProjectID) (*Project, error) {
|
||||||
@ -66,12 +65,22 @@ func (s *Server) ProjectByID(ctx context.Context, id *ProjectID) (*Project, erro
|
|||||||
return projectFromModel(project), nil
|
return projectFromModel(project), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) GetGrantedProjectGrantByID(ctx context.Context, in *ProjectGrantID) (*GrantedProject, error) {
|
func (s *Server) SearchGrantedProjects(ctx context.Context, in *GrantedProjectSearchRequest) (*ProjectGrantSearchResponse, error) {
|
||||||
project, err := s.project.GetGrantedProjectGrantByIDs(ctx, in.ProjectId, in.Id)
|
request := grantedProjectSearchRequestsToModel(in)
|
||||||
|
request.AppendMyOrgQuery(grpc_util.GetHeader(ctx, api.ZitadelOrgID))
|
||||||
|
response, err := s.project.SearchProjectGrants(ctx, request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return grantedProjectFromModel(project), nil
|
return projectGrantSearchResponseFromModel(response), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) GetGrantedProjectByID(ctx context.Context, in *ProjectGrantID) (*ProjectGrantView, error) {
|
||||||
|
project, err := s.project.ProjectGrantViewByID(ctx, in.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return projectGrantFromGrantedProjectModel(project), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) AddProjectRole(ctx context.Context, in *ProjectRoleAdd) (*ProjectRole, error) {
|
func (s *Server) AddProjectRole(ctx context.Context, in *ProjectRoleAdd) (*ProjectRole, error) {
|
||||||
|
@ -24,43 +24,38 @@ func projectFromModel(project *proj_model.Project) *Project {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func grantedProjectSearchResponseFromModel(response *proj_model.GrantedProjectSearchResponse) *GrantedProjectSearchResponse {
|
func projectSearchResponseFromModel(response *proj_model.ProjectViewSearchResponse) *ProjectSearchResponse {
|
||||||
return &GrantedProjectSearchResponse{
|
return &ProjectSearchResponse{
|
||||||
Offset: response.Offset,
|
Offset: response.Offset,
|
||||||
Limit: response.Limit,
|
Limit: response.Limit,
|
||||||
TotalResult: response.TotalResult,
|
TotalResult: response.TotalResult,
|
||||||
Result: grantedProjectsFromModel(response.Result),
|
Result: projectViewsFromModel(response.Result),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func grantedProjectsFromModel(projects []*proj_model.GrantedProjectView) []*GrantedProject {
|
func projectViewsFromModel(projects []*proj_model.ProjectView) []*ProjectView {
|
||||||
converted := make([]*GrantedProject, len(projects))
|
converted := make([]*ProjectView, len(projects))
|
||||||
for i, project := range projects {
|
for i, project := range projects {
|
||||||
converted[i] = grantedProjectFromModel(project)
|
converted[i] = projectViewFromModel(project)
|
||||||
}
|
}
|
||||||
return converted
|
return converted
|
||||||
}
|
}
|
||||||
|
|
||||||
func grantedProjectFromModel(project *proj_model.GrantedProjectView) *GrantedProject {
|
func projectViewFromModel(project *proj_model.ProjectView) *ProjectView {
|
||||||
creationDate, err := ptypes.TimestampProto(project.CreationDate)
|
creationDate, err := ptypes.TimestampProto(project.CreationDate)
|
||||||
logging.Log("GRPC-dlso3").OnError(err).Debug("unable to parse timestamp")
|
logging.Log("GRPC-dlso3").OnError(err).Debug("unable to parse timestamp")
|
||||||
|
|
||||||
changeDate, err := ptypes.TimestampProto(project.ChangeDate)
|
changeDate, err := ptypes.TimestampProto(project.ChangeDate)
|
||||||
logging.Log("GRPC-sope3").OnError(err).Debug("unable to parse timestamp")
|
logging.Log("GRPC-sope3").OnError(err).Debug("unable to parse timestamp")
|
||||||
|
|
||||||
return &GrantedProject{
|
return &ProjectView{
|
||||||
Id: project.ProjectID,
|
ProjectId: project.ProjectID,
|
||||||
State: projectStateFromModel(project.State),
|
State: projectStateFromModel(project.State),
|
||||||
CreationDate: creationDate,
|
CreationDate: creationDate,
|
||||||
ChangeDate: changeDate,
|
ChangeDate: changeDate,
|
||||||
Name: project.Name,
|
Name: project.Name,
|
||||||
Sequence: project.Sequence,
|
Sequence: project.Sequence,
|
||||||
ResourceOwner: project.ResourceOwner,
|
ResourceOwner: project.ResourceOwner,
|
||||||
OrgId: project.OrgID,
|
|
||||||
OrgName: project.OrgName,
|
|
||||||
OrgDomain: project.OrgDomain,
|
|
||||||
GrantId: project.GrantID,
|
|
||||||
Type: projectTypeFromModel(project.Type),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,17 +101,6 @@ func projectStateFromModel(state proj_model.ProjectState) ProjectState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func projectTypeFromModel(projecttype proj_model.ProjectType) ProjectType {
|
|
||||||
switch projecttype {
|
|
||||||
case proj_model.PROJECTTYPE_OWNED:
|
|
||||||
return ProjectType_PROJECTTYPE_OWNED
|
|
||||||
case proj_model.PROJECTTYPE_GRANTED:
|
|
||||||
return ProjectType_PROJECTTYPE_GRANTED
|
|
||||||
default:
|
|
||||||
return ProjectType_PROJECTTYPE_UNSPECIFIED
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func projectUpdateToModel(project *ProjectUpdateRequest) *proj_model.Project {
|
func projectUpdateToModel(project *ProjectUpdateRequest) *proj_model.Project {
|
||||||
return &proj_model.Project{
|
return &proj_model.Project{
|
||||||
ObjectRoot: models.ObjectRoot{
|
ObjectRoot: models.ObjectRoot{
|
||||||
@ -165,33 +149,65 @@ func projectRoleChangeToModel(role *ProjectRoleChange) *proj_model.ProjectRole {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func grantedProjectSearchRequestsToModel(project *GrantedProjectSearchRequest) *proj_model.GrantedProjectSearchRequest {
|
func projectSearchRequestsToModel(project *ProjectSearchRequest) *proj_model.ProjectViewSearchRequest {
|
||||||
return &proj_model.GrantedProjectSearchRequest{
|
return &proj_model.ProjectViewSearchRequest{
|
||||||
Offset: project.Offset,
|
Offset: project.Offset,
|
||||||
Limit: project.Limit,
|
Limit: project.Limit,
|
||||||
Queries: grantedProjectSearchQueriesToModel(project.Queries),
|
Queries: projectSearchQueriesToModel(project.Queries),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func grantedProjectSearchRequestsToModel(request *GrantedProjectSearchRequest) *proj_model.ProjectGrantViewSearchRequest {
|
||||||
|
return &proj_model.ProjectGrantViewSearchRequest{
|
||||||
|
Offset: request.Offset,
|
||||||
|
Limit: request.Limit,
|
||||||
|
Queries: grantedPRojectSearchQueriesToModel(request.Queries),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func grantedProjectSearchQueriesToModel(queries []*GrantedProjectSearchQuery) []*proj_model.GrantedProjectSearchQuery {
|
func projectSearchQueriesToModel(queries []*ProjectSearchQuery) []*proj_model.ProjectViewSearchQuery {
|
||||||
converted := make([]*proj_model.GrantedProjectSearchQuery, len(queries))
|
converted := make([]*proj_model.ProjectViewSearchQuery, len(queries))
|
||||||
for i, q := range queries {
|
for i, q := range queries {
|
||||||
converted[i] = grantedProjectSearchQueryToModel(q)
|
converted[i] = projectSearchQueryToModel(q)
|
||||||
}
|
}
|
||||||
return converted
|
return converted
|
||||||
}
|
}
|
||||||
|
|
||||||
func grantedProjectSearchQueryToModel(query *GrantedProjectSearchQuery) *proj_model.GrantedProjectSearchQuery {
|
func projectSearchQueryToModel(query *ProjectSearchQuery) *proj_model.ProjectViewSearchQuery {
|
||||||
return &proj_model.GrantedProjectSearchQuery{
|
return &proj_model.ProjectViewSearchQuery{
|
||||||
Key: projectSearchKeyToModel(query.Key),
|
Key: projectSearchKeyToModel(query.Key),
|
||||||
Method: searchMethodToModel(query.Method),
|
Method: searchMethodToModel(query.Method),
|
||||||
Value: query.Value,
|
Value: query.Value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func projectSearchKeyToModel(key GrantedProjectSearchKey) proj_model.GrantedProjectSearchKey {
|
func projectSearchKeyToModel(key ProjectSearchKey) proj_model.ProjectViewSearchKey {
|
||||||
switch key {
|
switch key {
|
||||||
case GrantedProjectSearchKey_PROJECTSEARCHKEY_PROJECT_NAME:
|
case ProjectSearchKey_PROJECTSEARCHKEY_PROJECT_NAME:
|
||||||
|
return proj_model.PROJECTSEARCHKEY_NAME
|
||||||
|
default:
|
||||||
|
return proj_model.PROJECTSEARCHKEY_UNSPECIFIED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func grantedPRojectSearchQueriesToModel(queries []*ProjectSearchQuery) []*proj_model.ProjectGrantViewSearchQuery {
|
||||||
|
converted := make([]*proj_model.ProjectGrantViewSearchQuery, len(queries))
|
||||||
|
for i, q := range queries {
|
||||||
|
converted[i] = grantedProjectSearchQueryToModel(q)
|
||||||
|
}
|
||||||
|
return converted
|
||||||
|
}
|
||||||
|
|
||||||
|
func grantedProjectSearchQueryToModel(query *ProjectSearchQuery) *proj_model.ProjectGrantViewSearchQuery {
|
||||||
|
return &proj_model.ProjectGrantViewSearchQuery{
|
||||||
|
Key: projectGrantSearchKeyToModel(query.Key),
|
||||||
|
Method: searchMethodToModel(query.Method),
|
||||||
|
Value: query.Value,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func projectGrantSearchKeyToModel(key ProjectSearchKey) proj_model.ProjectGrantViewSearchKey {
|
||||||
|
switch key {
|
||||||
|
case ProjectSearchKey_PROJECTSEARCHKEY_PROJECT_NAME:
|
||||||
return proj_model.GRANTEDPROJECTSEARCHKEY_NAME
|
return proj_model.GRANTEDPROJECTSEARCHKEY_NAME
|
||||||
default:
|
default:
|
||||||
return proj_model.GRANTEDPROJECTSEARCHKEY_UNSPECIFIED
|
return proj_model.GRANTEDPROJECTSEARCHKEY_UNSPECIFIED
|
||||||
|
@ -13,7 +13,7 @@ func (s *Server) SearchProjectGrants(ctx context.Context, in *ProjectGrantSearch
|
|||||||
orgID := grpc_util.GetHeader(ctx, api.ZitadelOrgID)
|
orgID := grpc_util.GetHeader(ctx, api.ZitadelOrgID)
|
||||||
request.AppendMyResourceOwnerQuery(orgID)
|
request.AppendMyResourceOwnerQuery(orgID)
|
||||||
request.AppendNotMyOrgQuery(orgID)
|
request.AppendNotMyOrgQuery(orgID)
|
||||||
response, err := s.project.SearchGrantedProjects(ctx, request)
|
response, err := s.project.SearchProjectGrants(ctx, request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -47,24 +47,24 @@ func projectGrantUpdateToModel(grant *ProjectGrantUpdate) *proj_model.ProjectGra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func projectGrantSearchRequestsToModel(request *ProjectGrantSearchRequest) *proj_model.GrantedProjectSearchRequest {
|
func projectGrantSearchRequestsToModel(request *ProjectGrantSearchRequest) *proj_model.ProjectGrantViewSearchRequest {
|
||||||
return &proj_model.GrantedProjectSearchRequest{
|
return &proj_model.ProjectGrantViewSearchRequest{
|
||||||
Offset: request.Offset,
|
Offset: request.Offset,
|
||||||
Limit: request.Limit,
|
Limit: request.Limit,
|
||||||
Queries: projectGrantSearchQueriesToModel(request.ProjectId),
|
Queries: projectGrantSearchQueriesToModel(request.ProjectId),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func projectGrantSearchQueriesToModel(projectId string) []*proj_model.GrantedProjectSearchQuery {
|
func projectGrantSearchQueriesToModel(projectId string) []*proj_model.ProjectGrantViewSearchQuery {
|
||||||
converted := make([]*proj_model.GrantedProjectSearchQuery, 0)
|
converted := make([]*proj_model.ProjectGrantViewSearchQuery, 0)
|
||||||
return append(converted, &proj_model.GrantedProjectSearchQuery{
|
return append(converted, &proj_model.ProjectGrantViewSearchQuery{
|
||||||
Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID,
|
Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID,
|
||||||
Method: model.SEARCHMETHOD_EQUALS,
|
Method: model.SEARCHMETHOD_EQUALS,
|
||||||
Value: projectId,
|
Value: projectId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func projectGrantSearchResponseFromModel(response *proj_model.GrantedProjectSearchResponse) *ProjectGrantSearchResponse {
|
func projectGrantSearchResponseFromModel(response *proj_model.ProjectGrantViewSearchResponse) *ProjectGrantSearchResponse {
|
||||||
return &ProjectGrantSearchResponse{
|
return &ProjectGrantSearchResponse{
|
||||||
Offset: response.Offset,
|
Offset: response.Offset,
|
||||||
Limit: response.Limit,
|
Limit: response.Limit,
|
||||||
@ -73,7 +73,7 @@ func projectGrantSearchResponseFromModel(response *proj_model.GrantedProjectSear
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func projectGrantsFromGrantedProjectModel(projects []*proj_model.GrantedProjectView) []*ProjectGrantView {
|
func projectGrantsFromGrantedProjectModel(projects []*proj_model.ProjectGrantView) []*ProjectGrantView {
|
||||||
converted := make([]*ProjectGrantView, len(projects))
|
converted := make([]*ProjectGrantView, len(projects))
|
||||||
for i, project := range projects {
|
for i, project := range projects {
|
||||||
converted[i] = projectGrantFromGrantedProjectModel(project)
|
converted[i] = projectGrantFromGrantedProjectModel(project)
|
||||||
@ -81,7 +81,7 @@ func projectGrantsFromGrantedProjectModel(projects []*proj_model.GrantedProjectV
|
|||||||
return converted
|
return converted
|
||||||
}
|
}
|
||||||
|
|
||||||
func projectGrantFromGrantedProjectModel(project *proj_model.GrantedProjectView) *ProjectGrantView {
|
func projectGrantFromGrantedProjectModel(project *proj_model.ProjectGrantView) *ProjectGrantView {
|
||||||
creationDate, err := ptypes.TimestampProto(project.CreationDate)
|
creationDate, err := ptypes.TimestampProto(project.CreationDate)
|
||||||
logging.Log("GRPC-dlso3").OnError(err).Debug("unable to parse timestamp")
|
logging.Log("GRPC-dlso3").OnError(err).Debug("unable to parse timestamp")
|
||||||
|
|
||||||
|
@ -571,9 +571,9 @@ service ManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//PROJECTS
|
//PROJECTS
|
||||||
rpc SearchGrantedProjects(GrantedProjectSearchRequest) returns (GrantedProjectSearchResponse) {
|
rpc SearchProjects(ProjectSearchRequest) returns (ProjectSearchResponse) {
|
||||||
option (google.api.http) = {
|
option (google.api.http) = {
|
||||||
post: "/grantedprojects/_search"
|
post: "/projects/_search"
|
||||||
body: "*"
|
body: "*"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -641,7 +641,19 @@ service ManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//GRANTED_PROJECT_GRANTS
|
//GRANTED_PROJECT_GRANTS
|
||||||
rpc GetGrantedProjectGrantByID(ProjectGrantID) returns (GrantedProject) {
|
rpc SearchGrantedProjects(GrantedProjectSearchRequest) returns (ProjectGrantSearchResponse) {
|
||||||
|
option (google.api.http) = {
|
||||||
|
post: "/grantedprojects/_search"
|
||||||
|
body: "*"
|
||||||
|
};
|
||||||
|
|
||||||
|
option (caos.zitadel.utils.v1.auth_option) = {
|
||||||
|
permission: "project.read"
|
||||||
|
check_field_name: "ProjectId"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
rpc GetGrantedProjectByID(ProjectGrantID) returns (ProjectGrantView) {
|
||||||
option (google.api.http) = {
|
option (google.api.http) = {
|
||||||
get: "/grantedprojects/{project_id}/grants/{id}"
|
get: "/grantedprojects/{project_id}/grants/{id}"
|
||||||
};
|
};
|
||||||
@ -1718,6 +1730,41 @@ message ProjectUpdateRequest {
|
|||||||
string name = 2 [(validate.rules).string = {min_len: 1, max_len: 200}];
|
string name = 2 [(validate.rules).string = {min_len: 1, max_len: 200}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ProjectSearchResponse {
|
||||||
|
uint64 offset = 1;
|
||||||
|
uint64 limit = 2;
|
||||||
|
uint64 total_result = 3;
|
||||||
|
repeated ProjectView result = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ProjectView {
|
||||||
|
string project_id = 1;
|
||||||
|
string name = 2;
|
||||||
|
ProjectState state = 3;
|
||||||
|
google.protobuf.Timestamp change_date = 4;
|
||||||
|
google.protobuf.Timestamp creation_date = 5;
|
||||||
|
string resource_owner = 6;
|
||||||
|
uint64 sequence = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message ProjectSearchRequest {
|
||||||
|
uint64 offset = 1;
|
||||||
|
uint64 limit = 2;
|
||||||
|
repeated ProjectSearchQuery queries = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ProjectSearchQuery {
|
||||||
|
ProjectSearchKey key = 1 [(validate.rules).enum = {not_in: [0]}];
|
||||||
|
SearchMethod method = 2;
|
||||||
|
string value = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ProjectSearchKey {
|
||||||
|
PROJECTSEARCHKEY_UNSPECIFIED = 0;
|
||||||
|
PROJECTSEARCHKEY_PROJECT_NAME = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message Projects {
|
message Projects {
|
||||||
repeated Project projects = 1;
|
repeated Project projects = 1;
|
||||||
}
|
}
|
||||||
@ -1743,45 +1790,6 @@ enum ProjectType {
|
|||||||
PROJECTTYPE_GRANTED = 2;
|
PROJECTTYPE_GRANTED = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GrantedProjectSearchResponse {
|
|
||||||
uint64 offset = 1;
|
|
||||||
uint64 limit = 2;
|
|
||||||
uint64 total_result = 3;
|
|
||||||
repeated GrantedProject result = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GrantedProject {
|
|
||||||
string id = 1;
|
|
||||||
string name = 2;
|
|
||||||
ProjectState state = 3;
|
|
||||||
google.protobuf.Timestamp change_date = 4;
|
|
||||||
google.protobuf.Timestamp creation_date = 5;
|
|
||||||
ProjectType type = 6;
|
|
||||||
string resource_owner = 7;
|
|
||||||
string org_id = 8;
|
|
||||||
string org_name = 9;
|
|
||||||
string org_domain = 10;
|
|
||||||
string grant_id = 11;
|
|
||||||
uint64 sequence = 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GrantedProjectSearchRequest {
|
|
||||||
uint64 offset = 1;
|
|
||||||
uint64 limit = 2;
|
|
||||||
repeated GrantedProjectSearchQuery queries = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GrantedProjectSearchQuery {
|
|
||||||
GrantedProjectSearchKey key = 1 [(validate.rules).enum = {not_in: [0]}];
|
|
||||||
SearchMethod method = 2;
|
|
||||||
string value = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum GrantedProjectSearchKey {
|
|
||||||
PROJECTSEARCHKEY_UNSPECIFIED = 0;
|
|
||||||
PROJECTSEARCHKEY_PROJECT_NAME = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ProjectMemberRoles {
|
message ProjectMemberRoles {
|
||||||
repeated string roles = 1;
|
repeated string roles = 1;
|
||||||
}
|
}
|
||||||
@ -2099,6 +2107,12 @@ message ProjectGrantSearchRequest {
|
|||||||
uint64 limit = 3;
|
uint64 limit = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GrantedProjectSearchRequest {
|
||||||
|
uint64 offset = 1;
|
||||||
|
uint64 limit = 2;
|
||||||
|
repeated ProjectSearchQuery queries = 3;
|
||||||
|
}
|
||||||
|
|
||||||
message ProjectGrantMemberRoles {
|
message ProjectGrantMemberRoles {
|
||||||
repeated string roles = 1;
|
repeated string roles = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user