2020-05-11 10:16:29 +00:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
2023-12-08 14:30:55 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
2021-04-06 14:03:07 +00:00
|
|
|
|
2020-05-11 10:16:29 +00:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ProjectMemberView struct {
|
2021-03-22 13:40:25 +00:00
|
|
|
UserID string
|
|
|
|
ProjectID string
|
|
|
|
UserName string
|
|
|
|
Email string
|
|
|
|
FirstName string
|
|
|
|
LastName string
|
|
|
|
DisplayName string
|
|
|
|
PreferredLoginName string
|
2021-06-11 11:20:39 +00:00
|
|
|
AvatarURL string
|
|
|
|
UserResourceOwner string
|
2021-03-22 13:40:25 +00:00
|
|
|
Roles []string
|
|
|
|
CreationDate time.Time
|
|
|
|
ChangeDate time.Time
|
|
|
|
Sequence uint64
|
2020-05-11 10:16:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ProjectMemberSearchRequest struct {
|
|
|
|
Offset uint64
|
|
|
|
Limit uint64
|
|
|
|
SortingColumn ProjectMemberSearchKey
|
|
|
|
Asc bool
|
|
|
|
Queries []*ProjectMemberSearchQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
type ProjectMemberSearchKey int32
|
|
|
|
|
|
|
|
const (
|
2020-06-23 12:47:47 +00:00
|
|
|
ProjectMemberSearchKeyUnspecified ProjectMemberSearchKey = iota
|
|
|
|
ProjectMemberSearchKeyUserName
|
|
|
|
ProjectMemberSearchKeyEmail
|
|
|
|
ProjectMemberSearchKeyFirstName
|
|
|
|
ProjectMemberSearchKeyLastName
|
|
|
|
ProjectMemberSearchKeyProjectID
|
|
|
|
ProjectMemberSearchKeyUserID
|
2020-05-11 10:16:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ProjectMemberSearchQuery struct {
|
|
|
|
Key ProjectMemberSearchKey
|
2021-03-01 07:48:50 +00:00
|
|
|
Method domain.SearchMethod
|
2020-06-16 09:40:18 +00:00
|
|
|
Value interface{}
|
2020-05-11 10:16:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ProjectMemberSearchResponse struct {
|
|
|
|
Offset uint64
|
|
|
|
Limit uint64
|
|
|
|
TotalResult uint64
|
|
|
|
Result []*ProjectMemberView
|
2020-07-15 11:24:36 +00:00
|
|
|
Sequence uint64
|
|
|
|
Timestamp time.Time
|
2020-05-11 10:16:29 +00:00
|
|
|
}
|
|
|
|
|
2021-04-06 14:03:07 +00:00
|
|
|
func (r *ProjectMemberSearchRequest) EnsureLimit(limit uint64) error {
|
|
|
|
if r.Limit > limit {
|
2023-12-08 14:30:55 +00:00
|
|
|
return zerrors.ThrowInvalidArgument(nil, "SEARCH-389Nd", "Errors.Limit.ExceedsDefault")
|
2021-04-06 14:03:07 +00:00
|
|
|
}
|
|
|
|
if r.Limit == 0 {
|
2020-05-11 10:16:29 +00:00
|
|
|
r.Limit = limit
|
|
|
|
}
|
2021-04-06 14:03:07 +00:00
|
|
|
return nil
|
2020-05-11 10:16:29 +00:00
|
|
|
}
|
2020-06-11 11:27:25 +00:00
|
|
|
func (r *ProjectMemberSearchRequest) AppendProjectQuery(projectID string) {
|
2021-03-01 07:48:50 +00:00
|
|
|
r.Queries = append(r.Queries, &ProjectMemberSearchQuery{Key: ProjectMemberSearchKeyProjectID, Method: domain.SearchMethodEquals, Value: projectID})
|
2020-06-11 11:27:25 +00:00
|
|
|
}
|