github.com/crowdsecurity/crowdsec@v1.6.1/pkg/database/ent/alert_update.go (about)

     1  // Code generated by ent, DO NOT EDIT.
     2  
     3  package ent
     4  
     5  import (
     6  	"context"
     7  	"errors"
     8  	"fmt"
     9  	"time"
    10  
    11  	"entgo.io/ent/dialect/sql"
    12  	"entgo.io/ent/dialect/sql/sqlgraph"
    13  	"entgo.io/ent/schema/field"
    14  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
    15  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
    16  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/event"
    17  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
    18  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
    19  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
    20  )
    21  
    22  // AlertUpdate is the builder for updating Alert entities.
    23  type AlertUpdate struct {
    24  	config
    25  	hooks    []Hook
    26  	mutation *AlertMutation
    27  }
    28  
    29  // Where appends a list predicates to the AlertUpdate builder.
    30  func (au *AlertUpdate) Where(ps ...predicate.Alert) *AlertUpdate {
    31  	au.mutation.Where(ps...)
    32  	return au
    33  }
    34  
    35  // SetCreatedAt sets the "created_at" field.
    36  func (au *AlertUpdate) SetCreatedAt(t time.Time) *AlertUpdate {
    37  	au.mutation.SetCreatedAt(t)
    38  	return au
    39  }
    40  
    41  // ClearCreatedAt clears the value of the "created_at" field.
    42  func (au *AlertUpdate) ClearCreatedAt() *AlertUpdate {
    43  	au.mutation.ClearCreatedAt()
    44  	return au
    45  }
    46  
    47  // SetUpdatedAt sets the "updated_at" field.
    48  func (au *AlertUpdate) SetUpdatedAt(t time.Time) *AlertUpdate {
    49  	au.mutation.SetUpdatedAt(t)
    50  	return au
    51  }
    52  
    53  // ClearUpdatedAt clears the value of the "updated_at" field.
    54  func (au *AlertUpdate) ClearUpdatedAt() *AlertUpdate {
    55  	au.mutation.ClearUpdatedAt()
    56  	return au
    57  }
    58  
    59  // SetScenario sets the "scenario" field.
    60  func (au *AlertUpdate) SetScenario(s string) *AlertUpdate {
    61  	au.mutation.SetScenario(s)
    62  	return au
    63  }
    64  
    65  // SetNillableScenario sets the "scenario" field if the given value is not nil.
    66  func (au *AlertUpdate) SetNillableScenario(s *string) *AlertUpdate {
    67  	if s != nil {
    68  		au.SetScenario(*s)
    69  	}
    70  	return au
    71  }
    72  
    73  // SetBucketId sets the "bucketId" field.
    74  func (au *AlertUpdate) SetBucketId(s string) *AlertUpdate {
    75  	au.mutation.SetBucketId(s)
    76  	return au
    77  }
    78  
    79  // SetNillableBucketId sets the "bucketId" field if the given value is not nil.
    80  func (au *AlertUpdate) SetNillableBucketId(s *string) *AlertUpdate {
    81  	if s != nil {
    82  		au.SetBucketId(*s)
    83  	}
    84  	return au
    85  }
    86  
    87  // ClearBucketId clears the value of the "bucketId" field.
    88  func (au *AlertUpdate) ClearBucketId() *AlertUpdate {
    89  	au.mutation.ClearBucketId()
    90  	return au
    91  }
    92  
    93  // SetMessage sets the "message" field.
    94  func (au *AlertUpdate) SetMessage(s string) *AlertUpdate {
    95  	au.mutation.SetMessage(s)
    96  	return au
    97  }
    98  
    99  // SetNillableMessage sets the "message" field if the given value is not nil.
   100  func (au *AlertUpdate) SetNillableMessage(s *string) *AlertUpdate {
   101  	if s != nil {
   102  		au.SetMessage(*s)
   103  	}
   104  	return au
   105  }
   106  
   107  // ClearMessage clears the value of the "message" field.
   108  func (au *AlertUpdate) ClearMessage() *AlertUpdate {
   109  	au.mutation.ClearMessage()
   110  	return au
   111  }
   112  
   113  // SetEventsCount sets the "eventsCount" field.
   114  func (au *AlertUpdate) SetEventsCount(i int32) *AlertUpdate {
   115  	au.mutation.ResetEventsCount()
   116  	au.mutation.SetEventsCount(i)
   117  	return au
   118  }
   119  
   120  // SetNillableEventsCount sets the "eventsCount" field if the given value is not nil.
   121  func (au *AlertUpdate) SetNillableEventsCount(i *int32) *AlertUpdate {
   122  	if i != nil {
   123  		au.SetEventsCount(*i)
   124  	}
   125  	return au
   126  }
   127  
   128  // AddEventsCount adds i to the "eventsCount" field.
   129  func (au *AlertUpdate) AddEventsCount(i int32) *AlertUpdate {
   130  	au.mutation.AddEventsCount(i)
   131  	return au
   132  }
   133  
   134  // ClearEventsCount clears the value of the "eventsCount" field.
   135  func (au *AlertUpdate) ClearEventsCount() *AlertUpdate {
   136  	au.mutation.ClearEventsCount()
   137  	return au
   138  }
   139  
   140  // SetStartedAt sets the "startedAt" field.
   141  func (au *AlertUpdate) SetStartedAt(t time.Time) *AlertUpdate {
   142  	au.mutation.SetStartedAt(t)
   143  	return au
   144  }
   145  
   146  // SetNillableStartedAt sets the "startedAt" field if the given value is not nil.
   147  func (au *AlertUpdate) SetNillableStartedAt(t *time.Time) *AlertUpdate {
   148  	if t != nil {
   149  		au.SetStartedAt(*t)
   150  	}
   151  	return au
   152  }
   153  
   154  // ClearStartedAt clears the value of the "startedAt" field.
   155  func (au *AlertUpdate) ClearStartedAt() *AlertUpdate {
   156  	au.mutation.ClearStartedAt()
   157  	return au
   158  }
   159  
   160  // SetStoppedAt sets the "stoppedAt" field.
   161  func (au *AlertUpdate) SetStoppedAt(t time.Time) *AlertUpdate {
   162  	au.mutation.SetStoppedAt(t)
   163  	return au
   164  }
   165  
   166  // SetNillableStoppedAt sets the "stoppedAt" field if the given value is not nil.
   167  func (au *AlertUpdate) SetNillableStoppedAt(t *time.Time) *AlertUpdate {
   168  	if t != nil {
   169  		au.SetStoppedAt(*t)
   170  	}
   171  	return au
   172  }
   173  
   174  // ClearStoppedAt clears the value of the "stoppedAt" field.
   175  func (au *AlertUpdate) ClearStoppedAt() *AlertUpdate {
   176  	au.mutation.ClearStoppedAt()
   177  	return au
   178  }
   179  
   180  // SetSourceIp sets the "sourceIp" field.
   181  func (au *AlertUpdate) SetSourceIp(s string) *AlertUpdate {
   182  	au.mutation.SetSourceIp(s)
   183  	return au
   184  }
   185  
   186  // SetNillableSourceIp sets the "sourceIp" field if the given value is not nil.
   187  func (au *AlertUpdate) SetNillableSourceIp(s *string) *AlertUpdate {
   188  	if s != nil {
   189  		au.SetSourceIp(*s)
   190  	}
   191  	return au
   192  }
   193  
   194  // ClearSourceIp clears the value of the "sourceIp" field.
   195  func (au *AlertUpdate) ClearSourceIp() *AlertUpdate {
   196  	au.mutation.ClearSourceIp()
   197  	return au
   198  }
   199  
   200  // SetSourceRange sets the "sourceRange" field.
   201  func (au *AlertUpdate) SetSourceRange(s string) *AlertUpdate {
   202  	au.mutation.SetSourceRange(s)
   203  	return au
   204  }
   205  
   206  // SetNillableSourceRange sets the "sourceRange" field if the given value is not nil.
   207  func (au *AlertUpdate) SetNillableSourceRange(s *string) *AlertUpdate {
   208  	if s != nil {
   209  		au.SetSourceRange(*s)
   210  	}
   211  	return au
   212  }
   213  
   214  // ClearSourceRange clears the value of the "sourceRange" field.
   215  func (au *AlertUpdate) ClearSourceRange() *AlertUpdate {
   216  	au.mutation.ClearSourceRange()
   217  	return au
   218  }
   219  
   220  // SetSourceAsNumber sets the "sourceAsNumber" field.
   221  func (au *AlertUpdate) SetSourceAsNumber(s string) *AlertUpdate {
   222  	au.mutation.SetSourceAsNumber(s)
   223  	return au
   224  }
   225  
   226  // SetNillableSourceAsNumber sets the "sourceAsNumber" field if the given value is not nil.
   227  func (au *AlertUpdate) SetNillableSourceAsNumber(s *string) *AlertUpdate {
   228  	if s != nil {
   229  		au.SetSourceAsNumber(*s)
   230  	}
   231  	return au
   232  }
   233  
   234  // ClearSourceAsNumber clears the value of the "sourceAsNumber" field.
   235  func (au *AlertUpdate) ClearSourceAsNumber() *AlertUpdate {
   236  	au.mutation.ClearSourceAsNumber()
   237  	return au
   238  }
   239  
   240  // SetSourceAsName sets the "sourceAsName" field.
   241  func (au *AlertUpdate) SetSourceAsName(s string) *AlertUpdate {
   242  	au.mutation.SetSourceAsName(s)
   243  	return au
   244  }
   245  
   246  // SetNillableSourceAsName sets the "sourceAsName" field if the given value is not nil.
   247  func (au *AlertUpdate) SetNillableSourceAsName(s *string) *AlertUpdate {
   248  	if s != nil {
   249  		au.SetSourceAsName(*s)
   250  	}
   251  	return au
   252  }
   253  
   254  // ClearSourceAsName clears the value of the "sourceAsName" field.
   255  func (au *AlertUpdate) ClearSourceAsName() *AlertUpdate {
   256  	au.mutation.ClearSourceAsName()
   257  	return au
   258  }
   259  
   260  // SetSourceCountry sets the "sourceCountry" field.
   261  func (au *AlertUpdate) SetSourceCountry(s string) *AlertUpdate {
   262  	au.mutation.SetSourceCountry(s)
   263  	return au
   264  }
   265  
   266  // SetNillableSourceCountry sets the "sourceCountry" field if the given value is not nil.
   267  func (au *AlertUpdate) SetNillableSourceCountry(s *string) *AlertUpdate {
   268  	if s != nil {
   269  		au.SetSourceCountry(*s)
   270  	}
   271  	return au
   272  }
   273  
   274  // ClearSourceCountry clears the value of the "sourceCountry" field.
   275  func (au *AlertUpdate) ClearSourceCountry() *AlertUpdate {
   276  	au.mutation.ClearSourceCountry()
   277  	return au
   278  }
   279  
   280  // SetSourceLatitude sets the "sourceLatitude" field.
   281  func (au *AlertUpdate) SetSourceLatitude(f float32) *AlertUpdate {
   282  	au.mutation.ResetSourceLatitude()
   283  	au.mutation.SetSourceLatitude(f)
   284  	return au
   285  }
   286  
   287  // SetNillableSourceLatitude sets the "sourceLatitude" field if the given value is not nil.
   288  func (au *AlertUpdate) SetNillableSourceLatitude(f *float32) *AlertUpdate {
   289  	if f != nil {
   290  		au.SetSourceLatitude(*f)
   291  	}
   292  	return au
   293  }
   294  
   295  // AddSourceLatitude adds f to the "sourceLatitude" field.
   296  func (au *AlertUpdate) AddSourceLatitude(f float32) *AlertUpdate {
   297  	au.mutation.AddSourceLatitude(f)
   298  	return au
   299  }
   300  
   301  // ClearSourceLatitude clears the value of the "sourceLatitude" field.
   302  func (au *AlertUpdate) ClearSourceLatitude() *AlertUpdate {
   303  	au.mutation.ClearSourceLatitude()
   304  	return au
   305  }
   306  
   307  // SetSourceLongitude sets the "sourceLongitude" field.
   308  func (au *AlertUpdate) SetSourceLongitude(f float32) *AlertUpdate {
   309  	au.mutation.ResetSourceLongitude()
   310  	au.mutation.SetSourceLongitude(f)
   311  	return au
   312  }
   313  
   314  // SetNillableSourceLongitude sets the "sourceLongitude" field if the given value is not nil.
   315  func (au *AlertUpdate) SetNillableSourceLongitude(f *float32) *AlertUpdate {
   316  	if f != nil {
   317  		au.SetSourceLongitude(*f)
   318  	}
   319  	return au
   320  }
   321  
   322  // AddSourceLongitude adds f to the "sourceLongitude" field.
   323  func (au *AlertUpdate) AddSourceLongitude(f float32) *AlertUpdate {
   324  	au.mutation.AddSourceLongitude(f)
   325  	return au
   326  }
   327  
   328  // ClearSourceLongitude clears the value of the "sourceLongitude" field.
   329  func (au *AlertUpdate) ClearSourceLongitude() *AlertUpdate {
   330  	au.mutation.ClearSourceLongitude()
   331  	return au
   332  }
   333  
   334  // SetSourceScope sets the "sourceScope" field.
   335  func (au *AlertUpdate) SetSourceScope(s string) *AlertUpdate {
   336  	au.mutation.SetSourceScope(s)
   337  	return au
   338  }
   339  
   340  // SetNillableSourceScope sets the "sourceScope" field if the given value is not nil.
   341  func (au *AlertUpdate) SetNillableSourceScope(s *string) *AlertUpdate {
   342  	if s != nil {
   343  		au.SetSourceScope(*s)
   344  	}
   345  	return au
   346  }
   347  
   348  // ClearSourceScope clears the value of the "sourceScope" field.
   349  func (au *AlertUpdate) ClearSourceScope() *AlertUpdate {
   350  	au.mutation.ClearSourceScope()
   351  	return au
   352  }
   353  
   354  // SetSourceValue sets the "sourceValue" field.
   355  func (au *AlertUpdate) SetSourceValue(s string) *AlertUpdate {
   356  	au.mutation.SetSourceValue(s)
   357  	return au
   358  }
   359  
   360  // SetNillableSourceValue sets the "sourceValue" field if the given value is not nil.
   361  func (au *AlertUpdate) SetNillableSourceValue(s *string) *AlertUpdate {
   362  	if s != nil {
   363  		au.SetSourceValue(*s)
   364  	}
   365  	return au
   366  }
   367  
   368  // ClearSourceValue clears the value of the "sourceValue" field.
   369  func (au *AlertUpdate) ClearSourceValue() *AlertUpdate {
   370  	au.mutation.ClearSourceValue()
   371  	return au
   372  }
   373  
   374  // SetCapacity sets the "capacity" field.
   375  func (au *AlertUpdate) SetCapacity(i int32) *AlertUpdate {
   376  	au.mutation.ResetCapacity()
   377  	au.mutation.SetCapacity(i)
   378  	return au
   379  }
   380  
   381  // SetNillableCapacity sets the "capacity" field if the given value is not nil.
   382  func (au *AlertUpdate) SetNillableCapacity(i *int32) *AlertUpdate {
   383  	if i != nil {
   384  		au.SetCapacity(*i)
   385  	}
   386  	return au
   387  }
   388  
   389  // AddCapacity adds i to the "capacity" field.
   390  func (au *AlertUpdate) AddCapacity(i int32) *AlertUpdate {
   391  	au.mutation.AddCapacity(i)
   392  	return au
   393  }
   394  
   395  // ClearCapacity clears the value of the "capacity" field.
   396  func (au *AlertUpdate) ClearCapacity() *AlertUpdate {
   397  	au.mutation.ClearCapacity()
   398  	return au
   399  }
   400  
   401  // SetLeakSpeed sets the "leakSpeed" field.
   402  func (au *AlertUpdate) SetLeakSpeed(s string) *AlertUpdate {
   403  	au.mutation.SetLeakSpeed(s)
   404  	return au
   405  }
   406  
   407  // SetNillableLeakSpeed sets the "leakSpeed" field if the given value is not nil.
   408  func (au *AlertUpdate) SetNillableLeakSpeed(s *string) *AlertUpdate {
   409  	if s != nil {
   410  		au.SetLeakSpeed(*s)
   411  	}
   412  	return au
   413  }
   414  
   415  // ClearLeakSpeed clears the value of the "leakSpeed" field.
   416  func (au *AlertUpdate) ClearLeakSpeed() *AlertUpdate {
   417  	au.mutation.ClearLeakSpeed()
   418  	return au
   419  }
   420  
   421  // SetScenarioVersion sets the "scenarioVersion" field.
   422  func (au *AlertUpdate) SetScenarioVersion(s string) *AlertUpdate {
   423  	au.mutation.SetScenarioVersion(s)
   424  	return au
   425  }
   426  
   427  // SetNillableScenarioVersion sets the "scenarioVersion" field if the given value is not nil.
   428  func (au *AlertUpdate) SetNillableScenarioVersion(s *string) *AlertUpdate {
   429  	if s != nil {
   430  		au.SetScenarioVersion(*s)
   431  	}
   432  	return au
   433  }
   434  
   435  // ClearScenarioVersion clears the value of the "scenarioVersion" field.
   436  func (au *AlertUpdate) ClearScenarioVersion() *AlertUpdate {
   437  	au.mutation.ClearScenarioVersion()
   438  	return au
   439  }
   440  
   441  // SetScenarioHash sets the "scenarioHash" field.
   442  func (au *AlertUpdate) SetScenarioHash(s string) *AlertUpdate {
   443  	au.mutation.SetScenarioHash(s)
   444  	return au
   445  }
   446  
   447  // SetNillableScenarioHash sets the "scenarioHash" field if the given value is not nil.
   448  func (au *AlertUpdate) SetNillableScenarioHash(s *string) *AlertUpdate {
   449  	if s != nil {
   450  		au.SetScenarioHash(*s)
   451  	}
   452  	return au
   453  }
   454  
   455  // ClearScenarioHash clears the value of the "scenarioHash" field.
   456  func (au *AlertUpdate) ClearScenarioHash() *AlertUpdate {
   457  	au.mutation.ClearScenarioHash()
   458  	return au
   459  }
   460  
   461  // SetSimulated sets the "simulated" field.
   462  func (au *AlertUpdate) SetSimulated(b bool) *AlertUpdate {
   463  	au.mutation.SetSimulated(b)
   464  	return au
   465  }
   466  
   467  // SetNillableSimulated sets the "simulated" field if the given value is not nil.
   468  func (au *AlertUpdate) SetNillableSimulated(b *bool) *AlertUpdate {
   469  	if b != nil {
   470  		au.SetSimulated(*b)
   471  	}
   472  	return au
   473  }
   474  
   475  // SetUUID sets the "uuid" field.
   476  func (au *AlertUpdate) SetUUID(s string) *AlertUpdate {
   477  	au.mutation.SetUUID(s)
   478  	return au
   479  }
   480  
   481  // SetNillableUUID sets the "uuid" field if the given value is not nil.
   482  func (au *AlertUpdate) SetNillableUUID(s *string) *AlertUpdate {
   483  	if s != nil {
   484  		au.SetUUID(*s)
   485  	}
   486  	return au
   487  }
   488  
   489  // ClearUUID clears the value of the "uuid" field.
   490  func (au *AlertUpdate) ClearUUID() *AlertUpdate {
   491  	au.mutation.ClearUUID()
   492  	return au
   493  }
   494  
   495  // SetOwnerID sets the "owner" edge to the Machine entity by ID.
   496  func (au *AlertUpdate) SetOwnerID(id int) *AlertUpdate {
   497  	au.mutation.SetOwnerID(id)
   498  	return au
   499  }
   500  
   501  // SetNillableOwnerID sets the "owner" edge to the Machine entity by ID if the given value is not nil.
   502  func (au *AlertUpdate) SetNillableOwnerID(id *int) *AlertUpdate {
   503  	if id != nil {
   504  		au = au.SetOwnerID(*id)
   505  	}
   506  	return au
   507  }
   508  
   509  // SetOwner sets the "owner" edge to the Machine entity.
   510  func (au *AlertUpdate) SetOwner(m *Machine) *AlertUpdate {
   511  	return au.SetOwnerID(m.ID)
   512  }
   513  
   514  // AddDecisionIDs adds the "decisions" edge to the Decision entity by IDs.
   515  func (au *AlertUpdate) AddDecisionIDs(ids ...int) *AlertUpdate {
   516  	au.mutation.AddDecisionIDs(ids...)
   517  	return au
   518  }
   519  
   520  // AddDecisions adds the "decisions" edges to the Decision entity.
   521  func (au *AlertUpdate) AddDecisions(d ...*Decision) *AlertUpdate {
   522  	ids := make([]int, len(d))
   523  	for i := range d {
   524  		ids[i] = d[i].ID
   525  	}
   526  	return au.AddDecisionIDs(ids...)
   527  }
   528  
   529  // AddEventIDs adds the "events" edge to the Event entity by IDs.
   530  func (au *AlertUpdate) AddEventIDs(ids ...int) *AlertUpdate {
   531  	au.mutation.AddEventIDs(ids...)
   532  	return au
   533  }
   534  
   535  // AddEvents adds the "events" edges to the Event entity.
   536  func (au *AlertUpdate) AddEvents(e ...*Event) *AlertUpdate {
   537  	ids := make([]int, len(e))
   538  	for i := range e {
   539  		ids[i] = e[i].ID
   540  	}
   541  	return au.AddEventIDs(ids...)
   542  }
   543  
   544  // AddMetaIDs adds the "metas" edge to the Meta entity by IDs.
   545  func (au *AlertUpdate) AddMetaIDs(ids ...int) *AlertUpdate {
   546  	au.mutation.AddMetaIDs(ids...)
   547  	return au
   548  }
   549  
   550  // AddMetas adds the "metas" edges to the Meta entity.
   551  func (au *AlertUpdate) AddMetas(m ...*Meta) *AlertUpdate {
   552  	ids := make([]int, len(m))
   553  	for i := range m {
   554  		ids[i] = m[i].ID
   555  	}
   556  	return au.AddMetaIDs(ids...)
   557  }
   558  
   559  // Mutation returns the AlertMutation object of the builder.
   560  func (au *AlertUpdate) Mutation() *AlertMutation {
   561  	return au.mutation
   562  }
   563  
   564  // ClearOwner clears the "owner" edge to the Machine entity.
   565  func (au *AlertUpdate) ClearOwner() *AlertUpdate {
   566  	au.mutation.ClearOwner()
   567  	return au
   568  }
   569  
   570  // ClearDecisions clears all "decisions" edges to the Decision entity.
   571  func (au *AlertUpdate) ClearDecisions() *AlertUpdate {
   572  	au.mutation.ClearDecisions()
   573  	return au
   574  }
   575  
   576  // RemoveDecisionIDs removes the "decisions" edge to Decision entities by IDs.
   577  func (au *AlertUpdate) RemoveDecisionIDs(ids ...int) *AlertUpdate {
   578  	au.mutation.RemoveDecisionIDs(ids...)
   579  	return au
   580  }
   581  
   582  // RemoveDecisions removes "decisions" edges to Decision entities.
   583  func (au *AlertUpdate) RemoveDecisions(d ...*Decision) *AlertUpdate {
   584  	ids := make([]int, len(d))
   585  	for i := range d {
   586  		ids[i] = d[i].ID
   587  	}
   588  	return au.RemoveDecisionIDs(ids...)
   589  }
   590  
   591  // ClearEvents clears all "events" edges to the Event entity.
   592  func (au *AlertUpdate) ClearEvents() *AlertUpdate {
   593  	au.mutation.ClearEvents()
   594  	return au
   595  }
   596  
   597  // RemoveEventIDs removes the "events" edge to Event entities by IDs.
   598  func (au *AlertUpdate) RemoveEventIDs(ids ...int) *AlertUpdate {
   599  	au.mutation.RemoveEventIDs(ids...)
   600  	return au
   601  }
   602  
   603  // RemoveEvents removes "events" edges to Event entities.
   604  func (au *AlertUpdate) RemoveEvents(e ...*Event) *AlertUpdate {
   605  	ids := make([]int, len(e))
   606  	for i := range e {
   607  		ids[i] = e[i].ID
   608  	}
   609  	return au.RemoveEventIDs(ids...)
   610  }
   611  
   612  // ClearMetas clears all "metas" edges to the Meta entity.
   613  func (au *AlertUpdate) ClearMetas() *AlertUpdate {
   614  	au.mutation.ClearMetas()
   615  	return au
   616  }
   617  
   618  // RemoveMetaIDs removes the "metas" edge to Meta entities by IDs.
   619  func (au *AlertUpdate) RemoveMetaIDs(ids ...int) *AlertUpdate {
   620  	au.mutation.RemoveMetaIDs(ids...)
   621  	return au
   622  }
   623  
   624  // RemoveMetas removes "metas" edges to Meta entities.
   625  func (au *AlertUpdate) RemoveMetas(m ...*Meta) *AlertUpdate {
   626  	ids := make([]int, len(m))
   627  	for i := range m {
   628  		ids[i] = m[i].ID
   629  	}
   630  	return au.RemoveMetaIDs(ids...)
   631  }
   632  
   633  // Save executes the query and returns the number of nodes affected by the update operation.
   634  func (au *AlertUpdate) Save(ctx context.Context) (int, error) {
   635  	au.defaults()
   636  	return withHooks(ctx, au.sqlSave, au.mutation, au.hooks)
   637  }
   638  
   639  // SaveX is like Save, but panics if an error occurs.
   640  func (au *AlertUpdate) SaveX(ctx context.Context) int {
   641  	affected, err := au.Save(ctx)
   642  	if err != nil {
   643  		panic(err)
   644  	}
   645  	return affected
   646  }
   647  
   648  // Exec executes the query.
   649  func (au *AlertUpdate) Exec(ctx context.Context) error {
   650  	_, err := au.Save(ctx)
   651  	return err
   652  }
   653  
   654  // ExecX is like Exec, but panics if an error occurs.
   655  func (au *AlertUpdate) ExecX(ctx context.Context) {
   656  	if err := au.Exec(ctx); err != nil {
   657  		panic(err)
   658  	}
   659  }
   660  
   661  // defaults sets the default values of the builder before save.
   662  func (au *AlertUpdate) defaults() {
   663  	if _, ok := au.mutation.CreatedAt(); !ok && !au.mutation.CreatedAtCleared() {
   664  		v := alert.UpdateDefaultCreatedAt()
   665  		au.mutation.SetCreatedAt(v)
   666  	}
   667  	if _, ok := au.mutation.UpdatedAt(); !ok && !au.mutation.UpdatedAtCleared() {
   668  		v := alert.UpdateDefaultUpdatedAt()
   669  		au.mutation.SetUpdatedAt(v)
   670  	}
   671  }
   672  
   673  func (au *AlertUpdate) sqlSave(ctx context.Context) (n int, err error) {
   674  	_spec := sqlgraph.NewUpdateSpec(alert.Table, alert.Columns, sqlgraph.NewFieldSpec(alert.FieldID, field.TypeInt))
   675  	if ps := au.mutation.predicates; len(ps) > 0 {
   676  		_spec.Predicate = func(selector *sql.Selector) {
   677  			for i := range ps {
   678  				ps[i](selector)
   679  			}
   680  		}
   681  	}
   682  	if value, ok := au.mutation.CreatedAt(); ok {
   683  		_spec.SetField(alert.FieldCreatedAt, field.TypeTime, value)
   684  	}
   685  	if au.mutation.CreatedAtCleared() {
   686  		_spec.ClearField(alert.FieldCreatedAt, field.TypeTime)
   687  	}
   688  	if value, ok := au.mutation.UpdatedAt(); ok {
   689  		_spec.SetField(alert.FieldUpdatedAt, field.TypeTime, value)
   690  	}
   691  	if au.mutation.UpdatedAtCleared() {
   692  		_spec.ClearField(alert.FieldUpdatedAt, field.TypeTime)
   693  	}
   694  	if value, ok := au.mutation.Scenario(); ok {
   695  		_spec.SetField(alert.FieldScenario, field.TypeString, value)
   696  	}
   697  	if value, ok := au.mutation.BucketId(); ok {
   698  		_spec.SetField(alert.FieldBucketId, field.TypeString, value)
   699  	}
   700  	if au.mutation.BucketIdCleared() {
   701  		_spec.ClearField(alert.FieldBucketId, field.TypeString)
   702  	}
   703  	if value, ok := au.mutation.Message(); ok {
   704  		_spec.SetField(alert.FieldMessage, field.TypeString, value)
   705  	}
   706  	if au.mutation.MessageCleared() {
   707  		_spec.ClearField(alert.FieldMessage, field.TypeString)
   708  	}
   709  	if value, ok := au.mutation.EventsCount(); ok {
   710  		_spec.SetField(alert.FieldEventsCount, field.TypeInt32, value)
   711  	}
   712  	if value, ok := au.mutation.AddedEventsCount(); ok {
   713  		_spec.AddField(alert.FieldEventsCount, field.TypeInt32, value)
   714  	}
   715  	if au.mutation.EventsCountCleared() {
   716  		_spec.ClearField(alert.FieldEventsCount, field.TypeInt32)
   717  	}
   718  	if value, ok := au.mutation.StartedAt(); ok {
   719  		_spec.SetField(alert.FieldStartedAt, field.TypeTime, value)
   720  	}
   721  	if au.mutation.StartedAtCleared() {
   722  		_spec.ClearField(alert.FieldStartedAt, field.TypeTime)
   723  	}
   724  	if value, ok := au.mutation.StoppedAt(); ok {
   725  		_spec.SetField(alert.FieldStoppedAt, field.TypeTime, value)
   726  	}
   727  	if au.mutation.StoppedAtCleared() {
   728  		_spec.ClearField(alert.FieldStoppedAt, field.TypeTime)
   729  	}
   730  	if value, ok := au.mutation.SourceIp(); ok {
   731  		_spec.SetField(alert.FieldSourceIp, field.TypeString, value)
   732  	}
   733  	if au.mutation.SourceIpCleared() {
   734  		_spec.ClearField(alert.FieldSourceIp, field.TypeString)
   735  	}
   736  	if value, ok := au.mutation.SourceRange(); ok {
   737  		_spec.SetField(alert.FieldSourceRange, field.TypeString, value)
   738  	}
   739  	if au.mutation.SourceRangeCleared() {
   740  		_spec.ClearField(alert.FieldSourceRange, field.TypeString)
   741  	}
   742  	if value, ok := au.mutation.SourceAsNumber(); ok {
   743  		_spec.SetField(alert.FieldSourceAsNumber, field.TypeString, value)
   744  	}
   745  	if au.mutation.SourceAsNumberCleared() {
   746  		_spec.ClearField(alert.FieldSourceAsNumber, field.TypeString)
   747  	}
   748  	if value, ok := au.mutation.SourceAsName(); ok {
   749  		_spec.SetField(alert.FieldSourceAsName, field.TypeString, value)
   750  	}
   751  	if au.mutation.SourceAsNameCleared() {
   752  		_spec.ClearField(alert.FieldSourceAsName, field.TypeString)
   753  	}
   754  	if value, ok := au.mutation.SourceCountry(); ok {
   755  		_spec.SetField(alert.FieldSourceCountry, field.TypeString, value)
   756  	}
   757  	if au.mutation.SourceCountryCleared() {
   758  		_spec.ClearField(alert.FieldSourceCountry, field.TypeString)
   759  	}
   760  	if value, ok := au.mutation.SourceLatitude(); ok {
   761  		_spec.SetField(alert.FieldSourceLatitude, field.TypeFloat32, value)
   762  	}
   763  	if value, ok := au.mutation.AddedSourceLatitude(); ok {
   764  		_spec.AddField(alert.FieldSourceLatitude, field.TypeFloat32, value)
   765  	}
   766  	if au.mutation.SourceLatitudeCleared() {
   767  		_spec.ClearField(alert.FieldSourceLatitude, field.TypeFloat32)
   768  	}
   769  	if value, ok := au.mutation.SourceLongitude(); ok {
   770  		_spec.SetField(alert.FieldSourceLongitude, field.TypeFloat32, value)
   771  	}
   772  	if value, ok := au.mutation.AddedSourceLongitude(); ok {
   773  		_spec.AddField(alert.FieldSourceLongitude, field.TypeFloat32, value)
   774  	}
   775  	if au.mutation.SourceLongitudeCleared() {
   776  		_spec.ClearField(alert.FieldSourceLongitude, field.TypeFloat32)
   777  	}
   778  	if value, ok := au.mutation.SourceScope(); ok {
   779  		_spec.SetField(alert.FieldSourceScope, field.TypeString, value)
   780  	}
   781  	if au.mutation.SourceScopeCleared() {
   782  		_spec.ClearField(alert.FieldSourceScope, field.TypeString)
   783  	}
   784  	if value, ok := au.mutation.SourceValue(); ok {
   785  		_spec.SetField(alert.FieldSourceValue, field.TypeString, value)
   786  	}
   787  	if au.mutation.SourceValueCleared() {
   788  		_spec.ClearField(alert.FieldSourceValue, field.TypeString)
   789  	}
   790  	if value, ok := au.mutation.Capacity(); ok {
   791  		_spec.SetField(alert.FieldCapacity, field.TypeInt32, value)
   792  	}
   793  	if value, ok := au.mutation.AddedCapacity(); ok {
   794  		_spec.AddField(alert.FieldCapacity, field.TypeInt32, value)
   795  	}
   796  	if au.mutation.CapacityCleared() {
   797  		_spec.ClearField(alert.FieldCapacity, field.TypeInt32)
   798  	}
   799  	if value, ok := au.mutation.LeakSpeed(); ok {
   800  		_spec.SetField(alert.FieldLeakSpeed, field.TypeString, value)
   801  	}
   802  	if au.mutation.LeakSpeedCleared() {
   803  		_spec.ClearField(alert.FieldLeakSpeed, field.TypeString)
   804  	}
   805  	if value, ok := au.mutation.ScenarioVersion(); ok {
   806  		_spec.SetField(alert.FieldScenarioVersion, field.TypeString, value)
   807  	}
   808  	if au.mutation.ScenarioVersionCleared() {
   809  		_spec.ClearField(alert.FieldScenarioVersion, field.TypeString)
   810  	}
   811  	if value, ok := au.mutation.ScenarioHash(); ok {
   812  		_spec.SetField(alert.FieldScenarioHash, field.TypeString, value)
   813  	}
   814  	if au.mutation.ScenarioHashCleared() {
   815  		_spec.ClearField(alert.FieldScenarioHash, field.TypeString)
   816  	}
   817  	if value, ok := au.mutation.Simulated(); ok {
   818  		_spec.SetField(alert.FieldSimulated, field.TypeBool, value)
   819  	}
   820  	if value, ok := au.mutation.UUID(); ok {
   821  		_spec.SetField(alert.FieldUUID, field.TypeString, value)
   822  	}
   823  	if au.mutation.UUIDCleared() {
   824  		_spec.ClearField(alert.FieldUUID, field.TypeString)
   825  	}
   826  	if au.mutation.OwnerCleared() {
   827  		edge := &sqlgraph.EdgeSpec{
   828  			Rel:     sqlgraph.M2O,
   829  			Inverse: true,
   830  			Table:   alert.OwnerTable,
   831  			Columns: []string{alert.OwnerColumn},
   832  			Bidi:    false,
   833  			Target: &sqlgraph.EdgeTarget{
   834  				IDSpec: sqlgraph.NewFieldSpec(machine.FieldID, field.TypeInt),
   835  			},
   836  		}
   837  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
   838  	}
   839  	if nodes := au.mutation.OwnerIDs(); len(nodes) > 0 {
   840  		edge := &sqlgraph.EdgeSpec{
   841  			Rel:     sqlgraph.M2O,
   842  			Inverse: true,
   843  			Table:   alert.OwnerTable,
   844  			Columns: []string{alert.OwnerColumn},
   845  			Bidi:    false,
   846  			Target: &sqlgraph.EdgeTarget{
   847  				IDSpec: sqlgraph.NewFieldSpec(machine.FieldID, field.TypeInt),
   848  			},
   849  		}
   850  		for _, k := range nodes {
   851  			edge.Target.Nodes = append(edge.Target.Nodes, k)
   852  		}
   853  		_spec.Edges.Add = append(_spec.Edges.Add, edge)
   854  	}
   855  	if au.mutation.DecisionsCleared() {
   856  		edge := &sqlgraph.EdgeSpec{
   857  			Rel:     sqlgraph.O2M,
   858  			Inverse: false,
   859  			Table:   alert.DecisionsTable,
   860  			Columns: []string{alert.DecisionsColumn},
   861  			Bidi:    false,
   862  			Target: &sqlgraph.EdgeTarget{
   863  				IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
   864  			},
   865  		}
   866  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
   867  	}
   868  	if nodes := au.mutation.RemovedDecisionsIDs(); len(nodes) > 0 && !au.mutation.DecisionsCleared() {
   869  		edge := &sqlgraph.EdgeSpec{
   870  			Rel:     sqlgraph.O2M,
   871  			Inverse: false,
   872  			Table:   alert.DecisionsTable,
   873  			Columns: []string{alert.DecisionsColumn},
   874  			Bidi:    false,
   875  			Target: &sqlgraph.EdgeTarget{
   876  				IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
   877  			},
   878  		}
   879  		for _, k := range nodes {
   880  			edge.Target.Nodes = append(edge.Target.Nodes, k)
   881  		}
   882  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
   883  	}
   884  	if nodes := au.mutation.DecisionsIDs(); len(nodes) > 0 {
   885  		edge := &sqlgraph.EdgeSpec{
   886  			Rel:     sqlgraph.O2M,
   887  			Inverse: false,
   888  			Table:   alert.DecisionsTable,
   889  			Columns: []string{alert.DecisionsColumn},
   890  			Bidi:    false,
   891  			Target: &sqlgraph.EdgeTarget{
   892  				IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
   893  			},
   894  		}
   895  		for _, k := range nodes {
   896  			edge.Target.Nodes = append(edge.Target.Nodes, k)
   897  		}
   898  		_spec.Edges.Add = append(_spec.Edges.Add, edge)
   899  	}
   900  	if au.mutation.EventsCleared() {
   901  		edge := &sqlgraph.EdgeSpec{
   902  			Rel:     sqlgraph.O2M,
   903  			Inverse: false,
   904  			Table:   alert.EventsTable,
   905  			Columns: []string{alert.EventsColumn},
   906  			Bidi:    false,
   907  			Target: &sqlgraph.EdgeTarget{
   908  				IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
   909  			},
   910  		}
   911  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
   912  	}
   913  	if nodes := au.mutation.RemovedEventsIDs(); len(nodes) > 0 && !au.mutation.EventsCleared() {
   914  		edge := &sqlgraph.EdgeSpec{
   915  			Rel:     sqlgraph.O2M,
   916  			Inverse: false,
   917  			Table:   alert.EventsTable,
   918  			Columns: []string{alert.EventsColumn},
   919  			Bidi:    false,
   920  			Target: &sqlgraph.EdgeTarget{
   921  				IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
   922  			},
   923  		}
   924  		for _, k := range nodes {
   925  			edge.Target.Nodes = append(edge.Target.Nodes, k)
   926  		}
   927  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
   928  	}
   929  	if nodes := au.mutation.EventsIDs(); len(nodes) > 0 {
   930  		edge := &sqlgraph.EdgeSpec{
   931  			Rel:     sqlgraph.O2M,
   932  			Inverse: false,
   933  			Table:   alert.EventsTable,
   934  			Columns: []string{alert.EventsColumn},
   935  			Bidi:    false,
   936  			Target: &sqlgraph.EdgeTarget{
   937  				IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
   938  			},
   939  		}
   940  		for _, k := range nodes {
   941  			edge.Target.Nodes = append(edge.Target.Nodes, k)
   942  		}
   943  		_spec.Edges.Add = append(_spec.Edges.Add, edge)
   944  	}
   945  	if au.mutation.MetasCleared() {
   946  		edge := &sqlgraph.EdgeSpec{
   947  			Rel:     sqlgraph.O2M,
   948  			Inverse: false,
   949  			Table:   alert.MetasTable,
   950  			Columns: []string{alert.MetasColumn},
   951  			Bidi:    false,
   952  			Target: &sqlgraph.EdgeTarget{
   953  				IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
   954  			},
   955  		}
   956  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
   957  	}
   958  	if nodes := au.mutation.RemovedMetasIDs(); len(nodes) > 0 && !au.mutation.MetasCleared() {
   959  		edge := &sqlgraph.EdgeSpec{
   960  			Rel:     sqlgraph.O2M,
   961  			Inverse: false,
   962  			Table:   alert.MetasTable,
   963  			Columns: []string{alert.MetasColumn},
   964  			Bidi:    false,
   965  			Target: &sqlgraph.EdgeTarget{
   966  				IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
   967  			},
   968  		}
   969  		for _, k := range nodes {
   970  			edge.Target.Nodes = append(edge.Target.Nodes, k)
   971  		}
   972  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
   973  	}
   974  	if nodes := au.mutation.MetasIDs(); len(nodes) > 0 {
   975  		edge := &sqlgraph.EdgeSpec{
   976  			Rel:     sqlgraph.O2M,
   977  			Inverse: false,
   978  			Table:   alert.MetasTable,
   979  			Columns: []string{alert.MetasColumn},
   980  			Bidi:    false,
   981  			Target: &sqlgraph.EdgeTarget{
   982  				IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
   983  			},
   984  		}
   985  		for _, k := range nodes {
   986  			edge.Target.Nodes = append(edge.Target.Nodes, k)
   987  		}
   988  		_spec.Edges.Add = append(_spec.Edges.Add, edge)
   989  	}
   990  	if n, err = sqlgraph.UpdateNodes(ctx, au.driver, _spec); err != nil {
   991  		if _, ok := err.(*sqlgraph.NotFoundError); ok {
   992  			err = &NotFoundError{alert.Label}
   993  		} else if sqlgraph.IsConstraintError(err) {
   994  			err = &ConstraintError{msg: err.Error(), wrap: err}
   995  		}
   996  		return 0, err
   997  	}
   998  	au.mutation.done = true
   999  	return n, nil
  1000  }
  1001  
  1002  // AlertUpdateOne is the builder for updating a single Alert entity.
  1003  type AlertUpdateOne struct {
  1004  	config
  1005  	fields   []string
  1006  	hooks    []Hook
  1007  	mutation *AlertMutation
  1008  }
  1009  
  1010  // SetCreatedAt sets the "created_at" field.
  1011  func (auo *AlertUpdateOne) SetCreatedAt(t time.Time) *AlertUpdateOne {
  1012  	auo.mutation.SetCreatedAt(t)
  1013  	return auo
  1014  }
  1015  
  1016  // ClearCreatedAt clears the value of the "created_at" field.
  1017  func (auo *AlertUpdateOne) ClearCreatedAt() *AlertUpdateOne {
  1018  	auo.mutation.ClearCreatedAt()
  1019  	return auo
  1020  }
  1021  
  1022  // SetUpdatedAt sets the "updated_at" field.
  1023  func (auo *AlertUpdateOne) SetUpdatedAt(t time.Time) *AlertUpdateOne {
  1024  	auo.mutation.SetUpdatedAt(t)
  1025  	return auo
  1026  }
  1027  
  1028  // ClearUpdatedAt clears the value of the "updated_at" field.
  1029  func (auo *AlertUpdateOne) ClearUpdatedAt() *AlertUpdateOne {
  1030  	auo.mutation.ClearUpdatedAt()
  1031  	return auo
  1032  }
  1033  
  1034  // SetScenario sets the "scenario" field.
  1035  func (auo *AlertUpdateOne) SetScenario(s string) *AlertUpdateOne {
  1036  	auo.mutation.SetScenario(s)
  1037  	return auo
  1038  }
  1039  
  1040  // SetNillableScenario sets the "scenario" field if the given value is not nil.
  1041  func (auo *AlertUpdateOne) SetNillableScenario(s *string) *AlertUpdateOne {
  1042  	if s != nil {
  1043  		auo.SetScenario(*s)
  1044  	}
  1045  	return auo
  1046  }
  1047  
  1048  // SetBucketId sets the "bucketId" field.
  1049  func (auo *AlertUpdateOne) SetBucketId(s string) *AlertUpdateOne {
  1050  	auo.mutation.SetBucketId(s)
  1051  	return auo
  1052  }
  1053  
  1054  // SetNillableBucketId sets the "bucketId" field if the given value is not nil.
  1055  func (auo *AlertUpdateOne) SetNillableBucketId(s *string) *AlertUpdateOne {
  1056  	if s != nil {
  1057  		auo.SetBucketId(*s)
  1058  	}
  1059  	return auo
  1060  }
  1061  
  1062  // ClearBucketId clears the value of the "bucketId" field.
  1063  func (auo *AlertUpdateOne) ClearBucketId() *AlertUpdateOne {
  1064  	auo.mutation.ClearBucketId()
  1065  	return auo
  1066  }
  1067  
  1068  // SetMessage sets the "message" field.
  1069  func (auo *AlertUpdateOne) SetMessage(s string) *AlertUpdateOne {
  1070  	auo.mutation.SetMessage(s)
  1071  	return auo
  1072  }
  1073  
  1074  // SetNillableMessage sets the "message" field if the given value is not nil.
  1075  func (auo *AlertUpdateOne) SetNillableMessage(s *string) *AlertUpdateOne {
  1076  	if s != nil {
  1077  		auo.SetMessage(*s)
  1078  	}
  1079  	return auo
  1080  }
  1081  
  1082  // ClearMessage clears the value of the "message" field.
  1083  func (auo *AlertUpdateOne) ClearMessage() *AlertUpdateOne {
  1084  	auo.mutation.ClearMessage()
  1085  	return auo
  1086  }
  1087  
  1088  // SetEventsCount sets the "eventsCount" field.
  1089  func (auo *AlertUpdateOne) SetEventsCount(i int32) *AlertUpdateOne {
  1090  	auo.mutation.ResetEventsCount()
  1091  	auo.mutation.SetEventsCount(i)
  1092  	return auo
  1093  }
  1094  
  1095  // SetNillableEventsCount sets the "eventsCount" field if the given value is not nil.
  1096  func (auo *AlertUpdateOne) SetNillableEventsCount(i *int32) *AlertUpdateOne {
  1097  	if i != nil {
  1098  		auo.SetEventsCount(*i)
  1099  	}
  1100  	return auo
  1101  }
  1102  
  1103  // AddEventsCount adds i to the "eventsCount" field.
  1104  func (auo *AlertUpdateOne) AddEventsCount(i int32) *AlertUpdateOne {
  1105  	auo.mutation.AddEventsCount(i)
  1106  	return auo
  1107  }
  1108  
  1109  // ClearEventsCount clears the value of the "eventsCount" field.
  1110  func (auo *AlertUpdateOne) ClearEventsCount() *AlertUpdateOne {
  1111  	auo.mutation.ClearEventsCount()
  1112  	return auo
  1113  }
  1114  
  1115  // SetStartedAt sets the "startedAt" field.
  1116  func (auo *AlertUpdateOne) SetStartedAt(t time.Time) *AlertUpdateOne {
  1117  	auo.mutation.SetStartedAt(t)
  1118  	return auo
  1119  }
  1120  
  1121  // SetNillableStartedAt sets the "startedAt" field if the given value is not nil.
  1122  func (auo *AlertUpdateOne) SetNillableStartedAt(t *time.Time) *AlertUpdateOne {
  1123  	if t != nil {
  1124  		auo.SetStartedAt(*t)
  1125  	}
  1126  	return auo
  1127  }
  1128  
  1129  // ClearStartedAt clears the value of the "startedAt" field.
  1130  func (auo *AlertUpdateOne) ClearStartedAt() *AlertUpdateOne {
  1131  	auo.mutation.ClearStartedAt()
  1132  	return auo
  1133  }
  1134  
  1135  // SetStoppedAt sets the "stoppedAt" field.
  1136  func (auo *AlertUpdateOne) SetStoppedAt(t time.Time) *AlertUpdateOne {
  1137  	auo.mutation.SetStoppedAt(t)
  1138  	return auo
  1139  }
  1140  
  1141  // SetNillableStoppedAt sets the "stoppedAt" field if the given value is not nil.
  1142  func (auo *AlertUpdateOne) SetNillableStoppedAt(t *time.Time) *AlertUpdateOne {
  1143  	if t != nil {
  1144  		auo.SetStoppedAt(*t)
  1145  	}
  1146  	return auo
  1147  }
  1148  
  1149  // ClearStoppedAt clears the value of the "stoppedAt" field.
  1150  func (auo *AlertUpdateOne) ClearStoppedAt() *AlertUpdateOne {
  1151  	auo.mutation.ClearStoppedAt()
  1152  	return auo
  1153  }
  1154  
  1155  // SetSourceIp sets the "sourceIp" field.
  1156  func (auo *AlertUpdateOne) SetSourceIp(s string) *AlertUpdateOne {
  1157  	auo.mutation.SetSourceIp(s)
  1158  	return auo
  1159  }
  1160  
  1161  // SetNillableSourceIp sets the "sourceIp" field if the given value is not nil.
  1162  func (auo *AlertUpdateOne) SetNillableSourceIp(s *string) *AlertUpdateOne {
  1163  	if s != nil {
  1164  		auo.SetSourceIp(*s)
  1165  	}
  1166  	return auo
  1167  }
  1168  
  1169  // ClearSourceIp clears the value of the "sourceIp" field.
  1170  func (auo *AlertUpdateOne) ClearSourceIp() *AlertUpdateOne {
  1171  	auo.mutation.ClearSourceIp()
  1172  	return auo
  1173  }
  1174  
  1175  // SetSourceRange sets the "sourceRange" field.
  1176  func (auo *AlertUpdateOne) SetSourceRange(s string) *AlertUpdateOne {
  1177  	auo.mutation.SetSourceRange(s)
  1178  	return auo
  1179  }
  1180  
  1181  // SetNillableSourceRange sets the "sourceRange" field if the given value is not nil.
  1182  func (auo *AlertUpdateOne) SetNillableSourceRange(s *string) *AlertUpdateOne {
  1183  	if s != nil {
  1184  		auo.SetSourceRange(*s)
  1185  	}
  1186  	return auo
  1187  }
  1188  
  1189  // ClearSourceRange clears the value of the "sourceRange" field.
  1190  func (auo *AlertUpdateOne) ClearSourceRange() *AlertUpdateOne {
  1191  	auo.mutation.ClearSourceRange()
  1192  	return auo
  1193  }
  1194  
  1195  // SetSourceAsNumber sets the "sourceAsNumber" field.
  1196  func (auo *AlertUpdateOne) SetSourceAsNumber(s string) *AlertUpdateOne {
  1197  	auo.mutation.SetSourceAsNumber(s)
  1198  	return auo
  1199  }
  1200  
  1201  // SetNillableSourceAsNumber sets the "sourceAsNumber" field if the given value is not nil.
  1202  func (auo *AlertUpdateOne) SetNillableSourceAsNumber(s *string) *AlertUpdateOne {
  1203  	if s != nil {
  1204  		auo.SetSourceAsNumber(*s)
  1205  	}
  1206  	return auo
  1207  }
  1208  
  1209  // ClearSourceAsNumber clears the value of the "sourceAsNumber" field.
  1210  func (auo *AlertUpdateOne) ClearSourceAsNumber() *AlertUpdateOne {
  1211  	auo.mutation.ClearSourceAsNumber()
  1212  	return auo
  1213  }
  1214  
  1215  // SetSourceAsName sets the "sourceAsName" field.
  1216  func (auo *AlertUpdateOne) SetSourceAsName(s string) *AlertUpdateOne {
  1217  	auo.mutation.SetSourceAsName(s)
  1218  	return auo
  1219  }
  1220  
  1221  // SetNillableSourceAsName sets the "sourceAsName" field if the given value is not nil.
  1222  func (auo *AlertUpdateOne) SetNillableSourceAsName(s *string) *AlertUpdateOne {
  1223  	if s != nil {
  1224  		auo.SetSourceAsName(*s)
  1225  	}
  1226  	return auo
  1227  }
  1228  
  1229  // ClearSourceAsName clears the value of the "sourceAsName" field.
  1230  func (auo *AlertUpdateOne) ClearSourceAsName() *AlertUpdateOne {
  1231  	auo.mutation.ClearSourceAsName()
  1232  	return auo
  1233  }
  1234  
  1235  // SetSourceCountry sets the "sourceCountry" field.
  1236  func (auo *AlertUpdateOne) SetSourceCountry(s string) *AlertUpdateOne {
  1237  	auo.mutation.SetSourceCountry(s)
  1238  	return auo
  1239  }
  1240  
  1241  // SetNillableSourceCountry sets the "sourceCountry" field if the given value is not nil.
  1242  func (auo *AlertUpdateOne) SetNillableSourceCountry(s *string) *AlertUpdateOne {
  1243  	if s != nil {
  1244  		auo.SetSourceCountry(*s)
  1245  	}
  1246  	return auo
  1247  }
  1248  
  1249  // ClearSourceCountry clears the value of the "sourceCountry" field.
  1250  func (auo *AlertUpdateOne) ClearSourceCountry() *AlertUpdateOne {
  1251  	auo.mutation.ClearSourceCountry()
  1252  	return auo
  1253  }
  1254  
  1255  // SetSourceLatitude sets the "sourceLatitude" field.
  1256  func (auo *AlertUpdateOne) SetSourceLatitude(f float32) *AlertUpdateOne {
  1257  	auo.mutation.ResetSourceLatitude()
  1258  	auo.mutation.SetSourceLatitude(f)
  1259  	return auo
  1260  }
  1261  
  1262  // SetNillableSourceLatitude sets the "sourceLatitude" field if the given value is not nil.
  1263  func (auo *AlertUpdateOne) SetNillableSourceLatitude(f *float32) *AlertUpdateOne {
  1264  	if f != nil {
  1265  		auo.SetSourceLatitude(*f)
  1266  	}
  1267  	return auo
  1268  }
  1269  
  1270  // AddSourceLatitude adds f to the "sourceLatitude" field.
  1271  func (auo *AlertUpdateOne) AddSourceLatitude(f float32) *AlertUpdateOne {
  1272  	auo.mutation.AddSourceLatitude(f)
  1273  	return auo
  1274  }
  1275  
  1276  // ClearSourceLatitude clears the value of the "sourceLatitude" field.
  1277  func (auo *AlertUpdateOne) ClearSourceLatitude() *AlertUpdateOne {
  1278  	auo.mutation.ClearSourceLatitude()
  1279  	return auo
  1280  }
  1281  
  1282  // SetSourceLongitude sets the "sourceLongitude" field.
  1283  func (auo *AlertUpdateOne) SetSourceLongitude(f float32) *AlertUpdateOne {
  1284  	auo.mutation.ResetSourceLongitude()
  1285  	auo.mutation.SetSourceLongitude(f)
  1286  	return auo
  1287  }
  1288  
  1289  // SetNillableSourceLongitude sets the "sourceLongitude" field if the given value is not nil.
  1290  func (auo *AlertUpdateOne) SetNillableSourceLongitude(f *float32) *AlertUpdateOne {
  1291  	if f != nil {
  1292  		auo.SetSourceLongitude(*f)
  1293  	}
  1294  	return auo
  1295  }
  1296  
  1297  // AddSourceLongitude adds f to the "sourceLongitude" field.
  1298  func (auo *AlertUpdateOne) AddSourceLongitude(f float32) *AlertUpdateOne {
  1299  	auo.mutation.AddSourceLongitude(f)
  1300  	return auo
  1301  }
  1302  
  1303  // ClearSourceLongitude clears the value of the "sourceLongitude" field.
  1304  func (auo *AlertUpdateOne) ClearSourceLongitude() *AlertUpdateOne {
  1305  	auo.mutation.ClearSourceLongitude()
  1306  	return auo
  1307  }
  1308  
  1309  // SetSourceScope sets the "sourceScope" field.
  1310  func (auo *AlertUpdateOne) SetSourceScope(s string) *AlertUpdateOne {
  1311  	auo.mutation.SetSourceScope(s)
  1312  	return auo
  1313  }
  1314  
  1315  // SetNillableSourceScope sets the "sourceScope" field if the given value is not nil.
  1316  func (auo *AlertUpdateOne) SetNillableSourceScope(s *string) *AlertUpdateOne {
  1317  	if s != nil {
  1318  		auo.SetSourceScope(*s)
  1319  	}
  1320  	return auo
  1321  }
  1322  
  1323  // ClearSourceScope clears the value of the "sourceScope" field.
  1324  func (auo *AlertUpdateOne) ClearSourceScope() *AlertUpdateOne {
  1325  	auo.mutation.ClearSourceScope()
  1326  	return auo
  1327  }
  1328  
  1329  // SetSourceValue sets the "sourceValue" field.
  1330  func (auo *AlertUpdateOne) SetSourceValue(s string) *AlertUpdateOne {
  1331  	auo.mutation.SetSourceValue(s)
  1332  	return auo
  1333  }
  1334  
  1335  // SetNillableSourceValue sets the "sourceValue" field if the given value is not nil.
  1336  func (auo *AlertUpdateOne) SetNillableSourceValue(s *string) *AlertUpdateOne {
  1337  	if s != nil {
  1338  		auo.SetSourceValue(*s)
  1339  	}
  1340  	return auo
  1341  }
  1342  
  1343  // ClearSourceValue clears the value of the "sourceValue" field.
  1344  func (auo *AlertUpdateOne) ClearSourceValue() *AlertUpdateOne {
  1345  	auo.mutation.ClearSourceValue()
  1346  	return auo
  1347  }
  1348  
  1349  // SetCapacity sets the "capacity" field.
  1350  func (auo *AlertUpdateOne) SetCapacity(i int32) *AlertUpdateOne {
  1351  	auo.mutation.ResetCapacity()
  1352  	auo.mutation.SetCapacity(i)
  1353  	return auo
  1354  }
  1355  
  1356  // SetNillableCapacity sets the "capacity" field if the given value is not nil.
  1357  func (auo *AlertUpdateOne) SetNillableCapacity(i *int32) *AlertUpdateOne {
  1358  	if i != nil {
  1359  		auo.SetCapacity(*i)
  1360  	}
  1361  	return auo
  1362  }
  1363  
  1364  // AddCapacity adds i to the "capacity" field.
  1365  func (auo *AlertUpdateOne) AddCapacity(i int32) *AlertUpdateOne {
  1366  	auo.mutation.AddCapacity(i)
  1367  	return auo
  1368  }
  1369  
  1370  // ClearCapacity clears the value of the "capacity" field.
  1371  func (auo *AlertUpdateOne) ClearCapacity() *AlertUpdateOne {
  1372  	auo.mutation.ClearCapacity()
  1373  	return auo
  1374  }
  1375  
  1376  // SetLeakSpeed sets the "leakSpeed" field.
  1377  func (auo *AlertUpdateOne) SetLeakSpeed(s string) *AlertUpdateOne {
  1378  	auo.mutation.SetLeakSpeed(s)
  1379  	return auo
  1380  }
  1381  
  1382  // SetNillableLeakSpeed sets the "leakSpeed" field if the given value is not nil.
  1383  func (auo *AlertUpdateOne) SetNillableLeakSpeed(s *string) *AlertUpdateOne {
  1384  	if s != nil {
  1385  		auo.SetLeakSpeed(*s)
  1386  	}
  1387  	return auo
  1388  }
  1389  
  1390  // ClearLeakSpeed clears the value of the "leakSpeed" field.
  1391  func (auo *AlertUpdateOne) ClearLeakSpeed() *AlertUpdateOne {
  1392  	auo.mutation.ClearLeakSpeed()
  1393  	return auo
  1394  }
  1395  
  1396  // SetScenarioVersion sets the "scenarioVersion" field.
  1397  func (auo *AlertUpdateOne) SetScenarioVersion(s string) *AlertUpdateOne {
  1398  	auo.mutation.SetScenarioVersion(s)
  1399  	return auo
  1400  }
  1401  
  1402  // SetNillableScenarioVersion sets the "scenarioVersion" field if the given value is not nil.
  1403  func (auo *AlertUpdateOne) SetNillableScenarioVersion(s *string) *AlertUpdateOne {
  1404  	if s != nil {
  1405  		auo.SetScenarioVersion(*s)
  1406  	}
  1407  	return auo
  1408  }
  1409  
  1410  // ClearScenarioVersion clears the value of the "scenarioVersion" field.
  1411  func (auo *AlertUpdateOne) ClearScenarioVersion() *AlertUpdateOne {
  1412  	auo.mutation.ClearScenarioVersion()
  1413  	return auo
  1414  }
  1415  
  1416  // SetScenarioHash sets the "scenarioHash" field.
  1417  func (auo *AlertUpdateOne) SetScenarioHash(s string) *AlertUpdateOne {
  1418  	auo.mutation.SetScenarioHash(s)
  1419  	return auo
  1420  }
  1421  
  1422  // SetNillableScenarioHash sets the "scenarioHash" field if the given value is not nil.
  1423  func (auo *AlertUpdateOne) SetNillableScenarioHash(s *string) *AlertUpdateOne {
  1424  	if s != nil {
  1425  		auo.SetScenarioHash(*s)
  1426  	}
  1427  	return auo
  1428  }
  1429  
  1430  // ClearScenarioHash clears the value of the "scenarioHash" field.
  1431  func (auo *AlertUpdateOne) ClearScenarioHash() *AlertUpdateOne {
  1432  	auo.mutation.ClearScenarioHash()
  1433  	return auo
  1434  }
  1435  
  1436  // SetSimulated sets the "simulated" field.
  1437  func (auo *AlertUpdateOne) SetSimulated(b bool) *AlertUpdateOne {
  1438  	auo.mutation.SetSimulated(b)
  1439  	return auo
  1440  }
  1441  
  1442  // SetNillableSimulated sets the "simulated" field if the given value is not nil.
  1443  func (auo *AlertUpdateOne) SetNillableSimulated(b *bool) *AlertUpdateOne {
  1444  	if b != nil {
  1445  		auo.SetSimulated(*b)
  1446  	}
  1447  	return auo
  1448  }
  1449  
  1450  // SetUUID sets the "uuid" field.
  1451  func (auo *AlertUpdateOne) SetUUID(s string) *AlertUpdateOne {
  1452  	auo.mutation.SetUUID(s)
  1453  	return auo
  1454  }
  1455  
  1456  // SetNillableUUID sets the "uuid" field if the given value is not nil.
  1457  func (auo *AlertUpdateOne) SetNillableUUID(s *string) *AlertUpdateOne {
  1458  	if s != nil {
  1459  		auo.SetUUID(*s)
  1460  	}
  1461  	return auo
  1462  }
  1463  
  1464  // ClearUUID clears the value of the "uuid" field.
  1465  func (auo *AlertUpdateOne) ClearUUID() *AlertUpdateOne {
  1466  	auo.mutation.ClearUUID()
  1467  	return auo
  1468  }
  1469  
  1470  // SetOwnerID sets the "owner" edge to the Machine entity by ID.
  1471  func (auo *AlertUpdateOne) SetOwnerID(id int) *AlertUpdateOne {
  1472  	auo.mutation.SetOwnerID(id)
  1473  	return auo
  1474  }
  1475  
  1476  // SetNillableOwnerID sets the "owner" edge to the Machine entity by ID if the given value is not nil.
  1477  func (auo *AlertUpdateOne) SetNillableOwnerID(id *int) *AlertUpdateOne {
  1478  	if id != nil {
  1479  		auo = auo.SetOwnerID(*id)
  1480  	}
  1481  	return auo
  1482  }
  1483  
  1484  // SetOwner sets the "owner" edge to the Machine entity.
  1485  func (auo *AlertUpdateOne) SetOwner(m *Machine) *AlertUpdateOne {
  1486  	return auo.SetOwnerID(m.ID)
  1487  }
  1488  
  1489  // AddDecisionIDs adds the "decisions" edge to the Decision entity by IDs.
  1490  func (auo *AlertUpdateOne) AddDecisionIDs(ids ...int) *AlertUpdateOne {
  1491  	auo.mutation.AddDecisionIDs(ids...)
  1492  	return auo
  1493  }
  1494  
  1495  // AddDecisions adds the "decisions" edges to the Decision entity.
  1496  func (auo *AlertUpdateOne) AddDecisions(d ...*Decision) *AlertUpdateOne {
  1497  	ids := make([]int, len(d))
  1498  	for i := range d {
  1499  		ids[i] = d[i].ID
  1500  	}
  1501  	return auo.AddDecisionIDs(ids...)
  1502  }
  1503  
  1504  // AddEventIDs adds the "events" edge to the Event entity by IDs.
  1505  func (auo *AlertUpdateOne) AddEventIDs(ids ...int) *AlertUpdateOne {
  1506  	auo.mutation.AddEventIDs(ids...)
  1507  	return auo
  1508  }
  1509  
  1510  // AddEvents adds the "events" edges to the Event entity.
  1511  func (auo *AlertUpdateOne) AddEvents(e ...*Event) *AlertUpdateOne {
  1512  	ids := make([]int, len(e))
  1513  	for i := range e {
  1514  		ids[i] = e[i].ID
  1515  	}
  1516  	return auo.AddEventIDs(ids...)
  1517  }
  1518  
  1519  // AddMetaIDs adds the "metas" edge to the Meta entity by IDs.
  1520  func (auo *AlertUpdateOne) AddMetaIDs(ids ...int) *AlertUpdateOne {
  1521  	auo.mutation.AddMetaIDs(ids...)
  1522  	return auo
  1523  }
  1524  
  1525  // AddMetas adds the "metas" edges to the Meta entity.
  1526  func (auo *AlertUpdateOne) AddMetas(m ...*Meta) *AlertUpdateOne {
  1527  	ids := make([]int, len(m))
  1528  	for i := range m {
  1529  		ids[i] = m[i].ID
  1530  	}
  1531  	return auo.AddMetaIDs(ids...)
  1532  }
  1533  
  1534  // Mutation returns the AlertMutation object of the builder.
  1535  func (auo *AlertUpdateOne) Mutation() *AlertMutation {
  1536  	return auo.mutation
  1537  }
  1538  
  1539  // ClearOwner clears the "owner" edge to the Machine entity.
  1540  func (auo *AlertUpdateOne) ClearOwner() *AlertUpdateOne {
  1541  	auo.mutation.ClearOwner()
  1542  	return auo
  1543  }
  1544  
  1545  // ClearDecisions clears all "decisions" edges to the Decision entity.
  1546  func (auo *AlertUpdateOne) ClearDecisions() *AlertUpdateOne {
  1547  	auo.mutation.ClearDecisions()
  1548  	return auo
  1549  }
  1550  
  1551  // RemoveDecisionIDs removes the "decisions" edge to Decision entities by IDs.
  1552  func (auo *AlertUpdateOne) RemoveDecisionIDs(ids ...int) *AlertUpdateOne {
  1553  	auo.mutation.RemoveDecisionIDs(ids...)
  1554  	return auo
  1555  }
  1556  
  1557  // RemoveDecisions removes "decisions" edges to Decision entities.
  1558  func (auo *AlertUpdateOne) RemoveDecisions(d ...*Decision) *AlertUpdateOne {
  1559  	ids := make([]int, len(d))
  1560  	for i := range d {
  1561  		ids[i] = d[i].ID
  1562  	}
  1563  	return auo.RemoveDecisionIDs(ids...)
  1564  }
  1565  
  1566  // ClearEvents clears all "events" edges to the Event entity.
  1567  func (auo *AlertUpdateOne) ClearEvents() *AlertUpdateOne {
  1568  	auo.mutation.ClearEvents()
  1569  	return auo
  1570  }
  1571  
  1572  // RemoveEventIDs removes the "events" edge to Event entities by IDs.
  1573  func (auo *AlertUpdateOne) RemoveEventIDs(ids ...int) *AlertUpdateOne {
  1574  	auo.mutation.RemoveEventIDs(ids...)
  1575  	return auo
  1576  }
  1577  
  1578  // RemoveEvents removes "events" edges to Event entities.
  1579  func (auo *AlertUpdateOne) RemoveEvents(e ...*Event) *AlertUpdateOne {
  1580  	ids := make([]int, len(e))
  1581  	for i := range e {
  1582  		ids[i] = e[i].ID
  1583  	}
  1584  	return auo.RemoveEventIDs(ids...)
  1585  }
  1586  
  1587  // ClearMetas clears all "metas" edges to the Meta entity.
  1588  func (auo *AlertUpdateOne) ClearMetas() *AlertUpdateOne {
  1589  	auo.mutation.ClearMetas()
  1590  	return auo
  1591  }
  1592  
  1593  // RemoveMetaIDs removes the "metas" edge to Meta entities by IDs.
  1594  func (auo *AlertUpdateOne) RemoveMetaIDs(ids ...int) *AlertUpdateOne {
  1595  	auo.mutation.RemoveMetaIDs(ids...)
  1596  	return auo
  1597  }
  1598  
  1599  // RemoveMetas removes "metas" edges to Meta entities.
  1600  func (auo *AlertUpdateOne) RemoveMetas(m ...*Meta) *AlertUpdateOne {
  1601  	ids := make([]int, len(m))
  1602  	for i := range m {
  1603  		ids[i] = m[i].ID
  1604  	}
  1605  	return auo.RemoveMetaIDs(ids...)
  1606  }
  1607  
  1608  // Where appends a list predicates to the AlertUpdate builder.
  1609  func (auo *AlertUpdateOne) Where(ps ...predicate.Alert) *AlertUpdateOne {
  1610  	auo.mutation.Where(ps...)
  1611  	return auo
  1612  }
  1613  
  1614  // Select allows selecting one or more fields (columns) of the returned entity.
  1615  // The default is selecting all fields defined in the entity schema.
  1616  func (auo *AlertUpdateOne) Select(field string, fields ...string) *AlertUpdateOne {
  1617  	auo.fields = append([]string{field}, fields...)
  1618  	return auo
  1619  }
  1620  
  1621  // Save executes the query and returns the updated Alert entity.
  1622  func (auo *AlertUpdateOne) Save(ctx context.Context) (*Alert, error) {
  1623  	auo.defaults()
  1624  	return withHooks(ctx, auo.sqlSave, auo.mutation, auo.hooks)
  1625  }
  1626  
  1627  // SaveX is like Save, but panics if an error occurs.
  1628  func (auo *AlertUpdateOne) SaveX(ctx context.Context) *Alert {
  1629  	node, err := auo.Save(ctx)
  1630  	if err != nil {
  1631  		panic(err)
  1632  	}
  1633  	return node
  1634  }
  1635  
  1636  // Exec executes the query on the entity.
  1637  func (auo *AlertUpdateOne) Exec(ctx context.Context) error {
  1638  	_, err := auo.Save(ctx)
  1639  	return err
  1640  }
  1641  
  1642  // ExecX is like Exec, but panics if an error occurs.
  1643  func (auo *AlertUpdateOne) ExecX(ctx context.Context) {
  1644  	if err := auo.Exec(ctx); err != nil {
  1645  		panic(err)
  1646  	}
  1647  }
  1648  
  1649  // defaults sets the default values of the builder before save.
  1650  func (auo *AlertUpdateOne) defaults() {
  1651  	if _, ok := auo.mutation.CreatedAt(); !ok && !auo.mutation.CreatedAtCleared() {
  1652  		v := alert.UpdateDefaultCreatedAt()
  1653  		auo.mutation.SetCreatedAt(v)
  1654  	}
  1655  	if _, ok := auo.mutation.UpdatedAt(); !ok && !auo.mutation.UpdatedAtCleared() {
  1656  		v := alert.UpdateDefaultUpdatedAt()
  1657  		auo.mutation.SetUpdatedAt(v)
  1658  	}
  1659  }
  1660  
  1661  func (auo *AlertUpdateOne) sqlSave(ctx context.Context) (_node *Alert, err error) {
  1662  	_spec := sqlgraph.NewUpdateSpec(alert.Table, alert.Columns, sqlgraph.NewFieldSpec(alert.FieldID, field.TypeInt))
  1663  	id, ok := auo.mutation.ID()
  1664  	if !ok {
  1665  		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Alert.id" for update`)}
  1666  	}
  1667  	_spec.Node.ID.Value = id
  1668  	if fields := auo.fields; len(fields) > 0 {
  1669  		_spec.Node.Columns = make([]string, 0, len(fields))
  1670  		_spec.Node.Columns = append(_spec.Node.Columns, alert.FieldID)
  1671  		for _, f := range fields {
  1672  			if !alert.ValidColumn(f) {
  1673  				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  1674  			}
  1675  			if f != alert.FieldID {
  1676  				_spec.Node.Columns = append(_spec.Node.Columns, f)
  1677  			}
  1678  		}
  1679  	}
  1680  	if ps := auo.mutation.predicates; len(ps) > 0 {
  1681  		_spec.Predicate = func(selector *sql.Selector) {
  1682  			for i := range ps {
  1683  				ps[i](selector)
  1684  			}
  1685  		}
  1686  	}
  1687  	if value, ok := auo.mutation.CreatedAt(); ok {
  1688  		_spec.SetField(alert.FieldCreatedAt, field.TypeTime, value)
  1689  	}
  1690  	if auo.mutation.CreatedAtCleared() {
  1691  		_spec.ClearField(alert.FieldCreatedAt, field.TypeTime)
  1692  	}
  1693  	if value, ok := auo.mutation.UpdatedAt(); ok {
  1694  		_spec.SetField(alert.FieldUpdatedAt, field.TypeTime, value)
  1695  	}
  1696  	if auo.mutation.UpdatedAtCleared() {
  1697  		_spec.ClearField(alert.FieldUpdatedAt, field.TypeTime)
  1698  	}
  1699  	if value, ok := auo.mutation.Scenario(); ok {
  1700  		_spec.SetField(alert.FieldScenario, field.TypeString, value)
  1701  	}
  1702  	if value, ok := auo.mutation.BucketId(); ok {
  1703  		_spec.SetField(alert.FieldBucketId, field.TypeString, value)
  1704  	}
  1705  	if auo.mutation.BucketIdCleared() {
  1706  		_spec.ClearField(alert.FieldBucketId, field.TypeString)
  1707  	}
  1708  	if value, ok := auo.mutation.Message(); ok {
  1709  		_spec.SetField(alert.FieldMessage, field.TypeString, value)
  1710  	}
  1711  	if auo.mutation.MessageCleared() {
  1712  		_spec.ClearField(alert.FieldMessage, field.TypeString)
  1713  	}
  1714  	if value, ok := auo.mutation.EventsCount(); ok {
  1715  		_spec.SetField(alert.FieldEventsCount, field.TypeInt32, value)
  1716  	}
  1717  	if value, ok := auo.mutation.AddedEventsCount(); ok {
  1718  		_spec.AddField(alert.FieldEventsCount, field.TypeInt32, value)
  1719  	}
  1720  	if auo.mutation.EventsCountCleared() {
  1721  		_spec.ClearField(alert.FieldEventsCount, field.TypeInt32)
  1722  	}
  1723  	if value, ok := auo.mutation.StartedAt(); ok {
  1724  		_spec.SetField(alert.FieldStartedAt, field.TypeTime, value)
  1725  	}
  1726  	if auo.mutation.StartedAtCleared() {
  1727  		_spec.ClearField(alert.FieldStartedAt, field.TypeTime)
  1728  	}
  1729  	if value, ok := auo.mutation.StoppedAt(); ok {
  1730  		_spec.SetField(alert.FieldStoppedAt, field.TypeTime, value)
  1731  	}
  1732  	if auo.mutation.StoppedAtCleared() {
  1733  		_spec.ClearField(alert.FieldStoppedAt, field.TypeTime)
  1734  	}
  1735  	if value, ok := auo.mutation.SourceIp(); ok {
  1736  		_spec.SetField(alert.FieldSourceIp, field.TypeString, value)
  1737  	}
  1738  	if auo.mutation.SourceIpCleared() {
  1739  		_spec.ClearField(alert.FieldSourceIp, field.TypeString)
  1740  	}
  1741  	if value, ok := auo.mutation.SourceRange(); ok {
  1742  		_spec.SetField(alert.FieldSourceRange, field.TypeString, value)
  1743  	}
  1744  	if auo.mutation.SourceRangeCleared() {
  1745  		_spec.ClearField(alert.FieldSourceRange, field.TypeString)
  1746  	}
  1747  	if value, ok := auo.mutation.SourceAsNumber(); ok {
  1748  		_spec.SetField(alert.FieldSourceAsNumber, field.TypeString, value)
  1749  	}
  1750  	if auo.mutation.SourceAsNumberCleared() {
  1751  		_spec.ClearField(alert.FieldSourceAsNumber, field.TypeString)
  1752  	}
  1753  	if value, ok := auo.mutation.SourceAsName(); ok {
  1754  		_spec.SetField(alert.FieldSourceAsName, field.TypeString, value)
  1755  	}
  1756  	if auo.mutation.SourceAsNameCleared() {
  1757  		_spec.ClearField(alert.FieldSourceAsName, field.TypeString)
  1758  	}
  1759  	if value, ok := auo.mutation.SourceCountry(); ok {
  1760  		_spec.SetField(alert.FieldSourceCountry, field.TypeString, value)
  1761  	}
  1762  	if auo.mutation.SourceCountryCleared() {
  1763  		_spec.ClearField(alert.FieldSourceCountry, field.TypeString)
  1764  	}
  1765  	if value, ok := auo.mutation.SourceLatitude(); ok {
  1766  		_spec.SetField(alert.FieldSourceLatitude, field.TypeFloat32, value)
  1767  	}
  1768  	if value, ok := auo.mutation.AddedSourceLatitude(); ok {
  1769  		_spec.AddField(alert.FieldSourceLatitude, field.TypeFloat32, value)
  1770  	}
  1771  	if auo.mutation.SourceLatitudeCleared() {
  1772  		_spec.ClearField(alert.FieldSourceLatitude, field.TypeFloat32)
  1773  	}
  1774  	if value, ok := auo.mutation.SourceLongitude(); ok {
  1775  		_spec.SetField(alert.FieldSourceLongitude, field.TypeFloat32, value)
  1776  	}
  1777  	if value, ok := auo.mutation.AddedSourceLongitude(); ok {
  1778  		_spec.AddField(alert.FieldSourceLongitude, field.TypeFloat32, value)
  1779  	}
  1780  	if auo.mutation.SourceLongitudeCleared() {
  1781  		_spec.ClearField(alert.FieldSourceLongitude, field.TypeFloat32)
  1782  	}
  1783  	if value, ok := auo.mutation.SourceScope(); ok {
  1784  		_spec.SetField(alert.FieldSourceScope, field.TypeString, value)
  1785  	}
  1786  	if auo.mutation.SourceScopeCleared() {
  1787  		_spec.ClearField(alert.FieldSourceScope, field.TypeString)
  1788  	}
  1789  	if value, ok := auo.mutation.SourceValue(); ok {
  1790  		_spec.SetField(alert.FieldSourceValue, field.TypeString, value)
  1791  	}
  1792  	if auo.mutation.SourceValueCleared() {
  1793  		_spec.ClearField(alert.FieldSourceValue, field.TypeString)
  1794  	}
  1795  	if value, ok := auo.mutation.Capacity(); ok {
  1796  		_spec.SetField(alert.FieldCapacity, field.TypeInt32, value)
  1797  	}
  1798  	if value, ok := auo.mutation.AddedCapacity(); ok {
  1799  		_spec.AddField(alert.FieldCapacity, field.TypeInt32, value)
  1800  	}
  1801  	if auo.mutation.CapacityCleared() {
  1802  		_spec.ClearField(alert.FieldCapacity, field.TypeInt32)
  1803  	}
  1804  	if value, ok := auo.mutation.LeakSpeed(); ok {
  1805  		_spec.SetField(alert.FieldLeakSpeed, field.TypeString, value)
  1806  	}
  1807  	if auo.mutation.LeakSpeedCleared() {
  1808  		_spec.ClearField(alert.FieldLeakSpeed, field.TypeString)
  1809  	}
  1810  	if value, ok := auo.mutation.ScenarioVersion(); ok {
  1811  		_spec.SetField(alert.FieldScenarioVersion, field.TypeString, value)
  1812  	}
  1813  	if auo.mutation.ScenarioVersionCleared() {
  1814  		_spec.ClearField(alert.FieldScenarioVersion, field.TypeString)
  1815  	}
  1816  	if value, ok := auo.mutation.ScenarioHash(); ok {
  1817  		_spec.SetField(alert.FieldScenarioHash, field.TypeString, value)
  1818  	}
  1819  	if auo.mutation.ScenarioHashCleared() {
  1820  		_spec.ClearField(alert.FieldScenarioHash, field.TypeString)
  1821  	}
  1822  	if value, ok := auo.mutation.Simulated(); ok {
  1823  		_spec.SetField(alert.FieldSimulated, field.TypeBool, value)
  1824  	}
  1825  	if value, ok := auo.mutation.UUID(); ok {
  1826  		_spec.SetField(alert.FieldUUID, field.TypeString, value)
  1827  	}
  1828  	if auo.mutation.UUIDCleared() {
  1829  		_spec.ClearField(alert.FieldUUID, field.TypeString)
  1830  	}
  1831  	if auo.mutation.OwnerCleared() {
  1832  		edge := &sqlgraph.EdgeSpec{
  1833  			Rel:     sqlgraph.M2O,
  1834  			Inverse: true,
  1835  			Table:   alert.OwnerTable,
  1836  			Columns: []string{alert.OwnerColumn},
  1837  			Bidi:    false,
  1838  			Target: &sqlgraph.EdgeTarget{
  1839  				IDSpec: sqlgraph.NewFieldSpec(machine.FieldID, field.TypeInt),
  1840  			},
  1841  		}
  1842  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1843  	}
  1844  	if nodes := auo.mutation.OwnerIDs(); len(nodes) > 0 {
  1845  		edge := &sqlgraph.EdgeSpec{
  1846  			Rel:     sqlgraph.M2O,
  1847  			Inverse: true,
  1848  			Table:   alert.OwnerTable,
  1849  			Columns: []string{alert.OwnerColumn},
  1850  			Bidi:    false,
  1851  			Target: &sqlgraph.EdgeTarget{
  1852  				IDSpec: sqlgraph.NewFieldSpec(machine.FieldID, field.TypeInt),
  1853  			},
  1854  		}
  1855  		for _, k := range nodes {
  1856  			edge.Target.Nodes = append(edge.Target.Nodes, k)
  1857  		}
  1858  		_spec.Edges.Add = append(_spec.Edges.Add, edge)
  1859  	}
  1860  	if auo.mutation.DecisionsCleared() {
  1861  		edge := &sqlgraph.EdgeSpec{
  1862  			Rel:     sqlgraph.O2M,
  1863  			Inverse: false,
  1864  			Table:   alert.DecisionsTable,
  1865  			Columns: []string{alert.DecisionsColumn},
  1866  			Bidi:    false,
  1867  			Target: &sqlgraph.EdgeTarget{
  1868  				IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
  1869  			},
  1870  		}
  1871  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1872  	}
  1873  	if nodes := auo.mutation.RemovedDecisionsIDs(); len(nodes) > 0 && !auo.mutation.DecisionsCleared() {
  1874  		edge := &sqlgraph.EdgeSpec{
  1875  			Rel:     sqlgraph.O2M,
  1876  			Inverse: false,
  1877  			Table:   alert.DecisionsTable,
  1878  			Columns: []string{alert.DecisionsColumn},
  1879  			Bidi:    false,
  1880  			Target: &sqlgraph.EdgeTarget{
  1881  				IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
  1882  			},
  1883  		}
  1884  		for _, k := range nodes {
  1885  			edge.Target.Nodes = append(edge.Target.Nodes, k)
  1886  		}
  1887  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1888  	}
  1889  	if nodes := auo.mutation.DecisionsIDs(); len(nodes) > 0 {
  1890  		edge := &sqlgraph.EdgeSpec{
  1891  			Rel:     sqlgraph.O2M,
  1892  			Inverse: false,
  1893  			Table:   alert.DecisionsTable,
  1894  			Columns: []string{alert.DecisionsColumn},
  1895  			Bidi:    false,
  1896  			Target: &sqlgraph.EdgeTarget{
  1897  				IDSpec: sqlgraph.NewFieldSpec(decision.FieldID, field.TypeInt),
  1898  			},
  1899  		}
  1900  		for _, k := range nodes {
  1901  			edge.Target.Nodes = append(edge.Target.Nodes, k)
  1902  		}
  1903  		_spec.Edges.Add = append(_spec.Edges.Add, edge)
  1904  	}
  1905  	if auo.mutation.EventsCleared() {
  1906  		edge := &sqlgraph.EdgeSpec{
  1907  			Rel:     sqlgraph.O2M,
  1908  			Inverse: false,
  1909  			Table:   alert.EventsTable,
  1910  			Columns: []string{alert.EventsColumn},
  1911  			Bidi:    false,
  1912  			Target: &sqlgraph.EdgeTarget{
  1913  				IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
  1914  			},
  1915  		}
  1916  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1917  	}
  1918  	if nodes := auo.mutation.RemovedEventsIDs(); len(nodes) > 0 && !auo.mutation.EventsCleared() {
  1919  		edge := &sqlgraph.EdgeSpec{
  1920  			Rel:     sqlgraph.O2M,
  1921  			Inverse: false,
  1922  			Table:   alert.EventsTable,
  1923  			Columns: []string{alert.EventsColumn},
  1924  			Bidi:    false,
  1925  			Target: &sqlgraph.EdgeTarget{
  1926  				IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
  1927  			},
  1928  		}
  1929  		for _, k := range nodes {
  1930  			edge.Target.Nodes = append(edge.Target.Nodes, k)
  1931  		}
  1932  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1933  	}
  1934  	if nodes := auo.mutation.EventsIDs(); len(nodes) > 0 {
  1935  		edge := &sqlgraph.EdgeSpec{
  1936  			Rel:     sqlgraph.O2M,
  1937  			Inverse: false,
  1938  			Table:   alert.EventsTable,
  1939  			Columns: []string{alert.EventsColumn},
  1940  			Bidi:    false,
  1941  			Target: &sqlgraph.EdgeTarget{
  1942  				IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt),
  1943  			},
  1944  		}
  1945  		for _, k := range nodes {
  1946  			edge.Target.Nodes = append(edge.Target.Nodes, k)
  1947  		}
  1948  		_spec.Edges.Add = append(_spec.Edges.Add, edge)
  1949  	}
  1950  	if auo.mutation.MetasCleared() {
  1951  		edge := &sqlgraph.EdgeSpec{
  1952  			Rel:     sqlgraph.O2M,
  1953  			Inverse: false,
  1954  			Table:   alert.MetasTable,
  1955  			Columns: []string{alert.MetasColumn},
  1956  			Bidi:    false,
  1957  			Target: &sqlgraph.EdgeTarget{
  1958  				IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
  1959  			},
  1960  		}
  1961  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1962  	}
  1963  	if nodes := auo.mutation.RemovedMetasIDs(); len(nodes) > 0 && !auo.mutation.MetasCleared() {
  1964  		edge := &sqlgraph.EdgeSpec{
  1965  			Rel:     sqlgraph.O2M,
  1966  			Inverse: false,
  1967  			Table:   alert.MetasTable,
  1968  			Columns: []string{alert.MetasColumn},
  1969  			Bidi:    false,
  1970  			Target: &sqlgraph.EdgeTarget{
  1971  				IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
  1972  			},
  1973  		}
  1974  		for _, k := range nodes {
  1975  			edge.Target.Nodes = append(edge.Target.Nodes, k)
  1976  		}
  1977  		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1978  	}
  1979  	if nodes := auo.mutation.MetasIDs(); len(nodes) > 0 {
  1980  		edge := &sqlgraph.EdgeSpec{
  1981  			Rel:     sqlgraph.O2M,
  1982  			Inverse: false,
  1983  			Table:   alert.MetasTable,
  1984  			Columns: []string{alert.MetasColumn},
  1985  			Bidi:    false,
  1986  			Target: &sqlgraph.EdgeTarget{
  1987  				IDSpec: sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt),
  1988  			},
  1989  		}
  1990  		for _, k := range nodes {
  1991  			edge.Target.Nodes = append(edge.Target.Nodes, k)
  1992  		}
  1993  		_spec.Edges.Add = append(_spec.Edges.Add, edge)
  1994  	}
  1995  	_node = &Alert{config: auo.config}
  1996  	_spec.Assign = _node.assignValues
  1997  	_spec.ScanValues = _node.scanValues
  1998  	if err = sqlgraph.UpdateNode(ctx, auo.driver, _spec); err != nil {
  1999  		if _, ok := err.(*sqlgraph.NotFoundError); ok {
  2000  			err = &NotFoundError{alert.Label}
  2001  		} else if sqlgraph.IsConstraintError(err) {
  2002  			err = &ConstraintError{msg: err.Error(), wrap: err}
  2003  		}
  2004  		return nil, err
  2005  	}
  2006  	auo.mutation.done = true
  2007  	return _node, nil
  2008  }