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