mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
f680dd934d
* 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>
84 lines
1.8 KiB
Go
84 lines
1.8 KiB
Go
package domain
|
|
|
|
import (
|
|
"time"
|
|
|
|
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
|
)
|
|
|
|
type Metadata struct {
|
|
es_models.ObjectRoot
|
|
|
|
State MetadataState
|
|
Key string
|
|
Value []byte
|
|
}
|
|
|
|
type MetadataState int32
|
|
|
|
const (
|
|
MetadataStateUnspecified MetadataState = iota
|
|
MetadataStateActive
|
|
MetadataStateRemoved
|
|
)
|
|
|
|
func (m *Metadata) IsValid() bool {
|
|
return m.Key != "" && len(m.Value) > 0
|
|
}
|
|
|
|
func (s MetadataState) Exists() bool {
|
|
return s != MetadataStateUnspecified && s != MetadataStateRemoved
|
|
}
|
|
|
|
type MetadataSearchRequest struct {
|
|
Offset uint64
|
|
Limit uint64
|
|
SortingColumn MetadataSearchKey
|
|
Asc bool
|
|
Queries []*MetadataSearchQuery
|
|
}
|
|
|
|
type MetadataSearchKey int32
|
|
|
|
const (
|
|
MetadataSearchKeyUnspecified MetadataSearchKey = iota
|
|
MetadataSearchKeyAggregateID
|
|
MetadataSearchKeyResourceOwner
|
|
MetadataSearchKeyKey
|
|
MetadataSearchKeyValue
|
|
)
|
|
|
|
type MetadataSearchQuery struct {
|
|
Key MetadataSearchKey
|
|
Method SearchMethod
|
|
Value interface{}
|
|
}
|
|
|
|
type MetadataSearchResponse struct {
|
|
Offset uint64
|
|
Limit uint64
|
|
TotalResult uint64
|
|
Result []*Metadata
|
|
Sequence uint64
|
|
Timestamp time.Time
|
|
}
|
|
|
|
func (r *MetadataSearchRequest) EnsureLimit(limit uint64) error {
|
|
if r.Limit > limit {
|
|
return zerrors.ThrowInvalidArgument(nil, "SEARCH-0ds32", "Errors.Limit.ExceedsDefault")
|
|
}
|
|
if r.Limit == 0 {
|
|
r.Limit = limit
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (r *MetadataSearchRequest) AppendAggregateIDQuery(aggregateID string) {
|
|
r.Queries = append(r.Queries, &MetadataSearchQuery{Key: MetadataSearchKeyAggregateID, Method: SearchMethodEquals, Value: aggregateID})
|
|
}
|
|
|
|
func (r *MetadataSearchRequest) AppendResourceOwnerQuery(resourceOwner string) {
|
|
r.Queries = append(r.Queries, &MetadataSearchQuery{Key: MetadataSearchKeyResourceOwner, Method: SearchMethodEquals, Value: resourceOwner})
|
|
}
|