mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-08 17:37:41 +00:00
feat: administrator (#271)
* feat: get views and failed events * feat: get views and failed events * feat: get views and failed events * Update internal/view/repository/sequence.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/view/repository/general_query.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
parent
b88f200434
commit
8bfa1a083c
13
internal/admin/repository/administrator.go
Normal file
13
internal/admin/repository/administrator.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/caos/zitadel/internal/view/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AdministratorRepository interface {
|
||||||
|
GetFailedEvents(context.Context) ([]*model.FailedEvent, error)
|
||||||
|
RemoveFailedEvent(context.Context, *model.FailedEvent) error
|
||||||
|
GetViews(context.Context) ([]*model.View, error)
|
||||||
|
ClearView(ctx context.Context, db, view string) error
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package eventstore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/caos/zitadel/internal/admin/repository/eventsourcing/view"
|
||||||
|
view_model "github.com/caos/zitadel/internal/view/model"
|
||||||
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
|
)
|
||||||
|
|
||||||
|
var dbList = []string{"management", "auth", "authz", "admin_api", "notification"}
|
||||||
|
|
||||||
|
type AdministratorRepo struct {
|
||||||
|
View *view.View
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repo *AdministratorRepo) GetFailedEvents(ctx context.Context) ([]*view_model.FailedEvent, error) {
|
||||||
|
allFailedEvents := make([]*view_model.FailedEvent, 0)
|
||||||
|
for _, db := range dbList {
|
||||||
|
failedEvents, err := repo.View.AllFailedEvents(db)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, failedEvent := range failedEvents {
|
||||||
|
allFailedEvents = append(allFailedEvents, repository.FailedEventToModel(failedEvent))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return allFailedEvents, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repo *AdministratorRepo) RemoveFailedEvent(ctx context.Context, failedEvent *view_model.FailedEvent) error {
|
||||||
|
return repo.View.RemoveFailedEvent(failedEvent.Database, repository.FailedEventFromModel(failedEvent))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repo *AdministratorRepo) GetViews(ctx context.Context) ([]*view_model.View, error) {
|
||||||
|
views := make([]*view_model.View, 0)
|
||||||
|
for _, db := range dbList {
|
||||||
|
sequences, err := repo.View.AllCurrentSequences(db)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, sequence := range sequences {
|
||||||
|
views = append(views, repository.CurrentSequenceToModel(sequence))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return views, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repo *AdministratorRepo) ClearView(ctx context.Context, database, view string) error {
|
||||||
|
return repo.View.ClearView(database, view)
|
||||||
|
}
|
@ -30,6 +30,7 @@ type Config struct {
|
|||||||
type EsRepository struct {
|
type EsRepository struct {
|
||||||
spooler *es_spol.Spooler
|
spooler *es_spol.Spooler
|
||||||
eventstore.OrgRepo
|
eventstore.OrgRepo
|
||||||
|
eventstore.AdministratorRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults) (*EsRepository, error) {
|
func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults) (*EsRepository, error) {
|
||||||
@ -95,6 +96,9 @@ func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults) (
|
|||||||
View: view,
|
View: view,
|
||||||
SearchLimit: conf.SearchLimit,
|
SearchLimit: conf.SearchLimit,
|
||||||
},
|
},
|
||||||
|
AdministratorRepo: eventstore.AdministratorRepo{
|
||||||
|
View: view,
|
||||||
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,25 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
errTable = "admin_api.failed_event"
|
errTable = "admin_api.failed_event"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (v *View) saveFailedEvent(failedEvent *view.FailedEvent) error {
|
func (v *View) saveFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return view.SaveFailedEvent(v.Db, errTable, failedEvent)
|
return repository.SaveFailedEvent(v.Db, errTable, failedEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) latestFailedEvent(viewName string, sequence uint64) (*view.FailedEvent, error) {
|
func (v *View) RemoveFailedEvent(database string, failedEvent *repository.FailedEvent) error {
|
||||||
return view.LatestFailedEvent(v.Db, errTable, viewName, sequence)
|
return repository.RemoveFailedEvent(v.Db, database+".failed_event", failedEvent)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) latestFailedEvent(viewName string, sequence uint64) (*repository.FailedEvent, error) {
|
||||||
|
return repository.LatestFailedEvent(v.Db, errTable, viewName, sequence)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) AllFailedEvents(db string) ([]*repository.FailedEvent, error) {
|
||||||
|
return repository.AllFailedEvents(v.Db, db+".failed_event")
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
org_model "github.com/caos/zitadel/internal/org/model"
|
org_model "github.com/caos/zitadel/internal/org/model"
|
||||||
org_view "github.com/caos/zitadel/internal/org/repository/view"
|
org_view "github.com/caos/zitadel/internal/org/repository/view"
|
||||||
"github.com/caos/zitadel/internal/org/repository/view/model"
|
"github.com/caos/zitadel/internal/org/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -27,11 +27,11 @@ func (v *View) PutOrg(org *model.OrgView) error {
|
|||||||
return v.ProcessedOrgSequence(org.Sequence)
|
return v.ProcessedOrgSequence(org.Sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestOrgFailedEvent(sequence uint64) (*view.FailedEvent, error) {
|
func (v *View) GetLatestOrgFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(orgTable, sequence)
|
return v.latestFailedEvent(orgTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedOrgFailedEvent(failedEvent *view.FailedEvent) error {
|
func (v *View) ProcessedOrgFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -9,9 +9,19 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (v *View) saveCurrentSequence(viewName string, sequence uint64) error {
|
func (v *View) saveCurrentSequence(viewName string, sequence uint64) error {
|
||||||
return view.SaveCurrentSequence(v.Db, sequencesTable, viewName, sequence)
|
return repository.SaveCurrentSequence(v.Db, sequencesTable, viewName, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) latestSequence(viewName string) (uint64, error) {
|
func (v *View) latestSequence(viewName string) (uint64, error) {
|
||||||
return view.LatestSequence(v.Db, sequencesTable, viewName)
|
return repository.LatestSequence(v.Db, sequencesTable, viewName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) AllCurrentSequences(db string) ([]*repository.CurrentSequence, error) {
|
||||||
|
return repository.AllCurrentSequences(v.Db, db+".current_sequences")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *View) ClearView(db, viewName string) error {
|
||||||
|
truncateView := db + "." + viewName
|
||||||
|
sequenceTable := db + ".current_sequences"
|
||||||
|
return repository.ClearView(v.Db, truncateView, sequenceTable)
|
||||||
}
|
}
|
||||||
|
@ -5,4 +5,5 @@ import "context"
|
|||||||
type Repository interface {
|
type Repository interface {
|
||||||
Health(ctx context.Context) error
|
Health(ctx context.Context) error
|
||||||
OrgRepository
|
OrgRepository
|
||||||
|
AdministratorRepository
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@ package view
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
|
|
||||||
"github.com/caos/zitadel/internal/errors"
|
"github.com/caos/zitadel/internal/errors"
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
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"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -47,11 +47,11 @@ func (v *View) ProcessedApplicationSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(applicationTable, eventSequence)
|
return v.saveCurrentSequence(applicationTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestApplicationFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestApplicationFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(applicationTable, sequence)
|
return v.latestFailedEvent(applicationTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedApplicationFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedApplicationFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
errTable = "auth.failed_event"
|
errTable = "auth.failed_event"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (v *View) saveFailedEvent(failedEvent *view.FailedEvent) error {
|
func (v *View) saveFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return view.SaveFailedEvent(v.Db, errTable, failedEvent)
|
return repository.SaveFailedEvent(v.Db, errTable, failedEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) latestFailedEvent(viewName string, sequence uint64) (*view.FailedEvent, error) {
|
func (v *View) latestFailedEvent(viewName string, sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return view.LatestFailedEvent(v.Db, errTable, viewName, sequence)
|
return repository.LatestFailedEvent(v.Db, errTable, viewName, sequence)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
key_model "github.com/caos/zitadel/internal/key/model"
|
key_model "github.com/caos/zitadel/internal/key/model"
|
||||||
"github.com/caos/zitadel/internal/key/repository/view"
|
"github.com/caos/zitadel/internal/key/repository/view"
|
||||||
"github.com/caos/zitadel/internal/key/repository/view/model"
|
"github.com/caos/zitadel/internal/key/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -63,10 +63,10 @@ func (v *View) ProcessedKeySequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(keyTable, eventSequence)
|
return v.saveCurrentSequence(keyTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestKeyFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestKeyFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(keyTable, sequence)
|
return v.latestFailedEvent(keyTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedKeyFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedKeyFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/caos/zitadel/internal/org/model"
|
"github.com/caos/zitadel/internal/org/model"
|
||||||
org_view "github.com/caos/zitadel/internal/org/repository/view"
|
org_view "github.com/caos/zitadel/internal/org/repository/view"
|
||||||
org_model "github.com/caos/zitadel/internal/org/repository/view/model"
|
org_model "github.com/caos/zitadel/internal/org/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -27,11 +27,11 @@ func (v *View) PutOrg(org *org_model.OrgView) error {
|
|||||||
return v.ProcessedOrgSequence(org.Sequence)
|
return v.ProcessedOrgSequence(org.Sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestOrgFailedEvent(sequence uint64) (*view.FailedEvent, error) {
|
func (v *View) GetLatestOrgFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(orgTable, sequence)
|
return v.latestFailedEvent(orgTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedOrgFailedEvent(failedEvent *view.FailedEvent) error {
|
func (v *View) ProcessedOrgFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -9,9 +9,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (v *View) saveCurrentSequence(viewName string, sequence uint64) error {
|
func (v *View) saveCurrentSequence(viewName string, sequence uint64) error {
|
||||||
return view.SaveCurrentSequence(v.Db, sequencesTable, viewName, sequence)
|
return repository.SaveCurrentSequence(v.Db, sequencesTable, viewName, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) latestSequence(viewName string) (uint64, error) {
|
func (v *View) latestSequence(viewName string) (uint64, error) {
|
||||||
return view.LatestSequence(v.Db, sequencesTable, viewName)
|
return repository.LatestSequence(v.Db, sequencesTable, viewName)
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/caos/zitadel/internal/token/repository/view"
|
"github.com/caos/zitadel/internal/token/repository/view"
|
||||||
"github.com/caos/zitadel/internal/token/repository/view/model"
|
"github.com/caos/zitadel/internal/token/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -90,10 +90,10 @@ func (v *View) ProcessedTokenSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(tokenTable, eventSequence)
|
return v.saveCurrentSequence(tokenTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestTokenFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestTokenFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(tokenTable, sequence)
|
return v.latestFailedEvent(tokenTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedTokenFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedTokenFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||||
"github.com/caos/zitadel/internal/user/repository/view"
|
"github.com/caos/zitadel/internal/user/repository/view"
|
||||||
"github.com/caos/zitadel/internal/user/repository/view/model"
|
"github.com/caos/zitadel/internal/user/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -66,10 +66,10 @@ func (v *View) ProcessedUserSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(userTable, eventSequence)
|
return v.saveCurrentSequence(userTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestUserFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestUserFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(userTable, sequence)
|
return v.latestFailedEvent(userTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedUserFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedUserFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
grant_model "github.com/caos/zitadel/internal/usergrant/model"
|
grant_model "github.com/caos/zitadel/internal/usergrant/model"
|
||||||
"github.com/caos/zitadel/internal/usergrant/repository/view"
|
"github.com/caos/zitadel/internal/usergrant/repository/view"
|
||||||
"github.com/caos/zitadel/internal/usergrant/repository/view/model"
|
"github.com/caos/zitadel/internal/usergrant/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -55,10 +55,10 @@ func (v *View) ProcessedUserGrantSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(userGrantTable, eventSequence)
|
return v.saveCurrentSequence(userGrantTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestUserGrantFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestUserGrantFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(userGrantTable, sequence)
|
return v.latestFailedEvent(userGrantTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedUserGrantFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedUserGrantFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package view
|
|||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/user/repository/view"
|
"github.com/caos/zitadel/internal/user/repository/view"
|
||||||
"github.com/caos/zitadel/internal/user/repository/view/model"
|
"github.com/caos/zitadel/internal/user/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -46,10 +46,10 @@ func (v *View) ProcessedUserSessionSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(userSessionTable, eventSequence)
|
return v.saveCurrentSequence(userSessionTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestUserSessionFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestUserSessionFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(userSessionTable, sequence)
|
return v.latestFailedEvent(userSessionTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedUserSessionFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedUserSessionFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
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"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -51,10 +51,10 @@ func (v *View) ProcessedApplicationSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(applicationTable, eventSequence)
|
return v.saveCurrentSequence(applicationTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestApplicationFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestApplicationFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(applicationTable, sequence)
|
return v.latestFailedEvent(applicationTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedApplicationFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedApplicationFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
errTable = "authz.failed_event"
|
errTable = "authz.failed_event"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (v *View) saveFailedEvent(failedEvent *view.FailedEvent) error {
|
func (v *View) saveFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return view.SaveFailedEvent(v.Db, errTable, failedEvent)
|
return repository.SaveFailedEvent(v.Db, errTable, failedEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) latestFailedEvent(viewName string, sequence uint64) (*view.FailedEvent, error) {
|
func (v *View) latestFailedEvent(viewName string, sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return view.LatestFailedEvent(v.Db, errTable, viewName, sequence)
|
return repository.LatestFailedEvent(v.Db, errTable, viewName, sequence)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -9,9 +9,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (v *View) saveCurrentSequence(viewName string, sequence uint64) error {
|
func (v *View) saveCurrentSequence(viewName string, sequence uint64) error {
|
||||||
return view.SaveCurrentSequence(v.Db, sequencesTable, viewName, sequence)
|
return repository.SaveCurrentSequence(v.Db, sequencesTable, viewName, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) latestSequence(viewName string) (uint64, error) {
|
func (v *View) latestSequence(viewName string) (uint64, error) {
|
||||||
return view.LatestSequence(v.Db, sequencesTable, viewName)
|
return repository.LatestSequence(v.Db, sequencesTable, viewName)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package view
|
|||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/token/repository/view"
|
"github.com/caos/zitadel/internal/token/repository/view"
|
||||||
"github.com/caos/zitadel/internal/token/repository/view/model"
|
"github.com/caos/zitadel/internal/token/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -50,10 +50,10 @@ func (v *View) ProcessedTokenSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(tokenTable, eventSequence)
|
return v.saveCurrentSequence(tokenTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestTokenFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestTokenFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(tokenTable, sequence)
|
return v.latestFailedEvent(tokenTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedTokenFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedTokenFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
grant_model "github.com/caos/zitadel/internal/usergrant/model"
|
grant_model "github.com/caos/zitadel/internal/usergrant/model"
|
||||||
"github.com/caos/zitadel/internal/usergrant/repository/view"
|
"github.com/caos/zitadel/internal/usergrant/repository/view"
|
||||||
"github.com/caos/zitadel/internal/usergrant/repository/view/model"
|
"github.com/caos/zitadel/internal/usergrant/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -55,10 +55,10 @@ func (v *View) ProcessedUserGrantSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(userGrantTable, eventSequence)
|
return v.saveCurrentSequence(userGrantTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestUserGrantFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestUserGrantFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(userGrantTable, sequence)
|
return v.latestFailedEvent(userGrantTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedUserGrantFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedUserGrantFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/caos/zitadel/internal/eventstore"
|
"github.com/caos/zitadel/internal/eventstore"
|
||||||
"github.com/caos/zitadel/internal/eventstore/models"
|
"github.com/caos/zitadel/internal/eventstore/models"
|
||||||
"github.com/caos/zitadel/internal/eventstore/query"
|
"github.com/caos/zitadel/internal/eventstore/query"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -104,8 +104,8 @@ func (s *spooledHandler) process(ctx context.Context, events []*models.Event) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func HandleError(event *models.Event, failedErr error,
|
func HandleError(event *models.Event, failedErr error,
|
||||||
latestFailedEvent func(sequence uint64) (*global_view.FailedEvent, error),
|
latestFailedEvent func(sequence uint64) (*repository.FailedEvent, error),
|
||||||
processFailedEvent func(*global_view.FailedEvent) error,
|
processFailedEvent func(*repository.FailedEvent) error,
|
||||||
processSequence func(uint64) error, errorCountUntilSkip uint64) error {
|
processSequence func(uint64) error, errorCountUntilSkip uint64) error {
|
||||||
failedEvent, err := latestFailedEvent(event.Sequence)
|
failedEvent, err := latestFailedEvent(event.Sequence)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
@ -8,12 +9,11 @@ import (
|
|||||||
key_model "github.com/caos/zitadel/internal/key/model"
|
key_model "github.com/caos/zitadel/internal/key/model"
|
||||||
"github.com/caos/zitadel/internal/key/repository/view/model"
|
"github.com/caos/zitadel/internal/key/repository/view/model"
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func KeyByIDAndType(db *gorm.DB, table, keyID string, private bool) (*model.KeyView, error) {
|
func KeyByIDAndType(db *gorm.DB, table, keyID string, private bool) (*model.KeyView, error) {
|
||||||
key := new(model.KeyView)
|
key := new(model.KeyView)
|
||||||
query := view.PrepareGetByQuery(table,
|
query := repository.PrepareGetByQuery(table,
|
||||||
model.KeySearchQuery{Key: key_model.KeySearchKeyID, Method: global_model.SearchMethodEquals, Value: keyID},
|
model.KeySearchQuery{Key: key_model.KeySearchKeyID, Method: global_model.SearchMethodEquals, Value: keyID},
|
||||||
model.KeySearchQuery{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: private},
|
model.KeySearchQuery{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: private},
|
||||||
)
|
)
|
||||||
@ -23,7 +23,7 @@ func KeyByIDAndType(db *gorm.DB, table, keyID string, private bool) (*model.KeyV
|
|||||||
|
|
||||||
func GetSigningKey(db *gorm.DB, table string) (*model.KeyView, error) {
|
func GetSigningKey(db *gorm.DB, table string) (*model.KeyView, error) {
|
||||||
key := new(model.KeyView)
|
key := new(model.KeyView)
|
||||||
query := view.PrepareGetByQuery(table,
|
query := repository.PrepareGetByQuery(table,
|
||||||
model.KeySearchQuery{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: true},
|
model.KeySearchQuery{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: true},
|
||||||
model.KeySearchQuery{Key: key_model.KeySearchKeyUsage, Method: global_model.SearchMethodEquals, Value: key_model.KeyUsageSigning},
|
model.KeySearchQuery{Key: key_model.KeySearchKeyUsage, Method: global_model.SearchMethodEquals, Value: key_model.KeyUsageSigning},
|
||||||
model.KeySearchQuery{Key: key_model.KeySearchKeyExpiry, Method: global_model.SearchMethodGreaterThan, Value: time.Now().UTC()},
|
model.KeySearchQuery{Key: key_model.KeySearchKeyExpiry, Method: global_model.SearchMethodGreaterThan, Value: time.Now().UTC()},
|
||||||
@ -34,7 +34,7 @@ func GetSigningKey(db *gorm.DB, table string) (*model.KeyView, error) {
|
|||||||
|
|
||||||
func GetActivePublicKeys(db *gorm.DB, table string) ([]*model.KeyView, error) {
|
func GetActivePublicKeys(db *gorm.DB, table string) ([]*model.KeyView, error) {
|
||||||
keys := make([]*model.KeyView, 0)
|
keys := make([]*model.KeyView, 0)
|
||||||
query := view.PrepareSearchQuery(table,
|
query := repository.PrepareSearchQuery(table,
|
||||||
model.KeySearchRequest{
|
model.KeySearchRequest{
|
||||||
Queries: []*key_model.KeySearchQuery{
|
Queries: []*key_model.KeySearchQuery{
|
||||||
{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: false},
|
{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: false},
|
||||||
@ -48,7 +48,7 @@ func GetActivePublicKeys(db *gorm.DB, table string) ([]*model.KeyView, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutKeys(db *gorm.DB, table string, privateKey, publicKey *model.KeyView) error {
|
func PutKeys(db *gorm.DB, table string, privateKey, publicKey *model.KeyView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
err := save(db, privateKey)
|
err := save(db, privateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -57,14 +57,14 @@ func PutKeys(db *gorm.DB, table string, privateKey, publicKey *model.KeyView) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DeleteKey(db *gorm.DB, table, keyID string, private bool) error {
|
func DeleteKey(db *gorm.DB, table, keyID string, private bool) error {
|
||||||
delete := view.PrepareDeleteByKeys(table,
|
delete := repository.PrepareDeleteByKeys(table,
|
||||||
view.Key{Key: model.KeySearchKey(key_model.KeySearchKeyID), Value: keyID},
|
repository.Key{Key: model.KeySearchKey(key_model.KeySearchKeyID), Value: keyID},
|
||||||
view.Key{Key: model.KeySearchKey(key_model.KeySearchKeyPrivate), Value: private},
|
repository.Key{Key: model.KeySearchKey(key_model.KeySearchKeyPrivate), Value: private},
|
||||||
)
|
)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteKeyPair(db *gorm.DB, table, keyID string) error {
|
func DeleteKeyPair(db *gorm.DB, table, keyID string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.KeySearchKey(key_model.KeySearchKeyID), keyID)
|
delete := repository.PrepareDeleteByKey(table, model.KeySearchKey(key_model.KeySearchKeyID), keyID)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
key_model "github.com/caos/zitadel/internal/key/model"
|
key_model "github.com/caos/zitadel/internal/key/model"
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type KeySearchRequest key_model.KeySearchRequest
|
type KeySearchRequest key_model.KeySearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req KeySearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req KeySearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req KeySearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == key_model.KeySearchKeyUnspecified {
|
if req.SortingColumn == key_model.KeySearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req KeySearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req KeySearchRequest) GetQueries() []view.SearchQuery {
|
func (req KeySearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = KeySearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = KeySearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req KeySearchQuery) GetKey() view.ColumnKey {
|
func (req KeySearchQuery) GetKey() repository.ColumnKey {
|
||||||
return KeySearchKey(req.Key)
|
return KeySearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
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"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -43,10 +43,10 @@ func (v *View) ProcessedApplicationSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(applicationTable, eventSequence)
|
return v.saveCurrentSequence(applicationTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestApplicationFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestApplicationFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(applicationTable, sequence)
|
return v.latestFailedEvent(applicationTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedApplicationFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedApplicationFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
errTable = "management.failed_event"
|
errTable = "management.failed_event"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (v *View) saveFailedEvent(failedEvent *view.FailedEvent) error {
|
func (v *View) saveFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return view.SaveFailedEvent(v.Db, errTable, failedEvent)
|
return repository.SaveFailedEvent(v.Db, errTable, failedEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) latestFailedEvent(viewName string, sequence uint64) (*view.FailedEvent, error) {
|
func (v *View) latestFailedEvent(viewName string, sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return view.LatestFailedEvent(v.Db, errTable, viewName, sequence)
|
return repository.LatestFailedEvent(v.Db, errTable, viewName, sequence)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package view
|
|||||||
import (
|
import (
|
||||||
org_view "github.com/caos/zitadel/internal/org/repository/view"
|
org_view "github.com/caos/zitadel/internal/org/repository/view"
|
||||||
"github.com/caos/zitadel/internal/org/repository/view/model"
|
"github.com/caos/zitadel/internal/org/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -22,11 +22,11 @@ func (v *View) PutOrg(org *model.OrgView) error {
|
|||||||
return v.ProcessedOrgSequence(org.Sequence)
|
return v.ProcessedOrgSequence(org.Sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestOrgFailedEvent(sequence uint64) (*view.FailedEvent, error) {
|
func (v *View) GetLatestOrgFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(orgTable, sequence)
|
return v.latestFailedEvent(orgTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedOrgFailedEvent(failedEvent *view.FailedEvent) error {
|
func (v *View) ProcessedOrgFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
org_model "github.com/caos/zitadel/internal/org/model"
|
org_model "github.com/caos/zitadel/internal/org/model"
|
||||||
"github.com/caos/zitadel/internal/org/repository/view"
|
"github.com/caos/zitadel/internal/org/repository/view"
|
||||||
"github.com/caos/zitadel/internal/org/repository/view/model"
|
"github.com/caos/zitadel/internal/org/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -54,10 +54,10 @@ func (v *View) ProcessedOrgDomainSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(orgDomainTable, eventSequence)
|
return v.saveCurrentSequence(orgDomainTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestOrgDomainFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestOrgDomainFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(orgDomainTable, sequence)
|
return v.latestFailedEvent(orgDomainTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedOrgDomainFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedOrgDomainFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
org_model "github.com/caos/zitadel/internal/org/model"
|
org_model "github.com/caos/zitadel/internal/org/model"
|
||||||
"github.com/caos/zitadel/internal/org/repository/view"
|
"github.com/caos/zitadel/internal/org/repository/view"
|
||||||
"github.com/caos/zitadel/internal/org/repository/view/model"
|
"github.com/caos/zitadel/internal/org/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -47,10 +47,10 @@ func (v *View) ProcessedOrgMemberSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(orgMemberTable, eventSequence)
|
return v.saveCurrentSequence(orgMemberTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestOrgMemberFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestOrgMemberFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(orgMemberTable, sequence)
|
return v.latestFailedEvent(orgMemberTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedOrgMemberFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedOrgMemberFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
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"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -43,10 +43,10 @@ func (v *View) ProcessedProjectSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(projectTable, eventSequence)
|
return v.saveCurrentSequence(projectTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestProjectFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestProjectFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(projectTable, sequence)
|
return v.latestFailedEvent(projectTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedProjectFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedProjectFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
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"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -55,10 +55,10 @@ func (v *View) ProcessedProjectGrantSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(grantedProjectTable, eventSequence)
|
return v.saveCurrentSequence(grantedProjectTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestProjectGrantFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestProjectGrantFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(grantedProjectTable, sequence)
|
return v.latestFailedEvent(grantedProjectTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedProjectGrantFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedProjectGrantFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
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"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -47,10 +47,10 @@ func (v *View) ProcessedProjectGrantMemberSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(projectGrantMemberTable, eventSequence)
|
return v.saveCurrentSequence(projectGrantMemberTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestProjectGrantMemberFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestProjectGrantMemberFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(projectGrantMemberTable, sequence)
|
return v.latestFailedEvent(projectGrantMemberTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedProjectGrantMemberFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedProjectGrantMemberFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
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"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -47,10 +47,10 @@ func (v *View) ProcessedProjectMemberSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(projectMemberTable, eventSequence)
|
return v.saveCurrentSequence(projectMemberTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestProjectMemberFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestProjectMemberFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(projectMemberTable, sequence)
|
return v.latestFailedEvent(projectMemberTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedProjectMemberFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedProjectMemberFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
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"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -51,10 +51,10 @@ func (v *View) ProcessedProjectRoleSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(projectRoleTable, eventSequence)
|
return v.saveCurrentSequence(projectRoleTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestProjectRoleFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestProjectRoleFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(projectRoleTable, sequence)
|
return v.latestFailedEvent(projectRoleTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedProjectRoleFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedProjectRoleFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -9,9 +9,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (v *View) saveCurrentSequence(viewName string, sequence uint64) error {
|
func (v *View) saveCurrentSequence(viewName string, sequence uint64) error {
|
||||||
return view.SaveCurrentSequence(v.Db, sequencesTable, viewName, sequence)
|
return repository.SaveCurrentSequence(v.Db, sequencesTable, viewName, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) latestSequence(viewName string) (uint64, error) {
|
func (v *View) latestSequence(viewName string) (uint64, error) {
|
||||||
return view.LatestSequence(v.Db, sequencesTable, viewName)
|
return repository.LatestSequence(v.Db, sequencesTable, viewName)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||||
"github.com/caos/zitadel/internal/user/repository/view"
|
"github.com/caos/zitadel/internal/user/repository/view"
|
||||||
"github.com/caos/zitadel/internal/user/repository/view/model"
|
"github.com/caos/zitadel/internal/user/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -62,10 +62,10 @@ func (v *View) ProcessedUserSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(userTable, eventSequence)
|
return v.saveCurrentSequence(userTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestUserFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestUserFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(userTable, sequence)
|
return v.latestFailedEvent(userTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedUserFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedUserFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
grant_model "github.com/caos/zitadel/internal/usergrant/model"
|
grant_model "github.com/caos/zitadel/internal/usergrant/model"
|
||||||
"github.com/caos/zitadel/internal/usergrant/repository/view"
|
"github.com/caos/zitadel/internal/usergrant/repository/view"
|
||||||
"github.com/caos/zitadel/internal/usergrant/repository/view/model"
|
"github.com/caos/zitadel/internal/usergrant/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -63,10 +63,10 @@ func (v *View) ProcessedUserGrantSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(userGrantTable, eventSequence)
|
return v.saveCurrentSequence(userGrantTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestUserGrantFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestUserGrantFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(userGrantTable, sequence)
|
return v.latestFailedEvent(userGrantTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedUserGrantFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedUserGrantFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
errTable = "notification.failed_event"
|
errTable = "notification.failed_event"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (v *View) saveFailedEvent(failedEvent *view.FailedEvent) error {
|
func (v *View) saveFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return view.SaveFailedEvent(v.Db, errTable, failedEvent)
|
return repository.SaveFailedEvent(v.Db, errTable, failedEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) latestFailedEvent(viewName string, sequence uint64) (*view.FailedEvent, error) {
|
func (v *View) latestFailedEvent(viewName string, sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return view.LatestFailedEvent(v.Db, errTable, viewName, sequence)
|
return repository.LatestFailedEvent(v.Db, errTable, viewName, sequence)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -16,10 +16,10 @@ func (v *View) ProcessedNotificationSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(notificationTable, eventSequence)
|
return v.saveCurrentSequence(notificationTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestNotificationFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestNotificationFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(notificationTable, sequence)
|
return v.latestFailedEvent(notificationTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedNotificationFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedNotificationFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package view
|
|||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/user/repository/view"
|
"github.com/caos/zitadel/internal/user/repository/view"
|
||||||
"github.com/caos/zitadel/internal/user/repository/view/model"
|
"github.com/caos/zitadel/internal/user/repository/view/model"
|
||||||
global_view "github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -38,10 +38,10 @@ func (v *View) ProcessedNotifyUserSequence(eventSequence uint64) error {
|
|||||||
return v.saveCurrentSequence(notifyUserTable, eventSequence)
|
return v.saveCurrentSequence(notifyUserTable, eventSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) GetLatestNotifyUserFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
func (v *View) GetLatestNotifyUserFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
||||||
return v.latestFailedEvent(notifyUserTable, sequence)
|
return v.latestFailedEvent(notifyUserTable, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) ProcessedNotifyUserFailedEvent(failedEvent *global_view.FailedEvent) error {
|
func (v *View) ProcessedNotifyUserFailedEvent(failedEvent *repository.FailedEvent) error {
|
||||||
return v.saveFailedEvent(failedEvent)
|
return v.saveFailedEvent(failedEvent)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -9,9 +9,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (v *View) saveCurrentSequence(viewName string, sequence uint64) error {
|
func (v *View) saveCurrentSequence(viewName string, sequence uint64) error {
|
||||||
return view.SaveCurrentSequence(v.Db, sequencesTable, viewName, sequence)
|
return repository.SaveCurrentSequence(v.Db, sequencesTable, viewName, sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *View) latestSequence(viewName string) (uint64, error) {
|
func (v *View) latestSequence(viewName string) (uint64, error) {
|
||||||
return view.LatestSequence(v.Db, sequencesTable, viewName)
|
return repository.LatestSequence(v.Db, sequencesTable, viewName)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
org_model "github.com/caos/zitadel/internal/org/model"
|
org_model "github.com/caos/zitadel/internal/org/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OrgDomainSearchRequest org_model.OrgDomainSearchRequest
|
type OrgDomainSearchRequest org_model.OrgDomainSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req OrgDomainSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req OrgDomainSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req OrgDomainSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == org_model.OrgDomainSearchKeyUnspecified {
|
if req.SortingColumn == org_model.OrgDomainSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req OrgDomainSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req OrgDomainSearchRequest) GetQueries() []view.SearchQuery {
|
func (req OrgDomainSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = OrgDomainSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = OrgDomainSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req OrgDomainSearchQuery) GetKey() view.ColumnKey {
|
func (req OrgDomainSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return OrgDomainSearchKey(req.Key)
|
return OrgDomainSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/org/model"
|
proj_model "github.com/caos/zitadel/internal/org/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OrgMemberSearchRequest proj_model.OrgMemberSearchRequest
|
type OrgMemberSearchRequest proj_model.OrgMemberSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req OrgMemberSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req OrgMemberSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req OrgMemberSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == proj_model.OrgMemberSearchKeyUnspecified {
|
if req.SortingColumn == proj_model.OrgMemberSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req OrgMemberSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req OrgMemberSearchRequest) GetQueries() []view.SearchQuery {
|
func (req OrgMemberSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = OrgMemberSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = OrgMemberSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req OrgMemberSearchQuery) GetKey() view.ColumnKey {
|
func (req OrgMemberSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return OrgMemberSearchKey(req.Key)
|
return OrgMemberSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
usr_model "github.com/caos/zitadel/internal/org/model"
|
usr_model "github.com/caos/zitadel/internal/org/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OrgSearchRequest usr_model.OrgSearchRequest
|
type OrgSearchRequest usr_model.OrgSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req OrgSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req OrgSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req OrgSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == usr_model.OrgSearchKeyUnspecified {
|
if req.SortingColumn == usr_model.OrgSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req OrgSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req OrgSearchRequest) GetQueries() []view.SearchQuery {
|
func (req OrgSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = OrgSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = OrgSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req OrgSearchQuery) GetKey() view.ColumnKey {
|
func (req OrgSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return OrgSearchKey(req.Key)
|
return OrgSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
org_model "github.com/caos/zitadel/internal/org/model"
|
org_model "github.com/caos/zitadel/internal/org/model"
|
||||||
"github.com/caos/zitadel/internal/org/repository/view/model"
|
"github.com/caos/zitadel/internal/org/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ func OrgDomainByOrgIDAndDomain(db *gorm.DB, table, orgID, domain string) (*model
|
|||||||
domainView := new(model.OrgDomainView)
|
domainView := new(model.OrgDomainView)
|
||||||
orgIDQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
orgIDQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||||
domainQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyDomain, Value: domain, Method: global_model.SearchMethodEquals}
|
domainQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyDomain, Value: domain, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, orgIDQuery, domainQuery)
|
query := repository.PrepareGetByQuery(table, orgIDQuery, domainQuery)
|
||||||
err := query(db, domainView)
|
err := query(db, domainView)
|
||||||
return domainView, err
|
return domainView, err
|
||||||
}
|
}
|
||||||
@ -21,14 +21,14 @@ func VerifiedOrgDomain(db *gorm.DB, table, domain string) (*model.OrgDomainView,
|
|||||||
domainView := new(model.OrgDomainView)
|
domainView := new(model.OrgDomainView)
|
||||||
domainQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyDomain, Value: domain, Method: global_model.SearchMethodEquals}
|
domainQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyDomain, Value: domain, Method: global_model.SearchMethodEquals}
|
||||||
verifiedQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyVerified, Value: true, Method: global_model.SearchMethodEquals}
|
verifiedQuery := &model.OrgDomainSearchQuery{Key: org_model.OrgDomainSearchKeyVerified, Value: true, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, domainQuery, verifiedQuery)
|
query := repository.PrepareGetByQuery(table, domainQuery, verifiedQuery)
|
||||||
err := query(db, domainView)
|
err := query(db, domainView)
|
||||||
return domainView, err
|
return domainView, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SearchOrgDomains(db *gorm.DB, table string, req *org_model.OrgDomainSearchRequest) ([]*model.OrgDomainView, int, error) {
|
func SearchOrgDomains(db *gorm.DB, table string, req *org_model.OrgDomainSearchRequest) ([]*model.OrgDomainView, int, error) {
|
||||||
members := make([]*model.OrgDomainView, 0)
|
members := make([]*model.OrgDomainView, 0)
|
||||||
query := view.PrepareSearchQuery(table, model.OrgDomainSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
query := repository.PrepareSearchQuery(table, model.OrgDomainSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
count, err := query(db, &members)
|
count, err := query(db, &members)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -45,7 +45,7 @@ func OrgDomainsByOrgID(db *gorm.DB, table string, orgID string) ([]*model.OrgDom
|
|||||||
Method: global_model.SearchMethodEquals,
|
Method: global_model.SearchMethodEquals,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.OrgDomainSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.OrgDomainSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &domains)
|
_, err := query(db, &domains)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -54,14 +54,14 @@ func OrgDomainsByOrgID(db *gorm.DB, table string, orgID string) ([]*model.OrgDom
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutOrgDomain(db *gorm.DB, table string, role *model.OrgDomainView) error {
|
func PutOrgDomain(db *gorm.DB, table string, role *model.OrgDomainView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, role)
|
return save(db, role)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteOrgDomain(db *gorm.DB, table, orgID, domain string) error {
|
func DeleteOrgDomain(db *gorm.DB, table, orgID, domain string) error {
|
||||||
delete := view.PrepareDeleteByKeys(table,
|
delete := repository.PrepareDeleteByKeys(table,
|
||||||
view.Key{Key: model.OrgDomainSearchKey(org_model.OrgDomainSearchKeyDomain), Value: domain},
|
repository.Key{Key: model.OrgDomainSearchKey(org_model.OrgDomainSearchKeyDomain), Value: domain},
|
||||||
view.Key{Key: model.OrgDomainSearchKey(org_model.OrgDomainSearchKeyOrgID), Value: orgID},
|
repository.Key{Key: model.OrgDomainSearchKey(org_model.OrgDomainSearchKeyOrgID), Value: orgID},
|
||||||
)
|
)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
org_model "github.com/caos/zitadel/internal/org/model"
|
org_model "github.com/caos/zitadel/internal/org/model"
|
||||||
"github.com/caos/zitadel/internal/org/repository/view/model"
|
"github.com/caos/zitadel/internal/org/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,14 +13,14 @@ func OrgMemberByIDs(db *gorm.DB, table, orgID, userID string) (*model.OrgMemberV
|
|||||||
|
|
||||||
orgIDQuery := &model.OrgMemberSearchQuery{Key: org_model.OrgMemberSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
orgIDQuery := &model.OrgMemberSearchQuery{Key: org_model.OrgMemberSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||||
userIDQuery := &model.OrgMemberSearchQuery{Key: org_model.OrgMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
userIDQuery := &model.OrgMemberSearchQuery{Key: org_model.OrgMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, orgIDQuery, userIDQuery)
|
query := repository.PrepareGetByQuery(table, orgIDQuery, userIDQuery)
|
||||||
err := query(db, member)
|
err := query(db, member)
|
||||||
return member, err
|
return member, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SearchOrgMembers(db *gorm.DB, table string, req *org_model.OrgMemberSearchRequest) ([]*model.OrgMemberView, int, error) {
|
func SearchOrgMembers(db *gorm.DB, table string, req *org_model.OrgMemberSearchRequest) ([]*model.OrgMemberView, int, error) {
|
||||||
members := make([]*model.OrgMemberView, 0)
|
members := make([]*model.OrgMemberView, 0)
|
||||||
query := view.PrepareSearchQuery(table, model.OrgMemberSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
query := repository.PrepareSearchQuery(table, model.OrgMemberSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
count, err := query(db, &members)
|
count, err := query(db, &members)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -36,7 +36,7 @@ func OrgMembersByUserID(db *gorm.DB, table string, userID string) ([]*model.OrgM
|
|||||||
Method: global_model.SearchMethodEquals,
|
Method: global_model.SearchMethodEquals,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.OrgMemberSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.OrgMemberSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &members)
|
_, err := query(db, &members)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -45,7 +45,7 @@ func OrgMembersByUserID(db *gorm.DB, table string, userID string) ([]*model.OrgM
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutOrgMember(db *gorm.DB, table string, role *model.OrgMemberView) error {
|
func PutOrgMember(db *gorm.DB, table string, role *model.OrgMemberView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, role)
|
return save(db, role)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +54,6 @@ func DeleteOrgMember(db *gorm.DB, table, orgID, userID string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
delete := view.PrepareDeleteByObject(table, member)
|
delete := repository.PrepareDeleteByObject(table, member)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -3,20 +3,20 @@ package view
|
|||||||
import (
|
import (
|
||||||
org_model "github.com/caos/zitadel/internal/org/model"
|
org_model "github.com/caos/zitadel/internal/org/model"
|
||||||
"github.com/caos/zitadel/internal/org/repository/view/model"
|
"github.com/caos/zitadel/internal/org/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func OrgByID(db *gorm.DB, table, orgID string) (*model.OrgView, error) {
|
func OrgByID(db *gorm.DB, table, orgID string) (*model.OrgView, error) {
|
||||||
org := new(model.OrgView)
|
org := new(model.OrgView)
|
||||||
query := view.PrepareGetByKey(table, model.OrgSearchKey(org_model.OrgSearchKeyOrgID), orgID)
|
query := repository.PrepareGetByKey(table, model.OrgSearchKey(org_model.OrgSearchKeyOrgID), orgID)
|
||||||
err := query(db, org)
|
err := query(db, org)
|
||||||
return org, err
|
return org, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SearchOrgs(db *gorm.DB, table string, req *org_model.OrgSearchRequest) ([]*model.OrgView, int, error) {
|
func SearchOrgs(db *gorm.DB, table string, req *org_model.OrgSearchRequest) ([]*model.OrgView, int, error) {
|
||||||
orgs := make([]*model.OrgView, 0)
|
orgs := make([]*model.OrgView, 0)
|
||||||
query := view.PrepareSearchQuery(table, model.OrgSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
query := repository.PrepareSearchQuery(table, model.OrgSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
count, err := query(db, &orgs)
|
count, err := query(db, &orgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -25,11 +25,11 @@ func SearchOrgs(db *gorm.DB, table string, req *org_model.OrgSearchRequest) ([]*
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutOrg(db *gorm.DB, table string, org *model.OrgView) error {
|
func PutOrg(db *gorm.DB, table string, org *model.OrgView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, org)
|
return save(db, org)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteOrg(db *gorm.DB, table, orgID string) error {
|
func DeleteOrg(db *gorm.DB, table, orgID string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.OrgSearchKey(org_model.OrgSearchKeyOrgID), orgID)
|
delete := repository.PrepareDeleteByKey(table, model.OrgSearchKey(org_model.OrgSearchKeyOrgID), orgID)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,13 @@ import (
|
|||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ApplicationByID(db *gorm.DB, table, appID string) (*model.ApplicationView, error) {
|
func ApplicationByID(db *gorm.DB, table, appID string) (*model.ApplicationView, error) {
|
||||||
app := new(model.ApplicationView)
|
app := new(model.ApplicationView)
|
||||||
query := view.PrepareGetByKey(table, model.ApplicationSearchKey(proj_model.AppSearchKeyAppID), appID)
|
query := repository.PrepareGetByKey(table, model.ApplicationSearchKey(proj_model.AppSearchKeyAppID), appID)
|
||||||
err := query(db, app)
|
err := query(db, app)
|
||||||
return app, err
|
return app, err
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ func ApplicationByID(db *gorm.DB, table, appID string) (*model.ApplicationView,
|
|||||||
func ApplicationByOIDCClientID(db *gorm.DB, table, clientID string) (*model.ApplicationView, error) {
|
func ApplicationByOIDCClientID(db *gorm.DB, table, clientID string) (*model.ApplicationView, error) {
|
||||||
app := new(model.ApplicationView)
|
app := new(model.ApplicationView)
|
||||||
clientIDQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyOIDCClientID, Value: clientID, Method: global_model.SearchMethodEquals}
|
clientIDQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyOIDCClientID, Value: clientID, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, clientIDQuery)
|
query := repository.PrepareGetByQuery(table, clientIDQuery)
|
||||||
err := query(db, app)
|
err := query(db, app)
|
||||||
return app, err
|
return app, err
|
||||||
}
|
}
|
||||||
@ -27,24 +27,24 @@ func ApplicationByProjectIDAndAppName(db *gorm.DB, table, projectID, appName str
|
|||||||
app := new(model.ApplicationView)
|
app := new(model.ApplicationView)
|
||||||
projectIDQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
projectIDQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||||
appNameQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyName, Value: appName, Method: global_model.SearchMethodEquals}
|
appNameQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyName, Value: appName, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, projectIDQuery, appNameQuery)
|
query := repository.PrepareGetByQuery(table, projectIDQuery, appNameQuery)
|
||||||
err := query(db, app)
|
err := query(db, app)
|
||||||
return app, err
|
return app, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SearchApplications(db *gorm.DB, table string, req *proj_model.ApplicationSearchRequest) ([]*model.ApplicationView, int, error) {
|
func SearchApplications(db *gorm.DB, table string, req *proj_model.ApplicationSearchRequest) ([]*model.ApplicationView, int, error) {
|
||||||
apps := make([]*model.ApplicationView, 0)
|
apps := make([]*model.ApplicationView, 0)
|
||||||
query := view.PrepareSearchQuery(table, model.ApplicationSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
query := repository.PrepareSearchQuery(table, model.ApplicationSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
count, err := query(db, &apps)
|
count, err := query(db, &apps)
|
||||||
return apps, count, err
|
return apps, count, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func PutApplication(db *gorm.DB, table string, app *model.ApplicationView) error {
|
func PutApplication(db *gorm.DB, table string, app *model.ApplicationView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, app)
|
return save(db, app)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteApplication(db *gorm.DB, table, appID string) error {
|
func DeleteApplication(db *gorm.DB, table, appID string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.ApplicationSearchKey(proj_model.AppSearchKeyAppID), appID)
|
delete := repository.PrepareDeleteByKey(table, model.ApplicationSearchKey(proj_model.AppSearchKeyAppID), appID)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ApplicationSearchRequest proj_model.ApplicationSearchRequest
|
type ApplicationSearchRequest proj_model.ApplicationSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req ApplicationSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ApplicationSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req ApplicationSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == proj_model.AppSearchKeyUnspecified {
|
if req.SortingColumn == proj_model.AppSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req ApplicationSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ApplicationSearchRequest) GetQueries() []view.SearchQuery {
|
func (req ApplicationSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = ApplicationSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = ApplicationSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ApplicationSearchQuery) GetKey() view.ColumnKey {
|
func (req ApplicationSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return ApplicationSearchKey(req.Key)
|
return ApplicationSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProjectGrantMemberSearchRequest proj_model.ProjectGrantMemberSearchRequest
|
type ProjectGrantMemberSearchRequest proj_model.ProjectGrantMemberSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req ProjectGrantMemberSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectGrantMemberSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req ProjectGrantMemberSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == proj_model.ProjectGrantMemberSearchKeyUnspecified {
|
if req.SortingColumn == proj_model.ProjectGrantMemberSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req ProjectGrantMemberSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectGrantMemberSearchRequest) GetQueries() []view.SearchQuery {
|
func (req ProjectGrantMemberSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = ProjectGrantMemberSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = ProjectGrantMemberSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectGrantMemberSearchQuery) GetKey() view.ColumnKey {
|
func (req ProjectGrantMemberSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return ProjectGrantMemberSearchKey(req.Key)
|
return ProjectGrantMemberSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProjectGrantSearchRequest proj_model.ProjectGrantViewSearchRequest
|
type ProjectGrantSearchRequest proj_model.ProjectGrantViewSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req ProjectGrantSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectGrantSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req ProjectGrantSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == proj_model.GrantedProjectSearchKeyUnspecified {
|
if req.SortingColumn == proj_model.GrantedProjectSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req ProjectGrantSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectGrantSearchRequest) GetQueries() []view.SearchQuery {
|
func (req ProjectGrantSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = ProjectGrantSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = ProjectGrantSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectGrantSearchQuery) GetKey() view.ColumnKey {
|
func (req ProjectGrantSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return ProjectGrantSearchKey(req.Key)
|
return ProjectGrantSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProjectMemberSearchRequest proj_model.ProjectMemberSearchRequest
|
type ProjectMemberSearchRequest proj_model.ProjectMemberSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req ProjectMemberSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectMemberSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req ProjectMemberSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == proj_model.ProjectMemberSearchKeyUnspecified {
|
if req.SortingColumn == proj_model.ProjectMemberSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req ProjectMemberSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectMemberSearchRequest) GetQueries() []view.SearchQuery {
|
func (req ProjectMemberSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = ProjectMemberSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = ProjectMemberSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectMemberSearchQuery) GetKey() view.ColumnKey {
|
func (req ProjectMemberSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return ProjectMemberSearchKey(req.Key)
|
return ProjectMemberSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProjectSearchRequest proj_model.ProjectViewSearchRequest
|
type ProjectSearchRequest proj_model.ProjectViewSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req ProjectSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req ProjectSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == proj_model.ProjectViewSearchKeyUnspecified {
|
if req.SortingColumn == proj_model.ProjectViewSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req ProjectSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectSearchRequest) GetQueries() []view.SearchQuery {
|
func (req ProjectSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = ProjectSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = ProjectSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectSearchQuery) GetKey() view.ColumnKey {
|
func (req ProjectSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return ProjectSearchKey(req.Key)
|
return ProjectSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProjectRoleSearchRequest proj_model.ProjectRoleSearchRequest
|
type ProjectRoleSearchRequest proj_model.ProjectRoleSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req ProjectRoleSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectRoleSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req ProjectRoleSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == proj_model.ProjectRoleSearchKeyUnspecified {
|
if req.SortingColumn == proj_model.ProjectRoleSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req ProjectRoleSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectRoleSearchRequest) GetQueries() []view.SearchQuery {
|
func (req ProjectRoleSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = ProjectRoleSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = ProjectRoleSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ProjectRoleSearchQuery) GetKey() view.ColumnKey {
|
func (req ProjectRoleSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return ProjectRoleSearchKey(req.Key)
|
return ProjectRoleSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,14 +13,14 @@ func ProjectGrantMemberByIDs(db *gorm.DB, table, grantID, userID string) (*model
|
|||||||
|
|
||||||
grantIDQuery := model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyGrantID, Value: grantID, Method: global_model.SearchMethodEquals}
|
grantIDQuery := model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyGrantID, Value: grantID, Method: global_model.SearchMethodEquals}
|
||||||
userIDQuery := model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
userIDQuery := model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, grantIDQuery, userIDQuery)
|
query := repository.PrepareGetByQuery(table, grantIDQuery, userIDQuery)
|
||||||
err := query(db, role)
|
err := query(db, role)
|
||||||
return role, err
|
return role, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SearchProjectGrantMembers(db *gorm.DB, table string, req *proj_model.ProjectGrantMemberSearchRequest) ([]*model.ProjectGrantMemberView, int, error) {
|
func SearchProjectGrantMembers(db *gorm.DB, table string, req *proj_model.ProjectGrantMemberSearchRequest) ([]*model.ProjectGrantMemberView, int, error) {
|
||||||
roles := make([]*model.ProjectGrantMemberView, 0)
|
roles := make([]*model.ProjectGrantMemberView, 0)
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectGrantMemberSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectGrantMemberSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
count, err := query(db, &roles)
|
count, err := query(db, &roles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -33,7 +33,7 @@ func ProjectGrantMembersByUserID(db *gorm.DB, table, userID string) ([]*model.Pr
|
|||||||
queries := []*proj_model.ProjectGrantMemberSearchQuery{
|
queries := []*proj_model.ProjectGrantMemberSearchQuery{
|
||||||
&proj_model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals},
|
&proj_model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectGrantMemberSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectGrantMemberSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &members)
|
_, err := query(db, &members)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -42,7 +42,7 @@ func ProjectGrantMembersByUserID(db *gorm.DB, table, userID string) ([]*model.Pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutProjectGrantMember(db *gorm.DB, table string, role *model.ProjectGrantMemberView) error {
|
func PutProjectGrantMember(db *gorm.DB, table string, role *model.ProjectGrantMemberView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, role)
|
return save(db, role)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +51,6 @@ func DeleteProjectGrantMember(db *gorm.DB, table, grantID, userID string) error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
delete := view.PrepareDeleteByObject(table, role)
|
delete := repository.PrepareDeleteByObject(table, role)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ func ProjectGrantByProjectAndOrg(db *gorm.DB, table, projectID, orgID string) (*
|
|||||||
|
|
||||||
projectIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
projectIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||||
orgIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
orgIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, projectIDQuery, orgIDQuery)
|
query := repository.PrepareGetByQuery(table, projectIDQuery, orgIDQuery)
|
||||||
err := query(db, project)
|
err := query(db, project)
|
||||||
return project, err
|
return project, err
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ func ProjectGrantByProjectAndOrg(db *gorm.DB, table, projectID, orgID string) (*
|
|||||||
func ProjectGrantByID(db *gorm.DB, table, grantID string) (*model.ProjectGrantView, error) {
|
func ProjectGrantByID(db *gorm.DB, table, grantID string) (*model.ProjectGrantView, error) {
|
||||||
project := new(model.ProjectGrantView)
|
project := new(model.ProjectGrantView)
|
||||||
grantIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyGrantID, Value: grantID, Method: global_model.SearchMethodEquals}
|
grantIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyGrantID, Value: grantID, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, grantIDQuery)
|
query := repository.PrepareGetByQuery(table, grantIDQuery)
|
||||||
err := query(db, project)
|
err := query(db, project)
|
||||||
return project, err
|
return project, err
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ func ProjectGrantsByProjectID(db *gorm.DB, table, projectID string) ([]*model.Pr
|
|||||||
queries := []*proj_model.ProjectGrantViewSearchQuery{
|
queries := []*proj_model.ProjectGrantViewSearchQuery{
|
||||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &projects)
|
_, err := query(db, &projects)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -45,7 +45,7 @@ func ProjectGrantsByProjectIDAndRoleKey(db *gorm.DB, table, projectID, roleKey s
|
|||||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyRoleKeys, Value: roleKey, Method: global_model.SearchMethodListContains},
|
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyRoleKeys, Value: roleKey, Method: global_model.SearchMethodListContains},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &projects)
|
_, err := query(db, &projects)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -55,7 +55,7 @@ func ProjectGrantsByProjectIDAndRoleKey(db *gorm.DB, table, projectID, roleKey s
|
|||||||
|
|
||||||
func SearchProjectGrants(db *gorm.DB, table string, req *proj_model.ProjectGrantViewSearchRequest) ([]*model.ProjectGrantView, int, error) {
|
func SearchProjectGrants(db *gorm.DB, table string, req *proj_model.ProjectGrantViewSearchRequest) ([]*model.ProjectGrantView, int, error) {
|
||||||
projects := make([]*model.ProjectGrantView, 0)
|
projects := make([]*model.ProjectGrantView, 0)
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
count, err := query(db, &projects)
|
count, err := query(db, &projects)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -64,11 +64,11 @@ func SearchProjectGrants(db *gorm.DB, table string, req *proj_model.ProjectGrant
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutProjectGrant(db *gorm.DB, table string, project *model.ProjectGrantView) error {
|
func PutProjectGrant(db *gorm.DB, table string, project *model.ProjectGrantView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, project)
|
return save(db, project)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteProjectGrant(db *gorm.DB, table, grantID string) error {
|
func DeleteProjectGrant(db *gorm.DB, table, grantID string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.GrantedProjectSearchKeyGrantID), grantID)
|
delete := repository.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.GrantedProjectSearchKeyGrantID), grantID)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,14 +13,14 @@ func ProjectMemberByIDs(db *gorm.DB, table, projectID, userID string) (*model.Pr
|
|||||||
|
|
||||||
projectIDQuery := model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
projectIDQuery := model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||||
userIDQuery := model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
userIDQuery := model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, projectIDQuery, userIDQuery)
|
query := repository.PrepareGetByQuery(table, projectIDQuery, userIDQuery)
|
||||||
err := query(db, role)
|
err := query(db, role)
|
||||||
return role, err
|
return role, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SearchProjectMembers(db *gorm.DB, table string, req *proj_model.ProjectMemberSearchRequest) ([]*model.ProjectMemberView, int, error) {
|
func SearchProjectMembers(db *gorm.DB, table string, req *proj_model.ProjectMemberSearchRequest) ([]*model.ProjectMemberView, int, error) {
|
||||||
roles := make([]*model.ProjectMemberView, 0)
|
roles := make([]*model.ProjectMemberView, 0)
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectMemberSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectMemberSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
count, err := query(db, &roles)
|
count, err := query(db, &roles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -32,7 +32,7 @@ func ProjectMembersByUserID(db *gorm.DB, table string, userID string) ([]*model.
|
|||||||
queries := []*proj_model.ProjectMemberSearchQuery{
|
queries := []*proj_model.ProjectMemberSearchQuery{
|
||||||
&proj_model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals},
|
&proj_model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectMemberSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectMemberSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &members)
|
_, err := query(db, &members)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -41,7 +41,7 @@ func ProjectMembersByUserID(db *gorm.DB, table string, userID string) ([]*model.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutProjectMember(db *gorm.DB, table string, role *model.ProjectMemberView) error {
|
func PutProjectMember(db *gorm.DB, table string, role *model.ProjectMemberView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, role)
|
return save(db, role)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +50,6 @@ func DeleteProjectMember(db *gorm.DB, table, projectID, userID string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
delete := view.PrepareDeleteByObject(table, role)
|
delete := repository.PrepareDeleteByObject(table, role)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ func ProjectRoleByIDs(db *gorm.DB, table, projectID, orgID, key string) (*model.
|
|||||||
projectIDQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
projectIDQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||||
grantIDQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
grantIDQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||||
keyQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyKey, Value: orgID, Method: global_model.SearchMethodEquals}
|
keyQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyKey, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, projectIDQuery, grantIDQuery, keyQuery)
|
query := repository.PrepareGetByQuery(table, projectIDQuery, grantIDQuery, keyQuery)
|
||||||
err := query(db, role)
|
err := query(db, role)
|
||||||
return role, err
|
return role, err
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ func ResourceOwnerProjectRolesByKey(db *gorm.DB, table, projectID, resourceOwner
|
|||||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyResourceOwner, Value: resourceOwner, Method: global_model.SearchMethodEquals},
|
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyResourceOwner, Value: resourceOwner, Method: global_model.SearchMethodEquals},
|
||||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyKey, Value: key, Method: global_model.SearchMethodEquals},
|
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyKey, Value: key, Method: global_model.SearchMethodEquals},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &roles)
|
_, err := query(db, &roles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -40,7 +40,7 @@ func ResourceOwnerProjectRoles(db *gorm.DB, table, projectID, resourceOwner stri
|
|||||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyResourceOwner, Value: resourceOwner, Method: global_model.SearchMethodEquals},
|
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyResourceOwner, Value: resourceOwner, Method: global_model.SearchMethodEquals},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &roles)
|
_, err := query(db, &roles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -50,7 +50,7 @@ func ResourceOwnerProjectRoles(db *gorm.DB, table, projectID, resourceOwner stri
|
|||||||
|
|
||||||
func SearchProjectRoles(db *gorm.DB, table string, req *proj_model.ProjectRoleSearchRequest) ([]*model.ProjectRoleView, int, error) {
|
func SearchProjectRoles(db *gorm.DB, table string, req *proj_model.ProjectRoleSearchRequest) ([]*model.ProjectRoleView, int, error) {
|
||||||
roles := make([]*model.ProjectRoleView, 0)
|
roles := make([]*model.ProjectRoleView, 0)
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
count, err := query(db, &roles)
|
count, err := query(db, &roles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -59,7 +59,7 @@ func SearchProjectRoles(db *gorm.DB, table string, req *proj_model.ProjectRoleSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutProjectRole(db *gorm.DB, table string, role *model.ProjectRoleView) error {
|
func PutProjectRole(db *gorm.DB, table string, role *model.ProjectRoleView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, role)
|
return save(db, role)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +68,6 @@ func DeleteProjectRole(db *gorm.DB, table, projectID, orgID, key string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
delete := view.PrepareDeleteByObject(table, role)
|
delete := repository.PrepareDeleteByObject(table, role)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||||
"github.com/caos/zitadel/internal/project/repository/view/model"
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ func ProjectByID(db *gorm.DB, table, projectID string) (*model.ProjectView, erro
|
|||||||
project := new(model.ProjectView)
|
project := new(model.ProjectView)
|
||||||
|
|
||||||
projectIDQuery := model.ProjectSearchQuery{Key: proj_model.ProjectViewSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
projectIDQuery := model.ProjectSearchQuery{Key: proj_model.ProjectViewSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, projectIDQuery)
|
query := repository.PrepareGetByQuery(table, projectIDQuery)
|
||||||
err := query(db, project)
|
err := query(db, project)
|
||||||
return project, err
|
return project, err
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ func ProjectsByResourceOwner(db *gorm.DB, table, orgID string) ([]*model.Project
|
|||||||
queries := []*proj_model.ProjectViewSearchQuery{
|
queries := []*proj_model.ProjectViewSearchQuery{
|
||||||
&proj_model.ProjectViewSearchQuery{Key: proj_model.ProjectViewSearchKeyResourceOwner, Value: orgID, Method: global_model.SearchMethodEquals},
|
&proj_model.ProjectViewSearchQuery{Key: proj_model.ProjectViewSearchKeyResourceOwner, Value: orgID, Method: global_model.SearchMethodEquals},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &projects)
|
_, err := query(db, &projects)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -32,7 +32,7 @@ func ProjectsByResourceOwner(db *gorm.DB, table, orgID string) ([]*model.Project
|
|||||||
|
|
||||||
func SearchProjects(db *gorm.DB, table string, req *proj_model.ProjectViewSearchRequest) ([]*model.ProjectView, int, error) {
|
func SearchProjects(db *gorm.DB, table string, req *proj_model.ProjectViewSearchRequest) ([]*model.ProjectView, int, error) {
|
||||||
projects := make([]*model.ProjectView, 0)
|
projects := make([]*model.ProjectView, 0)
|
||||||
query := view.PrepareSearchQuery(table, model.ProjectSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
query := repository.PrepareSearchQuery(table, model.ProjectSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
count, err := query(db, &projects)
|
count, err := query(db, &projects)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -41,11 +41,11 @@ func SearchProjects(db *gorm.DB, table string, req *proj_model.ProjectViewSearch
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutProject(db *gorm.DB, table string, project *model.ProjectView) error {
|
func PutProject(db *gorm.DB, table string, project *model.ProjectView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, project)
|
return save(db, project)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteProject(db *gorm.DB, table, projectID string) error {
|
func DeleteProject(db *gorm.DB, table, projectID string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.ProjectViewSearchKeyProjectID), projectID)
|
delete := repository.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.ProjectViewSearchKeyProjectID), projectID)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
token_model "github.com/caos/zitadel/internal/token/model"
|
token_model "github.com/caos/zitadel/internal/token/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TokenSearchRequest token_model.TokenSearchRequest
|
type TokenSearchRequest token_model.TokenSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req TokenSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req TokenSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req TokenSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == token_model.TokenSearchKeyUnspecified {
|
if req.SortingColumn == token_model.TokenSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req TokenSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req TokenSearchRequest) GetQueries() []view.SearchQuery {
|
func (req TokenSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = TokenSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = TokenSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req TokenSearchQuery) GetKey() view.ColumnKey {
|
func (req TokenSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return TokenSearchKey(req.Key)
|
return TokenSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
@ -9,12 +10,11 @@ import (
|
|||||||
"github.com/caos/zitadel/internal/errors"
|
"github.com/caos/zitadel/internal/errors"
|
||||||
token_model "github.com/caos/zitadel/internal/token/model"
|
token_model "github.com/caos/zitadel/internal/token/model"
|
||||||
"github.com/caos/zitadel/internal/token/repository/view/model"
|
"github.com/caos/zitadel/internal/token/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TokenByID(db *gorm.DB, table, tokenID string) (*model.Token, error) {
|
func TokenByID(db *gorm.DB, table, tokenID string) (*model.Token, error) {
|
||||||
token := new(model.Token)
|
token := new(model.Token)
|
||||||
query := view.PrepareGetByKey(table, model.TokenSearchKey(token_model.TokenSearchKeyTokenID), tokenID)
|
query := repository.PrepareGetByKey(table, model.TokenSearchKey(token_model.TokenSearchKeyTokenID), tokenID)
|
||||||
err := query(db, token)
|
err := query(db, token)
|
||||||
return token, err
|
return token, err
|
||||||
}
|
}
|
||||||
@ -31,29 +31,29 @@ func IsTokenValid(db *gorm.DB, table, tokenID string) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutToken(db *gorm.DB, table string, token *model.Token) error {
|
func PutToken(db *gorm.DB, table string, token *model.Token) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, token)
|
return save(db, token)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteToken(db *gorm.DB, table, tokenID string) error {
|
func DeleteToken(db *gorm.DB, table, tokenID string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.TokenSearchKey(token_model.TokenSearchKeyTokenID), tokenID)
|
delete := repository.PrepareDeleteByKey(table, model.TokenSearchKey(token_model.TokenSearchKeyTokenID), tokenID)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteSessionTokens(db *gorm.DB, table, agentID, userID string) error {
|
func DeleteSessionTokens(db *gorm.DB, table, agentID, userID string) error {
|
||||||
delete := view.PrepareDeleteByKeys(table,
|
delete := repository.PrepareDeleteByKeys(table,
|
||||||
view.Key{Key: model.TokenSearchKey(token_model.TokenSearchKeyUserAgentID), Value: agentID},
|
repository.Key{Key: model.TokenSearchKey(token_model.TokenSearchKeyUserAgentID), Value: agentID},
|
||||||
view.Key{Key: model.TokenSearchKey(token_model.TokenSearchKeyUserID), Value: userID},
|
repository.Key{Key: model.TokenSearchKey(token_model.TokenSearchKeyUserID), Value: userID},
|
||||||
)
|
)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteUserTokens(db *gorm.DB, table, userID string) error {
|
func DeleteUserTokens(db *gorm.DB, table, userID string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.TokenSearchKey(token_model.TokenSearchKeyUserID), userID)
|
delete := repository.PrepareDeleteByKey(table, model.TokenSearchKey(token_model.TokenSearchKeyUserID), userID)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteApplicationTokens(db *gorm.DB, table string, appIDs []string) error {
|
func DeleteApplicationTokens(db *gorm.DB, table string, appIDs []string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.TokenSearchKey(token_model.TokenSearchKeyApplicationID), pq.StringArray(appIDs))
|
delete := repository.PrepareDeleteByKey(table, model.TokenSearchKey(token_model.TokenSearchKeyApplicationID), pq.StringArray(appIDs))
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserSearchRequest usr_model.UserSearchRequest
|
type UserSearchRequest usr_model.UserSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req UserSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req UserSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req UserSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == usr_model.UserSearchKeyUnspecified {
|
if req.SortingColumn == usr_model.UserSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req UserSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req UserSearchRequest) GetQueries() []view.SearchQuery {
|
func (req UserSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = UserSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = UserSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req UserSearchQuery) GetKey() view.ColumnKey {
|
func (req UserSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return UserSearchKey(req.Key)
|
return UserSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserSessionSearchRequest usr_model.UserSessionSearchRequest
|
type UserSessionSearchRequest usr_model.UserSessionSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req UserSessionSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req UserSessionSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req UserSessionSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == usr_model.UserSessionSearchKeyUnspecified {
|
if req.SortingColumn == usr_model.UserSessionSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req UserSessionSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req UserSessionSearchRequest) GetQueries() []view.SearchQuery {
|
func (req UserSessionSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = UserSessionSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = UserSessionSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req UserSessionSearchQuery) GetKey() view.ColumnKey {
|
func (req UserSessionSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return UserSessionSearchKey(req.Key)
|
return UserSessionSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,23 +3,23 @@ package view
|
|||||||
import (
|
import (
|
||||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||||
"github.com/caos/zitadel/internal/user/repository/view/model"
|
"github.com/caos/zitadel/internal/user/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NotifyUserByID(db *gorm.DB, table, userID string) (*model.NotifyUser, error) {
|
func NotifyUserByID(db *gorm.DB, table, userID string) (*model.NotifyUser, error) {
|
||||||
user := new(model.NotifyUser)
|
user := new(model.NotifyUser)
|
||||||
query := view.PrepareGetByKey(table, model.UserSearchKey(usr_model.NotifyUserSearchKeyUserID), userID)
|
query := repository.PrepareGetByKey(table, model.UserSearchKey(usr_model.NotifyUserSearchKeyUserID), userID)
|
||||||
err := query(db, user)
|
err := query(db, user)
|
||||||
return user, err
|
return user, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func PutNotifyUser(db *gorm.DB, table string, project *model.NotifyUser) error {
|
func PutNotifyUser(db *gorm.DB, table string, project *model.NotifyUser) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, project)
|
return save(db, project)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteNotifyUser(db *gorm.DB, table, userID string) error {
|
func DeleteNotifyUser(db *gorm.DB, table, userID string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.UserSearchKey(usr_model.NotifyUserSearchKeyUserID), userID)
|
delete := repository.PrepareDeleteByKey(table, model.UserSearchKey(usr_model.NotifyUserSearchKeyUserID), userID)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
|
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||||
"github.com/caos/zitadel/internal/user/repository/view/model"
|
"github.com/caos/zitadel/internal/user/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func UserSessionByIDs(db *gorm.DB, table, agentID, userID string) (*model.UserSessionView, error) {
|
func UserSessionByIDs(db *gorm.DB, table, agentID, userID string) (*model.UserSessionView, error) {
|
||||||
@ -21,7 +21,7 @@ func UserSessionByIDs(db *gorm.DB, table, agentID, userID string) (*model.UserSe
|
|||||||
Method: global_model.SearchMethodEquals,
|
Method: global_model.SearchMethodEquals,
|
||||||
Value: userID,
|
Value: userID,
|
||||||
}
|
}
|
||||||
query := view.PrepareGetByQuery(table, userAgentQuery, userQuery)
|
query := repository.PrepareGetByQuery(table, userAgentQuery, userQuery)
|
||||||
err := query(db, userSession)
|
err := query(db, userSession)
|
||||||
return userSession, err
|
return userSession, err
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ func UserSessionsByUserID(db *gorm.DB, table, userID string) ([]*model.UserSessi
|
|||||||
Method: global_model.SearchMethodEquals,
|
Method: global_model.SearchMethodEquals,
|
||||||
Value: userID,
|
Value: userID,
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.UserSessionSearchRequest{
|
query := repository.PrepareSearchQuery(table, model.UserSessionSearchRequest{
|
||||||
Queries: []*usr_model.UserSessionSearchQuery{userAgentQuery},
|
Queries: []*usr_model.UserSessionSearchQuery{userAgentQuery},
|
||||||
})
|
})
|
||||||
_, err := query(db, &userSessions)
|
_, err := query(db, &userSessions)
|
||||||
@ -47,7 +47,7 @@ func UserSessionsByAgentID(db *gorm.DB, table, agentID string) ([]*model.UserSes
|
|||||||
Method: global_model.SearchMethodEquals,
|
Method: global_model.SearchMethodEquals,
|
||||||
Value: agentID,
|
Value: agentID,
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.UserSessionSearchRequest{
|
query := repository.PrepareSearchQuery(table, model.UserSessionSearchRequest{
|
||||||
Queries: []*usr_model.UserSessionSearchQuery{userAgentQuery},
|
Queries: []*usr_model.UserSessionSearchQuery{userAgentQuery},
|
||||||
})
|
})
|
||||||
_, err := query(db, &userSessions)
|
_, err := query(db, &userSessions)
|
||||||
@ -55,11 +55,11 @@ func UserSessionsByAgentID(db *gorm.DB, table, agentID string) ([]*model.UserSes
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutUserSession(db *gorm.DB, table string, session *model.UserSessionView) error {
|
func PutUserSession(db *gorm.DB, table string, session *model.UserSessionView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, session)
|
return save(db, session)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteUserSessions(db *gorm.DB, table, userID string) error {
|
func DeleteUserSessions(db *gorm.DB, table, userID string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.UserSessionSearchKey(usr_model.UserSessionSearchKeyUserID), userID)
|
delete := repository.PrepareDeleteByKey(table, model.UserSessionSearchKey(usr_model.UserSessionSearchKeyUserID), userID)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
|
|
||||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||||
"github.com/caos/zitadel/internal/user/repository/view/model"
|
"github.com/caos/zitadel/internal/user/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func UserByID(db *gorm.DB, table, userID string) (*model.UserView, error) {
|
func UserByID(db *gorm.DB, table, userID string) (*model.UserView, error) {
|
||||||
user := new(model.UserView)
|
user := new(model.UserView)
|
||||||
query := view.PrepareGetByKey(table, model.UserSearchKey(usr_model.UserSearchKeyUserID), userID)
|
query := repository.PrepareGetByKey(table, model.UserSearchKey(usr_model.UserSearchKeyUserID), userID)
|
||||||
err := query(db, user)
|
err := query(db, user)
|
||||||
if caos_errs.IsNotFound(err) {
|
if caos_errs.IsNotFound(err) {
|
||||||
return nil, caos_errs.ThrowNotFound(nil, "VIEW-sj8Sw", "Errors.User.NotFound")
|
return nil, caos_errs.ThrowNotFound(nil, "VIEW-sj8Sw", "Errors.User.NotFound")
|
||||||
@ -22,7 +22,7 @@ func UserByID(db *gorm.DB, table, userID string) (*model.UserView, error) {
|
|||||||
|
|
||||||
func UserByUserName(db *gorm.DB, table, userName string) (*model.UserView, error) {
|
func UserByUserName(db *gorm.DB, table, userName string) (*model.UserView, error) {
|
||||||
user := new(model.UserView)
|
user := new(model.UserView)
|
||||||
query := view.PrepareGetByKey(table, model.UserSearchKey(usr_model.UserSearchKeyUserName), userName)
|
query := repository.PrepareGetByKey(table, model.UserSearchKey(usr_model.UserSearchKeyUserName), userName)
|
||||||
err := query(db, user)
|
err := query(db, user)
|
||||||
if caos_errs.IsNotFound(err) {
|
if caos_errs.IsNotFound(err) {
|
||||||
return nil, caos_errs.ThrowNotFound(nil, "VIEW-Lso9s", "Errors.User.NotFound")
|
return nil, caos_errs.ThrowNotFound(nil, "VIEW-Lso9s", "Errors.User.NotFound")
|
||||||
@ -37,7 +37,7 @@ func UserByLoginName(db *gorm.DB, table, loginName string) (*model.UserView, err
|
|||||||
Method: global_model.SearchMethodListContains,
|
Method: global_model.SearchMethodListContains,
|
||||||
Value: loginName,
|
Value: loginName,
|
||||||
}
|
}
|
||||||
query := view.PrepareGetByQuery(table, loginNameQuery)
|
query := repository.PrepareGetByQuery(table, loginNameQuery)
|
||||||
err := query(db, user)
|
err := query(db, user)
|
||||||
return user, err
|
return user, err
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ func UsersByOrgID(db *gorm.DB, table, orgID string) ([]*model.UserView, error) {
|
|||||||
Method: global_model.SearchMethodEquals,
|
Method: global_model.SearchMethodEquals,
|
||||||
Value: orgID,
|
Value: orgID,
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.UserSearchRequest{
|
query := repository.PrepareSearchQuery(table, model.UserSearchRequest{
|
||||||
Queries: []*usr_model.UserSearchQuery{orgIDQuery},
|
Queries: []*usr_model.UserSearchQuery{orgIDQuery},
|
||||||
})
|
})
|
||||||
_, err := query(db, &users)
|
_, err := query(db, &users)
|
||||||
@ -58,7 +58,7 @@ func UsersByOrgID(db *gorm.DB, table, orgID string) ([]*model.UserView, error) {
|
|||||||
|
|
||||||
func SearchUsers(db *gorm.DB, table string, req *usr_model.UserSearchRequest) ([]*model.UserView, int, error) {
|
func SearchUsers(db *gorm.DB, table string, req *usr_model.UserSearchRequest) ([]*model.UserView, int, error) {
|
||||||
users := make([]*model.UserView, 0)
|
users := make([]*model.UserView, 0)
|
||||||
query := view.PrepareSearchQuery(table, model.UserSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
query := repository.PrepareSearchQuery(table, model.UserSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
count, err := query(db, &users)
|
count, err := query(db, &users)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -68,7 +68,7 @@ func SearchUsers(db *gorm.DB, table string, req *usr_model.UserSearchRequest) ([
|
|||||||
|
|
||||||
func GetGlobalUserByEmail(db *gorm.DB, table, email string) (*model.UserView, error) {
|
func GetGlobalUserByEmail(db *gorm.DB, table, email string) (*model.UserView, error) {
|
||||||
user := new(model.UserView)
|
user := new(model.UserView)
|
||||||
query := view.PrepareGetByKey(table, model.UserSearchKey(usr_model.UserSearchKeyEmail), email)
|
query := repository.PrepareGetByKey(table, model.UserSearchKey(usr_model.UserSearchKeyEmail), email)
|
||||||
err := query(db, user)
|
err := query(db, user)
|
||||||
if caos_errs.IsNotFound(err) {
|
if caos_errs.IsNotFound(err) {
|
||||||
return nil, caos_errs.ThrowNotFound(nil, "VIEW-8uWer", "Errors.User.NotFound")
|
return nil, caos_errs.ThrowNotFound(nil, "VIEW-8uWer", "Errors.User.NotFound")
|
||||||
@ -78,7 +78,7 @@ func GetGlobalUserByEmail(db *gorm.DB, table, email string) (*model.UserView, er
|
|||||||
|
|
||||||
func IsUserUnique(db *gorm.DB, table, userName, email string) (bool, error) {
|
func IsUserUnique(db *gorm.DB, table, userName, email string) (bool, error) {
|
||||||
user := new(model.UserView)
|
user := new(model.UserView)
|
||||||
query := view.PrepareGetByKey(table, model.UserSearchKey(usr_model.UserSearchKeyEmail), email)
|
query := repository.PrepareGetByKey(table, model.UserSearchKey(usr_model.UserSearchKeyEmail), email)
|
||||||
err := query(db, user)
|
err := query(db, user)
|
||||||
if err != nil && !caos_errs.IsNotFound(err) {
|
if err != nil && !caos_errs.IsNotFound(err) {
|
||||||
return false, err
|
return false, err
|
||||||
@ -86,7 +86,7 @@ func IsUserUnique(db *gorm.DB, table, userName, email string) (bool, error) {
|
|||||||
if user != nil {
|
if user != nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
query = view.PrepareGetByKey(table, model.UserSearchKey(usr_model.UserSearchKeyUserName), email)
|
query = repository.PrepareGetByKey(table, model.UserSearchKey(usr_model.UserSearchKeyUserName), email)
|
||||||
err = query(db, user)
|
err = query(db, user)
|
||||||
if err != nil && !caos_errs.IsNotFound(err) {
|
if err != nil && !caos_errs.IsNotFound(err) {
|
||||||
return false, err
|
return false, err
|
||||||
@ -106,11 +106,11 @@ func UserMfas(db *gorm.DB, table, userID string) ([]*usr_model.MultiFactor, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutUser(db *gorm.DB, table string, project *model.UserView) error {
|
func PutUser(db *gorm.DB, table string, project *model.UserView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, project)
|
return save(db, project)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteUser(db *gorm.DB, table, userID string) error {
|
func DeleteUser(db *gorm.DB, table, userID string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.UserSearchKey(usr_model.UserSearchKeyUserID), userID)
|
delete := repository.PrepareDeleteByKey(table, model.UserSearchKey(usr_model.UserSearchKeyUserID), userID)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
grant_model "github.com/caos/zitadel/internal/usergrant/model"
|
grant_model "github.com/caos/zitadel/internal/usergrant/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserGrantSearchRequest grant_model.UserGrantSearchRequest
|
type UserGrantSearchRequest grant_model.UserGrantSearchRequest
|
||||||
@ -18,7 +18,7 @@ func (req UserGrantSearchRequest) GetOffset() uint64 {
|
|||||||
return req.Offset
|
return req.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req UserGrantSearchRequest) GetSortingColumn() view.ColumnKey {
|
func (req UserGrantSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||||
if req.SortingColumn == grant_model.UserGrantSearchKeyUnspecified {
|
if req.SortingColumn == grant_model.UserGrantSearchKeyUnspecified {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ func (req UserGrantSearchRequest) GetAsc() bool {
|
|||||||
return req.Asc
|
return req.Asc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req UserGrantSearchRequest) GetQueries() []view.SearchQuery {
|
func (req UserGrantSearchRequest) GetQueries() []repository.SearchQuery {
|
||||||
result := make([]view.SearchQuery, len(req.Queries))
|
result := make([]repository.SearchQuery, len(req.Queries))
|
||||||
for i, q := range req.Queries {
|
for i, q := range req.Queries {
|
||||||
result[i] = UserGrantSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
result[i] = UserGrantSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req UserGrantSearchQuery) GetKey() view.ColumnKey {
|
func (req UserGrantSearchQuery) GetKey() repository.ColumnKey {
|
||||||
return UserGrantSearchKey(req.Key)
|
return UserGrantSearchKey(req.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ import (
|
|||||||
global_model "github.com/caos/zitadel/internal/model"
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
grant_model "github.com/caos/zitadel/internal/usergrant/model"
|
grant_model "github.com/caos/zitadel/internal/usergrant/model"
|
||||||
"github.com/caos/zitadel/internal/usergrant/repository/view/model"
|
"github.com/caos/zitadel/internal/usergrant/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view"
|
"github.com/caos/zitadel/internal/view/repository"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func UserGrantByID(db *gorm.DB, table, grantID string) (*model.UserGrantView, error) {
|
func UserGrantByID(db *gorm.DB, table, grantID string) (*model.UserGrantView, error) {
|
||||||
user := new(model.UserGrantView)
|
user := new(model.UserGrantView)
|
||||||
query := view.PrepareGetByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyGrantID), grantID)
|
query := repository.PrepareGetByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyGrantID), grantID)
|
||||||
err := query(db, user)
|
err := query(db, user)
|
||||||
return user, err
|
return user, err
|
||||||
}
|
}
|
||||||
@ -21,14 +21,14 @@ func UserGrantByIDs(db *gorm.DB, table, resourceOwnerID, projectID, userID strin
|
|||||||
resourceOwnerIDQuery := model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyResourceOwner, Value: resourceOwnerID, Method: global_model.SearchMethodEquals}
|
resourceOwnerIDQuery := model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyResourceOwner, Value: resourceOwnerID, Method: global_model.SearchMethodEquals}
|
||||||
projectIDQuery := model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
projectIDQuery := model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||||
userIDQuery := model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
userIDQuery := model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
||||||
query := view.PrepareGetByQuery(table, resourceOwnerIDQuery, projectIDQuery, userIDQuery)
|
query := repository.PrepareGetByQuery(table, resourceOwnerIDQuery, projectIDQuery, userIDQuery)
|
||||||
err := query(db, user)
|
err := query(db, user)
|
||||||
return user, err
|
return user, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SearchUserGrants(db *gorm.DB, table string, req *grant_model.UserGrantSearchRequest) ([]*model.UserGrantView, int, error) {
|
func SearchUserGrants(db *gorm.DB, table string, req *grant_model.UserGrantSearchRequest) ([]*model.UserGrantView, int, error) {
|
||||||
users := make([]*model.UserGrantView, 0)
|
users := make([]*model.UserGrantView, 0)
|
||||||
query := view.PrepareSearchQuery(table, model.UserGrantSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
query := repository.PrepareSearchQuery(table, model.UserGrantSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||||
count, err := query(db, &users)
|
count, err := query(db, &users)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -41,7 +41,7 @@ func UserGrantsByUserID(db *gorm.DB, table, userID string) ([]*model.UserGrantVi
|
|||||||
queries := []*grant_model.UserGrantSearchQuery{
|
queries := []*grant_model.UserGrantSearchQuery{
|
||||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals},
|
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &users)
|
_, err := query(db, &users)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -54,7 +54,7 @@ func UserGrantsByProjectID(db *gorm.DB, table, projectID string) ([]*model.UserG
|
|||||||
queries := []*grant_model.UserGrantSearchQuery{
|
queries := []*grant_model.UserGrantSearchQuery{
|
||||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &users)
|
_, err := query(db, &users)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -68,7 +68,7 @@ func UserGrantsByProjectIDAndRole(db *gorm.DB, table, projectID, roleKey string)
|
|||||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyRoleKey, Value: roleKey, Method: global_model.SearchMethodListContains},
|
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyRoleKey, Value: roleKey, Method: global_model.SearchMethodListContains},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &users)
|
_, err := query(db, &users)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -82,7 +82,7 @@ func UserGrantsByOrgIDAndProjectID(db *gorm.DB, table, orgID, projectID string)
|
|||||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyResourceOwner, Value: orgID, Method: global_model.SearchMethodEquals},
|
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyResourceOwner, Value: orgID, Method: global_model.SearchMethodEquals},
|
||||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &users)
|
_, err := query(db, &users)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -95,7 +95,7 @@ func UserGrantsByOrgID(db *gorm.DB, table, orgID string) ([]*model.UserGrantView
|
|||||||
queries := []*grant_model.UserGrantSearchQuery{
|
queries := []*grant_model.UserGrantSearchQuery{
|
||||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyResourceOwner, Value: orgID, Method: global_model.SearchMethodEquals},
|
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyResourceOwner, Value: orgID, Method: global_model.SearchMethodEquals},
|
||||||
}
|
}
|
||||||
query := view.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
query := repository.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
||||||
_, err := query(db, &users)
|
_, err := query(db, &users)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -104,11 +104,11 @@ func UserGrantsByOrgID(db *gorm.DB, table, orgID string) ([]*model.UserGrantView
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PutUserGrant(db *gorm.DB, table string, grant *model.UserGrantView) error {
|
func PutUserGrant(db *gorm.DB, table string, grant *model.UserGrantView) error {
|
||||||
save := view.PrepareSave(table)
|
save := repository.PrepareSave(table)
|
||||||
return save(db, grant)
|
return save(db, grant)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteUserGrant(db *gorm.DB, table, grantID string) error {
|
func DeleteUserGrant(db *gorm.DB, table, grantID string) error {
|
||||||
delete := view.PrepareDeleteByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyGrantID), grantID)
|
delete := repository.PrepareDeleteByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyGrantID), grantID)
|
||||||
return delete(db)
|
return delete(db)
|
||||||
}
|
}
|
||||||
|
9
internal/view/model/failed_event.go
Normal file
9
internal/view/model/failed_event.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
type FailedEvent struct {
|
||||||
|
Database string
|
||||||
|
ViewName string
|
||||||
|
FailedSequence uint64
|
||||||
|
FailureCount uint64
|
||||||
|
ErrMsg string
|
||||||
|
}
|
23
internal/view/model/general_query.go
Normal file
23
internal/view/model/general_query.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "github.com/caos/zitadel/internal/model"
|
||||||
|
|
||||||
|
type GeneralSearchRequest struct {
|
||||||
|
Offset uint64
|
||||||
|
Limit uint64
|
||||||
|
SortingColumn GeneralSearchKey
|
||||||
|
Asc bool
|
||||||
|
Queries []*GeneralSearchQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
type GeneralSearchKey int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
GeneralSearchKeyUnspecified GeneralSearchKey = iota
|
||||||
|
)
|
||||||
|
|
||||||
|
type GeneralSearchQuery struct {
|
||||||
|
Key GeneralSearchKey
|
||||||
|
Method model.SearchMethod
|
||||||
|
Value interface{}
|
||||||
|
}
|
7
internal/view/model/view.go
Normal file
7
internal/view/model/view.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
type View struct {
|
||||||
|
Database string
|
||||||
|
ViewName string
|
||||||
|
CurrentSequence uint64
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package view
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
@ -1,4 +1,4 @@
|
|||||||
package view
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
@ -28,6 +28,7 @@ var (
|
|||||||
}
|
}
|
||||||
expectedRemoveByObject = `DELETE FROM "%s" WHERE "%s"."%s" = \$1`
|
expectedRemoveByObject = `DELETE FROM "%s" WHERE "%s"."%s" = \$1`
|
||||||
expectedRemoveByObjectMultiplePK = `DELETE FROM "%s" WHERE "%s"."%s" = \$1 AND "%s"."%s" = \$2`
|
expectedRemoveByObjectMultiplePK = `DELETE FROM "%s" WHERE "%s"."%s" = \$1 AND "%s"."%s" = \$2`
|
||||||
|
expectedTruncate = `TRUNCATE %s;`
|
||||||
expectedSearch = `SELECT \* FROM "%s" OFFSET 0`
|
expectedSearch = `SELECT \* FROM "%s" OFFSET 0`
|
||||||
expectedSearchCount = `SELECT count\(\*\) FROM "%s"`
|
expectedSearchCount = `SELECT count\(\*\) FROM "%s"`
|
||||||
expectedSearchLimit = `SELECT \* FROM "%s" LIMIT %v OFFSET 0`
|
expectedSearchLimit = `SELECT \* FROM "%s" LIMIT %v OFFSET 0`
|
||||||
@ -289,6 +290,20 @@ func (db *dbMock) expectRemoveErr(table, key, value string, err error) *dbMock {
|
|||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *dbMock) expectTruncate(table string) *dbMock {
|
||||||
|
query := fmt.Sprintf(expectedTruncate, table)
|
||||||
|
db.mock.ExpectExec(query).
|
||||||
|
WillReturnResult(sqlmock.NewResult(1, 1))
|
||||||
|
|
||||||
|
return db
|
||||||
|
}
|
||||||
|
func (db *dbMock) expectTruncateErr(table string, err error) *dbMock {
|
||||||
|
query := fmt.Sprintf(expectedTruncate, table)
|
||||||
|
db.mock.ExpectExec(query).
|
||||||
|
WillReturnError(err)
|
||||||
|
|
||||||
|
return db
|
||||||
|
}
|
||||||
func (db *dbMock) expectGetSearchRequestNoParams(table string, resultAmount, total int) *dbMock {
|
func (db *dbMock) expectGetSearchRequestNoParams(table string, resultAmount, total int) *dbMock {
|
||||||
query := fmt.Sprintf(expectedSearch, table)
|
query := fmt.Sprintf(expectedSearch, table)
|
||||||
queryCount := fmt.Sprintf(expectedSearchCount, table)
|
queryCount := fmt.Sprintf(expectedSearchCount, table)
|
@ -1,9 +1,11 @@
|
|||||||
package view
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/errors"
|
"github.com/caos/zitadel/internal/errors"
|
||||||
"github.com/caos/zitadel/internal/model"
|
"github.com/caos/zitadel/internal/model"
|
||||||
|
view_model "github.com/caos/zitadel/internal/view/model"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -57,6 +59,25 @@ func (key failedEventSearchKey) ToColumnName() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FailedEventFromModel(failedEvent *view_model.FailedEvent) *FailedEvent {
|
||||||
|
return &FailedEvent{
|
||||||
|
ViewName: failedEvent.Database + "." + failedEvent.ViewName,
|
||||||
|
FailureCount: failedEvent.FailureCount,
|
||||||
|
FailedSequence: failedEvent.FailedSequence,
|
||||||
|
ErrMsg: failedEvent.ErrMsg,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func FailedEventToModel(failedEvent *FailedEvent) *view_model.FailedEvent {
|
||||||
|
dbView := strings.Split(failedEvent.ViewName, ".")
|
||||||
|
return &view_model.FailedEvent{
|
||||||
|
Database: dbView[0],
|
||||||
|
ViewName: dbView[1],
|
||||||
|
FailureCount: failedEvent.FailureCount,
|
||||||
|
FailedSequence: failedEvent.FailedSequence,
|
||||||
|
ErrMsg: failedEvent.ErrMsg,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func SaveFailedEvent(db *gorm.DB, table string, failedEvent *FailedEvent) error {
|
func SaveFailedEvent(db *gorm.DB, table string, failedEvent *FailedEvent) error {
|
||||||
save := PrepareSave(table)
|
save := PrepareSave(table)
|
||||||
err := save(db, failedEvent)
|
err := save(db, failedEvent)
|
||||||
@ -67,6 +88,14 @@ func SaveFailedEvent(db *gorm.DB, table string, failedEvent *FailedEvent) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RemoveFailedEvent(db *gorm.DB, table string, failedEvent *FailedEvent) error {
|
||||||
|
delete := PrepareDeleteByKeys(table,
|
||||||
|
Key{Key: failedEventSearchKey(FailedEventKeyViewName), Value: failedEvent.ViewName},
|
||||||
|
Key{Key: failedEventSearchKey(FailedEventKeyFailedSequence), Value: failedEvent.FailedSequence},
|
||||||
|
)
|
||||||
|
return delete(db)
|
||||||
|
}
|
||||||
|
|
||||||
func LatestFailedEvent(db *gorm.DB, table, viewName string, sequence uint64) (*FailedEvent, error) {
|
func LatestFailedEvent(db *gorm.DB, table, viewName string, sequence uint64) (*FailedEvent, error) {
|
||||||
failedEvent := new(FailedEvent)
|
failedEvent := new(FailedEvent)
|
||||||
queries := []SearchQuery{
|
queries := []SearchQuery{
|
||||||
@ -90,3 +119,13 @@ func LatestFailedEvent(db *gorm.DB, table, viewName string, sequence uint64) (*F
|
|||||||
return nil, errors.ThrowInternalf(err, "VIEW-9LyCB", "unable to get failed events of %s", viewName)
|
return nil, errors.ThrowInternalf(err, "VIEW-9LyCB", "unable to get failed events of %s", viewName)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AllFailedEvents(db *gorm.DB, table string) ([]*FailedEvent, error) {
|
||||||
|
failedEvents := make([]*FailedEvent, 0)
|
||||||
|
query := PrepareSearchQuery(table, GeneralSearchRequest{})
|
||||||
|
_, err := query(db, &failedEvents)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return failedEvents, nil
|
||||||
|
}
|
53
internal/view/repository/general_query.go
Normal file
53
internal/view/repository/general_query.go
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
|
"github.com/caos/zitadel/internal/view/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GeneralSearchRequest model.GeneralSearchRequest
|
||||||
|
type GeneralSearchQuery model.GeneralSearchQuery
|
||||||
|
type GeneralSearchKey model.GeneralSearchKey
|
||||||
|
|
||||||
|
func (req GeneralSearchRequest) GetLimit() uint64 {
|
||||||
|
return req.Limit
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req GeneralSearchRequest) GetOffset() uint64 {
|
||||||
|
return req.Offset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req GeneralSearchRequest) GetSortingColumn() ColumnKey {
|
||||||
|
if req.SortingColumn == model.GeneralSearchKeyUnspecified {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return GeneralSearchKey(req.SortingColumn)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req GeneralSearchRequest) GetAsc() bool {
|
||||||
|
return req.Asc
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req GeneralSearchRequest) GetQueries() []SearchQuery {
|
||||||
|
result := make([]SearchQuery, len(req.Queries))
|
||||||
|
for i, q := range req.Queries {
|
||||||
|
result[i] = GeneralSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req GeneralSearchQuery) GetKey() ColumnKey {
|
||||||
|
return GeneralSearchKey(req.Key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req GeneralSearchQuery) GetMethod() global_model.SearchMethod {
|
||||||
|
return req.Method
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req GeneralSearchQuery) GetValue() interface{} {
|
||||||
|
return req.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (key GeneralSearchKey) ToColumnName() string {
|
||||||
|
return ""
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package view
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package view
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
caos_errs "github.com/caos/zitadel/internal/errors"
|
@ -1,4 +1,4 @@
|
|||||||
package view
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@ -105,3 +105,15 @@ func PrepareDeleteByObject(table string, object interface{}) func(db *gorm.DB) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PrepareTruncate(table string) func(db *gorm.DB) error {
|
||||||
|
return func(db *gorm.DB) error {
|
||||||
|
err := db.
|
||||||
|
Exec("TRUNCATE " + table).
|
||||||
|
Error
|
||||||
|
if err != nil {
|
||||||
|
return caos_errs.ThrowInternal(err, "VIEW-lso9w", "could not truncate table")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package view
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
caos_errs "github.com/caos/zitadel/internal/errors"
|
@ -1,15 +1,17 @@
|
|||||||
package view
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||||
|
"github.com/caos/zitadel/internal/view/model"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type actualSequece struct {
|
type actualSequece struct {
|
||||||
ActualSequence uint64 `gorm:"column:current_sequence"`
|
ActualSequence uint64 `gorm:"column:current_sequence"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type currentSequence struct {
|
type CurrentSequence struct {
|
||||||
ViewName string `gorm:"column:view_name;primary_key"`
|
ViewName string `gorm:"column:view_name;primary_key"`
|
||||||
CurrentSequence uint64 `gorm:"column:current_sequence"`
|
CurrentSequence uint64 `gorm:"column:current_sequence"`
|
||||||
}
|
}
|
||||||
@ -32,9 +34,18 @@ func (key sequenceSearchKey) ToColumnName() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CurrentSequenceToModel(sequence *CurrentSequence) *model.View {
|
||||||
|
dbView := strings.Split(sequence.ViewName, ".")
|
||||||
|
return &model.View{
|
||||||
|
Database: dbView[0],
|
||||||
|
ViewName: dbView[1],
|
||||||
|
CurrentSequence: sequence.CurrentSequence,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func SaveCurrentSequence(db *gorm.DB, table, viewName string, sequence uint64) error {
|
func SaveCurrentSequence(db *gorm.DB, table, viewName string, sequence uint64) error {
|
||||||
save := PrepareSave(table)
|
save := PrepareSave(table)
|
||||||
err := save(db, ¤tSequence{viewName, sequence})
|
err := save(db, &CurrentSequence{viewName, sequence})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return caos_errs.ThrowInternal(err, "VIEW-5kOhP", "unable to updated processed sequence")
|
return caos_errs.ThrowInternal(err, "VIEW-5kOhP", "unable to updated processed sequence")
|
||||||
@ -56,3 +67,22 @@ func LatestSequence(db *gorm.DB, table, viewName string) (uint64, error) {
|
|||||||
}
|
}
|
||||||
return 0, caos_errs.ThrowInternalf(err, "VIEW-9LyCB", "unable to get latest sequence of %s", viewName)
|
return 0, caos_errs.ThrowInternalf(err, "VIEW-9LyCB", "unable to get latest sequence of %s", viewName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AllCurrentSequences(db *gorm.DB, table string) ([]*CurrentSequence, error) {
|
||||||
|
sequences := make([]*CurrentSequence, 0)
|
||||||
|
query := PrepareSearchQuery(table, GeneralSearchRequest{})
|
||||||
|
_, err := query(db, &sequences)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return sequences, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ClearView(db *gorm.DB, truncateView, sequenceTable string) error {
|
||||||
|
truncate := PrepareTruncate(truncateView)
|
||||||
|
err := truncate(db)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return SaveCurrentSequence(db, sequenceTable, truncateView, 0)
|
||||||
|
}
|
15
migrations/cockroach/V1.22__admin_view.sql
Normal file
15
migrations/cockroach/V1.22__admin_view.sql
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE auth TO admin_api;
|
||||||
|
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON TABLE auth.* TO admin_api;
|
||||||
|
|
||||||
|
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE authz TO admin_api;
|
||||||
|
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON TABLE authz.* TO admin_api;
|
||||||
|
|
||||||
|
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE management TO admin_api;
|
||||||
|
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON TABLE management.* TO admin_api;
|
||||||
|
|
||||||
|
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE notification TO admin_api;
|
||||||
|
GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON TABLE notification.* TO admin_api;
|
||||||
|
|
||||||
|
COMMIT;
|
@ -54,6 +54,26 @@ var AdminService_AuthMethods = utils_auth.MethodMapping{
|
|||||||
Permission: "iam.policy.delete",
|
Permission: "iam.policy.delete",
|
||||||
CheckParam: "",
|
CheckParam: "",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"/caos.zitadel.admin.api.v1.AdminService/GetViews": utils_auth.Option{
|
||||||
|
Permission: "iam.read",
|
||||||
|
CheckParam: "",
|
||||||
|
},
|
||||||
|
|
||||||
|
"/caos.zitadel.admin.api.v1.AdminService/ClearView": utils_auth.Option{
|
||||||
|
Permission: "iam.write",
|
||||||
|
CheckParam: "",
|
||||||
|
},
|
||||||
|
|
||||||
|
"/caos.zitadel.admin.api.v1.AdminService/GetFailedEvents": utils_auth.Option{
|
||||||
|
Permission: "iam.read",
|
||||||
|
CheckParam: "",
|
||||||
|
},
|
||||||
|
|
||||||
|
"/caos.zitadel.admin.api.v1.AdminService/RemoveFailedEvent": utils_auth.Option{
|
||||||
|
Permission: "iam.write",
|
||||||
|
CheckParam: "",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func AdminService_Authorization_Interceptor(verifier utils_auth.TokenVerifier, authConf *utils_auth.Config) grpc.UnaryServerInterceptor {
|
func AdminService_Authorization_Interceptor(verifier utils_auth.TokenVerifier, authConf *utils_auth.Config) grpc.UnaryServerInterceptor {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -38,15 +38,6 @@ func request_AdminService_Healthz_0(ctx context.Context, marshaler runtime.Marsh
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_AdminService_Healthz_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq empty.Empty
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
msg, err := server.Healthz(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func request_AdminService_Ready_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_AdminService_Ready_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq empty.Empty
|
var protoReq empty.Empty
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
@ -56,15 +47,6 @@ func request_AdminService_Ready_0(ctx context.Context, marshaler runtime.Marshal
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_AdminService_Ready_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq empty.Empty
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
msg, err := server.Ready(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func request_AdminService_Validate_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_AdminService_Validate_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq empty.Empty
|
var protoReq empty.Empty
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
@ -74,15 +56,6 @@ func request_AdminService_Validate_0(ctx context.Context, marshaler runtime.Mars
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_AdminService_Validate_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq empty.Empty
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
msg, err := server.Validate(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
filter_AdminService_IsOrgUnique_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
filter_AdminService_IsOrgUnique_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||||
)
|
)
|
||||||
@ -91,27 +64,11 @@ func request_AdminService_IsOrgUnique_0(ctx context.Context, marshaler runtime.M
|
|||||||
var protoReq UniqueOrgRequest
|
var protoReq UniqueOrgRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AdminService_IsOrgUnique_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.IsOrgUnique(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_AdminService_IsOrgUnique_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq UniqueOrgRequest
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_AdminService_IsOrgUnique_0); err != nil {
|
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_AdminService_IsOrgUnique_0); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := server.IsOrgUnique(ctx, &protoReq)
|
msg, err := client.IsOrgUnique(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -143,33 +100,6 @@ func request_AdminService_GetOrgByID_0(ctx context.Context, marshaler runtime.Ma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_AdminService_GetOrgByID_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq OrgID
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
var (
|
|
||||||
val string
|
|
||||||
ok bool
|
|
||||||
err error
|
|
||||||
_ = err
|
|
||||||
)
|
|
||||||
|
|
||||||
val, ok = pathParams["id"]
|
|
||||||
if !ok {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
|
||||||
}
|
|
||||||
|
|
||||||
protoReq.Id, err = runtime.String(val)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.GetOrgByID(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func request_AdminService_SearchOrgs_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_AdminService_SearchOrgs_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq OrgSearchRequest
|
var protoReq OrgSearchRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
@ -187,23 +117,6 @@ func request_AdminService_SearchOrgs_0(ctx context.Context, marshaler runtime.Ma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_AdminService_SearchOrgs_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq OrgSearchRequest
|
|
||||||
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 := server.SearchOrgs(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func request_AdminService_SetUpOrg_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_AdminService_SetUpOrg_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq OrgSetUpRequest
|
var protoReq OrgSetUpRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
@ -221,23 +134,6 @@ func request_AdminService_SetUpOrg_0(ctx context.Context, marshaler runtime.Mars
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_AdminService_SetUpOrg_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq OrgSetUpRequest
|
|
||||||
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 := server.SetUpOrg(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func request_AdminService_GetOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_AdminService_GetOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq OrgIamPolicyID
|
var protoReq OrgIamPolicyID
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
@ -265,33 +161,6 @@ func request_AdminService_GetOrgIamPolicy_0(ctx context.Context, marshaler runti
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_AdminService_GetOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq OrgIamPolicyID
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
var (
|
|
||||||
val string
|
|
||||||
ok bool
|
|
||||||
err error
|
|
||||||
_ = err
|
|
||||||
)
|
|
||||||
|
|
||||||
val, ok = pathParams["org_id"]
|
|
||||||
if !ok {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "org_id")
|
|
||||||
}
|
|
||||||
|
|
||||||
protoReq.OrgId, err = runtime.String(val)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "org_id", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.GetOrgIamPolicy(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func request_AdminService_CreateOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_AdminService_CreateOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq OrgIamPolicyRequest
|
var protoReq OrgIamPolicyRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
@ -327,41 +196,6 @@ func request_AdminService_CreateOrgIamPolicy_0(ctx context.Context, marshaler ru
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_AdminService_CreateOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq OrgIamPolicyRequest
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
val string
|
|
||||||
ok bool
|
|
||||||
err error
|
|
||||||
_ = err
|
|
||||||
)
|
|
||||||
|
|
||||||
val, ok = pathParams["org_id"]
|
|
||||||
if !ok {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "org_id")
|
|
||||||
}
|
|
||||||
|
|
||||||
protoReq.OrgId, err = runtime.String(val)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "org_id", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.CreateOrgIamPolicy(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func request_AdminService_UpdateOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_AdminService_UpdateOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq OrgIamPolicyRequest
|
var protoReq OrgIamPolicyRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
@ -397,41 +231,6 @@ func request_AdminService_UpdateOrgIamPolicy_0(ctx context.Context, marshaler ru
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_AdminService_UpdateOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq OrgIamPolicyRequest
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
val string
|
|
||||||
ok bool
|
|
||||||
err error
|
|
||||||
_ = err
|
|
||||||
)
|
|
||||||
|
|
||||||
val, ok = pathParams["org_id"]
|
|
||||||
if !ok {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "org_id")
|
|
||||||
}
|
|
||||||
|
|
||||||
protoReq.OrgId, err = runtime.String(val)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "org_id", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.UpdateOrgIamPolicy(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func request_AdminService_DeleteOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_AdminService_DeleteOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq OrgIamPolicyID
|
var protoReq OrgIamPolicyID
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
@ -459,8 +258,17 @@ func request_AdminService_DeleteOrgIamPolicy_0(ctx context.Context, marshaler ru
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_AdminService_DeleteOrgIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_AdminService_GetViews_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq OrgIamPolicyID
|
var protoReq empty.Empty
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
msg, err := client.GetViews(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func request_AdminService_ClearView_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq ViewID
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -470,248 +278,89 @@ func local_request_AdminService_DeleteOrgIamPolicy_0(ctx context.Context, marsha
|
|||||||
_ = err
|
_ = err
|
||||||
)
|
)
|
||||||
|
|
||||||
val, ok = pathParams["org_id"]
|
val, ok = pathParams["database"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "org_id")
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "database")
|
||||||
}
|
}
|
||||||
|
|
||||||
protoReq.OrgId, err = runtime.String(val)
|
protoReq.Database, err = runtime.String(val)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "org_id", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "database", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := server.DeleteOrgIamPolicy(ctx, &protoReq)
|
val, ok = pathParams["view_name"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "view_name")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.ViewName, err = runtime.String(val)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "view_name", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.ClearView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterAdminServiceHandlerServer registers the http handlers for service AdminService to "mux".
|
func request_AdminService_GetFailedEvents_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
// UnaryRPC :call AdminServiceServer directly.
|
var protoReq empty.Empty
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
var metadata runtime.ServerMetadata
|
||||||
func RegisterAdminServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AdminServiceServer, opts []grpc.DialOption) error {
|
|
||||||
|
|
||||||
mux.Handle("GET", pattern_AdminService_Healthz_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
msg, err := client.GetFailedEvents(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
return msg, metadata, err
|
||||||
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 := local_request_AdminService_Healthz_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_AdminService_Healthz_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
}
|
||||||
|
|
||||||
})
|
func request_AdminService_RemoveFailedEvent_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq FailedEventID
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
mux.Handle("GET", pattern_AdminService_Ready_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
var (
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
val string
|
||||||
defer cancel()
|
ok bool
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
err error
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
_ = err
|
||||||
if err != nil {
|
)
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_AdminService_Ready_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_AdminService_Ready_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
val, ok = pathParams["database"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "database")
|
||||||
|
}
|
||||||
|
|
||||||
})
|
protoReq.Database, err = runtime.String(val)
|
||||||
|
|
||||||
mux.Handle("GET", pattern_AdminService_Validate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
if err != nil {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "database", err)
|
||||||
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 := local_request_AdminService_Validate_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_AdminService_Validate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
val, ok = pathParams["view_name"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "view_name")
|
||||||
|
}
|
||||||
|
|
||||||
})
|
protoReq.ViewName, err = runtime.String(val)
|
||||||
|
|
||||||
mux.Handle("GET", pattern_AdminService_IsOrgUnique_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
if err != nil {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "view_name", err)
|
||||||
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 := local_request_AdminService_IsOrgUnique_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_AdminService_IsOrgUnique_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
val, ok = pathParams["failed_sequence"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "failed_sequence")
|
||||||
|
}
|
||||||
|
|
||||||
})
|
protoReq.FailedSequence, err = runtime.Uint64(val)
|
||||||
|
|
||||||
mux.Handle("GET", pattern_AdminService_GetOrgByID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
if err != nil {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "failed_sequence", err)
|
||||||
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 := local_request_AdminService_GetOrgByID_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_AdminService_GetOrgByID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
msg, err := client.RemoveFailedEvent(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_AdminService_SearchOrgs_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 := local_request_AdminService_SearchOrgs_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_AdminService_SearchOrgs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_AdminService_SetUpOrg_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 := local_request_AdminService_SetUpOrg_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_AdminService_SetUpOrg_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("GET", pattern_AdminService_GetOrgIamPolicy_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 := local_request_AdminService_GetOrgIamPolicy_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_AdminService_GetOrgIamPolicy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_AdminService_CreateOrgIamPolicy_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 := local_request_AdminService_CreateOrgIamPolicy_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_AdminService_CreateOrgIamPolicy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("PUT", pattern_AdminService_UpdateOrgIamPolicy_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 := local_request_AdminService_UpdateOrgIamPolicy_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_AdminService_UpdateOrgIamPolicy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("DELETE", pattern_AdminService_DeleteOrgIamPolicy_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 := local_request_AdminService_DeleteOrgIamPolicy_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_AdminService_DeleteOrgIamPolicy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterAdminServiceHandlerFromEndpoint is same as RegisterAdminServiceHandler but
|
// RegisterAdminServiceHandlerFromEndpoint is same as RegisterAdminServiceHandler but
|
||||||
@ -972,31 +621,119 @@ func RegisterAdminServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_AdminService_GetViews_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_AdminService_GetViews_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_AdminService_GetViews_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("POST", pattern_AdminService_ClearView_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_AdminService_ClearView_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_AdminService_ClearView_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_AdminService_GetFailedEvents_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_AdminService_GetFailedEvents_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_AdminService_GetFailedEvents_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("DELETE", pattern_AdminService_RemoveFailedEvent_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_AdminService_RemoveFailedEvent_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_AdminService_RemoveFailedEvent_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pattern_AdminService_Healthz_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"healthz"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_AdminService_Healthz_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"healthz"}, ""))
|
||||||
|
|
||||||
pattern_AdminService_Ready_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"ready"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_AdminService_Ready_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"ready"}, ""))
|
||||||
|
|
||||||
pattern_AdminService_Validate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"validate"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_AdminService_Validate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"validate"}, ""))
|
||||||
|
|
||||||
pattern_AdminService_IsOrgUnique_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_isunique"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_AdminService_IsOrgUnique_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_isunique"}, ""))
|
||||||
|
|
||||||
pattern_AdminService_GetOrgByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"orgs", "id"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_AdminService_GetOrgByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"orgs", "id"}, ""))
|
||||||
|
|
||||||
pattern_AdminService_SearchOrgs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_search"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_AdminService_SearchOrgs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_search"}, ""))
|
||||||
|
|
||||||
pattern_AdminService_SetUpOrg_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_setup"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_AdminService_SetUpOrg_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_setup"}, ""))
|
||||||
|
|
||||||
pattern_AdminService_GetOrgIamPolicy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"orgs", "org_id", "iampolicy"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_AdminService_GetOrgIamPolicy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"orgs", "org_id", "iampolicy"}, ""))
|
||||||
|
|
||||||
pattern_AdminService_CreateOrgIamPolicy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"orgs", "org_id", "iampolicy"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_AdminService_CreateOrgIamPolicy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"orgs", "org_id", "iampolicy"}, ""))
|
||||||
|
|
||||||
pattern_AdminService_UpdateOrgIamPolicy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"orgs", "org_id", "iampolicy"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_AdminService_UpdateOrgIamPolicy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"orgs", "org_id", "iampolicy"}, ""))
|
||||||
|
|
||||||
pattern_AdminService_DeleteOrgIamPolicy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"orgs", "org_id", "iampolicy"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_AdminService_DeleteOrgIamPolicy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"orgs", "org_id", "iampolicy"}, ""))
|
||||||
|
|
||||||
|
pattern_AdminService_GetViews_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"views"}, ""))
|
||||||
|
|
||||||
|
pattern_AdminService_ClearView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 1, 0, 4, 1, 5, 2}, []string{"views", "database", "view_name"}, ""))
|
||||||
|
|
||||||
|
pattern_AdminService_GetFailedEvents_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"failedevents"}, ""))
|
||||||
|
|
||||||
|
pattern_AdminService_RemoveFailedEvent_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3}, []string{"failedevents", "database", "view_name", "failed_sequence"}, ""))
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -1021,4 +758,12 @@ var (
|
|||||||
forward_AdminService_UpdateOrgIamPolicy_0 = runtime.ForwardResponseMessage
|
forward_AdminService_UpdateOrgIamPolicy_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_AdminService_DeleteOrgIamPolicy_0 = runtime.ForwardResponseMessage
|
forward_AdminService_DeleteOrgIamPolicy_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_AdminService_GetViews_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_AdminService_ClearView_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_AdminService_GetFailedEvents_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_AdminService_RemoveFailedEvent_0 = runtime.ForwardResponseMessage
|
||||||
)
|
)
|
||||||
|
@ -19,6 +19,59 @@
|
|||||||
"application/grpc"
|
"application/grpc"
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"/failedevents": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "GetFailedEvents",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A successful response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/v1FailedEvents"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"AdminService"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/failedevents/{database}/{view_name}/{failed_sequence}": {
|
||||||
|
"delete": {
|
||||||
|
"operationId": "RemoveFailedEvent",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A successful response.",
|
||||||
|
"schema": {
|
||||||
|
"properties": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "database",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "view_name",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "failed_sequence",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"AdminService"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/healthz": {
|
"/healthz": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Healthz returns status OK as soon as the service started",
|
"summary": "Healthz returns status OK as soon as the service started",
|
||||||
@ -274,7 +327,7 @@
|
|||||||
"200": {
|
"200": {
|
||||||
"description": "A successful response.",
|
"description": "A successful response.",
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "object"
|
"$ref": "#/definitions/protobufStruct"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -282,9 +335,68 @@
|
|||||||
"AdminService"
|
"AdminService"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/views": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "GetViews",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A successful response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/v1Views"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"AdminService"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/views/{database}/{view_name}": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "ClearView",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A successful response.",
|
||||||
|
"schema": {
|
||||||
|
"properties": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "database",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "view_name",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"AdminService"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
|
"protobufListValue": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"values": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/protobufValue"
|
||||||
|
},
|
||||||
|
"description": "Repeated field of dynamically typed values."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "`ListValue` is a wrapper around a repeated field of values.\n\nThe JSON representation for `ListValue` is JSON array."
|
||||||
|
},
|
||||||
"protobufNullValue": {
|
"protobufNullValue": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
@ -293,6 +405,51 @@
|
|||||||
"default": "NULL_VALUE",
|
"default": "NULL_VALUE",
|
||||||
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
|
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
|
||||||
},
|
},
|
||||||
|
"protobufStruct": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"fields": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/definitions/protobufValue"
|
||||||
|
},
|
||||||
|
"description": "Unordered map of dynamically typed values."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "`Struct` represents a structured data value, consisting of fields\nwhich map to dynamically typed values. In some languages, `Struct`\nmight be supported by a native representation. For example, in\nscripting languages like JS a struct is represented as an\nobject. The details of that representation are described together\nwith the proto support for the language.\n\nThe JSON representation for `Struct` is JSON object."
|
||||||
|
},
|
||||||
|
"protobufValue": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"null_value": {
|
||||||
|
"$ref": "#/definitions/protobufNullValue",
|
||||||
|
"description": "Represents a null value."
|
||||||
|
},
|
||||||
|
"number_value": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "double",
|
||||||
|
"description": "Represents a double value."
|
||||||
|
},
|
||||||
|
"string_value": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Represents a string value."
|
||||||
|
},
|
||||||
|
"bool_value": {
|
||||||
|
"type": "boolean",
|
||||||
|
"format": "boolean",
|
||||||
|
"description": "Represents a boolean value."
|
||||||
|
},
|
||||||
|
"struct_value": {
|
||||||
|
"$ref": "#/definitions/protobufStruct",
|
||||||
|
"description": "Represents a structured value."
|
||||||
|
},
|
||||||
|
"list_value": {
|
||||||
|
"$ref": "#/definitions/protobufListValue",
|
||||||
|
"description": "Represents a repeated `Value`."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "`Value` represents a dynamically typed value which can be either\nnull, a number, a string, a boolean, a recursive struct value, or a\nlist of values. A producer of value is expected to set one of that\nvariants, absence of any variant indicates an error.\n\nThe JSON representation for `Value` is JSON value."
|
||||||
|
},
|
||||||
"v1CreateOrgRequest": {
|
"v1CreateOrgRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -359,6 +516,39 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"v1FailedEvent": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"database": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"view_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"failed_sequence": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64"
|
||||||
|
},
|
||||||
|
"failure_count": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64"
|
||||||
|
},
|
||||||
|
"error_message": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"v1FailedEvents": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"failed_events": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/v1FailedEvent"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"v1Gender": {
|
"v1Gender": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
@ -647,6 +837,32 @@
|
|||||||
"USERSTATE_INITIAL"
|
"USERSTATE_INITIAL"
|
||||||
],
|
],
|
||||||
"default": "USERSTATE_UNSPECIFIED"
|
"default": "USERSTATE_UNSPECIFIED"
|
||||||
|
},
|
||||||
|
"v1View": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"database": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"view_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"sequence": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"v1Views": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"views": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/v1View"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
pkg/admin/api/grpc/administrator.go
Normal file
33
pkg/admin/api/grpc/administrator.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package grpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
view_model "github.com/caos/zitadel/internal/view/model"
|
||||||
|
"github.com/golang/protobuf/ptypes/empty"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Server) GetViews(ctx context.Context, _ *empty.Empty) (_ *Views, err error) {
|
||||||
|
views, err := s.administrator.GetViews(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &Views{Views: viewsFromModel(views)}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) ClearView(ctx context.Context, viewID *ViewID) (_ *empty.Empty, err error) {
|
||||||
|
err = s.administrator.ClearView(ctx, viewID.Database, viewID.ViewName)
|
||||||
|
return &empty.Empty{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) GetFailedEvents(ctx context.Context, _ *empty.Empty) (_ *FailedEvents, err error) {
|
||||||
|
failedEvents, err := s.administrator.GetFailedEvents(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &FailedEvents{FailedEvents: failedEventsFromModel(failedEvents)}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) RemoveFailedEvent(ctx context.Context, failedEventID *FailedEventID) (_ *empty.Empty, err error) {
|
||||||
|
err = s.administrator.RemoveFailedEvent(ctx, &view_model.FailedEvent{Database: failedEventID.Database, ViewName: failedEventID.ViewName, FailedSequence: failedEventID.FailedSequence})
|
||||||
|
return &empty.Empty{}, err
|
||||||
|
}
|
41
pkg/admin/api/grpc/administrator_converter.go
Normal file
41
pkg/admin/api/grpc/administrator_converter.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package grpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
view_model "github.com/caos/zitadel/internal/view/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func viewsFromModel(views []*view_model.View) []*View {
|
||||||
|
result := make([]*View, len(views))
|
||||||
|
for i, view := range views {
|
||||||
|
result[i] = viewFromModel(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func failedEventsFromModel(failedEvents []*view_model.FailedEvent) []*FailedEvent {
|
||||||
|
result := make([]*FailedEvent, len(failedEvents))
|
||||||
|
for i, view := range failedEvents {
|
||||||
|
result[i] = failedEventFromModel(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func viewFromModel(view *view_model.View) *View {
|
||||||
|
return &View{
|
||||||
|
Database: view.Database,
|
||||||
|
ViewName: view.ViewName,
|
||||||
|
Sequence: view.CurrentSequence,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func failedEventFromModel(failedEvent *view_model.FailedEvent) *FailedEvent {
|
||||||
|
return &FailedEvent{
|
||||||
|
Database: failedEvent.Database,
|
||||||
|
ViewName: failedEvent.ViewName,
|
||||||
|
FailedSequence: failedEvent.FailedSequence,
|
||||||
|
FailureCount: failedEvent.FailureCount,
|
||||||
|
ErrorMessage: failedEvent.ErrMsg,
|
||||||
|
}
|
||||||
|
}
|
@ -37,6 +37,26 @@ func (m *MockAdminServiceClient) EXPECT() *MockAdminServiceClientMockRecorder {
|
|||||||
return m.recorder
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearView mocks base method
|
||||||
|
func (m *MockAdminServiceClient) ClearView(arg0 context.Context, arg1 *grpc.ViewID, arg2 ...grpc0.CallOption) (*emptypb.Empty, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
varargs := []interface{}{arg0, arg1}
|
||||||
|
for _, a := range arg2 {
|
||||||
|
varargs = append(varargs, a)
|
||||||
|
}
|
||||||
|
ret := m.ctrl.Call(m, "ClearView", varargs...)
|
||||||
|
ret0, _ := ret[0].(*emptypb.Empty)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearView indicates an expected call of ClearView
|
||||||
|
func (mr *MockAdminServiceClientMockRecorder) ClearView(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, "ClearView", reflect.TypeOf((*MockAdminServiceClient)(nil).ClearView), varargs...)
|
||||||
|
}
|
||||||
|
|
||||||
// CreateOrgIamPolicy mocks base method
|
// CreateOrgIamPolicy mocks base method
|
||||||
func (m *MockAdminServiceClient) CreateOrgIamPolicy(arg0 context.Context, arg1 *grpc.OrgIamPolicyRequest, arg2 ...grpc0.CallOption) (*grpc.OrgIamPolicy, error) {
|
func (m *MockAdminServiceClient) CreateOrgIamPolicy(arg0 context.Context, arg1 *grpc.OrgIamPolicyRequest, arg2 ...grpc0.CallOption) (*grpc.OrgIamPolicy, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
@ -77,6 +97,26 @@ func (mr *MockAdminServiceClientMockRecorder) DeleteOrgIamPolicy(arg0, arg1 inte
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteOrgIamPolicy", reflect.TypeOf((*MockAdminServiceClient)(nil).DeleteOrgIamPolicy), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteOrgIamPolicy", reflect.TypeOf((*MockAdminServiceClient)(nil).DeleteOrgIamPolicy), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetFailedEvents mocks base method
|
||||||
|
func (m *MockAdminServiceClient) GetFailedEvents(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc0.CallOption) (*grpc.FailedEvents, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
varargs := []interface{}{arg0, arg1}
|
||||||
|
for _, a := range arg2 {
|
||||||
|
varargs = append(varargs, a)
|
||||||
|
}
|
||||||
|
ret := m.ctrl.Call(m, "GetFailedEvents", varargs...)
|
||||||
|
ret0, _ := ret[0].(*grpc.FailedEvents)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetFailedEvents indicates an expected call of GetFailedEvents
|
||||||
|
func (mr *MockAdminServiceClientMockRecorder) GetFailedEvents(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, "GetFailedEvents", reflect.TypeOf((*MockAdminServiceClient)(nil).GetFailedEvents), varargs...)
|
||||||
|
}
|
||||||
|
|
||||||
// GetOrgByID mocks base method
|
// GetOrgByID mocks base method
|
||||||
func (m *MockAdminServiceClient) GetOrgByID(arg0 context.Context, arg1 *grpc.OrgID, arg2 ...grpc0.CallOption) (*grpc.Org, error) {
|
func (m *MockAdminServiceClient) GetOrgByID(arg0 context.Context, arg1 *grpc.OrgID, arg2 ...grpc0.CallOption) (*grpc.Org, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
@ -117,6 +157,26 @@ func (mr *MockAdminServiceClientMockRecorder) GetOrgIamPolicy(arg0, arg1 interfa
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrgIamPolicy", reflect.TypeOf((*MockAdminServiceClient)(nil).GetOrgIamPolicy), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrgIamPolicy", reflect.TypeOf((*MockAdminServiceClient)(nil).GetOrgIamPolicy), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetViews mocks base method
|
||||||
|
func (m *MockAdminServiceClient) GetViews(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc0.CallOption) (*grpc.Views, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
varargs := []interface{}{arg0, arg1}
|
||||||
|
for _, a := range arg2 {
|
||||||
|
varargs = append(varargs, a)
|
||||||
|
}
|
||||||
|
ret := m.ctrl.Call(m, "GetViews", varargs...)
|
||||||
|
ret0, _ := ret[0].(*grpc.Views)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetViews indicates an expected call of GetViews
|
||||||
|
func (mr *MockAdminServiceClientMockRecorder) GetViews(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, "GetViews", reflect.TypeOf((*MockAdminServiceClient)(nil).GetViews), varargs...)
|
||||||
|
}
|
||||||
|
|
||||||
// Healthz mocks base method
|
// Healthz mocks base method
|
||||||
func (m *MockAdminServiceClient) Healthz(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc0.CallOption) (*emptypb.Empty, error) {
|
func (m *MockAdminServiceClient) Healthz(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc0.CallOption) (*emptypb.Empty, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
@ -177,6 +237,26 @@ func (mr *MockAdminServiceClientMockRecorder) Ready(arg0, arg1 interface{}, arg2
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ready", reflect.TypeOf((*MockAdminServiceClient)(nil).Ready), varargs...)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ready", reflect.TypeOf((*MockAdminServiceClient)(nil).Ready), varargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveFailedEvent mocks base method
|
||||||
|
func (m *MockAdminServiceClient) RemoveFailedEvent(arg0 context.Context, arg1 *grpc.FailedEventID, arg2 ...grpc0.CallOption) (*emptypb.Empty, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
varargs := []interface{}{arg0, arg1}
|
||||||
|
for _, a := range arg2 {
|
||||||
|
varargs = append(varargs, a)
|
||||||
|
}
|
||||||
|
ret := m.ctrl.Call(m, "RemoveFailedEvent", varargs...)
|
||||||
|
ret0, _ := ret[0].(*emptypb.Empty)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveFailedEvent indicates an expected call of RemoveFailedEvent
|
||||||
|
func (mr *MockAdminServiceClientMockRecorder) RemoveFailedEvent(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, "RemoveFailedEvent", reflect.TypeOf((*MockAdminServiceClient)(nil).RemoveFailedEvent), varargs...)
|
||||||
|
}
|
||||||
|
|
||||||
// SearchOrgs mocks base method
|
// SearchOrgs mocks base method
|
||||||
func (m *MockAdminServiceClient) SearchOrgs(arg0 context.Context, arg1 *grpc.OrgSearchRequest, arg2 ...grpc0.CallOption) (*grpc.OrgSearchResponse, error) {
|
func (m *MockAdminServiceClient) SearchOrgs(arg0 context.Context, arg1 *grpc.OrgSearchRequest, arg2 ...grpc0.CallOption) (*grpc.OrgSearchResponse, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
@ -15,20 +15,22 @@ import (
|
|||||||
var _ AdminServiceServer = (*Server)(nil)
|
var _ AdminServiceServer = (*Server)(nil)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
port string
|
port string
|
||||||
org repository.OrgRepository
|
org repository.OrgRepository
|
||||||
verifier auth.TokenVerifier
|
administrator repository.AdministratorRepository
|
||||||
authZ auth.Config
|
verifier auth.TokenVerifier
|
||||||
repo repository.Repository
|
authZ auth.Config
|
||||||
|
repo repository.Repository
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartServer(conf grpc_util.ServerConfig, authZRepo *authz_repo.EsRepository, authZ auth.Config, repo repository.Repository) *Server {
|
func StartServer(conf grpc_util.ServerConfig, authZRepo *authz_repo.EsRepository, authZ auth.Config, repo repository.Repository) *Server {
|
||||||
return &Server{
|
return &Server{
|
||||||
port: conf.Port,
|
port: conf.Port,
|
||||||
org: repo,
|
org: repo,
|
||||||
repo: repo,
|
administrator: repo,
|
||||||
authZ: authZ,
|
repo: repo,
|
||||||
verifier: admin_auth.Start(authZRepo),
|
authZ: authZ,
|
||||||
|
verifier: admin_auth.Start(authZRepo),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +141,46 @@ service AdminService {
|
|||||||
permission: "iam.policy.delete"
|
permission: "iam.policy.delete"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpc GetViews(google.protobuf.Empty) returns (Views) {
|
||||||
|
option (google.api.http) = {
|
||||||
|
get: "/views"
|
||||||
|
};
|
||||||
|
|
||||||
|
option (caos.zitadel.utils.v1.auth_option) = {
|
||||||
|
permission: "iam.read"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
rpc ClearView(ViewID) returns (google.protobuf.Empty) {
|
||||||
|
option (google.api.http) = {
|
||||||
|
post: "/views/{database}/{view_name}"
|
||||||
|
};
|
||||||
|
|
||||||
|
option (caos.zitadel.utils.v1.auth_option) = {
|
||||||
|
permission: "iam.write"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
rpc GetFailedEvents(google.protobuf.Empty) returns (FailedEvents) {
|
||||||
|
option (google.api.http) = {
|
||||||
|
get: "/failedevents"
|
||||||
|
};
|
||||||
|
|
||||||
|
option (caos.zitadel.utils.v1.auth_option) = {
|
||||||
|
permission: "iam.read"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
rpc RemoveFailedEvent(FailedEventID) returns (google.protobuf.Empty) {
|
||||||
|
option (google.api.http) = {
|
||||||
|
delete: "/failedevents/{database}/{view_name}/{failed_sequence}"
|
||||||
|
};
|
||||||
|
|
||||||
|
option (caos.zitadel.utils.v1.auth_option) = {
|
||||||
|
permission: "iam.write"
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message OrgID {
|
message OrgID {
|
||||||
@ -299,3 +339,38 @@ message OrgIamPolicyRequest {
|
|||||||
message OrgIamPolicyID {
|
message OrgIamPolicyID {
|
||||||
string org_id = 1;
|
string org_id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message FailedEventID {
|
||||||
|
string database = 1;
|
||||||
|
string view_name = 2;
|
||||||
|
uint64 failed_sequence = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FailedEvents {
|
||||||
|
repeated FailedEvent failed_events = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FailedEvent {
|
||||||
|
string database = 1;
|
||||||
|
string view_name = 2;
|
||||||
|
uint64 failed_sequence = 3;
|
||||||
|
uint64 failure_count = 4;
|
||||||
|
string error_message = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ViewID {
|
||||||
|
string database = 1;
|
||||||
|
string view_name = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Views {
|
||||||
|
repeated View views = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message View {
|
||||||
|
string database = 1;
|
||||||
|
string view_name = 2;
|
||||||
|
uint64 sequence = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user