zitadel/internal/project/model/project_role_view.go
Tim Möhlmann f680dd934d
refactor: rename package errors to zerrors (#7039)
* chore: rename package errors to zerrors

* rename package errors to gerrors

* fix error related linting issues

* fix zitadel error assertion

* fix gosimple linting issues

* fix deprecated linting issues

* resolve gci linting issues

* fix import structure

---------

Co-authored-by: Elio Bischof <elio@zitadel.com>
2023-12-08 15:30:55 +01:00

76 lines
1.9 KiB
Go

package model
import (
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/zerrors"
"time"
)
type ProjectRoleView struct {
ResourceOwner string
OrgID string
ProjectID string
Key string
DisplayName string
Group string
CreationDate time.Time
ChangeDate time.Time
Sequence uint64
}
type ProjectRoleSearchRequest struct {
Offset uint64
Limit uint64
SortingColumn ProjectRoleSearchKey
Asc bool
Queries []*ProjectRoleSearchQuery
}
type ProjectRoleSearchKey int32
const (
ProjectRoleSearchKeyUnspecified ProjectRoleSearchKey = iota
ProjectRoleSearchKeyKey
ProjectRoleSearchKeyProjectID
ProjectRoleSearchKeyOrgID
ProjectRoleSearchKeyResourceOwner
ProjectRoleSearchKeyDisplayName
)
type ProjectRoleSearchQuery struct {
Key ProjectRoleSearchKey
Method domain.SearchMethod
Value interface{}
}
type ProjectRoleSearchResponse struct {
Offset uint64
Limit uint64
TotalResult uint64
Result []*ProjectRoleView
Sequence uint64
Timestamp time.Time
}
func (r *ProjectRoleSearchRequest) AppendMyOrgQuery(orgID string) {
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: ProjectRoleSearchKeyOrgID, Method: domain.SearchMethodEquals, Value: orgID})
}
func (r *ProjectRoleSearchRequest) AppendProjectQuery(projectID string) {
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: ProjectRoleSearchKeyProjectID, Method: domain.SearchMethodEquals, Value: projectID})
}
func (r *ProjectRoleSearchRequest) AppendRoleKeysQuery(keys []string) {
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: ProjectRoleSearchKeyKey, Method: domain.SearchMethodIsOneOf, Value: keys})
}
func (r *ProjectRoleSearchRequest) EnsureLimit(limit uint64) error {
if r.Limit > limit {
return zerrors.ThrowInvalidArgument(nil, "SEARCH-92hNf", "Errors.Limit.ExceedsDefault")
}
if r.Limit == 0 {
r.Limit = limit
}
return nil
}