From 3f3d3e2028dc01abf6ba999d50de3acaf71dad90 Mon Sep 17 00:00:00 2001 From: KCarretto Date: Tue, 23 Jan 2024 02:13:56 +0000 Subject: [PATCH] Added MixinHistory to beacon and host --- tavern/internal/ent/beacon.go | 24 +- tavern/internal/ent/beacon/beacon.go | 24 + tavern/internal/ent/beacon/where.go | 90 +++ tavern/internal/ent/beacon_create.go | 102 +++- tavern/internal/ent/beacon_query.go | 8 +- tavern/internal/ent/beacon_update.go | 36 ++ tavern/internal/ent/gql_collection.go | 20 + tavern/internal/ent/gql_mutation_input.go | 10 +- tavern/internal/ent/gql_pagination.go | 72 +++ tavern/internal/ent/gql_where_input.go | 136 +++++ tavern/internal/ent/host.go | 24 +- tavern/internal/ent/host/host.go | 23 + tavern/internal/ent/host/where.go | 90 +++ tavern/internal/ent/host_create.go | 108 +++- tavern/internal/ent/host_query.go | 8 +- tavern/internal/ent/host_update.go | 36 ++ tavern/internal/ent/migrate/schema.go | 6 +- tavern/internal/ent/mutation.go | 220 ++++++- tavern/internal/ent/runtime/runtime.go | 26 + tavern/internal/ent/schema/beacon.go | 7 + tavern/internal/ent/schema/host.go | 7 + .../graphql/generated/ent.generated.go | 538 +++++++++++++++++- .../graphql/generated/mutation.generated.go | 8 + .../graphql/generated/root_.generated.go | 102 +++- tavern/internal/graphql/schema.graphql | 52 ++ tavern/internal/graphql/schema/ent.graphql | 52 ++ .../mutations/createQuest/NoFiles.yml | 8 +- .../mutations/createQuest/WithFiles.yml | 8 +- .../testdata/mutations/createTag/Group.yml | 8 +- .../mutations/createTag/MultipleHosts.yml | 20 +- .../testdata/mutations/createTag/Service.yml | 8 +- .../mutations/createTome/WithFiles.yml | 8 +- .../mutations/deleteTome/PermissionDenied.yml | 8 +- .../mutations/deleteTome/Singular.yml | 8 +- .../updateBeacon/ChangeNameError.yml | 8 +- .../testdata/mutations/updateHost/AddTag.yml | 8 +- .../mutations/updateHost/ChangeHostname.yml | 8 +- .../mutations/updateHost/RemoveTag.yml | 8 +- .../mutations/updateTag/ChangeName.yml | 8 +- .../mutations/updateTome/PermissionDenied.yml | 8 +- .../mutations/updateTome/Singular.yml | 8 +- .../testdata/queries/beacons/FilterByID.yml | 12 +- .../testdata/queries/beacons/Singular.yml | 8 +- .../testdata/queries/hosts/Multiple.yml | 8 +- .../testdata/queries/hosts/Singular.yml | 4 +- .../testdata/queries/quests/FilterByID.yml | 8 +- .../testdata/queries/quests/Singular.yml | 8 +- .../queries/tasks/BackwardPaginate.yml | 8 +- .../testdata/queries/tasks/FilterByID.yml | 8 +- .../queries/tasks/ForwardPaginate.yml | 8 +- .../testdata/queries/tasks/Multiple.yml | 8 +- .../queries/tasks/OrderByPaginate.yml | 8 +- .../testdata/queries/tasks/Singular.yml | 8 +- tavern/internal/www/schema.graphql | 52 ++ 54 files changed, 1962 insertions(+), 147 deletions(-) diff --git a/tavern/internal/ent/beacon.go b/tavern/internal/ent/beacon.go index 7f752517d..d1c5728ee 100644 --- a/tavern/internal/ent/beacon.go +++ b/tavern/internal/ent/beacon.go @@ -18,6 +18,10 @@ type Beacon struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` + // Timestamp of when this ent was created + CreatedAt time.Time `json:"created_at,omitempty"` + // Timestamp of when this ent was last updated + LastModifiedAt time.Time `json:"last_modified_at,omitempty"` // A human readable identifier for the beacon. Name string `json:"name,omitempty"` // The identity the beacon is authenticated as (e.g. 'root') @@ -83,7 +87,7 @@ func (*Beacon) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case beacon.FieldName, beacon.FieldPrincipal, beacon.FieldIdentifier, beacon.FieldAgentIdentifier: values[i] = new(sql.NullString) - case beacon.FieldLastSeenAt: + case beacon.FieldCreatedAt, beacon.FieldLastModifiedAt, beacon.FieldLastSeenAt: values[i] = new(sql.NullTime) case beacon.ForeignKeys[0]: // beacon_host values[i] = new(sql.NullInt64) @@ -108,6 +112,18 @@ func (b *Beacon) assignValues(columns []string, values []any) error { return fmt.Errorf("unexpected type %T for field id", value) } b.ID = int(value.Int64) + case beacon.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + b.CreatedAt = value.Time + } + case beacon.FieldLastModifiedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_modified_at", values[i]) + } else if value.Valid { + b.LastModifiedAt = value.Time + } case beacon.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) @@ -197,6 +213,12 @@ func (b *Beacon) String() string { var builder strings.Builder builder.WriteString("Beacon(") builder.WriteString(fmt.Sprintf("id=%v, ", b.ID)) + builder.WriteString("created_at=") + builder.WriteString(b.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("last_modified_at=") + builder.WriteString(b.LastModifiedAt.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("name=") builder.WriteString(b.Name) builder.WriteString(", ") diff --git a/tavern/internal/ent/beacon/beacon.go b/tavern/internal/ent/beacon/beacon.go index 7b7e8550b..daf680ec4 100644 --- a/tavern/internal/ent/beacon/beacon.go +++ b/tavern/internal/ent/beacon/beacon.go @@ -3,6 +3,8 @@ package beacon import ( + "time" + "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" ) @@ -12,6 +14,10 @@ const ( Label = "beacon" // FieldID holds the string denoting the id field in the database. FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldLastModifiedAt holds the string denoting the last_modified_at field in the database. + FieldLastModifiedAt = "last_modified_at" // FieldName holds the string denoting the name field in the database. FieldName = "name" // FieldPrincipal holds the string denoting the principal field in the database. @@ -49,6 +55,8 @@ const ( // Columns holds all SQL columns for beacon fields. var Columns = []string{ FieldID, + FieldCreatedAt, + FieldLastModifiedAt, FieldName, FieldPrincipal, FieldIdentifier, @@ -79,6 +87,12 @@ func ValidColumn(column string) bool { } var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultLastModifiedAt holds the default value on creation for the "last_modified_at" field. + DefaultLastModifiedAt func() time.Time + // UpdateDefaultLastModifiedAt holds the default value on update for the "last_modified_at" field. + UpdateDefaultLastModifiedAt func() time.Time // DefaultName holds the default value on creation for the "name" field. DefaultName func() string // NameValidator is a validator for the "name" field. It is called by the builders before save. @@ -101,6 +115,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByLastModifiedAt orders the results by the last_modified_at field. +func ByLastModifiedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastModifiedAt, opts...).ToFunc() +} + // ByName orders the results by the name field. func ByName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldName, opts...).ToFunc() diff --git a/tavern/internal/ent/beacon/where.go b/tavern/internal/ent/beacon/where.go index 0f5c15a00..c4e82d673 100644 --- a/tavern/internal/ent/beacon/where.go +++ b/tavern/internal/ent/beacon/where.go @@ -55,6 +55,16 @@ func IDLTE(id int) predicate.Beacon { return predicate.Beacon(sql.FieldLTE(FieldID, id)) } +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldCreatedAt, v)) +} + +// LastModifiedAt applies equality check predicate on the "last_modified_at" field. It's identical to LastModifiedAtEQ. +func LastModifiedAt(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldLastModifiedAt, v)) +} + // Name applies equality check predicate on the "name" field. It's identical to NameEQ. func Name(v string) predicate.Beacon { return predicate.Beacon(sql.FieldEQ(FieldName, v)) @@ -85,6 +95,86 @@ func Interval(v uint64) predicate.Beacon { return predicate.Beacon(sql.FieldEQ(FieldInterval, v)) } +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldLTE(FieldCreatedAt, v)) +} + +// LastModifiedAtEQ applies the EQ predicate on the "last_modified_at" field. +func LastModifiedAtEQ(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtNEQ applies the NEQ predicate on the "last_modified_at" field. +func LastModifiedAtNEQ(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldNEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtIn applies the In predicate on the "last_modified_at" field. +func LastModifiedAtIn(vs ...time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtNotIn applies the NotIn predicate on the "last_modified_at" field. +func LastModifiedAtNotIn(vs ...time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldNotIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtGT applies the GT predicate on the "last_modified_at" field. +func LastModifiedAtGT(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldGT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtGTE applies the GTE predicate on the "last_modified_at" field. +func LastModifiedAtGTE(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldGTE(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLT applies the LT predicate on the "last_modified_at" field. +func LastModifiedAtLT(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldLT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLTE applies the LTE predicate on the "last_modified_at" field. +func LastModifiedAtLTE(v time.Time) predicate.Beacon { + return predicate.Beacon(sql.FieldLTE(FieldLastModifiedAt, v)) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.Beacon { return predicate.Beacon(sql.FieldEQ(FieldName, v)) diff --git a/tavern/internal/ent/beacon_create.go b/tavern/internal/ent/beacon_create.go index 84f7c64d8..f9d643c80 100644 --- a/tavern/internal/ent/beacon_create.go +++ b/tavern/internal/ent/beacon_create.go @@ -24,6 +24,34 @@ type BeaconCreate struct { conflict []sql.ConflictOption } +// SetCreatedAt sets the "created_at" field. +func (bc *BeaconCreate) SetCreatedAt(t time.Time) *BeaconCreate { + bc.mutation.SetCreatedAt(t) + return bc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (bc *BeaconCreate) SetNillableCreatedAt(t *time.Time) *BeaconCreate { + if t != nil { + bc.SetCreatedAt(*t) + } + return bc +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (bc *BeaconCreate) SetLastModifiedAt(t time.Time) *BeaconCreate { + bc.mutation.SetLastModifiedAt(t) + return bc +} + +// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. +func (bc *BeaconCreate) SetNillableLastModifiedAt(t *time.Time) *BeaconCreate { + if t != nil { + bc.SetLastModifiedAt(*t) + } + return bc +} + // SetName sets the "name" field. func (bc *BeaconCreate) SetName(s string) *BeaconCreate { bc.mutation.SetName(s) @@ -169,6 +197,14 @@ func (bc *BeaconCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (bc *BeaconCreate) defaults() { + if _, ok := bc.mutation.CreatedAt(); !ok { + v := beacon.DefaultCreatedAt() + bc.mutation.SetCreatedAt(v) + } + if _, ok := bc.mutation.LastModifiedAt(); !ok { + v := beacon.DefaultLastModifiedAt() + bc.mutation.SetLastModifiedAt(v) + } if _, ok := bc.mutation.Name(); !ok { v := beacon.DefaultName() bc.mutation.SetName(v) @@ -181,6 +217,12 @@ func (bc *BeaconCreate) defaults() { // check runs all checks and user-defined validators on the builder. func (bc *BeaconCreate) check() error { + if _, ok := bc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Beacon.created_at"`)} + } + if _, ok := bc.mutation.LastModifiedAt(); !ok { + return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "Beacon.last_modified_at"`)} + } if _, ok := bc.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Beacon.name"`)} } @@ -237,6 +279,14 @@ func (bc *BeaconCreate) createSpec() (*Beacon, *sqlgraph.CreateSpec) { _spec = sqlgraph.NewCreateSpec(beacon.Table, sqlgraph.NewFieldSpec(beacon.FieldID, field.TypeInt)) ) _spec.OnConflict = bc.conflict + if value, ok := bc.mutation.CreatedAt(); ok { + _spec.SetField(beacon.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := bc.mutation.LastModifiedAt(); ok { + _spec.SetField(beacon.FieldLastModifiedAt, field.TypeTime, value) + _node.LastModifiedAt = value + } if value, ok := bc.mutation.Name(); ok { _spec.SetField(beacon.FieldName, field.TypeString, value) _node.Name = value @@ -301,7 +351,7 @@ func (bc *BeaconCreate) createSpec() (*Beacon, *sqlgraph.CreateSpec) { // of the `INSERT` statement. For example: // // client.Beacon.Create(). -// SetName(v). +// SetCreatedAt(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -310,7 +360,7 @@ func (bc *BeaconCreate) createSpec() (*Beacon, *sqlgraph.CreateSpec) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.BeaconUpsert) { -// SetName(v+v). +// SetCreatedAt(v+v). // }). // Exec(ctx) func (bc *BeaconCreate) OnConflict(opts ...sql.ConflictOption) *BeaconUpsertOne { @@ -346,6 +396,18 @@ type ( } ) +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BeaconUpsert) SetLastModifiedAt(v time.Time) *BeaconUpsert { + u.Set(beacon.FieldLastModifiedAt, v) + return u +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BeaconUpsert) UpdateLastModifiedAt() *BeaconUpsert { + u.SetExcluded(beacon.FieldLastModifiedAt) + return u +} + // SetPrincipal sets the "principal" field. func (u *BeaconUpsert) SetPrincipal(v string) *BeaconUpsert { u.Set(beacon.FieldPrincipal, v) @@ -447,6 +509,9 @@ func (u *BeaconUpsert) ClearInterval() *BeaconUpsert { func (u *BeaconUpsertOne) UpdateNewValues() *BeaconUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(beacon.FieldCreatedAt) + } if _, exists := u.create.mutation.Name(); exists { s.SetIgnore(beacon.FieldName) } @@ -481,6 +546,20 @@ func (u *BeaconUpsertOne) Update(set func(*BeaconUpsert)) *BeaconUpsertOne { return u } +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BeaconUpsertOne) SetLastModifiedAt(v time.Time) *BeaconUpsertOne { + return u.Update(func(s *BeaconUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BeaconUpsertOne) UpdateLastModifiedAt() *BeaconUpsertOne { + return u.Update(func(s *BeaconUpsert) { + s.UpdateLastModifiedAt() + }) +} + // SetPrincipal sets the "principal" field. func (u *BeaconUpsertOne) SetPrincipal(v string) *BeaconUpsertOne { return u.Update(func(s *BeaconUpsert) { @@ -721,7 +800,7 @@ func (bcb *BeaconCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.BeaconUpsert) { -// SetName(v+v). +// SetCreatedAt(v+v). // }). // Exec(ctx) func (bcb *BeaconCreateBulk) OnConflict(opts ...sql.ConflictOption) *BeaconUpsertBulk { @@ -762,6 +841,9 @@ func (u *BeaconUpsertBulk) UpdateNewValues() *BeaconUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { for _, b := range u.create.builders { + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(beacon.FieldCreatedAt) + } if _, exists := b.mutation.Name(); exists { s.SetIgnore(beacon.FieldName) } @@ -797,6 +879,20 @@ func (u *BeaconUpsertBulk) Update(set func(*BeaconUpsert)) *BeaconUpsertBulk { return u } +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BeaconUpsertBulk) SetLastModifiedAt(v time.Time) *BeaconUpsertBulk { + return u.Update(func(s *BeaconUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BeaconUpsertBulk) UpdateLastModifiedAt() *BeaconUpsertBulk { + return u.Update(func(s *BeaconUpsert) { + s.UpdateLastModifiedAt() + }) +} + // SetPrincipal sets the "principal" field. func (u *BeaconUpsertBulk) SetPrincipal(v string) *BeaconUpsertBulk { return u.Update(func(s *BeaconUpsert) { diff --git a/tavern/internal/ent/beacon_query.go b/tavern/internal/ent/beacon_query.go index e6f22c40d..2fa62c96d 100644 --- a/tavern/internal/ent/beacon_query.go +++ b/tavern/internal/ent/beacon_query.go @@ -338,12 +338,12 @@ func (bq *BeaconQuery) WithTasks(opts ...func(*TaskQuery)) *BeaconQuery { // Example: // // var v []struct { -// Name string `json:"name,omitempty"` +// CreatedAt time.Time `json:"created_at,omitempty"` // Count int `json:"count,omitempty"` // } // // client.Beacon.Query(). -// GroupBy(beacon.FieldName). +// GroupBy(beacon.FieldCreatedAt). // Aggregate(ent.Count()). // Scan(ctx, &v) func (bq *BeaconQuery) GroupBy(field string, fields ...string) *BeaconGroupBy { @@ -361,11 +361,11 @@ func (bq *BeaconQuery) GroupBy(field string, fields ...string) *BeaconGroupBy { // Example: // // var v []struct { -// Name string `json:"name,omitempty"` +// CreatedAt time.Time `json:"created_at,omitempty"` // } // // client.Beacon.Query(). -// Select(beacon.FieldName). +// Select(beacon.FieldCreatedAt). // Scan(ctx, &v) func (bq *BeaconQuery) Select(fields ...string) *BeaconSelect { bq.ctx.Fields = append(bq.ctx.Fields, fields...) diff --git a/tavern/internal/ent/beacon_update.go b/tavern/internal/ent/beacon_update.go index dbc1c31b7..328f4e1cf 100644 --- a/tavern/internal/ent/beacon_update.go +++ b/tavern/internal/ent/beacon_update.go @@ -30,6 +30,12 @@ func (bu *BeaconUpdate) Where(ps ...predicate.Beacon) *BeaconUpdate { return bu } +// SetLastModifiedAt sets the "last_modified_at" field. +func (bu *BeaconUpdate) SetLastModifiedAt(t time.Time) *BeaconUpdate { + bu.mutation.SetLastModifiedAt(t) + return bu +} + // SetPrincipal sets the "principal" field. func (bu *BeaconUpdate) SetPrincipal(s string) *BeaconUpdate { bu.mutation.SetPrincipal(s) @@ -191,6 +197,7 @@ func (bu *BeaconUpdate) RemoveTasks(t ...*Task) *BeaconUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (bu *BeaconUpdate) Save(ctx context.Context) (int, error) { + bu.defaults() return withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks) } @@ -216,6 +223,14 @@ func (bu *BeaconUpdate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (bu *BeaconUpdate) defaults() { + if _, ok := bu.mutation.LastModifiedAt(); !ok { + v := beacon.UpdateDefaultLastModifiedAt() + bu.mutation.SetLastModifiedAt(v) + } +} + // check runs all checks and user-defined validators on the builder. func (bu *BeaconUpdate) check() error { if v, ok := bu.mutation.Principal(); ok { @@ -251,6 +266,9 @@ func (bu *BeaconUpdate) sqlSave(ctx context.Context) (n int, err error) { } } } + if value, ok := bu.mutation.LastModifiedAt(); ok { + _spec.SetField(beacon.FieldLastModifiedAt, field.TypeTime, value) + } if value, ok := bu.mutation.Principal(); ok { _spec.SetField(beacon.FieldPrincipal, field.TypeString, value) } @@ -375,6 +393,12 @@ type BeaconUpdateOne struct { mutation *BeaconMutation } +// SetLastModifiedAt sets the "last_modified_at" field. +func (buo *BeaconUpdateOne) SetLastModifiedAt(t time.Time) *BeaconUpdateOne { + buo.mutation.SetLastModifiedAt(t) + return buo +} + // SetPrincipal sets the "principal" field. func (buo *BeaconUpdateOne) SetPrincipal(s string) *BeaconUpdateOne { buo.mutation.SetPrincipal(s) @@ -549,6 +573,7 @@ func (buo *BeaconUpdateOne) Select(field string, fields ...string) *BeaconUpdate // Save executes the query and returns the updated Beacon entity. func (buo *BeaconUpdateOne) Save(ctx context.Context) (*Beacon, error) { + buo.defaults() return withHooks(ctx, buo.sqlSave, buo.mutation, buo.hooks) } @@ -574,6 +599,14 @@ func (buo *BeaconUpdateOne) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (buo *BeaconUpdateOne) defaults() { + if _, ok := buo.mutation.LastModifiedAt(); !ok { + v := beacon.UpdateDefaultLastModifiedAt() + buo.mutation.SetLastModifiedAt(v) + } +} + // check runs all checks and user-defined validators on the builder. func (buo *BeaconUpdateOne) check() error { if v, ok := buo.mutation.Principal(); ok { @@ -626,6 +659,9 @@ func (buo *BeaconUpdateOne) sqlSave(ctx context.Context) (_node *Beacon, err err } } } + if value, ok := buo.mutation.LastModifiedAt(); ok { + _spec.SetField(beacon.FieldLastModifiedAt, field.TypeTime, value) + } if value, ok := buo.mutation.Principal(); ok { _spec.SetField(beacon.FieldPrincipal, field.TypeString, value) } diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index ca786b974..2ba2ce8f4 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -62,6 +62,16 @@ func (b *BeaconQuery) collectField(ctx context.Context, opCtx *graphql.Operation b.WithNamedTasks(alias, func(wq *TaskQuery) { *wq = *query }) + case "createdAt": + if _, ok := fieldSeen[beacon.FieldCreatedAt]; !ok { + selectedFields = append(selectedFields, beacon.FieldCreatedAt) + fieldSeen[beacon.FieldCreatedAt] = struct{}{} + } + case "lastModifiedAt": + if _, ok := fieldSeen[beacon.FieldLastModifiedAt]; !ok { + selectedFields = append(selectedFields, beacon.FieldLastModifiedAt) + fieldSeen[beacon.FieldLastModifiedAt] = struct{}{} + } case "name": if _, ok := fieldSeen[beacon.FieldName]; !ok { selectedFields = append(selectedFields, beacon.FieldName) @@ -333,6 +343,16 @@ func (h *HostQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo h.WithNamedProcesses(alias, func(wq *ProcessQuery) { *wq = *query }) + case "createdAt": + if _, ok := fieldSeen[host.FieldCreatedAt]; !ok { + selectedFields = append(selectedFields, host.FieldCreatedAt) + fieldSeen[host.FieldCreatedAt] = struct{}{} + } + case "lastModifiedAt": + if _, ok := fieldSeen[host.FieldLastModifiedAt]; !ok { + selectedFields = append(selectedFields, host.FieldLastModifiedAt) + fieldSeen[host.FieldLastModifiedAt] = struct{}{} + } case "identifier": if _, ok := fieldSeen[host.FieldIdentifier]; !ok { selectedFields = append(selectedFields, host.FieldIdentifier) diff --git a/tavern/internal/ent/gql_mutation_input.go b/tavern/internal/ent/gql_mutation_input.go index ac9bc1517..f82245cff 100644 --- a/tavern/internal/ent/gql_mutation_input.go +++ b/tavern/internal/ent/gql_mutation_input.go @@ -11,11 +11,15 @@ import ( // UpdateBeaconInput represents a mutation input for updating beacons. type UpdateBeaconInput struct { - HostID *int + LastModifiedAt *time.Time + HostID *int } // Mutate applies the UpdateBeaconInput on the BeaconMutation builder. func (i *UpdateBeaconInput) Mutate(m *BeaconMutation) { + if v := i.LastModifiedAt; v != nil { + m.SetLastModifiedAt(*v) + } if v := i.HostID; v != nil { m.SetHostID(*v) } @@ -35,6 +39,7 @@ func (c *BeaconUpdateOne) SetInput(i UpdateBeaconInput) *BeaconUpdateOne { // UpdateHostInput represents a mutation input for updating hosts. type UpdateHostInput struct { + LastModifiedAt *time.Time ClearName bool Name *string ClearTags bool @@ -50,6 +55,9 @@ type UpdateHostInput struct { // Mutate applies the UpdateHostInput on the HostMutation builder. func (i *UpdateHostInput) Mutate(m *HostMutation) { + if v := i.LastModifiedAt; v != nil { + m.SetLastModifiedAt(*v) + } if i.ClearName { m.ClearName() } diff --git a/tavern/internal/ent/gql_pagination.go b/tavern/internal/ent/gql_pagination.go index c19105491..a4058f3d6 100644 --- a/tavern/internal/ent/gql_pagination.go +++ b/tavern/internal/ent/gql_pagination.go @@ -312,6 +312,34 @@ func (b *BeaconQuery) Paginate( } var ( + // BeaconOrderFieldCreatedAt orders Beacon by created_at. + BeaconOrderFieldCreatedAt = &BeaconOrderField{ + Value: func(b *Beacon) (ent.Value, error) { + return b.CreatedAt, nil + }, + column: beacon.FieldCreatedAt, + toTerm: beacon.ByCreatedAt, + toCursor: func(b *Beacon) Cursor { + return Cursor{ + ID: b.ID, + Value: b.CreatedAt, + } + }, + } + // BeaconOrderFieldLastModifiedAt orders Beacon by last_modified_at. + BeaconOrderFieldLastModifiedAt = &BeaconOrderField{ + Value: func(b *Beacon) (ent.Value, error) { + return b.LastModifiedAt, nil + }, + column: beacon.FieldLastModifiedAt, + toTerm: beacon.ByLastModifiedAt, + toCursor: func(b *Beacon) Cursor { + return Cursor{ + ID: b.ID, + Value: b.LastModifiedAt, + } + }, + } // BeaconOrderFieldLastSeenAt orders Beacon by last_seen_at. BeaconOrderFieldLastSeenAt = &BeaconOrderField{ Value: func(b *Beacon) (ent.Value, error) { @@ -346,6 +374,10 @@ var ( func (f BeaconOrderField) String() string { var str string switch f.column { + case BeaconOrderFieldCreatedAt.column: + str = "CREATED_AT" + case BeaconOrderFieldLastModifiedAt.column: + str = "LAST_MODIFIED_AT" case BeaconOrderFieldLastSeenAt.column: str = "LAST_SEEN_AT" case BeaconOrderFieldInterval.column: @@ -366,6 +398,10 @@ func (f *BeaconOrderField) UnmarshalGQL(v interface{}) error { return fmt.Errorf("BeaconOrderField %T must be a string", v) } switch str { + case "CREATED_AT": + *f = *BeaconOrderFieldCreatedAt + case "LAST_MODIFIED_AT": + *f = *BeaconOrderFieldLastModifiedAt case "LAST_SEEN_AT": *f = *BeaconOrderFieldLastSeenAt case "INTERVAL": @@ -970,6 +1006,34 @@ func (h *HostQuery) Paginate( } var ( + // HostOrderFieldCreatedAt orders Host by created_at. + HostOrderFieldCreatedAt = &HostOrderField{ + Value: func(h *Host) (ent.Value, error) { + return h.CreatedAt, nil + }, + column: host.FieldCreatedAt, + toTerm: host.ByCreatedAt, + toCursor: func(h *Host) Cursor { + return Cursor{ + ID: h.ID, + Value: h.CreatedAt, + } + }, + } + // HostOrderFieldLastModifiedAt orders Host by last_modified_at. + HostOrderFieldLastModifiedAt = &HostOrderField{ + Value: func(h *Host) (ent.Value, error) { + return h.LastModifiedAt, nil + }, + column: host.FieldLastModifiedAt, + toTerm: host.ByLastModifiedAt, + toCursor: func(h *Host) Cursor { + return Cursor{ + ID: h.ID, + Value: h.LastModifiedAt, + } + }, + } // HostOrderFieldLastSeenAt orders Host by last_seen_at. HostOrderFieldLastSeenAt = &HostOrderField{ Value: func(h *Host) (ent.Value, error) { @@ -990,6 +1054,10 @@ var ( func (f HostOrderField) String() string { var str string switch f.column { + case HostOrderFieldCreatedAt.column: + str = "CREATED_AT" + case HostOrderFieldLastModifiedAt.column: + str = "LAST_MODIFIED_AT" case HostOrderFieldLastSeenAt.column: str = "LAST_SEEN_AT" } @@ -1008,6 +1076,10 @@ func (f *HostOrderField) UnmarshalGQL(v interface{}) error { return fmt.Errorf("HostOrderField %T must be a string", v) } switch str { + case "CREATED_AT": + *f = *HostOrderFieldCreatedAt + case "LAST_MODIFIED_AT": + *f = *HostOrderFieldLastModifiedAt case "LAST_SEEN_AT": *f = *HostOrderFieldLastSeenAt default: diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index cad442d9e..e41f865fe 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -36,6 +36,26 @@ type BeaconWhereInput struct { IDLT *int `json:"idLT,omitempty"` IDLTE *int `json:"idLTE,omitempty"` + // "created_at" field predicates. + CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAtNEQ *time.Time `json:"createdAtNEQ,omitempty"` + CreatedAtIn []time.Time `json:"createdAtIn,omitempty"` + CreatedAtNotIn []time.Time `json:"createdAtNotIn,omitempty"` + CreatedAtGT *time.Time `json:"createdAtGT,omitempty"` + CreatedAtGTE *time.Time `json:"createdAtGTE,omitempty"` + CreatedAtLT *time.Time `json:"createdAtLT,omitempty"` + CreatedAtLTE *time.Time `json:"createdAtLTE,omitempty"` + + // "last_modified_at" field predicates. + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAtNEQ *time.Time `json:"lastModifiedAtNEQ,omitempty"` + LastModifiedAtIn []time.Time `json:"lastModifiedAtIn,omitempty"` + LastModifiedAtNotIn []time.Time `json:"lastModifiedAtNotIn,omitempty"` + LastModifiedAtGT *time.Time `json:"lastModifiedAtGT,omitempty"` + LastModifiedAtGTE *time.Time `json:"lastModifiedAtGTE,omitempty"` + LastModifiedAtLT *time.Time `json:"lastModifiedAtLT,omitempty"` + LastModifiedAtLTE *time.Time `json:"lastModifiedAtLTE,omitempty"` + // "name" field predicates. Name *string `json:"name,omitempty"` NameNEQ *string `json:"nameNEQ,omitempty"` @@ -228,6 +248,54 @@ func (i *BeaconWhereInput) P() (predicate.Beacon, error) { if i.IDLTE != nil { predicates = append(predicates, beacon.IDLTE(*i.IDLTE)) } + if i.CreatedAt != nil { + predicates = append(predicates, beacon.CreatedAtEQ(*i.CreatedAt)) + } + if i.CreatedAtNEQ != nil { + predicates = append(predicates, beacon.CreatedAtNEQ(*i.CreatedAtNEQ)) + } + if len(i.CreatedAtIn) > 0 { + predicates = append(predicates, beacon.CreatedAtIn(i.CreatedAtIn...)) + } + if len(i.CreatedAtNotIn) > 0 { + predicates = append(predicates, beacon.CreatedAtNotIn(i.CreatedAtNotIn...)) + } + if i.CreatedAtGT != nil { + predicates = append(predicates, beacon.CreatedAtGT(*i.CreatedAtGT)) + } + if i.CreatedAtGTE != nil { + predicates = append(predicates, beacon.CreatedAtGTE(*i.CreatedAtGTE)) + } + if i.CreatedAtLT != nil { + predicates = append(predicates, beacon.CreatedAtLT(*i.CreatedAtLT)) + } + if i.CreatedAtLTE != nil { + predicates = append(predicates, beacon.CreatedAtLTE(*i.CreatedAtLTE)) + } + if i.LastModifiedAt != nil { + predicates = append(predicates, beacon.LastModifiedAtEQ(*i.LastModifiedAt)) + } + if i.LastModifiedAtNEQ != nil { + predicates = append(predicates, beacon.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) + } + if len(i.LastModifiedAtIn) > 0 { + predicates = append(predicates, beacon.LastModifiedAtIn(i.LastModifiedAtIn...)) + } + if len(i.LastModifiedAtNotIn) > 0 { + predicates = append(predicates, beacon.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) + } + if i.LastModifiedAtGT != nil { + predicates = append(predicates, beacon.LastModifiedAtGT(*i.LastModifiedAtGT)) + } + if i.LastModifiedAtGTE != nil { + predicates = append(predicates, beacon.LastModifiedAtGTE(*i.LastModifiedAtGTE)) + } + if i.LastModifiedAtLT != nil { + predicates = append(predicates, beacon.LastModifiedAtLT(*i.LastModifiedAtLT)) + } + if i.LastModifiedAtLTE != nil { + predicates = append(predicates, beacon.LastModifiedAtLTE(*i.LastModifiedAtLTE)) + } if i.Name != nil { predicates = append(predicates, beacon.NameEQ(*i.Name)) } @@ -876,6 +944,26 @@ type HostWhereInput struct { IDLT *int `json:"idLT,omitempty"` IDLTE *int `json:"idLTE,omitempty"` + // "created_at" field predicates. + CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAtNEQ *time.Time `json:"createdAtNEQ,omitempty"` + CreatedAtIn []time.Time `json:"createdAtIn,omitempty"` + CreatedAtNotIn []time.Time `json:"createdAtNotIn,omitempty"` + CreatedAtGT *time.Time `json:"createdAtGT,omitempty"` + CreatedAtGTE *time.Time `json:"createdAtGTE,omitempty"` + CreatedAtLT *time.Time `json:"createdAtLT,omitempty"` + CreatedAtLTE *time.Time `json:"createdAtLTE,omitempty"` + + // "last_modified_at" field predicates. + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAtNEQ *time.Time `json:"lastModifiedAtNEQ,omitempty"` + LastModifiedAtIn []time.Time `json:"lastModifiedAtIn,omitempty"` + LastModifiedAtNotIn []time.Time `json:"lastModifiedAtNotIn,omitempty"` + LastModifiedAtGT *time.Time `json:"lastModifiedAtGT,omitempty"` + LastModifiedAtGTE *time.Time `json:"lastModifiedAtGTE,omitempty"` + LastModifiedAtLT *time.Time `json:"lastModifiedAtLT,omitempty"` + LastModifiedAtLTE *time.Time `json:"lastModifiedAtLTE,omitempty"` + // "identifier" field predicates. Identifier *string `json:"identifier,omitempty"` IdentifierNEQ *string `json:"identifierNEQ,omitempty"` @@ -1051,6 +1139,54 @@ func (i *HostWhereInput) P() (predicate.Host, error) { if i.IDLTE != nil { predicates = append(predicates, host.IDLTE(*i.IDLTE)) } + if i.CreatedAt != nil { + predicates = append(predicates, host.CreatedAtEQ(*i.CreatedAt)) + } + if i.CreatedAtNEQ != nil { + predicates = append(predicates, host.CreatedAtNEQ(*i.CreatedAtNEQ)) + } + if len(i.CreatedAtIn) > 0 { + predicates = append(predicates, host.CreatedAtIn(i.CreatedAtIn...)) + } + if len(i.CreatedAtNotIn) > 0 { + predicates = append(predicates, host.CreatedAtNotIn(i.CreatedAtNotIn...)) + } + if i.CreatedAtGT != nil { + predicates = append(predicates, host.CreatedAtGT(*i.CreatedAtGT)) + } + if i.CreatedAtGTE != nil { + predicates = append(predicates, host.CreatedAtGTE(*i.CreatedAtGTE)) + } + if i.CreatedAtLT != nil { + predicates = append(predicates, host.CreatedAtLT(*i.CreatedAtLT)) + } + if i.CreatedAtLTE != nil { + predicates = append(predicates, host.CreatedAtLTE(*i.CreatedAtLTE)) + } + if i.LastModifiedAt != nil { + predicates = append(predicates, host.LastModifiedAtEQ(*i.LastModifiedAt)) + } + if i.LastModifiedAtNEQ != nil { + predicates = append(predicates, host.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) + } + if len(i.LastModifiedAtIn) > 0 { + predicates = append(predicates, host.LastModifiedAtIn(i.LastModifiedAtIn...)) + } + if len(i.LastModifiedAtNotIn) > 0 { + predicates = append(predicates, host.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) + } + if i.LastModifiedAtGT != nil { + predicates = append(predicates, host.LastModifiedAtGT(*i.LastModifiedAtGT)) + } + if i.LastModifiedAtGTE != nil { + predicates = append(predicates, host.LastModifiedAtGTE(*i.LastModifiedAtGTE)) + } + if i.LastModifiedAtLT != nil { + predicates = append(predicates, host.LastModifiedAtLT(*i.LastModifiedAtLT)) + } + if i.LastModifiedAtLTE != nil { + predicates = append(predicates, host.LastModifiedAtLTE(*i.LastModifiedAtLTE)) + } if i.Identifier != nil { predicates = append(predicates, host.IdentifierEQ(*i.Identifier)) } diff --git a/tavern/internal/ent/host.go b/tavern/internal/ent/host.go index 43d2da5b5..2ed68e284 100644 --- a/tavern/internal/ent/host.go +++ b/tavern/internal/ent/host.go @@ -17,6 +17,10 @@ type Host struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` + // Timestamp of when this ent was created + CreatedAt time.Time `json:"created_at,omitempty"` + // Timestamp of when this ent was last updated + LastModifiedAt time.Time `json:"last_modified_at,omitempty"` // Unique identifier for the host. Unique to each host. Identifier string `json:"identifier,omitempty"` // A human readable identifier for the host. @@ -88,7 +92,7 @@ func (*Host) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case host.FieldIdentifier, host.FieldName, host.FieldPrimaryIP, host.FieldPlatform: values[i] = new(sql.NullString) - case host.FieldLastSeenAt: + case host.FieldCreatedAt, host.FieldLastModifiedAt, host.FieldLastSeenAt: values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) @@ -111,6 +115,18 @@ func (h *Host) assignValues(columns []string, values []any) error { return fmt.Errorf("unexpected type %T for field id", value) } h.ID = int(value.Int64) + case host.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + h.CreatedAt = value.Time + } + case host.FieldLastModifiedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_modified_at", values[i]) + } else if value.Valid { + h.LastModifiedAt = value.Time + } case host.FieldIdentifier: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field identifier", values[i]) @@ -192,6 +208,12 @@ func (h *Host) String() string { var builder strings.Builder builder.WriteString("Host(") builder.WriteString(fmt.Sprintf("id=%v, ", h.ID)) + builder.WriteString("created_at=") + builder.WriteString(h.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("last_modified_at=") + builder.WriteString(h.LastModifiedAt.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("identifier=") builder.WriteString(h.Identifier) builder.WriteString(", ") diff --git a/tavern/internal/ent/host/host.go b/tavern/internal/ent/host/host.go index 672f73c8a..17854a752 100644 --- a/tavern/internal/ent/host/host.go +++ b/tavern/internal/ent/host/host.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "strconv" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -16,6 +17,10 @@ const ( Label = "host" // FieldID holds the string denoting the id field in the database. FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldLastModifiedAt holds the string denoting the last_modified_at field in the database. + FieldLastModifiedAt = "last_modified_at" // FieldIdentifier holds the string denoting the identifier field in the database. FieldIdentifier = "identifier" // FieldName holds the string denoting the name field in the database. @@ -58,6 +63,8 @@ const ( // Columns holds all SQL columns for host fields. var Columns = []string{ FieldID, + FieldCreatedAt, + FieldLastModifiedAt, FieldIdentifier, FieldName, FieldPrimaryIP, @@ -82,6 +89,12 @@ func ValidColumn(column string) bool { } var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultLastModifiedAt holds the default value on creation for the "last_modified_at" field. + DefaultLastModifiedAt func() time.Time + // UpdateDefaultLastModifiedAt holds the default value on update for the "last_modified_at" field. + UpdateDefaultLastModifiedAt func() time.Time // IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. IdentifierValidator func(string) error // NameValidator is a validator for the "name" field. It is called by the builders before save. @@ -125,6 +138,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByLastModifiedAt orders the results by the last_modified_at field. +func ByLastModifiedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastModifiedAt, opts...).ToFunc() +} + // ByIdentifier orders the results by the identifier field. func ByIdentifier(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldIdentifier, opts...).ToFunc() diff --git a/tavern/internal/ent/host/where.go b/tavern/internal/ent/host/where.go index 5d84635f1..942bfb85a 100644 --- a/tavern/internal/ent/host/where.go +++ b/tavern/internal/ent/host/where.go @@ -55,6 +55,16 @@ func IDLTE(id int) predicate.Host { return predicate.Host(sql.FieldLTE(FieldID, id)) } +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Host { + return predicate.Host(sql.FieldEQ(FieldCreatedAt, v)) +} + +// LastModifiedAt applies equality check predicate on the "last_modified_at" field. It's identical to LastModifiedAtEQ. +func LastModifiedAt(v time.Time) predicate.Host { + return predicate.Host(sql.FieldEQ(FieldLastModifiedAt, v)) +} + // Identifier applies equality check predicate on the "identifier" field. It's identical to IdentifierEQ. func Identifier(v string) predicate.Host { return predicate.Host(sql.FieldEQ(FieldIdentifier, v)) @@ -75,6 +85,86 @@ func LastSeenAt(v time.Time) predicate.Host { return predicate.Host(sql.FieldEQ(FieldLastSeenAt, v)) } +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Host { + return predicate.Host(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Host { + return predicate.Host(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Host { + return predicate.Host(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Host { + return predicate.Host(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Host { + return predicate.Host(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Host { + return predicate.Host(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Host { + return predicate.Host(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Host { + return predicate.Host(sql.FieldLTE(FieldCreatedAt, v)) +} + +// LastModifiedAtEQ applies the EQ predicate on the "last_modified_at" field. +func LastModifiedAtEQ(v time.Time) predicate.Host { + return predicate.Host(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtNEQ applies the NEQ predicate on the "last_modified_at" field. +func LastModifiedAtNEQ(v time.Time) predicate.Host { + return predicate.Host(sql.FieldNEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtIn applies the In predicate on the "last_modified_at" field. +func LastModifiedAtIn(vs ...time.Time) predicate.Host { + return predicate.Host(sql.FieldIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtNotIn applies the NotIn predicate on the "last_modified_at" field. +func LastModifiedAtNotIn(vs ...time.Time) predicate.Host { + return predicate.Host(sql.FieldNotIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtGT applies the GT predicate on the "last_modified_at" field. +func LastModifiedAtGT(v time.Time) predicate.Host { + return predicate.Host(sql.FieldGT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtGTE applies the GTE predicate on the "last_modified_at" field. +func LastModifiedAtGTE(v time.Time) predicate.Host { + return predicate.Host(sql.FieldGTE(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLT applies the LT predicate on the "last_modified_at" field. +func LastModifiedAtLT(v time.Time) predicate.Host { + return predicate.Host(sql.FieldLT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLTE applies the LTE predicate on the "last_modified_at" field. +func LastModifiedAtLTE(v time.Time) predicate.Host { + return predicate.Host(sql.FieldLTE(FieldLastModifiedAt, v)) +} + // IdentifierEQ applies the EQ predicate on the "identifier" field. func IdentifierEQ(v string) predicate.Host { return predicate.Host(sql.FieldEQ(FieldIdentifier, v)) diff --git a/tavern/internal/ent/host_create.go b/tavern/internal/ent/host_create.go index e0654973c..461ed3593 100644 --- a/tavern/internal/ent/host_create.go +++ b/tavern/internal/ent/host_create.go @@ -25,6 +25,34 @@ type HostCreate struct { conflict []sql.ConflictOption } +// SetCreatedAt sets the "created_at" field. +func (hc *HostCreate) SetCreatedAt(t time.Time) *HostCreate { + hc.mutation.SetCreatedAt(t) + return hc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (hc *HostCreate) SetNillableCreatedAt(t *time.Time) *HostCreate { + if t != nil { + hc.SetCreatedAt(*t) + } + return hc +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (hc *HostCreate) SetLastModifiedAt(t time.Time) *HostCreate { + hc.mutation.SetLastModifiedAt(t) + return hc +} + +// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. +func (hc *HostCreate) SetNillableLastModifiedAt(t *time.Time) *HostCreate { + if t != nil { + hc.SetLastModifiedAt(*t) + } + return hc +} + // SetIdentifier sets the "identifier" field. func (hc *HostCreate) SetIdentifier(s string) *HostCreate { hc.mutation.SetIdentifier(s) @@ -167,6 +195,14 @@ func (hc *HostCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (hc *HostCreate) defaults() { + if _, ok := hc.mutation.CreatedAt(); !ok { + v := host.DefaultCreatedAt() + hc.mutation.SetCreatedAt(v) + } + if _, ok := hc.mutation.LastModifiedAt(); !ok { + v := host.DefaultLastModifiedAt() + hc.mutation.SetLastModifiedAt(v) + } if _, ok := hc.mutation.Platform(); !ok { v := host.DefaultPlatform hc.mutation.SetPlatform(v) @@ -175,6 +211,12 @@ func (hc *HostCreate) defaults() { // check runs all checks and user-defined validators on the builder. func (hc *HostCreate) check() error { + if _, ok := hc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Host.created_at"`)} + } + if _, ok := hc.mutation.LastModifiedAt(); !ok { + return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "Host.last_modified_at"`)} + } if _, ok := hc.mutation.Identifier(); !ok { return &ValidationError{Name: "identifier", err: errors.New(`ent: missing required field "Host.identifier"`)} } @@ -223,6 +265,14 @@ func (hc *HostCreate) createSpec() (*Host, *sqlgraph.CreateSpec) { _spec = sqlgraph.NewCreateSpec(host.Table, sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt)) ) _spec.OnConflict = hc.conflict + if value, ok := hc.mutation.CreatedAt(); ok { + _spec.SetField(host.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := hc.mutation.LastModifiedAt(); ok { + _spec.SetField(host.FieldLastModifiedAt, field.TypeTime, value) + _node.LastModifiedAt = value + } if value, ok := hc.mutation.Identifier(); ok { _spec.SetField(host.FieldIdentifier, field.TypeString, value) _node.Identifier = value @@ -298,7 +348,7 @@ func (hc *HostCreate) createSpec() (*Host, *sqlgraph.CreateSpec) { // of the `INSERT` statement. For example: // // client.Host.Create(). -// SetIdentifier(v). +// SetCreatedAt(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -307,7 +357,7 @@ func (hc *HostCreate) createSpec() (*Host, *sqlgraph.CreateSpec) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.HostUpsert) { -// SetIdentifier(v+v). +// SetCreatedAt(v+v). // }). // Exec(ctx) func (hc *HostCreate) OnConflict(opts ...sql.ConflictOption) *HostUpsertOne { @@ -343,6 +393,18 @@ type ( } ) +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *HostUpsert) SetLastModifiedAt(v time.Time) *HostUpsert { + u.Set(host.FieldLastModifiedAt, v) + return u +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *HostUpsert) UpdateLastModifiedAt() *HostUpsert { + u.SetExcluded(host.FieldLastModifiedAt) + return u +} + // SetIdentifier sets the "identifier" field. func (u *HostUpsert) SetIdentifier(v string) *HostUpsert { u.Set(host.FieldIdentifier, v) @@ -431,6 +493,11 @@ func (u *HostUpsert) ClearLastSeenAt() *HostUpsert { // Exec(ctx) func (u *HostUpsertOne) UpdateNewValues() *HostUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(host.FieldCreatedAt) + } + })) return u } @@ -461,6 +528,20 @@ func (u *HostUpsertOne) Update(set func(*HostUpsert)) *HostUpsertOne { return u } +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *HostUpsertOne) SetLastModifiedAt(v time.Time) *HostUpsertOne { + return u.Update(func(s *HostUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *HostUpsertOne) UpdateLastModifiedAt() *HostUpsertOne { + return u.Update(func(s *HostUpsert) { + s.UpdateLastModifiedAt() + }) +} + // SetIdentifier sets the "identifier" field. func (u *HostUpsertOne) SetIdentifier(v string) *HostUpsertOne { return u.Update(func(s *HostUpsert) { @@ -687,7 +768,7 @@ func (hcb *HostCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.HostUpsert) { -// SetIdentifier(v+v). +// SetCreatedAt(v+v). // }). // Exec(ctx) func (hcb *HostCreateBulk) OnConflict(opts ...sql.ConflictOption) *HostUpsertBulk { @@ -726,6 +807,13 @@ type HostUpsertBulk struct { // Exec(ctx) func (u *HostUpsertBulk) UpdateNewValues() *HostUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(host.FieldCreatedAt) + } + } + })) return u } @@ -756,6 +844,20 @@ func (u *HostUpsertBulk) Update(set func(*HostUpsert)) *HostUpsertBulk { return u } +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *HostUpsertBulk) SetLastModifiedAt(v time.Time) *HostUpsertBulk { + return u.Update(func(s *HostUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *HostUpsertBulk) UpdateLastModifiedAt() *HostUpsertBulk { + return u.Update(func(s *HostUpsert) { + s.UpdateLastModifiedAt() + }) +} + // SetIdentifier sets the "identifier" field. func (u *HostUpsertBulk) SetIdentifier(v string) *HostUpsertBulk { return u.Update(func(s *HostUpsert) { diff --git a/tavern/internal/ent/host_query.go b/tavern/internal/ent/host_query.go index a2f0077b4..f2f07a0c3 100644 --- a/tavern/internal/ent/host_query.go +++ b/tavern/internal/ent/host_query.go @@ -375,12 +375,12 @@ func (hq *HostQuery) WithProcesses(opts ...func(*ProcessQuery)) *HostQuery { // Example: // // var v []struct { -// Identifier string `json:"identifier,omitempty"` +// CreatedAt time.Time `json:"created_at,omitempty"` // Count int `json:"count,omitempty"` // } // // client.Host.Query(). -// GroupBy(host.FieldIdentifier). +// GroupBy(host.FieldCreatedAt). // Aggregate(ent.Count()). // Scan(ctx, &v) func (hq *HostQuery) GroupBy(field string, fields ...string) *HostGroupBy { @@ -398,11 +398,11 @@ func (hq *HostQuery) GroupBy(field string, fields ...string) *HostGroupBy { // Example: // // var v []struct { -// Identifier string `json:"identifier,omitempty"` +// CreatedAt time.Time `json:"created_at,omitempty"` // } // // client.Host.Query(). -// Select(host.FieldIdentifier). +// Select(host.FieldCreatedAt). // Scan(ctx, &v) func (hq *HostQuery) Select(fields ...string) *HostSelect { hq.ctx.Fields = append(hq.ctx.Fields, fields...) diff --git a/tavern/internal/ent/host_update.go b/tavern/internal/ent/host_update.go index 73db365e0..974fd0d59 100644 --- a/tavern/internal/ent/host_update.go +++ b/tavern/internal/ent/host_update.go @@ -31,6 +31,12 @@ func (hu *HostUpdate) Where(ps ...predicate.Host) *HostUpdate { return hu } +// SetLastModifiedAt sets the "last_modified_at" field. +func (hu *HostUpdate) SetLastModifiedAt(t time.Time) *HostUpdate { + hu.mutation.SetLastModifiedAt(t) + return hu +} + // SetIdentifier sets the "identifier" field. func (hu *HostUpdate) SetIdentifier(s string) *HostUpdate { hu.mutation.SetIdentifier(s) @@ -226,6 +232,7 @@ func (hu *HostUpdate) RemoveProcesses(p ...*Process) *HostUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (hu *HostUpdate) Save(ctx context.Context) (int, error) { + hu.defaults() return withHooks(ctx, hu.sqlSave, hu.mutation, hu.hooks) } @@ -251,6 +258,14 @@ func (hu *HostUpdate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (hu *HostUpdate) defaults() { + if _, ok := hu.mutation.LastModifiedAt(); !ok { + v := host.UpdateDefaultLastModifiedAt() + hu.mutation.SetLastModifiedAt(v) + } +} + // check runs all checks and user-defined validators on the builder. func (hu *HostUpdate) check() error { if v, ok := hu.mutation.Identifier(); ok { @@ -283,6 +298,9 @@ func (hu *HostUpdate) sqlSave(ctx context.Context) (n int, err error) { } } } + if value, ok := hu.mutation.LastModifiedAt(); ok { + _spec.SetField(host.FieldLastModifiedAt, field.TypeTime, value) + } if value, ok := hu.mutation.Identifier(); ok { _spec.SetField(host.FieldIdentifier, field.TypeString, value) } @@ -462,6 +480,12 @@ type HostUpdateOne struct { mutation *HostMutation } +// SetLastModifiedAt sets the "last_modified_at" field. +func (huo *HostUpdateOne) SetLastModifiedAt(t time.Time) *HostUpdateOne { + huo.mutation.SetLastModifiedAt(t) + return huo +} + // SetIdentifier sets the "identifier" field. func (huo *HostUpdateOne) SetIdentifier(s string) *HostUpdateOne { huo.mutation.SetIdentifier(s) @@ -670,6 +694,7 @@ func (huo *HostUpdateOne) Select(field string, fields ...string) *HostUpdateOne // Save executes the query and returns the updated Host entity. func (huo *HostUpdateOne) Save(ctx context.Context) (*Host, error) { + huo.defaults() return withHooks(ctx, huo.sqlSave, huo.mutation, huo.hooks) } @@ -695,6 +720,14 @@ func (huo *HostUpdateOne) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (huo *HostUpdateOne) defaults() { + if _, ok := huo.mutation.LastModifiedAt(); !ok { + v := host.UpdateDefaultLastModifiedAt() + huo.mutation.SetLastModifiedAt(v) + } +} + // check runs all checks and user-defined validators on the builder. func (huo *HostUpdateOne) check() error { if v, ok := huo.mutation.Identifier(); ok { @@ -744,6 +777,9 @@ func (huo *HostUpdateOne) sqlSave(ctx context.Context) (_node *Host, err error) } } } + if value, ok := huo.mutation.LastModifiedAt(); ok { + _spec.SetField(host.FieldLastModifiedAt, field.TypeTime, value) + } if value, ok := huo.mutation.Identifier(); ok { _spec.SetField(host.FieldIdentifier, field.TypeString, value) } diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index e168e12e4..908e9b143 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -11,6 +11,8 @@ var ( // BeaconsColumns holds the columns for the "beacons" table. BeaconsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "last_modified_at", Type: field.TypeTime}, {Name: "name", Type: field.TypeString, Unique: true}, {Name: "principal", Type: field.TypeString, Nullable: true}, {Name: "identifier", Type: field.TypeString, Unique: true}, @@ -27,7 +29,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "beacons_hosts_host", - Columns: []*schema.Column{BeaconsColumns[7]}, + Columns: []*schema.Column{BeaconsColumns[9]}, RefColumns: []*schema.Column{HostsColumns[0]}, OnDelete: schema.NoAction, }, @@ -52,6 +54,8 @@ var ( // HostsColumns holds the columns for the "hosts" table. HostsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "last_modified_at", Type: field.TypeTime}, {Name: "identifier", Type: field.TypeString, Unique: true}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "primary_ip", Type: field.TypeString, Nullable: true}, diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index 9794de318..7357e752d 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -49,6 +49,8 @@ type BeaconMutation struct { op Op typ string id *int + created_at *time.Time + last_modified_at *time.Time name *string principal *string identifier *string @@ -165,6 +167,78 @@ func (m *BeaconMutation) IDs(ctx context.Context) ([]int, error) { } } +// SetCreatedAt sets the "created_at" field. +func (m *BeaconMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *BeaconMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Beacon entity. +// If the Beacon object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BeaconMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *BeaconMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (m *BeaconMutation) SetLastModifiedAt(t time.Time) { + m.last_modified_at = &t +} + +// LastModifiedAt returns the value of the "last_modified_at" field in the mutation. +func (m *BeaconMutation) LastModifiedAt() (r time.Time, exists bool) { + v := m.last_modified_at + if v == nil { + return + } + return *v, true +} + +// OldLastModifiedAt returns the old "last_modified_at" field's value of the Beacon entity. +// If the Beacon object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BeaconMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastModifiedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastModifiedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastModifiedAt: %w", err) + } + return oldValue.LastModifiedAt, nil +} + +// ResetLastModifiedAt resets all changes to the "last_modified_at" field. +func (m *BeaconMutation) ResetLastModifiedAt() { + m.last_modified_at = nil +} + // SetName sets the "name" field. func (m *BeaconMutation) SetName(s string) { m.name = &s @@ -581,7 +655,13 @@ func (m *BeaconMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BeaconMutation) Fields() []string { - fields := make([]string, 0, 6) + fields := make([]string, 0, 8) + if m.created_at != nil { + fields = append(fields, beacon.FieldCreatedAt) + } + if m.last_modified_at != nil { + fields = append(fields, beacon.FieldLastModifiedAt) + } if m.name != nil { fields = append(fields, beacon.FieldName) } @@ -608,6 +688,10 @@ func (m *BeaconMutation) Fields() []string { // schema. func (m *BeaconMutation) Field(name string) (ent.Value, bool) { switch name { + case beacon.FieldCreatedAt: + return m.CreatedAt() + case beacon.FieldLastModifiedAt: + return m.LastModifiedAt() case beacon.FieldName: return m.Name() case beacon.FieldPrincipal: @@ -629,6 +713,10 @@ func (m *BeaconMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *BeaconMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case beacon.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case beacon.FieldLastModifiedAt: + return m.OldLastModifiedAt(ctx) case beacon.FieldName: return m.OldName(ctx) case beacon.FieldPrincipal: @@ -650,6 +738,20 @@ func (m *BeaconMutation) OldField(ctx context.Context, name string) (ent.Value, // type. func (m *BeaconMutation) SetField(name string, value ent.Value) error { switch name { + case beacon.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case beacon.FieldLastModifiedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastModifiedAt(v) + return nil case beacon.FieldName: v, ok := value.(string) if !ok { @@ -783,6 +885,12 @@ func (m *BeaconMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *BeaconMutation) ResetField(name string) error { switch name { + case beacon.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case beacon.FieldLastModifiedAt: + m.ResetLastModifiedAt() + return nil case beacon.FieldName: m.ResetName() return nil @@ -1638,6 +1746,8 @@ type HostMutation struct { op Op typ string id *int + created_at *time.Time + last_modified_at *time.Time identifier *string name *string primary_ip *string @@ -1756,6 +1866,78 @@ func (m *HostMutation) IDs(ctx context.Context) ([]int, error) { } } +// SetCreatedAt sets the "created_at" field. +func (m *HostMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *HostMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *HostMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (m *HostMutation) SetLastModifiedAt(t time.Time) { + m.last_modified_at = &t +} + +// LastModifiedAt returns the value of the "last_modified_at" field in the mutation. +func (m *HostMutation) LastModifiedAt() (r time.Time, exists bool) { + v := m.last_modified_at + if v == nil { + return + } + return *v, true +} + +// OldLastModifiedAt returns the old "last_modified_at" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastModifiedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastModifiedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastModifiedAt: %w", err) + } + return oldValue.LastModifiedAt, nil +} + +// ResetLastModifiedAt resets all changes to the "last_modified_at" field. +func (m *HostMutation) ResetLastModifiedAt() { + m.last_modified_at = nil +} + // SetIdentifier sets the "identifier" field. func (m *HostMutation) SetIdentifier(s string) { m.identifier = &s @@ -2171,7 +2353,13 @@ func (m *HostMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *HostMutation) Fields() []string { - fields := make([]string, 0, 5) + fields := make([]string, 0, 7) + if m.created_at != nil { + fields = append(fields, host.FieldCreatedAt) + } + if m.last_modified_at != nil { + fields = append(fields, host.FieldLastModifiedAt) + } if m.identifier != nil { fields = append(fields, host.FieldIdentifier) } @@ -2195,6 +2383,10 @@ func (m *HostMutation) Fields() []string { // schema. func (m *HostMutation) Field(name string) (ent.Value, bool) { switch name { + case host.FieldCreatedAt: + return m.CreatedAt() + case host.FieldLastModifiedAt: + return m.LastModifiedAt() case host.FieldIdentifier: return m.Identifier() case host.FieldName: @@ -2214,6 +2406,10 @@ func (m *HostMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *HostMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case host.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case host.FieldLastModifiedAt: + return m.OldLastModifiedAt(ctx) case host.FieldIdentifier: return m.OldIdentifier(ctx) case host.FieldName: @@ -2233,6 +2429,20 @@ func (m *HostMutation) OldField(ctx context.Context, name string) (ent.Value, er // type. func (m *HostMutation) SetField(name string, value ent.Value) error { switch name { + case host.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case host.FieldLastModifiedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastModifiedAt(v) + return nil case host.FieldIdentifier: v, ok := value.(string) if !ok { @@ -2338,6 +2548,12 @@ func (m *HostMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *HostMutation) ResetField(name string) error { switch name { + case host.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case host.FieldLastModifiedAt: + m.ResetLastModifiedAt() + return nil case host.FieldIdentifier: m.ResetIdentifier() return nil diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index f80fa829c..c02c4c589 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -21,8 +21,21 @@ import ( // (default values, validators, hooks and policies) and stitches it // to their package variables. func init() { + beaconMixin := schema.Beacon{}.Mixin() + beaconMixinFields0 := beaconMixin[0].Fields() + _ = beaconMixinFields0 beaconFields := schema.Beacon{}.Fields() _ = beaconFields + // beaconDescCreatedAt is the schema descriptor for created_at field. + beaconDescCreatedAt := beaconMixinFields0[0].Descriptor() + // beacon.DefaultCreatedAt holds the default value on creation for the created_at field. + beacon.DefaultCreatedAt = beaconDescCreatedAt.Default.(func() time.Time) + // beaconDescLastModifiedAt is the schema descriptor for last_modified_at field. + beaconDescLastModifiedAt := beaconMixinFields0[1].Descriptor() + // beacon.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. + beacon.DefaultLastModifiedAt = beaconDescLastModifiedAt.Default.(func() time.Time) + // beacon.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. + beacon.UpdateDefaultLastModifiedAt = beaconDescLastModifiedAt.UpdateDefault.(func() time.Time) // beaconDescName is the schema descriptor for name field. beaconDescName := beaconFields[0].Descriptor() // beacon.DefaultName holds the default value on creation for the name field. @@ -74,8 +87,21 @@ func init() { fileDescHash := fileFields[2].Descriptor() // file.HashValidator is a validator for the "hash" field. It is called by the builders before save. file.HashValidator = fileDescHash.Validators[0].(func(string) error) + hostMixin := schema.Host{}.Mixin() + hostMixinFields0 := hostMixin[0].Fields() + _ = hostMixinFields0 hostFields := schema.Host{}.Fields() _ = hostFields + // hostDescCreatedAt is the schema descriptor for created_at field. + hostDescCreatedAt := hostMixinFields0[0].Descriptor() + // host.DefaultCreatedAt holds the default value on creation for the created_at field. + host.DefaultCreatedAt = hostDescCreatedAt.Default.(func() time.Time) + // hostDescLastModifiedAt is the schema descriptor for last_modified_at field. + hostDescLastModifiedAt := hostMixinFields0[1].Descriptor() + // host.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. + host.DefaultLastModifiedAt = hostDescLastModifiedAt.Default.(func() time.Time) + // host.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. + host.UpdateDefaultLastModifiedAt = hostDescLastModifiedAt.UpdateDefault.(func() time.Time) // hostDescIdentifier is the schema descriptor for identifier field. hostDescIdentifier := hostFields[0].Descriptor() // host.IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. diff --git a/tavern/internal/ent/schema/beacon.go b/tavern/internal/ent/schema/beacon.go index 6e1ca6af8..f58a98e6c 100644 --- a/tavern/internal/ent/schema/beacon.go +++ b/tavern/internal/ent/schema/beacon.go @@ -93,6 +93,13 @@ func (Beacon) Annotations() []schema.Annotation { } } +// Mixin defines common shared properties for the ent. +func (Beacon) Mixin() []ent.Mixin { + return []ent.Mixin{ + MixinHistory{}, // created_at, last_modified_at + } +} + func newRandomIdentifier() string { buf := make([]byte, 64) _, err := io.ReadFull(rand.Reader, buf) diff --git a/tavern/internal/ent/schema/host.go b/tavern/internal/ent/schema/host.go index 4fe495cdf..4b723e895 100644 --- a/tavern/internal/ent/schema/host.go +++ b/tavern/internal/ent/schema/host.go @@ -71,3 +71,10 @@ func (Host) Annotations() []schema.Annotation { ), } } + +// Mixin defines common shared properties for the ent. +func (Host) Mixin() []ent.Mixin { + return []ent.Mixin{ + MixinHistory{}, // created_at, last_modified_at + } +} diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index c3de66577..d6ac047ba 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -317,6 +317,94 @@ func (ec *executionContext) fieldContext_Beacon_id(ctx context.Context, field gr return fc, nil } +func (ec *executionContext) _Beacon_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_createdAt(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreatedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Beacon_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Beacon", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Beacon_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Beacon_lastModifiedAt(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.LastModifiedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Beacon_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Beacon", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Beacon_name(ctx context.Context, field graphql.CollectedField, obj *ent.Beacon) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Beacon_name(ctx, field) if err != nil { @@ -610,6 +698,10 @@ func (ec *executionContext) fieldContext_Beacon_host(ctx context.Context, field switch field.Name { case "id": return ec.fieldContext_Host_id(ctx, field) + case "createdAt": + return ec.fieldContext_Host_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Host_lastModifiedAt(ctx, field) case "identifier": return ec.fieldContext_Host_identifier(ctx, field) case "name": @@ -1075,6 +1167,94 @@ func (ec *executionContext) fieldContext_Host_id(ctx context.Context, field grap return fc, nil } +func (ec *executionContext) _Host_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Host_createdAt(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreatedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Host_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Host", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Host_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Host_lastModifiedAt(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.LastModifiedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Host_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Host", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Host_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Host_identifier(ctx, field) if err != nil { @@ -1375,6 +1555,10 @@ func (ec *executionContext) fieldContext_Host_beacons(ctx context.Context, field switch field.Name { case "id": return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) case "name": return ec.fieldContext_Beacon_name(ctx, field) case "principal": @@ -1932,6 +2116,10 @@ func (ec *executionContext) fieldContext_Process_host(ctx context.Context, field switch field.Name { case "id": return ec.fieldContext_Host_id(ctx, field) + case "createdAt": + return ec.fieldContext_Host_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Host_lastModifiedAt(ctx, field) case "identifier": return ec.fieldContext_Host_identifier(ctx, field) case "name": @@ -2478,6 +2666,10 @@ func (ec *executionContext) fieldContext_Query_beacons(ctx context.Context, fiel switch field.Name { case "id": return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) case "name": return ec.fieldContext_Beacon_name(ctx, field) case "principal": @@ -2577,6 +2769,10 @@ func (ec *executionContext) fieldContext_Query_hosts(ctx context.Context, field switch field.Name { case "id": return ec.fieldContext_Host_id(ctx, field) + case "createdAt": + return ec.fieldContext_Host_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Host_lastModifiedAt(ctx, field) case "identifier": return ec.fieldContext_Host_identifier(ctx, field) case "name": @@ -3721,6 +3917,10 @@ func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field gr switch field.Name { case "id": return ec.fieldContext_Host_id(ctx, field) + case "createdAt": + return ec.fieldContext_Host_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Host_lastModifiedAt(ctx, field) case "identifier": return ec.fieldContext_Host_identifier(ctx, field) case "name": @@ -4230,6 +4430,10 @@ func (ec *executionContext) fieldContext_Task_beacon(ctx context.Context, field switch field.Name { case "id": return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) case "name": return ec.fieldContext_Beacon_name(ctx, field) case "principal": @@ -5457,7 +5661,7 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -5563,6 +5767,150 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, return it, err } it.IDLTE = data + case "createdAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNotIn = data + case "createdAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGT = data + case "createdAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGTE = data + case "createdAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLT = data + case "createdAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLTE = data + case "lastModifiedAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAt = data + case "lastModifiedAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLTE = data case "name": var err error @@ -7153,7 +7501,7 @@ func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, ob asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameIsNil", "nameNotNil", "nameEqualFold", "nameContainsFold", "primaryIP", "primaryIPNEQ", "primaryIPIn", "primaryIPNotIn", "primaryIPGT", "primaryIPGTE", "primaryIPLT", "primaryIPLTE", "primaryIPContains", "primaryIPHasPrefix", "primaryIPHasSuffix", "primaryIPIsNil", "primaryIPNotNil", "primaryIPEqualFold", "primaryIPContainsFold", "platform", "platformNEQ", "platformIn", "platformNotIn", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "hasTags", "hasTagsWith", "hasBeacons", "hasBeaconsWith", "hasProcesses", "hasProcessesWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameIsNil", "nameNotNil", "nameEqualFold", "nameContainsFold", "primaryIP", "primaryIPNEQ", "primaryIPIn", "primaryIPNotIn", "primaryIPGT", "primaryIPGTE", "primaryIPLT", "primaryIPLTE", "primaryIPContains", "primaryIPHasPrefix", "primaryIPHasSuffix", "primaryIPIsNil", "primaryIPNotNil", "primaryIPEqualFold", "primaryIPContainsFold", "platform", "platformNEQ", "platformIn", "platformNotIn", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "hasTags", "hasTagsWith", "hasBeacons", "hasBeaconsWith", "hasProcesses", "hasProcessesWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -7259,6 +7607,150 @@ func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, ob return it, err } it.IDLTE = data + case "createdAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNotIn = data + case "createdAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGT = data + case "createdAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGTE = data + case "createdAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLT = data + case "createdAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLTE = data + case "lastModifiedAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAt = data + case "lastModifiedAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLTE = data case "identifier": var err error @@ -11450,13 +11942,22 @@ func (ec *executionContext) unmarshalInputUpdateBeaconInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"hostID"} + fieldsInOrder := [...]string{"lastModifiedAt", "hostID"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "lastModifiedAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAt = data case "hostID": var err error @@ -11479,13 +11980,22 @@ func (ec *executionContext) unmarshalInputUpdateHostInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"name", "clearName", "addTagIDs", "removeTagIDs", "clearTags", "addBeaconIDs", "removeBeaconIDs", "clearBeacons", "addProcessIDs", "removeProcessIDs", "clearProcesses"} + fieldsInOrder := [...]string{"lastModifiedAt", "name", "clearName", "addTagIDs", "removeTagIDs", "clearTags", "addBeaconIDs", "removeBeaconIDs", "clearBeacons", "addProcessIDs", "removeProcessIDs", "clearProcesses"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "lastModifiedAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAt = data case "name": var err error @@ -12352,6 +12862,16 @@ func (ec *executionContext) _Beacon(ctx context.Context, sel ast.SelectionSet, o if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "createdAt": + out.Values[i] = ec._Beacon_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "lastModifiedAt": + out.Values[i] = ec._Beacon_lastModifiedAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "name": out.Values[i] = ec._Beacon_name(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -12575,6 +13095,16 @@ func (ec *executionContext) _Host(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "createdAt": + out.Values[i] = ec._Host_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "lastModifiedAt": + out.Values[i] = ec._Host_lastModifiedAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "identifier": out.Values[i] = ec._Host_identifier(ctx, field, obj) if out.Values[i] == graphql.Null { diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index 9954db535..34135493b 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -390,6 +390,10 @@ func (ec *executionContext) fieldContext_Mutation_updateBeacon(ctx context.Conte switch field.Name { case "id": return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) case "name": return ec.fieldContext_Beacon_name(ctx, field) case "principal": @@ -489,6 +493,10 @@ func (ec *executionContext) fieldContext_Mutation_updateHost(ctx context.Context switch field.Name { case "id": return ec.fieldContext_Host_id(ctx, field) + case "createdAt": + return ec.fieldContext_Host_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Host_lastModifiedAt(ctx, field) case "identifier": return ec.fieldContext_Host_identifier(ctx, field) case "name": diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 2c6cdea11..a395b78fa 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -48,10 +48,12 @@ type DirectiveRoot struct { type ComplexityRoot struct { Beacon struct { AgentIdentifier func(childComplexity int) int + CreatedAt func(childComplexity int) int Host func(childComplexity int) int ID func(childComplexity int) int Identifier func(childComplexity int) int Interval func(childComplexity int) int + LastModifiedAt func(childComplexity int) int LastSeenAt func(childComplexity int) int Name func(childComplexity int) int Principal func(childComplexity int) int @@ -69,15 +71,17 @@ type ComplexityRoot struct { } Host struct { - Beacons func(childComplexity int) int - ID func(childComplexity int) int - Identifier func(childComplexity int) int - LastSeenAt func(childComplexity int) int - Name func(childComplexity int) int - Platform func(childComplexity int) int - PrimaryIP func(childComplexity int) int - Processes func(childComplexity int) int - Tags func(childComplexity int) int + Beacons func(childComplexity int) int + CreatedAt func(childComplexity int) int + ID func(childComplexity int) int + Identifier func(childComplexity int) int + LastModifiedAt func(childComplexity int) int + LastSeenAt func(childComplexity int) int + Name func(childComplexity int) int + Platform func(childComplexity int) int + PrimaryIP func(childComplexity int) int + Processes func(childComplexity int) int + Tags func(childComplexity int) int } Mutation struct { @@ -220,6 +224,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Beacon.AgentIdentifier(childComplexity), true + case "Beacon.createdAt": + if e.complexity.Beacon.CreatedAt == nil { + break + } + + return e.complexity.Beacon.CreatedAt(childComplexity), true + case "Beacon.host": if e.complexity.Beacon.Host == nil { break @@ -248,6 +259,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Beacon.Interval(childComplexity), true + case "Beacon.lastModifiedAt": + if e.complexity.Beacon.LastModifiedAt == nil { + break + } + + return e.complexity.Beacon.LastModifiedAt(childComplexity), true + case "Beacon.lastSeenAt": if e.complexity.Beacon.LastSeenAt == nil { break @@ -332,6 +350,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Host.Beacons(childComplexity), true + case "Host.createdAt": + if e.complexity.Host.CreatedAt == nil { + break + } + + return e.complexity.Host.CreatedAt(childComplexity), true + case "Host.id": if e.complexity.Host.ID == nil { break @@ -346,6 +371,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Host.Identifier(childComplexity), true + case "Host.lastModifiedAt": + if e.complexity.Host.LastModifiedAt == nil { + break + } + + return e.complexity.Host.LastModifiedAt(childComplexity), true + case "Host.lastSeenAt": if e.complexity.Host.LastSeenAt == nil { break @@ -1185,6 +1217,10 @@ enum Role { directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION type Beacon implements Node { id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! """A human readable identifier for the beacon.""" name: String! """The identity the beacon is authenticated as (e.g. 'root')""" @@ -1211,6 +1247,8 @@ input BeaconOrder { } """Properties by which Beacon connections can be ordered.""" enum BeaconOrderField { + CREATED_AT + LAST_MODIFIED_AT LAST_SEEN_AT INTERVAL } @@ -1231,6 +1269,24 @@ input BeaconWhereInput { idGTE: ID idLT: ID idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time """name field predicates""" name: String nameNEQ: String @@ -1474,6 +1530,10 @@ input FileWhereInput { } type Host implements Node { id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! """Unique identifier for the host. Unique to each host.""" identifier: String! """A human readable identifier for the host.""" @@ -1500,6 +1560,8 @@ input HostOrder { } """Properties by which Host connections can be ordered.""" enum HostOrderField { + CREATED_AT + LAST_MODIFIED_AT LAST_SEEN_AT } """HostPlatform is enum for the field platform""" @@ -1527,6 +1589,24 @@ input HostWhereInput { idGTE: ID idLT: ID idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time """identifier field predicates""" identifier: String identifierNEQ: String @@ -2289,6 +2369,8 @@ UpdateBeaconInput is used for update Beacon object. Input was generated by ent. """ input UpdateBeaconInput { + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time hostID: ID } """ @@ -2296,6 +2378,8 @@ UpdateHostInput is used for update Host object. Input was generated by ent. """ input UpdateHostInput { + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time """A human readable identifier for the host.""" name: String clearName: Boolean diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index 4e3de17cf..c37c4412e 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -7,6 +7,10 @@ enum Role { directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION type Beacon implements Node { id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! """A human readable identifier for the beacon.""" name: String! """The identity the beacon is authenticated as (e.g. 'root')""" @@ -33,6 +37,8 @@ input BeaconOrder { } """Properties by which Beacon connections can be ordered.""" enum BeaconOrderField { + CREATED_AT + LAST_MODIFIED_AT LAST_SEEN_AT INTERVAL } @@ -53,6 +59,24 @@ input BeaconWhereInput { idGTE: ID idLT: ID idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time """name field predicates""" name: String nameNEQ: String @@ -296,6 +320,10 @@ input FileWhereInput { } type Host implements Node { id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! """Unique identifier for the host. Unique to each host.""" identifier: String! """A human readable identifier for the host.""" @@ -322,6 +350,8 @@ input HostOrder { } """Properties by which Host connections can be ordered.""" enum HostOrderField { + CREATED_AT + LAST_MODIFIED_AT LAST_SEEN_AT } """HostPlatform is enum for the field platform""" @@ -349,6 +379,24 @@ input HostWhereInput { idGTE: ID idLT: ID idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time """identifier field predicates""" identifier: String identifierNEQ: String @@ -1111,6 +1159,8 @@ UpdateBeaconInput is used for update Beacon object. Input was generated by ent. """ input UpdateBeaconInput { + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time hostID: ID } """ @@ -1118,6 +1168,8 @@ UpdateHostInput is used for update Host object. Input was generated by ent. """ input UpdateHostInput { + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time """A human readable identifier for the host.""" name: String clearName: Boolean diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index 8418090cd..3eca04e09 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -2,6 +2,10 @@ directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | I directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION type Beacon implements Node { id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! """A human readable identifier for the beacon.""" name: String! """The identity the beacon is authenticated as (e.g. 'root')""" @@ -28,6 +32,8 @@ input BeaconOrder { } """Properties by which Beacon connections can be ordered.""" enum BeaconOrderField { + CREATED_AT + LAST_MODIFIED_AT LAST_SEEN_AT INTERVAL } @@ -48,6 +54,24 @@ input BeaconWhereInput { idGTE: ID idLT: ID idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time """name field predicates""" name: String nameNEQ: String @@ -291,6 +315,10 @@ input FileWhereInput { } type Host implements Node { id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! """Unique identifier for the host. Unique to each host.""" identifier: String! """A human readable identifier for the host.""" @@ -317,6 +345,8 @@ input HostOrder { } """Properties by which Host connections can be ordered.""" enum HostOrderField { + CREATED_AT + LAST_MODIFIED_AT LAST_SEEN_AT } """HostPlatform is enum for the field platform""" @@ -344,6 +374,24 @@ input HostWhereInput { idGTE: ID idLT: ID idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time """identifier field predicates""" identifier: String identifierNEQ: String @@ -1106,6 +1154,8 @@ UpdateBeaconInput is used for update Beacon object. Input was generated by ent. """ input UpdateBeaconInput { + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time hostID: ID } """ @@ -1113,6 +1163,8 @@ UpdateHostInput is used for update Host object. Input was generated by ent. """ input UpdateHostInput { + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time """A human readable identifier for the host.""" name: String clearName: Boolean diff --git a/tavern/internal/graphql/testdata/mutations/createQuest/NoFiles.yml b/tavern/internal/graphql/testdata/mutations/createQuest/NoFiles.yml index 260e3801e..efa3b2fec 100644 --- a/tavern/internal/graphql/testdata/mutations/createQuest/NoFiles.yml +++ b/tavern/internal/graphql/testdata/mutations/createQuest/NoFiles.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); requestor: diff --git a/tavern/internal/graphql/testdata/mutations/createQuest/WithFiles.yml b/tavern/internal/graphql/testdata/mutations/createQuest/WithFiles.yml index 7bfe516ff..080af2ced 100644 --- a/tavern/internal/graphql/testdata/mutations/createQuest/WithFiles.yml +++ b/tavern/internal/graphql/testdata/mutations/createQuest/WithFiles.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/createTag/Group.yml b/tavern/internal/graphql/testdata/mutations/createTag/Group.yml index ec93f792e..aeeee4e26 100644 --- a/tavern/internal/graphql/testdata/mutations/createTag/Group.yml +++ b/tavern/internal/graphql/testdata/mutations/createTag/Group.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456", 1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST","2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456", 1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: session_token: secretToken query: | diff --git a/tavern/internal/graphql/testdata/mutations/createTag/MultipleHosts.yml b/tavern/internal/graphql/testdata/mutations/createTag/MultipleHosts.yml index 79c51f04d..952ca3712 100644 --- a/tavern/internal/graphql/testdata/mutations/createTag/MultipleHosts.yml +++ b/tavern/internal/graphql/testdata/mutations/createTag/MultipleHosts.yml @@ -1,16 +1,16 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1011,"db2","EXISTING-HOST2"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (420,"lovely-emu","ZYXWVUT-987654",1010); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (421,"ballin-emu","ZYXWVUT-1234",1011); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1011,"db2","EXISTING-HOST2", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (420,"lovely-emu","ZYXWVUT-987654",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (421,"ballin-emu","ZYXWVUT-1234",1011, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: session_token: secretToken query: | diff --git a/tavern/internal/graphql/testdata/mutations/createTag/Service.yml b/tavern/internal/graphql/testdata/mutations/createTag/Service.yml index cc44068e7..f6d77350e 100644 --- a/tavern/internal/graphql/testdata/mutations/createTag/Service.yml +++ b/tavern/internal/graphql/testdata/mutations/createTag/Service.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: session_token: secretToken query: | diff --git a/tavern/internal/graphql/testdata/mutations/createTome/WithFiles.yml b/tavern/internal/graphql/testdata/mutations/createTome/WithFiles.yml index 9f6cc5978..ce2ed87d0 100644 --- a/tavern/internal/graphql/testdata/mutations/createTome/WithFiles.yml +++ b/tavern/internal/graphql/testdata/mutations/createTome/WithFiles.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at) VALUES (3000,"TestFile1", "hello world", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/deleteTome/PermissionDenied.yml b/tavern/internal/graphql/testdata/mutations/deleteTome/PermissionDenied.yml index 11a7a91d6..7578bf192 100644 --- a/tavern/internal/graphql/testdata/mutations/deleteTome/PermissionDenied.yml +++ b/tavern/internal/graphql/testdata/mutations/deleteTome/PermissionDenied.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,false); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/deleteTome/Singular.yml b/tavern/internal/graphql/testdata/mutations/deleteTome/Singular.yml index 4550bbee4..d1d29a14b 100644 --- a/tavern/internal/graphql/testdata/mutations/deleteTome/Singular.yml +++ b/tavern/internal/graphql/testdata/mutations/deleteTome/Singular.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/updateBeacon/ChangeNameError.yml b/tavern/internal/graphql/testdata/mutations/updateBeacon/ChangeNameError.yml index 5d1a65fe2..e36331253 100644 --- a/tavern/internal/graphql/testdata/mutations/updateBeacon/ChangeNameError.yml +++ b/tavern/internal/graphql/testdata/mutations/updateBeacon/ChangeNameError.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: session_token: secretToken query: | diff --git a/tavern/internal/graphql/testdata/mutations/updateHost/AddTag.yml b/tavern/internal/graphql/testdata/mutations/updateHost/AddTag.yml index d09181e1c..7b15dc243 100644 --- a/tavern/internal/graphql/testdata/mutations/updateHost/AddTag.yml +++ b/tavern/internal/graphql/testdata/mutations/updateHost/AddTag.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456", 1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456", 1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tags` (id, name, kind) VALUES (4000,"very-neat-tag","group"); requestor: diff --git a/tavern/internal/graphql/testdata/mutations/updateHost/ChangeHostname.yml b/tavern/internal/graphql/testdata/mutations/updateHost/ChangeHostname.yml index 5b8d5f8af..dc03bd9c3 100644 --- a/tavern/internal/graphql/testdata/mutations/updateHost/ChangeHostname.yml +++ b/tavern/internal/graphql/testdata/mutations/updateHost/ChangeHostname.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: session_token: secretToken query: | diff --git a/tavern/internal/graphql/testdata/mutations/updateHost/RemoveTag.yml b/tavern/internal/graphql/testdata/mutations/updateHost/RemoveTag.yml index d1fa2c3f3..bd19f106e 100644 --- a/tavern/internal/graphql/testdata/mutations/updateHost/RemoveTag.yml +++ b/tavern/internal/graphql/testdata/mutations/updateHost/RemoveTag.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tags` (id, name, kind) VALUES (4000,"very-neat-tag","group"); INSERT INTO `host_tags` (host_id, tag_id) diff --git a/tavern/internal/graphql/testdata/mutations/updateTag/ChangeName.yml b/tavern/internal/graphql/testdata/mutations/updateTag/ChangeName.yml index fa645b95a..5baab6404 100644 --- a/tavern/internal/graphql/testdata/mutations/updateTag/ChangeName.yml +++ b/tavern/internal/graphql/testdata/mutations/updateTag/ChangeName.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tags` (id, name, kind) VALUES (4000,"boring-tag","group"); requestor: diff --git a/tavern/internal/graphql/testdata/mutations/updateTome/PermissionDenied.yml b/tavern/internal/graphql/testdata/mutations/updateTome/PermissionDenied.yml index 615dc2b80..bad0289b9 100644 --- a/tavern/internal/graphql/testdata/mutations/updateTome/PermissionDenied.yml +++ b/tavern/internal/graphql/testdata/mutations/updateTome/PermissionDenied.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,false); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/updateTome/Singular.yml b/tavern/internal/graphql/testdata/mutations/updateTome/Singular.yml index 4d609f9a6..91731d025 100644 --- a/tavern/internal/graphql/testdata/mutations/updateTome/Singular.yml +++ b/tavern/internal/graphql/testdata/mutations/updateTome/Singular.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/beacons/FilterByID.yml b/tavern/internal/graphql/testdata/queries/beacons/FilterByID.yml index e2206fdc0..79baffb2a 100644 --- a/tavern/internal/graphql/testdata/queries/beacons/FilterByID.yml +++ b/tavern/internal/graphql/testdata/queries/beacons/FilterByID.yml @@ -1,12 +1,12 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1338,"filtered-lich","123456-ZYX",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1338,"filtered-lich","123456-ZYX",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: session_token: secretToken query: | diff --git a/tavern/internal/graphql/testdata/queries/beacons/Singular.yml b/tavern/internal/graphql/testdata/queries/beacons/Singular.yml index eabcd158d..1d40ff666 100644 --- a/tavern/internal/graphql/testdata/queries/beacons/Singular.yml +++ b/tavern/internal/graphql/testdata/queries/beacons/Singular.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host, interval) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, 120); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, interval, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, 120, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: session_token: secretToken query: | diff --git a/tavern/internal/graphql/testdata/queries/hosts/Multiple.yml b/tavern/internal/graphql/testdata/queries/hosts/Multiple.yml index 2e0f1c921..be70186b8 100644 --- a/tavern/internal/graphql/testdata/queries/hosts/Multiple.yml +++ b/tavern/internal/graphql/testdata/queries/hosts/Multiple.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1011,"db2","EXISTING-HOST2"); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1011,"db2","EXISTING-HOST2", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: session_token: secretToken query: | diff --git a/tavern/internal/graphql/testdata/queries/hosts/Singular.yml b/tavern/internal/graphql/testdata/queries/hosts/Singular.yml index fb1a91ae6..75325fe53 100644 --- a/tavern/internal/graphql/testdata/queries/hosts/Singular.yml +++ b/tavern/internal/graphql/testdata/queries/hosts/Singular.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: session_token: secretToken query: | diff --git a/tavern/internal/graphql/testdata/queries/quests/FilterByID.yml b/tavern/internal/graphql/testdata/queries/quests/FilterByID.yml index 611c5c731..7c289d3a4 100644 --- a/tavern/internal/graphql/testdata/queries/quests/FilterByID.yml +++ b/tavern/internal/graphql/testdata/queries/quests/FilterByID.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/quests/Singular.yml b/tavern/internal/graphql/testdata/queries/quests/Singular.yml index 99e68c492..7ce88ef2e 100644 --- a/tavern/internal/graphql/testdata/queries/quests/Singular.yml +++ b/tavern/internal/graphql/testdata/queries/quests/Singular.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/BackwardPaginate.yml b/tavern/internal/graphql/testdata/queries/tasks/BackwardPaginate.yml index 19df4c8ca..471758300 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/BackwardPaginate.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/BackwardPaginate.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/FilterByID.yml b/tavern/internal/graphql/testdata/queries/tasks/FilterByID.yml index e463ebf19..5c20f75c6 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/FilterByID.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/FilterByID.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/ForwardPaginate.yml b/tavern/internal/graphql/testdata/queries/tasks/ForwardPaginate.yml index b42d6c2a2..e99709b77 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/ForwardPaginate.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/ForwardPaginate.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/Multiple.yml b/tavern/internal/graphql/testdata/queries/tasks/Multiple.yml index 83bef3ec1..3e657341b 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/Multiple.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/Multiple.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/OrderByPaginate.yml b/tavern/internal/graphql/testdata/queries/tasks/OrderByPaginate.yml index b264a6680..4af7f9829 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/OrderByPaginate.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/OrderByPaginate.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/Singular.yml b/tavern/internal/graphql/testdata/queries/tasks/Singular.yml index 503776c46..5f3de51d8 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/Singular.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/Singular.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier) - VALUES (1010,"db1","EXISTING-HOST"); - INSERT INTO `beacons` (id, name, identifier, beacon_host) - VALUES (1337,"delightful-lich","ABCDEFG-123456",1010); + INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) + VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `quests` (id, quest_tome, name, created_at, last_modified_at) diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index 4e3de17cf..c37c4412e 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -7,6 +7,10 @@ enum Role { directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION type Beacon implements Node { id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! """A human readable identifier for the beacon.""" name: String! """The identity the beacon is authenticated as (e.g. 'root')""" @@ -33,6 +37,8 @@ input BeaconOrder { } """Properties by which Beacon connections can be ordered.""" enum BeaconOrderField { + CREATED_AT + LAST_MODIFIED_AT LAST_SEEN_AT INTERVAL } @@ -53,6 +59,24 @@ input BeaconWhereInput { idGTE: ID idLT: ID idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time """name field predicates""" name: String nameNEQ: String @@ -296,6 +320,10 @@ input FileWhereInput { } type Host implements Node { id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! """Unique identifier for the host. Unique to each host.""" identifier: String! """A human readable identifier for the host.""" @@ -322,6 +350,8 @@ input HostOrder { } """Properties by which Host connections can be ordered.""" enum HostOrderField { + CREATED_AT + LAST_MODIFIED_AT LAST_SEEN_AT } """HostPlatform is enum for the field platform""" @@ -349,6 +379,24 @@ input HostWhereInput { idGTE: ID idLT: ID idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time """identifier field predicates""" identifier: String identifierNEQ: String @@ -1111,6 +1159,8 @@ UpdateBeaconInput is used for update Beacon object. Input was generated by ent. """ input UpdateBeaconInput { + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time hostID: ID } """ @@ -1118,6 +1168,8 @@ UpdateHostInput is used for update Host object. Input was generated by ent. """ input UpdateHostInput { + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time """A human readable identifier for the host.""" name: String clearName: Boolean