2020-06-25 06:12:29 +00:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
2020-07-07 09:42:39 +00:00
|
|
|
"github.com/caos/zitadel/internal/errors"
|
2020-06-25 06:12:29 +00:00
|
|
|
iam_model "github.com/caos/zitadel/internal/iam/model"
|
|
|
|
"github.com/caos/zitadel/internal/iam/repository/view"
|
|
|
|
"github.com/caos/zitadel/internal/iam/repository/view/model"
|
|
|
|
global_view "github.com/caos/zitadel/internal/view/repository"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-07-07 14:53:54 +00:00
|
|
|
iamMemberTable = "adminapi.iam_members"
|
2020-06-25 06:12:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (v *View) IamMemberByIDs(orgID, userID string) (*model.IamMemberView, error) {
|
|
|
|
return view.IamMemberByIDs(v.Db, iamMemberTable, orgID, userID)
|
|
|
|
}
|
|
|
|
|
2020-07-30 12:37:55 +00:00
|
|
|
func (v *View) SearchIamMembers(request *iam_model.IamMemberSearchRequest) ([]*model.IamMemberView, uint64, error) {
|
2020-06-25 06:12:29 +00:00
|
|
|
return view.SearchIamMembers(v.Db, iamMemberTable, request)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) IamMembersByUserID(userID string) ([]*model.IamMemberView, error) {
|
|
|
|
return view.IamMembersByUserID(v.Db, iamMemberTable, userID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) PutIamMember(org *model.IamMemberView, sequence uint64) error {
|
|
|
|
err := view.PutIamMember(v.Db, iamMemberTable, org)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return v.ProcessedIamMemberSequence(sequence)
|
|
|
|
}
|
|
|
|
|
2020-07-07 09:42:39 +00:00
|
|
|
func (v *View) DeleteIamMember(iamID, userID string, eventSequence uint64) error {
|
|
|
|
err := view.DeleteIamMember(v.Db, iamMemberTable, iamID, userID)
|
|
|
|
if err != nil && !errors.IsNotFound(err) {
|
|
|
|
return err
|
2020-06-25 06:12:29 +00:00
|
|
|
}
|
|
|
|
return v.ProcessedIamMemberSequence(eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-07-15 11:24:36 +00:00
|
|
|
func (v *View) GetLatestIamMemberSequence() (*global_view.CurrentSequence, error) {
|
2020-06-25 06:12:29 +00:00
|
|
|
return v.latestSequence(iamMemberTable)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProcessedIamMemberSequence(eventSequence uint64) error {
|
|
|
|
return v.saveCurrentSequence(iamMemberTable, eventSequence)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) GetLatestIamMemberFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
|
|
|
return v.latestFailedEvent(iamMemberTable, sequence)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProcessedIamMemberFailedEvent(failedEvent *global_view.FailedEvent) error {
|
|
|
|
return v.saveFailedEvent(failedEvent)
|
|
|
|
}
|