mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-16 21:08:00 +00:00
6b3f5b984c
* refactor: switch from opencensus to opentelemetry * tempo works as designed nooooot * fix: log traceids * with grafana agent * fix: http tracing * fix: cleanup files * chore: remove todo * fix: bad test * fix: ignore methods in grpc interceptors * fix: remove test log * clean up * typo * fix(config): configure tracing endpoint * fix(span): add error id to span * feat: metrics package * feat: metrics package * fix: counter * fix: metric * try metrics * fix: coutner metrics * fix: active sessin counter * fix: active sessin counter * fix: change current Sequence table * fix: change current Sequence table * fix: current sequences * fix: spooler div metrics * fix: console view * fix: merge master * fix: Last spool run on search result instead of eventtimestamp * fix: go mod * Update console/src/assets/i18n/de.json Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: pr review * fix: map * update oidc pkg * fix: handlers * fix: value observer * fix: remove fmt * fix: handlers * fix: tests * fix: handler minimum cycle duration 1s * fix(spooler): handler channel buffer * fix interceptors Co-authored-by: adlerhurst <silvan.reusser@gmail.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com>
70 lines
2.3 KiB
Go
70 lines
2.3 KiB
Go
package view
|
|
|
|
import (
|
|
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/model"
|
|
"github.com/caos/zitadel/internal/view/repository"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
userGrantTable = "authz.user_grants"
|
|
)
|
|
|
|
func (v *View) UserGrantByID(grantID string) (*model.UserGrantView, error) {
|
|
return view.UserGrantByID(v.Db, userGrantTable, grantID)
|
|
}
|
|
|
|
func (v *View) UserGrantByIDs(resourceOwnerID, projectID, userID string) (*model.UserGrantView, error) {
|
|
return view.UserGrantByIDs(v.Db, userGrantTable, resourceOwnerID, projectID, userID)
|
|
}
|
|
|
|
func (v *View) UserGrantsByUserID(userID string) ([]*model.UserGrantView, error) {
|
|
return view.UserGrantsByUserID(v.Db, userGrantTable, userID)
|
|
}
|
|
|
|
func (v *View) UserGrantsByProjectID(projectID string) ([]*model.UserGrantView, error) {
|
|
return view.UserGrantsByProjectID(v.Db, userGrantTable, projectID)
|
|
}
|
|
|
|
func (v *View) SearchUserGrants(request *grant_model.UserGrantSearchRequest) ([]*model.UserGrantView, uint64, error) {
|
|
return view.SearchUserGrants(v.Db, userGrantTable, request)
|
|
}
|
|
|
|
func (v *View) PutUserGrant(grant *model.UserGrantView, sequence uint64, eventTimestamp time.Time) error {
|
|
err := view.PutUserGrant(v.Db, userGrantTable, grant)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return v.ProcessedUserGrantSequence(sequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) DeleteUserGrant(grantID string, eventSequence uint64, eventTimestamp time.Time) error {
|
|
err := view.DeleteUserGrant(v.Db, userGrantTable, grantID)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return v.ProcessedUserGrantSequence(eventSequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) GetLatestUserGrantSequence() (*repository.CurrentSequence, error) {
|
|
return v.latestSequence(userGrantTable)
|
|
}
|
|
|
|
func (v *View) ProcessedUserGrantSequence(eventSequence uint64, eventTimestamp time.Time) error {
|
|
return v.saveCurrentSequence(userGrantTable, eventSequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) UpdateUserGrantSpoolerRunTimestamp() error {
|
|
return v.updateSpoolerRunSequence(userGrantTable)
|
|
}
|
|
|
|
func (v *View) GetLatestUserGrantFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
|
return v.latestFailedEvent(userGrantTable, sequence)
|
|
}
|
|
|
|
func (v *View) ProcessedUserGrantFailedEvent(failedEvent *repository.FailedEvent) error {
|
|
return v.saveFailedEvent(failedEvent)
|
|
}
|