mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
cloudevent 支持since until参数过滤
This commit is contained in:
@@ -24,6 +24,9 @@ func init() {
|
||||
|
||||
type CloudeventListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
Since string `help:"since time"`
|
||||
Until string `hlep:"until time"`
|
||||
}
|
||||
R(&CloudeventListOptions{}, "cloud-event-list", "List cloud events", func(s *mcclient.ClientSession, opts *CloudeventListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package cloudevent
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/apis/compute"
|
||||
)
|
||||
@@ -23,4 +25,7 @@ type CloudeventListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
|
||||
compute.ManagedResourceListInput
|
||||
|
||||
Since time.Time
|
||||
Until time.Time
|
||||
}
|
||||
|
||||
@@ -101,6 +101,13 @@ func (manager *SCloudeventManager) ListItemFilter(ctx context.Context, q *sqlche
|
||||
q = q.In("provider", input.Providers)
|
||||
}
|
||||
|
||||
if !input.Since.IsZero() {
|
||||
q = q.GT("created_at", input.Since)
|
||||
}
|
||||
if !input.Until.IsZero() {
|
||||
q = q.LE("created_at", input.Until)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user