bitbucket.org/Aishee/synsec@v0.0.0-20210414005726-236fc01a153d/pkg/database/ent/mutation.go (about)

     1  // Code generated by entc, DO NOT EDIT.
     2  
     3  package ent
     4  
     5  import (
     6  	"context"
     7  	"fmt"
     8  	"sync"
     9  	"time"
    10  
    11  	"bitbucket.org/Aishee/synsec/pkg/database/ent/alert"
    12  	"bitbucket.org/Aishee/synsec/pkg/database/ent/bouncer"
    13  	"bitbucket.org/Aishee/synsec/pkg/database/ent/decision"
    14  	"bitbucket.org/Aishee/synsec/pkg/database/ent/event"
    15  	"bitbucket.org/Aishee/synsec/pkg/database/ent/machine"
    16  	"bitbucket.org/Aishee/synsec/pkg/database/ent/meta"
    17  	"bitbucket.org/Aishee/synsec/pkg/database/ent/predicate"
    18  
    19  	"entgo.io/ent"
    20  )
    21  
    22  const (
    23  	// Operation types.
    24  	OpCreate    = ent.OpCreate
    25  	OpDelete    = ent.OpDelete
    26  	OpDeleteOne = ent.OpDeleteOne
    27  	OpUpdate    = ent.OpUpdate
    28  	OpUpdateOne = ent.OpUpdateOne
    29  
    30  	// Node types.
    31  	TypeAlert    = "Alert"
    32  	TypeBouncer  = "Bouncer"
    33  	TypeDecision = "Decision"
    34  	TypeEvent    = "Event"
    35  	TypeMachine  = "Machine"
    36  	TypeMeta     = "Meta"
    37  )
    38  
    39  // AlertMutation represents an operation that mutates the Alert nodes in the graph.
    40  type AlertMutation struct {
    41  	config
    42  	op                 Op
    43  	typ                string
    44  	id                 *int
    45  	created_at         *time.Time
    46  	updated_at         *time.Time
    47  	scenario           *string
    48  	bucketId           *string
    49  	message            *string
    50  	eventsCount        *int32
    51  	addeventsCount     *int32
    52  	startedAt          *time.Time
    53  	stoppedAt          *time.Time
    54  	sourceIp           *string
    55  	sourceRange        *string
    56  	sourceAsNumber     *string
    57  	sourceAsName       *string
    58  	sourceCountry      *string
    59  	sourceLatitude     *float32
    60  	addsourceLatitude  *float32
    61  	sourceLongitude    *float32
    62  	addsourceLongitude *float32
    63  	sourceScope        *string
    64  	sourceValue        *string
    65  	capacity           *int32
    66  	addcapacity        *int32
    67  	leakSpeed          *string
    68  	scenarioVersion    *string
    69  	scenarioHash       *string
    70  	simulated          *bool
    71  	clearedFields      map[string]struct{}
    72  	owner              *int
    73  	clearedowner       bool
    74  	decisions          map[int]struct{}
    75  	removeddecisions   map[int]struct{}
    76  	cleareddecisions   bool
    77  	events             map[int]struct{}
    78  	removedevents      map[int]struct{}
    79  	clearedevents      bool
    80  	metas              map[int]struct{}
    81  	removedmetas       map[int]struct{}
    82  	clearedmetas       bool
    83  	done               bool
    84  	oldValue           func(context.Context) (*Alert, error)
    85  	predicates         []predicate.Alert
    86  }
    87  
    88  var _ ent.Mutation = (*AlertMutation)(nil)
    89  
    90  // alertOption allows management of the mutation configuration using functional options.
    91  type alertOption func(*AlertMutation)
    92  
    93  // newAlertMutation creates new mutation for the Alert entity.
    94  func newAlertMutation(c config, op Op, opts ...alertOption) *AlertMutation {
    95  	m := &AlertMutation{
    96  		config:        c,
    97  		op:            op,
    98  		typ:           TypeAlert,
    99  		clearedFields: make(map[string]struct{}),
   100  	}
   101  	for _, opt := range opts {
   102  		opt(m)
   103  	}
   104  	return m
   105  }
   106  
   107  // withAlertID sets the ID field of the mutation.
   108  func withAlertID(id int) alertOption {
   109  	return func(m *AlertMutation) {
   110  		var (
   111  			err   error
   112  			once  sync.Once
   113  			value *Alert
   114  		)
   115  		m.oldValue = func(ctx context.Context) (*Alert, error) {
   116  			once.Do(func() {
   117  				if m.done {
   118  					err = fmt.Errorf("querying old values post mutation is not allowed")
   119  				} else {
   120  					value, err = m.Client().Alert.Get(ctx, id)
   121  				}
   122  			})
   123  			return value, err
   124  		}
   125  		m.id = &id
   126  	}
   127  }
   128  
   129  // withAlert sets the old Alert of the mutation.
   130  func withAlert(node *Alert) alertOption {
   131  	return func(m *AlertMutation) {
   132  		m.oldValue = func(context.Context) (*Alert, error) {
   133  			return node, nil
   134  		}
   135  		m.id = &node.ID
   136  	}
   137  }
   138  
   139  // Client returns a new `ent.Client` from the mutation. If the mutation was
   140  // executed in a transaction (ent.Tx), a transactional client is returned.
   141  func (m AlertMutation) Client() *Client {
   142  	client := &Client{config: m.config}
   143  	client.init()
   144  	return client
   145  }
   146  
   147  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
   148  // it returns an error otherwise.
   149  func (m AlertMutation) Tx() (*Tx, error) {
   150  	if _, ok := m.driver.(*txDriver); !ok {
   151  		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
   152  	}
   153  	tx := &Tx{config: m.config}
   154  	tx.init()
   155  	return tx, nil
   156  }
   157  
   158  // ID returns the ID value in the mutation. Note that the ID
   159  // is only available if it was provided to the builder.
   160  func (m *AlertMutation) ID() (id int, exists bool) {
   161  	if m.id == nil {
   162  		return
   163  	}
   164  	return *m.id, true
   165  }
   166  
   167  // SetCreatedAt sets the "created_at" field.
   168  func (m *AlertMutation) SetCreatedAt(t time.Time) {
   169  	m.created_at = &t
   170  }
   171  
   172  // CreatedAt returns the value of the "created_at" field in the mutation.
   173  func (m *AlertMutation) CreatedAt() (r time.Time, exists bool) {
   174  	v := m.created_at
   175  	if v == nil {
   176  		return
   177  	}
   178  	return *v, true
   179  }
   180  
   181  // OldCreatedAt returns the old "created_at" field's value of the Alert entity.
   182  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   183  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   184  func (m *AlertMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
   185  	if !m.op.Is(OpUpdateOne) {
   186  		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
   187  	}
   188  	if m.id == nil || m.oldValue == nil {
   189  		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
   190  	}
   191  	oldValue, err := m.oldValue(ctx)
   192  	if err != nil {
   193  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
   194  	}
   195  	return oldValue.CreatedAt, nil
   196  }
   197  
   198  // ResetCreatedAt resets all changes to the "created_at" field.
   199  func (m *AlertMutation) ResetCreatedAt() {
   200  	m.created_at = nil
   201  }
   202  
   203  // SetUpdatedAt sets the "updated_at" field.
   204  func (m *AlertMutation) SetUpdatedAt(t time.Time) {
   205  	m.updated_at = &t
   206  }
   207  
   208  // UpdatedAt returns the value of the "updated_at" field in the mutation.
   209  func (m *AlertMutation) UpdatedAt() (r time.Time, exists bool) {
   210  	v := m.updated_at
   211  	if v == nil {
   212  		return
   213  	}
   214  	return *v, true
   215  }
   216  
   217  // OldUpdatedAt returns the old "updated_at" field's value of the Alert entity.
   218  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   219  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   220  func (m *AlertMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
   221  	if !m.op.Is(OpUpdateOne) {
   222  		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
   223  	}
   224  	if m.id == nil || m.oldValue == nil {
   225  		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
   226  	}
   227  	oldValue, err := m.oldValue(ctx)
   228  	if err != nil {
   229  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
   230  	}
   231  	return oldValue.UpdatedAt, nil
   232  }
   233  
   234  // ResetUpdatedAt resets all changes to the "updated_at" field.
   235  func (m *AlertMutation) ResetUpdatedAt() {
   236  	m.updated_at = nil
   237  }
   238  
   239  // SetScenario sets the "scenario" field.
   240  func (m *AlertMutation) SetScenario(s string) {
   241  	m.scenario = &s
   242  }
   243  
   244  // Scenario returns the value of the "scenario" field in the mutation.
   245  func (m *AlertMutation) Scenario() (r string, exists bool) {
   246  	v := m.scenario
   247  	if v == nil {
   248  		return
   249  	}
   250  	return *v, true
   251  }
   252  
   253  // OldScenario returns the old "scenario" field's value of the Alert entity.
   254  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   255  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   256  func (m *AlertMutation) OldScenario(ctx context.Context) (v string, err error) {
   257  	if !m.op.Is(OpUpdateOne) {
   258  		return v, fmt.Errorf("OldScenario is only allowed on UpdateOne operations")
   259  	}
   260  	if m.id == nil || m.oldValue == nil {
   261  		return v, fmt.Errorf("OldScenario requires an ID field in the mutation")
   262  	}
   263  	oldValue, err := m.oldValue(ctx)
   264  	if err != nil {
   265  		return v, fmt.Errorf("querying old value for OldScenario: %w", err)
   266  	}
   267  	return oldValue.Scenario, nil
   268  }
   269  
   270  // ResetScenario resets all changes to the "scenario" field.
   271  func (m *AlertMutation) ResetScenario() {
   272  	m.scenario = nil
   273  }
   274  
   275  // SetBucketId sets the "bucketId" field.
   276  func (m *AlertMutation) SetBucketId(s string) {
   277  	m.bucketId = &s
   278  }
   279  
   280  // BucketId returns the value of the "bucketId" field in the mutation.
   281  func (m *AlertMutation) BucketId() (r string, exists bool) {
   282  	v := m.bucketId
   283  	if v == nil {
   284  		return
   285  	}
   286  	return *v, true
   287  }
   288  
   289  // OldBucketId returns the old "bucketId" field's value of the Alert entity.
   290  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   291  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   292  func (m *AlertMutation) OldBucketId(ctx context.Context) (v string, err error) {
   293  	if !m.op.Is(OpUpdateOne) {
   294  		return v, fmt.Errorf("OldBucketId is only allowed on UpdateOne operations")
   295  	}
   296  	if m.id == nil || m.oldValue == nil {
   297  		return v, fmt.Errorf("OldBucketId requires an ID field in the mutation")
   298  	}
   299  	oldValue, err := m.oldValue(ctx)
   300  	if err != nil {
   301  		return v, fmt.Errorf("querying old value for OldBucketId: %w", err)
   302  	}
   303  	return oldValue.BucketId, nil
   304  }
   305  
   306  // ClearBucketId clears the value of the "bucketId" field.
   307  func (m *AlertMutation) ClearBucketId() {
   308  	m.bucketId = nil
   309  	m.clearedFields[alert.FieldBucketId] = struct{}{}
   310  }
   311  
   312  // BucketIdCleared returns if the "bucketId" field was cleared in this mutation.
   313  func (m *AlertMutation) BucketIdCleared() bool {
   314  	_, ok := m.clearedFields[alert.FieldBucketId]
   315  	return ok
   316  }
   317  
   318  // ResetBucketId resets all changes to the "bucketId" field.
   319  func (m *AlertMutation) ResetBucketId() {
   320  	m.bucketId = nil
   321  	delete(m.clearedFields, alert.FieldBucketId)
   322  }
   323  
   324  // SetMessage sets the "message" field.
   325  func (m *AlertMutation) SetMessage(s string) {
   326  	m.message = &s
   327  }
   328  
   329  // Message returns the value of the "message" field in the mutation.
   330  func (m *AlertMutation) Message() (r string, exists bool) {
   331  	v := m.message
   332  	if v == nil {
   333  		return
   334  	}
   335  	return *v, true
   336  }
   337  
   338  // OldMessage returns the old "message" field's value of the Alert entity.
   339  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   340  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   341  func (m *AlertMutation) OldMessage(ctx context.Context) (v string, err error) {
   342  	if !m.op.Is(OpUpdateOne) {
   343  		return v, fmt.Errorf("OldMessage is only allowed on UpdateOne operations")
   344  	}
   345  	if m.id == nil || m.oldValue == nil {
   346  		return v, fmt.Errorf("OldMessage requires an ID field in the mutation")
   347  	}
   348  	oldValue, err := m.oldValue(ctx)
   349  	if err != nil {
   350  		return v, fmt.Errorf("querying old value for OldMessage: %w", err)
   351  	}
   352  	return oldValue.Message, nil
   353  }
   354  
   355  // ClearMessage clears the value of the "message" field.
   356  func (m *AlertMutation) ClearMessage() {
   357  	m.message = nil
   358  	m.clearedFields[alert.FieldMessage] = struct{}{}
   359  }
   360  
   361  // MessageCleared returns if the "message" field was cleared in this mutation.
   362  func (m *AlertMutation) MessageCleared() bool {
   363  	_, ok := m.clearedFields[alert.FieldMessage]
   364  	return ok
   365  }
   366  
   367  // ResetMessage resets all changes to the "message" field.
   368  func (m *AlertMutation) ResetMessage() {
   369  	m.message = nil
   370  	delete(m.clearedFields, alert.FieldMessage)
   371  }
   372  
   373  // SetEventsCount sets the "eventsCount" field.
   374  func (m *AlertMutation) SetEventsCount(i int32) {
   375  	m.eventsCount = &i
   376  	m.addeventsCount = nil
   377  }
   378  
   379  // EventsCount returns the value of the "eventsCount" field in the mutation.
   380  func (m *AlertMutation) EventsCount() (r int32, exists bool) {
   381  	v := m.eventsCount
   382  	if v == nil {
   383  		return
   384  	}
   385  	return *v, true
   386  }
   387  
   388  // OldEventsCount returns the old "eventsCount" field's value of the Alert entity.
   389  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   390  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   391  func (m *AlertMutation) OldEventsCount(ctx context.Context) (v int32, err error) {
   392  	if !m.op.Is(OpUpdateOne) {
   393  		return v, fmt.Errorf("OldEventsCount is only allowed on UpdateOne operations")
   394  	}
   395  	if m.id == nil || m.oldValue == nil {
   396  		return v, fmt.Errorf("OldEventsCount requires an ID field in the mutation")
   397  	}
   398  	oldValue, err := m.oldValue(ctx)
   399  	if err != nil {
   400  		return v, fmt.Errorf("querying old value for OldEventsCount: %w", err)
   401  	}
   402  	return oldValue.EventsCount, nil
   403  }
   404  
   405  // AddEventsCount adds i to the "eventsCount" field.
   406  func (m *AlertMutation) AddEventsCount(i int32) {
   407  	if m.addeventsCount != nil {
   408  		*m.addeventsCount += i
   409  	} else {
   410  		m.addeventsCount = &i
   411  	}
   412  }
   413  
   414  // AddedEventsCount returns the value that was added to the "eventsCount" field in this mutation.
   415  func (m *AlertMutation) AddedEventsCount() (r int32, exists bool) {
   416  	v := m.addeventsCount
   417  	if v == nil {
   418  		return
   419  	}
   420  	return *v, true
   421  }
   422  
   423  // ClearEventsCount clears the value of the "eventsCount" field.
   424  func (m *AlertMutation) ClearEventsCount() {
   425  	m.eventsCount = nil
   426  	m.addeventsCount = nil
   427  	m.clearedFields[alert.FieldEventsCount] = struct{}{}
   428  }
   429  
   430  // EventsCountCleared returns if the "eventsCount" field was cleared in this mutation.
   431  func (m *AlertMutation) EventsCountCleared() bool {
   432  	_, ok := m.clearedFields[alert.FieldEventsCount]
   433  	return ok
   434  }
   435  
   436  // ResetEventsCount resets all changes to the "eventsCount" field.
   437  func (m *AlertMutation) ResetEventsCount() {
   438  	m.eventsCount = nil
   439  	m.addeventsCount = nil
   440  	delete(m.clearedFields, alert.FieldEventsCount)
   441  }
   442  
   443  // SetStartedAt sets the "startedAt" field.
   444  func (m *AlertMutation) SetStartedAt(t time.Time) {
   445  	m.startedAt = &t
   446  }
   447  
   448  // StartedAt returns the value of the "startedAt" field in the mutation.
   449  func (m *AlertMutation) StartedAt() (r time.Time, exists bool) {
   450  	v := m.startedAt
   451  	if v == nil {
   452  		return
   453  	}
   454  	return *v, true
   455  }
   456  
   457  // OldStartedAt returns the old "startedAt" field's value of the Alert entity.
   458  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   459  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   460  func (m *AlertMutation) OldStartedAt(ctx context.Context) (v time.Time, err error) {
   461  	if !m.op.Is(OpUpdateOne) {
   462  		return v, fmt.Errorf("OldStartedAt is only allowed on UpdateOne operations")
   463  	}
   464  	if m.id == nil || m.oldValue == nil {
   465  		return v, fmt.Errorf("OldStartedAt requires an ID field in the mutation")
   466  	}
   467  	oldValue, err := m.oldValue(ctx)
   468  	if err != nil {
   469  		return v, fmt.Errorf("querying old value for OldStartedAt: %w", err)
   470  	}
   471  	return oldValue.StartedAt, nil
   472  }
   473  
   474  // ClearStartedAt clears the value of the "startedAt" field.
   475  func (m *AlertMutation) ClearStartedAt() {
   476  	m.startedAt = nil
   477  	m.clearedFields[alert.FieldStartedAt] = struct{}{}
   478  }
   479  
   480  // StartedAtCleared returns if the "startedAt" field was cleared in this mutation.
   481  func (m *AlertMutation) StartedAtCleared() bool {
   482  	_, ok := m.clearedFields[alert.FieldStartedAt]
   483  	return ok
   484  }
   485  
   486  // ResetStartedAt resets all changes to the "startedAt" field.
   487  func (m *AlertMutation) ResetStartedAt() {
   488  	m.startedAt = nil
   489  	delete(m.clearedFields, alert.FieldStartedAt)
   490  }
   491  
   492  // SetStoppedAt sets the "stoppedAt" field.
   493  func (m *AlertMutation) SetStoppedAt(t time.Time) {
   494  	m.stoppedAt = &t
   495  }
   496  
   497  // StoppedAt returns the value of the "stoppedAt" field in the mutation.
   498  func (m *AlertMutation) StoppedAt() (r time.Time, exists bool) {
   499  	v := m.stoppedAt
   500  	if v == nil {
   501  		return
   502  	}
   503  	return *v, true
   504  }
   505  
   506  // OldStoppedAt returns the old "stoppedAt" field's value of the Alert entity.
   507  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   508  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   509  func (m *AlertMutation) OldStoppedAt(ctx context.Context) (v time.Time, err error) {
   510  	if !m.op.Is(OpUpdateOne) {
   511  		return v, fmt.Errorf("OldStoppedAt is only allowed on UpdateOne operations")
   512  	}
   513  	if m.id == nil || m.oldValue == nil {
   514  		return v, fmt.Errorf("OldStoppedAt requires an ID field in the mutation")
   515  	}
   516  	oldValue, err := m.oldValue(ctx)
   517  	if err != nil {
   518  		return v, fmt.Errorf("querying old value for OldStoppedAt: %w", err)
   519  	}
   520  	return oldValue.StoppedAt, nil
   521  }
   522  
   523  // ClearStoppedAt clears the value of the "stoppedAt" field.
   524  func (m *AlertMutation) ClearStoppedAt() {
   525  	m.stoppedAt = nil
   526  	m.clearedFields[alert.FieldStoppedAt] = struct{}{}
   527  }
   528  
   529  // StoppedAtCleared returns if the "stoppedAt" field was cleared in this mutation.
   530  func (m *AlertMutation) StoppedAtCleared() bool {
   531  	_, ok := m.clearedFields[alert.FieldStoppedAt]
   532  	return ok
   533  }
   534  
   535  // ResetStoppedAt resets all changes to the "stoppedAt" field.
   536  func (m *AlertMutation) ResetStoppedAt() {
   537  	m.stoppedAt = nil
   538  	delete(m.clearedFields, alert.FieldStoppedAt)
   539  }
   540  
   541  // SetSourceIp sets the "sourceIp" field.
   542  func (m *AlertMutation) SetSourceIp(s string) {
   543  	m.sourceIp = &s
   544  }
   545  
   546  // SourceIp returns the value of the "sourceIp" field in the mutation.
   547  func (m *AlertMutation) SourceIp() (r string, exists bool) {
   548  	v := m.sourceIp
   549  	if v == nil {
   550  		return
   551  	}
   552  	return *v, true
   553  }
   554  
   555  // OldSourceIp returns the old "sourceIp" field's value of the Alert entity.
   556  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   557  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   558  func (m *AlertMutation) OldSourceIp(ctx context.Context) (v string, err error) {
   559  	if !m.op.Is(OpUpdateOne) {
   560  		return v, fmt.Errorf("OldSourceIp is only allowed on UpdateOne operations")
   561  	}
   562  	if m.id == nil || m.oldValue == nil {
   563  		return v, fmt.Errorf("OldSourceIp requires an ID field in the mutation")
   564  	}
   565  	oldValue, err := m.oldValue(ctx)
   566  	if err != nil {
   567  		return v, fmt.Errorf("querying old value for OldSourceIp: %w", err)
   568  	}
   569  	return oldValue.SourceIp, nil
   570  }
   571  
   572  // ClearSourceIp clears the value of the "sourceIp" field.
   573  func (m *AlertMutation) ClearSourceIp() {
   574  	m.sourceIp = nil
   575  	m.clearedFields[alert.FieldSourceIp] = struct{}{}
   576  }
   577  
   578  // SourceIpCleared returns if the "sourceIp" field was cleared in this mutation.
   579  func (m *AlertMutation) SourceIpCleared() bool {
   580  	_, ok := m.clearedFields[alert.FieldSourceIp]
   581  	return ok
   582  }
   583  
   584  // ResetSourceIp resets all changes to the "sourceIp" field.
   585  func (m *AlertMutation) ResetSourceIp() {
   586  	m.sourceIp = nil
   587  	delete(m.clearedFields, alert.FieldSourceIp)
   588  }
   589  
   590  // SetSourceRange sets the "sourceRange" field.
   591  func (m *AlertMutation) SetSourceRange(s string) {
   592  	m.sourceRange = &s
   593  }
   594  
   595  // SourceRange returns the value of the "sourceRange" field in the mutation.
   596  func (m *AlertMutation) SourceRange() (r string, exists bool) {
   597  	v := m.sourceRange
   598  	if v == nil {
   599  		return
   600  	}
   601  	return *v, true
   602  }
   603  
   604  // OldSourceRange returns the old "sourceRange" field's value of the Alert entity.
   605  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   606  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   607  func (m *AlertMutation) OldSourceRange(ctx context.Context) (v string, err error) {
   608  	if !m.op.Is(OpUpdateOne) {
   609  		return v, fmt.Errorf("OldSourceRange is only allowed on UpdateOne operations")
   610  	}
   611  	if m.id == nil || m.oldValue == nil {
   612  		return v, fmt.Errorf("OldSourceRange requires an ID field in the mutation")
   613  	}
   614  	oldValue, err := m.oldValue(ctx)
   615  	if err != nil {
   616  		return v, fmt.Errorf("querying old value for OldSourceRange: %w", err)
   617  	}
   618  	return oldValue.SourceRange, nil
   619  }
   620  
   621  // ClearSourceRange clears the value of the "sourceRange" field.
   622  func (m *AlertMutation) ClearSourceRange() {
   623  	m.sourceRange = nil
   624  	m.clearedFields[alert.FieldSourceRange] = struct{}{}
   625  }
   626  
   627  // SourceRangeCleared returns if the "sourceRange" field was cleared in this mutation.
   628  func (m *AlertMutation) SourceRangeCleared() bool {
   629  	_, ok := m.clearedFields[alert.FieldSourceRange]
   630  	return ok
   631  }
   632  
   633  // ResetSourceRange resets all changes to the "sourceRange" field.
   634  func (m *AlertMutation) ResetSourceRange() {
   635  	m.sourceRange = nil
   636  	delete(m.clearedFields, alert.FieldSourceRange)
   637  }
   638  
   639  // SetSourceAsNumber sets the "sourceAsNumber" field.
   640  func (m *AlertMutation) SetSourceAsNumber(s string) {
   641  	m.sourceAsNumber = &s
   642  }
   643  
   644  // SourceAsNumber returns the value of the "sourceAsNumber" field in the mutation.
   645  func (m *AlertMutation) SourceAsNumber() (r string, exists bool) {
   646  	v := m.sourceAsNumber
   647  	if v == nil {
   648  		return
   649  	}
   650  	return *v, true
   651  }
   652  
   653  // OldSourceAsNumber returns the old "sourceAsNumber" field's value of the Alert entity.
   654  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   655  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   656  func (m *AlertMutation) OldSourceAsNumber(ctx context.Context) (v string, err error) {
   657  	if !m.op.Is(OpUpdateOne) {
   658  		return v, fmt.Errorf("OldSourceAsNumber is only allowed on UpdateOne operations")
   659  	}
   660  	if m.id == nil || m.oldValue == nil {
   661  		return v, fmt.Errorf("OldSourceAsNumber requires an ID field in the mutation")
   662  	}
   663  	oldValue, err := m.oldValue(ctx)
   664  	if err != nil {
   665  		return v, fmt.Errorf("querying old value for OldSourceAsNumber: %w", err)
   666  	}
   667  	return oldValue.SourceAsNumber, nil
   668  }
   669  
   670  // ClearSourceAsNumber clears the value of the "sourceAsNumber" field.
   671  func (m *AlertMutation) ClearSourceAsNumber() {
   672  	m.sourceAsNumber = nil
   673  	m.clearedFields[alert.FieldSourceAsNumber] = struct{}{}
   674  }
   675  
   676  // SourceAsNumberCleared returns if the "sourceAsNumber" field was cleared in this mutation.
   677  func (m *AlertMutation) SourceAsNumberCleared() bool {
   678  	_, ok := m.clearedFields[alert.FieldSourceAsNumber]
   679  	return ok
   680  }
   681  
   682  // ResetSourceAsNumber resets all changes to the "sourceAsNumber" field.
   683  func (m *AlertMutation) ResetSourceAsNumber() {
   684  	m.sourceAsNumber = nil
   685  	delete(m.clearedFields, alert.FieldSourceAsNumber)
   686  }
   687  
   688  // SetSourceAsName sets the "sourceAsName" field.
   689  func (m *AlertMutation) SetSourceAsName(s string) {
   690  	m.sourceAsName = &s
   691  }
   692  
   693  // SourceAsName returns the value of the "sourceAsName" field in the mutation.
   694  func (m *AlertMutation) SourceAsName() (r string, exists bool) {
   695  	v := m.sourceAsName
   696  	if v == nil {
   697  		return
   698  	}
   699  	return *v, true
   700  }
   701  
   702  // OldSourceAsName returns the old "sourceAsName" field's value of the Alert entity.
   703  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   704  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   705  func (m *AlertMutation) OldSourceAsName(ctx context.Context) (v string, err error) {
   706  	if !m.op.Is(OpUpdateOne) {
   707  		return v, fmt.Errorf("OldSourceAsName is only allowed on UpdateOne operations")
   708  	}
   709  	if m.id == nil || m.oldValue == nil {
   710  		return v, fmt.Errorf("OldSourceAsName requires an ID field in the mutation")
   711  	}
   712  	oldValue, err := m.oldValue(ctx)
   713  	if err != nil {
   714  		return v, fmt.Errorf("querying old value for OldSourceAsName: %w", err)
   715  	}
   716  	return oldValue.SourceAsName, nil
   717  }
   718  
   719  // ClearSourceAsName clears the value of the "sourceAsName" field.
   720  func (m *AlertMutation) ClearSourceAsName() {
   721  	m.sourceAsName = nil
   722  	m.clearedFields[alert.FieldSourceAsName] = struct{}{}
   723  }
   724  
   725  // SourceAsNameCleared returns if the "sourceAsName" field was cleared in this mutation.
   726  func (m *AlertMutation) SourceAsNameCleared() bool {
   727  	_, ok := m.clearedFields[alert.FieldSourceAsName]
   728  	return ok
   729  }
   730  
   731  // ResetSourceAsName resets all changes to the "sourceAsName" field.
   732  func (m *AlertMutation) ResetSourceAsName() {
   733  	m.sourceAsName = nil
   734  	delete(m.clearedFields, alert.FieldSourceAsName)
   735  }
   736  
   737  // SetSourceCountry sets the "sourceCountry" field.
   738  func (m *AlertMutation) SetSourceCountry(s string) {
   739  	m.sourceCountry = &s
   740  }
   741  
   742  // SourceCountry returns the value of the "sourceCountry" field in the mutation.
   743  func (m *AlertMutation) SourceCountry() (r string, exists bool) {
   744  	v := m.sourceCountry
   745  	if v == nil {
   746  		return
   747  	}
   748  	return *v, true
   749  }
   750  
   751  // OldSourceCountry returns the old "sourceCountry" field's value of the Alert entity.
   752  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   753  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   754  func (m *AlertMutation) OldSourceCountry(ctx context.Context) (v string, err error) {
   755  	if !m.op.Is(OpUpdateOne) {
   756  		return v, fmt.Errorf("OldSourceCountry is only allowed on UpdateOne operations")
   757  	}
   758  	if m.id == nil || m.oldValue == nil {
   759  		return v, fmt.Errorf("OldSourceCountry requires an ID field in the mutation")
   760  	}
   761  	oldValue, err := m.oldValue(ctx)
   762  	if err != nil {
   763  		return v, fmt.Errorf("querying old value for OldSourceCountry: %w", err)
   764  	}
   765  	return oldValue.SourceCountry, nil
   766  }
   767  
   768  // ClearSourceCountry clears the value of the "sourceCountry" field.
   769  func (m *AlertMutation) ClearSourceCountry() {
   770  	m.sourceCountry = nil
   771  	m.clearedFields[alert.FieldSourceCountry] = struct{}{}
   772  }
   773  
   774  // SourceCountryCleared returns if the "sourceCountry" field was cleared in this mutation.
   775  func (m *AlertMutation) SourceCountryCleared() bool {
   776  	_, ok := m.clearedFields[alert.FieldSourceCountry]
   777  	return ok
   778  }
   779  
   780  // ResetSourceCountry resets all changes to the "sourceCountry" field.
   781  func (m *AlertMutation) ResetSourceCountry() {
   782  	m.sourceCountry = nil
   783  	delete(m.clearedFields, alert.FieldSourceCountry)
   784  }
   785  
   786  // SetSourceLatitude sets the "sourceLatitude" field.
   787  func (m *AlertMutation) SetSourceLatitude(f float32) {
   788  	m.sourceLatitude = &f
   789  	m.addsourceLatitude = nil
   790  }
   791  
   792  // SourceLatitude returns the value of the "sourceLatitude" field in the mutation.
   793  func (m *AlertMutation) SourceLatitude() (r float32, exists bool) {
   794  	v := m.sourceLatitude
   795  	if v == nil {
   796  		return
   797  	}
   798  	return *v, true
   799  }
   800  
   801  // OldSourceLatitude returns the old "sourceLatitude" field's value of the Alert entity.
   802  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   803  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   804  func (m *AlertMutation) OldSourceLatitude(ctx context.Context) (v float32, err error) {
   805  	if !m.op.Is(OpUpdateOne) {
   806  		return v, fmt.Errorf("OldSourceLatitude is only allowed on UpdateOne operations")
   807  	}
   808  	if m.id == nil || m.oldValue == nil {
   809  		return v, fmt.Errorf("OldSourceLatitude requires an ID field in the mutation")
   810  	}
   811  	oldValue, err := m.oldValue(ctx)
   812  	if err != nil {
   813  		return v, fmt.Errorf("querying old value for OldSourceLatitude: %w", err)
   814  	}
   815  	return oldValue.SourceLatitude, nil
   816  }
   817  
   818  // AddSourceLatitude adds f to the "sourceLatitude" field.
   819  func (m *AlertMutation) AddSourceLatitude(f float32) {
   820  	if m.addsourceLatitude != nil {
   821  		*m.addsourceLatitude += f
   822  	} else {
   823  		m.addsourceLatitude = &f
   824  	}
   825  }
   826  
   827  // AddedSourceLatitude returns the value that was added to the "sourceLatitude" field in this mutation.
   828  func (m *AlertMutation) AddedSourceLatitude() (r float32, exists bool) {
   829  	v := m.addsourceLatitude
   830  	if v == nil {
   831  		return
   832  	}
   833  	return *v, true
   834  }
   835  
   836  // ClearSourceLatitude clears the value of the "sourceLatitude" field.
   837  func (m *AlertMutation) ClearSourceLatitude() {
   838  	m.sourceLatitude = nil
   839  	m.addsourceLatitude = nil
   840  	m.clearedFields[alert.FieldSourceLatitude] = struct{}{}
   841  }
   842  
   843  // SourceLatitudeCleared returns if the "sourceLatitude" field was cleared in this mutation.
   844  func (m *AlertMutation) SourceLatitudeCleared() bool {
   845  	_, ok := m.clearedFields[alert.FieldSourceLatitude]
   846  	return ok
   847  }
   848  
   849  // ResetSourceLatitude resets all changes to the "sourceLatitude" field.
   850  func (m *AlertMutation) ResetSourceLatitude() {
   851  	m.sourceLatitude = nil
   852  	m.addsourceLatitude = nil
   853  	delete(m.clearedFields, alert.FieldSourceLatitude)
   854  }
   855  
   856  // SetSourceLongitude sets the "sourceLongitude" field.
   857  func (m *AlertMutation) SetSourceLongitude(f float32) {
   858  	m.sourceLongitude = &f
   859  	m.addsourceLongitude = nil
   860  }
   861  
   862  // SourceLongitude returns the value of the "sourceLongitude" field in the mutation.
   863  func (m *AlertMutation) SourceLongitude() (r float32, exists bool) {
   864  	v := m.sourceLongitude
   865  	if v == nil {
   866  		return
   867  	}
   868  	return *v, true
   869  }
   870  
   871  // OldSourceLongitude returns the old "sourceLongitude" field's value of the Alert entity.
   872  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   873  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   874  func (m *AlertMutation) OldSourceLongitude(ctx context.Context) (v float32, err error) {
   875  	if !m.op.Is(OpUpdateOne) {
   876  		return v, fmt.Errorf("OldSourceLongitude is only allowed on UpdateOne operations")
   877  	}
   878  	if m.id == nil || m.oldValue == nil {
   879  		return v, fmt.Errorf("OldSourceLongitude requires an ID field in the mutation")
   880  	}
   881  	oldValue, err := m.oldValue(ctx)
   882  	if err != nil {
   883  		return v, fmt.Errorf("querying old value for OldSourceLongitude: %w", err)
   884  	}
   885  	return oldValue.SourceLongitude, nil
   886  }
   887  
   888  // AddSourceLongitude adds f to the "sourceLongitude" field.
   889  func (m *AlertMutation) AddSourceLongitude(f float32) {
   890  	if m.addsourceLongitude != nil {
   891  		*m.addsourceLongitude += f
   892  	} else {
   893  		m.addsourceLongitude = &f
   894  	}
   895  }
   896  
   897  // AddedSourceLongitude returns the value that was added to the "sourceLongitude" field in this mutation.
   898  func (m *AlertMutation) AddedSourceLongitude() (r float32, exists bool) {
   899  	v := m.addsourceLongitude
   900  	if v == nil {
   901  		return
   902  	}
   903  	return *v, true
   904  }
   905  
   906  // ClearSourceLongitude clears the value of the "sourceLongitude" field.
   907  func (m *AlertMutation) ClearSourceLongitude() {
   908  	m.sourceLongitude = nil
   909  	m.addsourceLongitude = nil
   910  	m.clearedFields[alert.FieldSourceLongitude] = struct{}{}
   911  }
   912  
   913  // SourceLongitudeCleared returns if the "sourceLongitude" field was cleared in this mutation.
   914  func (m *AlertMutation) SourceLongitudeCleared() bool {
   915  	_, ok := m.clearedFields[alert.FieldSourceLongitude]
   916  	return ok
   917  }
   918  
   919  // ResetSourceLongitude resets all changes to the "sourceLongitude" field.
   920  func (m *AlertMutation) ResetSourceLongitude() {
   921  	m.sourceLongitude = nil
   922  	m.addsourceLongitude = nil
   923  	delete(m.clearedFields, alert.FieldSourceLongitude)
   924  }
   925  
   926  // SetSourceScope sets the "sourceScope" field.
   927  func (m *AlertMutation) SetSourceScope(s string) {
   928  	m.sourceScope = &s
   929  }
   930  
   931  // SourceScope returns the value of the "sourceScope" field in the mutation.
   932  func (m *AlertMutation) SourceScope() (r string, exists bool) {
   933  	v := m.sourceScope
   934  	if v == nil {
   935  		return
   936  	}
   937  	return *v, true
   938  }
   939  
   940  // OldSourceScope returns the old "sourceScope" field's value of the Alert entity.
   941  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   942  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   943  func (m *AlertMutation) OldSourceScope(ctx context.Context) (v string, err error) {
   944  	if !m.op.Is(OpUpdateOne) {
   945  		return v, fmt.Errorf("OldSourceScope is only allowed on UpdateOne operations")
   946  	}
   947  	if m.id == nil || m.oldValue == nil {
   948  		return v, fmt.Errorf("OldSourceScope requires an ID field in the mutation")
   949  	}
   950  	oldValue, err := m.oldValue(ctx)
   951  	if err != nil {
   952  		return v, fmt.Errorf("querying old value for OldSourceScope: %w", err)
   953  	}
   954  	return oldValue.SourceScope, nil
   955  }
   956  
   957  // ClearSourceScope clears the value of the "sourceScope" field.
   958  func (m *AlertMutation) ClearSourceScope() {
   959  	m.sourceScope = nil
   960  	m.clearedFields[alert.FieldSourceScope] = struct{}{}
   961  }
   962  
   963  // SourceScopeCleared returns if the "sourceScope" field was cleared in this mutation.
   964  func (m *AlertMutation) SourceScopeCleared() bool {
   965  	_, ok := m.clearedFields[alert.FieldSourceScope]
   966  	return ok
   967  }
   968  
   969  // ResetSourceScope resets all changes to the "sourceScope" field.
   970  func (m *AlertMutation) ResetSourceScope() {
   971  	m.sourceScope = nil
   972  	delete(m.clearedFields, alert.FieldSourceScope)
   973  }
   974  
   975  // SetSourceValue sets the "sourceValue" field.
   976  func (m *AlertMutation) SetSourceValue(s string) {
   977  	m.sourceValue = &s
   978  }
   979  
   980  // SourceValue returns the value of the "sourceValue" field in the mutation.
   981  func (m *AlertMutation) SourceValue() (r string, exists bool) {
   982  	v := m.sourceValue
   983  	if v == nil {
   984  		return
   985  	}
   986  	return *v, true
   987  }
   988  
   989  // OldSourceValue returns the old "sourceValue" field's value of the Alert entity.
   990  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   991  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   992  func (m *AlertMutation) OldSourceValue(ctx context.Context) (v string, err error) {
   993  	if !m.op.Is(OpUpdateOne) {
   994  		return v, fmt.Errorf("OldSourceValue is only allowed on UpdateOne operations")
   995  	}
   996  	if m.id == nil || m.oldValue == nil {
   997  		return v, fmt.Errorf("OldSourceValue requires an ID field in the mutation")
   998  	}
   999  	oldValue, err := m.oldValue(ctx)
  1000  	if err != nil {
  1001  		return v, fmt.Errorf("querying old value for OldSourceValue: %w", err)
  1002  	}
  1003  	return oldValue.SourceValue, nil
  1004  }
  1005  
  1006  // ClearSourceValue clears the value of the "sourceValue" field.
  1007  func (m *AlertMutation) ClearSourceValue() {
  1008  	m.sourceValue = nil
  1009  	m.clearedFields[alert.FieldSourceValue] = struct{}{}
  1010  }
  1011  
  1012  // SourceValueCleared returns if the "sourceValue" field was cleared in this mutation.
  1013  func (m *AlertMutation) SourceValueCleared() bool {
  1014  	_, ok := m.clearedFields[alert.FieldSourceValue]
  1015  	return ok
  1016  }
  1017  
  1018  // ResetSourceValue resets all changes to the "sourceValue" field.
  1019  func (m *AlertMutation) ResetSourceValue() {
  1020  	m.sourceValue = nil
  1021  	delete(m.clearedFields, alert.FieldSourceValue)
  1022  }
  1023  
  1024  // SetCapacity sets the "capacity" field.
  1025  func (m *AlertMutation) SetCapacity(i int32) {
  1026  	m.capacity = &i
  1027  	m.addcapacity = nil
  1028  }
  1029  
  1030  // Capacity returns the value of the "capacity" field in the mutation.
  1031  func (m *AlertMutation) Capacity() (r int32, exists bool) {
  1032  	v := m.capacity
  1033  	if v == nil {
  1034  		return
  1035  	}
  1036  	return *v, true
  1037  }
  1038  
  1039  // OldCapacity returns the old "capacity" field's value of the Alert entity.
  1040  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1041  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1042  func (m *AlertMutation) OldCapacity(ctx context.Context) (v int32, err error) {
  1043  	if !m.op.Is(OpUpdateOne) {
  1044  		return v, fmt.Errorf("OldCapacity is only allowed on UpdateOne operations")
  1045  	}
  1046  	if m.id == nil || m.oldValue == nil {
  1047  		return v, fmt.Errorf("OldCapacity requires an ID field in the mutation")
  1048  	}
  1049  	oldValue, err := m.oldValue(ctx)
  1050  	if err != nil {
  1051  		return v, fmt.Errorf("querying old value for OldCapacity: %w", err)
  1052  	}
  1053  	return oldValue.Capacity, nil
  1054  }
  1055  
  1056  // AddCapacity adds i to the "capacity" field.
  1057  func (m *AlertMutation) AddCapacity(i int32) {
  1058  	if m.addcapacity != nil {
  1059  		*m.addcapacity += i
  1060  	} else {
  1061  		m.addcapacity = &i
  1062  	}
  1063  }
  1064  
  1065  // AddedCapacity returns the value that was added to the "capacity" field in this mutation.
  1066  func (m *AlertMutation) AddedCapacity() (r int32, exists bool) {
  1067  	v := m.addcapacity
  1068  	if v == nil {
  1069  		return
  1070  	}
  1071  	return *v, true
  1072  }
  1073  
  1074  // ClearCapacity clears the value of the "capacity" field.
  1075  func (m *AlertMutation) ClearCapacity() {
  1076  	m.capacity = nil
  1077  	m.addcapacity = nil
  1078  	m.clearedFields[alert.FieldCapacity] = struct{}{}
  1079  }
  1080  
  1081  // CapacityCleared returns if the "capacity" field was cleared in this mutation.
  1082  func (m *AlertMutation) CapacityCleared() bool {
  1083  	_, ok := m.clearedFields[alert.FieldCapacity]
  1084  	return ok
  1085  }
  1086  
  1087  // ResetCapacity resets all changes to the "capacity" field.
  1088  func (m *AlertMutation) ResetCapacity() {
  1089  	m.capacity = nil
  1090  	m.addcapacity = nil
  1091  	delete(m.clearedFields, alert.FieldCapacity)
  1092  }
  1093  
  1094  // SetLeakSpeed sets the "leakSpeed" field.
  1095  func (m *AlertMutation) SetLeakSpeed(s string) {
  1096  	m.leakSpeed = &s
  1097  }
  1098  
  1099  // LeakSpeed returns the value of the "leakSpeed" field in the mutation.
  1100  func (m *AlertMutation) LeakSpeed() (r string, exists bool) {
  1101  	v := m.leakSpeed
  1102  	if v == nil {
  1103  		return
  1104  	}
  1105  	return *v, true
  1106  }
  1107  
  1108  // OldLeakSpeed returns the old "leakSpeed" field's value of the Alert entity.
  1109  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1110  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1111  func (m *AlertMutation) OldLeakSpeed(ctx context.Context) (v string, err error) {
  1112  	if !m.op.Is(OpUpdateOne) {
  1113  		return v, fmt.Errorf("OldLeakSpeed is only allowed on UpdateOne operations")
  1114  	}
  1115  	if m.id == nil || m.oldValue == nil {
  1116  		return v, fmt.Errorf("OldLeakSpeed requires an ID field in the mutation")
  1117  	}
  1118  	oldValue, err := m.oldValue(ctx)
  1119  	if err != nil {
  1120  		return v, fmt.Errorf("querying old value for OldLeakSpeed: %w", err)
  1121  	}
  1122  	return oldValue.LeakSpeed, nil
  1123  }
  1124  
  1125  // ClearLeakSpeed clears the value of the "leakSpeed" field.
  1126  func (m *AlertMutation) ClearLeakSpeed() {
  1127  	m.leakSpeed = nil
  1128  	m.clearedFields[alert.FieldLeakSpeed] = struct{}{}
  1129  }
  1130  
  1131  // LeakSpeedCleared returns if the "leakSpeed" field was cleared in this mutation.
  1132  func (m *AlertMutation) LeakSpeedCleared() bool {
  1133  	_, ok := m.clearedFields[alert.FieldLeakSpeed]
  1134  	return ok
  1135  }
  1136  
  1137  // ResetLeakSpeed resets all changes to the "leakSpeed" field.
  1138  func (m *AlertMutation) ResetLeakSpeed() {
  1139  	m.leakSpeed = nil
  1140  	delete(m.clearedFields, alert.FieldLeakSpeed)
  1141  }
  1142  
  1143  // SetScenarioVersion sets the "scenarioVersion" field.
  1144  func (m *AlertMutation) SetScenarioVersion(s string) {
  1145  	m.scenarioVersion = &s
  1146  }
  1147  
  1148  // ScenarioVersion returns the value of the "scenarioVersion" field in the mutation.
  1149  func (m *AlertMutation) ScenarioVersion() (r string, exists bool) {
  1150  	v := m.scenarioVersion
  1151  	if v == nil {
  1152  		return
  1153  	}
  1154  	return *v, true
  1155  }
  1156  
  1157  // OldScenarioVersion returns the old "scenarioVersion" field's value of the Alert entity.
  1158  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1159  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1160  func (m *AlertMutation) OldScenarioVersion(ctx context.Context) (v string, err error) {
  1161  	if !m.op.Is(OpUpdateOne) {
  1162  		return v, fmt.Errorf("OldScenarioVersion is only allowed on UpdateOne operations")
  1163  	}
  1164  	if m.id == nil || m.oldValue == nil {
  1165  		return v, fmt.Errorf("OldScenarioVersion requires an ID field in the mutation")
  1166  	}
  1167  	oldValue, err := m.oldValue(ctx)
  1168  	if err != nil {
  1169  		return v, fmt.Errorf("querying old value for OldScenarioVersion: %w", err)
  1170  	}
  1171  	return oldValue.ScenarioVersion, nil
  1172  }
  1173  
  1174  // ClearScenarioVersion clears the value of the "scenarioVersion" field.
  1175  func (m *AlertMutation) ClearScenarioVersion() {
  1176  	m.scenarioVersion = nil
  1177  	m.clearedFields[alert.FieldScenarioVersion] = struct{}{}
  1178  }
  1179  
  1180  // ScenarioVersionCleared returns if the "scenarioVersion" field was cleared in this mutation.
  1181  func (m *AlertMutation) ScenarioVersionCleared() bool {
  1182  	_, ok := m.clearedFields[alert.FieldScenarioVersion]
  1183  	return ok
  1184  }
  1185  
  1186  // ResetScenarioVersion resets all changes to the "scenarioVersion" field.
  1187  func (m *AlertMutation) ResetScenarioVersion() {
  1188  	m.scenarioVersion = nil
  1189  	delete(m.clearedFields, alert.FieldScenarioVersion)
  1190  }
  1191  
  1192  // SetScenarioHash sets the "scenarioHash" field.
  1193  func (m *AlertMutation) SetScenarioHash(s string) {
  1194  	m.scenarioHash = &s
  1195  }
  1196  
  1197  // ScenarioHash returns the value of the "scenarioHash" field in the mutation.
  1198  func (m *AlertMutation) ScenarioHash() (r string, exists bool) {
  1199  	v := m.scenarioHash
  1200  	if v == nil {
  1201  		return
  1202  	}
  1203  	return *v, true
  1204  }
  1205  
  1206  // OldScenarioHash returns the old "scenarioHash" field's value of the Alert entity.
  1207  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1208  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1209  func (m *AlertMutation) OldScenarioHash(ctx context.Context) (v string, err error) {
  1210  	if !m.op.Is(OpUpdateOne) {
  1211  		return v, fmt.Errorf("OldScenarioHash is only allowed on UpdateOne operations")
  1212  	}
  1213  	if m.id == nil || m.oldValue == nil {
  1214  		return v, fmt.Errorf("OldScenarioHash requires an ID field in the mutation")
  1215  	}
  1216  	oldValue, err := m.oldValue(ctx)
  1217  	if err != nil {
  1218  		return v, fmt.Errorf("querying old value for OldScenarioHash: %w", err)
  1219  	}
  1220  	return oldValue.ScenarioHash, nil
  1221  }
  1222  
  1223  // ClearScenarioHash clears the value of the "scenarioHash" field.
  1224  func (m *AlertMutation) ClearScenarioHash() {
  1225  	m.scenarioHash = nil
  1226  	m.clearedFields[alert.FieldScenarioHash] = struct{}{}
  1227  }
  1228  
  1229  // ScenarioHashCleared returns if the "scenarioHash" field was cleared in this mutation.
  1230  func (m *AlertMutation) ScenarioHashCleared() bool {
  1231  	_, ok := m.clearedFields[alert.FieldScenarioHash]
  1232  	return ok
  1233  }
  1234  
  1235  // ResetScenarioHash resets all changes to the "scenarioHash" field.
  1236  func (m *AlertMutation) ResetScenarioHash() {
  1237  	m.scenarioHash = nil
  1238  	delete(m.clearedFields, alert.FieldScenarioHash)
  1239  }
  1240  
  1241  // SetSimulated sets the "simulated" field.
  1242  func (m *AlertMutation) SetSimulated(b bool) {
  1243  	m.simulated = &b
  1244  }
  1245  
  1246  // Simulated returns the value of the "simulated" field in the mutation.
  1247  func (m *AlertMutation) Simulated() (r bool, exists bool) {
  1248  	v := m.simulated
  1249  	if v == nil {
  1250  		return
  1251  	}
  1252  	return *v, true
  1253  }
  1254  
  1255  // OldSimulated returns the old "simulated" field's value of the Alert entity.
  1256  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1257  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1258  func (m *AlertMutation) OldSimulated(ctx context.Context) (v bool, err error) {
  1259  	if !m.op.Is(OpUpdateOne) {
  1260  		return v, fmt.Errorf("OldSimulated is only allowed on UpdateOne operations")
  1261  	}
  1262  	if m.id == nil || m.oldValue == nil {
  1263  		return v, fmt.Errorf("OldSimulated requires an ID field in the mutation")
  1264  	}
  1265  	oldValue, err := m.oldValue(ctx)
  1266  	if err != nil {
  1267  		return v, fmt.Errorf("querying old value for OldSimulated: %w", err)
  1268  	}
  1269  	return oldValue.Simulated, nil
  1270  }
  1271  
  1272  // ResetSimulated resets all changes to the "simulated" field.
  1273  func (m *AlertMutation) ResetSimulated() {
  1274  	m.simulated = nil
  1275  }
  1276  
  1277  // SetOwnerID sets the "owner" edge to the Machine entity by id.
  1278  func (m *AlertMutation) SetOwnerID(id int) {
  1279  	m.owner = &id
  1280  }
  1281  
  1282  // ClearOwner clears the "owner" edge to the Machine entity.
  1283  func (m *AlertMutation) ClearOwner() {
  1284  	m.clearedowner = true
  1285  }
  1286  
  1287  // OwnerCleared returns if the "owner" edge to the Machine entity was cleared.
  1288  func (m *AlertMutation) OwnerCleared() bool {
  1289  	return m.clearedowner
  1290  }
  1291  
  1292  // OwnerID returns the "owner" edge ID in the mutation.
  1293  func (m *AlertMutation) OwnerID() (id int, exists bool) {
  1294  	if m.owner != nil {
  1295  		return *m.owner, true
  1296  	}
  1297  	return
  1298  }
  1299  
  1300  // OwnerIDs returns the "owner" edge IDs in the mutation.
  1301  // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  1302  // OwnerID instead. It exists only for internal usage by the builders.
  1303  func (m *AlertMutation) OwnerIDs() (ids []int) {
  1304  	if id := m.owner; id != nil {
  1305  		ids = append(ids, *id)
  1306  	}
  1307  	return
  1308  }
  1309  
  1310  // ResetOwner resets all changes to the "owner" edge.
  1311  func (m *AlertMutation) ResetOwner() {
  1312  	m.owner = nil
  1313  	m.clearedowner = false
  1314  }
  1315  
  1316  // AddDecisionIDs adds the "decisions" edge to the Decision entity by ids.
  1317  func (m *AlertMutation) AddDecisionIDs(ids ...int) {
  1318  	if m.decisions == nil {
  1319  		m.decisions = make(map[int]struct{})
  1320  	}
  1321  	for i := range ids {
  1322  		m.decisions[ids[i]] = struct{}{}
  1323  	}
  1324  }
  1325  
  1326  // ClearDecisions clears the "decisions" edge to the Decision entity.
  1327  func (m *AlertMutation) ClearDecisions() {
  1328  	m.cleareddecisions = true
  1329  }
  1330  
  1331  // DecisionsCleared returns if the "decisions" edge to the Decision entity was cleared.
  1332  func (m *AlertMutation) DecisionsCleared() bool {
  1333  	return m.cleareddecisions
  1334  }
  1335  
  1336  // RemoveDecisionIDs removes the "decisions" edge to the Decision entity by IDs.
  1337  func (m *AlertMutation) RemoveDecisionIDs(ids ...int) {
  1338  	if m.removeddecisions == nil {
  1339  		m.removeddecisions = make(map[int]struct{})
  1340  	}
  1341  	for i := range ids {
  1342  		m.removeddecisions[ids[i]] = struct{}{}
  1343  	}
  1344  }
  1345  
  1346  // RemovedDecisions returns the removed IDs of the "decisions" edge to the Decision entity.
  1347  func (m *AlertMutation) RemovedDecisionsIDs() (ids []int) {
  1348  	for id := range m.removeddecisions {
  1349  		ids = append(ids, id)
  1350  	}
  1351  	return
  1352  }
  1353  
  1354  // DecisionsIDs returns the "decisions" edge IDs in the mutation.
  1355  func (m *AlertMutation) DecisionsIDs() (ids []int) {
  1356  	for id := range m.decisions {
  1357  		ids = append(ids, id)
  1358  	}
  1359  	return
  1360  }
  1361  
  1362  // ResetDecisions resets all changes to the "decisions" edge.
  1363  func (m *AlertMutation) ResetDecisions() {
  1364  	m.decisions = nil
  1365  	m.cleareddecisions = false
  1366  	m.removeddecisions = nil
  1367  }
  1368  
  1369  // AddEventIDs adds the "events" edge to the Event entity by ids.
  1370  func (m *AlertMutation) AddEventIDs(ids ...int) {
  1371  	if m.events == nil {
  1372  		m.events = make(map[int]struct{})
  1373  	}
  1374  	for i := range ids {
  1375  		m.events[ids[i]] = struct{}{}
  1376  	}
  1377  }
  1378  
  1379  // ClearEvents clears the "events" edge to the Event entity.
  1380  func (m *AlertMutation) ClearEvents() {
  1381  	m.clearedevents = true
  1382  }
  1383  
  1384  // EventsCleared returns if the "events" edge to the Event entity was cleared.
  1385  func (m *AlertMutation) EventsCleared() bool {
  1386  	return m.clearedevents
  1387  }
  1388  
  1389  // RemoveEventIDs removes the "events" edge to the Event entity by IDs.
  1390  func (m *AlertMutation) RemoveEventIDs(ids ...int) {
  1391  	if m.removedevents == nil {
  1392  		m.removedevents = make(map[int]struct{})
  1393  	}
  1394  	for i := range ids {
  1395  		m.removedevents[ids[i]] = struct{}{}
  1396  	}
  1397  }
  1398  
  1399  // RemovedEvents returns the removed IDs of the "events" edge to the Event entity.
  1400  func (m *AlertMutation) RemovedEventsIDs() (ids []int) {
  1401  	for id := range m.removedevents {
  1402  		ids = append(ids, id)
  1403  	}
  1404  	return
  1405  }
  1406  
  1407  // EventsIDs returns the "events" edge IDs in the mutation.
  1408  func (m *AlertMutation) EventsIDs() (ids []int) {
  1409  	for id := range m.events {
  1410  		ids = append(ids, id)
  1411  	}
  1412  	return
  1413  }
  1414  
  1415  // ResetEvents resets all changes to the "events" edge.
  1416  func (m *AlertMutation) ResetEvents() {
  1417  	m.events = nil
  1418  	m.clearedevents = false
  1419  	m.removedevents = nil
  1420  }
  1421  
  1422  // AddMetaIDs adds the "metas" edge to the Meta entity by ids.
  1423  func (m *AlertMutation) AddMetaIDs(ids ...int) {
  1424  	if m.metas == nil {
  1425  		m.metas = make(map[int]struct{})
  1426  	}
  1427  	for i := range ids {
  1428  		m.metas[ids[i]] = struct{}{}
  1429  	}
  1430  }
  1431  
  1432  // ClearMetas clears the "metas" edge to the Meta entity.
  1433  func (m *AlertMutation) ClearMetas() {
  1434  	m.clearedmetas = true
  1435  }
  1436  
  1437  // MetasCleared returns if the "metas" edge to the Meta entity was cleared.
  1438  func (m *AlertMutation) MetasCleared() bool {
  1439  	return m.clearedmetas
  1440  }
  1441  
  1442  // RemoveMetaIDs removes the "metas" edge to the Meta entity by IDs.
  1443  func (m *AlertMutation) RemoveMetaIDs(ids ...int) {
  1444  	if m.removedmetas == nil {
  1445  		m.removedmetas = make(map[int]struct{})
  1446  	}
  1447  	for i := range ids {
  1448  		m.removedmetas[ids[i]] = struct{}{}
  1449  	}
  1450  }
  1451  
  1452  // RemovedMetas returns the removed IDs of the "metas" edge to the Meta entity.
  1453  func (m *AlertMutation) RemovedMetasIDs() (ids []int) {
  1454  	for id := range m.removedmetas {
  1455  		ids = append(ids, id)
  1456  	}
  1457  	return
  1458  }
  1459  
  1460  // MetasIDs returns the "metas" edge IDs in the mutation.
  1461  func (m *AlertMutation) MetasIDs() (ids []int) {
  1462  	for id := range m.metas {
  1463  		ids = append(ids, id)
  1464  	}
  1465  	return
  1466  }
  1467  
  1468  // ResetMetas resets all changes to the "metas" edge.
  1469  func (m *AlertMutation) ResetMetas() {
  1470  	m.metas = nil
  1471  	m.clearedmetas = false
  1472  	m.removedmetas = nil
  1473  }
  1474  
  1475  // Op returns the operation name.
  1476  func (m *AlertMutation) Op() Op {
  1477  	return m.op
  1478  }
  1479  
  1480  // Type returns the node type of this mutation (Alert).
  1481  func (m *AlertMutation) Type() string {
  1482  	return m.typ
  1483  }
  1484  
  1485  // Fields returns all fields that were changed during this mutation. Note that in
  1486  // order to get all numeric fields that were incremented/decremented, call
  1487  // AddedFields().
  1488  func (m *AlertMutation) Fields() []string {
  1489  	fields := make([]string, 0, 22)
  1490  	if m.created_at != nil {
  1491  		fields = append(fields, alert.FieldCreatedAt)
  1492  	}
  1493  	if m.updated_at != nil {
  1494  		fields = append(fields, alert.FieldUpdatedAt)
  1495  	}
  1496  	if m.scenario != nil {
  1497  		fields = append(fields, alert.FieldScenario)
  1498  	}
  1499  	if m.bucketId != nil {
  1500  		fields = append(fields, alert.FieldBucketId)
  1501  	}
  1502  	if m.message != nil {
  1503  		fields = append(fields, alert.FieldMessage)
  1504  	}
  1505  	if m.eventsCount != nil {
  1506  		fields = append(fields, alert.FieldEventsCount)
  1507  	}
  1508  	if m.startedAt != nil {
  1509  		fields = append(fields, alert.FieldStartedAt)
  1510  	}
  1511  	if m.stoppedAt != nil {
  1512  		fields = append(fields, alert.FieldStoppedAt)
  1513  	}
  1514  	if m.sourceIp != nil {
  1515  		fields = append(fields, alert.FieldSourceIp)
  1516  	}
  1517  	if m.sourceRange != nil {
  1518  		fields = append(fields, alert.FieldSourceRange)
  1519  	}
  1520  	if m.sourceAsNumber != nil {
  1521  		fields = append(fields, alert.FieldSourceAsNumber)
  1522  	}
  1523  	if m.sourceAsName != nil {
  1524  		fields = append(fields, alert.FieldSourceAsName)
  1525  	}
  1526  	if m.sourceCountry != nil {
  1527  		fields = append(fields, alert.FieldSourceCountry)
  1528  	}
  1529  	if m.sourceLatitude != nil {
  1530  		fields = append(fields, alert.FieldSourceLatitude)
  1531  	}
  1532  	if m.sourceLongitude != nil {
  1533  		fields = append(fields, alert.FieldSourceLongitude)
  1534  	}
  1535  	if m.sourceScope != nil {
  1536  		fields = append(fields, alert.FieldSourceScope)
  1537  	}
  1538  	if m.sourceValue != nil {
  1539  		fields = append(fields, alert.FieldSourceValue)
  1540  	}
  1541  	if m.capacity != nil {
  1542  		fields = append(fields, alert.FieldCapacity)
  1543  	}
  1544  	if m.leakSpeed != nil {
  1545  		fields = append(fields, alert.FieldLeakSpeed)
  1546  	}
  1547  	if m.scenarioVersion != nil {
  1548  		fields = append(fields, alert.FieldScenarioVersion)
  1549  	}
  1550  	if m.scenarioHash != nil {
  1551  		fields = append(fields, alert.FieldScenarioHash)
  1552  	}
  1553  	if m.simulated != nil {
  1554  		fields = append(fields, alert.FieldSimulated)
  1555  	}
  1556  	return fields
  1557  }
  1558  
  1559  // Field returns the value of a field with the given name. The second boolean
  1560  // return value indicates that this field was not set, or was not defined in the
  1561  // schema.
  1562  func (m *AlertMutation) Field(name string) (ent.Value, bool) {
  1563  	switch name {
  1564  	case alert.FieldCreatedAt:
  1565  		return m.CreatedAt()
  1566  	case alert.FieldUpdatedAt:
  1567  		return m.UpdatedAt()
  1568  	case alert.FieldScenario:
  1569  		return m.Scenario()
  1570  	case alert.FieldBucketId:
  1571  		return m.BucketId()
  1572  	case alert.FieldMessage:
  1573  		return m.Message()
  1574  	case alert.FieldEventsCount:
  1575  		return m.EventsCount()
  1576  	case alert.FieldStartedAt:
  1577  		return m.StartedAt()
  1578  	case alert.FieldStoppedAt:
  1579  		return m.StoppedAt()
  1580  	case alert.FieldSourceIp:
  1581  		return m.SourceIp()
  1582  	case alert.FieldSourceRange:
  1583  		return m.SourceRange()
  1584  	case alert.FieldSourceAsNumber:
  1585  		return m.SourceAsNumber()
  1586  	case alert.FieldSourceAsName:
  1587  		return m.SourceAsName()
  1588  	case alert.FieldSourceCountry:
  1589  		return m.SourceCountry()
  1590  	case alert.FieldSourceLatitude:
  1591  		return m.SourceLatitude()
  1592  	case alert.FieldSourceLongitude:
  1593  		return m.SourceLongitude()
  1594  	case alert.FieldSourceScope:
  1595  		return m.SourceScope()
  1596  	case alert.FieldSourceValue:
  1597  		return m.SourceValue()
  1598  	case alert.FieldCapacity:
  1599  		return m.Capacity()
  1600  	case alert.FieldLeakSpeed:
  1601  		return m.LeakSpeed()
  1602  	case alert.FieldScenarioVersion:
  1603  		return m.ScenarioVersion()
  1604  	case alert.FieldScenarioHash:
  1605  		return m.ScenarioHash()
  1606  	case alert.FieldSimulated:
  1607  		return m.Simulated()
  1608  	}
  1609  	return nil, false
  1610  }
  1611  
  1612  // OldField returns the old value of the field from the database. An error is
  1613  // returned if the mutation operation is not UpdateOne, or the query to the
  1614  // database failed.
  1615  func (m *AlertMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1616  	switch name {
  1617  	case alert.FieldCreatedAt:
  1618  		return m.OldCreatedAt(ctx)
  1619  	case alert.FieldUpdatedAt:
  1620  		return m.OldUpdatedAt(ctx)
  1621  	case alert.FieldScenario:
  1622  		return m.OldScenario(ctx)
  1623  	case alert.FieldBucketId:
  1624  		return m.OldBucketId(ctx)
  1625  	case alert.FieldMessage:
  1626  		return m.OldMessage(ctx)
  1627  	case alert.FieldEventsCount:
  1628  		return m.OldEventsCount(ctx)
  1629  	case alert.FieldStartedAt:
  1630  		return m.OldStartedAt(ctx)
  1631  	case alert.FieldStoppedAt:
  1632  		return m.OldStoppedAt(ctx)
  1633  	case alert.FieldSourceIp:
  1634  		return m.OldSourceIp(ctx)
  1635  	case alert.FieldSourceRange:
  1636  		return m.OldSourceRange(ctx)
  1637  	case alert.FieldSourceAsNumber:
  1638  		return m.OldSourceAsNumber(ctx)
  1639  	case alert.FieldSourceAsName:
  1640  		return m.OldSourceAsName(ctx)
  1641  	case alert.FieldSourceCountry:
  1642  		return m.OldSourceCountry(ctx)
  1643  	case alert.FieldSourceLatitude:
  1644  		return m.OldSourceLatitude(ctx)
  1645  	case alert.FieldSourceLongitude:
  1646  		return m.OldSourceLongitude(ctx)
  1647  	case alert.FieldSourceScope:
  1648  		return m.OldSourceScope(ctx)
  1649  	case alert.FieldSourceValue:
  1650  		return m.OldSourceValue(ctx)
  1651  	case alert.FieldCapacity:
  1652  		return m.OldCapacity(ctx)
  1653  	case alert.FieldLeakSpeed:
  1654  		return m.OldLeakSpeed(ctx)
  1655  	case alert.FieldScenarioVersion:
  1656  		return m.OldScenarioVersion(ctx)
  1657  	case alert.FieldScenarioHash:
  1658  		return m.OldScenarioHash(ctx)
  1659  	case alert.FieldSimulated:
  1660  		return m.OldSimulated(ctx)
  1661  	}
  1662  	return nil, fmt.Errorf("unknown Alert field %s", name)
  1663  }
  1664  
  1665  // SetField sets the value of a field with the given name. It returns an error if
  1666  // the field is not defined in the schema, or if the type mismatched the field
  1667  // type.
  1668  func (m *AlertMutation) SetField(name string, value ent.Value) error {
  1669  	switch name {
  1670  	case alert.FieldCreatedAt:
  1671  		v, ok := value.(time.Time)
  1672  		if !ok {
  1673  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1674  		}
  1675  		m.SetCreatedAt(v)
  1676  		return nil
  1677  	case alert.FieldUpdatedAt:
  1678  		v, ok := value.(time.Time)
  1679  		if !ok {
  1680  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1681  		}
  1682  		m.SetUpdatedAt(v)
  1683  		return nil
  1684  	case alert.FieldScenario:
  1685  		v, ok := value.(string)
  1686  		if !ok {
  1687  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1688  		}
  1689  		m.SetScenario(v)
  1690  		return nil
  1691  	case alert.FieldBucketId:
  1692  		v, ok := value.(string)
  1693  		if !ok {
  1694  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1695  		}
  1696  		m.SetBucketId(v)
  1697  		return nil
  1698  	case alert.FieldMessage:
  1699  		v, ok := value.(string)
  1700  		if !ok {
  1701  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1702  		}
  1703  		m.SetMessage(v)
  1704  		return nil
  1705  	case alert.FieldEventsCount:
  1706  		v, ok := value.(int32)
  1707  		if !ok {
  1708  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1709  		}
  1710  		m.SetEventsCount(v)
  1711  		return nil
  1712  	case alert.FieldStartedAt:
  1713  		v, ok := value.(time.Time)
  1714  		if !ok {
  1715  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1716  		}
  1717  		m.SetStartedAt(v)
  1718  		return nil
  1719  	case alert.FieldStoppedAt:
  1720  		v, ok := value.(time.Time)
  1721  		if !ok {
  1722  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1723  		}
  1724  		m.SetStoppedAt(v)
  1725  		return nil
  1726  	case alert.FieldSourceIp:
  1727  		v, ok := value.(string)
  1728  		if !ok {
  1729  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1730  		}
  1731  		m.SetSourceIp(v)
  1732  		return nil
  1733  	case alert.FieldSourceRange:
  1734  		v, ok := value.(string)
  1735  		if !ok {
  1736  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1737  		}
  1738  		m.SetSourceRange(v)
  1739  		return nil
  1740  	case alert.FieldSourceAsNumber:
  1741  		v, ok := value.(string)
  1742  		if !ok {
  1743  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1744  		}
  1745  		m.SetSourceAsNumber(v)
  1746  		return nil
  1747  	case alert.FieldSourceAsName:
  1748  		v, ok := value.(string)
  1749  		if !ok {
  1750  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1751  		}
  1752  		m.SetSourceAsName(v)
  1753  		return nil
  1754  	case alert.FieldSourceCountry:
  1755  		v, ok := value.(string)
  1756  		if !ok {
  1757  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1758  		}
  1759  		m.SetSourceCountry(v)
  1760  		return nil
  1761  	case alert.FieldSourceLatitude:
  1762  		v, ok := value.(float32)
  1763  		if !ok {
  1764  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1765  		}
  1766  		m.SetSourceLatitude(v)
  1767  		return nil
  1768  	case alert.FieldSourceLongitude:
  1769  		v, ok := value.(float32)
  1770  		if !ok {
  1771  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1772  		}
  1773  		m.SetSourceLongitude(v)
  1774  		return nil
  1775  	case alert.FieldSourceScope:
  1776  		v, ok := value.(string)
  1777  		if !ok {
  1778  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1779  		}
  1780  		m.SetSourceScope(v)
  1781  		return nil
  1782  	case alert.FieldSourceValue:
  1783  		v, ok := value.(string)
  1784  		if !ok {
  1785  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1786  		}
  1787  		m.SetSourceValue(v)
  1788  		return nil
  1789  	case alert.FieldCapacity:
  1790  		v, ok := value.(int32)
  1791  		if !ok {
  1792  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1793  		}
  1794  		m.SetCapacity(v)
  1795  		return nil
  1796  	case alert.FieldLeakSpeed:
  1797  		v, ok := value.(string)
  1798  		if !ok {
  1799  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1800  		}
  1801  		m.SetLeakSpeed(v)
  1802  		return nil
  1803  	case alert.FieldScenarioVersion:
  1804  		v, ok := value.(string)
  1805  		if !ok {
  1806  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1807  		}
  1808  		m.SetScenarioVersion(v)
  1809  		return nil
  1810  	case alert.FieldScenarioHash:
  1811  		v, ok := value.(string)
  1812  		if !ok {
  1813  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1814  		}
  1815  		m.SetScenarioHash(v)
  1816  		return nil
  1817  	case alert.FieldSimulated:
  1818  		v, ok := value.(bool)
  1819  		if !ok {
  1820  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1821  		}
  1822  		m.SetSimulated(v)
  1823  		return nil
  1824  	}
  1825  	return fmt.Errorf("unknown Alert field %s", name)
  1826  }
  1827  
  1828  // AddedFields returns all numeric fields that were incremented/decremented during
  1829  // this mutation.
  1830  func (m *AlertMutation) AddedFields() []string {
  1831  	var fields []string
  1832  	if m.addeventsCount != nil {
  1833  		fields = append(fields, alert.FieldEventsCount)
  1834  	}
  1835  	if m.addsourceLatitude != nil {
  1836  		fields = append(fields, alert.FieldSourceLatitude)
  1837  	}
  1838  	if m.addsourceLongitude != nil {
  1839  		fields = append(fields, alert.FieldSourceLongitude)
  1840  	}
  1841  	if m.addcapacity != nil {
  1842  		fields = append(fields, alert.FieldCapacity)
  1843  	}
  1844  	return fields
  1845  }
  1846  
  1847  // AddedField returns the numeric value that was incremented/decremented on a field
  1848  // with the given name. The second boolean return value indicates that this field
  1849  // was not set, or was not defined in the schema.
  1850  func (m *AlertMutation) AddedField(name string) (ent.Value, bool) {
  1851  	switch name {
  1852  	case alert.FieldEventsCount:
  1853  		return m.AddedEventsCount()
  1854  	case alert.FieldSourceLatitude:
  1855  		return m.AddedSourceLatitude()
  1856  	case alert.FieldSourceLongitude:
  1857  		return m.AddedSourceLongitude()
  1858  	case alert.FieldCapacity:
  1859  		return m.AddedCapacity()
  1860  	}
  1861  	return nil, false
  1862  }
  1863  
  1864  // AddField adds the value to the field with the given name. It returns an error if
  1865  // the field is not defined in the schema, or if the type mismatched the field
  1866  // type.
  1867  func (m *AlertMutation) AddField(name string, value ent.Value) error {
  1868  	switch name {
  1869  	case alert.FieldEventsCount:
  1870  		v, ok := value.(int32)
  1871  		if !ok {
  1872  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1873  		}
  1874  		m.AddEventsCount(v)
  1875  		return nil
  1876  	case alert.FieldSourceLatitude:
  1877  		v, ok := value.(float32)
  1878  		if !ok {
  1879  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1880  		}
  1881  		m.AddSourceLatitude(v)
  1882  		return nil
  1883  	case alert.FieldSourceLongitude:
  1884  		v, ok := value.(float32)
  1885  		if !ok {
  1886  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1887  		}
  1888  		m.AddSourceLongitude(v)
  1889  		return nil
  1890  	case alert.FieldCapacity:
  1891  		v, ok := value.(int32)
  1892  		if !ok {
  1893  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1894  		}
  1895  		m.AddCapacity(v)
  1896  		return nil
  1897  	}
  1898  	return fmt.Errorf("unknown Alert numeric field %s", name)
  1899  }
  1900  
  1901  // ClearedFields returns all nullable fields that were cleared during this
  1902  // mutation.
  1903  func (m *AlertMutation) ClearedFields() []string {
  1904  	var fields []string
  1905  	if m.FieldCleared(alert.FieldBucketId) {
  1906  		fields = append(fields, alert.FieldBucketId)
  1907  	}
  1908  	if m.FieldCleared(alert.FieldMessage) {
  1909  		fields = append(fields, alert.FieldMessage)
  1910  	}
  1911  	if m.FieldCleared(alert.FieldEventsCount) {
  1912  		fields = append(fields, alert.FieldEventsCount)
  1913  	}
  1914  	if m.FieldCleared(alert.FieldStartedAt) {
  1915  		fields = append(fields, alert.FieldStartedAt)
  1916  	}
  1917  	if m.FieldCleared(alert.FieldStoppedAt) {
  1918  		fields = append(fields, alert.FieldStoppedAt)
  1919  	}
  1920  	if m.FieldCleared(alert.FieldSourceIp) {
  1921  		fields = append(fields, alert.FieldSourceIp)
  1922  	}
  1923  	if m.FieldCleared(alert.FieldSourceRange) {
  1924  		fields = append(fields, alert.FieldSourceRange)
  1925  	}
  1926  	if m.FieldCleared(alert.FieldSourceAsNumber) {
  1927  		fields = append(fields, alert.FieldSourceAsNumber)
  1928  	}
  1929  	if m.FieldCleared(alert.FieldSourceAsName) {
  1930  		fields = append(fields, alert.FieldSourceAsName)
  1931  	}
  1932  	if m.FieldCleared(alert.FieldSourceCountry) {
  1933  		fields = append(fields, alert.FieldSourceCountry)
  1934  	}
  1935  	if m.FieldCleared(alert.FieldSourceLatitude) {
  1936  		fields = append(fields, alert.FieldSourceLatitude)
  1937  	}
  1938  	if m.FieldCleared(alert.FieldSourceLongitude) {
  1939  		fields = append(fields, alert.FieldSourceLongitude)
  1940  	}
  1941  	if m.FieldCleared(alert.FieldSourceScope) {
  1942  		fields = append(fields, alert.FieldSourceScope)
  1943  	}
  1944  	if m.FieldCleared(alert.FieldSourceValue) {
  1945  		fields = append(fields, alert.FieldSourceValue)
  1946  	}
  1947  	if m.FieldCleared(alert.FieldCapacity) {
  1948  		fields = append(fields, alert.FieldCapacity)
  1949  	}
  1950  	if m.FieldCleared(alert.FieldLeakSpeed) {
  1951  		fields = append(fields, alert.FieldLeakSpeed)
  1952  	}
  1953  	if m.FieldCleared(alert.FieldScenarioVersion) {
  1954  		fields = append(fields, alert.FieldScenarioVersion)
  1955  	}
  1956  	if m.FieldCleared(alert.FieldScenarioHash) {
  1957  		fields = append(fields, alert.FieldScenarioHash)
  1958  	}
  1959  	return fields
  1960  }
  1961  
  1962  // FieldCleared returns a boolean indicating if a field with the given name was
  1963  // cleared in this mutation.
  1964  func (m *AlertMutation) FieldCleared(name string) bool {
  1965  	_, ok := m.clearedFields[name]
  1966  	return ok
  1967  }
  1968  
  1969  // ClearField clears the value of the field with the given name. It returns an
  1970  // error if the field is not defined in the schema.
  1971  func (m *AlertMutation) ClearField(name string) error {
  1972  	switch name {
  1973  	case alert.FieldBucketId:
  1974  		m.ClearBucketId()
  1975  		return nil
  1976  	case alert.FieldMessage:
  1977  		m.ClearMessage()
  1978  		return nil
  1979  	case alert.FieldEventsCount:
  1980  		m.ClearEventsCount()
  1981  		return nil
  1982  	case alert.FieldStartedAt:
  1983  		m.ClearStartedAt()
  1984  		return nil
  1985  	case alert.FieldStoppedAt:
  1986  		m.ClearStoppedAt()
  1987  		return nil
  1988  	case alert.FieldSourceIp:
  1989  		m.ClearSourceIp()
  1990  		return nil
  1991  	case alert.FieldSourceRange:
  1992  		m.ClearSourceRange()
  1993  		return nil
  1994  	case alert.FieldSourceAsNumber:
  1995  		m.ClearSourceAsNumber()
  1996  		return nil
  1997  	case alert.FieldSourceAsName:
  1998  		m.ClearSourceAsName()
  1999  		return nil
  2000  	case alert.FieldSourceCountry:
  2001  		m.ClearSourceCountry()
  2002  		return nil
  2003  	case alert.FieldSourceLatitude:
  2004  		m.ClearSourceLatitude()
  2005  		return nil
  2006  	case alert.FieldSourceLongitude:
  2007  		m.ClearSourceLongitude()
  2008  		return nil
  2009  	case alert.FieldSourceScope:
  2010  		m.ClearSourceScope()
  2011  		return nil
  2012  	case alert.FieldSourceValue:
  2013  		m.ClearSourceValue()
  2014  		return nil
  2015  	case alert.FieldCapacity:
  2016  		m.ClearCapacity()
  2017  		return nil
  2018  	case alert.FieldLeakSpeed:
  2019  		m.ClearLeakSpeed()
  2020  		return nil
  2021  	case alert.FieldScenarioVersion:
  2022  		m.ClearScenarioVersion()
  2023  		return nil
  2024  	case alert.FieldScenarioHash:
  2025  		m.ClearScenarioHash()
  2026  		return nil
  2027  	}
  2028  	return fmt.Errorf("unknown Alert nullable field %s", name)
  2029  }
  2030  
  2031  // ResetField resets all changes in the mutation for the field with the given name.
  2032  // It returns an error if the field is not defined in the schema.
  2033  func (m *AlertMutation) ResetField(name string) error {
  2034  	switch name {
  2035  	case alert.FieldCreatedAt:
  2036  		m.ResetCreatedAt()
  2037  		return nil
  2038  	case alert.FieldUpdatedAt:
  2039  		m.ResetUpdatedAt()
  2040  		return nil
  2041  	case alert.FieldScenario:
  2042  		m.ResetScenario()
  2043  		return nil
  2044  	case alert.FieldBucketId:
  2045  		m.ResetBucketId()
  2046  		return nil
  2047  	case alert.FieldMessage:
  2048  		m.ResetMessage()
  2049  		return nil
  2050  	case alert.FieldEventsCount:
  2051  		m.ResetEventsCount()
  2052  		return nil
  2053  	case alert.FieldStartedAt:
  2054  		m.ResetStartedAt()
  2055  		return nil
  2056  	case alert.FieldStoppedAt:
  2057  		m.ResetStoppedAt()
  2058  		return nil
  2059  	case alert.FieldSourceIp:
  2060  		m.ResetSourceIp()
  2061  		return nil
  2062  	case alert.FieldSourceRange:
  2063  		m.ResetSourceRange()
  2064  		return nil
  2065  	case alert.FieldSourceAsNumber:
  2066  		m.ResetSourceAsNumber()
  2067  		return nil
  2068  	case alert.FieldSourceAsName:
  2069  		m.ResetSourceAsName()
  2070  		return nil
  2071  	case alert.FieldSourceCountry:
  2072  		m.ResetSourceCountry()
  2073  		return nil
  2074  	case alert.FieldSourceLatitude:
  2075  		m.ResetSourceLatitude()
  2076  		return nil
  2077  	case alert.FieldSourceLongitude:
  2078  		m.ResetSourceLongitude()
  2079  		return nil
  2080  	case alert.FieldSourceScope:
  2081  		m.ResetSourceScope()
  2082  		return nil
  2083  	case alert.FieldSourceValue:
  2084  		m.ResetSourceValue()
  2085  		return nil
  2086  	case alert.FieldCapacity:
  2087  		m.ResetCapacity()
  2088  		return nil
  2089  	case alert.FieldLeakSpeed:
  2090  		m.ResetLeakSpeed()
  2091  		return nil
  2092  	case alert.FieldScenarioVersion:
  2093  		m.ResetScenarioVersion()
  2094  		return nil
  2095  	case alert.FieldScenarioHash:
  2096  		m.ResetScenarioHash()
  2097  		return nil
  2098  	case alert.FieldSimulated:
  2099  		m.ResetSimulated()
  2100  		return nil
  2101  	}
  2102  	return fmt.Errorf("unknown Alert field %s", name)
  2103  }
  2104  
  2105  // AddedEdges returns all edge names that were set/added in this mutation.
  2106  func (m *AlertMutation) AddedEdges() []string {
  2107  	edges := make([]string, 0, 4)
  2108  	if m.owner != nil {
  2109  		edges = append(edges, alert.EdgeOwner)
  2110  	}
  2111  	if m.decisions != nil {
  2112  		edges = append(edges, alert.EdgeDecisions)
  2113  	}
  2114  	if m.events != nil {
  2115  		edges = append(edges, alert.EdgeEvents)
  2116  	}
  2117  	if m.metas != nil {
  2118  		edges = append(edges, alert.EdgeMetas)
  2119  	}
  2120  	return edges
  2121  }
  2122  
  2123  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2124  // name in this mutation.
  2125  func (m *AlertMutation) AddedIDs(name string) []ent.Value {
  2126  	switch name {
  2127  	case alert.EdgeOwner:
  2128  		if id := m.owner; id != nil {
  2129  			return []ent.Value{*id}
  2130  		}
  2131  	case alert.EdgeDecisions:
  2132  		ids := make([]ent.Value, 0, len(m.decisions))
  2133  		for id := range m.decisions {
  2134  			ids = append(ids, id)
  2135  		}
  2136  		return ids
  2137  	case alert.EdgeEvents:
  2138  		ids := make([]ent.Value, 0, len(m.events))
  2139  		for id := range m.events {
  2140  			ids = append(ids, id)
  2141  		}
  2142  		return ids
  2143  	case alert.EdgeMetas:
  2144  		ids := make([]ent.Value, 0, len(m.metas))
  2145  		for id := range m.metas {
  2146  			ids = append(ids, id)
  2147  		}
  2148  		return ids
  2149  	}
  2150  	return nil
  2151  }
  2152  
  2153  // RemovedEdges returns all edge names that were removed in this mutation.
  2154  func (m *AlertMutation) RemovedEdges() []string {
  2155  	edges := make([]string, 0, 4)
  2156  	if m.removeddecisions != nil {
  2157  		edges = append(edges, alert.EdgeDecisions)
  2158  	}
  2159  	if m.removedevents != nil {
  2160  		edges = append(edges, alert.EdgeEvents)
  2161  	}
  2162  	if m.removedmetas != nil {
  2163  		edges = append(edges, alert.EdgeMetas)
  2164  	}
  2165  	return edges
  2166  }
  2167  
  2168  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2169  // the given name in this mutation.
  2170  func (m *AlertMutation) RemovedIDs(name string) []ent.Value {
  2171  	switch name {
  2172  	case alert.EdgeDecisions:
  2173  		ids := make([]ent.Value, 0, len(m.removeddecisions))
  2174  		for id := range m.removeddecisions {
  2175  			ids = append(ids, id)
  2176  		}
  2177  		return ids
  2178  	case alert.EdgeEvents:
  2179  		ids := make([]ent.Value, 0, len(m.removedevents))
  2180  		for id := range m.removedevents {
  2181  			ids = append(ids, id)
  2182  		}
  2183  		return ids
  2184  	case alert.EdgeMetas:
  2185  		ids := make([]ent.Value, 0, len(m.removedmetas))
  2186  		for id := range m.removedmetas {
  2187  			ids = append(ids, id)
  2188  		}
  2189  		return ids
  2190  	}
  2191  	return nil
  2192  }
  2193  
  2194  // ClearedEdges returns all edge names that were cleared in this mutation.
  2195  func (m *AlertMutation) ClearedEdges() []string {
  2196  	edges := make([]string, 0, 4)
  2197  	if m.clearedowner {
  2198  		edges = append(edges, alert.EdgeOwner)
  2199  	}
  2200  	if m.cleareddecisions {
  2201  		edges = append(edges, alert.EdgeDecisions)
  2202  	}
  2203  	if m.clearedevents {
  2204  		edges = append(edges, alert.EdgeEvents)
  2205  	}
  2206  	if m.clearedmetas {
  2207  		edges = append(edges, alert.EdgeMetas)
  2208  	}
  2209  	return edges
  2210  }
  2211  
  2212  // EdgeCleared returns a boolean which indicates if the edge with the given name
  2213  // was cleared in this mutation.
  2214  func (m *AlertMutation) EdgeCleared(name string) bool {
  2215  	switch name {
  2216  	case alert.EdgeOwner:
  2217  		return m.clearedowner
  2218  	case alert.EdgeDecisions:
  2219  		return m.cleareddecisions
  2220  	case alert.EdgeEvents:
  2221  		return m.clearedevents
  2222  	case alert.EdgeMetas:
  2223  		return m.clearedmetas
  2224  	}
  2225  	return false
  2226  }
  2227  
  2228  // ClearEdge clears the value of the edge with the given name. It returns an error
  2229  // if that edge is not defined in the schema.
  2230  func (m *AlertMutation) ClearEdge(name string) error {
  2231  	switch name {
  2232  	case alert.EdgeOwner:
  2233  		m.ClearOwner()
  2234  		return nil
  2235  	}
  2236  	return fmt.Errorf("unknown Alert unique edge %s", name)
  2237  }
  2238  
  2239  // ResetEdge resets all changes to the edge with the given name in this mutation.
  2240  // It returns an error if the edge is not defined in the schema.
  2241  func (m *AlertMutation) ResetEdge(name string) error {
  2242  	switch name {
  2243  	case alert.EdgeOwner:
  2244  		m.ResetOwner()
  2245  		return nil
  2246  	case alert.EdgeDecisions:
  2247  		m.ResetDecisions()
  2248  		return nil
  2249  	case alert.EdgeEvents:
  2250  		m.ResetEvents()
  2251  		return nil
  2252  	case alert.EdgeMetas:
  2253  		m.ResetMetas()
  2254  		return nil
  2255  	}
  2256  	return fmt.Errorf("unknown Alert edge %s", name)
  2257  }
  2258  
  2259  // BouncerMutation represents an operation that mutates the Bouncer nodes in the graph.
  2260  type BouncerMutation struct {
  2261  	config
  2262  	op            Op
  2263  	typ           string
  2264  	id            *int
  2265  	created_at    *time.Time
  2266  	updated_at    *time.Time
  2267  	name          *string
  2268  	api_key       *string
  2269  	revoked       *bool
  2270  	ip_address    *string
  2271  	_type         *string
  2272  	version       *string
  2273  	until         *time.Time
  2274  	last_pull     *time.Time
  2275  	clearedFields map[string]struct{}
  2276  	done          bool
  2277  	oldValue      func(context.Context) (*Bouncer, error)
  2278  	predicates    []predicate.Bouncer
  2279  }
  2280  
  2281  var _ ent.Mutation = (*BouncerMutation)(nil)
  2282  
  2283  // bouncerOption allows management of the mutation configuration using functional options.
  2284  type bouncerOption func(*BouncerMutation)
  2285  
  2286  // newBouncerMutation creates new mutation for the Bouncer entity.
  2287  func newBouncerMutation(c config, op Op, opts ...bouncerOption) *BouncerMutation {
  2288  	m := &BouncerMutation{
  2289  		config:        c,
  2290  		op:            op,
  2291  		typ:           TypeBouncer,
  2292  		clearedFields: make(map[string]struct{}),
  2293  	}
  2294  	for _, opt := range opts {
  2295  		opt(m)
  2296  	}
  2297  	return m
  2298  }
  2299  
  2300  // withBouncerID sets the ID field of the mutation.
  2301  func withBouncerID(id int) bouncerOption {
  2302  	return func(m *BouncerMutation) {
  2303  		var (
  2304  			err   error
  2305  			once  sync.Once
  2306  			value *Bouncer
  2307  		)
  2308  		m.oldValue = func(ctx context.Context) (*Bouncer, error) {
  2309  			once.Do(func() {
  2310  				if m.done {
  2311  					err = fmt.Errorf("querying old values post mutation is not allowed")
  2312  				} else {
  2313  					value, err = m.Client().Bouncer.Get(ctx, id)
  2314  				}
  2315  			})
  2316  			return value, err
  2317  		}
  2318  		m.id = &id
  2319  	}
  2320  }
  2321  
  2322  // withBouncer sets the old Bouncer of the mutation.
  2323  func withBouncer(node *Bouncer) bouncerOption {
  2324  	return func(m *BouncerMutation) {
  2325  		m.oldValue = func(context.Context) (*Bouncer, error) {
  2326  			return node, nil
  2327  		}
  2328  		m.id = &node.ID
  2329  	}
  2330  }
  2331  
  2332  // Client returns a new `ent.Client` from the mutation. If the mutation was
  2333  // executed in a transaction (ent.Tx), a transactional client is returned.
  2334  func (m BouncerMutation) Client() *Client {
  2335  	client := &Client{config: m.config}
  2336  	client.init()
  2337  	return client
  2338  }
  2339  
  2340  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2341  // it returns an error otherwise.
  2342  func (m BouncerMutation) Tx() (*Tx, error) {
  2343  	if _, ok := m.driver.(*txDriver); !ok {
  2344  		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
  2345  	}
  2346  	tx := &Tx{config: m.config}
  2347  	tx.init()
  2348  	return tx, nil
  2349  }
  2350  
  2351  // ID returns the ID value in the mutation. Note that the ID
  2352  // is only available if it was provided to the builder.
  2353  func (m *BouncerMutation) ID() (id int, exists bool) {
  2354  	if m.id == nil {
  2355  		return
  2356  	}
  2357  	return *m.id, true
  2358  }
  2359  
  2360  // SetCreatedAt sets the "created_at" field.
  2361  func (m *BouncerMutation) SetCreatedAt(t time.Time) {
  2362  	m.created_at = &t
  2363  }
  2364  
  2365  // CreatedAt returns the value of the "created_at" field in the mutation.
  2366  func (m *BouncerMutation) CreatedAt() (r time.Time, exists bool) {
  2367  	v := m.created_at
  2368  	if v == nil {
  2369  		return
  2370  	}
  2371  	return *v, true
  2372  }
  2373  
  2374  // OldCreatedAt returns the old "created_at" field's value of the Bouncer entity.
  2375  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2376  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2377  func (m *BouncerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2378  	if !m.op.Is(OpUpdateOne) {
  2379  		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
  2380  	}
  2381  	if m.id == nil || m.oldValue == nil {
  2382  		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
  2383  	}
  2384  	oldValue, err := m.oldValue(ctx)
  2385  	if err != nil {
  2386  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2387  	}
  2388  	return oldValue.CreatedAt, nil
  2389  }
  2390  
  2391  // ResetCreatedAt resets all changes to the "created_at" field.
  2392  func (m *BouncerMutation) ResetCreatedAt() {
  2393  	m.created_at = nil
  2394  }
  2395  
  2396  // SetUpdatedAt sets the "updated_at" field.
  2397  func (m *BouncerMutation) SetUpdatedAt(t time.Time) {
  2398  	m.updated_at = &t
  2399  }
  2400  
  2401  // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2402  func (m *BouncerMutation) UpdatedAt() (r time.Time, exists bool) {
  2403  	v := m.updated_at
  2404  	if v == nil {
  2405  		return
  2406  	}
  2407  	return *v, true
  2408  }
  2409  
  2410  // OldUpdatedAt returns the old "updated_at" field's value of the Bouncer entity.
  2411  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2412  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2413  func (m *BouncerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2414  	if !m.op.Is(OpUpdateOne) {
  2415  		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
  2416  	}
  2417  	if m.id == nil || m.oldValue == nil {
  2418  		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
  2419  	}
  2420  	oldValue, err := m.oldValue(ctx)
  2421  	if err != nil {
  2422  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2423  	}
  2424  	return oldValue.UpdatedAt, nil
  2425  }
  2426  
  2427  // ResetUpdatedAt resets all changes to the "updated_at" field.
  2428  func (m *BouncerMutation) ResetUpdatedAt() {
  2429  	m.updated_at = nil
  2430  }
  2431  
  2432  // SetName sets the "name" field.
  2433  func (m *BouncerMutation) SetName(s string) {
  2434  	m.name = &s
  2435  }
  2436  
  2437  // Name returns the value of the "name" field in the mutation.
  2438  func (m *BouncerMutation) Name() (r string, exists bool) {
  2439  	v := m.name
  2440  	if v == nil {
  2441  		return
  2442  	}
  2443  	return *v, true
  2444  }
  2445  
  2446  // OldName returns the old "name" field's value of the Bouncer entity.
  2447  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2448  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2449  func (m *BouncerMutation) OldName(ctx context.Context) (v string, err error) {
  2450  	if !m.op.Is(OpUpdateOne) {
  2451  		return v, fmt.Errorf("OldName is only allowed on UpdateOne operations")
  2452  	}
  2453  	if m.id == nil || m.oldValue == nil {
  2454  		return v, fmt.Errorf("OldName requires an ID field in the mutation")
  2455  	}
  2456  	oldValue, err := m.oldValue(ctx)
  2457  	if err != nil {
  2458  		return v, fmt.Errorf("querying old value for OldName: %w", err)
  2459  	}
  2460  	return oldValue.Name, nil
  2461  }
  2462  
  2463  // ResetName resets all changes to the "name" field.
  2464  func (m *BouncerMutation) ResetName() {
  2465  	m.name = nil
  2466  }
  2467  
  2468  // SetAPIKey sets the "api_key" field.
  2469  func (m *BouncerMutation) SetAPIKey(s string) {
  2470  	m.api_key = &s
  2471  }
  2472  
  2473  // APIKey returns the value of the "api_key" field in the mutation.
  2474  func (m *BouncerMutation) APIKey() (r string, exists bool) {
  2475  	v := m.api_key
  2476  	if v == nil {
  2477  		return
  2478  	}
  2479  	return *v, true
  2480  }
  2481  
  2482  // OldAPIKey returns the old "api_key" field's value of the Bouncer entity.
  2483  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2484  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2485  func (m *BouncerMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  2486  	if !m.op.Is(OpUpdateOne) {
  2487  		return v, fmt.Errorf("OldAPIKey is only allowed on UpdateOne operations")
  2488  	}
  2489  	if m.id == nil || m.oldValue == nil {
  2490  		return v, fmt.Errorf("OldAPIKey requires an ID field in the mutation")
  2491  	}
  2492  	oldValue, err := m.oldValue(ctx)
  2493  	if err != nil {
  2494  		return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  2495  	}
  2496  	return oldValue.APIKey, nil
  2497  }
  2498  
  2499  // ResetAPIKey resets all changes to the "api_key" field.
  2500  func (m *BouncerMutation) ResetAPIKey() {
  2501  	m.api_key = nil
  2502  }
  2503  
  2504  // SetRevoked sets the "revoked" field.
  2505  func (m *BouncerMutation) SetRevoked(b bool) {
  2506  	m.revoked = &b
  2507  }
  2508  
  2509  // Revoked returns the value of the "revoked" field in the mutation.
  2510  func (m *BouncerMutation) Revoked() (r bool, exists bool) {
  2511  	v := m.revoked
  2512  	if v == nil {
  2513  		return
  2514  	}
  2515  	return *v, true
  2516  }
  2517  
  2518  // OldRevoked returns the old "revoked" field's value of the Bouncer entity.
  2519  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2520  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2521  func (m *BouncerMutation) OldRevoked(ctx context.Context) (v bool, err error) {
  2522  	if !m.op.Is(OpUpdateOne) {
  2523  		return v, fmt.Errorf("OldRevoked is only allowed on UpdateOne operations")
  2524  	}
  2525  	if m.id == nil || m.oldValue == nil {
  2526  		return v, fmt.Errorf("OldRevoked requires an ID field in the mutation")
  2527  	}
  2528  	oldValue, err := m.oldValue(ctx)
  2529  	if err != nil {
  2530  		return v, fmt.Errorf("querying old value for OldRevoked: %w", err)
  2531  	}
  2532  	return oldValue.Revoked, nil
  2533  }
  2534  
  2535  // ResetRevoked resets all changes to the "revoked" field.
  2536  func (m *BouncerMutation) ResetRevoked() {
  2537  	m.revoked = nil
  2538  }
  2539  
  2540  // SetIPAddress sets the "ip_address" field.
  2541  func (m *BouncerMutation) SetIPAddress(s string) {
  2542  	m.ip_address = &s
  2543  }
  2544  
  2545  // IPAddress returns the value of the "ip_address" field in the mutation.
  2546  func (m *BouncerMutation) IPAddress() (r string, exists bool) {
  2547  	v := m.ip_address
  2548  	if v == nil {
  2549  		return
  2550  	}
  2551  	return *v, true
  2552  }
  2553  
  2554  // OldIPAddress returns the old "ip_address" field's value of the Bouncer entity.
  2555  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2556  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2557  func (m *BouncerMutation) OldIPAddress(ctx context.Context) (v string, err error) {
  2558  	if !m.op.Is(OpUpdateOne) {
  2559  		return v, fmt.Errorf("OldIPAddress is only allowed on UpdateOne operations")
  2560  	}
  2561  	if m.id == nil || m.oldValue == nil {
  2562  		return v, fmt.Errorf("OldIPAddress requires an ID field in the mutation")
  2563  	}
  2564  	oldValue, err := m.oldValue(ctx)
  2565  	if err != nil {
  2566  		return v, fmt.Errorf("querying old value for OldIPAddress: %w", err)
  2567  	}
  2568  	return oldValue.IPAddress, nil
  2569  }
  2570  
  2571  // ClearIPAddress clears the value of the "ip_address" field.
  2572  func (m *BouncerMutation) ClearIPAddress() {
  2573  	m.ip_address = nil
  2574  	m.clearedFields[bouncer.FieldIPAddress] = struct{}{}
  2575  }
  2576  
  2577  // IPAddressCleared returns if the "ip_address" field was cleared in this mutation.
  2578  func (m *BouncerMutation) IPAddressCleared() bool {
  2579  	_, ok := m.clearedFields[bouncer.FieldIPAddress]
  2580  	return ok
  2581  }
  2582  
  2583  // ResetIPAddress resets all changes to the "ip_address" field.
  2584  func (m *BouncerMutation) ResetIPAddress() {
  2585  	m.ip_address = nil
  2586  	delete(m.clearedFields, bouncer.FieldIPAddress)
  2587  }
  2588  
  2589  // SetType sets the "type" field.
  2590  func (m *BouncerMutation) SetType(s string) {
  2591  	m._type = &s
  2592  }
  2593  
  2594  // GetType returns the value of the "type" field in the mutation.
  2595  func (m *BouncerMutation) GetType() (r string, exists bool) {
  2596  	v := m._type
  2597  	if v == nil {
  2598  		return
  2599  	}
  2600  	return *v, true
  2601  }
  2602  
  2603  // OldType returns the old "type" field's value of the Bouncer entity.
  2604  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2605  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2606  func (m *BouncerMutation) OldType(ctx context.Context) (v string, err error) {
  2607  	if !m.op.Is(OpUpdateOne) {
  2608  		return v, fmt.Errorf("OldType is only allowed on UpdateOne operations")
  2609  	}
  2610  	if m.id == nil || m.oldValue == nil {
  2611  		return v, fmt.Errorf("OldType requires an ID field in the mutation")
  2612  	}
  2613  	oldValue, err := m.oldValue(ctx)
  2614  	if err != nil {
  2615  		return v, fmt.Errorf("querying old value for OldType: %w", err)
  2616  	}
  2617  	return oldValue.Type, nil
  2618  }
  2619  
  2620  // ClearType clears the value of the "type" field.
  2621  func (m *BouncerMutation) ClearType() {
  2622  	m._type = nil
  2623  	m.clearedFields[bouncer.FieldType] = struct{}{}
  2624  }
  2625  
  2626  // TypeCleared returns if the "type" field was cleared in this mutation.
  2627  func (m *BouncerMutation) TypeCleared() bool {
  2628  	_, ok := m.clearedFields[bouncer.FieldType]
  2629  	return ok
  2630  }
  2631  
  2632  // ResetType resets all changes to the "type" field.
  2633  func (m *BouncerMutation) ResetType() {
  2634  	m._type = nil
  2635  	delete(m.clearedFields, bouncer.FieldType)
  2636  }
  2637  
  2638  // SetVersion sets the "version" field.
  2639  func (m *BouncerMutation) SetVersion(s string) {
  2640  	m.version = &s
  2641  }
  2642  
  2643  // Version returns the value of the "version" field in the mutation.
  2644  func (m *BouncerMutation) Version() (r string, exists bool) {
  2645  	v := m.version
  2646  	if v == nil {
  2647  		return
  2648  	}
  2649  	return *v, true
  2650  }
  2651  
  2652  // OldVersion returns the old "version" field's value of the Bouncer entity.
  2653  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2654  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2655  func (m *BouncerMutation) OldVersion(ctx context.Context) (v string, err error) {
  2656  	if !m.op.Is(OpUpdateOne) {
  2657  		return v, fmt.Errorf("OldVersion is only allowed on UpdateOne operations")
  2658  	}
  2659  	if m.id == nil || m.oldValue == nil {
  2660  		return v, fmt.Errorf("OldVersion requires an ID field in the mutation")
  2661  	}
  2662  	oldValue, err := m.oldValue(ctx)
  2663  	if err != nil {
  2664  		return v, fmt.Errorf("querying old value for OldVersion: %w", err)
  2665  	}
  2666  	return oldValue.Version, nil
  2667  }
  2668  
  2669  // ClearVersion clears the value of the "version" field.
  2670  func (m *BouncerMutation) ClearVersion() {
  2671  	m.version = nil
  2672  	m.clearedFields[bouncer.FieldVersion] = struct{}{}
  2673  }
  2674  
  2675  // VersionCleared returns if the "version" field was cleared in this mutation.
  2676  func (m *BouncerMutation) VersionCleared() bool {
  2677  	_, ok := m.clearedFields[bouncer.FieldVersion]
  2678  	return ok
  2679  }
  2680  
  2681  // ResetVersion resets all changes to the "version" field.
  2682  func (m *BouncerMutation) ResetVersion() {
  2683  	m.version = nil
  2684  	delete(m.clearedFields, bouncer.FieldVersion)
  2685  }
  2686  
  2687  // SetUntil sets the "until" field.
  2688  func (m *BouncerMutation) SetUntil(t time.Time) {
  2689  	m.until = &t
  2690  }
  2691  
  2692  // Until returns the value of the "until" field in the mutation.
  2693  func (m *BouncerMutation) Until() (r time.Time, exists bool) {
  2694  	v := m.until
  2695  	if v == nil {
  2696  		return
  2697  	}
  2698  	return *v, true
  2699  }
  2700  
  2701  // OldUntil returns the old "until" field's value of the Bouncer entity.
  2702  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2703  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2704  func (m *BouncerMutation) OldUntil(ctx context.Context) (v time.Time, err error) {
  2705  	if !m.op.Is(OpUpdateOne) {
  2706  		return v, fmt.Errorf("OldUntil is only allowed on UpdateOne operations")
  2707  	}
  2708  	if m.id == nil || m.oldValue == nil {
  2709  		return v, fmt.Errorf("OldUntil requires an ID field in the mutation")
  2710  	}
  2711  	oldValue, err := m.oldValue(ctx)
  2712  	if err != nil {
  2713  		return v, fmt.Errorf("querying old value for OldUntil: %w", err)
  2714  	}
  2715  	return oldValue.Until, nil
  2716  }
  2717  
  2718  // ClearUntil clears the value of the "until" field.
  2719  func (m *BouncerMutation) ClearUntil() {
  2720  	m.until = nil
  2721  	m.clearedFields[bouncer.FieldUntil] = struct{}{}
  2722  }
  2723  
  2724  // UntilCleared returns if the "until" field was cleared in this mutation.
  2725  func (m *BouncerMutation) UntilCleared() bool {
  2726  	_, ok := m.clearedFields[bouncer.FieldUntil]
  2727  	return ok
  2728  }
  2729  
  2730  // ResetUntil resets all changes to the "until" field.
  2731  func (m *BouncerMutation) ResetUntil() {
  2732  	m.until = nil
  2733  	delete(m.clearedFields, bouncer.FieldUntil)
  2734  }
  2735  
  2736  // SetLastPull sets the "last_pull" field.
  2737  func (m *BouncerMutation) SetLastPull(t time.Time) {
  2738  	m.last_pull = &t
  2739  }
  2740  
  2741  // LastPull returns the value of the "last_pull" field in the mutation.
  2742  func (m *BouncerMutation) LastPull() (r time.Time, exists bool) {
  2743  	v := m.last_pull
  2744  	if v == nil {
  2745  		return
  2746  	}
  2747  	return *v, true
  2748  }
  2749  
  2750  // OldLastPull returns the old "last_pull" field's value of the Bouncer entity.
  2751  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2752  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2753  func (m *BouncerMutation) OldLastPull(ctx context.Context) (v time.Time, err error) {
  2754  	if !m.op.Is(OpUpdateOne) {
  2755  		return v, fmt.Errorf("OldLastPull is only allowed on UpdateOne operations")
  2756  	}
  2757  	if m.id == nil || m.oldValue == nil {
  2758  		return v, fmt.Errorf("OldLastPull requires an ID field in the mutation")
  2759  	}
  2760  	oldValue, err := m.oldValue(ctx)
  2761  	if err != nil {
  2762  		return v, fmt.Errorf("querying old value for OldLastPull: %w", err)
  2763  	}
  2764  	return oldValue.LastPull, nil
  2765  }
  2766  
  2767  // ResetLastPull resets all changes to the "last_pull" field.
  2768  func (m *BouncerMutation) ResetLastPull() {
  2769  	m.last_pull = nil
  2770  }
  2771  
  2772  // Op returns the operation name.
  2773  func (m *BouncerMutation) Op() Op {
  2774  	return m.op
  2775  }
  2776  
  2777  // Type returns the node type of this mutation (Bouncer).
  2778  func (m *BouncerMutation) Type() string {
  2779  	return m.typ
  2780  }
  2781  
  2782  // Fields returns all fields that were changed during this mutation. Note that in
  2783  // order to get all numeric fields that were incremented/decremented, call
  2784  // AddedFields().
  2785  func (m *BouncerMutation) Fields() []string {
  2786  	fields := make([]string, 0, 10)
  2787  	if m.created_at != nil {
  2788  		fields = append(fields, bouncer.FieldCreatedAt)
  2789  	}
  2790  	if m.updated_at != nil {
  2791  		fields = append(fields, bouncer.FieldUpdatedAt)
  2792  	}
  2793  	if m.name != nil {
  2794  		fields = append(fields, bouncer.FieldName)
  2795  	}
  2796  	if m.api_key != nil {
  2797  		fields = append(fields, bouncer.FieldAPIKey)
  2798  	}
  2799  	if m.revoked != nil {
  2800  		fields = append(fields, bouncer.FieldRevoked)
  2801  	}
  2802  	if m.ip_address != nil {
  2803  		fields = append(fields, bouncer.FieldIPAddress)
  2804  	}
  2805  	if m._type != nil {
  2806  		fields = append(fields, bouncer.FieldType)
  2807  	}
  2808  	if m.version != nil {
  2809  		fields = append(fields, bouncer.FieldVersion)
  2810  	}
  2811  	if m.until != nil {
  2812  		fields = append(fields, bouncer.FieldUntil)
  2813  	}
  2814  	if m.last_pull != nil {
  2815  		fields = append(fields, bouncer.FieldLastPull)
  2816  	}
  2817  	return fields
  2818  }
  2819  
  2820  // Field returns the value of a field with the given name. The second boolean
  2821  // return value indicates that this field was not set, or was not defined in the
  2822  // schema.
  2823  func (m *BouncerMutation) Field(name string) (ent.Value, bool) {
  2824  	switch name {
  2825  	case bouncer.FieldCreatedAt:
  2826  		return m.CreatedAt()
  2827  	case bouncer.FieldUpdatedAt:
  2828  		return m.UpdatedAt()
  2829  	case bouncer.FieldName:
  2830  		return m.Name()
  2831  	case bouncer.FieldAPIKey:
  2832  		return m.APIKey()
  2833  	case bouncer.FieldRevoked:
  2834  		return m.Revoked()
  2835  	case bouncer.FieldIPAddress:
  2836  		return m.IPAddress()
  2837  	case bouncer.FieldType:
  2838  		return m.GetType()
  2839  	case bouncer.FieldVersion:
  2840  		return m.Version()
  2841  	case bouncer.FieldUntil:
  2842  		return m.Until()
  2843  	case bouncer.FieldLastPull:
  2844  		return m.LastPull()
  2845  	}
  2846  	return nil, false
  2847  }
  2848  
  2849  // OldField returns the old value of the field from the database. An error is
  2850  // returned if the mutation operation is not UpdateOne, or the query to the
  2851  // database failed.
  2852  func (m *BouncerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2853  	switch name {
  2854  	case bouncer.FieldCreatedAt:
  2855  		return m.OldCreatedAt(ctx)
  2856  	case bouncer.FieldUpdatedAt:
  2857  		return m.OldUpdatedAt(ctx)
  2858  	case bouncer.FieldName:
  2859  		return m.OldName(ctx)
  2860  	case bouncer.FieldAPIKey:
  2861  		return m.OldAPIKey(ctx)
  2862  	case bouncer.FieldRevoked:
  2863  		return m.OldRevoked(ctx)
  2864  	case bouncer.FieldIPAddress:
  2865  		return m.OldIPAddress(ctx)
  2866  	case bouncer.FieldType:
  2867  		return m.OldType(ctx)
  2868  	case bouncer.FieldVersion:
  2869  		return m.OldVersion(ctx)
  2870  	case bouncer.FieldUntil:
  2871  		return m.OldUntil(ctx)
  2872  	case bouncer.FieldLastPull:
  2873  		return m.OldLastPull(ctx)
  2874  	}
  2875  	return nil, fmt.Errorf("unknown Bouncer field %s", name)
  2876  }
  2877  
  2878  // SetField sets the value of a field with the given name. It returns an error if
  2879  // the field is not defined in the schema, or if the type mismatched the field
  2880  // type.
  2881  func (m *BouncerMutation) SetField(name string, value ent.Value) error {
  2882  	switch name {
  2883  	case bouncer.FieldCreatedAt:
  2884  		v, ok := value.(time.Time)
  2885  		if !ok {
  2886  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2887  		}
  2888  		m.SetCreatedAt(v)
  2889  		return nil
  2890  	case bouncer.FieldUpdatedAt:
  2891  		v, ok := value.(time.Time)
  2892  		if !ok {
  2893  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2894  		}
  2895  		m.SetUpdatedAt(v)
  2896  		return nil
  2897  	case bouncer.FieldName:
  2898  		v, ok := value.(string)
  2899  		if !ok {
  2900  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2901  		}
  2902  		m.SetName(v)
  2903  		return nil
  2904  	case bouncer.FieldAPIKey:
  2905  		v, ok := value.(string)
  2906  		if !ok {
  2907  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2908  		}
  2909  		m.SetAPIKey(v)
  2910  		return nil
  2911  	case bouncer.FieldRevoked:
  2912  		v, ok := value.(bool)
  2913  		if !ok {
  2914  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2915  		}
  2916  		m.SetRevoked(v)
  2917  		return nil
  2918  	case bouncer.FieldIPAddress:
  2919  		v, ok := value.(string)
  2920  		if !ok {
  2921  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2922  		}
  2923  		m.SetIPAddress(v)
  2924  		return nil
  2925  	case bouncer.FieldType:
  2926  		v, ok := value.(string)
  2927  		if !ok {
  2928  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2929  		}
  2930  		m.SetType(v)
  2931  		return nil
  2932  	case bouncer.FieldVersion:
  2933  		v, ok := value.(string)
  2934  		if !ok {
  2935  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2936  		}
  2937  		m.SetVersion(v)
  2938  		return nil
  2939  	case bouncer.FieldUntil:
  2940  		v, ok := value.(time.Time)
  2941  		if !ok {
  2942  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2943  		}
  2944  		m.SetUntil(v)
  2945  		return nil
  2946  	case bouncer.FieldLastPull:
  2947  		v, ok := value.(time.Time)
  2948  		if !ok {
  2949  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2950  		}
  2951  		m.SetLastPull(v)
  2952  		return nil
  2953  	}
  2954  	return fmt.Errorf("unknown Bouncer field %s", name)
  2955  }
  2956  
  2957  // AddedFields returns all numeric fields that were incremented/decremented during
  2958  // this mutation.
  2959  func (m *BouncerMutation) AddedFields() []string {
  2960  	return nil
  2961  }
  2962  
  2963  // AddedField returns the numeric value that was incremented/decremented on a field
  2964  // with the given name. The second boolean return value indicates that this field
  2965  // was not set, or was not defined in the schema.
  2966  func (m *BouncerMutation) AddedField(name string) (ent.Value, bool) {
  2967  	return nil, false
  2968  }
  2969  
  2970  // AddField adds the value to the field with the given name. It returns an error if
  2971  // the field is not defined in the schema, or if the type mismatched the field
  2972  // type.
  2973  func (m *BouncerMutation) AddField(name string, value ent.Value) error {
  2974  	switch name {
  2975  	}
  2976  	return fmt.Errorf("unknown Bouncer numeric field %s", name)
  2977  }
  2978  
  2979  // ClearedFields returns all nullable fields that were cleared during this
  2980  // mutation.
  2981  func (m *BouncerMutation) ClearedFields() []string {
  2982  	var fields []string
  2983  	if m.FieldCleared(bouncer.FieldIPAddress) {
  2984  		fields = append(fields, bouncer.FieldIPAddress)
  2985  	}
  2986  	if m.FieldCleared(bouncer.FieldType) {
  2987  		fields = append(fields, bouncer.FieldType)
  2988  	}
  2989  	if m.FieldCleared(bouncer.FieldVersion) {
  2990  		fields = append(fields, bouncer.FieldVersion)
  2991  	}
  2992  	if m.FieldCleared(bouncer.FieldUntil) {
  2993  		fields = append(fields, bouncer.FieldUntil)
  2994  	}
  2995  	return fields
  2996  }
  2997  
  2998  // FieldCleared returns a boolean indicating if a field with the given name was
  2999  // cleared in this mutation.
  3000  func (m *BouncerMutation) FieldCleared(name string) bool {
  3001  	_, ok := m.clearedFields[name]
  3002  	return ok
  3003  }
  3004  
  3005  // ClearField clears the value of the field with the given name. It returns an
  3006  // error if the field is not defined in the schema.
  3007  func (m *BouncerMutation) ClearField(name string) error {
  3008  	switch name {
  3009  	case bouncer.FieldIPAddress:
  3010  		m.ClearIPAddress()
  3011  		return nil
  3012  	case bouncer.FieldType:
  3013  		m.ClearType()
  3014  		return nil
  3015  	case bouncer.FieldVersion:
  3016  		m.ClearVersion()
  3017  		return nil
  3018  	case bouncer.FieldUntil:
  3019  		m.ClearUntil()
  3020  		return nil
  3021  	}
  3022  	return fmt.Errorf("unknown Bouncer nullable field %s", name)
  3023  }
  3024  
  3025  // ResetField resets all changes in the mutation for the field with the given name.
  3026  // It returns an error if the field is not defined in the schema.
  3027  func (m *BouncerMutation) ResetField(name string) error {
  3028  	switch name {
  3029  	case bouncer.FieldCreatedAt:
  3030  		m.ResetCreatedAt()
  3031  		return nil
  3032  	case bouncer.FieldUpdatedAt:
  3033  		m.ResetUpdatedAt()
  3034  		return nil
  3035  	case bouncer.FieldName:
  3036  		m.ResetName()
  3037  		return nil
  3038  	case bouncer.FieldAPIKey:
  3039  		m.ResetAPIKey()
  3040  		return nil
  3041  	case bouncer.FieldRevoked:
  3042  		m.ResetRevoked()
  3043  		return nil
  3044  	case bouncer.FieldIPAddress:
  3045  		m.ResetIPAddress()
  3046  		return nil
  3047  	case bouncer.FieldType:
  3048  		m.ResetType()
  3049  		return nil
  3050  	case bouncer.FieldVersion:
  3051  		m.ResetVersion()
  3052  		return nil
  3053  	case bouncer.FieldUntil:
  3054  		m.ResetUntil()
  3055  		return nil
  3056  	case bouncer.FieldLastPull:
  3057  		m.ResetLastPull()
  3058  		return nil
  3059  	}
  3060  	return fmt.Errorf("unknown Bouncer field %s", name)
  3061  }
  3062  
  3063  // AddedEdges returns all edge names that were set/added in this mutation.
  3064  func (m *BouncerMutation) AddedEdges() []string {
  3065  	edges := make([]string, 0, 0)
  3066  	return edges
  3067  }
  3068  
  3069  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3070  // name in this mutation.
  3071  func (m *BouncerMutation) AddedIDs(name string) []ent.Value {
  3072  	return nil
  3073  }
  3074  
  3075  // RemovedEdges returns all edge names that were removed in this mutation.
  3076  func (m *BouncerMutation) RemovedEdges() []string {
  3077  	edges := make([]string, 0, 0)
  3078  	return edges
  3079  }
  3080  
  3081  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3082  // the given name in this mutation.
  3083  func (m *BouncerMutation) RemovedIDs(name string) []ent.Value {
  3084  	return nil
  3085  }
  3086  
  3087  // ClearedEdges returns all edge names that were cleared in this mutation.
  3088  func (m *BouncerMutation) ClearedEdges() []string {
  3089  	edges := make([]string, 0, 0)
  3090  	return edges
  3091  }
  3092  
  3093  // EdgeCleared returns a boolean which indicates if the edge with the given name
  3094  // was cleared in this mutation.
  3095  func (m *BouncerMutation) EdgeCleared(name string) bool {
  3096  	return false
  3097  }
  3098  
  3099  // ClearEdge clears the value of the edge with the given name. It returns an error
  3100  // if that edge is not defined in the schema.
  3101  func (m *BouncerMutation) ClearEdge(name string) error {
  3102  	return fmt.Errorf("unknown Bouncer unique edge %s", name)
  3103  }
  3104  
  3105  // ResetEdge resets all changes to the edge with the given name in this mutation.
  3106  // It returns an error if the edge is not defined in the schema.
  3107  func (m *BouncerMutation) ResetEdge(name string) error {
  3108  	return fmt.Errorf("unknown Bouncer edge %s", name)
  3109  }
  3110  
  3111  // DecisionMutation represents an operation that mutates the Decision nodes in the graph.
  3112  type DecisionMutation struct {
  3113  	config
  3114  	op              Op
  3115  	typ             string
  3116  	id              *int
  3117  	created_at      *time.Time
  3118  	updated_at      *time.Time
  3119  	until           *time.Time
  3120  	scenario        *string
  3121  	_type           *string
  3122  	start_ip        *int64
  3123  	addstart_ip     *int64
  3124  	end_ip          *int64
  3125  	addend_ip       *int64
  3126  	start_suffix    *int64
  3127  	addstart_suffix *int64
  3128  	end_suffix      *int64
  3129  	addend_suffix   *int64
  3130  	ip_size         *int64
  3131  	addip_size      *int64
  3132  	scope           *string
  3133  	value           *string
  3134  	origin          *string
  3135  	simulated       *bool
  3136  	clearedFields   map[string]struct{}
  3137  	owner           *int
  3138  	clearedowner    bool
  3139  	done            bool
  3140  	oldValue        func(context.Context) (*Decision, error)
  3141  	predicates      []predicate.Decision
  3142  }
  3143  
  3144  var _ ent.Mutation = (*DecisionMutation)(nil)
  3145  
  3146  // decisionOption allows management of the mutation configuration using functional options.
  3147  type decisionOption func(*DecisionMutation)
  3148  
  3149  // newDecisionMutation creates new mutation for the Decision entity.
  3150  func newDecisionMutation(c config, op Op, opts ...decisionOption) *DecisionMutation {
  3151  	m := &DecisionMutation{
  3152  		config:        c,
  3153  		op:            op,
  3154  		typ:           TypeDecision,
  3155  		clearedFields: make(map[string]struct{}),
  3156  	}
  3157  	for _, opt := range opts {
  3158  		opt(m)
  3159  	}
  3160  	return m
  3161  }
  3162  
  3163  // withDecisionID sets the ID field of the mutation.
  3164  func withDecisionID(id int) decisionOption {
  3165  	return func(m *DecisionMutation) {
  3166  		var (
  3167  			err   error
  3168  			once  sync.Once
  3169  			value *Decision
  3170  		)
  3171  		m.oldValue = func(ctx context.Context) (*Decision, error) {
  3172  			once.Do(func() {
  3173  				if m.done {
  3174  					err = fmt.Errorf("querying old values post mutation is not allowed")
  3175  				} else {
  3176  					value, err = m.Client().Decision.Get(ctx, id)
  3177  				}
  3178  			})
  3179  			return value, err
  3180  		}
  3181  		m.id = &id
  3182  	}
  3183  }
  3184  
  3185  // withDecision sets the old Decision of the mutation.
  3186  func withDecision(node *Decision) decisionOption {
  3187  	return func(m *DecisionMutation) {
  3188  		m.oldValue = func(context.Context) (*Decision, error) {
  3189  			return node, nil
  3190  		}
  3191  		m.id = &node.ID
  3192  	}
  3193  }
  3194  
  3195  // Client returns a new `ent.Client` from the mutation. If the mutation was
  3196  // executed in a transaction (ent.Tx), a transactional client is returned.
  3197  func (m DecisionMutation) Client() *Client {
  3198  	client := &Client{config: m.config}
  3199  	client.init()
  3200  	return client
  3201  }
  3202  
  3203  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3204  // it returns an error otherwise.
  3205  func (m DecisionMutation) Tx() (*Tx, error) {
  3206  	if _, ok := m.driver.(*txDriver); !ok {
  3207  		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
  3208  	}
  3209  	tx := &Tx{config: m.config}
  3210  	tx.init()
  3211  	return tx, nil
  3212  }
  3213  
  3214  // ID returns the ID value in the mutation. Note that the ID
  3215  // is only available if it was provided to the builder.
  3216  func (m *DecisionMutation) ID() (id int, exists bool) {
  3217  	if m.id == nil {
  3218  		return
  3219  	}
  3220  	return *m.id, true
  3221  }
  3222  
  3223  // SetCreatedAt sets the "created_at" field.
  3224  func (m *DecisionMutation) SetCreatedAt(t time.Time) {
  3225  	m.created_at = &t
  3226  }
  3227  
  3228  // CreatedAt returns the value of the "created_at" field in the mutation.
  3229  func (m *DecisionMutation) CreatedAt() (r time.Time, exists bool) {
  3230  	v := m.created_at
  3231  	if v == nil {
  3232  		return
  3233  	}
  3234  	return *v, true
  3235  }
  3236  
  3237  // OldCreatedAt returns the old "created_at" field's value of the Decision entity.
  3238  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3239  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3240  func (m *DecisionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3241  	if !m.op.Is(OpUpdateOne) {
  3242  		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
  3243  	}
  3244  	if m.id == nil || m.oldValue == nil {
  3245  		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
  3246  	}
  3247  	oldValue, err := m.oldValue(ctx)
  3248  	if err != nil {
  3249  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3250  	}
  3251  	return oldValue.CreatedAt, nil
  3252  }
  3253  
  3254  // ResetCreatedAt resets all changes to the "created_at" field.
  3255  func (m *DecisionMutation) ResetCreatedAt() {
  3256  	m.created_at = nil
  3257  }
  3258  
  3259  // SetUpdatedAt sets the "updated_at" field.
  3260  func (m *DecisionMutation) SetUpdatedAt(t time.Time) {
  3261  	m.updated_at = &t
  3262  }
  3263  
  3264  // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3265  func (m *DecisionMutation) UpdatedAt() (r time.Time, exists bool) {
  3266  	v := m.updated_at
  3267  	if v == nil {
  3268  		return
  3269  	}
  3270  	return *v, true
  3271  }
  3272  
  3273  // OldUpdatedAt returns the old "updated_at" field's value of the Decision entity.
  3274  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3275  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3276  func (m *DecisionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3277  	if !m.op.Is(OpUpdateOne) {
  3278  		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
  3279  	}
  3280  	if m.id == nil || m.oldValue == nil {
  3281  		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
  3282  	}
  3283  	oldValue, err := m.oldValue(ctx)
  3284  	if err != nil {
  3285  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3286  	}
  3287  	return oldValue.UpdatedAt, nil
  3288  }
  3289  
  3290  // ResetUpdatedAt resets all changes to the "updated_at" field.
  3291  func (m *DecisionMutation) ResetUpdatedAt() {
  3292  	m.updated_at = nil
  3293  }
  3294  
  3295  // SetUntil sets the "until" field.
  3296  func (m *DecisionMutation) SetUntil(t time.Time) {
  3297  	m.until = &t
  3298  }
  3299  
  3300  // Until returns the value of the "until" field in the mutation.
  3301  func (m *DecisionMutation) Until() (r time.Time, exists bool) {
  3302  	v := m.until
  3303  	if v == nil {
  3304  		return
  3305  	}
  3306  	return *v, true
  3307  }
  3308  
  3309  // OldUntil returns the old "until" field's value of the Decision entity.
  3310  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3311  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3312  func (m *DecisionMutation) OldUntil(ctx context.Context) (v time.Time, err error) {
  3313  	if !m.op.Is(OpUpdateOne) {
  3314  		return v, fmt.Errorf("OldUntil is only allowed on UpdateOne operations")
  3315  	}
  3316  	if m.id == nil || m.oldValue == nil {
  3317  		return v, fmt.Errorf("OldUntil requires an ID field in the mutation")
  3318  	}
  3319  	oldValue, err := m.oldValue(ctx)
  3320  	if err != nil {
  3321  		return v, fmt.Errorf("querying old value for OldUntil: %w", err)
  3322  	}
  3323  	return oldValue.Until, nil
  3324  }
  3325  
  3326  // ResetUntil resets all changes to the "until" field.
  3327  func (m *DecisionMutation) ResetUntil() {
  3328  	m.until = nil
  3329  }
  3330  
  3331  // SetScenario sets the "scenario" field.
  3332  func (m *DecisionMutation) SetScenario(s string) {
  3333  	m.scenario = &s
  3334  }
  3335  
  3336  // Scenario returns the value of the "scenario" field in the mutation.
  3337  func (m *DecisionMutation) Scenario() (r string, exists bool) {
  3338  	v := m.scenario
  3339  	if v == nil {
  3340  		return
  3341  	}
  3342  	return *v, true
  3343  }
  3344  
  3345  // OldScenario returns the old "scenario" field's value of the Decision entity.
  3346  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3347  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3348  func (m *DecisionMutation) OldScenario(ctx context.Context) (v string, err error) {
  3349  	if !m.op.Is(OpUpdateOne) {
  3350  		return v, fmt.Errorf("OldScenario is only allowed on UpdateOne operations")
  3351  	}
  3352  	if m.id == nil || m.oldValue == nil {
  3353  		return v, fmt.Errorf("OldScenario requires an ID field in the mutation")
  3354  	}
  3355  	oldValue, err := m.oldValue(ctx)
  3356  	if err != nil {
  3357  		return v, fmt.Errorf("querying old value for OldScenario: %w", err)
  3358  	}
  3359  	return oldValue.Scenario, nil
  3360  }
  3361  
  3362  // ResetScenario resets all changes to the "scenario" field.
  3363  func (m *DecisionMutation) ResetScenario() {
  3364  	m.scenario = nil
  3365  }
  3366  
  3367  // SetType sets the "type" field.
  3368  func (m *DecisionMutation) SetType(s string) {
  3369  	m._type = &s
  3370  }
  3371  
  3372  // GetType returns the value of the "type" field in the mutation.
  3373  func (m *DecisionMutation) GetType() (r string, exists bool) {
  3374  	v := m._type
  3375  	if v == nil {
  3376  		return
  3377  	}
  3378  	return *v, true
  3379  }
  3380  
  3381  // OldType returns the old "type" field's value of the Decision entity.
  3382  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3383  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3384  func (m *DecisionMutation) OldType(ctx context.Context) (v string, err error) {
  3385  	if !m.op.Is(OpUpdateOne) {
  3386  		return v, fmt.Errorf("OldType is only allowed on UpdateOne operations")
  3387  	}
  3388  	if m.id == nil || m.oldValue == nil {
  3389  		return v, fmt.Errorf("OldType requires an ID field in the mutation")
  3390  	}
  3391  	oldValue, err := m.oldValue(ctx)
  3392  	if err != nil {
  3393  		return v, fmt.Errorf("querying old value for OldType: %w", err)
  3394  	}
  3395  	return oldValue.Type, nil
  3396  }
  3397  
  3398  // ResetType resets all changes to the "type" field.
  3399  func (m *DecisionMutation) ResetType() {
  3400  	m._type = nil
  3401  }
  3402  
  3403  // SetStartIP sets the "start_ip" field.
  3404  func (m *DecisionMutation) SetStartIP(i int64) {
  3405  	m.start_ip = &i
  3406  	m.addstart_ip = nil
  3407  }
  3408  
  3409  // StartIP returns the value of the "start_ip" field in the mutation.
  3410  func (m *DecisionMutation) StartIP() (r int64, exists bool) {
  3411  	v := m.start_ip
  3412  	if v == nil {
  3413  		return
  3414  	}
  3415  	return *v, true
  3416  }
  3417  
  3418  // OldStartIP returns the old "start_ip" field's value of the Decision entity.
  3419  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3420  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3421  func (m *DecisionMutation) OldStartIP(ctx context.Context) (v int64, err error) {
  3422  	if !m.op.Is(OpUpdateOne) {
  3423  		return v, fmt.Errorf("OldStartIP is only allowed on UpdateOne operations")
  3424  	}
  3425  	if m.id == nil || m.oldValue == nil {
  3426  		return v, fmt.Errorf("OldStartIP requires an ID field in the mutation")
  3427  	}
  3428  	oldValue, err := m.oldValue(ctx)
  3429  	if err != nil {
  3430  		return v, fmt.Errorf("querying old value for OldStartIP: %w", err)
  3431  	}
  3432  	return oldValue.StartIP, nil
  3433  }
  3434  
  3435  // AddStartIP adds i to the "start_ip" field.
  3436  func (m *DecisionMutation) AddStartIP(i int64) {
  3437  	if m.addstart_ip != nil {
  3438  		*m.addstart_ip += i
  3439  	} else {
  3440  		m.addstart_ip = &i
  3441  	}
  3442  }
  3443  
  3444  // AddedStartIP returns the value that was added to the "start_ip" field in this mutation.
  3445  func (m *DecisionMutation) AddedStartIP() (r int64, exists bool) {
  3446  	v := m.addstart_ip
  3447  	if v == nil {
  3448  		return
  3449  	}
  3450  	return *v, true
  3451  }
  3452  
  3453  // ClearStartIP clears the value of the "start_ip" field.
  3454  func (m *DecisionMutation) ClearStartIP() {
  3455  	m.start_ip = nil
  3456  	m.addstart_ip = nil
  3457  	m.clearedFields[decision.FieldStartIP] = struct{}{}
  3458  }
  3459  
  3460  // StartIPCleared returns if the "start_ip" field was cleared in this mutation.
  3461  func (m *DecisionMutation) StartIPCleared() bool {
  3462  	_, ok := m.clearedFields[decision.FieldStartIP]
  3463  	return ok
  3464  }
  3465  
  3466  // ResetStartIP resets all changes to the "start_ip" field.
  3467  func (m *DecisionMutation) ResetStartIP() {
  3468  	m.start_ip = nil
  3469  	m.addstart_ip = nil
  3470  	delete(m.clearedFields, decision.FieldStartIP)
  3471  }
  3472  
  3473  // SetEndIP sets the "end_ip" field.
  3474  func (m *DecisionMutation) SetEndIP(i int64) {
  3475  	m.end_ip = &i
  3476  	m.addend_ip = nil
  3477  }
  3478  
  3479  // EndIP returns the value of the "end_ip" field in the mutation.
  3480  func (m *DecisionMutation) EndIP() (r int64, exists bool) {
  3481  	v := m.end_ip
  3482  	if v == nil {
  3483  		return
  3484  	}
  3485  	return *v, true
  3486  }
  3487  
  3488  // OldEndIP returns the old "end_ip" field's value of the Decision entity.
  3489  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3490  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3491  func (m *DecisionMutation) OldEndIP(ctx context.Context) (v int64, err error) {
  3492  	if !m.op.Is(OpUpdateOne) {
  3493  		return v, fmt.Errorf("OldEndIP is only allowed on UpdateOne operations")
  3494  	}
  3495  	if m.id == nil || m.oldValue == nil {
  3496  		return v, fmt.Errorf("OldEndIP requires an ID field in the mutation")
  3497  	}
  3498  	oldValue, err := m.oldValue(ctx)
  3499  	if err != nil {
  3500  		return v, fmt.Errorf("querying old value for OldEndIP: %w", err)
  3501  	}
  3502  	return oldValue.EndIP, nil
  3503  }
  3504  
  3505  // AddEndIP adds i to the "end_ip" field.
  3506  func (m *DecisionMutation) AddEndIP(i int64) {
  3507  	if m.addend_ip != nil {
  3508  		*m.addend_ip += i
  3509  	} else {
  3510  		m.addend_ip = &i
  3511  	}
  3512  }
  3513  
  3514  // AddedEndIP returns the value that was added to the "end_ip" field in this mutation.
  3515  func (m *DecisionMutation) AddedEndIP() (r int64, exists bool) {
  3516  	v := m.addend_ip
  3517  	if v == nil {
  3518  		return
  3519  	}
  3520  	return *v, true
  3521  }
  3522  
  3523  // ClearEndIP clears the value of the "end_ip" field.
  3524  func (m *DecisionMutation) ClearEndIP() {
  3525  	m.end_ip = nil
  3526  	m.addend_ip = nil
  3527  	m.clearedFields[decision.FieldEndIP] = struct{}{}
  3528  }
  3529  
  3530  // EndIPCleared returns if the "end_ip" field was cleared in this mutation.
  3531  func (m *DecisionMutation) EndIPCleared() bool {
  3532  	_, ok := m.clearedFields[decision.FieldEndIP]
  3533  	return ok
  3534  }
  3535  
  3536  // ResetEndIP resets all changes to the "end_ip" field.
  3537  func (m *DecisionMutation) ResetEndIP() {
  3538  	m.end_ip = nil
  3539  	m.addend_ip = nil
  3540  	delete(m.clearedFields, decision.FieldEndIP)
  3541  }
  3542  
  3543  // SetStartSuffix sets the "start_suffix" field.
  3544  func (m *DecisionMutation) SetStartSuffix(i int64) {
  3545  	m.start_suffix = &i
  3546  	m.addstart_suffix = nil
  3547  }
  3548  
  3549  // StartSuffix returns the value of the "start_suffix" field in the mutation.
  3550  func (m *DecisionMutation) StartSuffix() (r int64, exists bool) {
  3551  	v := m.start_suffix
  3552  	if v == nil {
  3553  		return
  3554  	}
  3555  	return *v, true
  3556  }
  3557  
  3558  // OldStartSuffix returns the old "start_suffix" field's value of the Decision entity.
  3559  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3560  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3561  func (m *DecisionMutation) OldStartSuffix(ctx context.Context) (v int64, err error) {
  3562  	if !m.op.Is(OpUpdateOne) {
  3563  		return v, fmt.Errorf("OldStartSuffix is only allowed on UpdateOne operations")
  3564  	}
  3565  	if m.id == nil || m.oldValue == nil {
  3566  		return v, fmt.Errorf("OldStartSuffix requires an ID field in the mutation")
  3567  	}
  3568  	oldValue, err := m.oldValue(ctx)
  3569  	if err != nil {
  3570  		return v, fmt.Errorf("querying old value for OldStartSuffix: %w", err)
  3571  	}
  3572  	return oldValue.StartSuffix, nil
  3573  }
  3574  
  3575  // AddStartSuffix adds i to the "start_suffix" field.
  3576  func (m *DecisionMutation) AddStartSuffix(i int64) {
  3577  	if m.addstart_suffix != nil {
  3578  		*m.addstart_suffix += i
  3579  	} else {
  3580  		m.addstart_suffix = &i
  3581  	}
  3582  }
  3583  
  3584  // AddedStartSuffix returns the value that was added to the "start_suffix" field in this mutation.
  3585  func (m *DecisionMutation) AddedStartSuffix() (r int64, exists bool) {
  3586  	v := m.addstart_suffix
  3587  	if v == nil {
  3588  		return
  3589  	}
  3590  	return *v, true
  3591  }
  3592  
  3593  // ClearStartSuffix clears the value of the "start_suffix" field.
  3594  func (m *DecisionMutation) ClearStartSuffix() {
  3595  	m.start_suffix = nil
  3596  	m.addstart_suffix = nil
  3597  	m.clearedFields[decision.FieldStartSuffix] = struct{}{}
  3598  }
  3599  
  3600  // StartSuffixCleared returns if the "start_suffix" field was cleared in this mutation.
  3601  func (m *DecisionMutation) StartSuffixCleared() bool {
  3602  	_, ok := m.clearedFields[decision.FieldStartSuffix]
  3603  	return ok
  3604  }
  3605  
  3606  // ResetStartSuffix resets all changes to the "start_suffix" field.
  3607  func (m *DecisionMutation) ResetStartSuffix() {
  3608  	m.start_suffix = nil
  3609  	m.addstart_suffix = nil
  3610  	delete(m.clearedFields, decision.FieldStartSuffix)
  3611  }
  3612  
  3613  // SetEndSuffix sets the "end_suffix" field.
  3614  func (m *DecisionMutation) SetEndSuffix(i int64) {
  3615  	m.end_suffix = &i
  3616  	m.addend_suffix = nil
  3617  }
  3618  
  3619  // EndSuffix returns the value of the "end_suffix" field in the mutation.
  3620  func (m *DecisionMutation) EndSuffix() (r int64, exists bool) {
  3621  	v := m.end_suffix
  3622  	if v == nil {
  3623  		return
  3624  	}
  3625  	return *v, true
  3626  }
  3627  
  3628  // OldEndSuffix returns the old "end_suffix" field's value of the Decision entity.
  3629  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3630  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3631  func (m *DecisionMutation) OldEndSuffix(ctx context.Context) (v int64, err error) {
  3632  	if !m.op.Is(OpUpdateOne) {
  3633  		return v, fmt.Errorf("OldEndSuffix is only allowed on UpdateOne operations")
  3634  	}
  3635  	if m.id == nil || m.oldValue == nil {
  3636  		return v, fmt.Errorf("OldEndSuffix requires an ID field in the mutation")
  3637  	}
  3638  	oldValue, err := m.oldValue(ctx)
  3639  	if err != nil {
  3640  		return v, fmt.Errorf("querying old value for OldEndSuffix: %w", err)
  3641  	}
  3642  	return oldValue.EndSuffix, nil
  3643  }
  3644  
  3645  // AddEndSuffix adds i to the "end_suffix" field.
  3646  func (m *DecisionMutation) AddEndSuffix(i int64) {
  3647  	if m.addend_suffix != nil {
  3648  		*m.addend_suffix += i
  3649  	} else {
  3650  		m.addend_suffix = &i
  3651  	}
  3652  }
  3653  
  3654  // AddedEndSuffix returns the value that was added to the "end_suffix" field in this mutation.
  3655  func (m *DecisionMutation) AddedEndSuffix() (r int64, exists bool) {
  3656  	v := m.addend_suffix
  3657  	if v == nil {
  3658  		return
  3659  	}
  3660  	return *v, true
  3661  }
  3662  
  3663  // ClearEndSuffix clears the value of the "end_suffix" field.
  3664  func (m *DecisionMutation) ClearEndSuffix() {
  3665  	m.end_suffix = nil
  3666  	m.addend_suffix = nil
  3667  	m.clearedFields[decision.FieldEndSuffix] = struct{}{}
  3668  }
  3669  
  3670  // EndSuffixCleared returns if the "end_suffix" field was cleared in this mutation.
  3671  func (m *DecisionMutation) EndSuffixCleared() bool {
  3672  	_, ok := m.clearedFields[decision.FieldEndSuffix]
  3673  	return ok
  3674  }
  3675  
  3676  // ResetEndSuffix resets all changes to the "end_suffix" field.
  3677  func (m *DecisionMutation) ResetEndSuffix() {
  3678  	m.end_suffix = nil
  3679  	m.addend_suffix = nil
  3680  	delete(m.clearedFields, decision.FieldEndSuffix)
  3681  }
  3682  
  3683  // SetIPSize sets the "ip_size" field.
  3684  func (m *DecisionMutation) SetIPSize(i int64) {
  3685  	m.ip_size = &i
  3686  	m.addip_size = nil
  3687  }
  3688  
  3689  // IPSize returns the value of the "ip_size" field in the mutation.
  3690  func (m *DecisionMutation) IPSize() (r int64, exists bool) {
  3691  	v := m.ip_size
  3692  	if v == nil {
  3693  		return
  3694  	}
  3695  	return *v, true
  3696  }
  3697  
  3698  // OldIPSize returns the old "ip_size" field's value of the Decision entity.
  3699  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3700  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3701  func (m *DecisionMutation) OldIPSize(ctx context.Context) (v int64, err error) {
  3702  	if !m.op.Is(OpUpdateOne) {
  3703  		return v, fmt.Errorf("OldIPSize is only allowed on UpdateOne operations")
  3704  	}
  3705  	if m.id == nil || m.oldValue == nil {
  3706  		return v, fmt.Errorf("OldIPSize requires an ID field in the mutation")
  3707  	}
  3708  	oldValue, err := m.oldValue(ctx)
  3709  	if err != nil {
  3710  		return v, fmt.Errorf("querying old value for OldIPSize: %w", err)
  3711  	}
  3712  	return oldValue.IPSize, nil
  3713  }
  3714  
  3715  // AddIPSize adds i to the "ip_size" field.
  3716  func (m *DecisionMutation) AddIPSize(i int64) {
  3717  	if m.addip_size != nil {
  3718  		*m.addip_size += i
  3719  	} else {
  3720  		m.addip_size = &i
  3721  	}
  3722  }
  3723  
  3724  // AddedIPSize returns the value that was added to the "ip_size" field in this mutation.
  3725  func (m *DecisionMutation) AddedIPSize() (r int64, exists bool) {
  3726  	v := m.addip_size
  3727  	if v == nil {
  3728  		return
  3729  	}
  3730  	return *v, true
  3731  }
  3732  
  3733  // ClearIPSize clears the value of the "ip_size" field.
  3734  func (m *DecisionMutation) ClearIPSize() {
  3735  	m.ip_size = nil
  3736  	m.addip_size = nil
  3737  	m.clearedFields[decision.FieldIPSize] = struct{}{}
  3738  }
  3739  
  3740  // IPSizeCleared returns if the "ip_size" field was cleared in this mutation.
  3741  func (m *DecisionMutation) IPSizeCleared() bool {
  3742  	_, ok := m.clearedFields[decision.FieldIPSize]
  3743  	return ok
  3744  }
  3745  
  3746  // ResetIPSize resets all changes to the "ip_size" field.
  3747  func (m *DecisionMutation) ResetIPSize() {
  3748  	m.ip_size = nil
  3749  	m.addip_size = nil
  3750  	delete(m.clearedFields, decision.FieldIPSize)
  3751  }
  3752  
  3753  // SetScope sets the "scope" field.
  3754  func (m *DecisionMutation) SetScope(s string) {
  3755  	m.scope = &s
  3756  }
  3757  
  3758  // Scope returns the value of the "scope" field in the mutation.
  3759  func (m *DecisionMutation) Scope() (r string, exists bool) {
  3760  	v := m.scope
  3761  	if v == nil {
  3762  		return
  3763  	}
  3764  	return *v, true
  3765  }
  3766  
  3767  // OldScope returns the old "scope" field's value of the Decision entity.
  3768  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3769  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3770  func (m *DecisionMutation) OldScope(ctx context.Context) (v string, err error) {
  3771  	if !m.op.Is(OpUpdateOne) {
  3772  		return v, fmt.Errorf("OldScope is only allowed on UpdateOne operations")
  3773  	}
  3774  	if m.id == nil || m.oldValue == nil {
  3775  		return v, fmt.Errorf("OldScope requires an ID field in the mutation")
  3776  	}
  3777  	oldValue, err := m.oldValue(ctx)
  3778  	if err != nil {
  3779  		return v, fmt.Errorf("querying old value for OldScope: %w", err)
  3780  	}
  3781  	return oldValue.Scope, nil
  3782  }
  3783  
  3784  // ResetScope resets all changes to the "scope" field.
  3785  func (m *DecisionMutation) ResetScope() {
  3786  	m.scope = nil
  3787  }
  3788  
  3789  // SetValue sets the "value" field.
  3790  func (m *DecisionMutation) SetValue(s string) {
  3791  	m.value = &s
  3792  }
  3793  
  3794  // Value returns the value of the "value" field in the mutation.
  3795  func (m *DecisionMutation) Value() (r string, exists bool) {
  3796  	v := m.value
  3797  	if v == nil {
  3798  		return
  3799  	}
  3800  	return *v, true
  3801  }
  3802  
  3803  // OldValue returns the old "value" field's value of the Decision entity.
  3804  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3805  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3806  func (m *DecisionMutation) OldValue(ctx context.Context) (v string, err error) {
  3807  	if !m.op.Is(OpUpdateOne) {
  3808  		return v, fmt.Errorf("OldValue is only allowed on UpdateOne operations")
  3809  	}
  3810  	if m.id == nil || m.oldValue == nil {
  3811  		return v, fmt.Errorf("OldValue requires an ID field in the mutation")
  3812  	}
  3813  	oldValue, err := m.oldValue(ctx)
  3814  	if err != nil {
  3815  		return v, fmt.Errorf("querying old value for OldValue: %w", err)
  3816  	}
  3817  	return oldValue.Value, nil
  3818  }
  3819  
  3820  // ResetValue resets all changes to the "value" field.
  3821  func (m *DecisionMutation) ResetValue() {
  3822  	m.value = nil
  3823  }
  3824  
  3825  // SetOrigin sets the "origin" field.
  3826  func (m *DecisionMutation) SetOrigin(s string) {
  3827  	m.origin = &s
  3828  }
  3829  
  3830  // Origin returns the value of the "origin" field in the mutation.
  3831  func (m *DecisionMutation) Origin() (r string, exists bool) {
  3832  	v := m.origin
  3833  	if v == nil {
  3834  		return
  3835  	}
  3836  	return *v, true
  3837  }
  3838  
  3839  // OldOrigin returns the old "origin" field's value of the Decision entity.
  3840  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3841  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3842  func (m *DecisionMutation) OldOrigin(ctx context.Context) (v string, err error) {
  3843  	if !m.op.Is(OpUpdateOne) {
  3844  		return v, fmt.Errorf("OldOrigin is only allowed on UpdateOne operations")
  3845  	}
  3846  	if m.id == nil || m.oldValue == nil {
  3847  		return v, fmt.Errorf("OldOrigin requires an ID field in the mutation")
  3848  	}
  3849  	oldValue, err := m.oldValue(ctx)
  3850  	if err != nil {
  3851  		return v, fmt.Errorf("querying old value for OldOrigin: %w", err)
  3852  	}
  3853  	return oldValue.Origin, nil
  3854  }
  3855  
  3856  // ResetOrigin resets all changes to the "origin" field.
  3857  func (m *DecisionMutation) ResetOrigin() {
  3858  	m.origin = nil
  3859  }
  3860  
  3861  // SetSimulated sets the "simulated" field.
  3862  func (m *DecisionMutation) SetSimulated(b bool) {
  3863  	m.simulated = &b
  3864  }
  3865  
  3866  // Simulated returns the value of the "simulated" field in the mutation.
  3867  func (m *DecisionMutation) Simulated() (r bool, exists bool) {
  3868  	v := m.simulated
  3869  	if v == nil {
  3870  		return
  3871  	}
  3872  	return *v, true
  3873  }
  3874  
  3875  // OldSimulated returns the old "simulated" field's value of the Decision entity.
  3876  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  3877  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3878  func (m *DecisionMutation) OldSimulated(ctx context.Context) (v bool, err error) {
  3879  	if !m.op.Is(OpUpdateOne) {
  3880  		return v, fmt.Errorf("OldSimulated is only allowed on UpdateOne operations")
  3881  	}
  3882  	if m.id == nil || m.oldValue == nil {
  3883  		return v, fmt.Errorf("OldSimulated requires an ID field in the mutation")
  3884  	}
  3885  	oldValue, err := m.oldValue(ctx)
  3886  	if err != nil {
  3887  		return v, fmt.Errorf("querying old value for OldSimulated: %w", err)
  3888  	}
  3889  	return oldValue.Simulated, nil
  3890  }
  3891  
  3892  // ResetSimulated resets all changes to the "simulated" field.
  3893  func (m *DecisionMutation) ResetSimulated() {
  3894  	m.simulated = nil
  3895  }
  3896  
  3897  // SetOwnerID sets the "owner" edge to the Alert entity by id.
  3898  func (m *DecisionMutation) SetOwnerID(id int) {
  3899  	m.owner = &id
  3900  }
  3901  
  3902  // ClearOwner clears the "owner" edge to the Alert entity.
  3903  func (m *DecisionMutation) ClearOwner() {
  3904  	m.clearedowner = true
  3905  }
  3906  
  3907  // OwnerCleared returns if the "owner" edge to the Alert entity was cleared.
  3908  func (m *DecisionMutation) OwnerCleared() bool {
  3909  	return m.clearedowner
  3910  }
  3911  
  3912  // OwnerID returns the "owner" edge ID in the mutation.
  3913  func (m *DecisionMutation) OwnerID() (id int, exists bool) {
  3914  	if m.owner != nil {
  3915  		return *m.owner, true
  3916  	}
  3917  	return
  3918  }
  3919  
  3920  // OwnerIDs returns the "owner" edge IDs in the mutation.
  3921  // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  3922  // OwnerID instead. It exists only for internal usage by the builders.
  3923  func (m *DecisionMutation) OwnerIDs() (ids []int) {
  3924  	if id := m.owner; id != nil {
  3925  		ids = append(ids, *id)
  3926  	}
  3927  	return
  3928  }
  3929  
  3930  // ResetOwner resets all changes to the "owner" edge.
  3931  func (m *DecisionMutation) ResetOwner() {
  3932  	m.owner = nil
  3933  	m.clearedowner = false
  3934  }
  3935  
  3936  // Op returns the operation name.
  3937  func (m *DecisionMutation) Op() Op {
  3938  	return m.op
  3939  }
  3940  
  3941  // Type returns the node type of this mutation (Decision).
  3942  func (m *DecisionMutation) Type() string {
  3943  	return m.typ
  3944  }
  3945  
  3946  // Fields returns all fields that were changed during this mutation. Note that in
  3947  // order to get all numeric fields that were incremented/decremented, call
  3948  // AddedFields().
  3949  func (m *DecisionMutation) Fields() []string {
  3950  	fields := make([]string, 0, 14)
  3951  	if m.created_at != nil {
  3952  		fields = append(fields, decision.FieldCreatedAt)
  3953  	}
  3954  	if m.updated_at != nil {
  3955  		fields = append(fields, decision.FieldUpdatedAt)
  3956  	}
  3957  	if m.until != nil {
  3958  		fields = append(fields, decision.FieldUntil)
  3959  	}
  3960  	if m.scenario != nil {
  3961  		fields = append(fields, decision.FieldScenario)
  3962  	}
  3963  	if m._type != nil {
  3964  		fields = append(fields, decision.FieldType)
  3965  	}
  3966  	if m.start_ip != nil {
  3967  		fields = append(fields, decision.FieldStartIP)
  3968  	}
  3969  	if m.end_ip != nil {
  3970  		fields = append(fields, decision.FieldEndIP)
  3971  	}
  3972  	if m.start_suffix != nil {
  3973  		fields = append(fields, decision.FieldStartSuffix)
  3974  	}
  3975  	if m.end_suffix != nil {
  3976  		fields = append(fields, decision.FieldEndSuffix)
  3977  	}
  3978  	if m.ip_size != nil {
  3979  		fields = append(fields, decision.FieldIPSize)
  3980  	}
  3981  	if m.scope != nil {
  3982  		fields = append(fields, decision.FieldScope)
  3983  	}
  3984  	if m.value != nil {
  3985  		fields = append(fields, decision.FieldValue)
  3986  	}
  3987  	if m.origin != nil {
  3988  		fields = append(fields, decision.FieldOrigin)
  3989  	}
  3990  	if m.simulated != nil {
  3991  		fields = append(fields, decision.FieldSimulated)
  3992  	}
  3993  	return fields
  3994  }
  3995  
  3996  // Field returns the value of a field with the given name. The second boolean
  3997  // return value indicates that this field was not set, or was not defined in the
  3998  // schema.
  3999  func (m *DecisionMutation) Field(name string) (ent.Value, bool) {
  4000  	switch name {
  4001  	case decision.FieldCreatedAt:
  4002  		return m.CreatedAt()
  4003  	case decision.FieldUpdatedAt:
  4004  		return m.UpdatedAt()
  4005  	case decision.FieldUntil:
  4006  		return m.Until()
  4007  	case decision.FieldScenario:
  4008  		return m.Scenario()
  4009  	case decision.FieldType:
  4010  		return m.GetType()
  4011  	case decision.FieldStartIP:
  4012  		return m.StartIP()
  4013  	case decision.FieldEndIP:
  4014  		return m.EndIP()
  4015  	case decision.FieldStartSuffix:
  4016  		return m.StartSuffix()
  4017  	case decision.FieldEndSuffix:
  4018  		return m.EndSuffix()
  4019  	case decision.FieldIPSize:
  4020  		return m.IPSize()
  4021  	case decision.FieldScope:
  4022  		return m.Scope()
  4023  	case decision.FieldValue:
  4024  		return m.Value()
  4025  	case decision.FieldOrigin:
  4026  		return m.Origin()
  4027  	case decision.FieldSimulated:
  4028  		return m.Simulated()
  4029  	}
  4030  	return nil, false
  4031  }
  4032  
  4033  // OldField returns the old value of the field from the database. An error is
  4034  // returned if the mutation operation is not UpdateOne, or the query to the
  4035  // database failed.
  4036  func (m *DecisionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4037  	switch name {
  4038  	case decision.FieldCreatedAt:
  4039  		return m.OldCreatedAt(ctx)
  4040  	case decision.FieldUpdatedAt:
  4041  		return m.OldUpdatedAt(ctx)
  4042  	case decision.FieldUntil:
  4043  		return m.OldUntil(ctx)
  4044  	case decision.FieldScenario:
  4045  		return m.OldScenario(ctx)
  4046  	case decision.FieldType:
  4047  		return m.OldType(ctx)
  4048  	case decision.FieldStartIP:
  4049  		return m.OldStartIP(ctx)
  4050  	case decision.FieldEndIP:
  4051  		return m.OldEndIP(ctx)
  4052  	case decision.FieldStartSuffix:
  4053  		return m.OldStartSuffix(ctx)
  4054  	case decision.FieldEndSuffix:
  4055  		return m.OldEndSuffix(ctx)
  4056  	case decision.FieldIPSize:
  4057  		return m.OldIPSize(ctx)
  4058  	case decision.FieldScope:
  4059  		return m.OldScope(ctx)
  4060  	case decision.FieldValue:
  4061  		return m.OldValue(ctx)
  4062  	case decision.FieldOrigin:
  4063  		return m.OldOrigin(ctx)
  4064  	case decision.FieldSimulated:
  4065  		return m.OldSimulated(ctx)
  4066  	}
  4067  	return nil, fmt.Errorf("unknown Decision field %s", name)
  4068  }
  4069  
  4070  // SetField sets the value of a field with the given name. It returns an error if
  4071  // the field is not defined in the schema, or if the type mismatched the field
  4072  // type.
  4073  func (m *DecisionMutation) SetField(name string, value ent.Value) error {
  4074  	switch name {
  4075  	case decision.FieldCreatedAt:
  4076  		v, ok := value.(time.Time)
  4077  		if !ok {
  4078  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4079  		}
  4080  		m.SetCreatedAt(v)
  4081  		return nil
  4082  	case decision.FieldUpdatedAt:
  4083  		v, ok := value.(time.Time)
  4084  		if !ok {
  4085  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4086  		}
  4087  		m.SetUpdatedAt(v)
  4088  		return nil
  4089  	case decision.FieldUntil:
  4090  		v, ok := value.(time.Time)
  4091  		if !ok {
  4092  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4093  		}
  4094  		m.SetUntil(v)
  4095  		return nil
  4096  	case decision.FieldScenario:
  4097  		v, ok := value.(string)
  4098  		if !ok {
  4099  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4100  		}
  4101  		m.SetScenario(v)
  4102  		return nil
  4103  	case decision.FieldType:
  4104  		v, ok := value.(string)
  4105  		if !ok {
  4106  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4107  		}
  4108  		m.SetType(v)
  4109  		return nil
  4110  	case decision.FieldStartIP:
  4111  		v, ok := value.(int64)
  4112  		if !ok {
  4113  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4114  		}
  4115  		m.SetStartIP(v)
  4116  		return nil
  4117  	case decision.FieldEndIP:
  4118  		v, ok := value.(int64)
  4119  		if !ok {
  4120  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4121  		}
  4122  		m.SetEndIP(v)
  4123  		return nil
  4124  	case decision.FieldStartSuffix:
  4125  		v, ok := value.(int64)
  4126  		if !ok {
  4127  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4128  		}
  4129  		m.SetStartSuffix(v)
  4130  		return nil
  4131  	case decision.FieldEndSuffix:
  4132  		v, ok := value.(int64)
  4133  		if !ok {
  4134  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4135  		}
  4136  		m.SetEndSuffix(v)
  4137  		return nil
  4138  	case decision.FieldIPSize:
  4139  		v, ok := value.(int64)
  4140  		if !ok {
  4141  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4142  		}
  4143  		m.SetIPSize(v)
  4144  		return nil
  4145  	case decision.FieldScope:
  4146  		v, ok := value.(string)
  4147  		if !ok {
  4148  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4149  		}
  4150  		m.SetScope(v)
  4151  		return nil
  4152  	case decision.FieldValue:
  4153  		v, ok := value.(string)
  4154  		if !ok {
  4155  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4156  		}
  4157  		m.SetValue(v)
  4158  		return nil
  4159  	case decision.FieldOrigin:
  4160  		v, ok := value.(string)
  4161  		if !ok {
  4162  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4163  		}
  4164  		m.SetOrigin(v)
  4165  		return nil
  4166  	case decision.FieldSimulated:
  4167  		v, ok := value.(bool)
  4168  		if !ok {
  4169  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4170  		}
  4171  		m.SetSimulated(v)
  4172  		return nil
  4173  	}
  4174  	return fmt.Errorf("unknown Decision field %s", name)
  4175  }
  4176  
  4177  // AddedFields returns all numeric fields that were incremented/decremented during
  4178  // this mutation.
  4179  func (m *DecisionMutation) AddedFields() []string {
  4180  	var fields []string
  4181  	if m.addstart_ip != nil {
  4182  		fields = append(fields, decision.FieldStartIP)
  4183  	}
  4184  	if m.addend_ip != nil {
  4185  		fields = append(fields, decision.FieldEndIP)
  4186  	}
  4187  	if m.addstart_suffix != nil {
  4188  		fields = append(fields, decision.FieldStartSuffix)
  4189  	}
  4190  	if m.addend_suffix != nil {
  4191  		fields = append(fields, decision.FieldEndSuffix)
  4192  	}
  4193  	if m.addip_size != nil {
  4194  		fields = append(fields, decision.FieldIPSize)
  4195  	}
  4196  	return fields
  4197  }
  4198  
  4199  // AddedField returns the numeric value that was incremented/decremented on a field
  4200  // with the given name. The second boolean return value indicates that this field
  4201  // was not set, or was not defined in the schema.
  4202  func (m *DecisionMutation) AddedField(name string) (ent.Value, bool) {
  4203  	switch name {
  4204  	case decision.FieldStartIP:
  4205  		return m.AddedStartIP()
  4206  	case decision.FieldEndIP:
  4207  		return m.AddedEndIP()
  4208  	case decision.FieldStartSuffix:
  4209  		return m.AddedStartSuffix()
  4210  	case decision.FieldEndSuffix:
  4211  		return m.AddedEndSuffix()
  4212  	case decision.FieldIPSize:
  4213  		return m.AddedIPSize()
  4214  	}
  4215  	return nil, false
  4216  }
  4217  
  4218  // AddField adds the value to the field with the given name. It returns an error if
  4219  // the field is not defined in the schema, or if the type mismatched the field
  4220  // type.
  4221  func (m *DecisionMutation) AddField(name string, value ent.Value) error {
  4222  	switch name {
  4223  	case decision.FieldStartIP:
  4224  		v, ok := value.(int64)
  4225  		if !ok {
  4226  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4227  		}
  4228  		m.AddStartIP(v)
  4229  		return nil
  4230  	case decision.FieldEndIP:
  4231  		v, ok := value.(int64)
  4232  		if !ok {
  4233  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4234  		}
  4235  		m.AddEndIP(v)
  4236  		return nil
  4237  	case decision.FieldStartSuffix:
  4238  		v, ok := value.(int64)
  4239  		if !ok {
  4240  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4241  		}
  4242  		m.AddStartSuffix(v)
  4243  		return nil
  4244  	case decision.FieldEndSuffix:
  4245  		v, ok := value.(int64)
  4246  		if !ok {
  4247  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4248  		}
  4249  		m.AddEndSuffix(v)
  4250  		return nil
  4251  	case decision.FieldIPSize:
  4252  		v, ok := value.(int64)
  4253  		if !ok {
  4254  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4255  		}
  4256  		m.AddIPSize(v)
  4257  		return nil
  4258  	}
  4259  	return fmt.Errorf("unknown Decision numeric field %s", name)
  4260  }
  4261  
  4262  // ClearedFields returns all nullable fields that were cleared during this
  4263  // mutation.
  4264  func (m *DecisionMutation) ClearedFields() []string {
  4265  	var fields []string
  4266  	if m.FieldCleared(decision.FieldStartIP) {
  4267  		fields = append(fields, decision.FieldStartIP)
  4268  	}
  4269  	if m.FieldCleared(decision.FieldEndIP) {
  4270  		fields = append(fields, decision.FieldEndIP)
  4271  	}
  4272  	if m.FieldCleared(decision.FieldStartSuffix) {
  4273  		fields = append(fields, decision.FieldStartSuffix)
  4274  	}
  4275  	if m.FieldCleared(decision.FieldEndSuffix) {
  4276  		fields = append(fields, decision.FieldEndSuffix)
  4277  	}
  4278  	if m.FieldCleared(decision.FieldIPSize) {
  4279  		fields = append(fields, decision.FieldIPSize)
  4280  	}
  4281  	return fields
  4282  }
  4283  
  4284  // FieldCleared returns a boolean indicating if a field with the given name was
  4285  // cleared in this mutation.
  4286  func (m *DecisionMutation) FieldCleared(name string) bool {
  4287  	_, ok := m.clearedFields[name]
  4288  	return ok
  4289  }
  4290  
  4291  // ClearField clears the value of the field with the given name. It returns an
  4292  // error if the field is not defined in the schema.
  4293  func (m *DecisionMutation) ClearField(name string) error {
  4294  	switch name {
  4295  	case decision.FieldStartIP:
  4296  		m.ClearStartIP()
  4297  		return nil
  4298  	case decision.FieldEndIP:
  4299  		m.ClearEndIP()
  4300  		return nil
  4301  	case decision.FieldStartSuffix:
  4302  		m.ClearStartSuffix()
  4303  		return nil
  4304  	case decision.FieldEndSuffix:
  4305  		m.ClearEndSuffix()
  4306  		return nil
  4307  	case decision.FieldIPSize:
  4308  		m.ClearIPSize()
  4309  		return nil
  4310  	}
  4311  	return fmt.Errorf("unknown Decision nullable field %s", name)
  4312  }
  4313  
  4314  // ResetField resets all changes in the mutation for the field with the given name.
  4315  // It returns an error if the field is not defined in the schema.
  4316  func (m *DecisionMutation) ResetField(name string) error {
  4317  	switch name {
  4318  	case decision.FieldCreatedAt:
  4319  		m.ResetCreatedAt()
  4320  		return nil
  4321  	case decision.FieldUpdatedAt:
  4322  		m.ResetUpdatedAt()
  4323  		return nil
  4324  	case decision.FieldUntil:
  4325  		m.ResetUntil()
  4326  		return nil
  4327  	case decision.FieldScenario:
  4328  		m.ResetScenario()
  4329  		return nil
  4330  	case decision.FieldType:
  4331  		m.ResetType()
  4332  		return nil
  4333  	case decision.FieldStartIP:
  4334  		m.ResetStartIP()
  4335  		return nil
  4336  	case decision.FieldEndIP:
  4337  		m.ResetEndIP()
  4338  		return nil
  4339  	case decision.FieldStartSuffix:
  4340  		m.ResetStartSuffix()
  4341  		return nil
  4342  	case decision.FieldEndSuffix:
  4343  		m.ResetEndSuffix()
  4344  		return nil
  4345  	case decision.FieldIPSize:
  4346  		m.ResetIPSize()
  4347  		return nil
  4348  	case decision.FieldScope:
  4349  		m.ResetScope()
  4350  		return nil
  4351  	case decision.FieldValue:
  4352  		m.ResetValue()
  4353  		return nil
  4354  	case decision.FieldOrigin:
  4355  		m.ResetOrigin()
  4356  		return nil
  4357  	case decision.FieldSimulated:
  4358  		m.ResetSimulated()
  4359  		return nil
  4360  	}
  4361  	return fmt.Errorf("unknown Decision field %s", name)
  4362  }
  4363  
  4364  // AddedEdges returns all edge names that were set/added in this mutation.
  4365  func (m *DecisionMutation) AddedEdges() []string {
  4366  	edges := make([]string, 0, 1)
  4367  	if m.owner != nil {
  4368  		edges = append(edges, decision.EdgeOwner)
  4369  	}
  4370  	return edges
  4371  }
  4372  
  4373  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4374  // name in this mutation.
  4375  func (m *DecisionMutation) AddedIDs(name string) []ent.Value {
  4376  	switch name {
  4377  	case decision.EdgeOwner:
  4378  		if id := m.owner; id != nil {
  4379  			return []ent.Value{*id}
  4380  		}
  4381  	}
  4382  	return nil
  4383  }
  4384  
  4385  // RemovedEdges returns all edge names that were removed in this mutation.
  4386  func (m *DecisionMutation) RemovedEdges() []string {
  4387  	edges := make([]string, 0, 1)
  4388  	return edges
  4389  }
  4390  
  4391  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4392  // the given name in this mutation.
  4393  func (m *DecisionMutation) RemovedIDs(name string) []ent.Value {
  4394  	switch name {
  4395  	}
  4396  	return nil
  4397  }
  4398  
  4399  // ClearedEdges returns all edge names that were cleared in this mutation.
  4400  func (m *DecisionMutation) ClearedEdges() []string {
  4401  	edges := make([]string, 0, 1)
  4402  	if m.clearedowner {
  4403  		edges = append(edges, decision.EdgeOwner)
  4404  	}
  4405  	return edges
  4406  }
  4407  
  4408  // EdgeCleared returns a boolean which indicates if the edge with the given name
  4409  // was cleared in this mutation.
  4410  func (m *DecisionMutation) EdgeCleared(name string) bool {
  4411  	switch name {
  4412  	case decision.EdgeOwner:
  4413  		return m.clearedowner
  4414  	}
  4415  	return false
  4416  }
  4417  
  4418  // ClearEdge clears the value of the edge with the given name. It returns an error
  4419  // if that edge is not defined in the schema.
  4420  func (m *DecisionMutation) ClearEdge(name string) error {
  4421  	switch name {
  4422  	case decision.EdgeOwner:
  4423  		m.ClearOwner()
  4424  		return nil
  4425  	}
  4426  	return fmt.Errorf("unknown Decision unique edge %s", name)
  4427  }
  4428  
  4429  // ResetEdge resets all changes to the edge with the given name in this mutation.
  4430  // It returns an error if the edge is not defined in the schema.
  4431  func (m *DecisionMutation) ResetEdge(name string) error {
  4432  	switch name {
  4433  	case decision.EdgeOwner:
  4434  		m.ResetOwner()
  4435  		return nil
  4436  	}
  4437  	return fmt.Errorf("unknown Decision edge %s", name)
  4438  }
  4439  
  4440  // EventMutation represents an operation that mutates the Event nodes in the graph.
  4441  type EventMutation struct {
  4442  	config
  4443  	op            Op
  4444  	typ           string
  4445  	id            *int
  4446  	created_at    *time.Time
  4447  	updated_at    *time.Time
  4448  	time          *time.Time
  4449  	serialized    *string
  4450  	clearedFields map[string]struct{}
  4451  	owner         *int
  4452  	clearedowner  bool
  4453  	done          bool
  4454  	oldValue      func(context.Context) (*Event, error)
  4455  	predicates    []predicate.Event
  4456  }
  4457  
  4458  var _ ent.Mutation = (*EventMutation)(nil)
  4459  
  4460  // eventOption allows management of the mutation configuration using functional options.
  4461  type eventOption func(*EventMutation)
  4462  
  4463  // newEventMutation creates new mutation for the Event entity.
  4464  func newEventMutation(c config, op Op, opts ...eventOption) *EventMutation {
  4465  	m := &EventMutation{
  4466  		config:        c,
  4467  		op:            op,
  4468  		typ:           TypeEvent,
  4469  		clearedFields: make(map[string]struct{}),
  4470  	}
  4471  	for _, opt := range opts {
  4472  		opt(m)
  4473  	}
  4474  	return m
  4475  }
  4476  
  4477  // withEventID sets the ID field of the mutation.
  4478  func withEventID(id int) eventOption {
  4479  	return func(m *EventMutation) {
  4480  		var (
  4481  			err   error
  4482  			once  sync.Once
  4483  			value *Event
  4484  		)
  4485  		m.oldValue = func(ctx context.Context) (*Event, error) {
  4486  			once.Do(func() {
  4487  				if m.done {
  4488  					err = fmt.Errorf("querying old values post mutation is not allowed")
  4489  				} else {
  4490  					value, err = m.Client().Event.Get(ctx, id)
  4491  				}
  4492  			})
  4493  			return value, err
  4494  		}
  4495  		m.id = &id
  4496  	}
  4497  }
  4498  
  4499  // withEvent sets the old Event of the mutation.
  4500  func withEvent(node *Event) eventOption {
  4501  	return func(m *EventMutation) {
  4502  		m.oldValue = func(context.Context) (*Event, error) {
  4503  			return node, nil
  4504  		}
  4505  		m.id = &node.ID
  4506  	}
  4507  }
  4508  
  4509  // Client returns a new `ent.Client` from the mutation. If the mutation was
  4510  // executed in a transaction (ent.Tx), a transactional client is returned.
  4511  func (m EventMutation) Client() *Client {
  4512  	client := &Client{config: m.config}
  4513  	client.init()
  4514  	return client
  4515  }
  4516  
  4517  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4518  // it returns an error otherwise.
  4519  func (m EventMutation) Tx() (*Tx, error) {
  4520  	if _, ok := m.driver.(*txDriver); !ok {
  4521  		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
  4522  	}
  4523  	tx := &Tx{config: m.config}
  4524  	tx.init()
  4525  	return tx, nil
  4526  }
  4527  
  4528  // ID returns the ID value in the mutation. Note that the ID
  4529  // is only available if it was provided to the builder.
  4530  func (m *EventMutation) ID() (id int, exists bool) {
  4531  	if m.id == nil {
  4532  		return
  4533  	}
  4534  	return *m.id, true
  4535  }
  4536  
  4537  // SetCreatedAt sets the "created_at" field.
  4538  func (m *EventMutation) SetCreatedAt(t time.Time) {
  4539  	m.created_at = &t
  4540  }
  4541  
  4542  // CreatedAt returns the value of the "created_at" field in the mutation.
  4543  func (m *EventMutation) CreatedAt() (r time.Time, exists bool) {
  4544  	v := m.created_at
  4545  	if v == nil {
  4546  		return
  4547  	}
  4548  	return *v, true
  4549  }
  4550  
  4551  // OldCreatedAt returns the old "created_at" field's value of the Event entity.
  4552  // If the Event object wasn't provided to the builder, the object is fetched from the database.
  4553  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4554  func (m *EventMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4555  	if !m.op.Is(OpUpdateOne) {
  4556  		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
  4557  	}
  4558  	if m.id == nil || m.oldValue == nil {
  4559  		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
  4560  	}
  4561  	oldValue, err := m.oldValue(ctx)
  4562  	if err != nil {
  4563  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4564  	}
  4565  	return oldValue.CreatedAt, nil
  4566  }
  4567  
  4568  // ResetCreatedAt resets all changes to the "created_at" field.
  4569  func (m *EventMutation) ResetCreatedAt() {
  4570  	m.created_at = nil
  4571  }
  4572  
  4573  // SetUpdatedAt sets the "updated_at" field.
  4574  func (m *EventMutation) SetUpdatedAt(t time.Time) {
  4575  	m.updated_at = &t
  4576  }
  4577  
  4578  // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4579  func (m *EventMutation) UpdatedAt() (r time.Time, exists bool) {
  4580  	v := m.updated_at
  4581  	if v == nil {
  4582  		return
  4583  	}
  4584  	return *v, true
  4585  }
  4586  
  4587  // OldUpdatedAt returns the old "updated_at" field's value of the Event entity.
  4588  // If the Event object wasn't provided to the builder, the object is fetched from the database.
  4589  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4590  func (m *EventMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4591  	if !m.op.Is(OpUpdateOne) {
  4592  		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
  4593  	}
  4594  	if m.id == nil || m.oldValue == nil {
  4595  		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
  4596  	}
  4597  	oldValue, err := m.oldValue(ctx)
  4598  	if err != nil {
  4599  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4600  	}
  4601  	return oldValue.UpdatedAt, nil
  4602  }
  4603  
  4604  // ResetUpdatedAt resets all changes to the "updated_at" field.
  4605  func (m *EventMutation) ResetUpdatedAt() {
  4606  	m.updated_at = nil
  4607  }
  4608  
  4609  // SetTime sets the "time" field.
  4610  func (m *EventMutation) SetTime(t time.Time) {
  4611  	m.time = &t
  4612  }
  4613  
  4614  // Time returns the value of the "time" field in the mutation.
  4615  func (m *EventMutation) Time() (r time.Time, exists bool) {
  4616  	v := m.time
  4617  	if v == nil {
  4618  		return
  4619  	}
  4620  	return *v, true
  4621  }
  4622  
  4623  // OldTime returns the old "time" field's value of the Event entity.
  4624  // If the Event object wasn't provided to the builder, the object is fetched from the database.
  4625  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4626  func (m *EventMutation) OldTime(ctx context.Context) (v time.Time, err error) {
  4627  	if !m.op.Is(OpUpdateOne) {
  4628  		return v, fmt.Errorf("OldTime is only allowed on UpdateOne operations")
  4629  	}
  4630  	if m.id == nil || m.oldValue == nil {
  4631  		return v, fmt.Errorf("OldTime requires an ID field in the mutation")
  4632  	}
  4633  	oldValue, err := m.oldValue(ctx)
  4634  	if err != nil {
  4635  		return v, fmt.Errorf("querying old value for OldTime: %w", err)
  4636  	}
  4637  	return oldValue.Time, nil
  4638  }
  4639  
  4640  // ResetTime resets all changes to the "time" field.
  4641  func (m *EventMutation) ResetTime() {
  4642  	m.time = nil
  4643  }
  4644  
  4645  // SetSerialized sets the "serialized" field.
  4646  func (m *EventMutation) SetSerialized(s string) {
  4647  	m.serialized = &s
  4648  }
  4649  
  4650  // Serialized returns the value of the "serialized" field in the mutation.
  4651  func (m *EventMutation) Serialized() (r string, exists bool) {
  4652  	v := m.serialized
  4653  	if v == nil {
  4654  		return
  4655  	}
  4656  	return *v, true
  4657  }
  4658  
  4659  // OldSerialized returns the old "serialized" field's value of the Event entity.
  4660  // If the Event object wasn't provided to the builder, the object is fetched from the database.
  4661  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4662  func (m *EventMutation) OldSerialized(ctx context.Context) (v string, err error) {
  4663  	if !m.op.Is(OpUpdateOne) {
  4664  		return v, fmt.Errorf("OldSerialized is only allowed on UpdateOne operations")
  4665  	}
  4666  	if m.id == nil || m.oldValue == nil {
  4667  		return v, fmt.Errorf("OldSerialized requires an ID field in the mutation")
  4668  	}
  4669  	oldValue, err := m.oldValue(ctx)
  4670  	if err != nil {
  4671  		return v, fmt.Errorf("querying old value for OldSerialized: %w", err)
  4672  	}
  4673  	return oldValue.Serialized, nil
  4674  }
  4675  
  4676  // ResetSerialized resets all changes to the "serialized" field.
  4677  func (m *EventMutation) ResetSerialized() {
  4678  	m.serialized = nil
  4679  }
  4680  
  4681  // SetOwnerID sets the "owner" edge to the Alert entity by id.
  4682  func (m *EventMutation) SetOwnerID(id int) {
  4683  	m.owner = &id
  4684  }
  4685  
  4686  // ClearOwner clears the "owner" edge to the Alert entity.
  4687  func (m *EventMutation) ClearOwner() {
  4688  	m.clearedowner = true
  4689  }
  4690  
  4691  // OwnerCleared returns if the "owner" edge to the Alert entity was cleared.
  4692  func (m *EventMutation) OwnerCleared() bool {
  4693  	return m.clearedowner
  4694  }
  4695  
  4696  // OwnerID returns the "owner" edge ID in the mutation.
  4697  func (m *EventMutation) OwnerID() (id int, exists bool) {
  4698  	if m.owner != nil {
  4699  		return *m.owner, true
  4700  	}
  4701  	return
  4702  }
  4703  
  4704  // OwnerIDs returns the "owner" edge IDs in the mutation.
  4705  // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4706  // OwnerID instead. It exists only for internal usage by the builders.
  4707  func (m *EventMutation) OwnerIDs() (ids []int) {
  4708  	if id := m.owner; id != nil {
  4709  		ids = append(ids, *id)
  4710  	}
  4711  	return
  4712  }
  4713  
  4714  // ResetOwner resets all changes to the "owner" edge.
  4715  func (m *EventMutation) ResetOwner() {
  4716  	m.owner = nil
  4717  	m.clearedowner = false
  4718  }
  4719  
  4720  // Op returns the operation name.
  4721  func (m *EventMutation) Op() Op {
  4722  	return m.op
  4723  }
  4724  
  4725  // Type returns the node type of this mutation (Event).
  4726  func (m *EventMutation) Type() string {
  4727  	return m.typ
  4728  }
  4729  
  4730  // Fields returns all fields that were changed during this mutation. Note that in
  4731  // order to get all numeric fields that were incremented/decremented, call
  4732  // AddedFields().
  4733  func (m *EventMutation) Fields() []string {
  4734  	fields := make([]string, 0, 4)
  4735  	if m.created_at != nil {
  4736  		fields = append(fields, event.FieldCreatedAt)
  4737  	}
  4738  	if m.updated_at != nil {
  4739  		fields = append(fields, event.FieldUpdatedAt)
  4740  	}
  4741  	if m.time != nil {
  4742  		fields = append(fields, event.FieldTime)
  4743  	}
  4744  	if m.serialized != nil {
  4745  		fields = append(fields, event.FieldSerialized)
  4746  	}
  4747  	return fields
  4748  }
  4749  
  4750  // Field returns the value of a field with the given name. The second boolean
  4751  // return value indicates that this field was not set, or was not defined in the
  4752  // schema.
  4753  func (m *EventMutation) Field(name string) (ent.Value, bool) {
  4754  	switch name {
  4755  	case event.FieldCreatedAt:
  4756  		return m.CreatedAt()
  4757  	case event.FieldUpdatedAt:
  4758  		return m.UpdatedAt()
  4759  	case event.FieldTime:
  4760  		return m.Time()
  4761  	case event.FieldSerialized:
  4762  		return m.Serialized()
  4763  	}
  4764  	return nil, false
  4765  }
  4766  
  4767  // OldField returns the old value of the field from the database. An error is
  4768  // returned if the mutation operation is not UpdateOne, or the query to the
  4769  // database failed.
  4770  func (m *EventMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4771  	switch name {
  4772  	case event.FieldCreatedAt:
  4773  		return m.OldCreatedAt(ctx)
  4774  	case event.FieldUpdatedAt:
  4775  		return m.OldUpdatedAt(ctx)
  4776  	case event.FieldTime:
  4777  		return m.OldTime(ctx)
  4778  	case event.FieldSerialized:
  4779  		return m.OldSerialized(ctx)
  4780  	}
  4781  	return nil, fmt.Errorf("unknown Event field %s", name)
  4782  }
  4783  
  4784  // SetField sets the value of a field with the given name. It returns an error if
  4785  // the field is not defined in the schema, or if the type mismatched the field
  4786  // type.
  4787  func (m *EventMutation) SetField(name string, value ent.Value) error {
  4788  	switch name {
  4789  	case event.FieldCreatedAt:
  4790  		v, ok := value.(time.Time)
  4791  		if !ok {
  4792  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4793  		}
  4794  		m.SetCreatedAt(v)
  4795  		return nil
  4796  	case event.FieldUpdatedAt:
  4797  		v, ok := value.(time.Time)
  4798  		if !ok {
  4799  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4800  		}
  4801  		m.SetUpdatedAt(v)
  4802  		return nil
  4803  	case event.FieldTime:
  4804  		v, ok := value.(time.Time)
  4805  		if !ok {
  4806  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4807  		}
  4808  		m.SetTime(v)
  4809  		return nil
  4810  	case event.FieldSerialized:
  4811  		v, ok := value.(string)
  4812  		if !ok {
  4813  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  4814  		}
  4815  		m.SetSerialized(v)
  4816  		return nil
  4817  	}
  4818  	return fmt.Errorf("unknown Event field %s", name)
  4819  }
  4820  
  4821  // AddedFields returns all numeric fields that were incremented/decremented during
  4822  // this mutation.
  4823  func (m *EventMutation) AddedFields() []string {
  4824  	return nil
  4825  }
  4826  
  4827  // AddedField returns the numeric value that was incremented/decremented on a field
  4828  // with the given name. The second boolean return value indicates that this field
  4829  // was not set, or was not defined in the schema.
  4830  func (m *EventMutation) AddedField(name string) (ent.Value, bool) {
  4831  	return nil, false
  4832  }
  4833  
  4834  // AddField adds the value to the field with the given name. It returns an error if
  4835  // the field is not defined in the schema, or if the type mismatched the field
  4836  // type.
  4837  func (m *EventMutation) AddField(name string, value ent.Value) error {
  4838  	switch name {
  4839  	}
  4840  	return fmt.Errorf("unknown Event numeric field %s", name)
  4841  }
  4842  
  4843  // ClearedFields returns all nullable fields that were cleared during this
  4844  // mutation.
  4845  func (m *EventMutation) ClearedFields() []string {
  4846  	return nil
  4847  }
  4848  
  4849  // FieldCleared returns a boolean indicating if a field with the given name was
  4850  // cleared in this mutation.
  4851  func (m *EventMutation) FieldCleared(name string) bool {
  4852  	_, ok := m.clearedFields[name]
  4853  	return ok
  4854  }
  4855  
  4856  // ClearField clears the value of the field with the given name. It returns an
  4857  // error if the field is not defined in the schema.
  4858  func (m *EventMutation) ClearField(name string) error {
  4859  	return fmt.Errorf("unknown Event nullable field %s", name)
  4860  }
  4861  
  4862  // ResetField resets all changes in the mutation for the field with the given name.
  4863  // It returns an error if the field is not defined in the schema.
  4864  func (m *EventMutation) ResetField(name string) error {
  4865  	switch name {
  4866  	case event.FieldCreatedAt:
  4867  		m.ResetCreatedAt()
  4868  		return nil
  4869  	case event.FieldUpdatedAt:
  4870  		m.ResetUpdatedAt()
  4871  		return nil
  4872  	case event.FieldTime:
  4873  		m.ResetTime()
  4874  		return nil
  4875  	case event.FieldSerialized:
  4876  		m.ResetSerialized()
  4877  		return nil
  4878  	}
  4879  	return fmt.Errorf("unknown Event field %s", name)
  4880  }
  4881  
  4882  // AddedEdges returns all edge names that were set/added in this mutation.
  4883  func (m *EventMutation) AddedEdges() []string {
  4884  	edges := make([]string, 0, 1)
  4885  	if m.owner != nil {
  4886  		edges = append(edges, event.EdgeOwner)
  4887  	}
  4888  	return edges
  4889  }
  4890  
  4891  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4892  // name in this mutation.
  4893  func (m *EventMutation) AddedIDs(name string) []ent.Value {
  4894  	switch name {
  4895  	case event.EdgeOwner:
  4896  		if id := m.owner; id != nil {
  4897  			return []ent.Value{*id}
  4898  		}
  4899  	}
  4900  	return nil
  4901  }
  4902  
  4903  // RemovedEdges returns all edge names that were removed in this mutation.
  4904  func (m *EventMutation) RemovedEdges() []string {
  4905  	edges := make([]string, 0, 1)
  4906  	return edges
  4907  }
  4908  
  4909  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4910  // the given name in this mutation.
  4911  func (m *EventMutation) RemovedIDs(name string) []ent.Value {
  4912  	switch name {
  4913  	}
  4914  	return nil
  4915  }
  4916  
  4917  // ClearedEdges returns all edge names that were cleared in this mutation.
  4918  func (m *EventMutation) ClearedEdges() []string {
  4919  	edges := make([]string, 0, 1)
  4920  	if m.clearedowner {
  4921  		edges = append(edges, event.EdgeOwner)
  4922  	}
  4923  	return edges
  4924  }
  4925  
  4926  // EdgeCleared returns a boolean which indicates if the edge with the given name
  4927  // was cleared in this mutation.
  4928  func (m *EventMutation) EdgeCleared(name string) bool {
  4929  	switch name {
  4930  	case event.EdgeOwner:
  4931  		return m.clearedowner
  4932  	}
  4933  	return false
  4934  }
  4935  
  4936  // ClearEdge clears the value of the edge with the given name. It returns an error
  4937  // if that edge is not defined in the schema.
  4938  func (m *EventMutation) ClearEdge(name string) error {
  4939  	switch name {
  4940  	case event.EdgeOwner:
  4941  		m.ClearOwner()
  4942  		return nil
  4943  	}
  4944  	return fmt.Errorf("unknown Event unique edge %s", name)
  4945  }
  4946  
  4947  // ResetEdge resets all changes to the edge with the given name in this mutation.
  4948  // It returns an error if the edge is not defined in the schema.
  4949  func (m *EventMutation) ResetEdge(name string) error {
  4950  	switch name {
  4951  	case event.EdgeOwner:
  4952  		m.ResetOwner()
  4953  		return nil
  4954  	}
  4955  	return fmt.Errorf("unknown Event edge %s", name)
  4956  }
  4957  
  4958  // MachineMutation represents an operation that mutates the Machine nodes in the graph.
  4959  type MachineMutation struct {
  4960  	config
  4961  	op            Op
  4962  	typ           string
  4963  	id            *int
  4964  	created_at    *time.Time
  4965  	updated_at    *time.Time
  4966  	machineId     *string
  4967  	password      *string
  4968  	ipAddress     *string
  4969  	scenarios     *string
  4970  	version       *string
  4971  	isValidated   *bool
  4972  	status        *string
  4973  	clearedFields map[string]struct{}
  4974  	alerts        map[int]struct{}
  4975  	removedalerts map[int]struct{}
  4976  	clearedalerts bool
  4977  	done          bool
  4978  	oldValue      func(context.Context) (*Machine, error)
  4979  	predicates    []predicate.Machine
  4980  }
  4981  
  4982  var _ ent.Mutation = (*MachineMutation)(nil)
  4983  
  4984  // machineOption allows management of the mutation configuration using functional options.
  4985  type machineOption func(*MachineMutation)
  4986  
  4987  // newMachineMutation creates new mutation for the Machine entity.
  4988  func newMachineMutation(c config, op Op, opts ...machineOption) *MachineMutation {
  4989  	m := &MachineMutation{
  4990  		config:        c,
  4991  		op:            op,
  4992  		typ:           TypeMachine,
  4993  		clearedFields: make(map[string]struct{}),
  4994  	}
  4995  	for _, opt := range opts {
  4996  		opt(m)
  4997  	}
  4998  	return m
  4999  }
  5000  
  5001  // withMachineID sets the ID field of the mutation.
  5002  func withMachineID(id int) machineOption {
  5003  	return func(m *MachineMutation) {
  5004  		var (
  5005  			err   error
  5006  			once  sync.Once
  5007  			value *Machine
  5008  		)
  5009  		m.oldValue = func(ctx context.Context) (*Machine, error) {
  5010  			once.Do(func() {
  5011  				if m.done {
  5012  					err = fmt.Errorf("querying old values post mutation is not allowed")
  5013  				} else {
  5014  					value, err = m.Client().Machine.Get(ctx, id)
  5015  				}
  5016  			})
  5017  			return value, err
  5018  		}
  5019  		m.id = &id
  5020  	}
  5021  }
  5022  
  5023  // withMachine sets the old Machine of the mutation.
  5024  func withMachine(node *Machine) machineOption {
  5025  	return func(m *MachineMutation) {
  5026  		m.oldValue = func(context.Context) (*Machine, error) {
  5027  			return node, nil
  5028  		}
  5029  		m.id = &node.ID
  5030  	}
  5031  }
  5032  
  5033  // Client returns a new `ent.Client` from the mutation. If the mutation was
  5034  // executed in a transaction (ent.Tx), a transactional client is returned.
  5035  func (m MachineMutation) Client() *Client {
  5036  	client := &Client{config: m.config}
  5037  	client.init()
  5038  	return client
  5039  }
  5040  
  5041  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5042  // it returns an error otherwise.
  5043  func (m MachineMutation) Tx() (*Tx, error) {
  5044  	if _, ok := m.driver.(*txDriver); !ok {
  5045  		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
  5046  	}
  5047  	tx := &Tx{config: m.config}
  5048  	tx.init()
  5049  	return tx, nil
  5050  }
  5051  
  5052  // ID returns the ID value in the mutation. Note that the ID
  5053  // is only available if it was provided to the builder.
  5054  func (m *MachineMutation) ID() (id int, exists bool) {
  5055  	if m.id == nil {
  5056  		return
  5057  	}
  5058  	return *m.id, true
  5059  }
  5060  
  5061  // SetCreatedAt sets the "created_at" field.
  5062  func (m *MachineMutation) SetCreatedAt(t time.Time) {
  5063  	m.created_at = &t
  5064  }
  5065  
  5066  // CreatedAt returns the value of the "created_at" field in the mutation.
  5067  func (m *MachineMutation) CreatedAt() (r time.Time, exists bool) {
  5068  	v := m.created_at
  5069  	if v == nil {
  5070  		return
  5071  	}
  5072  	return *v, true
  5073  }
  5074  
  5075  // OldCreatedAt returns the old "created_at" field's value of the Machine entity.
  5076  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  5077  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5078  func (m *MachineMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5079  	if !m.op.Is(OpUpdateOne) {
  5080  		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
  5081  	}
  5082  	if m.id == nil || m.oldValue == nil {
  5083  		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
  5084  	}
  5085  	oldValue, err := m.oldValue(ctx)
  5086  	if err != nil {
  5087  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5088  	}
  5089  	return oldValue.CreatedAt, nil
  5090  }
  5091  
  5092  // ResetCreatedAt resets all changes to the "created_at" field.
  5093  func (m *MachineMutation) ResetCreatedAt() {
  5094  	m.created_at = nil
  5095  }
  5096  
  5097  // SetUpdatedAt sets the "updated_at" field.
  5098  func (m *MachineMutation) SetUpdatedAt(t time.Time) {
  5099  	m.updated_at = &t
  5100  }
  5101  
  5102  // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5103  func (m *MachineMutation) UpdatedAt() (r time.Time, exists bool) {
  5104  	v := m.updated_at
  5105  	if v == nil {
  5106  		return
  5107  	}
  5108  	return *v, true
  5109  }
  5110  
  5111  // OldUpdatedAt returns the old "updated_at" field's value of the Machine entity.
  5112  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  5113  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5114  func (m *MachineMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5115  	if !m.op.Is(OpUpdateOne) {
  5116  		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
  5117  	}
  5118  	if m.id == nil || m.oldValue == nil {
  5119  		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
  5120  	}
  5121  	oldValue, err := m.oldValue(ctx)
  5122  	if err != nil {
  5123  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5124  	}
  5125  	return oldValue.UpdatedAt, nil
  5126  }
  5127  
  5128  // ResetUpdatedAt resets all changes to the "updated_at" field.
  5129  func (m *MachineMutation) ResetUpdatedAt() {
  5130  	m.updated_at = nil
  5131  }
  5132  
  5133  // SetMachineId sets the "machineId" field.
  5134  func (m *MachineMutation) SetMachineId(s string) {
  5135  	m.machineId = &s
  5136  }
  5137  
  5138  // MachineId returns the value of the "machineId" field in the mutation.
  5139  func (m *MachineMutation) MachineId() (r string, exists bool) {
  5140  	v := m.machineId
  5141  	if v == nil {
  5142  		return
  5143  	}
  5144  	return *v, true
  5145  }
  5146  
  5147  // OldMachineId returns the old "machineId" field's value of the Machine entity.
  5148  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  5149  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5150  func (m *MachineMutation) OldMachineId(ctx context.Context) (v string, err error) {
  5151  	if !m.op.Is(OpUpdateOne) {
  5152  		return v, fmt.Errorf("OldMachineId is only allowed on UpdateOne operations")
  5153  	}
  5154  	if m.id == nil || m.oldValue == nil {
  5155  		return v, fmt.Errorf("OldMachineId requires an ID field in the mutation")
  5156  	}
  5157  	oldValue, err := m.oldValue(ctx)
  5158  	if err != nil {
  5159  		return v, fmt.Errorf("querying old value for OldMachineId: %w", err)
  5160  	}
  5161  	return oldValue.MachineId, nil
  5162  }
  5163  
  5164  // ResetMachineId resets all changes to the "machineId" field.
  5165  func (m *MachineMutation) ResetMachineId() {
  5166  	m.machineId = nil
  5167  }
  5168  
  5169  // SetPassword sets the "password" field.
  5170  func (m *MachineMutation) SetPassword(s string) {
  5171  	m.password = &s
  5172  }
  5173  
  5174  // Password returns the value of the "password" field in the mutation.
  5175  func (m *MachineMutation) Password() (r string, exists bool) {
  5176  	v := m.password
  5177  	if v == nil {
  5178  		return
  5179  	}
  5180  	return *v, true
  5181  }
  5182  
  5183  // OldPassword returns the old "password" field's value of the Machine entity.
  5184  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  5185  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5186  func (m *MachineMutation) OldPassword(ctx context.Context) (v string, err error) {
  5187  	if !m.op.Is(OpUpdateOne) {
  5188  		return v, fmt.Errorf("OldPassword is only allowed on UpdateOne operations")
  5189  	}
  5190  	if m.id == nil || m.oldValue == nil {
  5191  		return v, fmt.Errorf("OldPassword requires an ID field in the mutation")
  5192  	}
  5193  	oldValue, err := m.oldValue(ctx)
  5194  	if err != nil {
  5195  		return v, fmt.Errorf("querying old value for OldPassword: %w", err)
  5196  	}
  5197  	return oldValue.Password, nil
  5198  }
  5199  
  5200  // ResetPassword resets all changes to the "password" field.
  5201  func (m *MachineMutation) ResetPassword() {
  5202  	m.password = nil
  5203  }
  5204  
  5205  // SetIpAddress sets the "ipAddress" field.
  5206  func (m *MachineMutation) SetIpAddress(s string) {
  5207  	m.ipAddress = &s
  5208  }
  5209  
  5210  // IpAddress returns the value of the "ipAddress" field in the mutation.
  5211  func (m *MachineMutation) IpAddress() (r string, exists bool) {
  5212  	v := m.ipAddress
  5213  	if v == nil {
  5214  		return
  5215  	}
  5216  	return *v, true
  5217  }
  5218  
  5219  // OldIpAddress returns the old "ipAddress" field's value of the Machine entity.
  5220  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  5221  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5222  func (m *MachineMutation) OldIpAddress(ctx context.Context) (v string, err error) {
  5223  	if !m.op.Is(OpUpdateOne) {
  5224  		return v, fmt.Errorf("OldIpAddress is only allowed on UpdateOne operations")
  5225  	}
  5226  	if m.id == nil || m.oldValue == nil {
  5227  		return v, fmt.Errorf("OldIpAddress requires an ID field in the mutation")
  5228  	}
  5229  	oldValue, err := m.oldValue(ctx)
  5230  	if err != nil {
  5231  		return v, fmt.Errorf("querying old value for OldIpAddress: %w", err)
  5232  	}
  5233  	return oldValue.IpAddress, nil
  5234  }
  5235  
  5236  // ResetIpAddress resets all changes to the "ipAddress" field.
  5237  func (m *MachineMutation) ResetIpAddress() {
  5238  	m.ipAddress = nil
  5239  }
  5240  
  5241  // SetScenarios sets the "scenarios" field.
  5242  func (m *MachineMutation) SetScenarios(s string) {
  5243  	m.scenarios = &s
  5244  }
  5245  
  5246  // Scenarios returns the value of the "scenarios" field in the mutation.
  5247  func (m *MachineMutation) Scenarios() (r string, exists bool) {
  5248  	v := m.scenarios
  5249  	if v == nil {
  5250  		return
  5251  	}
  5252  	return *v, true
  5253  }
  5254  
  5255  // OldScenarios returns the old "scenarios" field's value of the Machine entity.
  5256  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  5257  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5258  func (m *MachineMutation) OldScenarios(ctx context.Context) (v string, err error) {
  5259  	if !m.op.Is(OpUpdateOne) {
  5260  		return v, fmt.Errorf("OldScenarios is only allowed on UpdateOne operations")
  5261  	}
  5262  	if m.id == nil || m.oldValue == nil {
  5263  		return v, fmt.Errorf("OldScenarios requires an ID field in the mutation")
  5264  	}
  5265  	oldValue, err := m.oldValue(ctx)
  5266  	if err != nil {
  5267  		return v, fmt.Errorf("querying old value for OldScenarios: %w", err)
  5268  	}
  5269  	return oldValue.Scenarios, nil
  5270  }
  5271  
  5272  // ClearScenarios clears the value of the "scenarios" field.
  5273  func (m *MachineMutation) ClearScenarios() {
  5274  	m.scenarios = nil
  5275  	m.clearedFields[machine.FieldScenarios] = struct{}{}
  5276  }
  5277  
  5278  // ScenariosCleared returns if the "scenarios" field was cleared in this mutation.
  5279  func (m *MachineMutation) ScenariosCleared() bool {
  5280  	_, ok := m.clearedFields[machine.FieldScenarios]
  5281  	return ok
  5282  }
  5283  
  5284  // ResetScenarios resets all changes to the "scenarios" field.
  5285  func (m *MachineMutation) ResetScenarios() {
  5286  	m.scenarios = nil
  5287  	delete(m.clearedFields, machine.FieldScenarios)
  5288  }
  5289  
  5290  // SetVersion sets the "version" field.
  5291  func (m *MachineMutation) SetVersion(s string) {
  5292  	m.version = &s
  5293  }
  5294  
  5295  // Version returns the value of the "version" field in the mutation.
  5296  func (m *MachineMutation) Version() (r string, exists bool) {
  5297  	v := m.version
  5298  	if v == nil {
  5299  		return
  5300  	}
  5301  	return *v, true
  5302  }
  5303  
  5304  // OldVersion returns the old "version" field's value of the Machine entity.
  5305  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  5306  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5307  func (m *MachineMutation) OldVersion(ctx context.Context) (v string, err error) {
  5308  	if !m.op.Is(OpUpdateOne) {
  5309  		return v, fmt.Errorf("OldVersion is only allowed on UpdateOne operations")
  5310  	}
  5311  	if m.id == nil || m.oldValue == nil {
  5312  		return v, fmt.Errorf("OldVersion requires an ID field in the mutation")
  5313  	}
  5314  	oldValue, err := m.oldValue(ctx)
  5315  	if err != nil {
  5316  		return v, fmt.Errorf("querying old value for OldVersion: %w", err)
  5317  	}
  5318  	return oldValue.Version, nil
  5319  }
  5320  
  5321  // ClearVersion clears the value of the "version" field.
  5322  func (m *MachineMutation) ClearVersion() {
  5323  	m.version = nil
  5324  	m.clearedFields[machine.FieldVersion] = struct{}{}
  5325  }
  5326  
  5327  // VersionCleared returns if the "version" field was cleared in this mutation.
  5328  func (m *MachineMutation) VersionCleared() bool {
  5329  	_, ok := m.clearedFields[machine.FieldVersion]
  5330  	return ok
  5331  }
  5332  
  5333  // ResetVersion resets all changes to the "version" field.
  5334  func (m *MachineMutation) ResetVersion() {
  5335  	m.version = nil
  5336  	delete(m.clearedFields, machine.FieldVersion)
  5337  }
  5338  
  5339  // SetIsValidated sets the "isValidated" field.
  5340  func (m *MachineMutation) SetIsValidated(b bool) {
  5341  	m.isValidated = &b
  5342  }
  5343  
  5344  // IsValidated returns the value of the "isValidated" field in the mutation.
  5345  func (m *MachineMutation) IsValidated() (r bool, exists bool) {
  5346  	v := m.isValidated
  5347  	if v == nil {
  5348  		return
  5349  	}
  5350  	return *v, true
  5351  }
  5352  
  5353  // OldIsValidated returns the old "isValidated" field's value of the Machine entity.
  5354  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  5355  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5356  func (m *MachineMutation) OldIsValidated(ctx context.Context) (v bool, err error) {
  5357  	if !m.op.Is(OpUpdateOne) {
  5358  		return v, fmt.Errorf("OldIsValidated is only allowed on UpdateOne operations")
  5359  	}
  5360  	if m.id == nil || m.oldValue == nil {
  5361  		return v, fmt.Errorf("OldIsValidated requires an ID field in the mutation")
  5362  	}
  5363  	oldValue, err := m.oldValue(ctx)
  5364  	if err != nil {
  5365  		return v, fmt.Errorf("querying old value for OldIsValidated: %w", err)
  5366  	}
  5367  	return oldValue.IsValidated, nil
  5368  }
  5369  
  5370  // ResetIsValidated resets all changes to the "isValidated" field.
  5371  func (m *MachineMutation) ResetIsValidated() {
  5372  	m.isValidated = nil
  5373  }
  5374  
  5375  // SetStatus sets the "status" field.
  5376  func (m *MachineMutation) SetStatus(s string) {
  5377  	m.status = &s
  5378  }
  5379  
  5380  // Status returns the value of the "status" field in the mutation.
  5381  func (m *MachineMutation) Status() (r string, exists bool) {
  5382  	v := m.status
  5383  	if v == nil {
  5384  		return
  5385  	}
  5386  	return *v, true
  5387  }
  5388  
  5389  // OldStatus returns the old "status" field's value of the Machine entity.
  5390  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  5391  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5392  func (m *MachineMutation) OldStatus(ctx context.Context) (v string, err error) {
  5393  	if !m.op.Is(OpUpdateOne) {
  5394  		return v, fmt.Errorf("OldStatus is only allowed on UpdateOne operations")
  5395  	}
  5396  	if m.id == nil || m.oldValue == nil {
  5397  		return v, fmt.Errorf("OldStatus requires an ID field in the mutation")
  5398  	}
  5399  	oldValue, err := m.oldValue(ctx)
  5400  	if err != nil {
  5401  		return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5402  	}
  5403  	return oldValue.Status, nil
  5404  }
  5405  
  5406  // ClearStatus clears the value of the "status" field.
  5407  func (m *MachineMutation) ClearStatus() {
  5408  	m.status = nil
  5409  	m.clearedFields[machine.FieldStatus] = struct{}{}
  5410  }
  5411  
  5412  // StatusCleared returns if the "status" field was cleared in this mutation.
  5413  func (m *MachineMutation) StatusCleared() bool {
  5414  	_, ok := m.clearedFields[machine.FieldStatus]
  5415  	return ok
  5416  }
  5417  
  5418  // ResetStatus resets all changes to the "status" field.
  5419  func (m *MachineMutation) ResetStatus() {
  5420  	m.status = nil
  5421  	delete(m.clearedFields, machine.FieldStatus)
  5422  }
  5423  
  5424  // AddAlertIDs adds the "alerts" edge to the Alert entity by ids.
  5425  func (m *MachineMutation) AddAlertIDs(ids ...int) {
  5426  	if m.alerts == nil {
  5427  		m.alerts = make(map[int]struct{})
  5428  	}
  5429  	for i := range ids {
  5430  		m.alerts[ids[i]] = struct{}{}
  5431  	}
  5432  }
  5433  
  5434  // ClearAlerts clears the "alerts" edge to the Alert entity.
  5435  func (m *MachineMutation) ClearAlerts() {
  5436  	m.clearedalerts = true
  5437  }
  5438  
  5439  // AlertsCleared returns if the "alerts" edge to the Alert entity was cleared.
  5440  func (m *MachineMutation) AlertsCleared() bool {
  5441  	return m.clearedalerts
  5442  }
  5443  
  5444  // RemoveAlertIDs removes the "alerts" edge to the Alert entity by IDs.
  5445  func (m *MachineMutation) RemoveAlertIDs(ids ...int) {
  5446  	if m.removedalerts == nil {
  5447  		m.removedalerts = make(map[int]struct{})
  5448  	}
  5449  	for i := range ids {
  5450  		m.removedalerts[ids[i]] = struct{}{}
  5451  	}
  5452  }
  5453  
  5454  // RemovedAlerts returns the removed IDs of the "alerts" edge to the Alert entity.
  5455  func (m *MachineMutation) RemovedAlertsIDs() (ids []int) {
  5456  	for id := range m.removedalerts {
  5457  		ids = append(ids, id)
  5458  	}
  5459  	return
  5460  }
  5461  
  5462  // AlertsIDs returns the "alerts" edge IDs in the mutation.
  5463  func (m *MachineMutation) AlertsIDs() (ids []int) {
  5464  	for id := range m.alerts {
  5465  		ids = append(ids, id)
  5466  	}
  5467  	return
  5468  }
  5469  
  5470  // ResetAlerts resets all changes to the "alerts" edge.
  5471  func (m *MachineMutation) ResetAlerts() {
  5472  	m.alerts = nil
  5473  	m.clearedalerts = false
  5474  	m.removedalerts = nil
  5475  }
  5476  
  5477  // Op returns the operation name.
  5478  func (m *MachineMutation) Op() Op {
  5479  	return m.op
  5480  }
  5481  
  5482  // Type returns the node type of this mutation (Machine).
  5483  func (m *MachineMutation) Type() string {
  5484  	return m.typ
  5485  }
  5486  
  5487  // Fields returns all fields that were changed during this mutation. Note that in
  5488  // order to get all numeric fields that were incremented/decremented, call
  5489  // AddedFields().
  5490  func (m *MachineMutation) Fields() []string {
  5491  	fields := make([]string, 0, 9)
  5492  	if m.created_at != nil {
  5493  		fields = append(fields, machine.FieldCreatedAt)
  5494  	}
  5495  	if m.updated_at != nil {
  5496  		fields = append(fields, machine.FieldUpdatedAt)
  5497  	}
  5498  	if m.machineId != nil {
  5499  		fields = append(fields, machine.FieldMachineId)
  5500  	}
  5501  	if m.password != nil {
  5502  		fields = append(fields, machine.FieldPassword)
  5503  	}
  5504  	if m.ipAddress != nil {
  5505  		fields = append(fields, machine.FieldIpAddress)
  5506  	}
  5507  	if m.scenarios != nil {
  5508  		fields = append(fields, machine.FieldScenarios)
  5509  	}
  5510  	if m.version != nil {
  5511  		fields = append(fields, machine.FieldVersion)
  5512  	}
  5513  	if m.isValidated != nil {
  5514  		fields = append(fields, machine.FieldIsValidated)
  5515  	}
  5516  	if m.status != nil {
  5517  		fields = append(fields, machine.FieldStatus)
  5518  	}
  5519  	return fields
  5520  }
  5521  
  5522  // Field returns the value of a field with the given name. The second boolean
  5523  // return value indicates that this field was not set, or was not defined in the
  5524  // schema.
  5525  func (m *MachineMutation) Field(name string) (ent.Value, bool) {
  5526  	switch name {
  5527  	case machine.FieldCreatedAt:
  5528  		return m.CreatedAt()
  5529  	case machine.FieldUpdatedAt:
  5530  		return m.UpdatedAt()
  5531  	case machine.FieldMachineId:
  5532  		return m.MachineId()
  5533  	case machine.FieldPassword:
  5534  		return m.Password()
  5535  	case machine.FieldIpAddress:
  5536  		return m.IpAddress()
  5537  	case machine.FieldScenarios:
  5538  		return m.Scenarios()
  5539  	case machine.FieldVersion:
  5540  		return m.Version()
  5541  	case machine.FieldIsValidated:
  5542  		return m.IsValidated()
  5543  	case machine.FieldStatus:
  5544  		return m.Status()
  5545  	}
  5546  	return nil, false
  5547  }
  5548  
  5549  // OldField returns the old value of the field from the database. An error is
  5550  // returned if the mutation operation is not UpdateOne, or the query to the
  5551  // database failed.
  5552  func (m *MachineMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5553  	switch name {
  5554  	case machine.FieldCreatedAt:
  5555  		return m.OldCreatedAt(ctx)
  5556  	case machine.FieldUpdatedAt:
  5557  		return m.OldUpdatedAt(ctx)
  5558  	case machine.FieldMachineId:
  5559  		return m.OldMachineId(ctx)
  5560  	case machine.FieldPassword:
  5561  		return m.OldPassword(ctx)
  5562  	case machine.FieldIpAddress:
  5563  		return m.OldIpAddress(ctx)
  5564  	case machine.FieldScenarios:
  5565  		return m.OldScenarios(ctx)
  5566  	case machine.FieldVersion:
  5567  		return m.OldVersion(ctx)
  5568  	case machine.FieldIsValidated:
  5569  		return m.OldIsValidated(ctx)
  5570  	case machine.FieldStatus:
  5571  		return m.OldStatus(ctx)
  5572  	}
  5573  	return nil, fmt.Errorf("unknown Machine field %s", name)
  5574  }
  5575  
  5576  // SetField sets the value of a field with the given name. It returns an error if
  5577  // the field is not defined in the schema, or if the type mismatched the field
  5578  // type.
  5579  func (m *MachineMutation) SetField(name string, value ent.Value) error {
  5580  	switch name {
  5581  	case machine.FieldCreatedAt:
  5582  		v, ok := value.(time.Time)
  5583  		if !ok {
  5584  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5585  		}
  5586  		m.SetCreatedAt(v)
  5587  		return nil
  5588  	case machine.FieldUpdatedAt:
  5589  		v, ok := value.(time.Time)
  5590  		if !ok {
  5591  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5592  		}
  5593  		m.SetUpdatedAt(v)
  5594  		return nil
  5595  	case machine.FieldMachineId:
  5596  		v, ok := value.(string)
  5597  		if !ok {
  5598  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5599  		}
  5600  		m.SetMachineId(v)
  5601  		return nil
  5602  	case machine.FieldPassword:
  5603  		v, ok := value.(string)
  5604  		if !ok {
  5605  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5606  		}
  5607  		m.SetPassword(v)
  5608  		return nil
  5609  	case machine.FieldIpAddress:
  5610  		v, ok := value.(string)
  5611  		if !ok {
  5612  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5613  		}
  5614  		m.SetIpAddress(v)
  5615  		return nil
  5616  	case machine.FieldScenarios:
  5617  		v, ok := value.(string)
  5618  		if !ok {
  5619  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5620  		}
  5621  		m.SetScenarios(v)
  5622  		return nil
  5623  	case machine.FieldVersion:
  5624  		v, ok := value.(string)
  5625  		if !ok {
  5626  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5627  		}
  5628  		m.SetVersion(v)
  5629  		return nil
  5630  	case machine.FieldIsValidated:
  5631  		v, ok := value.(bool)
  5632  		if !ok {
  5633  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5634  		}
  5635  		m.SetIsValidated(v)
  5636  		return nil
  5637  	case machine.FieldStatus:
  5638  		v, ok := value.(string)
  5639  		if !ok {
  5640  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5641  		}
  5642  		m.SetStatus(v)
  5643  		return nil
  5644  	}
  5645  	return fmt.Errorf("unknown Machine field %s", name)
  5646  }
  5647  
  5648  // AddedFields returns all numeric fields that were incremented/decremented during
  5649  // this mutation.
  5650  func (m *MachineMutation) AddedFields() []string {
  5651  	return nil
  5652  }
  5653  
  5654  // AddedField returns the numeric value that was incremented/decremented on a field
  5655  // with the given name. The second boolean return value indicates that this field
  5656  // was not set, or was not defined in the schema.
  5657  func (m *MachineMutation) AddedField(name string) (ent.Value, bool) {
  5658  	return nil, false
  5659  }
  5660  
  5661  // AddField adds the value to the field with the given name. It returns an error if
  5662  // the field is not defined in the schema, or if the type mismatched the field
  5663  // type.
  5664  func (m *MachineMutation) AddField(name string, value ent.Value) error {
  5665  	switch name {
  5666  	}
  5667  	return fmt.Errorf("unknown Machine numeric field %s", name)
  5668  }
  5669  
  5670  // ClearedFields returns all nullable fields that were cleared during this
  5671  // mutation.
  5672  func (m *MachineMutation) ClearedFields() []string {
  5673  	var fields []string
  5674  	if m.FieldCleared(machine.FieldScenarios) {
  5675  		fields = append(fields, machine.FieldScenarios)
  5676  	}
  5677  	if m.FieldCleared(machine.FieldVersion) {
  5678  		fields = append(fields, machine.FieldVersion)
  5679  	}
  5680  	if m.FieldCleared(machine.FieldStatus) {
  5681  		fields = append(fields, machine.FieldStatus)
  5682  	}
  5683  	return fields
  5684  }
  5685  
  5686  // FieldCleared returns a boolean indicating if a field with the given name was
  5687  // cleared in this mutation.
  5688  func (m *MachineMutation) FieldCleared(name string) bool {
  5689  	_, ok := m.clearedFields[name]
  5690  	return ok
  5691  }
  5692  
  5693  // ClearField clears the value of the field with the given name. It returns an
  5694  // error if the field is not defined in the schema.
  5695  func (m *MachineMutation) ClearField(name string) error {
  5696  	switch name {
  5697  	case machine.FieldScenarios:
  5698  		m.ClearScenarios()
  5699  		return nil
  5700  	case machine.FieldVersion:
  5701  		m.ClearVersion()
  5702  		return nil
  5703  	case machine.FieldStatus:
  5704  		m.ClearStatus()
  5705  		return nil
  5706  	}
  5707  	return fmt.Errorf("unknown Machine nullable field %s", name)
  5708  }
  5709  
  5710  // ResetField resets all changes in the mutation for the field with the given name.
  5711  // It returns an error if the field is not defined in the schema.
  5712  func (m *MachineMutation) ResetField(name string) error {
  5713  	switch name {
  5714  	case machine.FieldCreatedAt:
  5715  		m.ResetCreatedAt()
  5716  		return nil
  5717  	case machine.FieldUpdatedAt:
  5718  		m.ResetUpdatedAt()
  5719  		return nil
  5720  	case machine.FieldMachineId:
  5721  		m.ResetMachineId()
  5722  		return nil
  5723  	case machine.FieldPassword:
  5724  		m.ResetPassword()
  5725  		return nil
  5726  	case machine.FieldIpAddress:
  5727  		m.ResetIpAddress()
  5728  		return nil
  5729  	case machine.FieldScenarios:
  5730  		m.ResetScenarios()
  5731  		return nil
  5732  	case machine.FieldVersion:
  5733  		m.ResetVersion()
  5734  		return nil
  5735  	case machine.FieldIsValidated:
  5736  		m.ResetIsValidated()
  5737  		return nil
  5738  	case machine.FieldStatus:
  5739  		m.ResetStatus()
  5740  		return nil
  5741  	}
  5742  	return fmt.Errorf("unknown Machine field %s", name)
  5743  }
  5744  
  5745  // AddedEdges returns all edge names that were set/added in this mutation.
  5746  func (m *MachineMutation) AddedEdges() []string {
  5747  	edges := make([]string, 0, 1)
  5748  	if m.alerts != nil {
  5749  		edges = append(edges, machine.EdgeAlerts)
  5750  	}
  5751  	return edges
  5752  }
  5753  
  5754  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5755  // name in this mutation.
  5756  func (m *MachineMutation) AddedIDs(name string) []ent.Value {
  5757  	switch name {
  5758  	case machine.EdgeAlerts:
  5759  		ids := make([]ent.Value, 0, len(m.alerts))
  5760  		for id := range m.alerts {
  5761  			ids = append(ids, id)
  5762  		}
  5763  		return ids
  5764  	}
  5765  	return nil
  5766  }
  5767  
  5768  // RemovedEdges returns all edge names that were removed in this mutation.
  5769  func (m *MachineMutation) RemovedEdges() []string {
  5770  	edges := make([]string, 0, 1)
  5771  	if m.removedalerts != nil {
  5772  		edges = append(edges, machine.EdgeAlerts)
  5773  	}
  5774  	return edges
  5775  }
  5776  
  5777  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5778  // the given name in this mutation.
  5779  func (m *MachineMutation) RemovedIDs(name string) []ent.Value {
  5780  	switch name {
  5781  	case machine.EdgeAlerts:
  5782  		ids := make([]ent.Value, 0, len(m.removedalerts))
  5783  		for id := range m.removedalerts {
  5784  			ids = append(ids, id)
  5785  		}
  5786  		return ids
  5787  	}
  5788  	return nil
  5789  }
  5790  
  5791  // ClearedEdges returns all edge names that were cleared in this mutation.
  5792  func (m *MachineMutation) ClearedEdges() []string {
  5793  	edges := make([]string, 0, 1)
  5794  	if m.clearedalerts {
  5795  		edges = append(edges, machine.EdgeAlerts)
  5796  	}
  5797  	return edges
  5798  }
  5799  
  5800  // EdgeCleared returns a boolean which indicates if the edge with the given name
  5801  // was cleared in this mutation.
  5802  func (m *MachineMutation) EdgeCleared(name string) bool {
  5803  	switch name {
  5804  	case machine.EdgeAlerts:
  5805  		return m.clearedalerts
  5806  	}
  5807  	return false
  5808  }
  5809  
  5810  // ClearEdge clears the value of the edge with the given name. It returns an error
  5811  // if that edge is not defined in the schema.
  5812  func (m *MachineMutation) ClearEdge(name string) error {
  5813  	switch name {
  5814  	}
  5815  	return fmt.Errorf("unknown Machine unique edge %s", name)
  5816  }
  5817  
  5818  // ResetEdge resets all changes to the edge with the given name in this mutation.
  5819  // It returns an error if the edge is not defined in the schema.
  5820  func (m *MachineMutation) ResetEdge(name string) error {
  5821  	switch name {
  5822  	case machine.EdgeAlerts:
  5823  		m.ResetAlerts()
  5824  		return nil
  5825  	}
  5826  	return fmt.Errorf("unknown Machine edge %s", name)
  5827  }
  5828  
  5829  // MetaMutation represents an operation that mutates the Meta nodes in the graph.
  5830  type MetaMutation struct {
  5831  	config
  5832  	op            Op
  5833  	typ           string
  5834  	id            *int
  5835  	created_at    *time.Time
  5836  	updated_at    *time.Time
  5837  	key           *string
  5838  	value         *string
  5839  	clearedFields map[string]struct{}
  5840  	owner         *int
  5841  	clearedowner  bool
  5842  	done          bool
  5843  	oldValue      func(context.Context) (*Meta, error)
  5844  	predicates    []predicate.Meta
  5845  }
  5846  
  5847  var _ ent.Mutation = (*MetaMutation)(nil)
  5848  
  5849  // metaOption allows management of the mutation configuration using functional options.
  5850  type metaOption func(*MetaMutation)
  5851  
  5852  // newMetaMutation creates new mutation for the Meta entity.
  5853  func newMetaMutation(c config, op Op, opts ...metaOption) *MetaMutation {
  5854  	m := &MetaMutation{
  5855  		config:        c,
  5856  		op:            op,
  5857  		typ:           TypeMeta,
  5858  		clearedFields: make(map[string]struct{}),
  5859  	}
  5860  	for _, opt := range opts {
  5861  		opt(m)
  5862  	}
  5863  	return m
  5864  }
  5865  
  5866  // withMetaID sets the ID field of the mutation.
  5867  func withMetaID(id int) metaOption {
  5868  	return func(m *MetaMutation) {
  5869  		var (
  5870  			err   error
  5871  			once  sync.Once
  5872  			value *Meta
  5873  		)
  5874  		m.oldValue = func(ctx context.Context) (*Meta, error) {
  5875  			once.Do(func() {
  5876  				if m.done {
  5877  					err = fmt.Errorf("querying old values post mutation is not allowed")
  5878  				} else {
  5879  					value, err = m.Client().Meta.Get(ctx, id)
  5880  				}
  5881  			})
  5882  			return value, err
  5883  		}
  5884  		m.id = &id
  5885  	}
  5886  }
  5887  
  5888  // withMeta sets the old Meta of the mutation.
  5889  func withMeta(node *Meta) metaOption {
  5890  	return func(m *MetaMutation) {
  5891  		m.oldValue = func(context.Context) (*Meta, error) {
  5892  			return node, nil
  5893  		}
  5894  		m.id = &node.ID
  5895  	}
  5896  }
  5897  
  5898  // Client returns a new `ent.Client` from the mutation. If the mutation was
  5899  // executed in a transaction (ent.Tx), a transactional client is returned.
  5900  func (m MetaMutation) Client() *Client {
  5901  	client := &Client{config: m.config}
  5902  	client.init()
  5903  	return client
  5904  }
  5905  
  5906  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5907  // it returns an error otherwise.
  5908  func (m MetaMutation) Tx() (*Tx, error) {
  5909  	if _, ok := m.driver.(*txDriver); !ok {
  5910  		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
  5911  	}
  5912  	tx := &Tx{config: m.config}
  5913  	tx.init()
  5914  	return tx, nil
  5915  }
  5916  
  5917  // ID returns the ID value in the mutation. Note that the ID
  5918  // is only available if it was provided to the builder.
  5919  func (m *MetaMutation) ID() (id int, exists bool) {
  5920  	if m.id == nil {
  5921  		return
  5922  	}
  5923  	return *m.id, true
  5924  }
  5925  
  5926  // SetCreatedAt sets the "created_at" field.
  5927  func (m *MetaMutation) SetCreatedAt(t time.Time) {
  5928  	m.created_at = &t
  5929  }
  5930  
  5931  // CreatedAt returns the value of the "created_at" field in the mutation.
  5932  func (m *MetaMutation) CreatedAt() (r time.Time, exists bool) {
  5933  	v := m.created_at
  5934  	if v == nil {
  5935  		return
  5936  	}
  5937  	return *v, true
  5938  }
  5939  
  5940  // OldCreatedAt returns the old "created_at" field's value of the Meta entity.
  5941  // If the Meta object wasn't provided to the builder, the object is fetched from the database.
  5942  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5943  func (m *MetaMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5944  	if !m.op.Is(OpUpdateOne) {
  5945  		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
  5946  	}
  5947  	if m.id == nil || m.oldValue == nil {
  5948  		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
  5949  	}
  5950  	oldValue, err := m.oldValue(ctx)
  5951  	if err != nil {
  5952  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5953  	}
  5954  	return oldValue.CreatedAt, nil
  5955  }
  5956  
  5957  // ResetCreatedAt resets all changes to the "created_at" field.
  5958  func (m *MetaMutation) ResetCreatedAt() {
  5959  	m.created_at = nil
  5960  }
  5961  
  5962  // SetUpdatedAt sets the "updated_at" field.
  5963  func (m *MetaMutation) SetUpdatedAt(t time.Time) {
  5964  	m.updated_at = &t
  5965  }
  5966  
  5967  // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5968  func (m *MetaMutation) UpdatedAt() (r time.Time, exists bool) {
  5969  	v := m.updated_at
  5970  	if v == nil {
  5971  		return
  5972  	}
  5973  	return *v, true
  5974  }
  5975  
  5976  // OldUpdatedAt returns the old "updated_at" field's value of the Meta entity.
  5977  // If the Meta object wasn't provided to the builder, the object is fetched from the database.
  5978  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5979  func (m *MetaMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5980  	if !m.op.Is(OpUpdateOne) {
  5981  		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
  5982  	}
  5983  	if m.id == nil || m.oldValue == nil {
  5984  		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
  5985  	}
  5986  	oldValue, err := m.oldValue(ctx)
  5987  	if err != nil {
  5988  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5989  	}
  5990  	return oldValue.UpdatedAt, nil
  5991  }
  5992  
  5993  // ResetUpdatedAt resets all changes to the "updated_at" field.
  5994  func (m *MetaMutation) ResetUpdatedAt() {
  5995  	m.updated_at = nil
  5996  }
  5997  
  5998  // SetKey sets the "key" field.
  5999  func (m *MetaMutation) SetKey(s string) {
  6000  	m.key = &s
  6001  }
  6002  
  6003  // Key returns the value of the "key" field in the mutation.
  6004  func (m *MetaMutation) Key() (r string, exists bool) {
  6005  	v := m.key
  6006  	if v == nil {
  6007  		return
  6008  	}
  6009  	return *v, true
  6010  }
  6011  
  6012  // OldKey returns the old "key" field's value of the Meta entity.
  6013  // If the Meta object wasn't provided to the builder, the object is fetched from the database.
  6014  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6015  func (m *MetaMutation) OldKey(ctx context.Context) (v string, err error) {
  6016  	if !m.op.Is(OpUpdateOne) {
  6017  		return v, fmt.Errorf("OldKey is only allowed on UpdateOne operations")
  6018  	}
  6019  	if m.id == nil || m.oldValue == nil {
  6020  		return v, fmt.Errorf("OldKey requires an ID field in the mutation")
  6021  	}
  6022  	oldValue, err := m.oldValue(ctx)
  6023  	if err != nil {
  6024  		return v, fmt.Errorf("querying old value for OldKey: %w", err)
  6025  	}
  6026  	return oldValue.Key, nil
  6027  }
  6028  
  6029  // ResetKey resets all changes to the "key" field.
  6030  func (m *MetaMutation) ResetKey() {
  6031  	m.key = nil
  6032  }
  6033  
  6034  // SetValue sets the "value" field.
  6035  func (m *MetaMutation) SetValue(s string) {
  6036  	m.value = &s
  6037  }
  6038  
  6039  // Value returns the value of the "value" field in the mutation.
  6040  func (m *MetaMutation) Value() (r string, exists bool) {
  6041  	v := m.value
  6042  	if v == nil {
  6043  		return
  6044  	}
  6045  	return *v, true
  6046  }
  6047  
  6048  // OldValue returns the old "value" field's value of the Meta entity.
  6049  // If the Meta object wasn't provided to the builder, the object is fetched from the database.
  6050  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6051  func (m *MetaMutation) OldValue(ctx context.Context) (v string, err error) {
  6052  	if !m.op.Is(OpUpdateOne) {
  6053  		return v, fmt.Errorf("OldValue is only allowed on UpdateOne operations")
  6054  	}
  6055  	if m.id == nil || m.oldValue == nil {
  6056  		return v, fmt.Errorf("OldValue requires an ID field in the mutation")
  6057  	}
  6058  	oldValue, err := m.oldValue(ctx)
  6059  	if err != nil {
  6060  		return v, fmt.Errorf("querying old value for OldValue: %w", err)
  6061  	}
  6062  	return oldValue.Value, nil
  6063  }
  6064  
  6065  // ResetValue resets all changes to the "value" field.
  6066  func (m *MetaMutation) ResetValue() {
  6067  	m.value = nil
  6068  }
  6069  
  6070  // SetOwnerID sets the "owner" edge to the Alert entity by id.
  6071  func (m *MetaMutation) SetOwnerID(id int) {
  6072  	m.owner = &id
  6073  }
  6074  
  6075  // ClearOwner clears the "owner" edge to the Alert entity.
  6076  func (m *MetaMutation) ClearOwner() {
  6077  	m.clearedowner = true
  6078  }
  6079  
  6080  // OwnerCleared returns if the "owner" edge to the Alert entity was cleared.
  6081  func (m *MetaMutation) OwnerCleared() bool {
  6082  	return m.clearedowner
  6083  }
  6084  
  6085  // OwnerID returns the "owner" edge ID in the mutation.
  6086  func (m *MetaMutation) OwnerID() (id int, exists bool) {
  6087  	if m.owner != nil {
  6088  		return *m.owner, true
  6089  	}
  6090  	return
  6091  }
  6092  
  6093  // OwnerIDs returns the "owner" edge IDs in the mutation.
  6094  // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6095  // OwnerID instead. It exists only for internal usage by the builders.
  6096  func (m *MetaMutation) OwnerIDs() (ids []int) {
  6097  	if id := m.owner; id != nil {
  6098  		ids = append(ids, *id)
  6099  	}
  6100  	return
  6101  }
  6102  
  6103  // ResetOwner resets all changes to the "owner" edge.
  6104  func (m *MetaMutation) ResetOwner() {
  6105  	m.owner = nil
  6106  	m.clearedowner = false
  6107  }
  6108  
  6109  // Op returns the operation name.
  6110  func (m *MetaMutation) Op() Op {
  6111  	return m.op
  6112  }
  6113  
  6114  // Type returns the node type of this mutation (Meta).
  6115  func (m *MetaMutation) Type() string {
  6116  	return m.typ
  6117  }
  6118  
  6119  // Fields returns all fields that were changed during this mutation. Note that in
  6120  // order to get all numeric fields that were incremented/decremented, call
  6121  // AddedFields().
  6122  func (m *MetaMutation) Fields() []string {
  6123  	fields := make([]string, 0, 4)
  6124  	if m.created_at != nil {
  6125  		fields = append(fields, meta.FieldCreatedAt)
  6126  	}
  6127  	if m.updated_at != nil {
  6128  		fields = append(fields, meta.FieldUpdatedAt)
  6129  	}
  6130  	if m.key != nil {
  6131  		fields = append(fields, meta.FieldKey)
  6132  	}
  6133  	if m.value != nil {
  6134  		fields = append(fields, meta.FieldValue)
  6135  	}
  6136  	return fields
  6137  }
  6138  
  6139  // Field returns the value of a field with the given name. The second boolean
  6140  // return value indicates that this field was not set, or was not defined in the
  6141  // schema.
  6142  func (m *MetaMutation) Field(name string) (ent.Value, bool) {
  6143  	switch name {
  6144  	case meta.FieldCreatedAt:
  6145  		return m.CreatedAt()
  6146  	case meta.FieldUpdatedAt:
  6147  		return m.UpdatedAt()
  6148  	case meta.FieldKey:
  6149  		return m.Key()
  6150  	case meta.FieldValue:
  6151  		return m.Value()
  6152  	}
  6153  	return nil, false
  6154  }
  6155  
  6156  // OldField returns the old value of the field from the database. An error is
  6157  // returned if the mutation operation is not UpdateOne, or the query to the
  6158  // database failed.
  6159  func (m *MetaMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6160  	switch name {
  6161  	case meta.FieldCreatedAt:
  6162  		return m.OldCreatedAt(ctx)
  6163  	case meta.FieldUpdatedAt:
  6164  		return m.OldUpdatedAt(ctx)
  6165  	case meta.FieldKey:
  6166  		return m.OldKey(ctx)
  6167  	case meta.FieldValue:
  6168  		return m.OldValue(ctx)
  6169  	}
  6170  	return nil, fmt.Errorf("unknown Meta field %s", name)
  6171  }
  6172  
  6173  // SetField sets the value of a field with the given name. It returns an error if
  6174  // the field is not defined in the schema, or if the type mismatched the field
  6175  // type.
  6176  func (m *MetaMutation) SetField(name string, value ent.Value) error {
  6177  	switch name {
  6178  	case meta.FieldCreatedAt:
  6179  		v, ok := value.(time.Time)
  6180  		if !ok {
  6181  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  6182  		}
  6183  		m.SetCreatedAt(v)
  6184  		return nil
  6185  	case meta.FieldUpdatedAt:
  6186  		v, ok := value.(time.Time)
  6187  		if !ok {
  6188  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  6189  		}
  6190  		m.SetUpdatedAt(v)
  6191  		return nil
  6192  	case meta.FieldKey:
  6193  		v, ok := value.(string)
  6194  		if !ok {
  6195  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  6196  		}
  6197  		m.SetKey(v)
  6198  		return nil
  6199  	case meta.FieldValue:
  6200  		v, ok := value.(string)
  6201  		if !ok {
  6202  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  6203  		}
  6204  		m.SetValue(v)
  6205  		return nil
  6206  	}
  6207  	return fmt.Errorf("unknown Meta field %s", name)
  6208  }
  6209  
  6210  // AddedFields returns all numeric fields that were incremented/decremented during
  6211  // this mutation.
  6212  func (m *MetaMutation) AddedFields() []string {
  6213  	return nil
  6214  }
  6215  
  6216  // AddedField returns the numeric value that was incremented/decremented on a field
  6217  // with the given name. The second boolean return value indicates that this field
  6218  // was not set, or was not defined in the schema.
  6219  func (m *MetaMutation) AddedField(name string) (ent.Value, bool) {
  6220  	return nil, false
  6221  }
  6222  
  6223  // AddField adds the value to the field with the given name. It returns an error if
  6224  // the field is not defined in the schema, or if the type mismatched the field
  6225  // type.
  6226  func (m *MetaMutation) AddField(name string, value ent.Value) error {
  6227  	switch name {
  6228  	}
  6229  	return fmt.Errorf("unknown Meta numeric field %s", name)
  6230  }
  6231  
  6232  // ClearedFields returns all nullable fields that were cleared during this
  6233  // mutation.
  6234  func (m *MetaMutation) ClearedFields() []string {
  6235  	return nil
  6236  }
  6237  
  6238  // FieldCleared returns a boolean indicating if a field with the given name was
  6239  // cleared in this mutation.
  6240  func (m *MetaMutation) FieldCleared(name string) bool {
  6241  	_, ok := m.clearedFields[name]
  6242  	return ok
  6243  }
  6244  
  6245  // ClearField clears the value of the field with the given name. It returns an
  6246  // error if the field is not defined in the schema.
  6247  func (m *MetaMutation) ClearField(name string) error {
  6248  	return fmt.Errorf("unknown Meta nullable field %s", name)
  6249  }
  6250  
  6251  // ResetField resets all changes in the mutation for the field with the given name.
  6252  // It returns an error if the field is not defined in the schema.
  6253  func (m *MetaMutation) ResetField(name string) error {
  6254  	switch name {
  6255  	case meta.FieldCreatedAt:
  6256  		m.ResetCreatedAt()
  6257  		return nil
  6258  	case meta.FieldUpdatedAt:
  6259  		m.ResetUpdatedAt()
  6260  		return nil
  6261  	case meta.FieldKey:
  6262  		m.ResetKey()
  6263  		return nil
  6264  	case meta.FieldValue:
  6265  		m.ResetValue()
  6266  		return nil
  6267  	}
  6268  	return fmt.Errorf("unknown Meta field %s", name)
  6269  }
  6270  
  6271  // AddedEdges returns all edge names that were set/added in this mutation.
  6272  func (m *MetaMutation) AddedEdges() []string {
  6273  	edges := make([]string, 0, 1)
  6274  	if m.owner != nil {
  6275  		edges = append(edges, meta.EdgeOwner)
  6276  	}
  6277  	return edges
  6278  }
  6279  
  6280  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6281  // name in this mutation.
  6282  func (m *MetaMutation) AddedIDs(name string) []ent.Value {
  6283  	switch name {
  6284  	case meta.EdgeOwner:
  6285  		if id := m.owner; id != nil {
  6286  			return []ent.Value{*id}
  6287  		}
  6288  	}
  6289  	return nil
  6290  }
  6291  
  6292  // RemovedEdges returns all edge names that were removed in this mutation.
  6293  func (m *MetaMutation) RemovedEdges() []string {
  6294  	edges := make([]string, 0, 1)
  6295  	return edges
  6296  }
  6297  
  6298  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6299  // the given name in this mutation.
  6300  func (m *MetaMutation) RemovedIDs(name string) []ent.Value {
  6301  	switch name {
  6302  	}
  6303  	return nil
  6304  }
  6305  
  6306  // ClearedEdges returns all edge names that were cleared in this mutation.
  6307  func (m *MetaMutation) ClearedEdges() []string {
  6308  	edges := make([]string, 0, 1)
  6309  	if m.clearedowner {
  6310  		edges = append(edges, meta.EdgeOwner)
  6311  	}
  6312  	return edges
  6313  }
  6314  
  6315  // EdgeCleared returns a boolean which indicates if the edge with the given name
  6316  // was cleared in this mutation.
  6317  func (m *MetaMutation) EdgeCleared(name string) bool {
  6318  	switch name {
  6319  	case meta.EdgeOwner:
  6320  		return m.clearedowner
  6321  	}
  6322  	return false
  6323  }
  6324  
  6325  // ClearEdge clears the value of the edge with the given name. It returns an error
  6326  // if that edge is not defined in the schema.
  6327  func (m *MetaMutation) ClearEdge(name string) error {
  6328  	switch name {
  6329  	case meta.EdgeOwner:
  6330  		m.ClearOwner()
  6331  		return nil
  6332  	}
  6333  	return fmt.Errorf("unknown Meta unique edge %s", name)
  6334  }
  6335  
  6336  // ResetEdge resets all changes to the edge with the given name in this mutation.
  6337  // It returns an error if the edge is not defined in the schema.
  6338  func (m *MetaMutation) ResetEdge(name string) error {
  6339  	switch name {
  6340  	case meta.EdgeOwner:
  6341  		m.ResetOwner()
  6342  		return nil
  6343  	}
  6344  	return fmt.Errorf("unknown Meta edge %s", name)
  6345  }