crowdsec/pkg/database/ent/alert_update.go

2009 lines
58 KiB
Go
Raw Permalink Normal View History

// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/event"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
)
// AlertUpdate is the builder for updating Alert entities.
type AlertUpdate struct {
config
2021-01-14 15:27:45 +00:00
hooks []Hook
mutation *AlertMutation
}
// Where appends a list predicates to the AlertUpdate builder.
func (au *AlertUpdate) Where(ps ...predicate.Alert) *AlertUpdate {
au.mutation.Where(ps...)
return au
}
2021-01-14 15:27:45 +00:00
// SetCreatedAt sets the "created_at" field.
func (au *AlertUpdate) SetCreatedAt(t time.Time) *AlertUpdate {
au.mutation.SetCreatedAt(t)
return au
}
// ClearCreatedAt clears the value of the "created_at" field.
func (au *AlertUpdate) ClearCreatedAt() *AlertUpdate {
au.mutation.ClearCreatedAt()
return au
}
2021-01-14 15:27:45 +00:00
// SetUpdatedAt sets the "updated_at" field.
func (au *AlertUpdate) SetUpdatedAt(t time.Time) *AlertUpdate {
au.mutation.SetUpdatedAt(t)
return au
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (au *AlertUpdate) ClearUpdatedAt() *AlertUpdate {
au.mutation.ClearUpdatedAt()
return au
}
2021-01-14 15:27:45 +00:00
// SetScenario sets the "scenario" field.
func (au *AlertUpdate) SetScenario(s string) *AlertUpdate {
au.mutation.SetScenario(s)
return au
}
// SetNillableScenario sets the "scenario" field if the given value is not nil.
func (au *AlertUpdate) SetNillableScenario(s *string) *AlertUpdate {
if s != nil {
au.SetScenario(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// SetBucketId sets the "bucketId" field.
func (au *AlertUpdate) SetBucketId(s string) *AlertUpdate {
au.mutation.SetBucketId(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableBucketId sets the "bucketId" field if the given value is not nil.
func (au *AlertUpdate) SetNillableBucketId(s *string) *AlertUpdate {
if s != nil {
au.SetBucketId(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearBucketId clears the value of the "bucketId" field.
func (au *AlertUpdate) ClearBucketId() *AlertUpdate {
au.mutation.ClearBucketId()
return au
}
2021-01-14 15:27:45 +00:00
// SetMessage sets the "message" field.
func (au *AlertUpdate) SetMessage(s string) *AlertUpdate {
au.mutation.SetMessage(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableMessage sets the "message" field if the given value is not nil.
func (au *AlertUpdate) SetNillableMessage(s *string) *AlertUpdate {
if s != nil {
au.SetMessage(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearMessage clears the value of the "message" field.
func (au *AlertUpdate) ClearMessage() *AlertUpdate {
au.mutation.ClearMessage()
return au
}
2021-01-14 15:27:45 +00:00
// SetEventsCount sets the "eventsCount" field.
func (au *AlertUpdate) SetEventsCount(i int32) *AlertUpdate {
au.mutation.ResetEventsCount()
au.mutation.SetEventsCount(i)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableEventsCount sets the "eventsCount" field if the given value is not nil.
func (au *AlertUpdate) SetNillableEventsCount(i *int32) *AlertUpdate {
if i != nil {
au.SetEventsCount(*i)
}
return au
}
2021-01-14 15:27:45 +00:00
// AddEventsCount adds i to the "eventsCount" field.
func (au *AlertUpdate) AddEventsCount(i int32) *AlertUpdate {
au.mutation.AddEventsCount(i)
return au
}
2021-01-14 15:27:45 +00:00
// ClearEventsCount clears the value of the "eventsCount" field.
func (au *AlertUpdate) ClearEventsCount() *AlertUpdate {
au.mutation.ClearEventsCount()
return au
}
2021-01-14 15:27:45 +00:00
// SetStartedAt sets the "startedAt" field.
func (au *AlertUpdate) SetStartedAt(t time.Time) *AlertUpdate {
au.mutation.SetStartedAt(t)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableStartedAt sets the "startedAt" field if the given value is not nil.
func (au *AlertUpdate) SetNillableStartedAt(t *time.Time) *AlertUpdate {
if t != nil {
au.SetStartedAt(*t)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearStartedAt clears the value of the "startedAt" field.
func (au *AlertUpdate) ClearStartedAt() *AlertUpdate {
au.mutation.ClearStartedAt()
return au
}
2021-01-14 15:27:45 +00:00
// SetStoppedAt sets the "stoppedAt" field.
func (au *AlertUpdate) SetStoppedAt(t time.Time) *AlertUpdate {
au.mutation.SetStoppedAt(t)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableStoppedAt sets the "stoppedAt" field if the given value is not nil.
func (au *AlertUpdate) SetNillableStoppedAt(t *time.Time) *AlertUpdate {
if t != nil {
au.SetStoppedAt(*t)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearStoppedAt clears the value of the "stoppedAt" field.
func (au *AlertUpdate) ClearStoppedAt() *AlertUpdate {
au.mutation.ClearStoppedAt()
return au
}
2021-01-14 15:27:45 +00:00
// SetSourceIp sets the "sourceIp" field.
func (au *AlertUpdate) SetSourceIp(s string) *AlertUpdate {
au.mutation.SetSourceIp(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceIp sets the "sourceIp" field if the given value is not nil.
func (au *AlertUpdate) SetNillableSourceIp(s *string) *AlertUpdate {
if s != nil {
au.SetSourceIp(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearSourceIp clears the value of the "sourceIp" field.
func (au *AlertUpdate) ClearSourceIp() *AlertUpdate {
au.mutation.ClearSourceIp()
return au
}
2021-01-14 15:27:45 +00:00
// SetSourceRange sets the "sourceRange" field.
func (au *AlertUpdate) SetSourceRange(s string) *AlertUpdate {
au.mutation.SetSourceRange(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceRange sets the "sourceRange" field if the given value is not nil.
func (au *AlertUpdate) SetNillableSourceRange(s *string) *AlertUpdate {
if s != nil {
au.SetSourceRange(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearSourceRange clears the value of the "sourceRange" field.
func (au *AlertUpdate) ClearSourceRange() *AlertUpdate {
au.mutation.ClearSourceRange()
return au
}
2021-01-14 15:27:45 +00:00
// SetSourceAsNumber sets the "sourceAsNumber" field.
func (au *AlertUpdate) SetSourceAsNumber(s string) *AlertUpdate {
au.mutation.SetSourceAsNumber(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceAsNumber sets the "sourceAsNumber" field if the given value is not nil.
func (au *AlertUpdate) SetNillableSourceAsNumber(s *string) *AlertUpdate {
if s != nil {
au.SetSourceAsNumber(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearSourceAsNumber clears the value of the "sourceAsNumber" field.
func (au *AlertUpdate) ClearSourceAsNumber() *AlertUpdate {
au.mutation.ClearSourceAsNumber()
return au
}
2021-01-14 15:27:45 +00:00
// SetSourceAsName sets the "sourceAsName" field.
func (au *AlertUpdate) SetSourceAsName(s string) *AlertUpdate {
au.mutation.SetSourceAsName(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceAsName sets the "sourceAsName" field if the given value is not nil.
func (au *AlertUpdate) SetNillableSourceAsName(s *string) *AlertUpdate {
if s != nil {
au.SetSourceAsName(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearSourceAsName clears the value of the "sourceAsName" field.
func (au *AlertUpdate) ClearSourceAsName() *AlertUpdate {
au.mutation.ClearSourceAsName()
return au
}
2021-01-14 15:27:45 +00:00
// SetSourceCountry sets the "sourceCountry" field.
func (au *AlertUpdate) SetSourceCountry(s string) *AlertUpdate {
au.mutation.SetSourceCountry(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceCountry sets the "sourceCountry" field if the given value is not nil.
func (au *AlertUpdate) SetNillableSourceCountry(s *string) *AlertUpdate {
if s != nil {
au.SetSourceCountry(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearSourceCountry clears the value of the "sourceCountry" field.
func (au *AlertUpdate) ClearSourceCountry() *AlertUpdate {
au.mutation.ClearSourceCountry()
return au
}
2021-01-14 15:27:45 +00:00
// SetSourceLatitude sets the "sourceLatitude" field.
func (au *AlertUpdate) SetSourceLatitude(f float32) *AlertUpdate {
au.mutation.ResetSourceLatitude()
au.mutation.SetSourceLatitude(f)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceLatitude sets the "sourceLatitude" field if the given value is not nil.
func (au *AlertUpdate) SetNillableSourceLatitude(f *float32) *AlertUpdate {
if f != nil {
au.SetSourceLatitude(*f)
}
return au
}
2021-01-14 15:27:45 +00:00
// AddSourceLatitude adds f to the "sourceLatitude" field.
func (au *AlertUpdate) AddSourceLatitude(f float32) *AlertUpdate {
au.mutation.AddSourceLatitude(f)
return au
}
2021-01-14 15:27:45 +00:00
// ClearSourceLatitude clears the value of the "sourceLatitude" field.
func (au *AlertUpdate) ClearSourceLatitude() *AlertUpdate {
au.mutation.ClearSourceLatitude()
return au
}
2021-01-14 15:27:45 +00:00
// SetSourceLongitude sets the "sourceLongitude" field.
func (au *AlertUpdate) SetSourceLongitude(f float32) *AlertUpdate {
au.mutation.ResetSourceLongitude()
au.mutation.SetSourceLongitude(f)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceLongitude sets the "sourceLongitude" field if the given value is not nil.
func (au *AlertUpdate) SetNillableSourceLongitude(f *float32) *AlertUpdate {
if f != nil {
au.SetSourceLongitude(*f)
}
return au
}
2021-01-14 15:27:45 +00:00
// AddSourceLongitude adds f to the "sourceLongitude" field.
func (au *AlertUpdate) AddSourceLongitude(f float32) *AlertUpdate {
au.mutation.AddSourceLongitude(f)
return au
}
2021-01-14 15:27:45 +00:00
// ClearSourceLongitude clears the value of the "sourceLongitude" field.
func (au *AlertUpdate) ClearSourceLongitude() *AlertUpdate {
au.mutation.ClearSourceLongitude()
return au
}
2021-01-14 15:27:45 +00:00
// SetSourceScope sets the "sourceScope" field.
func (au *AlertUpdate) SetSourceScope(s string) *AlertUpdate {
au.mutation.SetSourceScope(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceScope sets the "sourceScope" field if the given value is not nil.
func (au *AlertUpdate) SetNillableSourceScope(s *string) *AlertUpdate {
if s != nil {
au.SetSourceScope(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearSourceScope clears the value of the "sourceScope" field.
func (au *AlertUpdate) ClearSourceScope() *AlertUpdate {
au.mutation.ClearSourceScope()
return au
}
2021-01-14 15:27:45 +00:00
// SetSourceValue sets the "sourceValue" field.
func (au *AlertUpdate) SetSourceValue(s string) *AlertUpdate {
au.mutation.SetSourceValue(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceValue sets the "sourceValue" field if the given value is not nil.
func (au *AlertUpdate) SetNillableSourceValue(s *string) *AlertUpdate {
if s != nil {
au.SetSourceValue(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearSourceValue clears the value of the "sourceValue" field.
func (au *AlertUpdate) ClearSourceValue() *AlertUpdate {
au.mutation.ClearSourceValue()
return au
}
2021-01-14 15:27:45 +00:00
// SetCapacity sets the "capacity" field.
func (au *AlertUpdate) SetCapacity(i int32) *AlertUpdate {
au.mutation.ResetCapacity()
au.mutation.SetCapacity(i)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableCapacity sets the "capacity" field if the given value is not nil.
func (au *AlertUpdate) SetNillableCapacity(i *int32) *AlertUpdate {
if i != nil {
au.SetCapacity(*i)
}
return au
}
2021-01-14 15:27:45 +00:00
// AddCapacity adds i to the "capacity" field.
func (au *AlertUpdate) AddCapacity(i int32) *AlertUpdate {
au.mutation.AddCapacity(i)
return au
}
2021-01-14 15:27:45 +00:00
// ClearCapacity clears the value of the "capacity" field.
func (au *AlertUpdate) ClearCapacity() *AlertUpdate {
au.mutation.ClearCapacity()
return au
}
2021-01-14 15:27:45 +00:00
// SetLeakSpeed sets the "leakSpeed" field.
func (au *AlertUpdate) SetLeakSpeed(s string) *AlertUpdate {
au.mutation.SetLeakSpeed(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableLeakSpeed sets the "leakSpeed" field if the given value is not nil.
func (au *AlertUpdate) SetNillableLeakSpeed(s *string) *AlertUpdate {
if s != nil {
au.SetLeakSpeed(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearLeakSpeed clears the value of the "leakSpeed" field.
func (au *AlertUpdate) ClearLeakSpeed() *AlertUpdate {
au.mutation.ClearLeakSpeed()
return au
}
2021-01-14 15:27:45 +00:00
// SetScenarioVersion sets the "scenarioVersion" field.
func (au *AlertUpdate) SetScenarioVersion(s string) *AlertUpdate {
au.mutation.SetScenarioVersion(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableScenarioVersion sets the "scenarioVersion" field if the given value is not nil.
func (au *AlertUpdate) SetNillableScenarioVersion(s *string) *AlertUpdate {
if s != nil {
au.SetScenarioVersion(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearScenarioVersion clears the value of the "scenarioVersion" field.
func (au *AlertUpdate) ClearScenarioVersion() *AlertUpdate {
au.mutation.ClearScenarioVersion()
return au
}
2021-01-14 15:27:45 +00:00
// SetScenarioHash sets the "scenarioHash" field.
func (au *AlertUpdate) SetScenarioHash(s string) *AlertUpdate {
au.mutation.SetScenarioHash(s)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableScenarioHash sets the "scenarioHash" field if the given value is not nil.
func (au *AlertUpdate) SetNillableScenarioHash(s *string) *AlertUpdate {
if s != nil {
au.SetScenarioHash(*s)
}
return au
}
2021-01-14 15:27:45 +00:00
// ClearScenarioHash clears the value of the "scenarioHash" field.
func (au *AlertUpdate) ClearScenarioHash() *AlertUpdate {
au.mutation.ClearScenarioHash()
return au
}
2021-01-14 15:27:45 +00:00
// SetSimulated sets the "simulated" field.
func (au *AlertUpdate) SetSimulated(b bool) *AlertUpdate {
au.mutation.SetSimulated(b)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableSimulated sets the "simulated" field if the given value is not nil.
func (au *AlertUpdate) SetNillableSimulated(b *bool) *AlertUpdate {
if b != nil {
au.SetSimulated(*b)
}
return au
}
// SetUUID sets the "uuid" field.
func (au *AlertUpdate) SetUUID(s string) *AlertUpdate {
au.mutation.SetUUID(s)
return au
}
// SetNillableUUID sets the "uuid" field if the given value is not nil.
func (au *AlertUpdate) SetNillableUUID(s *string) *AlertUpdate {
if s != nil {
au.SetUUID(*s)
}
return au
}
// ClearUUID clears the value of the "uuid" field.
func (au *AlertUpdate) ClearUUID() *AlertUpdate {
au.mutation.ClearUUID()
return au
}
2021-01-14 15:27:45 +00:00
// SetOwnerID sets the "owner" edge to the Machine entity by ID.
func (au *AlertUpdate) SetOwnerID(id int) *AlertUpdate {
au.mutation.SetOwnerID(id)
return au
}
2021-01-14 15:27:45 +00:00
// SetNillableOwnerID sets the "owner" edge to the Machine entity by ID if the given value is not nil.
func (au *AlertUpdate) SetNillableOwnerID(id *int) *AlertUpdate {
if id != nil {
au = au.SetOwnerID(*id)
}
return au
}
2021-01-14 15:27:45 +00:00
// SetOwner sets the "owner" edge to the Machine entity.
func (au *AlertUpdate) SetOwner(m *Machine) *AlertUpdate {
return au.SetOwnerID(m.ID)
}
2021-01-14 15:27:45 +00:00
// AddDecisionIDs adds the "decisions" edge to the Decision entity by IDs.
func (au *AlertUpdate) AddDecisionIDs(ids ...int) *AlertUpdate {
au.mutation.AddDecisionIDs(ids...)
return au
}
2021-01-14 15:27:45 +00:00
// AddDecisions adds the "decisions" edges to the Decision entity.
func (au *AlertUpdate) AddDecisions(d ...*Decision) *AlertUpdate {
ids := make([]int, len(d))
for i := range d {
ids[i] = d[i].ID
}
return au.AddDecisionIDs(ids...)
}
2021-01-14 15:27:45 +00:00
// AddEventIDs adds the "events" edge to the Event entity by IDs.
func (au *AlertUpdate) AddEventIDs(ids ...int) *AlertUpdate {
au.mutation.AddEventIDs(ids...)
return au
}
2021-01-14 15:27:45 +00:00
// AddEvents adds the "events" edges to the Event entity.
func (au *AlertUpdate) AddEvents(e ...*Event) *AlertUpdate {
ids := make([]int, len(e))
for i := range e {
ids[i] = e[i].ID
}
return au.AddEventIDs(ids...)
}
2021-01-14 15:27:45 +00:00
// AddMetaIDs adds the "metas" edge to the Meta entity by IDs.
func (au *AlertUpdate) AddMetaIDs(ids ...int) *AlertUpdate {
au.mutation.AddMetaIDs(ids...)
return au
}
2021-01-14 15:27:45 +00:00
// AddMetas adds the "metas" edges to the Meta entity.
func (au *AlertUpdate) AddMetas(m ...*Meta) *AlertUpdate {
ids := make([]int, len(m))
for i := range m {
ids[i] = m[i].ID
}
return au.AddMetaIDs(ids...)
}
// Mutation returns the AlertMutation object of the builder.
func (au *AlertUpdate) Mutation() *AlertMutation {
return au.mutation
}
2021-01-14 15:27:45 +00:00
// ClearOwner clears the "owner" edge to the Machine entity.
func (au *AlertUpdate) ClearOwner() *AlertUpdate {
au.mutation.ClearOwner()
return au
}
2021-01-14 15:27:45 +00:00
// ClearDecisions clears all "decisions" edges to the Decision entity.
func (au *AlertUpdate) ClearDecisions() *AlertUpdate {
au.mutation.ClearDecisions()
return au
}
2021-01-14 15:27:45 +00:00
// RemoveDecisionIDs removes the "decisions" edge to Decision entities by IDs.
func (au *AlertUpdate) RemoveDecisionIDs(ids ...int) *AlertUpdate {
au.mutation.RemoveDecisionIDs(ids...)
return au
}
2021-01-14 15:27:45 +00:00
// RemoveDecisions removes "decisions" edges to Decision entities.
func (au *AlertUpdate) RemoveDecisions(d ...*Decision) *AlertUpdate {
ids := make([]int, len(d))
for i := range d {
ids[i] = d[i].ID
}
return au.RemoveDecisionIDs(ids...)
}
2021-01-14 15:27:45 +00:00
// ClearEvents clears all "events" edges to the Event entity.
func (au *AlertUpdate) ClearEvents() *AlertUpdate {
au.mutation.ClearEvents()
return au
}
2021-01-14 15:27:45 +00:00
// RemoveEventIDs removes the "events" edge to Event entities by IDs.
func (au *AlertUpdate) RemoveEventIDs(ids ...int) *AlertUpdate {
au.mutation.RemoveEventIDs(ids...)
return au
}
2021-01-14 15:27:45 +00:00
// RemoveEvents removes "events" edges to Event entities.
func (au *AlertUpdate) RemoveEvents(e ...*Event) *AlertUpdate {
ids := make([]int, len(e))
for i := range e {
ids[i] = e[i].ID
}
return au.RemoveEventIDs(ids...)
}
2021-01-14 15:27:45 +00:00
// ClearMetas clears all "metas" edges to the Meta entity.
func (au *AlertUpdate) ClearMetas() *AlertUpdate {
au.mutation.ClearMetas()
return au
}
2021-01-14 15:27:45 +00:00
// RemoveMetaIDs removes the "metas" edge to Meta entities by IDs.
func (au *AlertUpdate) RemoveMetaIDs(ids ...int) *AlertUpdate {
au.mutation.RemoveMetaIDs(ids...)
return au
}
2021-01-14 15:27:45 +00:00
// RemoveMetas removes "metas" edges to Meta entities.
func (au *AlertUpdate) RemoveMetas(m ...*Meta) *AlertUpdate {
ids := make([]int, len(m))
for i := range m {
ids[i] = m[i].ID
}
return au.RemoveMetaIDs(ids...)
}
2021-01-14 15:27:45 +00:00
// Save executes the query and returns the number of nodes affected by the update operation.
func (au *AlertUpdate) Save(ctx context.Context) (int, error) {
au.defaults()
2024-02-14 10:19:13 +00:00
return withHooks(ctx, au.sqlSave, au.mutation, au.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (au *AlertUpdate) SaveX(ctx context.Context) int {
affected, err := au.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (au *AlertUpdate) Exec(ctx context.Context) error {
_, err := au.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (au *AlertUpdate) ExecX(ctx context.Context) {
if err := au.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (au *AlertUpdate) defaults() {
if _, ok := au.mutation.CreatedAt(); !ok && !au.mutation.CreatedAtCleared() {
v := alert.UpdateDefaultCreatedAt()
au.mutation.SetCreatedAt(v)
}
if _, ok := au.mutation.UpdatedAt(); !ok && !au.mutation.UpdatedAtCleared() {
v := alert.UpdateDefaultUpdatedAt()
au.mutation.SetUpdatedAt(v)
}
}
func (au *AlertUpdate) sqlSave(ctx context.Context) (n int, err error) {
2024-02-14 10:19:13 +00:00
_spec := sqlgraph.NewUpdateSpec(alert.Table, alert.Columns, sqlgraph.NewFieldSpec(alert.FieldID, field.TypeInt))
2021-01-14 15:27:45 +00:00
if ps := au.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := au.mutation.CreatedAt(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldCreatedAt, field.TypeTime, value)
}
if au.mutation.CreatedAtCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldCreatedAt, field.TypeTime)
}
if value, ok := au.mutation.UpdatedAt(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldUpdatedAt, field.TypeTime, value)
}
if au.mutation.UpdatedAtCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldUpdatedAt, field.TypeTime)
}
if value, ok := au.mutation.Scenario(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldScenario, field.TypeString, value)
}
if value, ok := au.mutation.BucketId(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldBucketId, field.TypeString, value)
}
if au.mutation.BucketIdCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldBucketId, field.TypeString)
}
if value, ok := au.mutation.Message(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldMessage, field.TypeString, value)
}
if au.mutation.MessageCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldMessage, field.TypeString)
}
if value, ok := au.mutation.EventsCount(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldEventsCount, field.TypeInt32, value)
}
if value, ok := au.mutation.AddedEventsCount(); ok {
2024-02-14 10:19:13 +00:00
_spec.AddField(alert.FieldEventsCount, field.TypeInt32, value)
}
if au.mutation.EventsCountCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldEventsCount, field.TypeInt32)
}
if value, ok := au.mutation.StartedAt(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldStartedAt, field.TypeTime, value)
}
if au.mutation.StartedAtCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldStartedAt, field.TypeTime)
}
if value, ok := au.mutation.StoppedAt(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldStoppedAt, field.TypeTime, value)
}
if au.mutation.StoppedAtCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldStoppedAt, field.TypeTime)
}
if value, ok := au.mutation.SourceIp(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceIp, field.TypeString, value)
}
if au.mutation.SourceIpCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceIp, field.TypeString)
}
if value, ok := au.mutation.SourceRange(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceRange, field.TypeString, value)
}
if au.mutation.SourceRangeCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceRange, field.TypeString)
}
if value, ok := au.mutation.SourceAsNumber(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceAsNumber, field.TypeString, value)
}
if au.mutation.SourceAsNumberCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceAsNumber, field.TypeString)
}
if value, ok := au.mutation.SourceAsName(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceAsName, field.TypeString, value)
}
if au.mutation.SourceAsNameCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceAsName, field.TypeString)
}
if value, ok := au.mutation.SourceCountry(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceCountry, field.TypeString, value)
}
if au.mutation.SourceCountryCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceCountry, field.TypeString)
}
if value, ok := au.mutation.SourceLatitude(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceLatitude, field.TypeFloat32, value)
}
if value, ok := au.mutation.AddedSourceLatitude(); ok {
2024-02-14 10:19:13 +00:00
_spec.AddField(alert.FieldSourceLatitude, field.TypeFloat32, value)
}
if au.mutation.SourceLatitudeCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceLatitude, field.TypeFloat32)
}
if value, ok := au.mutation.SourceLongitude(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceLongitude, field.TypeFloat32, value)
}
if value, ok := au.mutation.AddedSourceLongitude(); ok {
2024-02-14 10:19:13 +00:00
_spec.AddField(alert.FieldSourceLongitude, field.TypeFloat32, value)
}
if au.mutation.SourceLongitudeCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceLongitude, field.TypeFloat32)
}
if value, ok := au.mutation.SourceScope(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceScope, field.TypeString, value)
}
if au.mutation.SourceScopeCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceScope, field.TypeString)
}
if value, ok := au.mutation.SourceValue(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceValue, field.TypeString, value)
}
if au.mutation.SourceValueCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceValue, field.TypeString)
}
if value, ok := au.mutation.Capacity(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldCapacity, field.TypeInt32, value)
}
if value, ok := au.mutation.AddedCapacity(); ok {
2024-02-14 10:19:13 +00:00
_spec.AddField(alert.FieldCapacity, field.TypeInt32, value)
}
if au.mutation.CapacityCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldCapacity, field.TypeInt32)
}
if value, ok := au.mutation.LeakSpeed(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldLeakSpeed, field.TypeString, value)
}
if au.mutation.LeakSpeedCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldLeakSpeed, field.TypeString)
}
if value, ok := au.mutation.ScenarioVersion(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldScenarioVersion, field.TypeString, value)
}
if au.mutation.ScenarioVersionCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldScenarioVersion, field.TypeString)
}
if value, ok := au.mutation.ScenarioHash(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldScenarioHash, field.TypeString, value)
}
if au.mutation.ScenarioHashCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldScenarioHash, field.TypeString)
}
if value, ok := au.mutation.Simulated(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSimulated, field.TypeBool, value)
}
if value, ok := au.mutation.UUID(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldUUID, field.TypeString, value)
}
if au.mutation.UUIDCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldUUID, field.TypeString)
}
if au.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: alert.OwnerTable,
Columns: []string{alert.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(machine.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := au.mutation.OwnerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: alert.OwnerTable,
Columns: []string{alert.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(machine.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if au.mutation.DecisionsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.DecisionsTable,
Columns: []string{alert.DecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := au.mutation.RemovedDecisionsIDs(); len(nodes) > 0 && !au.mutation.DecisionsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.DecisionsTable,
Columns: []string{alert.DecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := au.mutation.DecisionsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.DecisionsTable,
Columns: []string{alert.DecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if au.mutation.EventsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.EventsTable,
Columns: []string{alert.EventsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := au.mutation.RemovedEventsIDs(); len(nodes) > 0 && !au.mutation.EventsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.EventsTable,
Columns: []string{alert.EventsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := au.mutation.EventsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.EventsTable,
Columns: []string{alert.EventsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if au.mutation.MetasCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.MetasTable,
Columns: []string{alert.MetasColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := au.mutation.RemovedMetasIDs(); len(nodes) > 0 && !au.mutation.MetasCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.MetasTable,
Columns: []string{alert.MetasColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := au.mutation.MetasIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.MetasTable,
Columns: []string{alert.MetasColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if n, err = sqlgraph.UpdateNodes(ctx, au.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{alert.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
2024-02-14 10:19:13 +00:00
au.mutation.done = true
return n, nil
}
// AlertUpdateOne is the builder for updating a single Alert entity.
type AlertUpdateOne struct {
config
fields []string
hooks []Hook
mutation *AlertMutation
}
2021-01-14 15:27:45 +00:00
// SetCreatedAt sets the "created_at" field.
func (auo *AlertUpdateOne) SetCreatedAt(t time.Time) *AlertUpdateOne {
auo.mutation.SetCreatedAt(t)
return auo
}
// ClearCreatedAt clears the value of the "created_at" field.
func (auo *AlertUpdateOne) ClearCreatedAt() *AlertUpdateOne {
auo.mutation.ClearCreatedAt()
return auo
}
2021-01-14 15:27:45 +00:00
// SetUpdatedAt sets the "updated_at" field.
func (auo *AlertUpdateOne) SetUpdatedAt(t time.Time) *AlertUpdateOne {
auo.mutation.SetUpdatedAt(t)
return auo
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (auo *AlertUpdateOne) ClearUpdatedAt() *AlertUpdateOne {
auo.mutation.ClearUpdatedAt()
return auo
}
2021-01-14 15:27:45 +00:00
// SetScenario sets the "scenario" field.
func (auo *AlertUpdateOne) SetScenario(s string) *AlertUpdateOne {
auo.mutation.SetScenario(s)
return auo
}
// SetNillableScenario sets the "scenario" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableScenario(s *string) *AlertUpdateOne {
if s != nil {
auo.SetScenario(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// SetBucketId sets the "bucketId" field.
func (auo *AlertUpdateOne) SetBucketId(s string) *AlertUpdateOne {
auo.mutation.SetBucketId(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableBucketId sets the "bucketId" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableBucketId(s *string) *AlertUpdateOne {
if s != nil {
auo.SetBucketId(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearBucketId clears the value of the "bucketId" field.
func (auo *AlertUpdateOne) ClearBucketId() *AlertUpdateOne {
auo.mutation.ClearBucketId()
return auo
}
2021-01-14 15:27:45 +00:00
// SetMessage sets the "message" field.
func (auo *AlertUpdateOne) SetMessage(s string) *AlertUpdateOne {
auo.mutation.SetMessage(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableMessage sets the "message" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableMessage(s *string) *AlertUpdateOne {
if s != nil {
auo.SetMessage(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearMessage clears the value of the "message" field.
func (auo *AlertUpdateOne) ClearMessage() *AlertUpdateOne {
auo.mutation.ClearMessage()
return auo
}
2021-01-14 15:27:45 +00:00
// SetEventsCount sets the "eventsCount" field.
func (auo *AlertUpdateOne) SetEventsCount(i int32) *AlertUpdateOne {
auo.mutation.ResetEventsCount()
auo.mutation.SetEventsCount(i)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableEventsCount sets the "eventsCount" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableEventsCount(i *int32) *AlertUpdateOne {
if i != nil {
auo.SetEventsCount(*i)
}
return auo
}
2021-01-14 15:27:45 +00:00
// AddEventsCount adds i to the "eventsCount" field.
func (auo *AlertUpdateOne) AddEventsCount(i int32) *AlertUpdateOne {
auo.mutation.AddEventsCount(i)
return auo
}
2021-01-14 15:27:45 +00:00
// ClearEventsCount clears the value of the "eventsCount" field.
func (auo *AlertUpdateOne) ClearEventsCount() *AlertUpdateOne {
auo.mutation.ClearEventsCount()
return auo
}
2021-01-14 15:27:45 +00:00
// SetStartedAt sets the "startedAt" field.
func (auo *AlertUpdateOne) SetStartedAt(t time.Time) *AlertUpdateOne {
auo.mutation.SetStartedAt(t)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableStartedAt sets the "startedAt" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableStartedAt(t *time.Time) *AlertUpdateOne {
if t != nil {
auo.SetStartedAt(*t)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearStartedAt clears the value of the "startedAt" field.
func (auo *AlertUpdateOne) ClearStartedAt() *AlertUpdateOne {
auo.mutation.ClearStartedAt()
return auo
}
2021-01-14 15:27:45 +00:00
// SetStoppedAt sets the "stoppedAt" field.
func (auo *AlertUpdateOne) SetStoppedAt(t time.Time) *AlertUpdateOne {
auo.mutation.SetStoppedAt(t)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableStoppedAt sets the "stoppedAt" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableStoppedAt(t *time.Time) *AlertUpdateOne {
if t != nil {
auo.SetStoppedAt(*t)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearStoppedAt clears the value of the "stoppedAt" field.
func (auo *AlertUpdateOne) ClearStoppedAt() *AlertUpdateOne {
auo.mutation.ClearStoppedAt()
return auo
}
2021-01-14 15:27:45 +00:00
// SetSourceIp sets the "sourceIp" field.
func (auo *AlertUpdateOne) SetSourceIp(s string) *AlertUpdateOne {
auo.mutation.SetSourceIp(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceIp sets the "sourceIp" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableSourceIp(s *string) *AlertUpdateOne {
if s != nil {
auo.SetSourceIp(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearSourceIp clears the value of the "sourceIp" field.
func (auo *AlertUpdateOne) ClearSourceIp() *AlertUpdateOne {
auo.mutation.ClearSourceIp()
return auo
}
2021-01-14 15:27:45 +00:00
// SetSourceRange sets the "sourceRange" field.
func (auo *AlertUpdateOne) SetSourceRange(s string) *AlertUpdateOne {
auo.mutation.SetSourceRange(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceRange sets the "sourceRange" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableSourceRange(s *string) *AlertUpdateOne {
if s != nil {
auo.SetSourceRange(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearSourceRange clears the value of the "sourceRange" field.
func (auo *AlertUpdateOne) ClearSourceRange() *AlertUpdateOne {
auo.mutation.ClearSourceRange()
return auo
}
2021-01-14 15:27:45 +00:00
// SetSourceAsNumber sets the "sourceAsNumber" field.
func (auo *AlertUpdateOne) SetSourceAsNumber(s string) *AlertUpdateOne {
auo.mutation.SetSourceAsNumber(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceAsNumber sets the "sourceAsNumber" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableSourceAsNumber(s *string) *AlertUpdateOne {
if s != nil {
auo.SetSourceAsNumber(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearSourceAsNumber clears the value of the "sourceAsNumber" field.
func (auo *AlertUpdateOne) ClearSourceAsNumber() *AlertUpdateOne {
auo.mutation.ClearSourceAsNumber()
return auo
}
2021-01-14 15:27:45 +00:00
// SetSourceAsName sets the "sourceAsName" field.
func (auo *AlertUpdateOne) SetSourceAsName(s string) *AlertUpdateOne {
auo.mutation.SetSourceAsName(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceAsName sets the "sourceAsName" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableSourceAsName(s *string) *AlertUpdateOne {
if s != nil {
auo.SetSourceAsName(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearSourceAsName clears the value of the "sourceAsName" field.
func (auo *AlertUpdateOne) ClearSourceAsName() *AlertUpdateOne {
auo.mutation.ClearSourceAsName()
return auo
}
2021-01-14 15:27:45 +00:00
// SetSourceCountry sets the "sourceCountry" field.
func (auo *AlertUpdateOne) SetSourceCountry(s string) *AlertUpdateOne {
auo.mutation.SetSourceCountry(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceCountry sets the "sourceCountry" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableSourceCountry(s *string) *AlertUpdateOne {
if s != nil {
auo.SetSourceCountry(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearSourceCountry clears the value of the "sourceCountry" field.
func (auo *AlertUpdateOne) ClearSourceCountry() *AlertUpdateOne {
auo.mutation.ClearSourceCountry()
return auo
}
2021-01-14 15:27:45 +00:00
// SetSourceLatitude sets the "sourceLatitude" field.
func (auo *AlertUpdateOne) SetSourceLatitude(f float32) *AlertUpdateOne {
auo.mutation.ResetSourceLatitude()
auo.mutation.SetSourceLatitude(f)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceLatitude sets the "sourceLatitude" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableSourceLatitude(f *float32) *AlertUpdateOne {
if f != nil {
auo.SetSourceLatitude(*f)
}
return auo
}
2021-01-14 15:27:45 +00:00
// AddSourceLatitude adds f to the "sourceLatitude" field.
func (auo *AlertUpdateOne) AddSourceLatitude(f float32) *AlertUpdateOne {
auo.mutation.AddSourceLatitude(f)
return auo
}
2021-01-14 15:27:45 +00:00
// ClearSourceLatitude clears the value of the "sourceLatitude" field.
func (auo *AlertUpdateOne) ClearSourceLatitude() *AlertUpdateOne {
auo.mutation.ClearSourceLatitude()
return auo
}
2021-01-14 15:27:45 +00:00
// SetSourceLongitude sets the "sourceLongitude" field.
func (auo *AlertUpdateOne) SetSourceLongitude(f float32) *AlertUpdateOne {
auo.mutation.ResetSourceLongitude()
auo.mutation.SetSourceLongitude(f)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceLongitude sets the "sourceLongitude" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableSourceLongitude(f *float32) *AlertUpdateOne {
if f != nil {
auo.SetSourceLongitude(*f)
}
return auo
}
2021-01-14 15:27:45 +00:00
// AddSourceLongitude adds f to the "sourceLongitude" field.
func (auo *AlertUpdateOne) AddSourceLongitude(f float32) *AlertUpdateOne {
auo.mutation.AddSourceLongitude(f)
return auo
}
2021-01-14 15:27:45 +00:00
// ClearSourceLongitude clears the value of the "sourceLongitude" field.
func (auo *AlertUpdateOne) ClearSourceLongitude() *AlertUpdateOne {
auo.mutation.ClearSourceLongitude()
return auo
}
2021-01-14 15:27:45 +00:00
// SetSourceScope sets the "sourceScope" field.
func (auo *AlertUpdateOne) SetSourceScope(s string) *AlertUpdateOne {
auo.mutation.SetSourceScope(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceScope sets the "sourceScope" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableSourceScope(s *string) *AlertUpdateOne {
if s != nil {
auo.SetSourceScope(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearSourceScope clears the value of the "sourceScope" field.
func (auo *AlertUpdateOne) ClearSourceScope() *AlertUpdateOne {
auo.mutation.ClearSourceScope()
return auo
}
2021-01-14 15:27:45 +00:00
// SetSourceValue sets the "sourceValue" field.
func (auo *AlertUpdateOne) SetSourceValue(s string) *AlertUpdateOne {
auo.mutation.SetSourceValue(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableSourceValue sets the "sourceValue" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableSourceValue(s *string) *AlertUpdateOne {
if s != nil {
auo.SetSourceValue(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearSourceValue clears the value of the "sourceValue" field.
func (auo *AlertUpdateOne) ClearSourceValue() *AlertUpdateOne {
auo.mutation.ClearSourceValue()
return auo
}
2021-01-14 15:27:45 +00:00
// SetCapacity sets the "capacity" field.
func (auo *AlertUpdateOne) SetCapacity(i int32) *AlertUpdateOne {
auo.mutation.ResetCapacity()
auo.mutation.SetCapacity(i)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableCapacity sets the "capacity" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableCapacity(i *int32) *AlertUpdateOne {
if i != nil {
auo.SetCapacity(*i)
}
return auo
}
2021-01-14 15:27:45 +00:00
// AddCapacity adds i to the "capacity" field.
func (auo *AlertUpdateOne) AddCapacity(i int32) *AlertUpdateOne {
auo.mutation.AddCapacity(i)
return auo
}
2021-01-14 15:27:45 +00:00
// ClearCapacity clears the value of the "capacity" field.
func (auo *AlertUpdateOne) ClearCapacity() *AlertUpdateOne {
auo.mutation.ClearCapacity()
return auo
}
2021-01-14 15:27:45 +00:00
// SetLeakSpeed sets the "leakSpeed" field.
func (auo *AlertUpdateOne) SetLeakSpeed(s string) *AlertUpdateOne {
auo.mutation.SetLeakSpeed(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableLeakSpeed sets the "leakSpeed" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableLeakSpeed(s *string) *AlertUpdateOne {
if s != nil {
auo.SetLeakSpeed(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearLeakSpeed clears the value of the "leakSpeed" field.
func (auo *AlertUpdateOne) ClearLeakSpeed() *AlertUpdateOne {
auo.mutation.ClearLeakSpeed()
return auo
}
2021-01-14 15:27:45 +00:00
// SetScenarioVersion sets the "scenarioVersion" field.
func (auo *AlertUpdateOne) SetScenarioVersion(s string) *AlertUpdateOne {
auo.mutation.SetScenarioVersion(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableScenarioVersion sets the "scenarioVersion" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableScenarioVersion(s *string) *AlertUpdateOne {
if s != nil {
auo.SetScenarioVersion(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearScenarioVersion clears the value of the "scenarioVersion" field.
func (auo *AlertUpdateOne) ClearScenarioVersion() *AlertUpdateOne {
auo.mutation.ClearScenarioVersion()
return auo
}
2021-01-14 15:27:45 +00:00
// SetScenarioHash sets the "scenarioHash" field.
func (auo *AlertUpdateOne) SetScenarioHash(s string) *AlertUpdateOne {
auo.mutation.SetScenarioHash(s)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableScenarioHash sets the "scenarioHash" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableScenarioHash(s *string) *AlertUpdateOne {
if s != nil {
auo.SetScenarioHash(*s)
}
return auo
}
2021-01-14 15:27:45 +00:00
// ClearScenarioHash clears the value of the "scenarioHash" field.
func (auo *AlertUpdateOne) ClearScenarioHash() *AlertUpdateOne {
auo.mutation.ClearScenarioHash()
return auo
}
2021-01-14 15:27:45 +00:00
// SetSimulated sets the "simulated" field.
func (auo *AlertUpdateOne) SetSimulated(b bool) *AlertUpdateOne {
auo.mutation.SetSimulated(b)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableSimulated sets the "simulated" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableSimulated(b *bool) *AlertUpdateOne {
if b != nil {
auo.SetSimulated(*b)
}
return auo
}
// SetUUID sets the "uuid" field.
func (auo *AlertUpdateOne) SetUUID(s string) *AlertUpdateOne {
auo.mutation.SetUUID(s)
return auo
}
// SetNillableUUID sets the "uuid" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableUUID(s *string) *AlertUpdateOne {
if s != nil {
auo.SetUUID(*s)
}
return auo
}
// ClearUUID clears the value of the "uuid" field.
func (auo *AlertUpdateOne) ClearUUID() *AlertUpdateOne {
auo.mutation.ClearUUID()
return auo
}
2021-01-14 15:27:45 +00:00
// SetOwnerID sets the "owner" edge to the Machine entity by ID.
func (auo *AlertUpdateOne) SetOwnerID(id int) *AlertUpdateOne {
auo.mutation.SetOwnerID(id)
return auo
}
2021-01-14 15:27:45 +00:00
// SetNillableOwnerID sets the "owner" edge to the Machine entity by ID if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableOwnerID(id *int) *AlertUpdateOne {
if id != nil {
auo = auo.SetOwnerID(*id)
}
return auo
}
2021-01-14 15:27:45 +00:00
// SetOwner sets the "owner" edge to the Machine entity.
func (auo *AlertUpdateOne) SetOwner(m *Machine) *AlertUpdateOne {
return auo.SetOwnerID(m.ID)
}
2021-01-14 15:27:45 +00:00
// AddDecisionIDs adds the "decisions" edge to the Decision entity by IDs.
func (auo *AlertUpdateOne) AddDecisionIDs(ids ...int) *AlertUpdateOne {
auo.mutation.AddDecisionIDs(ids...)
return auo
}
2021-01-14 15:27:45 +00:00
// AddDecisions adds the "decisions" edges to the Decision entity.
func (auo *AlertUpdateOne) AddDecisions(d ...*Decision) *AlertUpdateOne {
ids := make([]int, len(d))
for i := range d {
ids[i] = d[i].ID
}
return auo.AddDecisionIDs(ids...)
}
2021-01-14 15:27:45 +00:00
// AddEventIDs adds the "events" edge to the Event entity by IDs.
func (auo *AlertUpdateOne) AddEventIDs(ids ...int) *AlertUpdateOne {
auo.mutation.AddEventIDs(ids...)
return auo
}
2021-01-14 15:27:45 +00:00
// AddEvents adds the "events" edges to the Event entity.
func (auo *AlertUpdateOne) AddEvents(e ...*Event) *AlertUpdateOne {
ids := make([]int, len(e))
for i := range e {
ids[i] = e[i].ID
}
return auo.AddEventIDs(ids...)
}
2021-01-14 15:27:45 +00:00
// AddMetaIDs adds the "metas" edge to the Meta entity by IDs.
func (auo *AlertUpdateOne) AddMetaIDs(ids ...int) *AlertUpdateOne {
auo.mutation.AddMetaIDs(ids...)
return auo
}
2021-01-14 15:27:45 +00:00
// AddMetas adds the "metas" edges to the Meta entity.
func (auo *AlertUpdateOne) AddMetas(m ...*Meta) *AlertUpdateOne {
ids := make([]int, len(m))
for i := range m {
ids[i] = m[i].ID
}
return auo.AddMetaIDs(ids...)
}
// Mutation returns the AlertMutation object of the builder.
func (auo *AlertUpdateOne) Mutation() *AlertMutation {
return auo.mutation
}
2021-01-14 15:27:45 +00:00
// ClearOwner clears the "owner" edge to the Machine entity.
func (auo *AlertUpdateOne) ClearOwner() *AlertUpdateOne {
auo.mutation.ClearOwner()
return auo
}
2021-01-14 15:27:45 +00:00
// ClearDecisions clears all "decisions" edges to the Decision entity.
func (auo *AlertUpdateOne) ClearDecisions() *AlertUpdateOne {
auo.mutation.ClearDecisions()
return auo
}
2021-01-14 15:27:45 +00:00
// RemoveDecisionIDs removes the "decisions" edge to Decision entities by IDs.
func (auo *AlertUpdateOne) RemoveDecisionIDs(ids ...int) *AlertUpdateOne {
auo.mutation.RemoveDecisionIDs(ids...)
return auo
}
2021-01-14 15:27:45 +00:00
// RemoveDecisions removes "decisions" edges to Decision entities.
func (auo *AlertUpdateOne) RemoveDecisions(d ...*Decision) *AlertUpdateOne {
ids := make([]int, len(d))
for i := range d {
ids[i] = d[i].ID
}
return auo.RemoveDecisionIDs(ids...)
}
2021-01-14 15:27:45 +00:00
// ClearEvents clears all "events" edges to the Event entity.
func (auo *AlertUpdateOne) ClearEvents() *AlertUpdateOne {
auo.mutation.ClearEvents()
return auo
}
2021-01-14 15:27:45 +00:00
// RemoveEventIDs removes the "events" edge to Event entities by IDs.
func (auo *AlertUpdateOne) RemoveEventIDs(ids ...int) *AlertUpdateOne {
auo.mutation.RemoveEventIDs(ids...)
return auo
}
2021-01-14 15:27:45 +00:00
// RemoveEvents removes "events" edges to Event entities.
func (auo *AlertUpdateOne) RemoveEvents(e ...*Event) *AlertUpdateOne {
ids := make([]int, len(e))
for i := range e {
ids[i] = e[i].ID
}
return auo.RemoveEventIDs(ids...)
}
2021-01-14 15:27:45 +00:00
// ClearMetas clears all "metas" edges to the Meta entity.
func (auo *AlertUpdateOne) ClearMetas() *AlertUpdateOne {
auo.mutation.ClearMetas()
return auo
}
2021-01-14 15:27:45 +00:00
// RemoveMetaIDs removes the "metas" edge to Meta entities by IDs.
func (auo *AlertUpdateOne) RemoveMetaIDs(ids ...int) *AlertUpdateOne {
auo.mutation.RemoveMetaIDs(ids...)
return auo
}
2021-01-14 15:27:45 +00:00
// RemoveMetas removes "metas" edges to Meta entities.
func (auo *AlertUpdateOne) RemoveMetas(m ...*Meta) *AlertUpdateOne {
ids := make([]int, len(m))
for i := range m {
ids[i] = m[i].ID
}
return auo.RemoveMetaIDs(ids...)
}
2024-02-14 10:19:13 +00:00
// Where appends a list predicates to the AlertUpdate builder.
func (auo *AlertUpdateOne) Where(ps ...predicate.Alert) *AlertUpdateOne {
auo.mutation.Where(ps...)
return auo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (auo *AlertUpdateOne) Select(field string, fields ...string) *AlertUpdateOne {
auo.fields = append([]string{field}, fields...)
return auo
}
2021-01-14 15:27:45 +00:00
// Save executes the query and returns the updated Alert entity.
func (auo *AlertUpdateOne) Save(ctx context.Context) (*Alert, error) {
auo.defaults()
2024-02-14 10:19:13 +00:00
return withHooks(ctx, auo.sqlSave, auo.mutation, auo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (auo *AlertUpdateOne) SaveX(ctx context.Context) *Alert {
node, err := auo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (auo *AlertUpdateOne) Exec(ctx context.Context) error {
_, err := auo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (auo *AlertUpdateOne) ExecX(ctx context.Context) {
if err := auo.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (auo *AlertUpdateOne) defaults() {
if _, ok := auo.mutation.CreatedAt(); !ok && !auo.mutation.CreatedAtCleared() {
v := alert.UpdateDefaultCreatedAt()
auo.mutation.SetCreatedAt(v)
}
if _, ok := auo.mutation.UpdatedAt(); !ok && !auo.mutation.UpdatedAtCleared() {
v := alert.UpdateDefaultUpdatedAt()
auo.mutation.SetUpdatedAt(v)
}
}
func (auo *AlertUpdateOne) sqlSave(ctx context.Context) (_node *Alert, err error) {
2024-02-14 10:19:13 +00:00
_spec := sqlgraph.NewUpdateSpec(alert.Table, alert.Columns, sqlgraph.NewFieldSpec(alert.FieldID, field.TypeInt))
id, ok := auo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Alert.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := auo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, alert.FieldID)
for _, f := range fields {
if !alert.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != alert.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := auo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := auo.mutation.CreatedAt(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldCreatedAt, field.TypeTime, value)
}
if auo.mutation.CreatedAtCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldCreatedAt, field.TypeTime)
}
if value, ok := auo.mutation.UpdatedAt(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldUpdatedAt, field.TypeTime, value)
}
if auo.mutation.UpdatedAtCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldUpdatedAt, field.TypeTime)
}
if value, ok := auo.mutation.Scenario(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldScenario, field.TypeString, value)
}
if value, ok := auo.mutation.BucketId(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldBucketId, field.TypeString, value)
}
if auo.mutation.BucketIdCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldBucketId, field.TypeString)
}
if value, ok := auo.mutation.Message(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldMessage, field.TypeString, value)
}
if auo.mutation.MessageCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldMessage, field.TypeString)
}
if value, ok := auo.mutation.EventsCount(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldEventsCount, field.TypeInt32, value)
}
if value, ok := auo.mutation.AddedEventsCount(); ok {
2024-02-14 10:19:13 +00:00
_spec.AddField(alert.FieldEventsCount, field.TypeInt32, value)
}
if auo.mutation.EventsCountCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldEventsCount, field.TypeInt32)
}
if value, ok := auo.mutation.StartedAt(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldStartedAt, field.TypeTime, value)
}
if auo.mutation.StartedAtCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldStartedAt, field.TypeTime)
}
if value, ok := auo.mutation.StoppedAt(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldStoppedAt, field.TypeTime, value)
}
if auo.mutation.StoppedAtCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldStoppedAt, field.TypeTime)
}
if value, ok := auo.mutation.SourceIp(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceIp, field.TypeString, value)
}
if auo.mutation.SourceIpCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceIp, field.TypeString)
}
if value, ok := auo.mutation.SourceRange(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceRange, field.TypeString, value)
}
if auo.mutation.SourceRangeCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceRange, field.TypeString)
}
if value, ok := auo.mutation.SourceAsNumber(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceAsNumber, field.TypeString, value)
}
if auo.mutation.SourceAsNumberCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceAsNumber, field.TypeString)
}
if value, ok := auo.mutation.SourceAsName(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceAsName, field.TypeString, value)
}
if auo.mutation.SourceAsNameCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceAsName, field.TypeString)
}
if value, ok := auo.mutation.SourceCountry(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceCountry, field.TypeString, value)
}
if auo.mutation.SourceCountryCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceCountry, field.TypeString)
}
if value, ok := auo.mutation.SourceLatitude(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceLatitude, field.TypeFloat32, value)
}
if value, ok := auo.mutation.AddedSourceLatitude(); ok {
2024-02-14 10:19:13 +00:00
_spec.AddField(alert.FieldSourceLatitude, field.TypeFloat32, value)
}
if auo.mutation.SourceLatitudeCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceLatitude, field.TypeFloat32)
}
if value, ok := auo.mutation.SourceLongitude(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceLongitude, field.TypeFloat32, value)
}
if value, ok := auo.mutation.AddedSourceLongitude(); ok {
2024-02-14 10:19:13 +00:00
_spec.AddField(alert.FieldSourceLongitude, field.TypeFloat32, value)
}
if auo.mutation.SourceLongitudeCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceLongitude, field.TypeFloat32)
}
if value, ok := auo.mutation.SourceScope(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceScope, field.TypeString, value)
}
if auo.mutation.SourceScopeCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceScope, field.TypeString)
}
if value, ok := auo.mutation.SourceValue(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSourceValue, field.TypeString, value)
}
if auo.mutation.SourceValueCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldSourceValue, field.TypeString)
}
if value, ok := auo.mutation.Capacity(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldCapacity, field.TypeInt32, value)
}
if value, ok := auo.mutation.AddedCapacity(); ok {
2024-02-14 10:19:13 +00:00
_spec.AddField(alert.FieldCapacity, field.TypeInt32, value)
}
if auo.mutation.CapacityCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldCapacity, field.TypeInt32)
}
if value, ok := auo.mutation.LeakSpeed(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldLeakSpeed, field.TypeString, value)
}
if auo.mutation.LeakSpeedCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldLeakSpeed, field.TypeString)
}
if value, ok := auo.mutation.ScenarioVersion(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldScenarioVersion, field.TypeString, value)
}
if auo.mutation.ScenarioVersionCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldScenarioVersion, field.TypeString)
}
if value, ok := auo.mutation.ScenarioHash(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldScenarioHash, field.TypeString, value)
}
if auo.mutation.ScenarioHashCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldScenarioHash, field.TypeString)
}
if value, ok := auo.mutation.Simulated(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldSimulated, field.TypeBool, value)
}
if value, ok := auo.mutation.UUID(); ok {
2024-02-14 10:19:13 +00:00
_spec.SetField(alert.FieldUUID, field.TypeString, value)
}
if auo.mutation.UUIDCleared() {
2024-02-14 10:19:13 +00:00
_spec.ClearField(alert.FieldUUID, field.TypeString)
}
if auo.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: alert.OwnerTable,
Columns: []string{alert.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(machine.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := auo.mutation.OwnerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: alert.OwnerTable,
Columns: []string{alert.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(machine.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if auo.mutation.DecisionsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.DecisionsTable,
Columns: []string{alert.DecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := auo.mutation.RemovedDecisionsIDs(); len(nodes) > 0 && !auo.mutation.DecisionsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.DecisionsTable,
Columns: []string{alert.DecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := auo.mutation.DecisionsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.DecisionsTable,
Columns: []string{alert.DecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if auo.mutation.EventsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.EventsTable,
Columns: []string{alert.EventsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := auo.mutation.RemovedEventsIDs(); len(nodes) > 0 && !auo.mutation.EventsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.EventsTable,
Columns: []string{alert.EventsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := auo.mutation.EventsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.EventsTable,
Columns: []string{alert.EventsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if auo.mutation.MetasCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.MetasTable,
Columns: []string{alert.MetasColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := auo.mutation.RemovedMetasIDs(); len(nodes) > 0 && !auo.mutation.MetasCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.MetasTable,
Columns: []string{alert.MetasColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := auo.mutation.MetasIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: alert.MetasTable,
Columns: []string{alert.MetasColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2024-02-14 10:19:13 +00:00
IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &Alert{config: auo.config}
_spec.Assign = _node.assignValues
2021-01-14 15:27:45 +00:00
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, auo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{alert.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
2024-02-14 10:19:13 +00:00
auo.mutation.done = true
return _node, nil
}