2020-05-11 12:16:29 +02:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/caos/zitadel/internal/model"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type GrantedProjectView struct {
|
|
|
|
ProjectID string
|
|
|
|
Name string
|
|
|
|
CreationDate time.Time
|
|
|
|
ChangeDate time.Time
|
|
|
|
State ProjectState
|
|
|
|
Type ProjectType
|
|
|
|
ResourceOwner string
|
|
|
|
OrgID string
|
|
|
|
OrgName string
|
|
|
|
OrgDomain string
|
|
|
|
Sequence uint64
|
|
|
|
GrantID string
|
|
|
|
GrantedRoleKeys []string
|
|
|
|
}
|
|
|
|
|
|
|
|
type ProjectType int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
PROJECTTYPE_OWNED ProjectType = iota
|
|
|
|
PROJECTTYPE_GRANTED
|
|
|
|
)
|
|
|
|
|
|
|
|
type GrantedProjectSearchRequest struct {
|
|
|
|
Offset uint64
|
|
|
|
Limit uint64
|
|
|
|
SortingColumn GrantedProjectSearchKey
|
|
|
|
Asc bool
|
|
|
|
Queries []*GrantedProjectSearchQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
type GrantedProjectSearchKey int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
GRANTEDPROJECTSEARCHKEY_UNSPECIFIED GrantedProjectSearchKey = iota
|
|
|
|
GRANTEDPROJECTSEARCHKEY_NAME
|
|
|
|
GRANTEDPROJECTSEARCHKEY_PROJECTID
|
|
|
|
GRANTEDPROJECTSEARCHKEY_GRANTID
|
|
|
|
GRANTEDPROJECTSEARCHKEY_ORGID
|
|
|
|
GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER
|
|
|
|
)
|
|
|
|
|
|
|
|
type GrantedProjectSearchQuery struct {
|
|
|
|
Key GrantedProjectSearchKey
|
|
|
|
Method model.SearchMethod
|
2020-06-05 07:50:04 +02:00
|
|
|
Value interface{}
|
2020-05-11 12:16:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type GrantedProjectSearchResponse struct {
|
|
|
|
Offset uint64
|
|
|
|
Limit uint64
|
|
|
|
TotalResult uint64
|
|
|
|
Result []*GrantedProjectView
|
|
|
|
}
|
|
|
|
|
2020-05-12 06:30:53 +02:00
|
|
|
func (r *GrantedProjectSearchRequest) AppendMyOrgQuery(orgID string) {
|
2020-05-11 12:16:29 +02:00
|
|
|
r.Queries = append(r.Queries, &GrantedProjectSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
|
|
|
}
|
|
|
|
|
2020-05-12 06:30:53 +02:00
|
|
|
func (r *GrantedProjectSearchRequest) AppendNotMyOrgQuery(orgID string) {
|
2020-05-11 12:16:29 +02:00
|
|
|
r.Queries = append(r.Queries, &GrantedProjectSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_NOT_EQUALS, Value: orgID})
|
|
|
|
}
|
|
|
|
|
2020-05-12 06:30:53 +02:00
|
|
|
func (r *GrantedProjectSearchRequest) AppendMyResourceOwnerQuery(orgID string) {
|
2020-05-11 12:16:29 +02:00
|
|
|
r.Queries = append(r.Queries, &GrantedProjectSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *GrantedProjectSearchRequest) EnsureLimit(limit uint64) {
|
|
|
|
if r.Limit == 0 || r.Limit > limit {
|
|
|
|
r.Limit = limit
|
|
|
|
}
|
|
|
|
}
|