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

     1  // Code generated by ent, DO NOT EDIT.
     2  
     3  package ent
     4  
     5  import (
     6  	"context"
     7  	"errors"
     8  	"fmt"
     9  	"sync"
    10  	"time"
    11  
    12  	"entgo.io/ent"
    13  	"entgo.io/ent/dialect/sql"
    14  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
    15  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/bouncer"
    16  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/configitem"
    17  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
    18  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/event"
    19  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/lock"
    20  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
    21  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
    22  	"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
    23  )
    24  
    25  const (
    26  	// Operation types.
    27  	OpCreate    = ent.OpCreate
    28  	OpDelete    = ent.OpDelete
    29  	OpDeleteOne = ent.OpDeleteOne
    30  	OpUpdate    = ent.OpUpdate
    31  	OpUpdateOne = ent.OpUpdateOne
    32  
    33  	// Node types.
    34  	TypeAlert      = "Alert"
    35  	TypeBouncer    = "Bouncer"
    36  	TypeConfigItem = "ConfigItem"
    37  	TypeDecision   = "Decision"
    38  	TypeEvent      = "Event"
    39  	TypeLock       = "Lock"
    40  	TypeMachine    = "Machine"
    41  	TypeMeta       = "Meta"
    42  )
    43  
    44  // AlertMutation represents an operation that mutates the Alert nodes in the graph.
    45  type AlertMutation struct {
    46  	config
    47  	op                 Op
    48  	typ                string
    49  	id                 *int
    50  	created_at         *time.Time
    51  	updated_at         *time.Time
    52  	scenario           *string
    53  	bucketId           *string
    54  	message            *string
    55  	eventsCount        *int32
    56  	addeventsCount     *int32
    57  	startedAt          *time.Time
    58  	stoppedAt          *time.Time
    59  	sourceIp           *string
    60  	sourceRange        *string
    61  	sourceAsNumber     *string
    62  	sourceAsName       *string
    63  	sourceCountry      *string
    64  	sourceLatitude     *float32
    65  	addsourceLatitude  *float32
    66  	sourceLongitude    *float32
    67  	addsourceLongitude *float32
    68  	sourceScope        *string
    69  	sourceValue        *string
    70  	capacity           *int32
    71  	addcapacity        *int32
    72  	leakSpeed          *string
    73  	scenarioVersion    *string
    74  	scenarioHash       *string
    75  	simulated          *bool
    76  	uuid               *string
    77  	clearedFields      map[string]struct{}
    78  	owner              *int
    79  	clearedowner       bool
    80  	decisions          map[int]struct{}
    81  	removeddecisions   map[int]struct{}
    82  	cleareddecisions   bool
    83  	events             map[int]struct{}
    84  	removedevents      map[int]struct{}
    85  	clearedevents      bool
    86  	metas              map[int]struct{}
    87  	removedmetas       map[int]struct{}
    88  	clearedmetas       bool
    89  	done               bool
    90  	oldValue           func(context.Context) (*Alert, error)
    91  	predicates         []predicate.Alert
    92  }
    93  
    94  var _ ent.Mutation = (*AlertMutation)(nil)
    95  
    96  // alertOption allows management of the mutation configuration using functional options.
    97  type alertOption func(*AlertMutation)
    98  
    99  // newAlertMutation creates new mutation for the Alert entity.
   100  func newAlertMutation(c config, op Op, opts ...alertOption) *AlertMutation {
   101  	m := &AlertMutation{
   102  		config:        c,
   103  		op:            op,
   104  		typ:           TypeAlert,
   105  		clearedFields: make(map[string]struct{}),
   106  	}
   107  	for _, opt := range opts {
   108  		opt(m)
   109  	}
   110  	return m
   111  }
   112  
   113  // withAlertID sets the ID field of the mutation.
   114  func withAlertID(id int) alertOption {
   115  	return func(m *AlertMutation) {
   116  		var (
   117  			err   error
   118  			once  sync.Once
   119  			value *Alert
   120  		)
   121  		m.oldValue = func(ctx context.Context) (*Alert, error) {
   122  			once.Do(func() {
   123  				if m.done {
   124  					err = errors.New("querying old values post mutation is not allowed")
   125  				} else {
   126  					value, err = m.Client().Alert.Get(ctx, id)
   127  				}
   128  			})
   129  			return value, err
   130  		}
   131  		m.id = &id
   132  	}
   133  }
   134  
   135  // withAlert sets the old Alert of the mutation.
   136  func withAlert(node *Alert) alertOption {
   137  	return func(m *AlertMutation) {
   138  		m.oldValue = func(context.Context) (*Alert, error) {
   139  			return node, nil
   140  		}
   141  		m.id = &node.ID
   142  	}
   143  }
   144  
   145  // Client returns a new `ent.Client` from the mutation. If the mutation was
   146  // executed in a transaction (ent.Tx), a transactional client is returned.
   147  func (m AlertMutation) Client() *Client {
   148  	client := &Client{config: m.config}
   149  	client.init()
   150  	return client
   151  }
   152  
   153  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
   154  // it returns an error otherwise.
   155  func (m AlertMutation) Tx() (*Tx, error) {
   156  	if _, ok := m.driver.(*txDriver); !ok {
   157  		return nil, errors.New("ent: mutation is not running in a transaction")
   158  	}
   159  	tx := &Tx{config: m.config}
   160  	tx.init()
   161  	return tx, nil
   162  }
   163  
   164  // ID returns the ID value in the mutation. Note that the ID is only available
   165  // if it was provided to the builder or after it was returned from the database.
   166  func (m *AlertMutation) ID() (id int, exists bool) {
   167  	if m.id == nil {
   168  		return
   169  	}
   170  	return *m.id, true
   171  }
   172  
   173  // IDs queries the database and returns the entity ids that match the mutation's predicate.
   174  // That means, if the mutation is applied within a transaction with an isolation level such
   175  // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
   176  // or updated by the mutation.
   177  func (m *AlertMutation) IDs(ctx context.Context) ([]int, error) {
   178  	switch {
   179  	case m.op.Is(OpUpdateOne | OpDeleteOne):
   180  		id, exists := m.ID()
   181  		if exists {
   182  			return []int{id}, nil
   183  		}
   184  		fallthrough
   185  	case m.op.Is(OpUpdate | OpDelete):
   186  		return m.Client().Alert.Query().Where(m.predicates...).IDs(ctx)
   187  	default:
   188  		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
   189  	}
   190  }
   191  
   192  // SetCreatedAt sets the "created_at" field.
   193  func (m *AlertMutation) SetCreatedAt(t time.Time) {
   194  	m.created_at = &t
   195  }
   196  
   197  // CreatedAt returns the value of the "created_at" field in the mutation.
   198  func (m *AlertMutation) CreatedAt() (r time.Time, exists bool) {
   199  	v := m.created_at
   200  	if v == nil {
   201  		return
   202  	}
   203  	return *v, true
   204  }
   205  
   206  // OldCreatedAt returns the old "created_at" field's value of the Alert entity.
   207  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   208  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   209  func (m *AlertMutation) OldCreatedAt(ctx context.Context) (v *time.Time, err error) {
   210  	if !m.op.Is(OpUpdateOne) {
   211  		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
   212  	}
   213  	if m.id == nil || m.oldValue == nil {
   214  		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
   215  	}
   216  	oldValue, err := m.oldValue(ctx)
   217  	if err != nil {
   218  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
   219  	}
   220  	return oldValue.CreatedAt, nil
   221  }
   222  
   223  // ClearCreatedAt clears the value of the "created_at" field.
   224  func (m *AlertMutation) ClearCreatedAt() {
   225  	m.created_at = nil
   226  	m.clearedFields[alert.FieldCreatedAt] = struct{}{}
   227  }
   228  
   229  // CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
   230  func (m *AlertMutation) CreatedAtCleared() bool {
   231  	_, ok := m.clearedFields[alert.FieldCreatedAt]
   232  	return ok
   233  }
   234  
   235  // ResetCreatedAt resets all changes to the "created_at" field.
   236  func (m *AlertMutation) ResetCreatedAt() {
   237  	m.created_at = nil
   238  	delete(m.clearedFields, alert.FieldCreatedAt)
   239  }
   240  
   241  // SetUpdatedAt sets the "updated_at" field.
   242  func (m *AlertMutation) SetUpdatedAt(t time.Time) {
   243  	m.updated_at = &t
   244  }
   245  
   246  // UpdatedAt returns the value of the "updated_at" field in the mutation.
   247  func (m *AlertMutation) UpdatedAt() (r time.Time, exists bool) {
   248  	v := m.updated_at
   249  	if v == nil {
   250  		return
   251  	}
   252  	return *v, true
   253  }
   254  
   255  // OldUpdatedAt returns the old "updated_at" field's value of the Alert entity.
   256  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   257  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   258  func (m *AlertMutation) OldUpdatedAt(ctx context.Context) (v *time.Time, err error) {
   259  	if !m.op.Is(OpUpdateOne) {
   260  		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
   261  	}
   262  	if m.id == nil || m.oldValue == nil {
   263  		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
   264  	}
   265  	oldValue, err := m.oldValue(ctx)
   266  	if err != nil {
   267  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
   268  	}
   269  	return oldValue.UpdatedAt, nil
   270  }
   271  
   272  // ClearUpdatedAt clears the value of the "updated_at" field.
   273  func (m *AlertMutation) ClearUpdatedAt() {
   274  	m.updated_at = nil
   275  	m.clearedFields[alert.FieldUpdatedAt] = struct{}{}
   276  }
   277  
   278  // UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
   279  func (m *AlertMutation) UpdatedAtCleared() bool {
   280  	_, ok := m.clearedFields[alert.FieldUpdatedAt]
   281  	return ok
   282  }
   283  
   284  // ResetUpdatedAt resets all changes to the "updated_at" field.
   285  func (m *AlertMutation) ResetUpdatedAt() {
   286  	m.updated_at = nil
   287  	delete(m.clearedFields, alert.FieldUpdatedAt)
   288  }
   289  
   290  // SetScenario sets the "scenario" field.
   291  func (m *AlertMutation) SetScenario(s string) {
   292  	m.scenario = &s
   293  }
   294  
   295  // Scenario returns the value of the "scenario" field in the mutation.
   296  func (m *AlertMutation) Scenario() (r string, exists bool) {
   297  	v := m.scenario
   298  	if v == nil {
   299  		return
   300  	}
   301  	return *v, true
   302  }
   303  
   304  // OldScenario returns the old "scenario" field's value of the Alert entity.
   305  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   306  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   307  func (m *AlertMutation) OldScenario(ctx context.Context) (v string, err error) {
   308  	if !m.op.Is(OpUpdateOne) {
   309  		return v, errors.New("OldScenario is only allowed on UpdateOne operations")
   310  	}
   311  	if m.id == nil || m.oldValue == nil {
   312  		return v, errors.New("OldScenario requires an ID field in the mutation")
   313  	}
   314  	oldValue, err := m.oldValue(ctx)
   315  	if err != nil {
   316  		return v, fmt.Errorf("querying old value for OldScenario: %w", err)
   317  	}
   318  	return oldValue.Scenario, nil
   319  }
   320  
   321  // ResetScenario resets all changes to the "scenario" field.
   322  func (m *AlertMutation) ResetScenario() {
   323  	m.scenario = nil
   324  }
   325  
   326  // SetBucketId sets the "bucketId" field.
   327  func (m *AlertMutation) SetBucketId(s string) {
   328  	m.bucketId = &s
   329  }
   330  
   331  // BucketId returns the value of the "bucketId" field in the mutation.
   332  func (m *AlertMutation) BucketId() (r string, exists bool) {
   333  	v := m.bucketId
   334  	if v == nil {
   335  		return
   336  	}
   337  	return *v, true
   338  }
   339  
   340  // OldBucketId returns the old "bucketId" field's value of the Alert entity.
   341  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   342  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   343  func (m *AlertMutation) OldBucketId(ctx context.Context) (v string, err error) {
   344  	if !m.op.Is(OpUpdateOne) {
   345  		return v, errors.New("OldBucketId is only allowed on UpdateOne operations")
   346  	}
   347  	if m.id == nil || m.oldValue == nil {
   348  		return v, errors.New("OldBucketId requires an ID field in the mutation")
   349  	}
   350  	oldValue, err := m.oldValue(ctx)
   351  	if err != nil {
   352  		return v, fmt.Errorf("querying old value for OldBucketId: %w", err)
   353  	}
   354  	return oldValue.BucketId, nil
   355  }
   356  
   357  // ClearBucketId clears the value of the "bucketId" field.
   358  func (m *AlertMutation) ClearBucketId() {
   359  	m.bucketId = nil
   360  	m.clearedFields[alert.FieldBucketId] = struct{}{}
   361  }
   362  
   363  // BucketIdCleared returns if the "bucketId" field was cleared in this mutation.
   364  func (m *AlertMutation) BucketIdCleared() bool {
   365  	_, ok := m.clearedFields[alert.FieldBucketId]
   366  	return ok
   367  }
   368  
   369  // ResetBucketId resets all changes to the "bucketId" field.
   370  func (m *AlertMutation) ResetBucketId() {
   371  	m.bucketId = nil
   372  	delete(m.clearedFields, alert.FieldBucketId)
   373  }
   374  
   375  // SetMessage sets the "message" field.
   376  func (m *AlertMutation) SetMessage(s string) {
   377  	m.message = &s
   378  }
   379  
   380  // Message returns the value of the "message" field in the mutation.
   381  func (m *AlertMutation) Message() (r string, exists bool) {
   382  	v := m.message
   383  	if v == nil {
   384  		return
   385  	}
   386  	return *v, true
   387  }
   388  
   389  // OldMessage returns the old "message" field's value of the Alert entity.
   390  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   391  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   392  func (m *AlertMutation) OldMessage(ctx context.Context) (v string, err error) {
   393  	if !m.op.Is(OpUpdateOne) {
   394  		return v, errors.New("OldMessage is only allowed on UpdateOne operations")
   395  	}
   396  	if m.id == nil || m.oldValue == nil {
   397  		return v, errors.New("OldMessage requires an ID field in the mutation")
   398  	}
   399  	oldValue, err := m.oldValue(ctx)
   400  	if err != nil {
   401  		return v, fmt.Errorf("querying old value for OldMessage: %w", err)
   402  	}
   403  	return oldValue.Message, nil
   404  }
   405  
   406  // ClearMessage clears the value of the "message" field.
   407  func (m *AlertMutation) ClearMessage() {
   408  	m.message = nil
   409  	m.clearedFields[alert.FieldMessage] = struct{}{}
   410  }
   411  
   412  // MessageCleared returns if the "message" field was cleared in this mutation.
   413  func (m *AlertMutation) MessageCleared() bool {
   414  	_, ok := m.clearedFields[alert.FieldMessage]
   415  	return ok
   416  }
   417  
   418  // ResetMessage resets all changes to the "message" field.
   419  func (m *AlertMutation) ResetMessage() {
   420  	m.message = nil
   421  	delete(m.clearedFields, alert.FieldMessage)
   422  }
   423  
   424  // SetEventsCount sets the "eventsCount" field.
   425  func (m *AlertMutation) SetEventsCount(i int32) {
   426  	m.eventsCount = &i
   427  	m.addeventsCount = nil
   428  }
   429  
   430  // EventsCount returns the value of the "eventsCount" field in the mutation.
   431  func (m *AlertMutation) EventsCount() (r int32, exists bool) {
   432  	v := m.eventsCount
   433  	if v == nil {
   434  		return
   435  	}
   436  	return *v, true
   437  }
   438  
   439  // OldEventsCount returns the old "eventsCount" field's value of the Alert entity.
   440  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   441  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   442  func (m *AlertMutation) OldEventsCount(ctx context.Context) (v int32, err error) {
   443  	if !m.op.Is(OpUpdateOne) {
   444  		return v, errors.New("OldEventsCount is only allowed on UpdateOne operations")
   445  	}
   446  	if m.id == nil || m.oldValue == nil {
   447  		return v, errors.New("OldEventsCount requires an ID field in the mutation")
   448  	}
   449  	oldValue, err := m.oldValue(ctx)
   450  	if err != nil {
   451  		return v, fmt.Errorf("querying old value for OldEventsCount: %w", err)
   452  	}
   453  	return oldValue.EventsCount, nil
   454  }
   455  
   456  // AddEventsCount adds i to the "eventsCount" field.
   457  func (m *AlertMutation) AddEventsCount(i int32) {
   458  	if m.addeventsCount != nil {
   459  		*m.addeventsCount += i
   460  	} else {
   461  		m.addeventsCount = &i
   462  	}
   463  }
   464  
   465  // AddedEventsCount returns the value that was added to the "eventsCount" field in this mutation.
   466  func (m *AlertMutation) AddedEventsCount() (r int32, exists bool) {
   467  	v := m.addeventsCount
   468  	if v == nil {
   469  		return
   470  	}
   471  	return *v, true
   472  }
   473  
   474  // ClearEventsCount clears the value of the "eventsCount" field.
   475  func (m *AlertMutation) ClearEventsCount() {
   476  	m.eventsCount = nil
   477  	m.addeventsCount = nil
   478  	m.clearedFields[alert.FieldEventsCount] = struct{}{}
   479  }
   480  
   481  // EventsCountCleared returns if the "eventsCount" field was cleared in this mutation.
   482  func (m *AlertMutation) EventsCountCleared() bool {
   483  	_, ok := m.clearedFields[alert.FieldEventsCount]
   484  	return ok
   485  }
   486  
   487  // ResetEventsCount resets all changes to the "eventsCount" field.
   488  func (m *AlertMutation) ResetEventsCount() {
   489  	m.eventsCount = nil
   490  	m.addeventsCount = nil
   491  	delete(m.clearedFields, alert.FieldEventsCount)
   492  }
   493  
   494  // SetStartedAt sets the "startedAt" field.
   495  func (m *AlertMutation) SetStartedAt(t time.Time) {
   496  	m.startedAt = &t
   497  }
   498  
   499  // StartedAt returns the value of the "startedAt" field in the mutation.
   500  func (m *AlertMutation) StartedAt() (r time.Time, exists bool) {
   501  	v := m.startedAt
   502  	if v == nil {
   503  		return
   504  	}
   505  	return *v, true
   506  }
   507  
   508  // OldStartedAt returns the old "startedAt" field's value of the Alert entity.
   509  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   510  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   511  func (m *AlertMutation) OldStartedAt(ctx context.Context) (v time.Time, err error) {
   512  	if !m.op.Is(OpUpdateOne) {
   513  		return v, errors.New("OldStartedAt is only allowed on UpdateOne operations")
   514  	}
   515  	if m.id == nil || m.oldValue == nil {
   516  		return v, errors.New("OldStartedAt requires an ID field in the mutation")
   517  	}
   518  	oldValue, err := m.oldValue(ctx)
   519  	if err != nil {
   520  		return v, fmt.Errorf("querying old value for OldStartedAt: %w", err)
   521  	}
   522  	return oldValue.StartedAt, nil
   523  }
   524  
   525  // ClearStartedAt clears the value of the "startedAt" field.
   526  func (m *AlertMutation) ClearStartedAt() {
   527  	m.startedAt = nil
   528  	m.clearedFields[alert.FieldStartedAt] = struct{}{}
   529  }
   530  
   531  // StartedAtCleared returns if the "startedAt" field was cleared in this mutation.
   532  func (m *AlertMutation) StartedAtCleared() bool {
   533  	_, ok := m.clearedFields[alert.FieldStartedAt]
   534  	return ok
   535  }
   536  
   537  // ResetStartedAt resets all changes to the "startedAt" field.
   538  func (m *AlertMutation) ResetStartedAt() {
   539  	m.startedAt = nil
   540  	delete(m.clearedFields, alert.FieldStartedAt)
   541  }
   542  
   543  // SetStoppedAt sets the "stoppedAt" field.
   544  func (m *AlertMutation) SetStoppedAt(t time.Time) {
   545  	m.stoppedAt = &t
   546  }
   547  
   548  // StoppedAt returns the value of the "stoppedAt" field in the mutation.
   549  func (m *AlertMutation) StoppedAt() (r time.Time, exists bool) {
   550  	v := m.stoppedAt
   551  	if v == nil {
   552  		return
   553  	}
   554  	return *v, true
   555  }
   556  
   557  // OldStoppedAt returns the old "stoppedAt" field's value of the Alert entity.
   558  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   559  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   560  func (m *AlertMutation) OldStoppedAt(ctx context.Context) (v time.Time, err error) {
   561  	if !m.op.Is(OpUpdateOne) {
   562  		return v, errors.New("OldStoppedAt is only allowed on UpdateOne operations")
   563  	}
   564  	if m.id == nil || m.oldValue == nil {
   565  		return v, errors.New("OldStoppedAt requires an ID field in the mutation")
   566  	}
   567  	oldValue, err := m.oldValue(ctx)
   568  	if err != nil {
   569  		return v, fmt.Errorf("querying old value for OldStoppedAt: %w", err)
   570  	}
   571  	return oldValue.StoppedAt, nil
   572  }
   573  
   574  // ClearStoppedAt clears the value of the "stoppedAt" field.
   575  func (m *AlertMutation) ClearStoppedAt() {
   576  	m.stoppedAt = nil
   577  	m.clearedFields[alert.FieldStoppedAt] = struct{}{}
   578  }
   579  
   580  // StoppedAtCleared returns if the "stoppedAt" field was cleared in this mutation.
   581  func (m *AlertMutation) StoppedAtCleared() bool {
   582  	_, ok := m.clearedFields[alert.FieldStoppedAt]
   583  	return ok
   584  }
   585  
   586  // ResetStoppedAt resets all changes to the "stoppedAt" field.
   587  func (m *AlertMutation) ResetStoppedAt() {
   588  	m.stoppedAt = nil
   589  	delete(m.clearedFields, alert.FieldStoppedAt)
   590  }
   591  
   592  // SetSourceIp sets the "sourceIp" field.
   593  func (m *AlertMutation) SetSourceIp(s string) {
   594  	m.sourceIp = &s
   595  }
   596  
   597  // SourceIp returns the value of the "sourceIp" field in the mutation.
   598  func (m *AlertMutation) SourceIp() (r string, exists bool) {
   599  	v := m.sourceIp
   600  	if v == nil {
   601  		return
   602  	}
   603  	return *v, true
   604  }
   605  
   606  // OldSourceIp returns the old "sourceIp" field's value of the Alert entity.
   607  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   608  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   609  func (m *AlertMutation) OldSourceIp(ctx context.Context) (v string, err error) {
   610  	if !m.op.Is(OpUpdateOne) {
   611  		return v, errors.New("OldSourceIp is only allowed on UpdateOne operations")
   612  	}
   613  	if m.id == nil || m.oldValue == nil {
   614  		return v, errors.New("OldSourceIp requires an ID field in the mutation")
   615  	}
   616  	oldValue, err := m.oldValue(ctx)
   617  	if err != nil {
   618  		return v, fmt.Errorf("querying old value for OldSourceIp: %w", err)
   619  	}
   620  	return oldValue.SourceIp, nil
   621  }
   622  
   623  // ClearSourceIp clears the value of the "sourceIp" field.
   624  func (m *AlertMutation) ClearSourceIp() {
   625  	m.sourceIp = nil
   626  	m.clearedFields[alert.FieldSourceIp] = struct{}{}
   627  }
   628  
   629  // SourceIpCleared returns if the "sourceIp" field was cleared in this mutation.
   630  func (m *AlertMutation) SourceIpCleared() bool {
   631  	_, ok := m.clearedFields[alert.FieldSourceIp]
   632  	return ok
   633  }
   634  
   635  // ResetSourceIp resets all changes to the "sourceIp" field.
   636  func (m *AlertMutation) ResetSourceIp() {
   637  	m.sourceIp = nil
   638  	delete(m.clearedFields, alert.FieldSourceIp)
   639  }
   640  
   641  // SetSourceRange sets the "sourceRange" field.
   642  func (m *AlertMutation) SetSourceRange(s string) {
   643  	m.sourceRange = &s
   644  }
   645  
   646  // SourceRange returns the value of the "sourceRange" field in the mutation.
   647  func (m *AlertMutation) SourceRange() (r string, exists bool) {
   648  	v := m.sourceRange
   649  	if v == nil {
   650  		return
   651  	}
   652  	return *v, true
   653  }
   654  
   655  // OldSourceRange returns the old "sourceRange" field's value of the Alert entity.
   656  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   657  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   658  func (m *AlertMutation) OldSourceRange(ctx context.Context) (v string, err error) {
   659  	if !m.op.Is(OpUpdateOne) {
   660  		return v, errors.New("OldSourceRange is only allowed on UpdateOne operations")
   661  	}
   662  	if m.id == nil || m.oldValue == nil {
   663  		return v, errors.New("OldSourceRange requires an ID field in the mutation")
   664  	}
   665  	oldValue, err := m.oldValue(ctx)
   666  	if err != nil {
   667  		return v, fmt.Errorf("querying old value for OldSourceRange: %w", err)
   668  	}
   669  	return oldValue.SourceRange, nil
   670  }
   671  
   672  // ClearSourceRange clears the value of the "sourceRange" field.
   673  func (m *AlertMutation) ClearSourceRange() {
   674  	m.sourceRange = nil
   675  	m.clearedFields[alert.FieldSourceRange] = struct{}{}
   676  }
   677  
   678  // SourceRangeCleared returns if the "sourceRange" field was cleared in this mutation.
   679  func (m *AlertMutation) SourceRangeCleared() bool {
   680  	_, ok := m.clearedFields[alert.FieldSourceRange]
   681  	return ok
   682  }
   683  
   684  // ResetSourceRange resets all changes to the "sourceRange" field.
   685  func (m *AlertMutation) ResetSourceRange() {
   686  	m.sourceRange = nil
   687  	delete(m.clearedFields, alert.FieldSourceRange)
   688  }
   689  
   690  // SetSourceAsNumber sets the "sourceAsNumber" field.
   691  func (m *AlertMutation) SetSourceAsNumber(s string) {
   692  	m.sourceAsNumber = &s
   693  }
   694  
   695  // SourceAsNumber returns the value of the "sourceAsNumber" field in the mutation.
   696  func (m *AlertMutation) SourceAsNumber() (r string, exists bool) {
   697  	v := m.sourceAsNumber
   698  	if v == nil {
   699  		return
   700  	}
   701  	return *v, true
   702  }
   703  
   704  // OldSourceAsNumber returns the old "sourceAsNumber" field's value of the Alert entity.
   705  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   706  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   707  func (m *AlertMutation) OldSourceAsNumber(ctx context.Context) (v string, err error) {
   708  	if !m.op.Is(OpUpdateOne) {
   709  		return v, errors.New("OldSourceAsNumber is only allowed on UpdateOne operations")
   710  	}
   711  	if m.id == nil || m.oldValue == nil {
   712  		return v, errors.New("OldSourceAsNumber requires an ID field in the mutation")
   713  	}
   714  	oldValue, err := m.oldValue(ctx)
   715  	if err != nil {
   716  		return v, fmt.Errorf("querying old value for OldSourceAsNumber: %w", err)
   717  	}
   718  	return oldValue.SourceAsNumber, nil
   719  }
   720  
   721  // ClearSourceAsNumber clears the value of the "sourceAsNumber" field.
   722  func (m *AlertMutation) ClearSourceAsNumber() {
   723  	m.sourceAsNumber = nil
   724  	m.clearedFields[alert.FieldSourceAsNumber] = struct{}{}
   725  }
   726  
   727  // SourceAsNumberCleared returns if the "sourceAsNumber" field was cleared in this mutation.
   728  func (m *AlertMutation) SourceAsNumberCleared() bool {
   729  	_, ok := m.clearedFields[alert.FieldSourceAsNumber]
   730  	return ok
   731  }
   732  
   733  // ResetSourceAsNumber resets all changes to the "sourceAsNumber" field.
   734  func (m *AlertMutation) ResetSourceAsNumber() {
   735  	m.sourceAsNumber = nil
   736  	delete(m.clearedFields, alert.FieldSourceAsNumber)
   737  }
   738  
   739  // SetSourceAsName sets the "sourceAsName" field.
   740  func (m *AlertMutation) SetSourceAsName(s string) {
   741  	m.sourceAsName = &s
   742  }
   743  
   744  // SourceAsName returns the value of the "sourceAsName" field in the mutation.
   745  func (m *AlertMutation) SourceAsName() (r string, exists bool) {
   746  	v := m.sourceAsName
   747  	if v == nil {
   748  		return
   749  	}
   750  	return *v, true
   751  }
   752  
   753  // OldSourceAsName returns the old "sourceAsName" field's value of the Alert entity.
   754  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   755  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   756  func (m *AlertMutation) OldSourceAsName(ctx context.Context) (v string, err error) {
   757  	if !m.op.Is(OpUpdateOne) {
   758  		return v, errors.New("OldSourceAsName is only allowed on UpdateOne operations")
   759  	}
   760  	if m.id == nil || m.oldValue == nil {
   761  		return v, errors.New("OldSourceAsName requires an ID field in the mutation")
   762  	}
   763  	oldValue, err := m.oldValue(ctx)
   764  	if err != nil {
   765  		return v, fmt.Errorf("querying old value for OldSourceAsName: %w", err)
   766  	}
   767  	return oldValue.SourceAsName, nil
   768  }
   769  
   770  // ClearSourceAsName clears the value of the "sourceAsName" field.
   771  func (m *AlertMutation) ClearSourceAsName() {
   772  	m.sourceAsName = nil
   773  	m.clearedFields[alert.FieldSourceAsName] = struct{}{}
   774  }
   775  
   776  // SourceAsNameCleared returns if the "sourceAsName" field was cleared in this mutation.
   777  func (m *AlertMutation) SourceAsNameCleared() bool {
   778  	_, ok := m.clearedFields[alert.FieldSourceAsName]
   779  	return ok
   780  }
   781  
   782  // ResetSourceAsName resets all changes to the "sourceAsName" field.
   783  func (m *AlertMutation) ResetSourceAsName() {
   784  	m.sourceAsName = nil
   785  	delete(m.clearedFields, alert.FieldSourceAsName)
   786  }
   787  
   788  // SetSourceCountry sets the "sourceCountry" field.
   789  func (m *AlertMutation) SetSourceCountry(s string) {
   790  	m.sourceCountry = &s
   791  }
   792  
   793  // SourceCountry returns the value of the "sourceCountry" field in the mutation.
   794  func (m *AlertMutation) SourceCountry() (r string, exists bool) {
   795  	v := m.sourceCountry
   796  	if v == nil {
   797  		return
   798  	}
   799  	return *v, true
   800  }
   801  
   802  // OldSourceCountry returns the old "sourceCountry" field's value of the Alert entity.
   803  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   804  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   805  func (m *AlertMutation) OldSourceCountry(ctx context.Context) (v string, err error) {
   806  	if !m.op.Is(OpUpdateOne) {
   807  		return v, errors.New("OldSourceCountry is only allowed on UpdateOne operations")
   808  	}
   809  	if m.id == nil || m.oldValue == nil {
   810  		return v, errors.New("OldSourceCountry requires an ID field in the mutation")
   811  	}
   812  	oldValue, err := m.oldValue(ctx)
   813  	if err != nil {
   814  		return v, fmt.Errorf("querying old value for OldSourceCountry: %w", err)
   815  	}
   816  	return oldValue.SourceCountry, nil
   817  }
   818  
   819  // ClearSourceCountry clears the value of the "sourceCountry" field.
   820  func (m *AlertMutation) ClearSourceCountry() {
   821  	m.sourceCountry = nil
   822  	m.clearedFields[alert.FieldSourceCountry] = struct{}{}
   823  }
   824  
   825  // SourceCountryCleared returns if the "sourceCountry" field was cleared in this mutation.
   826  func (m *AlertMutation) SourceCountryCleared() bool {
   827  	_, ok := m.clearedFields[alert.FieldSourceCountry]
   828  	return ok
   829  }
   830  
   831  // ResetSourceCountry resets all changes to the "sourceCountry" field.
   832  func (m *AlertMutation) ResetSourceCountry() {
   833  	m.sourceCountry = nil
   834  	delete(m.clearedFields, alert.FieldSourceCountry)
   835  }
   836  
   837  // SetSourceLatitude sets the "sourceLatitude" field.
   838  func (m *AlertMutation) SetSourceLatitude(f float32) {
   839  	m.sourceLatitude = &f
   840  	m.addsourceLatitude = nil
   841  }
   842  
   843  // SourceLatitude returns the value of the "sourceLatitude" field in the mutation.
   844  func (m *AlertMutation) SourceLatitude() (r float32, exists bool) {
   845  	v := m.sourceLatitude
   846  	if v == nil {
   847  		return
   848  	}
   849  	return *v, true
   850  }
   851  
   852  // OldSourceLatitude returns the old "sourceLatitude" field's value of the Alert entity.
   853  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   854  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   855  func (m *AlertMutation) OldSourceLatitude(ctx context.Context) (v float32, err error) {
   856  	if !m.op.Is(OpUpdateOne) {
   857  		return v, errors.New("OldSourceLatitude is only allowed on UpdateOne operations")
   858  	}
   859  	if m.id == nil || m.oldValue == nil {
   860  		return v, errors.New("OldSourceLatitude requires an ID field in the mutation")
   861  	}
   862  	oldValue, err := m.oldValue(ctx)
   863  	if err != nil {
   864  		return v, fmt.Errorf("querying old value for OldSourceLatitude: %w", err)
   865  	}
   866  	return oldValue.SourceLatitude, nil
   867  }
   868  
   869  // AddSourceLatitude adds f to the "sourceLatitude" field.
   870  func (m *AlertMutation) AddSourceLatitude(f float32) {
   871  	if m.addsourceLatitude != nil {
   872  		*m.addsourceLatitude += f
   873  	} else {
   874  		m.addsourceLatitude = &f
   875  	}
   876  }
   877  
   878  // AddedSourceLatitude returns the value that was added to the "sourceLatitude" field in this mutation.
   879  func (m *AlertMutation) AddedSourceLatitude() (r float32, exists bool) {
   880  	v := m.addsourceLatitude
   881  	if v == nil {
   882  		return
   883  	}
   884  	return *v, true
   885  }
   886  
   887  // ClearSourceLatitude clears the value of the "sourceLatitude" field.
   888  func (m *AlertMutation) ClearSourceLatitude() {
   889  	m.sourceLatitude = nil
   890  	m.addsourceLatitude = nil
   891  	m.clearedFields[alert.FieldSourceLatitude] = struct{}{}
   892  }
   893  
   894  // SourceLatitudeCleared returns if the "sourceLatitude" field was cleared in this mutation.
   895  func (m *AlertMutation) SourceLatitudeCleared() bool {
   896  	_, ok := m.clearedFields[alert.FieldSourceLatitude]
   897  	return ok
   898  }
   899  
   900  // ResetSourceLatitude resets all changes to the "sourceLatitude" field.
   901  func (m *AlertMutation) ResetSourceLatitude() {
   902  	m.sourceLatitude = nil
   903  	m.addsourceLatitude = nil
   904  	delete(m.clearedFields, alert.FieldSourceLatitude)
   905  }
   906  
   907  // SetSourceLongitude sets the "sourceLongitude" field.
   908  func (m *AlertMutation) SetSourceLongitude(f float32) {
   909  	m.sourceLongitude = &f
   910  	m.addsourceLongitude = nil
   911  }
   912  
   913  // SourceLongitude returns the value of the "sourceLongitude" field in the mutation.
   914  func (m *AlertMutation) SourceLongitude() (r float32, exists bool) {
   915  	v := m.sourceLongitude
   916  	if v == nil {
   917  		return
   918  	}
   919  	return *v, true
   920  }
   921  
   922  // OldSourceLongitude returns the old "sourceLongitude" field's value of the Alert entity.
   923  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   924  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   925  func (m *AlertMutation) OldSourceLongitude(ctx context.Context) (v float32, err error) {
   926  	if !m.op.Is(OpUpdateOne) {
   927  		return v, errors.New("OldSourceLongitude is only allowed on UpdateOne operations")
   928  	}
   929  	if m.id == nil || m.oldValue == nil {
   930  		return v, errors.New("OldSourceLongitude requires an ID field in the mutation")
   931  	}
   932  	oldValue, err := m.oldValue(ctx)
   933  	if err != nil {
   934  		return v, fmt.Errorf("querying old value for OldSourceLongitude: %w", err)
   935  	}
   936  	return oldValue.SourceLongitude, nil
   937  }
   938  
   939  // AddSourceLongitude adds f to the "sourceLongitude" field.
   940  func (m *AlertMutation) AddSourceLongitude(f float32) {
   941  	if m.addsourceLongitude != nil {
   942  		*m.addsourceLongitude += f
   943  	} else {
   944  		m.addsourceLongitude = &f
   945  	}
   946  }
   947  
   948  // AddedSourceLongitude returns the value that was added to the "sourceLongitude" field in this mutation.
   949  func (m *AlertMutation) AddedSourceLongitude() (r float32, exists bool) {
   950  	v := m.addsourceLongitude
   951  	if v == nil {
   952  		return
   953  	}
   954  	return *v, true
   955  }
   956  
   957  // ClearSourceLongitude clears the value of the "sourceLongitude" field.
   958  func (m *AlertMutation) ClearSourceLongitude() {
   959  	m.sourceLongitude = nil
   960  	m.addsourceLongitude = nil
   961  	m.clearedFields[alert.FieldSourceLongitude] = struct{}{}
   962  }
   963  
   964  // SourceLongitudeCleared returns if the "sourceLongitude" field was cleared in this mutation.
   965  func (m *AlertMutation) SourceLongitudeCleared() bool {
   966  	_, ok := m.clearedFields[alert.FieldSourceLongitude]
   967  	return ok
   968  }
   969  
   970  // ResetSourceLongitude resets all changes to the "sourceLongitude" field.
   971  func (m *AlertMutation) ResetSourceLongitude() {
   972  	m.sourceLongitude = nil
   973  	m.addsourceLongitude = nil
   974  	delete(m.clearedFields, alert.FieldSourceLongitude)
   975  }
   976  
   977  // SetSourceScope sets the "sourceScope" field.
   978  func (m *AlertMutation) SetSourceScope(s string) {
   979  	m.sourceScope = &s
   980  }
   981  
   982  // SourceScope returns the value of the "sourceScope" field in the mutation.
   983  func (m *AlertMutation) SourceScope() (r string, exists bool) {
   984  	v := m.sourceScope
   985  	if v == nil {
   986  		return
   987  	}
   988  	return *v, true
   989  }
   990  
   991  // OldSourceScope returns the old "sourceScope" field's value of the Alert entity.
   992  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
   993  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
   994  func (m *AlertMutation) OldSourceScope(ctx context.Context) (v string, err error) {
   995  	if !m.op.Is(OpUpdateOne) {
   996  		return v, errors.New("OldSourceScope is only allowed on UpdateOne operations")
   997  	}
   998  	if m.id == nil || m.oldValue == nil {
   999  		return v, errors.New("OldSourceScope requires an ID field in the mutation")
  1000  	}
  1001  	oldValue, err := m.oldValue(ctx)
  1002  	if err != nil {
  1003  		return v, fmt.Errorf("querying old value for OldSourceScope: %w", err)
  1004  	}
  1005  	return oldValue.SourceScope, nil
  1006  }
  1007  
  1008  // ClearSourceScope clears the value of the "sourceScope" field.
  1009  func (m *AlertMutation) ClearSourceScope() {
  1010  	m.sourceScope = nil
  1011  	m.clearedFields[alert.FieldSourceScope] = struct{}{}
  1012  }
  1013  
  1014  // SourceScopeCleared returns if the "sourceScope" field was cleared in this mutation.
  1015  func (m *AlertMutation) SourceScopeCleared() bool {
  1016  	_, ok := m.clearedFields[alert.FieldSourceScope]
  1017  	return ok
  1018  }
  1019  
  1020  // ResetSourceScope resets all changes to the "sourceScope" field.
  1021  func (m *AlertMutation) ResetSourceScope() {
  1022  	m.sourceScope = nil
  1023  	delete(m.clearedFields, alert.FieldSourceScope)
  1024  }
  1025  
  1026  // SetSourceValue sets the "sourceValue" field.
  1027  func (m *AlertMutation) SetSourceValue(s string) {
  1028  	m.sourceValue = &s
  1029  }
  1030  
  1031  // SourceValue returns the value of the "sourceValue" field in the mutation.
  1032  func (m *AlertMutation) SourceValue() (r string, exists bool) {
  1033  	v := m.sourceValue
  1034  	if v == nil {
  1035  		return
  1036  	}
  1037  	return *v, true
  1038  }
  1039  
  1040  // OldSourceValue returns the old "sourceValue" field's value of the Alert entity.
  1041  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1042  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1043  func (m *AlertMutation) OldSourceValue(ctx context.Context) (v string, err error) {
  1044  	if !m.op.Is(OpUpdateOne) {
  1045  		return v, errors.New("OldSourceValue is only allowed on UpdateOne operations")
  1046  	}
  1047  	if m.id == nil || m.oldValue == nil {
  1048  		return v, errors.New("OldSourceValue requires an ID field in the mutation")
  1049  	}
  1050  	oldValue, err := m.oldValue(ctx)
  1051  	if err != nil {
  1052  		return v, fmt.Errorf("querying old value for OldSourceValue: %w", err)
  1053  	}
  1054  	return oldValue.SourceValue, nil
  1055  }
  1056  
  1057  // ClearSourceValue clears the value of the "sourceValue" field.
  1058  func (m *AlertMutation) ClearSourceValue() {
  1059  	m.sourceValue = nil
  1060  	m.clearedFields[alert.FieldSourceValue] = struct{}{}
  1061  }
  1062  
  1063  // SourceValueCleared returns if the "sourceValue" field was cleared in this mutation.
  1064  func (m *AlertMutation) SourceValueCleared() bool {
  1065  	_, ok := m.clearedFields[alert.FieldSourceValue]
  1066  	return ok
  1067  }
  1068  
  1069  // ResetSourceValue resets all changes to the "sourceValue" field.
  1070  func (m *AlertMutation) ResetSourceValue() {
  1071  	m.sourceValue = nil
  1072  	delete(m.clearedFields, alert.FieldSourceValue)
  1073  }
  1074  
  1075  // SetCapacity sets the "capacity" field.
  1076  func (m *AlertMutation) SetCapacity(i int32) {
  1077  	m.capacity = &i
  1078  	m.addcapacity = nil
  1079  }
  1080  
  1081  // Capacity returns the value of the "capacity" field in the mutation.
  1082  func (m *AlertMutation) Capacity() (r int32, exists bool) {
  1083  	v := m.capacity
  1084  	if v == nil {
  1085  		return
  1086  	}
  1087  	return *v, true
  1088  }
  1089  
  1090  // OldCapacity returns the old "capacity" field's value of the Alert entity.
  1091  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1092  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1093  func (m *AlertMutation) OldCapacity(ctx context.Context) (v int32, err error) {
  1094  	if !m.op.Is(OpUpdateOne) {
  1095  		return v, errors.New("OldCapacity is only allowed on UpdateOne operations")
  1096  	}
  1097  	if m.id == nil || m.oldValue == nil {
  1098  		return v, errors.New("OldCapacity requires an ID field in the mutation")
  1099  	}
  1100  	oldValue, err := m.oldValue(ctx)
  1101  	if err != nil {
  1102  		return v, fmt.Errorf("querying old value for OldCapacity: %w", err)
  1103  	}
  1104  	return oldValue.Capacity, nil
  1105  }
  1106  
  1107  // AddCapacity adds i to the "capacity" field.
  1108  func (m *AlertMutation) AddCapacity(i int32) {
  1109  	if m.addcapacity != nil {
  1110  		*m.addcapacity += i
  1111  	} else {
  1112  		m.addcapacity = &i
  1113  	}
  1114  }
  1115  
  1116  // AddedCapacity returns the value that was added to the "capacity" field in this mutation.
  1117  func (m *AlertMutation) AddedCapacity() (r int32, exists bool) {
  1118  	v := m.addcapacity
  1119  	if v == nil {
  1120  		return
  1121  	}
  1122  	return *v, true
  1123  }
  1124  
  1125  // ClearCapacity clears the value of the "capacity" field.
  1126  func (m *AlertMutation) ClearCapacity() {
  1127  	m.capacity = nil
  1128  	m.addcapacity = nil
  1129  	m.clearedFields[alert.FieldCapacity] = struct{}{}
  1130  }
  1131  
  1132  // CapacityCleared returns if the "capacity" field was cleared in this mutation.
  1133  func (m *AlertMutation) CapacityCleared() bool {
  1134  	_, ok := m.clearedFields[alert.FieldCapacity]
  1135  	return ok
  1136  }
  1137  
  1138  // ResetCapacity resets all changes to the "capacity" field.
  1139  func (m *AlertMutation) ResetCapacity() {
  1140  	m.capacity = nil
  1141  	m.addcapacity = nil
  1142  	delete(m.clearedFields, alert.FieldCapacity)
  1143  }
  1144  
  1145  // SetLeakSpeed sets the "leakSpeed" field.
  1146  func (m *AlertMutation) SetLeakSpeed(s string) {
  1147  	m.leakSpeed = &s
  1148  }
  1149  
  1150  // LeakSpeed returns the value of the "leakSpeed" field in the mutation.
  1151  func (m *AlertMutation) LeakSpeed() (r string, exists bool) {
  1152  	v := m.leakSpeed
  1153  	if v == nil {
  1154  		return
  1155  	}
  1156  	return *v, true
  1157  }
  1158  
  1159  // OldLeakSpeed returns the old "leakSpeed" field's value of the Alert entity.
  1160  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1161  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1162  func (m *AlertMutation) OldLeakSpeed(ctx context.Context) (v string, err error) {
  1163  	if !m.op.Is(OpUpdateOne) {
  1164  		return v, errors.New("OldLeakSpeed is only allowed on UpdateOne operations")
  1165  	}
  1166  	if m.id == nil || m.oldValue == nil {
  1167  		return v, errors.New("OldLeakSpeed requires an ID field in the mutation")
  1168  	}
  1169  	oldValue, err := m.oldValue(ctx)
  1170  	if err != nil {
  1171  		return v, fmt.Errorf("querying old value for OldLeakSpeed: %w", err)
  1172  	}
  1173  	return oldValue.LeakSpeed, nil
  1174  }
  1175  
  1176  // ClearLeakSpeed clears the value of the "leakSpeed" field.
  1177  func (m *AlertMutation) ClearLeakSpeed() {
  1178  	m.leakSpeed = nil
  1179  	m.clearedFields[alert.FieldLeakSpeed] = struct{}{}
  1180  }
  1181  
  1182  // LeakSpeedCleared returns if the "leakSpeed" field was cleared in this mutation.
  1183  func (m *AlertMutation) LeakSpeedCleared() bool {
  1184  	_, ok := m.clearedFields[alert.FieldLeakSpeed]
  1185  	return ok
  1186  }
  1187  
  1188  // ResetLeakSpeed resets all changes to the "leakSpeed" field.
  1189  func (m *AlertMutation) ResetLeakSpeed() {
  1190  	m.leakSpeed = nil
  1191  	delete(m.clearedFields, alert.FieldLeakSpeed)
  1192  }
  1193  
  1194  // SetScenarioVersion sets the "scenarioVersion" field.
  1195  func (m *AlertMutation) SetScenarioVersion(s string) {
  1196  	m.scenarioVersion = &s
  1197  }
  1198  
  1199  // ScenarioVersion returns the value of the "scenarioVersion" field in the mutation.
  1200  func (m *AlertMutation) ScenarioVersion() (r string, exists bool) {
  1201  	v := m.scenarioVersion
  1202  	if v == nil {
  1203  		return
  1204  	}
  1205  	return *v, true
  1206  }
  1207  
  1208  // OldScenarioVersion returns the old "scenarioVersion" field's value of the Alert entity.
  1209  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1210  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1211  func (m *AlertMutation) OldScenarioVersion(ctx context.Context) (v string, err error) {
  1212  	if !m.op.Is(OpUpdateOne) {
  1213  		return v, errors.New("OldScenarioVersion is only allowed on UpdateOne operations")
  1214  	}
  1215  	if m.id == nil || m.oldValue == nil {
  1216  		return v, errors.New("OldScenarioVersion requires an ID field in the mutation")
  1217  	}
  1218  	oldValue, err := m.oldValue(ctx)
  1219  	if err != nil {
  1220  		return v, fmt.Errorf("querying old value for OldScenarioVersion: %w", err)
  1221  	}
  1222  	return oldValue.ScenarioVersion, nil
  1223  }
  1224  
  1225  // ClearScenarioVersion clears the value of the "scenarioVersion" field.
  1226  func (m *AlertMutation) ClearScenarioVersion() {
  1227  	m.scenarioVersion = nil
  1228  	m.clearedFields[alert.FieldScenarioVersion] = struct{}{}
  1229  }
  1230  
  1231  // ScenarioVersionCleared returns if the "scenarioVersion" field was cleared in this mutation.
  1232  func (m *AlertMutation) ScenarioVersionCleared() bool {
  1233  	_, ok := m.clearedFields[alert.FieldScenarioVersion]
  1234  	return ok
  1235  }
  1236  
  1237  // ResetScenarioVersion resets all changes to the "scenarioVersion" field.
  1238  func (m *AlertMutation) ResetScenarioVersion() {
  1239  	m.scenarioVersion = nil
  1240  	delete(m.clearedFields, alert.FieldScenarioVersion)
  1241  }
  1242  
  1243  // SetScenarioHash sets the "scenarioHash" field.
  1244  func (m *AlertMutation) SetScenarioHash(s string) {
  1245  	m.scenarioHash = &s
  1246  }
  1247  
  1248  // ScenarioHash returns the value of the "scenarioHash" field in the mutation.
  1249  func (m *AlertMutation) ScenarioHash() (r string, exists bool) {
  1250  	v := m.scenarioHash
  1251  	if v == nil {
  1252  		return
  1253  	}
  1254  	return *v, true
  1255  }
  1256  
  1257  // OldScenarioHash returns the old "scenarioHash" field's value of the Alert entity.
  1258  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1259  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1260  func (m *AlertMutation) OldScenarioHash(ctx context.Context) (v string, err error) {
  1261  	if !m.op.Is(OpUpdateOne) {
  1262  		return v, errors.New("OldScenarioHash is only allowed on UpdateOne operations")
  1263  	}
  1264  	if m.id == nil || m.oldValue == nil {
  1265  		return v, errors.New("OldScenarioHash requires an ID field in the mutation")
  1266  	}
  1267  	oldValue, err := m.oldValue(ctx)
  1268  	if err != nil {
  1269  		return v, fmt.Errorf("querying old value for OldScenarioHash: %w", err)
  1270  	}
  1271  	return oldValue.ScenarioHash, nil
  1272  }
  1273  
  1274  // ClearScenarioHash clears the value of the "scenarioHash" field.
  1275  func (m *AlertMutation) ClearScenarioHash() {
  1276  	m.scenarioHash = nil
  1277  	m.clearedFields[alert.FieldScenarioHash] = struct{}{}
  1278  }
  1279  
  1280  // ScenarioHashCleared returns if the "scenarioHash" field was cleared in this mutation.
  1281  func (m *AlertMutation) ScenarioHashCleared() bool {
  1282  	_, ok := m.clearedFields[alert.FieldScenarioHash]
  1283  	return ok
  1284  }
  1285  
  1286  // ResetScenarioHash resets all changes to the "scenarioHash" field.
  1287  func (m *AlertMutation) ResetScenarioHash() {
  1288  	m.scenarioHash = nil
  1289  	delete(m.clearedFields, alert.FieldScenarioHash)
  1290  }
  1291  
  1292  // SetSimulated sets the "simulated" field.
  1293  func (m *AlertMutation) SetSimulated(b bool) {
  1294  	m.simulated = &b
  1295  }
  1296  
  1297  // Simulated returns the value of the "simulated" field in the mutation.
  1298  func (m *AlertMutation) Simulated() (r bool, exists bool) {
  1299  	v := m.simulated
  1300  	if v == nil {
  1301  		return
  1302  	}
  1303  	return *v, true
  1304  }
  1305  
  1306  // OldSimulated returns the old "simulated" field's value of the Alert entity.
  1307  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1308  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1309  func (m *AlertMutation) OldSimulated(ctx context.Context) (v bool, err error) {
  1310  	if !m.op.Is(OpUpdateOne) {
  1311  		return v, errors.New("OldSimulated is only allowed on UpdateOne operations")
  1312  	}
  1313  	if m.id == nil || m.oldValue == nil {
  1314  		return v, errors.New("OldSimulated requires an ID field in the mutation")
  1315  	}
  1316  	oldValue, err := m.oldValue(ctx)
  1317  	if err != nil {
  1318  		return v, fmt.Errorf("querying old value for OldSimulated: %w", err)
  1319  	}
  1320  	return oldValue.Simulated, nil
  1321  }
  1322  
  1323  // ResetSimulated resets all changes to the "simulated" field.
  1324  func (m *AlertMutation) ResetSimulated() {
  1325  	m.simulated = nil
  1326  }
  1327  
  1328  // SetUUID sets the "uuid" field.
  1329  func (m *AlertMutation) SetUUID(s string) {
  1330  	m.uuid = &s
  1331  }
  1332  
  1333  // UUID returns the value of the "uuid" field in the mutation.
  1334  func (m *AlertMutation) UUID() (r string, exists bool) {
  1335  	v := m.uuid
  1336  	if v == nil {
  1337  		return
  1338  	}
  1339  	return *v, true
  1340  }
  1341  
  1342  // OldUUID returns the old "uuid" field's value of the Alert entity.
  1343  // If the Alert object wasn't provided to the builder, the object is fetched from the database.
  1344  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1345  func (m *AlertMutation) OldUUID(ctx context.Context) (v string, err error) {
  1346  	if !m.op.Is(OpUpdateOne) {
  1347  		return v, errors.New("OldUUID is only allowed on UpdateOne operations")
  1348  	}
  1349  	if m.id == nil || m.oldValue == nil {
  1350  		return v, errors.New("OldUUID requires an ID field in the mutation")
  1351  	}
  1352  	oldValue, err := m.oldValue(ctx)
  1353  	if err != nil {
  1354  		return v, fmt.Errorf("querying old value for OldUUID: %w", err)
  1355  	}
  1356  	return oldValue.UUID, nil
  1357  }
  1358  
  1359  // ClearUUID clears the value of the "uuid" field.
  1360  func (m *AlertMutation) ClearUUID() {
  1361  	m.uuid = nil
  1362  	m.clearedFields[alert.FieldUUID] = struct{}{}
  1363  }
  1364  
  1365  // UUIDCleared returns if the "uuid" field was cleared in this mutation.
  1366  func (m *AlertMutation) UUIDCleared() bool {
  1367  	_, ok := m.clearedFields[alert.FieldUUID]
  1368  	return ok
  1369  }
  1370  
  1371  // ResetUUID resets all changes to the "uuid" field.
  1372  func (m *AlertMutation) ResetUUID() {
  1373  	m.uuid = nil
  1374  	delete(m.clearedFields, alert.FieldUUID)
  1375  }
  1376  
  1377  // SetOwnerID sets the "owner" edge to the Machine entity by id.
  1378  func (m *AlertMutation) SetOwnerID(id int) {
  1379  	m.owner = &id
  1380  }
  1381  
  1382  // ClearOwner clears the "owner" edge to the Machine entity.
  1383  func (m *AlertMutation) ClearOwner() {
  1384  	m.clearedowner = true
  1385  }
  1386  
  1387  // OwnerCleared reports if the "owner" edge to the Machine entity was cleared.
  1388  func (m *AlertMutation) OwnerCleared() bool {
  1389  	return m.clearedowner
  1390  }
  1391  
  1392  // OwnerID returns the "owner" edge ID in the mutation.
  1393  func (m *AlertMutation) OwnerID() (id int, exists bool) {
  1394  	if m.owner != nil {
  1395  		return *m.owner, true
  1396  	}
  1397  	return
  1398  }
  1399  
  1400  // OwnerIDs returns the "owner" edge IDs in the mutation.
  1401  // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  1402  // OwnerID instead. It exists only for internal usage by the builders.
  1403  func (m *AlertMutation) OwnerIDs() (ids []int) {
  1404  	if id := m.owner; id != nil {
  1405  		ids = append(ids, *id)
  1406  	}
  1407  	return
  1408  }
  1409  
  1410  // ResetOwner resets all changes to the "owner" edge.
  1411  func (m *AlertMutation) ResetOwner() {
  1412  	m.owner = nil
  1413  	m.clearedowner = false
  1414  }
  1415  
  1416  // AddDecisionIDs adds the "decisions" edge to the Decision entity by ids.
  1417  func (m *AlertMutation) AddDecisionIDs(ids ...int) {
  1418  	if m.decisions == nil {
  1419  		m.decisions = make(map[int]struct{})
  1420  	}
  1421  	for i := range ids {
  1422  		m.decisions[ids[i]] = struct{}{}
  1423  	}
  1424  }
  1425  
  1426  // ClearDecisions clears the "decisions" edge to the Decision entity.
  1427  func (m *AlertMutation) ClearDecisions() {
  1428  	m.cleareddecisions = true
  1429  }
  1430  
  1431  // DecisionsCleared reports if the "decisions" edge to the Decision entity was cleared.
  1432  func (m *AlertMutation) DecisionsCleared() bool {
  1433  	return m.cleareddecisions
  1434  }
  1435  
  1436  // RemoveDecisionIDs removes the "decisions" edge to the Decision entity by IDs.
  1437  func (m *AlertMutation) RemoveDecisionIDs(ids ...int) {
  1438  	if m.removeddecisions == nil {
  1439  		m.removeddecisions = make(map[int]struct{})
  1440  	}
  1441  	for i := range ids {
  1442  		delete(m.decisions, ids[i])
  1443  		m.removeddecisions[ids[i]] = struct{}{}
  1444  	}
  1445  }
  1446  
  1447  // RemovedDecisions returns the removed IDs of the "decisions" edge to the Decision entity.
  1448  func (m *AlertMutation) RemovedDecisionsIDs() (ids []int) {
  1449  	for id := range m.removeddecisions {
  1450  		ids = append(ids, id)
  1451  	}
  1452  	return
  1453  }
  1454  
  1455  // DecisionsIDs returns the "decisions" edge IDs in the mutation.
  1456  func (m *AlertMutation) DecisionsIDs() (ids []int) {
  1457  	for id := range m.decisions {
  1458  		ids = append(ids, id)
  1459  	}
  1460  	return
  1461  }
  1462  
  1463  // ResetDecisions resets all changes to the "decisions" edge.
  1464  func (m *AlertMutation) ResetDecisions() {
  1465  	m.decisions = nil
  1466  	m.cleareddecisions = false
  1467  	m.removeddecisions = nil
  1468  }
  1469  
  1470  // AddEventIDs adds the "events" edge to the Event entity by ids.
  1471  func (m *AlertMutation) AddEventIDs(ids ...int) {
  1472  	if m.events == nil {
  1473  		m.events = make(map[int]struct{})
  1474  	}
  1475  	for i := range ids {
  1476  		m.events[ids[i]] = struct{}{}
  1477  	}
  1478  }
  1479  
  1480  // ClearEvents clears the "events" edge to the Event entity.
  1481  func (m *AlertMutation) ClearEvents() {
  1482  	m.clearedevents = true
  1483  }
  1484  
  1485  // EventsCleared reports if the "events" edge to the Event entity was cleared.
  1486  func (m *AlertMutation) EventsCleared() bool {
  1487  	return m.clearedevents
  1488  }
  1489  
  1490  // RemoveEventIDs removes the "events" edge to the Event entity by IDs.
  1491  func (m *AlertMutation) RemoveEventIDs(ids ...int) {
  1492  	if m.removedevents == nil {
  1493  		m.removedevents = make(map[int]struct{})
  1494  	}
  1495  	for i := range ids {
  1496  		delete(m.events, ids[i])
  1497  		m.removedevents[ids[i]] = struct{}{}
  1498  	}
  1499  }
  1500  
  1501  // RemovedEvents returns the removed IDs of the "events" edge to the Event entity.
  1502  func (m *AlertMutation) RemovedEventsIDs() (ids []int) {
  1503  	for id := range m.removedevents {
  1504  		ids = append(ids, id)
  1505  	}
  1506  	return
  1507  }
  1508  
  1509  // EventsIDs returns the "events" edge IDs in the mutation.
  1510  func (m *AlertMutation) EventsIDs() (ids []int) {
  1511  	for id := range m.events {
  1512  		ids = append(ids, id)
  1513  	}
  1514  	return
  1515  }
  1516  
  1517  // ResetEvents resets all changes to the "events" edge.
  1518  func (m *AlertMutation) ResetEvents() {
  1519  	m.events = nil
  1520  	m.clearedevents = false
  1521  	m.removedevents = nil
  1522  }
  1523  
  1524  // AddMetaIDs adds the "metas" edge to the Meta entity by ids.
  1525  func (m *AlertMutation) AddMetaIDs(ids ...int) {
  1526  	if m.metas == nil {
  1527  		m.metas = make(map[int]struct{})
  1528  	}
  1529  	for i := range ids {
  1530  		m.metas[ids[i]] = struct{}{}
  1531  	}
  1532  }
  1533  
  1534  // ClearMetas clears the "metas" edge to the Meta entity.
  1535  func (m *AlertMutation) ClearMetas() {
  1536  	m.clearedmetas = true
  1537  }
  1538  
  1539  // MetasCleared reports if the "metas" edge to the Meta entity was cleared.
  1540  func (m *AlertMutation) MetasCleared() bool {
  1541  	return m.clearedmetas
  1542  }
  1543  
  1544  // RemoveMetaIDs removes the "metas" edge to the Meta entity by IDs.
  1545  func (m *AlertMutation) RemoveMetaIDs(ids ...int) {
  1546  	if m.removedmetas == nil {
  1547  		m.removedmetas = make(map[int]struct{})
  1548  	}
  1549  	for i := range ids {
  1550  		delete(m.metas, ids[i])
  1551  		m.removedmetas[ids[i]] = struct{}{}
  1552  	}
  1553  }
  1554  
  1555  // RemovedMetas returns the removed IDs of the "metas" edge to the Meta entity.
  1556  func (m *AlertMutation) RemovedMetasIDs() (ids []int) {
  1557  	for id := range m.removedmetas {
  1558  		ids = append(ids, id)
  1559  	}
  1560  	return
  1561  }
  1562  
  1563  // MetasIDs returns the "metas" edge IDs in the mutation.
  1564  func (m *AlertMutation) MetasIDs() (ids []int) {
  1565  	for id := range m.metas {
  1566  		ids = append(ids, id)
  1567  	}
  1568  	return
  1569  }
  1570  
  1571  // ResetMetas resets all changes to the "metas" edge.
  1572  func (m *AlertMutation) ResetMetas() {
  1573  	m.metas = nil
  1574  	m.clearedmetas = false
  1575  	m.removedmetas = nil
  1576  }
  1577  
  1578  // Where appends a list predicates to the AlertMutation builder.
  1579  func (m *AlertMutation) Where(ps ...predicate.Alert) {
  1580  	m.predicates = append(m.predicates, ps...)
  1581  }
  1582  
  1583  // WhereP appends storage-level predicates to the AlertMutation builder. Using this method,
  1584  // users can use type-assertion to append predicates that do not depend on any generated package.
  1585  func (m *AlertMutation) WhereP(ps ...func(*sql.Selector)) {
  1586  	p := make([]predicate.Alert, len(ps))
  1587  	for i := range ps {
  1588  		p[i] = ps[i]
  1589  	}
  1590  	m.Where(p...)
  1591  }
  1592  
  1593  // Op returns the operation name.
  1594  func (m *AlertMutation) Op() Op {
  1595  	return m.op
  1596  }
  1597  
  1598  // SetOp allows setting the mutation operation.
  1599  func (m *AlertMutation) SetOp(op Op) {
  1600  	m.op = op
  1601  }
  1602  
  1603  // Type returns the node type of this mutation (Alert).
  1604  func (m *AlertMutation) Type() string {
  1605  	return m.typ
  1606  }
  1607  
  1608  // Fields returns all fields that were changed during this mutation. Note that in
  1609  // order to get all numeric fields that were incremented/decremented, call
  1610  // AddedFields().
  1611  func (m *AlertMutation) Fields() []string {
  1612  	fields := make([]string, 0, 23)
  1613  	if m.created_at != nil {
  1614  		fields = append(fields, alert.FieldCreatedAt)
  1615  	}
  1616  	if m.updated_at != nil {
  1617  		fields = append(fields, alert.FieldUpdatedAt)
  1618  	}
  1619  	if m.scenario != nil {
  1620  		fields = append(fields, alert.FieldScenario)
  1621  	}
  1622  	if m.bucketId != nil {
  1623  		fields = append(fields, alert.FieldBucketId)
  1624  	}
  1625  	if m.message != nil {
  1626  		fields = append(fields, alert.FieldMessage)
  1627  	}
  1628  	if m.eventsCount != nil {
  1629  		fields = append(fields, alert.FieldEventsCount)
  1630  	}
  1631  	if m.startedAt != nil {
  1632  		fields = append(fields, alert.FieldStartedAt)
  1633  	}
  1634  	if m.stoppedAt != nil {
  1635  		fields = append(fields, alert.FieldStoppedAt)
  1636  	}
  1637  	if m.sourceIp != nil {
  1638  		fields = append(fields, alert.FieldSourceIp)
  1639  	}
  1640  	if m.sourceRange != nil {
  1641  		fields = append(fields, alert.FieldSourceRange)
  1642  	}
  1643  	if m.sourceAsNumber != nil {
  1644  		fields = append(fields, alert.FieldSourceAsNumber)
  1645  	}
  1646  	if m.sourceAsName != nil {
  1647  		fields = append(fields, alert.FieldSourceAsName)
  1648  	}
  1649  	if m.sourceCountry != nil {
  1650  		fields = append(fields, alert.FieldSourceCountry)
  1651  	}
  1652  	if m.sourceLatitude != nil {
  1653  		fields = append(fields, alert.FieldSourceLatitude)
  1654  	}
  1655  	if m.sourceLongitude != nil {
  1656  		fields = append(fields, alert.FieldSourceLongitude)
  1657  	}
  1658  	if m.sourceScope != nil {
  1659  		fields = append(fields, alert.FieldSourceScope)
  1660  	}
  1661  	if m.sourceValue != nil {
  1662  		fields = append(fields, alert.FieldSourceValue)
  1663  	}
  1664  	if m.capacity != nil {
  1665  		fields = append(fields, alert.FieldCapacity)
  1666  	}
  1667  	if m.leakSpeed != nil {
  1668  		fields = append(fields, alert.FieldLeakSpeed)
  1669  	}
  1670  	if m.scenarioVersion != nil {
  1671  		fields = append(fields, alert.FieldScenarioVersion)
  1672  	}
  1673  	if m.scenarioHash != nil {
  1674  		fields = append(fields, alert.FieldScenarioHash)
  1675  	}
  1676  	if m.simulated != nil {
  1677  		fields = append(fields, alert.FieldSimulated)
  1678  	}
  1679  	if m.uuid != nil {
  1680  		fields = append(fields, alert.FieldUUID)
  1681  	}
  1682  	return fields
  1683  }
  1684  
  1685  // Field returns the value of a field with the given name. The second boolean
  1686  // return value indicates that this field was not set, or was not defined in the
  1687  // schema.
  1688  func (m *AlertMutation) Field(name string) (ent.Value, bool) {
  1689  	switch name {
  1690  	case alert.FieldCreatedAt:
  1691  		return m.CreatedAt()
  1692  	case alert.FieldUpdatedAt:
  1693  		return m.UpdatedAt()
  1694  	case alert.FieldScenario:
  1695  		return m.Scenario()
  1696  	case alert.FieldBucketId:
  1697  		return m.BucketId()
  1698  	case alert.FieldMessage:
  1699  		return m.Message()
  1700  	case alert.FieldEventsCount:
  1701  		return m.EventsCount()
  1702  	case alert.FieldStartedAt:
  1703  		return m.StartedAt()
  1704  	case alert.FieldStoppedAt:
  1705  		return m.StoppedAt()
  1706  	case alert.FieldSourceIp:
  1707  		return m.SourceIp()
  1708  	case alert.FieldSourceRange:
  1709  		return m.SourceRange()
  1710  	case alert.FieldSourceAsNumber:
  1711  		return m.SourceAsNumber()
  1712  	case alert.FieldSourceAsName:
  1713  		return m.SourceAsName()
  1714  	case alert.FieldSourceCountry:
  1715  		return m.SourceCountry()
  1716  	case alert.FieldSourceLatitude:
  1717  		return m.SourceLatitude()
  1718  	case alert.FieldSourceLongitude:
  1719  		return m.SourceLongitude()
  1720  	case alert.FieldSourceScope:
  1721  		return m.SourceScope()
  1722  	case alert.FieldSourceValue:
  1723  		return m.SourceValue()
  1724  	case alert.FieldCapacity:
  1725  		return m.Capacity()
  1726  	case alert.FieldLeakSpeed:
  1727  		return m.LeakSpeed()
  1728  	case alert.FieldScenarioVersion:
  1729  		return m.ScenarioVersion()
  1730  	case alert.FieldScenarioHash:
  1731  		return m.ScenarioHash()
  1732  	case alert.FieldSimulated:
  1733  		return m.Simulated()
  1734  	case alert.FieldUUID:
  1735  		return m.UUID()
  1736  	}
  1737  	return nil, false
  1738  }
  1739  
  1740  // OldField returns the old value of the field from the database. An error is
  1741  // returned if the mutation operation is not UpdateOne, or the query to the
  1742  // database failed.
  1743  func (m *AlertMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1744  	switch name {
  1745  	case alert.FieldCreatedAt:
  1746  		return m.OldCreatedAt(ctx)
  1747  	case alert.FieldUpdatedAt:
  1748  		return m.OldUpdatedAt(ctx)
  1749  	case alert.FieldScenario:
  1750  		return m.OldScenario(ctx)
  1751  	case alert.FieldBucketId:
  1752  		return m.OldBucketId(ctx)
  1753  	case alert.FieldMessage:
  1754  		return m.OldMessage(ctx)
  1755  	case alert.FieldEventsCount:
  1756  		return m.OldEventsCount(ctx)
  1757  	case alert.FieldStartedAt:
  1758  		return m.OldStartedAt(ctx)
  1759  	case alert.FieldStoppedAt:
  1760  		return m.OldStoppedAt(ctx)
  1761  	case alert.FieldSourceIp:
  1762  		return m.OldSourceIp(ctx)
  1763  	case alert.FieldSourceRange:
  1764  		return m.OldSourceRange(ctx)
  1765  	case alert.FieldSourceAsNumber:
  1766  		return m.OldSourceAsNumber(ctx)
  1767  	case alert.FieldSourceAsName:
  1768  		return m.OldSourceAsName(ctx)
  1769  	case alert.FieldSourceCountry:
  1770  		return m.OldSourceCountry(ctx)
  1771  	case alert.FieldSourceLatitude:
  1772  		return m.OldSourceLatitude(ctx)
  1773  	case alert.FieldSourceLongitude:
  1774  		return m.OldSourceLongitude(ctx)
  1775  	case alert.FieldSourceScope:
  1776  		return m.OldSourceScope(ctx)
  1777  	case alert.FieldSourceValue:
  1778  		return m.OldSourceValue(ctx)
  1779  	case alert.FieldCapacity:
  1780  		return m.OldCapacity(ctx)
  1781  	case alert.FieldLeakSpeed:
  1782  		return m.OldLeakSpeed(ctx)
  1783  	case alert.FieldScenarioVersion:
  1784  		return m.OldScenarioVersion(ctx)
  1785  	case alert.FieldScenarioHash:
  1786  		return m.OldScenarioHash(ctx)
  1787  	case alert.FieldSimulated:
  1788  		return m.OldSimulated(ctx)
  1789  	case alert.FieldUUID:
  1790  		return m.OldUUID(ctx)
  1791  	}
  1792  	return nil, fmt.Errorf("unknown Alert field %s", name)
  1793  }
  1794  
  1795  // SetField sets the value of a field with the given name. It returns an error if
  1796  // the field is not defined in the schema, or if the type mismatched the field
  1797  // type.
  1798  func (m *AlertMutation) SetField(name string, value ent.Value) error {
  1799  	switch name {
  1800  	case alert.FieldCreatedAt:
  1801  		v, ok := value.(time.Time)
  1802  		if !ok {
  1803  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1804  		}
  1805  		m.SetCreatedAt(v)
  1806  		return nil
  1807  	case alert.FieldUpdatedAt:
  1808  		v, ok := value.(time.Time)
  1809  		if !ok {
  1810  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1811  		}
  1812  		m.SetUpdatedAt(v)
  1813  		return nil
  1814  	case alert.FieldScenario:
  1815  		v, ok := value.(string)
  1816  		if !ok {
  1817  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1818  		}
  1819  		m.SetScenario(v)
  1820  		return nil
  1821  	case alert.FieldBucketId:
  1822  		v, ok := value.(string)
  1823  		if !ok {
  1824  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1825  		}
  1826  		m.SetBucketId(v)
  1827  		return nil
  1828  	case alert.FieldMessage:
  1829  		v, ok := value.(string)
  1830  		if !ok {
  1831  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1832  		}
  1833  		m.SetMessage(v)
  1834  		return nil
  1835  	case alert.FieldEventsCount:
  1836  		v, ok := value.(int32)
  1837  		if !ok {
  1838  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1839  		}
  1840  		m.SetEventsCount(v)
  1841  		return nil
  1842  	case alert.FieldStartedAt:
  1843  		v, ok := value.(time.Time)
  1844  		if !ok {
  1845  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1846  		}
  1847  		m.SetStartedAt(v)
  1848  		return nil
  1849  	case alert.FieldStoppedAt:
  1850  		v, ok := value.(time.Time)
  1851  		if !ok {
  1852  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1853  		}
  1854  		m.SetStoppedAt(v)
  1855  		return nil
  1856  	case alert.FieldSourceIp:
  1857  		v, ok := value.(string)
  1858  		if !ok {
  1859  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1860  		}
  1861  		m.SetSourceIp(v)
  1862  		return nil
  1863  	case alert.FieldSourceRange:
  1864  		v, ok := value.(string)
  1865  		if !ok {
  1866  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1867  		}
  1868  		m.SetSourceRange(v)
  1869  		return nil
  1870  	case alert.FieldSourceAsNumber:
  1871  		v, ok := value.(string)
  1872  		if !ok {
  1873  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1874  		}
  1875  		m.SetSourceAsNumber(v)
  1876  		return nil
  1877  	case alert.FieldSourceAsName:
  1878  		v, ok := value.(string)
  1879  		if !ok {
  1880  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1881  		}
  1882  		m.SetSourceAsName(v)
  1883  		return nil
  1884  	case alert.FieldSourceCountry:
  1885  		v, ok := value.(string)
  1886  		if !ok {
  1887  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1888  		}
  1889  		m.SetSourceCountry(v)
  1890  		return nil
  1891  	case alert.FieldSourceLatitude:
  1892  		v, ok := value.(float32)
  1893  		if !ok {
  1894  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1895  		}
  1896  		m.SetSourceLatitude(v)
  1897  		return nil
  1898  	case alert.FieldSourceLongitude:
  1899  		v, ok := value.(float32)
  1900  		if !ok {
  1901  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1902  		}
  1903  		m.SetSourceLongitude(v)
  1904  		return nil
  1905  	case alert.FieldSourceScope:
  1906  		v, ok := value.(string)
  1907  		if !ok {
  1908  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1909  		}
  1910  		m.SetSourceScope(v)
  1911  		return nil
  1912  	case alert.FieldSourceValue:
  1913  		v, ok := value.(string)
  1914  		if !ok {
  1915  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1916  		}
  1917  		m.SetSourceValue(v)
  1918  		return nil
  1919  	case alert.FieldCapacity:
  1920  		v, ok := value.(int32)
  1921  		if !ok {
  1922  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1923  		}
  1924  		m.SetCapacity(v)
  1925  		return nil
  1926  	case alert.FieldLeakSpeed:
  1927  		v, ok := value.(string)
  1928  		if !ok {
  1929  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1930  		}
  1931  		m.SetLeakSpeed(v)
  1932  		return nil
  1933  	case alert.FieldScenarioVersion:
  1934  		v, ok := value.(string)
  1935  		if !ok {
  1936  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1937  		}
  1938  		m.SetScenarioVersion(v)
  1939  		return nil
  1940  	case alert.FieldScenarioHash:
  1941  		v, ok := value.(string)
  1942  		if !ok {
  1943  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1944  		}
  1945  		m.SetScenarioHash(v)
  1946  		return nil
  1947  	case alert.FieldSimulated:
  1948  		v, ok := value.(bool)
  1949  		if !ok {
  1950  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1951  		}
  1952  		m.SetSimulated(v)
  1953  		return nil
  1954  	case alert.FieldUUID:
  1955  		v, ok := value.(string)
  1956  		if !ok {
  1957  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  1958  		}
  1959  		m.SetUUID(v)
  1960  		return nil
  1961  	}
  1962  	return fmt.Errorf("unknown Alert field %s", name)
  1963  }
  1964  
  1965  // AddedFields returns all numeric fields that were incremented/decremented during
  1966  // this mutation.
  1967  func (m *AlertMutation) AddedFields() []string {
  1968  	var fields []string
  1969  	if m.addeventsCount != nil {
  1970  		fields = append(fields, alert.FieldEventsCount)
  1971  	}
  1972  	if m.addsourceLatitude != nil {
  1973  		fields = append(fields, alert.FieldSourceLatitude)
  1974  	}
  1975  	if m.addsourceLongitude != nil {
  1976  		fields = append(fields, alert.FieldSourceLongitude)
  1977  	}
  1978  	if m.addcapacity != nil {
  1979  		fields = append(fields, alert.FieldCapacity)
  1980  	}
  1981  	return fields
  1982  }
  1983  
  1984  // AddedField returns the numeric value that was incremented/decremented on a field
  1985  // with the given name. The second boolean return value indicates that this field
  1986  // was not set, or was not defined in the schema.
  1987  func (m *AlertMutation) AddedField(name string) (ent.Value, bool) {
  1988  	switch name {
  1989  	case alert.FieldEventsCount:
  1990  		return m.AddedEventsCount()
  1991  	case alert.FieldSourceLatitude:
  1992  		return m.AddedSourceLatitude()
  1993  	case alert.FieldSourceLongitude:
  1994  		return m.AddedSourceLongitude()
  1995  	case alert.FieldCapacity:
  1996  		return m.AddedCapacity()
  1997  	}
  1998  	return nil, false
  1999  }
  2000  
  2001  // AddField adds the value to the field with the given name. It returns an error if
  2002  // the field is not defined in the schema, or if the type mismatched the field
  2003  // type.
  2004  func (m *AlertMutation) AddField(name string, value ent.Value) error {
  2005  	switch name {
  2006  	case alert.FieldEventsCount:
  2007  		v, ok := value.(int32)
  2008  		if !ok {
  2009  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2010  		}
  2011  		m.AddEventsCount(v)
  2012  		return nil
  2013  	case alert.FieldSourceLatitude:
  2014  		v, ok := value.(float32)
  2015  		if !ok {
  2016  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2017  		}
  2018  		m.AddSourceLatitude(v)
  2019  		return nil
  2020  	case alert.FieldSourceLongitude:
  2021  		v, ok := value.(float32)
  2022  		if !ok {
  2023  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2024  		}
  2025  		m.AddSourceLongitude(v)
  2026  		return nil
  2027  	case alert.FieldCapacity:
  2028  		v, ok := value.(int32)
  2029  		if !ok {
  2030  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  2031  		}
  2032  		m.AddCapacity(v)
  2033  		return nil
  2034  	}
  2035  	return fmt.Errorf("unknown Alert numeric field %s", name)
  2036  }
  2037  
  2038  // ClearedFields returns all nullable fields that were cleared during this
  2039  // mutation.
  2040  func (m *AlertMutation) ClearedFields() []string {
  2041  	var fields []string
  2042  	if m.FieldCleared(alert.FieldCreatedAt) {
  2043  		fields = append(fields, alert.FieldCreatedAt)
  2044  	}
  2045  	if m.FieldCleared(alert.FieldUpdatedAt) {
  2046  		fields = append(fields, alert.FieldUpdatedAt)
  2047  	}
  2048  	if m.FieldCleared(alert.FieldBucketId) {
  2049  		fields = append(fields, alert.FieldBucketId)
  2050  	}
  2051  	if m.FieldCleared(alert.FieldMessage) {
  2052  		fields = append(fields, alert.FieldMessage)
  2053  	}
  2054  	if m.FieldCleared(alert.FieldEventsCount) {
  2055  		fields = append(fields, alert.FieldEventsCount)
  2056  	}
  2057  	if m.FieldCleared(alert.FieldStartedAt) {
  2058  		fields = append(fields, alert.FieldStartedAt)
  2059  	}
  2060  	if m.FieldCleared(alert.FieldStoppedAt) {
  2061  		fields = append(fields, alert.FieldStoppedAt)
  2062  	}
  2063  	if m.FieldCleared(alert.FieldSourceIp) {
  2064  		fields = append(fields, alert.FieldSourceIp)
  2065  	}
  2066  	if m.FieldCleared(alert.FieldSourceRange) {
  2067  		fields = append(fields, alert.FieldSourceRange)
  2068  	}
  2069  	if m.FieldCleared(alert.FieldSourceAsNumber) {
  2070  		fields = append(fields, alert.FieldSourceAsNumber)
  2071  	}
  2072  	if m.FieldCleared(alert.FieldSourceAsName) {
  2073  		fields = append(fields, alert.FieldSourceAsName)
  2074  	}
  2075  	if m.FieldCleared(alert.FieldSourceCountry) {
  2076  		fields = append(fields, alert.FieldSourceCountry)
  2077  	}
  2078  	if m.FieldCleared(alert.FieldSourceLatitude) {
  2079  		fields = append(fields, alert.FieldSourceLatitude)
  2080  	}
  2081  	if m.FieldCleared(alert.FieldSourceLongitude) {
  2082  		fields = append(fields, alert.FieldSourceLongitude)
  2083  	}
  2084  	if m.FieldCleared(alert.FieldSourceScope) {
  2085  		fields = append(fields, alert.FieldSourceScope)
  2086  	}
  2087  	if m.FieldCleared(alert.FieldSourceValue) {
  2088  		fields = append(fields, alert.FieldSourceValue)
  2089  	}
  2090  	if m.FieldCleared(alert.FieldCapacity) {
  2091  		fields = append(fields, alert.FieldCapacity)
  2092  	}
  2093  	if m.FieldCleared(alert.FieldLeakSpeed) {
  2094  		fields = append(fields, alert.FieldLeakSpeed)
  2095  	}
  2096  	if m.FieldCleared(alert.FieldScenarioVersion) {
  2097  		fields = append(fields, alert.FieldScenarioVersion)
  2098  	}
  2099  	if m.FieldCleared(alert.FieldScenarioHash) {
  2100  		fields = append(fields, alert.FieldScenarioHash)
  2101  	}
  2102  	if m.FieldCleared(alert.FieldUUID) {
  2103  		fields = append(fields, alert.FieldUUID)
  2104  	}
  2105  	return fields
  2106  }
  2107  
  2108  // FieldCleared returns a boolean indicating if a field with the given name was
  2109  // cleared in this mutation.
  2110  func (m *AlertMutation) FieldCleared(name string) bool {
  2111  	_, ok := m.clearedFields[name]
  2112  	return ok
  2113  }
  2114  
  2115  // ClearField clears the value of the field with the given name. It returns an
  2116  // error if the field is not defined in the schema.
  2117  func (m *AlertMutation) ClearField(name string) error {
  2118  	switch name {
  2119  	case alert.FieldCreatedAt:
  2120  		m.ClearCreatedAt()
  2121  		return nil
  2122  	case alert.FieldUpdatedAt:
  2123  		m.ClearUpdatedAt()
  2124  		return nil
  2125  	case alert.FieldBucketId:
  2126  		m.ClearBucketId()
  2127  		return nil
  2128  	case alert.FieldMessage:
  2129  		m.ClearMessage()
  2130  		return nil
  2131  	case alert.FieldEventsCount:
  2132  		m.ClearEventsCount()
  2133  		return nil
  2134  	case alert.FieldStartedAt:
  2135  		m.ClearStartedAt()
  2136  		return nil
  2137  	case alert.FieldStoppedAt:
  2138  		m.ClearStoppedAt()
  2139  		return nil
  2140  	case alert.FieldSourceIp:
  2141  		m.ClearSourceIp()
  2142  		return nil
  2143  	case alert.FieldSourceRange:
  2144  		m.ClearSourceRange()
  2145  		return nil
  2146  	case alert.FieldSourceAsNumber:
  2147  		m.ClearSourceAsNumber()
  2148  		return nil
  2149  	case alert.FieldSourceAsName:
  2150  		m.ClearSourceAsName()
  2151  		return nil
  2152  	case alert.FieldSourceCountry:
  2153  		m.ClearSourceCountry()
  2154  		return nil
  2155  	case alert.FieldSourceLatitude:
  2156  		m.ClearSourceLatitude()
  2157  		return nil
  2158  	case alert.FieldSourceLongitude:
  2159  		m.ClearSourceLongitude()
  2160  		return nil
  2161  	case alert.FieldSourceScope:
  2162  		m.ClearSourceScope()
  2163  		return nil
  2164  	case alert.FieldSourceValue:
  2165  		m.ClearSourceValue()
  2166  		return nil
  2167  	case alert.FieldCapacity:
  2168  		m.ClearCapacity()
  2169  		return nil
  2170  	case alert.FieldLeakSpeed:
  2171  		m.ClearLeakSpeed()
  2172  		return nil
  2173  	case alert.FieldScenarioVersion:
  2174  		m.ClearScenarioVersion()
  2175  		return nil
  2176  	case alert.FieldScenarioHash:
  2177  		m.ClearScenarioHash()
  2178  		return nil
  2179  	case alert.FieldUUID:
  2180  		m.ClearUUID()
  2181  		return nil
  2182  	}
  2183  	return fmt.Errorf("unknown Alert nullable field %s", name)
  2184  }
  2185  
  2186  // ResetField resets all changes in the mutation for the field with the given name.
  2187  // It returns an error if the field is not defined in the schema.
  2188  func (m *AlertMutation) ResetField(name string) error {
  2189  	switch name {
  2190  	case alert.FieldCreatedAt:
  2191  		m.ResetCreatedAt()
  2192  		return nil
  2193  	case alert.FieldUpdatedAt:
  2194  		m.ResetUpdatedAt()
  2195  		return nil
  2196  	case alert.FieldScenario:
  2197  		m.ResetScenario()
  2198  		return nil
  2199  	case alert.FieldBucketId:
  2200  		m.ResetBucketId()
  2201  		return nil
  2202  	case alert.FieldMessage:
  2203  		m.ResetMessage()
  2204  		return nil
  2205  	case alert.FieldEventsCount:
  2206  		m.ResetEventsCount()
  2207  		return nil
  2208  	case alert.FieldStartedAt:
  2209  		m.ResetStartedAt()
  2210  		return nil
  2211  	case alert.FieldStoppedAt:
  2212  		m.ResetStoppedAt()
  2213  		return nil
  2214  	case alert.FieldSourceIp:
  2215  		m.ResetSourceIp()
  2216  		return nil
  2217  	case alert.FieldSourceRange:
  2218  		m.ResetSourceRange()
  2219  		return nil
  2220  	case alert.FieldSourceAsNumber:
  2221  		m.ResetSourceAsNumber()
  2222  		return nil
  2223  	case alert.FieldSourceAsName:
  2224  		m.ResetSourceAsName()
  2225  		return nil
  2226  	case alert.FieldSourceCountry:
  2227  		m.ResetSourceCountry()
  2228  		return nil
  2229  	case alert.FieldSourceLatitude:
  2230  		m.ResetSourceLatitude()
  2231  		return nil
  2232  	case alert.FieldSourceLongitude:
  2233  		m.ResetSourceLongitude()
  2234  		return nil
  2235  	case alert.FieldSourceScope:
  2236  		m.ResetSourceScope()
  2237  		return nil
  2238  	case alert.FieldSourceValue:
  2239  		m.ResetSourceValue()
  2240  		return nil
  2241  	case alert.FieldCapacity:
  2242  		m.ResetCapacity()
  2243  		return nil
  2244  	case alert.FieldLeakSpeed:
  2245  		m.ResetLeakSpeed()
  2246  		return nil
  2247  	case alert.FieldScenarioVersion:
  2248  		m.ResetScenarioVersion()
  2249  		return nil
  2250  	case alert.FieldScenarioHash:
  2251  		m.ResetScenarioHash()
  2252  		return nil
  2253  	case alert.FieldSimulated:
  2254  		m.ResetSimulated()
  2255  		return nil
  2256  	case alert.FieldUUID:
  2257  		m.ResetUUID()
  2258  		return nil
  2259  	}
  2260  	return fmt.Errorf("unknown Alert field %s", name)
  2261  }
  2262  
  2263  // AddedEdges returns all edge names that were set/added in this mutation.
  2264  func (m *AlertMutation) AddedEdges() []string {
  2265  	edges := make([]string, 0, 4)
  2266  	if m.owner != nil {
  2267  		edges = append(edges, alert.EdgeOwner)
  2268  	}
  2269  	if m.decisions != nil {
  2270  		edges = append(edges, alert.EdgeDecisions)
  2271  	}
  2272  	if m.events != nil {
  2273  		edges = append(edges, alert.EdgeEvents)
  2274  	}
  2275  	if m.metas != nil {
  2276  		edges = append(edges, alert.EdgeMetas)
  2277  	}
  2278  	return edges
  2279  }
  2280  
  2281  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2282  // name in this mutation.
  2283  func (m *AlertMutation) AddedIDs(name string) []ent.Value {
  2284  	switch name {
  2285  	case alert.EdgeOwner:
  2286  		if id := m.owner; id != nil {
  2287  			return []ent.Value{*id}
  2288  		}
  2289  	case alert.EdgeDecisions:
  2290  		ids := make([]ent.Value, 0, len(m.decisions))
  2291  		for id := range m.decisions {
  2292  			ids = append(ids, id)
  2293  		}
  2294  		return ids
  2295  	case alert.EdgeEvents:
  2296  		ids := make([]ent.Value, 0, len(m.events))
  2297  		for id := range m.events {
  2298  			ids = append(ids, id)
  2299  		}
  2300  		return ids
  2301  	case alert.EdgeMetas:
  2302  		ids := make([]ent.Value, 0, len(m.metas))
  2303  		for id := range m.metas {
  2304  			ids = append(ids, id)
  2305  		}
  2306  		return ids
  2307  	}
  2308  	return nil
  2309  }
  2310  
  2311  // RemovedEdges returns all edge names that were removed in this mutation.
  2312  func (m *AlertMutation) RemovedEdges() []string {
  2313  	edges := make([]string, 0, 4)
  2314  	if m.removeddecisions != nil {
  2315  		edges = append(edges, alert.EdgeDecisions)
  2316  	}
  2317  	if m.removedevents != nil {
  2318  		edges = append(edges, alert.EdgeEvents)
  2319  	}
  2320  	if m.removedmetas != nil {
  2321  		edges = append(edges, alert.EdgeMetas)
  2322  	}
  2323  	return edges
  2324  }
  2325  
  2326  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2327  // the given name in this mutation.
  2328  func (m *AlertMutation) RemovedIDs(name string) []ent.Value {
  2329  	switch name {
  2330  	case alert.EdgeDecisions:
  2331  		ids := make([]ent.Value, 0, len(m.removeddecisions))
  2332  		for id := range m.removeddecisions {
  2333  			ids = append(ids, id)
  2334  		}
  2335  		return ids
  2336  	case alert.EdgeEvents:
  2337  		ids := make([]ent.Value, 0, len(m.removedevents))
  2338  		for id := range m.removedevents {
  2339  			ids = append(ids, id)
  2340  		}
  2341  		return ids
  2342  	case alert.EdgeMetas:
  2343  		ids := make([]ent.Value, 0, len(m.removedmetas))
  2344  		for id := range m.removedmetas {
  2345  			ids = append(ids, id)
  2346  		}
  2347  		return ids
  2348  	}
  2349  	return nil
  2350  }
  2351  
  2352  // ClearedEdges returns all edge names that were cleared in this mutation.
  2353  func (m *AlertMutation) ClearedEdges() []string {
  2354  	edges := make([]string, 0, 4)
  2355  	if m.clearedowner {
  2356  		edges = append(edges, alert.EdgeOwner)
  2357  	}
  2358  	if m.cleareddecisions {
  2359  		edges = append(edges, alert.EdgeDecisions)
  2360  	}
  2361  	if m.clearedevents {
  2362  		edges = append(edges, alert.EdgeEvents)
  2363  	}
  2364  	if m.clearedmetas {
  2365  		edges = append(edges, alert.EdgeMetas)
  2366  	}
  2367  	return edges
  2368  }
  2369  
  2370  // EdgeCleared returns a boolean which indicates if the edge with the given name
  2371  // was cleared in this mutation.
  2372  func (m *AlertMutation) EdgeCleared(name string) bool {
  2373  	switch name {
  2374  	case alert.EdgeOwner:
  2375  		return m.clearedowner
  2376  	case alert.EdgeDecisions:
  2377  		return m.cleareddecisions
  2378  	case alert.EdgeEvents:
  2379  		return m.clearedevents
  2380  	case alert.EdgeMetas:
  2381  		return m.clearedmetas
  2382  	}
  2383  	return false
  2384  }
  2385  
  2386  // ClearEdge clears the value of the edge with the given name. It returns an error
  2387  // if that edge is not defined in the schema.
  2388  func (m *AlertMutation) ClearEdge(name string) error {
  2389  	switch name {
  2390  	case alert.EdgeOwner:
  2391  		m.ClearOwner()
  2392  		return nil
  2393  	}
  2394  	return fmt.Errorf("unknown Alert unique edge %s", name)
  2395  }
  2396  
  2397  // ResetEdge resets all changes to the edge with the given name in this mutation.
  2398  // It returns an error if the edge is not defined in the schema.
  2399  func (m *AlertMutation) ResetEdge(name string) error {
  2400  	switch name {
  2401  	case alert.EdgeOwner:
  2402  		m.ResetOwner()
  2403  		return nil
  2404  	case alert.EdgeDecisions:
  2405  		m.ResetDecisions()
  2406  		return nil
  2407  	case alert.EdgeEvents:
  2408  		m.ResetEvents()
  2409  		return nil
  2410  	case alert.EdgeMetas:
  2411  		m.ResetMetas()
  2412  		return nil
  2413  	}
  2414  	return fmt.Errorf("unknown Alert edge %s", name)
  2415  }
  2416  
  2417  // BouncerMutation represents an operation that mutates the Bouncer nodes in the graph.
  2418  type BouncerMutation struct {
  2419  	config
  2420  	op            Op
  2421  	typ           string
  2422  	id            *int
  2423  	created_at    *time.Time
  2424  	updated_at    *time.Time
  2425  	name          *string
  2426  	api_key       *string
  2427  	revoked       *bool
  2428  	ip_address    *string
  2429  	_type         *string
  2430  	version       *string
  2431  	until         *time.Time
  2432  	last_pull     *time.Time
  2433  	auth_type     *string
  2434  	clearedFields map[string]struct{}
  2435  	done          bool
  2436  	oldValue      func(context.Context) (*Bouncer, error)
  2437  	predicates    []predicate.Bouncer
  2438  }
  2439  
  2440  var _ ent.Mutation = (*BouncerMutation)(nil)
  2441  
  2442  // bouncerOption allows management of the mutation configuration using functional options.
  2443  type bouncerOption func(*BouncerMutation)
  2444  
  2445  // newBouncerMutation creates new mutation for the Bouncer entity.
  2446  func newBouncerMutation(c config, op Op, opts ...bouncerOption) *BouncerMutation {
  2447  	m := &BouncerMutation{
  2448  		config:        c,
  2449  		op:            op,
  2450  		typ:           TypeBouncer,
  2451  		clearedFields: make(map[string]struct{}),
  2452  	}
  2453  	for _, opt := range opts {
  2454  		opt(m)
  2455  	}
  2456  	return m
  2457  }
  2458  
  2459  // withBouncerID sets the ID field of the mutation.
  2460  func withBouncerID(id int) bouncerOption {
  2461  	return func(m *BouncerMutation) {
  2462  		var (
  2463  			err   error
  2464  			once  sync.Once
  2465  			value *Bouncer
  2466  		)
  2467  		m.oldValue = func(ctx context.Context) (*Bouncer, error) {
  2468  			once.Do(func() {
  2469  				if m.done {
  2470  					err = errors.New("querying old values post mutation is not allowed")
  2471  				} else {
  2472  					value, err = m.Client().Bouncer.Get(ctx, id)
  2473  				}
  2474  			})
  2475  			return value, err
  2476  		}
  2477  		m.id = &id
  2478  	}
  2479  }
  2480  
  2481  // withBouncer sets the old Bouncer of the mutation.
  2482  func withBouncer(node *Bouncer) bouncerOption {
  2483  	return func(m *BouncerMutation) {
  2484  		m.oldValue = func(context.Context) (*Bouncer, error) {
  2485  			return node, nil
  2486  		}
  2487  		m.id = &node.ID
  2488  	}
  2489  }
  2490  
  2491  // Client returns a new `ent.Client` from the mutation. If the mutation was
  2492  // executed in a transaction (ent.Tx), a transactional client is returned.
  2493  func (m BouncerMutation) Client() *Client {
  2494  	client := &Client{config: m.config}
  2495  	client.init()
  2496  	return client
  2497  }
  2498  
  2499  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2500  // it returns an error otherwise.
  2501  func (m BouncerMutation) Tx() (*Tx, error) {
  2502  	if _, ok := m.driver.(*txDriver); !ok {
  2503  		return nil, errors.New("ent: mutation is not running in a transaction")
  2504  	}
  2505  	tx := &Tx{config: m.config}
  2506  	tx.init()
  2507  	return tx, nil
  2508  }
  2509  
  2510  // ID returns the ID value in the mutation. Note that the ID is only available
  2511  // if it was provided to the builder or after it was returned from the database.
  2512  func (m *BouncerMutation) ID() (id int, exists bool) {
  2513  	if m.id == nil {
  2514  		return
  2515  	}
  2516  	return *m.id, true
  2517  }
  2518  
  2519  // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2520  // That means, if the mutation is applied within a transaction with an isolation level such
  2521  // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2522  // or updated by the mutation.
  2523  func (m *BouncerMutation) IDs(ctx context.Context) ([]int, error) {
  2524  	switch {
  2525  	case m.op.Is(OpUpdateOne | OpDeleteOne):
  2526  		id, exists := m.ID()
  2527  		if exists {
  2528  			return []int{id}, nil
  2529  		}
  2530  		fallthrough
  2531  	case m.op.Is(OpUpdate | OpDelete):
  2532  		return m.Client().Bouncer.Query().Where(m.predicates...).IDs(ctx)
  2533  	default:
  2534  		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2535  	}
  2536  }
  2537  
  2538  // SetCreatedAt sets the "created_at" field.
  2539  func (m *BouncerMutation) SetCreatedAt(t time.Time) {
  2540  	m.created_at = &t
  2541  }
  2542  
  2543  // CreatedAt returns the value of the "created_at" field in the mutation.
  2544  func (m *BouncerMutation) CreatedAt() (r time.Time, exists bool) {
  2545  	v := m.created_at
  2546  	if v == nil {
  2547  		return
  2548  	}
  2549  	return *v, true
  2550  }
  2551  
  2552  // OldCreatedAt returns the old "created_at" field's value of the Bouncer entity.
  2553  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2554  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2555  func (m *BouncerMutation) OldCreatedAt(ctx context.Context) (v *time.Time, err error) {
  2556  	if !m.op.Is(OpUpdateOne) {
  2557  		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2558  	}
  2559  	if m.id == nil || m.oldValue == nil {
  2560  		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2561  	}
  2562  	oldValue, err := m.oldValue(ctx)
  2563  	if err != nil {
  2564  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2565  	}
  2566  	return oldValue.CreatedAt, nil
  2567  }
  2568  
  2569  // ClearCreatedAt clears the value of the "created_at" field.
  2570  func (m *BouncerMutation) ClearCreatedAt() {
  2571  	m.created_at = nil
  2572  	m.clearedFields[bouncer.FieldCreatedAt] = struct{}{}
  2573  }
  2574  
  2575  // CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
  2576  func (m *BouncerMutation) CreatedAtCleared() bool {
  2577  	_, ok := m.clearedFields[bouncer.FieldCreatedAt]
  2578  	return ok
  2579  }
  2580  
  2581  // ResetCreatedAt resets all changes to the "created_at" field.
  2582  func (m *BouncerMutation) ResetCreatedAt() {
  2583  	m.created_at = nil
  2584  	delete(m.clearedFields, bouncer.FieldCreatedAt)
  2585  }
  2586  
  2587  // SetUpdatedAt sets the "updated_at" field.
  2588  func (m *BouncerMutation) SetUpdatedAt(t time.Time) {
  2589  	m.updated_at = &t
  2590  }
  2591  
  2592  // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2593  func (m *BouncerMutation) UpdatedAt() (r time.Time, exists bool) {
  2594  	v := m.updated_at
  2595  	if v == nil {
  2596  		return
  2597  	}
  2598  	return *v, true
  2599  }
  2600  
  2601  // OldUpdatedAt returns the old "updated_at" field's value of the Bouncer entity.
  2602  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2603  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2604  func (m *BouncerMutation) OldUpdatedAt(ctx context.Context) (v *time.Time, err error) {
  2605  	if !m.op.Is(OpUpdateOne) {
  2606  		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2607  	}
  2608  	if m.id == nil || m.oldValue == nil {
  2609  		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2610  	}
  2611  	oldValue, err := m.oldValue(ctx)
  2612  	if err != nil {
  2613  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2614  	}
  2615  	return oldValue.UpdatedAt, nil
  2616  }
  2617  
  2618  // ClearUpdatedAt clears the value of the "updated_at" field.
  2619  func (m *BouncerMutation) ClearUpdatedAt() {
  2620  	m.updated_at = nil
  2621  	m.clearedFields[bouncer.FieldUpdatedAt] = struct{}{}
  2622  }
  2623  
  2624  // UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
  2625  func (m *BouncerMutation) UpdatedAtCleared() bool {
  2626  	_, ok := m.clearedFields[bouncer.FieldUpdatedAt]
  2627  	return ok
  2628  }
  2629  
  2630  // ResetUpdatedAt resets all changes to the "updated_at" field.
  2631  func (m *BouncerMutation) ResetUpdatedAt() {
  2632  	m.updated_at = nil
  2633  	delete(m.clearedFields, bouncer.FieldUpdatedAt)
  2634  }
  2635  
  2636  // SetName sets the "name" field.
  2637  func (m *BouncerMutation) SetName(s string) {
  2638  	m.name = &s
  2639  }
  2640  
  2641  // Name returns the value of the "name" field in the mutation.
  2642  func (m *BouncerMutation) Name() (r string, exists bool) {
  2643  	v := m.name
  2644  	if v == nil {
  2645  		return
  2646  	}
  2647  	return *v, true
  2648  }
  2649  
  2650  // OldName returns the old "name" field's value of the Bouncer entity.
  2651  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2652  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2653  func (m *BouncerMutation) OldName(ctx context.Context) (v string, err error) {
  2654  	if !m.op.Is(OpUpdateOne) {
  2655  		return v, errors.New("OldName is only allowed on UpdateOne operations")
  2656  	}
  2657  	if m.id == nil || m.oldValue == nil {
  2658  		return v, errors.New("OldName requires an ID field in the mutation")
  2659  	}
  2660  	oldValue, err := m.oldValue(ctx)
  2661  	if err != nil {
  2662  		return v, fmt.Errorf("querying old value for OldName: %w", err)
  2663  	}
  2664  	return oldValue.Name, nil
  2665  }
  2666  
  2667  // ResetName resets all changes to the "name" field.
  2668  func (m *BouncerMutation) ResetName() {
  2669  	m.name = nil
  2670  }
  2671  
  2672  // SetAPIKey sets the "api_key" field.
  2673  func (m *BouncerMutation) SetAPIKey(s string) {
  2674  	m.api_key = &s
  2675  }
  2676  
  2677  // APIKey returns the value of the "api_key" field in the mutation.
  2678  func (m *BouncerMutation) APIKey() (r string, exists bool) {
  2679  	v := m.api_key
  2680  	if v == nil {
  2681  		return
  2682  	}
  2683  	return *v, true
  2684  }
  2685  
  2686  // OldAPIKey returns the old "api_key" field's value of the Bouncer entity.
  2687  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2688  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2689  func (m *BouncerMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  2690  	if !m.op.Is(OpUpdateOne) {
  2691  		return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  2692  	}
  2693  	if m.id == nil || m.oldValue == nil {
  2694  		return v, errors.New("OldAPIKey requires an ID field in the mutation")
  2695  	}
  2696  	oldValue, err := m.oldValue(ctx)
  2697  	if err != nil {
  2698  		return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  2699  	}
  2700  	return oldValue.APIKey, nil
  2701  }
  2702  
  2703  // ResetAPIKey resets all changes to the "api_key" field.
  2704  func (m *BouncerMutation) ResetAPIKey() {
  2705  	m.api_key = nil
  2706  }
  2707  
  2708  // SetRevoked sets the "revoked" field.
  2709  func (m *BouncerMutation) SetRevoked(b bool) {
  2710  	m.revoked = &b
  2711  }
  2712  
  2713  // Revoked returns the value of the "revoked" field in the mutation.
  2714  func (m *BouncerMutation) Revoked() (r bool, exists bool) {
  2715  	v := m.revoked
  2716  	if v == nil {
  2717  		return
  2718  	}
  2719  	return *v, true
  2720  }
  2721  
  2722  // OldRevoked returns the old "revoked" field's value of the Bouncer entity.
  2723  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2724  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2725  func (m *BouncerMutation) OldRevoked(ctx context.Context) (v bool, err error) {
  2726  	if !m.op.Is(OpUpdateOne) {
  2727  		return v, errors.New("OldRevoked is only allowed on UpdateOne operations")
  2728  	}
  2729  	if m.id == nil || m.oldValue == nil {
  2730  		return v, errors.New("OldRevoked requires an ID field in the mutation")
  2731  	}
  2732  	oldValue, err := m.oldValue(ctx)
  2733  	if err != nil {
  2734  		return v, fmt.Errorf("querying old value for OldRevoked: %w", err)
  2735  	}
  2736  	return oldValue.Revoked, nil
  2737  }
  2738  
  2739  // ResetRevoked resets all changes to the "revoked" field.
  2740  func (m *BouncerMutation) ResetRevoked() {
  2741  	m.revoked = nil
  2742  }
  2743  
  2744  // SetIPAddress sets the "ip_address" field.
  2745  func (m *BouncerMutation) SetIPAddress(s string) {
  2746  	m.ip_address = &s
  2747  }
  2748  
  2749  // IPAddress returns the value of the "ip_address" field in the mutation.
  2750  func (m *BouncerMutation) IPAddress() (r string, exists bool) {
  2751  	v := m.ip_address
  2752  	if v == nil {
  2753  		return
  2754  	}
  2755  	return *v, true
  2756  }
  2757  
  2758  // OldIPAddress returns the old "ip_address" field's value of the Bouncer entity.
  2759  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2760  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2761  func (m *BouncerMutation) OldIPAddress(ctx context.Context) (v string, err error) {
  2762  	if !m.op.Is(OpUpdateOne) {
  2763  		return v, errors.New("OldIPAddress is only allowed on UpdateOne operations")
  2764  	}
  2765  	if m.id == nil || m.oldValue == nil {
  2766  		return v, errors.New("OldIPAddress requires an ID field in the mutation")
  2767  	}
  2768  	oldValue, err := m.oldValue(ctx)
  2769  	if err != nil {
  2770  		return v, fmt.Errorf("querying old value for OldIPAddress: %w", err)
  2771  	}
  2772  	return oldValue.IPAddress, nil
  2773  }
  2774  
  2775  // ClearIPAddress clears the value of the "ip_address" field.
  2776  func (m *BouncerMutation) ClearIPAddress() {
  2777  	m.ip_address = nil
  2778  	m.clearedFields[bouncer.FieldIPAddress] = struct{}{}
  2779  }
  2780  
  2781  // IPAddressCleared returns if the "ip_address" field was cleared in this mutation.
  2782  func (m *BouncerMutation) IPAddressCleared() bool {
  2783  	_, ok := m.clearedFields[bouncer.FieldIPAddress]
  2784  	return ok
  2785  }
  2786  
  2787  // ResetIPAddress resets all changes to the "ip_address" field.
  2788  func (m *BouncerMutation) ResetIPAddress() {
  2789  	m.ip_address = nil
  2790  	delete(m.clearedFields, bouncer.FieldIPAddress)
  2791  }
  2792  
  2793  // SetType sets the "type" field.
  2794  func (m *BouncerMutation) SetType(s string) {
  2795  	m._type = &s
  2796  }
  2797  
  2798  // GetType returns the value of the "type" field in the mutation.
  2799  func (m *BouncerMutation) GetType() (r string, exists bool) {
  2800  	v := m._type
  2801  	if v == nil {
  2802  		return
  2803  	}
  2804  	return *v, true
  2805  }
  2806  
  2807  // OldType returns the old "type" field's value of the Bouncer entity.
  2808  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2809  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2810  func (m *BouncerMutation) OldType(ctx context.Context) (v string, err error) {
  2811  	if !m.op.Is(OpUpdateOne) {
  2812  		return v, errors.New("OldType is only allowed on UpdateOne operations")
  2813  	}
  2814  	if m.id == nil || m.oldValue == nil {
  2815  		return v, errors.New("OldType requires an ID field in the mutation")
  2816  	}
  2817  	oldValue, err := m.oldValue(ctx)
  2818  	if err != nil {
  2819  		return v, fmt.Errorf("querying old value for OldType: %w", err)
  2820  	}
  2821  	return oldValue.Type, nil
  2822  }
  2823  
  2824  // ClearType clears the value of the "type" field.
  2825  func (m *BouncerMutation) ClearType() {
  2826  	m._type = nil
  2827  	m.clearedFields[bouncer.FieldType] = struct{}{}
  2828  }
  2829  
  2830  // TypeCleared returns if the "type" field was cleared in this mutation.
  2831  func (m *BouncerMutation) TypeCleared() bool {
  2832  	_, ok := m.clearedFields[bouncer.FieldType]
  2833  	return ok
  2834  }
  2835  
  2836  // ResetType resets all changes to the "type" field.
  2837  func (m *BouncerMutation) ResetType() {
  2838  	m._type = nil
  2839  	delete(m.clearedFields, bouncer.FieldType)
  2840  }
  2841  
  2842  // SetVersion sets the "version" field.
  2843  func (m *BouncerMutation) SetVersion(s string) {
  2844  	m.version = &s
  2845  }
  2846  
  2847  // Version returns the value of the "version" field in the mutation.
  2848  func (m *BouncerMutation) Version() (r string, exists bool) {
  2849  	v := m.version
  2850  	if v == nil {
  2851  		return
  2852  	}
  2853  	return *v, true
  2854  }
  2855  
  2856  // OldVersion returns the old "version" field's value of the Bouncer entity.
  2857  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2858  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2859  func (m *BouncerMutation) OldVersion(ctx context.Context) (v string, err error) {
  2860  	if !m.op.Is(OpUpdateOne) {
  2861  		return v, errors.New("OldVersion is only allowed on UpdateOne operations")
  2862  	}
  2863  	if m.id == nil || m.oldValue == nil {
  2864  		return v, errors.New("OldVersion requires an ID field in the mutation")
  2865  	}
  2866  	oldValue, err := m.oldValue(ctx)
  2867  	if err != nil {
  2868  		return v, fmt.Errorf("querying old value for OldVersion: %w", err)
  2869  	}
  2870  	return oldValue.Version, nil
  2871  }
  2872  
  2873  // ClearVersion clears the value of the "version" field.
  2874  func (m *BouncerMutation) ClearVersion() {
  2875  	m.version = nil
  2876  	m.clearedFields[bouncer.FieldVersion] = struct{}{}
  2877  }
  2878  
  2879  // VersionCleared returns if the "version" field was cleared in this mutation.
  2880  func (m *BouncerMutation) VersionCleared() bool {
  2881  	_, ok := m.clearedFields[bouncer.FieldVersion]
  2882  	return ok
  2883  }
  2884  
  2885  // ResetVersion resets all changes to the "version" field.
  2886  func (m *BouncerMutation) ResetVersion() {
  2887  	m.version = nil
  2888  	delete(m.clearedFields, bouncer.FieldVersion)
  2889  }
  2890  
  2891  // SetUntil sets the "until" field.
  2892  func (m *BouncerMutation) SetUntil(t time.Time) {
  2893  	m.until = &t
  2894  }
  2895  
  2896  // Until returns the value of the "until" field in the mutation.
  2897  func (m *BouncerMutation) Until() (r time.Time, exists bool) {
  2898  	v := m.until
  2899  	if v == nil {
  2900  		return
  2901  	}
  2902  	return *v, true
  2903  }
  2904  
  2905  // OldUntil returns the old "until" field's value of the Bouncer entity.
  2906  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2907  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2908  func (m *BouncerMutation) OldUntil(ctx context.Context) (v time.Time, err error) {
  2909  	if !m.op.Is(OpUpdateOne) {
  2910  		return v, errors.New("OldUntil is only allowed on UpdateOne operations")
  2911  	}
  2912  	if m.id == nil || m.oldValue == nil {
  2913  		return v, errors.New("OldUntil requires an ID field in the mutation")
  2914  	}
  2915  	oldValue, err := m.oldValue(ctx)
  2916  	if err != nil {
  2917  		return v, fmt.Errorf("querying old value for OldUntil: %w", err)
  2918  	}
  2919  	return oldValue.Until, nil
  2920  }
  2921  
  2922  // ClearUntil clears the value of the "until" field.
  2923  func (m *BouncerMutation) ClearUntil() {
  2924  	m.until = nil
  2925  	m.clearedFields[bouncer.FieldUntil] = struct{}{}
  2926  }
  2927  
  2928  // UntilCleared returns if the "until" field was cleared in this mutation.
  2929  func (m *BouncerMutation) UntilCleared() bool {
  2930  	_, ok := m.clearedFields[bouncer.FieldUntil]
  2931  	return ok
  2932  }
  2933  
  2934  // ResetUntil resets all changes to the "until" field.
  2935  func (m *BouncerMutation) ResetUntil() {
  2936  	m.until = nil
  2937  	delete(m.clearedFields, bouncer.FieldUntil)
  2938  }
  2939  
  2940  // SetLastPull sets the "last_pull" field.
  2941  func (m *BouncerMutation) SetLastPull(t time.Time) {
  2942  	m.last_pull = &t
  2943  }
  2944  
  2945  // LastPull returns the value of the "last_pull" field in the mutation.
  2946  func (m *BouncerMutation) LastPull() (r time.Time, exists bool) {
  2947  	v := m.last_pull
  2948  	if v == nil {
  2949  		return
  2950  	}
  2951  	return *v, true
  2952  }
  2953  
  2954  // OldLastPull returns the old "last_pull" field's value of the Bouncer entity.
  2955  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2956  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2957  func (m *BouncerMutation) OldLastPull(ctx context.Context) (v time.Time, err error) {
  2958  	if !m.op.Is(OpUpdateOne) {
  2959  		return v, errors.New("OldLastPull is only allowed on UpdateOne operations")
  2960  	}
  2961  	if m.id == nil || m.oldValue == nil {
  2962  		return v, errors.New("OldLastPull requires an ID field in the mutation")
  2963  	}
  2964  	oldValue, err := m.oldValue(ctx)
  2965  	if err != nil {
  2966  		return v, fmt.Errorf("querying old value for OldLastPull: %w", err)
  2967  	}
  2968  	return oldValue.LastPull, nil
  2969  }
  2970  
  2971  // ResetLastPull resets all changes to the "last_pull" field.
  2972  func (m *BouncerMutation) ResetLastPull() {
  2973  	m.last_pull = nil
  2974  }
  2975  
  2976  // SetAuthType sets the "auth_type" field.
  2977  func (m *BouncerMutation) SetAuthType(s string) {
  2978  	m.auth_type = &s
  2979  }
  2980  
  2981  // AuthType returns the value of the "auth_type" field in the mutation.
  2982  func (m *BouncerMutation) AuthType() (r string, exists bool) {
  2983  	v := m.auth_type
  2984  	if v == nil {
  2985  		return
  2986  	}
  2987  	return *v, true
  2988  }
  2989  
  2990  // OldAuthType returns the old "auth_type" field's value of the Bouncer entity.
  2991  // If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
  2992  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2993  func (m *BouncerMutation) OldAuthType(ctx context.Context) (v string, err error) {
  2994  	if !m.op.Is(OpUpdateOne) {
  2995  		return v, errors.New("OldAuthType is only allowed on UpdateOne operations")
  2996  	}
  2997  	if m.id == nil || m.oldValue == nil {
  2998  		return v, errors.New("OldAuthType requires an ID field in the mutation")
  2999  	}
  3000  	oldValue, err := m.oldValue(ctx)
  3001  	if err != nil {
  3002  		return v, fmt.Errorf("querying old value for OldAuthType: %w", err)
  3003  	}
  3004  	return oldValue.AuthType, nil
  3005  }
  3006  
  3007  // ResetAuthType resets all changes to the "auth_type" field.
  3008  func (m *BouncerMutation) ResetAuthType() {
  3009  	m.auth_type = nil
  3010  }
  3011  
  3012  // Where appends a list predicates to the BouncerMutation builder.
  3013  func (m *BouncerMutation) Where(ps ...predicate.Bouncer) {
  3014  	m.predicates = append(m.predicates, ps...)
  3015  }
  3016  
  3017  // WhereP appends storage-level predicates to the BouncerMutation builder. Using this method,
  3018  // users can use type-assertion to append predicates that do not depend on any generated package.
  3019  func (m *BouncerMutation) WhereP(ps ...func(*sql.Selector)) {
  3020  	p := make([]predicate.Bouncer, len(ps))
  3021  	for i := range ps {
  3022  		p[i] = ps[i]
  3023  	}
  3024  	m.Where(p...)
  3025  }
  3026  
  3027  // Op returns the operation name.
  3028  func (m *BouncerMutation) Op() Op {
  3029  	return m.op
  3030  }
  3031  
  3032  // SetOp allows setting the mutation operation.
  3033  func (m *BouncerMutation) SetOp(op Op) {
  3034  	m.op = op
  3035  }
  3036  
  3037  // Type returns the node type of this mutation (Bouncer).
  3038  func (m *BouncerMutation) Type() string {
  3039  	return m.typ
  3040  }
  3041  
  3042  // Fields returns all fields that were changed during this mutation. Note that in
  3043  // order to get all numeric fields that were incremented/decremented, call
  3044  // AddedFields().
  3045  func (m *BouncerMutation) Fields() []string {
  3046  	fields := make([]string, 0, 11)
  3047  	if m.created_at != nil {
  3048  		fields = append(fields, bouncer.FieldCreatedAt)
  3049  	}
  3050  	if m.updated_at != nil {
  3051  		fields = append(fields, bouncer.FieldUpdatedAt)
  3052  	}
  3053  	if m.name != nil {
  3054  		fields = append(fields, bouncer.FieldName)
  3055  	}
  3056  	if m.api_key != nil {
  3057  		fields = append(fields, bouncer.FieldAPIKey)
  3058  	}
  3059  	if m.revoked != nil {
  3060  		fields = append(fields, bouncer.FieldRevoked)
  3061  	}
  3062  	if m.ip_address != nil {
  3063  		fields = append(fields, bouncer.FieldIPAddress)
  3064  	}
  3065  	if m._type != nil {
  3066  		fields = append(fields, bouncer.FieldType)
  3067  	}
  3068  	if m.version != nil {
  3069  		fields = append(fields, bouncer.FieldVersion)
  3070  	}
  3071  	if m.until != nil {
  3072  		fields = append(fields, bouncer.FieldUntil)
  3073  	}
  3074  	if m.last_pull != nil {
  3075  		fields = append(fields, bouncer.FieldLastPull)
  3076  	}
  3077  	if m.auth_type != nil {
  3078  		fields = append(fields, bouncer.FieldAuthType)
  3079  	}
  3080  	return fields
  3081  }
  3082  
  3083  // Field returns the value of a field with the given name. The second boolean
  3084  // return value indicates that this field was not set, or was not defined in the
  3085  // schema.
  3086  func (m *BouncerMutation) Field(name string) (ent.Value, bool) {
  3087  	switch name {
  3088  	case bouncer.FieldCreatedAt:
  3089  		return m.CreatedAt()
  3090  	case bouncer.FieldUpdatedAt:
  3091  		return m.UpdatedAt()
  3092  	case bouncer.FieldName:
  3093  		return m.Name()
  3094  	case bouncer.FieldAPIKey:
  3095  		return m.APIKey()
  3096  	case bouncer.FieldRevoked:
  3097  		return m.Revoked()
  3098  	case bouncer.FieldIPAddress:
  3099  		return m.IPAddress()
  3100  	case bouncer.FieldType:
  3101  		return m.GetType()
  3102  	case bouncer.FieldVersion:
  3103  		return m.Version()
  3104  	case bouncer.FieldUntil:
  3105  		return m.Until()
  3106  	case bouncer.FieldLastPull:
  3107  		return m.LastPull()
  3108  	case bouncer.FieldAuthType:
  3109  		return m.AuthType()
  3110  	}
  3111  	return nil, false
  3112  }
  3113  
  3114  // OldField returns the old value of the field from the database. An error is
  3115  // returned if the mutation operation is not UpdateOne, or the query to the
  3116  // database failed.
  3117  func (m *BouncerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3118  	switch name {
  3119  	case bouncer.FieldCreatedAt:
  3120  		return m.OldCreatedAt(ctx)
  3121  	case bouncer.FieldUpdatedAt:
  3122  		return m.OldUpdatedAt(ctx)
  3123  	case bouncer.FieldName:
  3124  		return m.OldName(ctx)
  3125  	case bouncer.FieldAPIKey:
  3126  		return m.OldAPIKey(ctx)
  3127  	case bouncer.FieldRevoked:
  3128  		return m.OldRevoked(ctx)
  3129  	case bouncer.FieldIPAddress:
  3130  		return m.OldIPAddress(ctx)
  3131  	case bouncer.FieldType:
  3132  		return m.OldType(ctx)
  3133  	case bouncer.FieldVersion:
  3134  		return m.OldVersion(ctx)
  3135  	case bouncer.FieldUntil:
  3136  		return m.OldUntil(ctx)
  3137  	case bouncer.FieldLastPull:
  3138  		return m.OldLastPull(ctx)
  3139  	case bouncer.FieldAuthType:
  3140  		return m.OldAuthType(ctx)
  3141  	}
  3142  	return nil, fmt.Errorf("unknown Bouncer field %s", name)
  3143  }
  3144  
  3145  // SetField sets the value of a field with the given name. It returns an error if
  3146  // the field is not defined in the schema, or if the type mismatched the field
  3147  // type.
  3148  func (m *BouncerMutation) SetField(name string, value ent.Value) error {
  3149  	switch name {
  3150  	case bouncer.FieldCreatedAt:
  3151  		v, ok := value.(time.Time)
  3152  		if !ok {
  3153  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3154  		}
  3155  		m.SetCreatedAt(v)
  3156  		return nil
  3157  	case bouncer.FieldUpdatedAt:
  3158  		v, ok := value.(time.Time)
  3159  		if !ok {
  3160  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3161  		}
  3162  		m.SetUpdatedAt(v)
  3163  		return nil
  3164  	case bouncer.FieldName:
  3165  		v, ok := value.(string)
  3166  		if !ok {
  3167  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3168  		}
  3169  		m.SetName(v)
  3170  		return nil
  3171  	case bouncer.FieldAPIKey:
  3172  		v, ok := value.(string)
  3173  		if !ok {
  3174  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3175  		}
  3176  		m.SetAPIKey(v)
  3177  		return nil
  3178  	case bouncer.FieldRevoked:
  3179  		v, ok := value.(bool)
  3180  		if !ok {
  3181  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3182  		}
  3183  		m.SetRevoked(v)
  3184  		return nil
  3185  	case bouncer.FieldIPAddress:
  3186  		v, ok := value.(string)
  3187  		if !ok {
  3188  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3189  		}
  3190  		m.SetIPAddress(v)
  3191  		return nil
  3192  	case bouncer.FieldType:
  3193  		v, ok := value.(string)
  3194  		if !ok {
  3195  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3196  		}
  3197  		m.SetType(v)
  3198  		return nil
  3199  	case bouncer.FieldVersion:
  3200  		v, ok := value.(string)
  3201  		if !ok {
  3202  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3203  		}
  3204  		m.SetVersion(v)
  3205  		return nil
  3206  	case bouncer.FieldUntil:
  3207  		v, ok := value.(time.Time)
  3208  		if !ok {
  3209  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3210  		}
  3211  		m.SetUntil(v)
  3212  		return nil
  3213  	case bouncer.FieldLastPull:
  3214  		v, ok := value.(time.Time)
  3215  		if !ok {
  3216  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3217  		}
  3218  		m.SetLastPull(v)
  3219  		return nil
  3220  	case bouncer.FieldAuthType:
  3221  		v, ok := value.(string)
  3222  		if !ok {
  3223  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3224  		}
  3225  		m.SetAuthType(v)
  3226  		return nil
  3227  	}
  3228  	return fmt.Errorf("unknown Bouncer field %s", name)
  3229  }
  3230  
  3231  // AddedFields returns all numeric fields that were incremented/decremented during
  3232  // this mutation.
  3233  func (m *BouncerMutation) AddedFields() []string {
  3234  	return nil
  3235  }
  3236  
  3237  // AddedField returns the numeric value that was incremented/decremented on a field
  3238  // with the given name. The second boolean return value indicates that this field
  3239  // was not set, or was not defined in the schema.
  3240  func (m *BouncerMutation) AddedField(name string) (ent.Value, bool) {
  3241  	return nil, false
  3242  }
  3243  
  3244  // AddField adds the value to the field with the given name. It returns an error if
  3245  // the field is not defined in the schema, or if the type mismatched the field
  3246  // type.
  3247  func (m *BouncerMutation) AddField(name string, value ent.Value) error {
  3248  	switch name {
  3249  	}
  3250  	return fmt.Errorf("unknown Bouncer numeric field %s", name)
  3251  }
  3252  
  3253  // ClearedFields returns all nullable fields that were cleared during this
  3254  // mutation.
  3255  func (m *BouncerMutation) ClearedFields() []string {
  3256  	var fields []string
  3257  	if m.FieldCleared(bouncer.FieldCreatedAt) {
  3258  		fields = append(fields, bouncer.FieldCreatedAt)
  3259  	}
  3260  	if m.FieldCleared(bouncer.FieldUpdatedAt) {
  3261  		fields = append(fields, bouncer.FieldUpdatedAt)
  3262  	}
  3263  	if m.FieldCleared(bouncer.FieldIPAddress) {
  3264  		fields = append(fields, bouncer.FieldIPAddress)
  3265  	}
  3266  	if m.FieldCleared(bouncer.FieldType) {
  3267  		fields = append(fields, bouncer.FieldType)
  3268  	}
  3269  	if m.FieldCleared(bouncer.FieldVersion) {
  3270  		fields = append(fields, bouncer.FieldVersion)
  3271  	}
  3272  	if m.FieldCleared(bouncer.FieldUntil) {
  3273  		fields = append(fields, bouncer.FieldUntil)
  3274  	}
  3275  	return fields
  3276  }
  3277  
  3278  // FieldCleared returns a boolean indicating if a field with the given name was
  3279  // cleared in this mutation.
  3280  func (m *BouncerMutation) FieldCleared(name string) bool {
  3281  	_, ok := m.clearedFields[name]
  3282  	return ok
  3283  }
  3284  
  3285  // ClearField clears the value of the field with the given name. It returns an
  3286  // error if the field is not defined in the schema.
  3287  func (m *BouncerMutation) ClearField(name string) error {
  3288  	switch name {
  3289  	case bouncer.FieldCreatedAt:
  3290  		m.ClearCreatedAt()
  3291  		return nil
  3292  	case bouncer.FieldUpdatedAt:
  3293  		m.ClearUpdatedAt()
  3294  		return nil
  3295  	case bouncer.FieldIPAddress:
  3296  		m.ClearIPAddress()
  3297  		return nil
  3298  	case bouncer.FieldType:
  3299  		m.ClearType()
  3300  		return nil
  3301  	case bouncer.FieldVersion:
  3302  		m.ClearVersion()
  3303  		return nil
  3304  	case bouncer.FieldUntil:
  3305  		m.ClearUntil()
  3306  		return nil
  3307  	}
  3308  	return fmt.Errorf("unknown Bouncer nullable field %s", name)
  3309  }
  3310  
  3311  // ResetField resets all changes in the mutation for the field with the given name.
  3312  // It returns an error if the field is not defined in the schema.
  3313  func (m *BouncerMutation) ResetField(name string) error {
  3314  	switch name {
  3315  	case bouncer.FieldCreatedAt:
  3316  		m.ResetCreatedAt()
  3317  		return nil
  3318  	case bouncer.FieldUpdatedAt:
  3319  		m.ResetUpdatedAt()
  3320  		return nil
  3321  	case bouncer.FieldName:
  3322  		m.ResetName()
  3323  		return nil
  3324  	case bouncer.FieldAPIKey:
  3325  		m.ResetAPIKey()
  3326  		return nil
  3327  	case bouncer.FieldRevoked:
  3328  		m.ResetRevoked()
  3329  		return nil
  3330  	case bouncer.FieldIPAddress:
  3331  		m.ResetIPAddress()
  3332  		return nil
  3333  	case bouncer.FieldType:
  3334  		m.ResetType()
  3335  		return nil
  3336  	case bouncer.FieldVersion:
  3337  		m.ResetVersion()
  3338  		return nil
  3339  	case bouncer.FieldUntil:
  3340  		m.ResetUntil()
  3341  		return nil
  3342  	case bouncer.FieldLastPull:
  3343  		m.ResetLastPull()
  3344  		return nil
  3345  	case bouncer.FieldAuthType:
  3346  		m.ResetAuthType()
  3347  		return nil
  3348  	}
  3349  	return fmt.Errorf("unknown Bouncer field %s", name)
  3350  }
  3351  
  3352  // AddedEdges returns all edge names that were set/added in this mutation.
  3353  func (m *BouncerMutation) AddedEdges() []string {
  3354  	edges := make([]string, 0, 0)
  3355  	return edges
  3356  }
  3357  
  3358  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3359  // name in this mutation.
  3360  func (m *BouncerMutation) AddedIDs(name string) []ent.Value {
  3361  	return nil
  3362  }
  3363  
  3364  // RemovedEdges returns all edge names that were removed in this mutation.
  3365  func (m *BouncerMutation) RemovedEdges() []string {
  3366  	edges := make([]string, 0, 0)
  3367  	return edges
  3368  }
  3369  
  3370  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3371  // the given name in this mutation.
  3372  func (m *BouncerMutation) RemovedIDs(name string) []ent.Value {
  3373  	return nil
  3374  }
  3375  
  3376  // ClearedEdges returns all edge names that were cleared in this mutation.
  3377  func (m *BouncerMutation) ClearedEdges() []string {
  3378  	edges := make([]string, 0, 0)
  3379  	return edges
  3380  }
  3381  
  3382  // EdgeCleared returns a boolean which indicates if the edge with the given name
  3383  // was cleared in this mutation.
  3384  func (m *BouncerMutation) EdgeCleared(name string) bool {
  3385  	return false
  3386  }
  3387  
  3388  // ClearEdge clears the value of the edge with the given name. It returns an error
  3389  // if that edge is not defined in the schema.
  3390  func (m *BouncerMutation) ClearEdge(name string) error {
  3391  	return fmt.Errorf("unknown Bouncer unique edge %s", name)
  3392  }
  3393  
  3394  // ResetEdge resets all changes to the edge with the given name in this mutation.
  3395  // It returns an error if the edge is not defined in the schema.
  3396  func (m *BouncerMutation) ResetEdge(name string) error {
  3397  	return fmt.Errorf("unknown Bouncer edge %s", name)
  3398  }
  3399  
  3400  // ConfigItemMutation represents an operation that mutates the ConfigItem nodes in the graph.
  3401  type ConfigItemMutation struct {
  3402  	config
  3403  	op            Op
  3404  	typ           string
  3405  	id            *int
  3406  	created_at    *time.Time
  3407  	updated_at    *time.Time
  3408  	name          *string
  3409  	value         *string
  3410  	clearedFields map[string]struct{}
  3411  	done          bool
  3412  	oldValue      func(context.Context) (*ConfigItem, error)
  3413  	predicates    []predicate.ConfigItem
  3414  }
  3415  
  3416  var _ ent.Mutation = (*ConfigItemMutation)(nil)
  3417  
  3418  // configitemOption allows management of the mutation configuration using functional options.
  3419  type configitemOption func(*ConfigItemMutation)
  3420  
  3421  // newConfigItemMutation creates new mutation for the ConfigItem entity.
  3422  func newConfigItemMutation(c config, op Op, opts ...configitemOption) *ConfigItemMutation {
  3423  	m := &ConfigItemMutation{
  3424  		config:        c,
  3425  		op:            op,
  3426  		typ:           TypeConfigItem,
  3427  		clearedFields: make(map[string]struct{}),
  3428  	}
  3429  	for _, opt := range opts {
  3430  		opt(m)
  3431  	}
  3432  	return m
  3433  }
  3434  
  3435  // withConfigItemID sets the ID field of the mutation.
  3436  func withConfigItemID(id int) configitemOption {
  3437  	return func(m *ConfigItemMutation) {
  3438  		var (
  3439  			err   error
  3440  			once  sync.Once
  3441  			value *ConfigItem
  3442  		)
  3443  		m.oldValue = func(ctx context.Context) (*ConfigItem, error) {
  3444  			once.Do(func() {
  3445  				if m.done {
  3446  					err = errors.New("querying old values post mutation is not allowed")
  3447  				} else {
  3448  					value, err = m.Client().ConfigItem.Get(ctx, id)
  3449  				}
  3450  			})
  3451  			return value, err
  3452  		}
  3453  		m.id = &id
  3454  	}
  3455  }
  3456  
  3457  // withConfigItem sets the old ConfigItem of the mutation.
  3458  func withConfigItem(node *ConfigItem) configitemOption {
  3459  	return func(m *ConfigItemMutation) {
  3460  		m.oldValue = func(context.Context) (*ConfigItem, error) {
  3461  			return node, nil
  3462  		}
  3463  		m.id = &node.ID
  3464  	}
  3465  }
  3466  
  3467  // Client returns a new `ent.Client` from the mutation. If the mutation was
  3468  // executed in a transaction (ent.Tx), a transactional client is returned.
  3469  func (m ConfigItemMutation) Client() *Client {
  3470  	client := &Client{config: m.config}
  3471  	client.init()
  3472  	return client
  3473  }
  3474  
  3475  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3476  // it returns an error otherwise.
  3477  func (m ConfigItemMutation) Tx() (*Tx, error) {
  3478  	if _, ok := m.driver.(*txDriver); !ok {
  3479  		return nil, errors.New("ent: mutation is not running in a transaction")
  3480  	}
  3481  	tx := &Tx{config: m.config}
  3482  	tx.init()
  3483  	return tx, nil
  3484  }
  3485  
  3486  // ID returns the ID value in the mutation. Note that the ID is only available
  3487  // if it was provided to the builder or after it was returned from the database.
  3488  func (m *ConfigItemMutation) ID() (id int, exists bool) {
  3489  	if m.id == nil {
  3490  		return
  3491  	}
  3492  	return *m.id, true
  3493  }
  3494  
  3495  // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3496  // That means, if the mutation is applied within a transaction with an isolation level such
  3497  // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3498  // or updated by the mutation.
  3499  func (m *ConfigItemMutation) IDs(ctx context.Context) ([]int, error) {
  3500  	switch {
  3501  	case m.op.Is(OpUpdateOne | OpDeleteOne):
  3502  		id, exists := m.ID()
  3503  		if exists {
  3504  			return []int{id}, nil
  3505  		}
  3506  		fallthrough
  3507  	case m.op.Is(OpUpdate | OpDelete):
  3508  		return m.Client().ConfigItem.Query().Where(m.predicates...).IDs(ctx)
  3509  	default:
  3510  		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3511  	}
  3512  }
  3513  
  3514  // SetCreatedAt sets the "created_at" field.
  3515  func (m *ConfigItemMutation) SetCreatedAt(t time.Time) {
  3516  	m.created_at = &t
  3517  }
  3518  
  3519  // CreatedAt returns the value of the "created_at" field in the mutation.
  3520  func (m *ConfigItemMutation) CreatedAt() (r time.Time, exists bool) {
  3521  	v := m.created_at
  3522  	if v == nil {
  3523  		return
  3524  	}
  3525  	return *v, true
  3526  }
  3527  
  3528  // OldCreatedAt returns the old "created_at" field's value of the ConfigItem entity.
  3529  // If the ConfigItem object wasn't provided to the builder, the object is fetched from the database.
  3530  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3531  func (m *ConfigItemMutation) OldCreatedAt(ctx context.Context) (v *time.Time, err error) {
  3532  	if !m.op.Is(OpUpdateOne) {
  3533  		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3534  	}
  3535  	if m.id == nil || m.oldValue == nil {
  3536  		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3537  	}
  3538  	oldValue, err := m.oldValue(ctx)
  3539  	if err != nil {
  3540  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3541  	}
  3542  	return oldValue.CreatedAt, nil
  3543  }
  3544  
  3545  // ClearCreatedAt clears the value of the "created_at" field.
  3546  func (m *ConfigItemMutation) ClearCreatedAt() {
  3547  	m.created_at = nil
  3548  	m.clearedFields[configitem.FieldCreatedAt] = struct{}{}
  3549  }
  3550  
  3551  // CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
  3552  func (m *ConfigItemMutation) CreatedAtCleared() bool {
  3553  	_, ok := m.clearedFields[configitem.FieldCreatedAt]
  3554  	return ok
  3555  }
  3556  
  3557  // ResetCreatedAt resets all changes to the "created_at" field.
  3558  func (m *ConfigItemMutation) ResetCreatedAt() {
  3559  	m.created_at = nil
  3560  	delete(m.clearedFields, configitem.FieldCreatedAt)
  3561  }
  3562  
  3563  // SetUpdatedAt sets the "updated_at" field.
  3564  func (m *ConfigItemMutation) SetUpdatedAt(t time.Time) {
  3565  	m.updated_at = &t
  3566  }
  3567  
  3568  // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3569  func (m *ConfigItemMutation) UpdatedAt() (r time.Time, exists bool) {
  3570  	v := m.updated_at
  3571  	if v == nil {
  3572  		return
  3573  	}
  3574  	return *v, true
  3575  }
  3576  
  3577  // OldUpdatedAt returns the old "updated_at" field's value of the ConfigItem entity.
  3578  // If the ConfigItem object wasn't provided to the builder, the object is fetched from the database.
  3579  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3580  func (m *ConfigItemMutation) OldUpdatedAt(ctx context.Context) (v *time.Time, err error) {
  3581  	if !m.op.Is(OpUpdateOne) {
  3582  		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3583  	}
  3584  	if m.id == nil || m.oldValue == nil {
  3585  		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3586  	}
  3587  	oldValue, err := m.oldValue(ctx)
  3588  	if err != nil {
  3589  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3590  	}
  3591  	return oldValue.UpdatedAt, nil
  3592  }
  3593  
  3594  // ClearUpdatedAt clears the value of the "updated_at" field.
  3595  func (m *ConfigItemMutation) ClearUpdatedAt() {
  3596  	m.updated_at = nil
  3597  	m.clearedFields[configitem.FieldUpdatedAt] = struct{}{}
  3598  }
  3599  
  3600  // UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
  3601  func (m *ConfigItemMutation) UpdatedAtCleared() bool {
  3602  	_, ok := m.clearedFields[configitem.FieldUpdatedAt]
  3603  	return ok
  3604  }
  3605  
  3606  // ResetUpdatedAt resets all changes to the "updated_at" field.
  3607  func (m *ConfigItemMutation) ResetUpdatedAt() {
  3608  	m.updated_at = nil
  3609  	delete(m.clearedFields, configitem.FieldUpdatedAt)
  3610  }
  3611  
  3612  // SetName sets the "name" field.
  3613  func (m *ConfigItemMutation) SetName(s string) {
  3614  	m.name = &s
  3615  }
  3616  
  3617  // Name returns the value of the "name" field in the mutation.
  3618  func (m *ConfigItemMutation) Name() (r string, exists bool) {
  3619  	v := m.name
  3620  	if v == nil {
  3621  		return
  3622  	}
  3623  	return *v, true
  3624  }
  3625  
  3626  // OldName returns the old "name" field's value of the ConfigItem entity.
  3627  // If the ConfigItem object wasn't provided to the builder, the object is fetched from the database.
  3628  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3629  func (m *ConfigItemMutation) OldName(ctx context.Context) (v string, err error) {
  3630  	if !m.op.Is(OpUpdateOne) {
  3631  		return v, errors.New("OldName is only allowed on UpdateOne operations")
  3632  	}
  3633  	if m.id == nil || m.oldValue == nil {
  3634  		return v, errors.New("OldName requires an ID field in the mutation")
  3635  	}
  3636  	oldValue, err := m.oldValue(ctx)
  3637  	if err != nil {
  3638  		return v, fmt.Errorf("querying old value for OldName: %w", err)
  3639  	}
  3640  	return oldValue.Name, nil
  3641  }
  3642  
  3643  // ResetName resets all changes to the "name" field.
  3644  func (m *ConfigItemMutation) ResetName() {
  3645  	m.name = nil
  3646  }
  3647  
  3648  // SetValue sets the "value" field.
  3649  func (m *ConfigItemMutation) SetValue(s string) {
  3650  	m.value = &s
  3651  }
  3652  
  3653  // Value returns the value of the "value" field in the mutation.
  3654  func (m *ConfigItemMutation) Value() (r string, exists bool) {
  3655  	v := m.value
  3656  	if v == nil {
  3657  		return
  3658  	}
  3659  	return *v, true
  3660  }
  3661  
  3662  // OldValue returns the old "value" field's value of the ConfigItem entity.
  3663  // If the ConfigItem object wasn't provided to the builder, the object is fetched from the database.
  3664  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3665  func (m *ConfigItemMutation) OldValue(ctx context.Context) (v string, err error) {
  3666  	if !m.op.Is(OpUpdateOne) {
  3667  		return v, errors.New("OldValue is only allowed on UpdateOne operations")
  3668  	}
  3669  	if m.id == nil || m.oldValue == nil {
  3670  		return v, errors.New("OldValue requires an ID field in the mutation")
  3671  	}
  3672  	oldValue, err := m.oldValue(ctx)
  3673  	if err != nil {
  3674  		return v, fmt.Errorf("querying old value for OldValue: %w", err)
  3675  	}
  3676  	return oldValue.Value, nil
  3677  }
  3678  
  3679  // ResetValue resets all changes to the "value" field.
  3680  func (m *ConfigItemMutation) ResetValue() {
  3681  	m.value = nil
  3682  }
  3683  
  3684  // Where appends a list predicates to the ConfigItemMutation builder.
  3685  func (m *ConfigItemMutation) Where(ps ...predicate.ConfigItem) {
  3686  	m.predicates = append(m.predicates, ps...)
  3687  }
  3688  
  3689  // WhereP appends storage-level predicates to the ConfigItemMutation builder. Using this method,
  3690  // users can use type-assertion to append predicates that do not depend on any generated package.
  3691  func (m *ConfigItemMutation) WhereP(ps ...func(*sql.Selector)) {
  3692  	p := make([]predicate.ConfigItem, len(ps))
  3693  	for i := range ps {
  3694  		p[i] = ps[i]
  3695  	}
  3696  	m.Where(p...)
  3697  }
  3698  
  3699  // Op returns the operation name.
  3700  func (m *ConfigItemMutation) Op() Op {
  3701  	return m.op
  3702  }
  3703  
  3704  // SetOp allows setting the mutation operation.
  3705  func (m *ConfigItemMutation) SetOp(op Op) {
  3706  	m.op = op
  3707  }
  3708  
  3709  // Type returns the node type of this mutation (ConfigItem).
  3710  func (m *ConfigItemMutation) Type() string {
  3711  	return m.typ
  3712  }
  3713  
  3714  // Fields returns all fields that were changed during this mutation. Note that in
  3715  // order to get all numeric fields that were incremented/decremented, call
  3716  // AddedFields().
  3717  func (m *ConfigItemMutation) Fields() []string {
  3718  	fields := make([]string, 0, 4)
  3719  	if m.created_at != nil {
  3720  		fields = append(fields, configitem.FieldCreatedAt)
  3721  	}
  3722  	if m.updated_at != nil {
  3723  		fields = append(fields, configitem.FieldUpdatedAt)
  3724  	}
  3725  	if m.name != nil {
  3726  		fields = append(fields, configitem.FieldName)
  3727  	}
  3728  	if m.value != nil {
  3729  		fields = append(fields, configitem.FieldValue)
  3730  	}
  3731  	return fields
  3732  }
  3733  
  3734  // Field returns the value of a field with the given name. The second boolean
  3735  // return value indicates that this field was not set, or was not defined in the
  3736  // schema.
  3737  func (m *ConfigItemMutation) Field(name string) (ent.Value, bool) {
  3738  	switch name {
  3739  	case configitem.FieldCreatedAt:
  3740  		return m.CreatedAt()
  3741  	case configitem.FieldUpdatedAt:
  3742  		return m.UpdatedAt()
  3743  	case configitem.FieldName:
  3744  		return m.Name()
  3745  	case configitem.FieldValue:
  3746  		return m.Value()
  3747  	}
  3748  	return nil, false
  3749  }
  3750  
  3751  // OldField returns the old value of the field from the database. An error is
  3752  // returned if the mutation operation is not UpdateOne, or the query to the
  3753  // database failed.
  3754  func (m *ConfigItemMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3755  	switch name {
  3756  	case configitem.FieldCreatedAt:
  3757  		return m.OldCreatedAt(ctx)
  3758  	case configitem.FieldUpdatedAt:
  3759  		return m.OldUpdatedAt(ctx)
  3760  	case configitem.FieldName:
  3761  		return m.OldName(ctx)
  3762  	case configitem.FieldValue:
  3763  		return m.OldValue(ctx)
  3764  	}
  3765  	return nil, fmt.Errorf("unknown ConfigItem field %s", name)
  3766  }
  3767  
  3768  // SetField sets the value of a field with the given name. It returns an error if
  3769  // the field is not defined in the schema, or if the type mismatched the field
  3770  // type.
  3771  func (m *ConfigItemMutation) SetField(name string, value ent.Value) error {
  3772  	switch name {
  3773  	case configitem.FieldCreatedAt:
  3774  		v, ok := value.(time.Time)
  3775  		if !ok {
  3776  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3777  		}
  3778  		m.SetCreatedAt(v)
  3779  		return nil
  3780  	case configitem.FieldUpdatedAt:
  3781  		v, ok := value.(time.Time)
  3782  		if !ok {
  3783  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3784  		}
  3785  		m.SetUpdatedAt(v)
  3786  		return nil
  3787  	case configitem.FieldName:
  3788  		v, ok := value.(string)
  3789  		if !ok {
  3790  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3791  		}
  3792  		m.SetName(v)
  3793  		return nil
  3794  	case configitem.FieldValue:
  3795  		v, ok := value.(string)
  3796  		if !ok {
  3797  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  3798  		}
  3799  		m.SetValue(v)
  3800  		return nil
  3801  	}
  3802  	return fmt.Errorf("unknown ConfigItem field %s", name)
  3803  }
  3804  
  3805  // AddedFields returns all numeric fields that were incremented/decremented during
  3806  // this mutation.
  3807  func (m *ConfigItemMutation) AddedFields() []string {
  3808  	return nil
  3809  }
  3810  
  3811  // AddedField returns the numeric value that was incremented/decremented on a field
  3812  // with the given name. The second boolean return value indicates that this field
  3813  // was not set, or was not defined in the schema.
  3814  func (m *ConfigItemMutation) AddedField(name string) (ent.Value, bool) {
  3815  	return nil, false
  3816  }
  3817  
  3818  // AddField adds the value to the field with the given name. It returns an error if
  3819  // the field is not defined in the schema, or if the type mismatched the field
  3820  // type.
  3821  func (m *ConfigItemMutation) AddField(name string, value ent.Value) error {
  3822  	switch name {
  3823  	}
  3824  	return fmt.Errorf("unknown ConfigItem numeric field %s", name)
  3825  }
  3826  
  3827  // ClearedFields returns all nullable fields that were cleared during this
  3828  // mutation.
  3829  func (m *ConfigItemMutation) ClearedFields() []string {
  3830  	var fields []string
  3831  	if m.FieldCleared(configitem.FieldCreatedAt) {
  3832  		fields = append(fields, configitem.FieldCreatedAt)
  3833  	}
  3834  	if m.FieldCleared(configitem.FieldUpdatedAt) {
  3835  		fields = append(fields, configitem.FieldUpdatedAt)
  3836  	}
  3837  	return fields
  3838  }
  3839  
  3840  // FieldCleared returns a boolean indicating if a field with the given name was
  3841  // cleared in this mutation.
  3842  func (m *ConfigItemMutation) FieldCleared(name string) bool {
  3843  	_, ok := m.clearedFields[name]
  3844  	return ok
  3845  }
  3846  
  3847  // ClearField clears the value of the field with the given name. It returns an
  3848  // error if the field is not defined in the schema.
  3849  func (m *ConfigItemMutation) ClearField(name string) error {
  3850  	switch name {
  3851  	case configitem.FieldCreatedAt:
  3852  		m.ClearCreatedAt()
  3853  		return nil
  3854  	case configitem.FieldUpdatedAt:
  3855  		m.ClearUpdatedAt()
  3856  		return nil
  3857  	}
  3858  	return fmt.Errorf("unknown ConfigItem nullable field %s", name)
  3859  }
  3860  
  3861  // ResetField resets all changes in the mutation for the field with the given name.
  3862  // It returns an error if the field is not defined in the schema.
  3863  func (m *ConfigItemMutation) ResetField(name string) error {
  3864  	switch name {
  3865  	case configitem.FieldCreatedAt:
  3866  		m.ResetCreatedAt()
  3867  		return nil
  3868  	case configitem.FieldUpdatedAt:
  3869  		m.ResetUpdatedAt()
  3870  		return nil
  3871  	case configitem.FieldName:
  3872  		m.ResetName()
  3873  		return nil
  3874  	case configitem.FieldValue:
  3875  		m.ResetValue()
  3876  		return nil
  3877  	}
  3878  	return fmt.Errorf("unknown ConfigItem field %s", name)
  3879  }
  3880  
  3881  // AddedEdges returns all edge names that were set/added in this mutation.
  3882  func (m *ConfigItemMutation) AddedEdges() []string {
  3883  	edges := make([]string, 0, 0)
  3884  	return edges
  3885  }
  3886  
  3887  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3888  // name in this mutation.
  3889  func (m *ConfigItemMutation) AddedIDs(name string) []ent.Value {
  3890  	return nil
  3891  }
  3892  
  3893  // RemovedEdges returns all edge names that were removed in this mutation.
  3894  func (m *ConfigItemMutation) RemovedEdges() []string {
  3895  	edges := make([]string, 0, 0)
  3896  	return edges
  3897  }
  3898  
  3899  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3900  // the given name in this mutation.
  3901  func (m *ConfigItemMutation) RemovedIDs(name string) []ent.Value {
  3902  	return nil
  3903  }
  3904  
  3905  // ClearedEdges returns all edge names that were cleared in this mutation.
  3906  func (m *ConfigItemMutation) ClearedEdges() []string {
  3907  	edges := make([]string, 0, 0)
  3908  	return edges
  3909  }
  3910  
  3911  // EdgeCleared returns a boolean which indicates if the edge with the given name
  3912  // was cleared in this mutation.
  3913  func (m *ConfigItemMutation) EdgeCleared(name string) bool {
  3914  	return false
  3915  }
  3916  
  3917  // ClearEdge clears the value of the edge with the given name. It returns an error
  3918  // if that edge is not defined in the schema.
  3919  func (m *ConfigItemMutation) ClearEdge(name string) error {
  3920  	return fmt.Errorf("unknown ConfigItem unique edge %s", name)
  3921  }
  3922  
  3923  // ResetEdge resets all changes to the edge with the given name in this mutation.
  3924  // It returns an error if the edge is not defined in the schema.
  3925  func (m *ConfigItemMutation) ResetEdge(name string) error {
  3926  	return fmt.Errorf("unknown ConfigItem edge %s", name)
  3927  }
  3928  
  3929  // DecisionMutation represents an operation that mutates the Decision nodes in the graph.
  3930  type DecisionMutation struct {
  3931  	config
  3932  	op              Op
  3933  	typ             string
  3934  	id              *int
  3935  	created_at      *time.Time
  3936  	updated_at      *time.Time
  3937  	until           *time.Time
  3938  	scenario        *string
  3939  	_type           *string
  3940  	start_ip        *int64
  3941  	addstart_ip     *int64
  3942  	end_ip          *int64
  3943  	addend_ip       *int64
  3944  	start_suffix    *int64
  3945  	addstart_suffix *int64
  3946  	end_suffix      *int64
  3947  	addend_suffix   *int64
  3948  	ip_size         *int64
  3949  	addip_size      *int64
  3950  	scope           *string
  3951  	value           *string
  3952  	origin          *string
  3953  	simulated       *bool
  3954  	uuid            *string
  3955  	clearedFields   map[string]struct{}
  3956  	owner           *int
  3957  	clearedowner    bool
  3958  	done            bool
  3959  	oldValue        func(context.Context) (*Decision, error)
  3960  	predicates      []predicate.Decision
  3961  }
  3962  
  3963  var _ ent.Mutation = (*DecisionMutation)(nil)
  3964  
  3965  // decisionOption allows management of the mutation configuration using functional options.
  3966  type decisionOption func(*DecisionMutation)
  3967  
  3968  // newDecisionMutation creates new mutation for the Decision entity.
  3969  func newDecisionMutation(c config, op Op, opts ...decisionOption) *DecisionMutation {
  3970  	m := &DecisionMutation{
  3971  		config:        c,
  3972  		op:            op,
  3973  		typ:           TypeDecision,
  3974  		clearedFields: make(map[string]struct{}),
  3975  	}
  3976  	for _, opt := range opts {
  3977  		opt(m)
  3978  	}
  3979  	return m
  3980  }
  3981  
  3982  // withDecisionID sets the ID field of the mutation.
  3983  func withDecisionID(id int) decisionOption {
  3984  	return func(m *DecisionMutation) {
  3985  		var (
  3986  			err   error
  3987  			once  sync.Once
  3988  			value *Decision
  3989  		)
  3990  		m.oldValue = func(ctx context.Context) (*Decision, error) {
  3991  			once.Do(func() {
  3992  				if m.done {
  3993  					err = errors.New("querying old values post mutation is not allowed")
  3994  				} else {
  3995  					value, err = m.Client().Decision.Get(ctx, id)
  3996  				}
  3997  			})
  3998  			return value, err
  3999  		}
  4000  		m.id = &id
  4001  	}
  4002  }
  4003  
  4004  // withDecision sets the old Decision of the mutation.
  4005  func withDecision(node *Decision) decisionOption {
  4006  	return func(m *DecisionMutation) {
  4007  		m.oldValue = func(context.Context) (*Decision, error) {
  4008  			return node, nil
  4009  		}
  4010  		m.id = &node.ID
  4011  	}
  4012  }
  4013  
  4014  // Client returns a new `ent.Client` from the mutation. If the mutation was
  4015  // executed in a transaction (ent.Tx), a transactional client is returned.
  4016  func (m DecisionMutation) Client() *Client {
  4017  	client := &Client{config: m.config}
  4018  	client.init()
  4019  	return client
  4020  }
  4021  
  4022  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4023  // it returns an error otherwise.
  4024  func (m DecisionMutation) Tx() (*Tx, error) {
  4025  	if _, ok := m.driver.(*txDriver); !ok {
  4026  		return nil, errors.New("ent: mutation is not running in a transaction")
  4027  	}
  4028  	tx := &Tx{config: m.config}
  4029  	tx.init()
  4030  	return tx, nil
  4031  }
  4032  
  4033  // ID returns the ID value in the mutation. Note that the ID is only available
  4034  // if it was provided to the builder or after it was returned from the database.
  4035  func (m *DecisionMutation) ID() (id int, exists bool) {
  4036  	if m.id == nil {
  4037  		return
  4038  	}
  4039  	return *m.id, true
  4040  }
  4041  
  4042  // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4043  // That means, if the mutation is applied within a transaction with an isolation level such
  4044  // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4045  // or updated by the mutation.
  4046  func (m *DecisionMutation) IDs(ctx context.Context) ([]int, error) {
  4047  	switch {
  4048  	case m.op.Is(OpUpdateOne | OpDeleteOne):
  4049  		id, exists := m.ID()
  4050  		if exists {
  4051  			return []int{id}, nil
  4052  		}
  4053  		fallthrough
  4054  	case m.op.Is(OpUpdate | OpDelete):
  4055  		return m.Client().Decision.Query().Where(m.predicates...).IDs(ctx)
  4056  	default:
  4057  		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4058  	}
  4059  }
  4060  
  4061  // SetCreatedAt sets the "created_at" field.
  4062  func (m *DecisionMutation) SetCreatedAt(t time.Time) {
  4063  	m.created_at = &t
  4064  }
  4065  
  4066  // CreatedAt returns the value of the "created_at" field in the mutation.
  4067  func (m *DecisionMutation) CreatedAt() (r time.Time, exists bool) {
  4068  	v := m.created_at
  4069  	if v == nil {
  4070  		return
  4071  	}
  4072  	return *v, true
  4073  }
  4074  
  4075  // OldCreatedAt returns the old "created_at" field's value of the Decision entity.
  4076  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4077  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4078  func (m *DecisionMutation) OldCreatedAt(ctx context.Context) (v *time.Time, err error) {
  4079  	if !m.op.Is(OpUpdateOne) {
  4080  		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4081  	}
  4082  	if m.id == nil || m.oldValue == nil {
  4083  		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4084  	}
  4085  	oldValue, err := m.oldValue(ctx)
  4086  	if err != nil {
  4087  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4088  	}
  4089  	return oldValue.CreatedAt, nil
  4090  }
  4091  
  4092  // ClearCreatedAt clears the value of the "created_at" field.
  4093  func (m *DecisionMutation) ClearCreatedAt() {
  4094  	m.created_at = nil
  4095  	m.clearedFields[decision.FieldCreatedAt] = struct{}{}
  4096  }
  4097  
  4098  // CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
  4099  func (m *DecisionMutation) CreatedAtCleared() bool {
  4100  	_, ok := m.clearedFields[decision.FieldCreatedAt]
  4101  	return ok
  4102  }
  4103  
  4104  // ResetCreatedAt resets all changes to the "created_at" field.
  4105  func (m *DecisionMutation) ResetCreatedAt() {
  4106  	m.created_at = nil
  4107  	delete(m.clearedFields, decision.FieldCreatedAt)
  4108  }
  4109  
  4110  // SetUpdatedAt sets the "updated_at" field.
  4111  func (m *DecisionMutation) SetUpdatedAt(t time.Time) {
  4112  	m.updated_at = &t
  4113  }
  4114  
  4115  // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4116  func (m *DecisionMutation) UpdatedAt() (r time.Time, exists bool) {
  4117  	v := m.updated_at
  4118  	if v == nil {
  4119  		return
  4120  	}
  4121  	return *v, true
  4122  }
  4123  
  4124  // OldUpdatedAt returns the old "updated_at" field's value of the Decision entity.
  4125  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4126  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4127  func (m *DecisionMutation) OldUpdatedAt(ctx context.Context) (v *time.Time, err error) {
  4128  	if !m.op.Is(OpUpdateOne) {
  4129  		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4130  	}
  4131  	if m.id == nil || m.oldValue == nil {
  4132  		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4133  	}
  4134  	oldValue, err := m.oldValue(ctx)
  4135  	if err != nil {
  4136  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4137  	}
  4138  	return oldValue.UpdatedAt, nil
  4139  }
  4140  
  4141  // ClearUpdatedAt clears the value of the "updated_at" field.
  4142  func (m *DecisionMutation) ClearUpdatedAt() {
  4143  	m.updated_at = nil
  4144  	m.clearedFields[decision.FieldUpdatedAt] = struct{}{}
  4145  }
  4146  
  4147  // UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
  4148  func (m *DecisionMutation) UpdatedAtCleared() bool {
  4149  	_, ok := m.clearedFields[decision.FieldUpdatedAt]
  4150  	return ok
  4151  }
  4152  
  4153  // ResetUpdatedAt resets all changes to the "updated_at" field.
  4154  func (m *DecisionMutation) ResetUpdatedAt() {
  4155  	m.updated_at = nil
  4156  	delete(m.clearedFields, decision.FieldUpdatedAt)
  4157  }
  4158  
  4159  // SetUntil sets the "until" field.
  4160  func (m *DecisionMutation) SetUntil(t time.Time) {
  4161  	m.until = &t
  4162  }
  4163  
  4164  // Until returns the value of the "until" field in the mutation.
  4165  func (m *DecisionMutation) Until() (r time.Time, exists bool) {
  4166  	v := m.until
  4167  	if v == nil {
  4168  		return
  4169  	}
  4170  	return *v, true
  4171  }
  4172  
  4173  // OldUntil returns the old "until" field's value of the Decision entity.
  4174  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4175  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4176  func (m *DecisionMutation) OldUntil(ctx context.Context) (v *time.Time, err error) {
  4177  	if !m.op.Is(OpUpdateOne) {
  4178  		return v, errors.New("OldUntil is only allowed on UpdateOne operations")
  4179  	}
  4180  	if m.id == nil || m.oldValue == nil {
  4181  		return v, errors.New("OldUntil requires an ID field in the mutation")
  4182  	}
  4183  	oldValue, err := m.oldValue(ctx)
  4184  	if err != nil {
  4185  		return v, fmt.Errorf("querying old value for OldUntil: %w", err)
  4186  	}
  4187  	return oldValue.Until, nil
  4188  }
  4189  
  4190  // ClearUntil clears the value of the "until" field.
  4191  func (m *DecisionMutation) ClearUntil() {
  4192  	m.until = nil
  4193  	m.clearedFields[decision.FieldUntil] = struct{}{}
  4194  }
  4195  
  4196  // UntilCleared returns if the "until" field was cleared in this mutation.
  4197  func (m *DecisionMutation) UntilCleared() bool {
  4198  	_, ok := m.clearedFields[decision.FieldUntil]
  4199  	return ok
  4200  }
  4201  
  4202  // ResetUntil resets all changes to the "until" field.
  4203  func (m *DecisionMutation) ResetUntil() {
  4204  	m.until = nil
  4205  	delete(m.clearedFields, decision.FieldUntil)
  4206  }
  4207  
  4208  // SetScenario sets the "scenario" field.
  4209  func (m *DecisionMutation) SetScenario(s string) {
  4210  	m.scenario = &s
  4211  }
  4212  
  4213  // Scenario returns the value of the "scenario" field in the mutation.
  4214  func (m *DecisionMutation) Scenario() (r string, exists bool) {
  4215  	v := m.scenario
  4216  	if v == nil {
  4217  		return
  4218  	}
  4219  	return *v, true
  4220  }
  4221  
  4222  // OldScenario returns the old "scenario" field's value of the Decision entity.
  4223  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4224  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4225  func (m *DecisionMutation) OldScenario(ctx context.Context) (v string, err error) {
  4226  	if !m.op.Is(OpUpdateOne) {
  4227  		return v, errors.New("OldScenario is only allowed on UpdateOne operations")
  4228  	}
  4229  	if m.id == nil || m.oldValue == nil {
  4230  		return v, errors.New("OldScenario requires an ID field in the mutation")
  4231  	}
  4232  	oldValue, err := m.oldValue(ctx)
  4233  	if err != nil {
  4234  		return v, fmt.Errorf("querying old value for OldScenario: %w", err)
  4235  	}
  4236  	return oldValue.Scenario, nil
  4237  }
  4238  
  4239  // ResetScenario resets all changes to the "scenario" field.
  4240  func (m *DecisionMutation) ResetScenario() {
  4241  	m.scenario = nil
  4242  }
  4243  
  4244  // SetType sets the "type" field.
  4245  func (m *DecisionMutation) SetType(s string) {
  4246  	m._type = &s
  4247  }
  4248  
  4249  // GetType returns the value of the "type" field in the mutation.
  4250  func (m *DecisionMutation) GetType() (r string, exists bool) {
  4251  	v := m._type
  4252  	if v == nil {
  4253  		return
  4254  	}
  4255  	return *v, true
  4256  }
  4257  
  4258  // OldType returns the old "type" field's value of the Decision entity.
  4259  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4260  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4261  func (m *DecisionMutation) OldType(ctx context.Context) (v string, err error) {
  4262  	if !m.op.Is(OpUpdateOne) {
  4263  		return v, errors.New("OldType is only allowed on UpdateOne operations")
  4264  	}
  4265  	if m.id == nil || m.oldValue == nil {
  4266  		return v, errors.New("OldType requires an ID field in the mutation")
  4267  	}
  4268  	oldValue, err := m.oldValue(ctx)
  4269  	if err != nil {
  4270  		return v, fmt.Errorf("querying old value for OldType: %w", err)
  4271  	}
  4272  	return oldValue.Type, nil
  4273  }
  4274  
  4275  // ResetType resets all changes to the "type" field.
  4276  func (m *DecisionMutation) ResetType() {
  4277  	m._type = nil
  4278  }
  4279  
  4280  // SetStartIP sets the "start_ip" field.
  4281  func (m *DecisionMutation) SetStartIP(i int64) {
  4282  	m.start_ip = &i
  4283  	m.addstart_ip = nil
  4284  }
  4285  
  4286  // StartIP returns the value of the "start_ip" field in the mutation.
  4287  func (m *DecisionMutation) StartIP() (r int64, exists bool) {
  4288  	v := m.start_ip
  4289  	if v == nil {
  4290  		return
  4291  	}
  4292  	return *v, true
  4293  }
  4294  
  4295  // OldStartIP returns the old "start_ip" field's value of the Decision entity.
  4296  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4297  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4298  func (m *DecisionMutation) OldStartIP(ctx context.Context) (v int64, err error) {
  4299  	if !m.op.Is(OpUpdateOne) {
  4300  		return v, errors.New("OldStartIP is only allowed on UpdateOne operations")
  4301  	}
  4302  	if m.id == nil || m.oldValue == nil {
  4303  		return v, errors.New("OldStartIP requires an ID field in the mutation")
  4304  	}
  4305  	oldValue, err := m.oldValue(ctx)
  4306  	if err != nil {
  4307  		return v, fmt.Errorf("querying old value for OldStartIP: %w", err)
  4308  	}
  4309  	return oldValue.StartIP, nil
  4310  }
  4311  
  4312  // AddStartIP adds i to the "start_ip" field.
  4313  func (m *DecisionMutation) AddStartIP(i int64) {
  4314  	if m.addstart_ip != nil {
  4315  		*m.addstart_ip += i
  4316  	} else {
  4317  		m.addstart_ip = &i
  4318  	}
  4319  }
  4320  
  4321  // AddedStartIP returns the value that was added to the "start_ip" field in this mutation.
  4322  func (m *DecisionMutation) AddedStartIP() (r int64, exists bool) {
  4323  	v := m.addstart_ip
  4324  	if v == nil {
  4325  		return
  4326  	}
  4327  	return *v, true
  4328  }
  4329  
  4330  // ClearStartIP clears the value of the "start_ip" field.
  4331  func (m *DecisionMutation) ClearStartIP() {
  4332  	m.start_ip = nil
  4333  	m.addstart_ip = nil
  4334  	m.clearedFields[decision.FieldStartIP] = struct{}{}
  4335  }
  4336  
  4337  // StartIPCleared returns if the "start_ip" field was cleared in this mutation.
  4338  func (m *DecisionMutation) StartIPCleared() bool {
  4339  	_, ok := m.clearedFields[decision.FieldStartIP]
  4340  	return ok
  4341  }
  4342  
  4343  // ResetStartIP resets all changes to the "start_ip" field.
  4344  func (m *DecisionMutation) ResetStartIP() {
  4345  	m.start_ip = nil
  4346  	m.addstart_ip = nil
  4347  	delete(m.clearedFields, decision.FieldStartIP)
  4348  }
  4349  
  4350  // SetEndIP sets the "end_ip" field.
  4351  func (m *DecisionMutation) SetEndIP(i int64) {
  4352  	m.end_ip = &i
  4353  	m.addend_ip = nil
  4354  }
  4355  
  4356  // EndIP returns the value of the "end_ip" field in the mutation.
  4357  func (m *DecisionMutation) EndIP() (r int64, exists bool) {
  4358  	v := m.end_ip
  4359  	if v == nil {
  4360  		return
  4361  	}
  4362  	return *v, true
  4363  }
  4364  
  4365  // OldEndIP returns the old "end_ip" field's value of the Decision entity.
  4366  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4367  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4368  func (m *DecisionMutation) OldEndIP(ctx context.Context) (v int64, err error) {
  4369  	if !m.op.Is(OpUpdateOne) {
  4370  		return v, errors.New("OldEndIP is only allowed on UpdateOne operations")
  4371  	}
  4372  	if m.id == nil || m.oldValue == nil {
  4373  		return v, errors.New("OldEndIP requires an ID field in the mutation")
  4374  	}
  4375  	oldValue, err := m.oldValue(ctx)
  4376  	if err != nil {
  4377  		return v, fmt.Errorf("querying old value for OldEndIP: %w", err)
  4378  	}
  4379  	return oldValue.EndIP, nil
  4380  }
  4381  
  4382  // AddEndIP adds i to the "end_ip" field.
  4383  func (m *DecisionMutation) AddEndIP(i int64) {
  4384  	if m.addend_ip != nil {
  4385  		*m.addend_ip += i
  4386  	} else {
  4387  		m.addend_ip = &i
  4388  	}
  4389  }
  4390  
  4391  // AddedEndIP returns the value that was added to the "end_ip" field in this mutation.
  4392  func (m *DecisionMutation) AddedEndIP() (r int64, exists bool) {
  4393  	v := m.addend_ip
  4394  	if v == nil {
  4395  		return
  4396  	}
  4397  	return *v, true
  4398  }
  4399  
  4400  // ClearEndIP clears the value of the "end_ip" field.
  4401  func (m *DecisionMutation) ClearEndIP() {
  4402  	m.end_ip = nil
  4403  	m.addend_ip = nil
  4404  	m.clearedFields[decision.FieldEndIP] = struct{}{}
  4405  }
  4406  
  4407  // EndIPCleared returns if the "end_ip" field was cleared in this mutation.
  4408  func (m *DecisionMutation) EndIPCleared() bool {
  4409  	_, ok := m.clearedFields[decision.FieldEndIP]
  4410  	return ok
  4411  }
  4412  
  4413  // ResetEndIP resets all changes to the "end_ip" field.
  4414  func (m *DecisionMutation) ResetEndIP() {
  4415  	m.end_ip = nil
  4416  	m.addend_ip = nil
  4417  	delete(m.clearedFields, decision.FieldEndIP)
  4418  }
  4419  
  4420  // SetStartSuffix sets the "start_suffix" field.
  4421  func (m *DecisionMutation) SetStartSuffix(i int64) {
  4422  	m.start_suffix = &i
  4423  	m.addstart_suffix = nil
  4424  }
  4425  
  4426  // StartSuffix returns the value of the "start_suffix" field in the mutation.
  4427  func (m *DecisionMutation) StartSuffix() (r int64, exists bool) {
  4428  	v := m.start_suffix
  4429  	if v == nil {
  4430  		return
  4431  	}
  4432  	return *v, true
  4433  }
  4434  
  4435  // OldStartSuffix returns the old "start_suffix" field's value of the Decision entity.
  4436  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4437  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4438  func (m *DecisionMutation) OldStartSuffix(ctx context.Context) (v int64, err error) {
  4439  	if !m.op.Is(OpUpdateOne) {
  4440  		return v, errors.New("OldStartSuffix is only allowed on UpdateOne operations")
  4441  	}
  4442  	if m.id == nil || m.oldValue == nil {
  4443  		return v, errors.New("OldStartSuffix requires an ID field in the mutation")
  4444  	}
  4445  	oldValue, err := m.oldValue(ctx)
  4446  	if err != nil {
  4447  		return v, fmt.Errorf("querying old value for OldStartSuffix: %w", err)
  4448  	}
  4449  	return oldValue.StartSuffix, nil
  4450  }
  4451  
  4452  // AddStartSuffix adds i to the "start_suffix" field.
  4453  func (m *DecisionMutation) AddStartSuffix(i int64) {
  4454  	if m.addstart_suffix != nil {
  4455  		*m.addstart_suffix += i
  4456  	} else {
  4457  		m.addstart_suffix = &i
  4458  	}
  4459  }
  4460  
  4461  // AddedStartSuffix returns the value that was added to the "start_suffix" field in this mutation.
  4462  func (m *DecisionMutation) AddedStartSuffix() (r int64, exists bool) {
  4463  	v := m.addstart_suffix
  4464  	if v == nil {
  4465  		return
  4466  	}
  4467  	return *v, true
  4468  }
  4469  
  4470  // ClearStartSuffix clears the value of the "start_suffix" field.
  4471  func (m *DecisionMutation) ClearStartSuffix() {
  4472  	m.start_suffix = nil
  4473  	m.addstart_suffix = nil
  4474  	m.clearedFields[decision.FieldStartSuffix] = struct{}{}
  4475  }
  4476  
  4477  // StartSuffixCleared returns if the "start_suffix" field was cleared in this mutation.
  4478  func (m *DecisionMutation) StartSuffixCleared() bool {
  4479  	_, ok := m.clearedFields[decision.FieldStartSuffix]
  4480  	return ok
  4481  }
  4482  
  4483  // ResetStartSuffix resets all changes to the "start_suffix" field.
  4484  func (m *DecisionMutation) ResetStartSuffix() {
  4485  	m.start_suffix = nil
  4486  	m.addstart_suffix = nil
  4487  	delete(m.clearedFields, decision.FieldStartSuffix)
  4488  }
  4489  
  4490  // SetEndSuffix sets the "end_suffix" field.
  4491  func (m *DecisionMutation) SetEndSuffix(i int64) {
  4492  	m.end_suffix = &i
  4493  	m.addend_suffix = nil
  4494  }
  4495  
  4496  // EndSuffix returns the value of the "end_suffix" field in the mutation.
  4497  func (m *DecisionMutation) EndSuffix() (r int64, exists bool) {
  4498  	v := m.end_suffix
  4499  	if v == nil {
  4500  		return
  4501  	}
  4502  	return *v, true
  4503  }
  4504  
  4505  // OldEndSuffix returns the old "end_suffix" field's value of the Decision entity.
  4506  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4507  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4508  func (m *DecisionMutation) OldEndSuffix(ctx context.Context) (v int64, err error) {
  4509  	if !m.op.Is(OpUpdateOne) {
  4510  		return v, errors.New("OldEndSuffix is only allowed on UpdateOne operations")
  4511  	}
  4512  	if m.id == nil || m.oldValue == nil {
  4513  		return v, errors.New("OldEndSuffix requires an ID field in the mutation")
  4514  	}
  4515  	oldValue, err := m.oldValue(ctx)
  4516  	if err != nil {
  4517  		return v, fmt.Errorf("querying old value for OldEndSuffix: %w", err)
  4518  	}
  4519  	return oldValue.EndSuffix, nil
  4520  }
  4521  
  4522  // AddEndSuffix adds i to the "end_suffix" field.
  4523  func (m *DecisionMutation) AddEndSuffix(i int64) {
  4524  	if m.addend_suffix != nil {
  4525  		*m.addend_suffix += i
  4526  	} else {
  4527  		m.addend_suffix = &i
  4528  	}
  4529  }
  4530  
  4531  // AddedEndSuffix returns the value that was added to the "end_suffix" field in this mutation.
  4532  func (m *DecisionMutation) AddedEndSuffix() (r int64, exists bool) {
  4533  	v := m.addend_suffix
  4534  	if v == nil {
  4535  		return
  4536  	}
  4537  	return *v, true
  4538  }
  4539  
  4540  // ClearEndSuffix clears the value of the "end_suffix" field.
  4541  func (m *DecisionMutation) ClearEndSuffix() {
  4542  	m.end_suffix = nil
  4543  	m.addend_suffix = nil
  4544  	m.clearedFields[decision.FieldEndSuffix] = struct{}{}
  4545  }
  4546  
  4547  // EndSuffixCleared returns if the "end_suffix" field was cleared in this mutation.
  4548  func (m *DecisionMutation) EndSuffixCleared() bool {
  4549  	_, ok := m.clearedFields[decision.FieldEndSuffix]
  4550  	return ok
  4551  }
  4552  
  4553  // ResetEndSuffix resets all changes to the "end_suffix" field.
  4554  func (m *DecisionMutation) ResetEndSuffix() {
  4555  	m.end_suffix = nil
  4556  	m.addend_suffix = nil
  4557  	delete(m.clearedFields, decision.FieldEndSuffix)
  4558  }
  4559  
  4560  // SetIPSize sets the "ip_size" field.
  4561  func (m *DecisionMutation) SetIPSize(i int64) {
  4562  	m.ip_size = &i
  4563  	m.addip_size = nil
  4564  }
  4565  
  4566  // IPSize returns the value of the "ip_size" field in the mutation.
  4567  func (m *DecisionMutation) IPSize() (r int64, exists bool) {
  4568  	v := m.ip_size
  4569  	if v == nil {
  4570  		return
  4571  	}
  4572  	return *v, true
  4573  }
  4574  
  4575  // OldIPSize returns the old "ip_size" field's value of the Decision entity.
  4576  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4577  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4578  func (m *DecisionMutation) OldIPSize(ctx context.Context) (v int64, err error) {
  4579  	if !m.op.Is(OpUpdateOne) {
  4580  		return v, errors.New("OldIPSize is only allowed on UpdateOne operations")
  4581  	}
  4582  	if m.id == nil || m.oldValue == nil {
  4583  		return v, errors.New("OldIPSize requires an ID field in the mutation")
  4584  	}
  4585  	oldValue, err := m.oldValue(ctx)
  4586  	if err != nil {
  4587  		return v, fmt.Errorf("querying old value for OldIPSize: %w", err)
  4588  	}
  4589  	return oldValue.IPSize, nil
  4590  }
  4591  
  4592  // AddIPSize adds i to the "ip_size" field.
  4593  func (m *DecisionMutation) AddIPSize(i int64) {
  4594  	if m.addip_size != nil {
  4595  		*m.addip_size += i
  4596  	} else {
  4597  		m.addip_size = &i
  4598  	}
  4599  }
  4600  
  4601  // AddedIPSize returns the value that was added to the "ip_size" field in this mutation.
  4602  func (m *DecisionMutation) AddedIPSize() (r int64, exists bool) {
  4603  	v := m.addip_size
  4604  	if v == nil {
  4605  		return
  4606  	}
  4607  	return *v, true
  4608  }
  4609  
  4610  // ClearIPSize clears the value of the "ip_size" field.
  4611  func (m *DecisionMutation) ClearIPSize() {
  4612  	m.ip_size = nil
  4613  	m.addip_size = nil
  4614  	m.clearedFields[decision.FieldIPSize] = struct{}{}
  4615  }
  4616  
  4617  // IPSizeCleared returns if the "ip_size" field was cleared in this mutation.
  4618  func (m *DecisionMutation) IPSizeCleared() bool {
  4619  	_, ok := m.clearedFields[decision.FieldIPSize]
  4620  	return ok
  4621  }
  4622  
  4623  // ResetIPSize resets all changes to the "ip_size" field.
  4624  func (m *DecisionMutation) ResetIPSize() {
  4625  	m.ip_size = nil
  4626  	m.addip_size = nil
  4627  	delete(m.clearedFields, decision.FieldIPSize)
  4628  }
  4629  
  4630  // SetScope sets the "scope" field.
  4631  func (m *DecisionMutation) SetScope(s string) {
  4632  	m.scope = &s
  4633  }
  4634  
  4635  // Scope returns the value of the "scope" field in the mutation.
  4636  func (m *DecisionMutation) Scope() (r string, exists bool) {
  4637  	v := m.scope
  4638  	if v == nil {
  4639  		return
  4640  	}
  4641  	return *v, true
  4642  }
  4643  
  4644  // OldScope returns the old "scope" field's value of the Decision entity.
  4645  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4646  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4647  func (m *DecisionMutation) OldScope(ctx context.Context) (v string, err error) {
  4648  	if !m.op.Is(OpUpdateOne) {
  4649  		return v, errors.New("OldScope is only allowed on UpdateOne operations")
  4650  	}
  4651  	if m.id == nil || m.oldValue == nil {
  4652  		return v, errors.New("OldScope requires an ID field in the mutation")
  4653  	}
  4654  	oldValue, err := m.oldValue(ctx)
  4655  	if err != nil {
  4656  		return v, fmt.Errorf("querying old value for OldScope: %w", err)
  4657  	}
  4658  	return oldValue.Scope, nil
  4659  }
  4660  
  4661  // ResetScope resets all changes to the "scope" field.
  4662  func (m *DecisionMutation) ResetScope() {
  4663  	m.scope = nil
  4664  }
  4665  
  4666  // SetValue sets the "value" field.
  4667  func (m *DecisionMutation) SetValue(s string) {
  4668  	m.value = &s
  4669  }
  4670  
  4671  // Value returns the value of the "value" field in the mutation.
  4672  func (m *DecisionMutation) Value() (r string, exists bool) {
  4673  	v := m.value
  4674  	if v == nil {
  4675  		return
  4676  	}
  4677  	return *v, true
  4678  }
  4679  
  4680  // OldValue returns the old "value" field's value of the Decision entity.
  4681  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4682  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4683  func (m *DecisionMutation) OldValue(ctx context.Context) (v string, err error) {
  4684  	if !m.op.Is(OpUpdateOne) {
  4685  		return v, errors.New("OldValue is only allowed on UpdateOne operations")
  4686  	}
  4687  	if m.id == nil || m.oldValue == nil {
  4688  		return v, errors.New("OldValue requires an ID field in the mutation")
  4689  	}
  4690  	oldValue, err := m.oldValue(ctx)
  4691  	if err != nil {
  4692  		return v, fmt.Errorf("querying old value for OldValue: %w", err)
  4693  	}
  4694  	return oldValue.Value, nil
  4695  }
  4696  
  4697  // ResetValue resets all changes to the "value" field.
  4698  func (m *DecisionMutation) ResetValue() {
  4699  	m.value = nil
  4700  }
  4701  
  4702  // SetOrigin sets the "origin" field.
  4703  func (m *DecisionMutation) SetOrigin(s string) {
  4704  	m.origin = &s
  4705  }
  4706  
  4707  // Origin returns the value of the "origin" field in the mutation.
  4708  func (m *DecisionMutation) Origin() (r string, exists bool) {
  4709  	v := m.origin
  4710  	if v == nil {
  4711  		return
  4712  	}
  4713  	return *v, true
  4714  }
  4715  
  4716  // OldOrigin returns the old "origin" field's value of the Decision entity.
  4717  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4718  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4719  func (m *DecisionMutation) OldOrigin(ctx context.Context) (v string, err error) {
  4720  	if !m.op.Is(OpUpdateOne) {
  4721  		return v, errors.New("OldOrigin is only allowed on UpdateOne operations")
  4722  	}
  4723  	if m.id == nil || m.oldValue == nil {
  4724  		return v, errors.New("OldOrigin requires an ID field in the mutation")
  4725  	}
  4726  	oldValue, err := m.oldValue(ctx)
  4727  	if err != nil {
  4728  		return v, fmt.Errorf("querying old value for OldOrigin: %w", err)
  4729  	}
  4730  	return oldValue.Origin, nil
  4731  }
  4732  
  4733  // ResetOrigin resets all changes to the "origin" field.
  4734  func (m *DecisionMutation) ResetOrigin() {
  4735  	m.origin = nil
  4736  }
  4737  
  4738  // SetSimulated sets the "simulated" field.
  4739  func (m *DecisionMutation) SetSimulated(b bool) {
  4740  	m.simulated = &b
  4741  }
  4742  
  4743  // Simulated returns the value of the "simulated" field in the mutation.
  4744  func (m *DecisionMutation) Simulated() (r bool, exists bool) {
  4745  	v := m.simulated
  4746  	if v == nil {
  4747  		return
  4748  	}
  4749  	return *v, true
  4750  }
  4751  
  4752  // OldSimulated returns the old "simulated" field's value of the Decision entity.
  4753  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4754  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4755  func (m *DecisionMutation) OldSimulated(ctx context.Context) (v bool, err error) {
  4756  	if !m.op.Is(OpUpdateOne) {
  4757  		return v, errors.New("OldSimulated is only allowed on UpdateOne operations")
  4758  	}
  4759  	if m.id == nil || m.oldValue == nil {
  4760  		return v, errors.New("OldSimulated requires an ID field in the mutation")
  4761  	}
  4762  	oldValue, err := m.oldValue(ctx)
  4763  	if err != nil {
  4764  		return v, fmt.Errorf("querying old value for OldSimulated: %w", err)
  4765  	}
  4766  	return oldValue.Simulated, nil
  4767  }
  4768  
  4769  // ResetSimulated resets all changes to the "simulated" field.
  4770  func (m *DecisionMutation) ResetSimulated() {
  4771  	m.simulated = nil
  4772  }
  4773  
  4774  // SetUUID sets the "uuid" field.
  4775  func (m *DecisionMutation) SetUUID(s string) {
  4776  	m.uuid = &s
  4777  }
  4778  
  4779  // UUID returns the value of the "uuid" field in the mutation.
  4780  func (m *DecisionMutation) UUID() (r string, exists bool) {
  4781  	v := m.uuid
  4782  	if v == nil {
  4783  		return
  4784  	}
  4785  	return *v, true
  4786  }
  4787  
  4788  // OldUUID returns the old "uuid" field's value of the Decision entity.
  4789  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4790  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4791  func (m *DecisionMutation) OldUUID(ctx context.Context) (v string, err error) {
  4792  	if !m.op.Is(OpUpdateOne) {
  4793  		return v, errors.New("OldUUID is only allowed on UpdateOne operations")
  4794  	}
  4795  	if m.id == nil || m.oldValue == nil {
  4796  		return v, errors.New("OldUUID requires an ID field in the mutation")
  4797  	}
  4798  	oldValue, err := m.oldValue(ctx)
  4799  	if err != nil {
  4800  		return v, fmt.Errorf("querying old value for OldUUID: %w", err)
  4801  	}
  4802  	return oldValue.UUID, nil
  4803  }
  4804  
  4805  // ClearUUID clears the value of the "uuid" field.
  4806  func (m *DecisionMutation) ClearUUID() {
  4807  	m.uuid = nil
  4808  	m.clearedFields[decision.FieldUUID] = struct{}{}
  4809  }
  4810  
  4811  // UUIDCleared returns if the "uuid" field was cleared in this mutation.
  4812  func (m *DecisionMutation) UUIDCleared() bool {
  4813  	_, ok := m.clearedFields[decision.FieldUUID]
  4814  	return ok
  4815  }
  4816  
  4817  // ResetUUID resets all changes to the "uuid" field.
  4818  func (m *DecisionMutation) ResetUUID() {
  4819  	m.uuid = nil
  4820  	delete(m.clearedFields, decision.FieldUUID)
  4821  }
  4822  
  4823  // SetAlertDecisions sets the "alert_decisions" field.
  4824  func (m *DecisionMutation) SetAlertDecisions(i int) {
  4825  	m.owner = &i
  4826  }
  4827  
  4828  // AlertDecisions returns the value of the "alert_decisions" field in the mutation.
  4829  func (m *DecisionMutation) AlertDecisions() (r int, exists bool) {
  4830  	v := m.owner
  4831  	if v == nil {
  4832  		return
  4833  	}
  4834  	return *v, true
  4835  }
  4836  
  4837  // OldAlertDecisions returns the old "alert_decisions" field's value of the Decision entity.
  4838  // If the Decision object wasn't provided to the builder, the object is fetched from the database.
  4839  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4840  func (m *DecisionMutation) OldAlertDecisions(ctx context.Context) (v int, err error) {
  4841  	if !m.op.Is(OpUpdateOne) {
  4842  		return v, errors.New("OldAlertDecisions is only allowed on UpdateOne operations")
  4843  	}
  4844  	if m.id == nil || m.oldValue == nil {
  4845  		return v, errors.New("OldAlertDecisions requires an ID field in the mutation")
  4846  	}
  4847  	oldValue, err := m.oldValue(ctx)
  4848  	if err != nil {
  4849  		return v, fmt.Errorf("querying old value for OldAlertDecisions: %w", err)
  4850  	}
  4851  	return oldValue.AlertDecisions, nil
  4852  }
  4853  
  4854  // ClearAlertDecisions clears the value of the "alert_decisions" field.
  4855  func (m *DecisionMutation) ClearAlertDecisions() {
  4856  	m.owner = nil
  4857  	m.clearedFields[decision.FieldAlertDecisions] = struct{}{}
  4858  }
  4859  
  4860  // AlertDecisionsCleared returns if the "alert_decisions" field was cleared in this mutation.
  4861  func (m *DecisionMutation) AlertDecisionsCleared() bool {
  4862  	_, ok := m.clearedFields[decision.FieldAlertDecisions]
  4863  	return ok
  4864  }
  4865  
  4866  // ResetAlertDecisions resets all changes to the "alert_decisions" field.
  4867  func (m *DecisionMutation) ResetAlertDecisions() {
  4868  	m.owner = nil
  4869  	delete(m.clearedFields, decision.FieldAlertDecisions)
  4870  }
  4871  
  4872  // SetOwnerID sets the "owner" edge to the Alert entity by id.
  4873  func (m *DecisionMutation) SetOwnerID(id int) {
  4874  	m.owner = &id
  4875  }
  4876  
  4877  // ClearOwner clears the "owner" edge to the Alert entity.
  4878  func (m *DecisionMutation) ClearOwner() {
  4879  	m.clearedowner = true
  4880  	m.clearedFields[decision.FieldAlertDecisions] = struct{}{}
  4881  }
  4882  
  4883  // OwnerCleared reports if the "owner" edge to the Alert entity was cleared.
  4884  func (m *DecisionMutation) OwnerCleared() bool {
  4885  	return m.AlertDecisionsCleared() || m.clearedowner
  4886  }
  4887  
  4888  // OwnerID returns the "owner" edge ID in the mutation.
  4889  func (m *DecisionMutation) OwnerID() (id int, exists bool) {
  4890  	if m.owner != nil {
  4891  		return *m.owner, true
  4892  	}
  4893  	return
  4894  }
  4895  
  4896  // OwnerIDs returns the "owner" edge IDs in the mutation.
  4897  // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4898  // OwnerID instead. It exists only for internal usage by the builders.
  4899  func (m *DecisionMutation) OwnerIDs() (ids []int) {
  4900  	if id := m.owner; id != nil {
  4901  		ids = append(ids, *id)
  4902  	}
  4903  	return
  4904  }
  4905  
  4906  // ResetOwner resets all changes to the "owner" edge.
  4907  func (m *DecisionMutation) ResetOwner() {
  4908  	m.owner = nil
  4909  	m.clearedowner = false
  4910  }
  4911  
  4912  // Where appends a list predicates to the DecisionMutation builder.
  4913  func (m *DecisionMutation) Where(ps ...predicate.Decision) {
  4914  	m.predicates = append(m.predicates, ps...)
  4915  }
  4916  
  4917  // WhereP appends storage-level predicates to the DecisionMutation builder. Using this method,
  4918  // users can use type-assertion to append predicates that do not depend on any generated package.
  4919  func (m *DecisionMutation) WhereP(ps ...func(*sql.Selector)) {
  4920  	p := make([]predicate.Decision, len(ps))
  4921  	for i := range ps {
  4922  		p[i] = ps[i]
  4923  	}
  4924  	m.Where(p...)
  4925  }
  4926  
  4927  // Op returns the operation name.
  4928  func (m *DecisionMutation) Op() Op {
  4929  	return m.op
  4930  }
  4931  
  4932  // SetOp allows setting the mutation operation.
  4933  func (m *DecisionMutation) SetOp(op Op) {
  4934  	m.op = op
  4935  }
  4936  
  4937  // Type returns the node type of this mutation (Decision).
  4938  func (m *DecisionMutation) Type() string {
  4939  	return m.typ
  4940  }
  4941  
  4942  // Fields returns all fields that were changed during this mutation. Note that in
  4943  // order to get all numeric fields that were incremented/decremented, call
  4944  // AddedFields().
  4945  func (m *DecisionMutation) Fields() []string {
  4946  	fields := make([]string, 0, 16)
  4947  	if m.created_at != nil {
  4948  		fields = append(fields, decision.FieldCreatedAt)
  4949  	}
  4950  	if m.updated_at != nil {
  4951  		fields = append(fields, decision.FieldUpdatedAt)
  4952  	}
  4953  	if m.until != nil {
  4954  		fields = append(fields, decision.FieldUntil)
  4955  	}
  4956  	if m.scenario != nil {
  4957  		fields = append(fields, decision.FieldScenario)
  4958  	}
  4959  	if m._type != nil {
  4960  		fields = append(fields, decision.FieldType)
  4961  	}
  4962  	if m.start_ip != nil {
  4963  		fields = append(fields, decision.FieldStartIP)
  4964  	}
  4965  	if m.end_ip != nil {
  4966  		fields = append(fields, decision.FieldEndIP)
  4967  	}
  4968  	if m.start_suffix != nil {
  4969  		fields = append(fields, decision.FieldStartSuffix)
  4970  	}
  4971  	if m.end_suffix != nil {
  4972  		fields = append(fields, decision.FieldEndSuffix)
  4973  	}
  4974  	if m.ip_size != nil {
  4975  		fields = append(fields, decision.FieldIPSize)
  4976  	}
  4977  	if m.scope != nil {
  4978  		fields = append(fields, decision.FieldScope)
  4979  	}
  4980  	if m.value != nil {
  4981  		fields = append(fields, decision.FieldValue)
  4982  	}
  4983  	if m.origin != nil {
  4984  		fields = append(fields, decision.FieldOrigin)
  4985  	}
  4986  	if m.simulated != nil {
  4987  		fields = append(fields, decision.FieldSimulated)
  4988  	}
  4989  	if m.uuid != nil {
  4990  		fields = append(fields, decision.FieldUUID)
  4991  	}
  4992  	if m.owner != nil {
  4993  		fields = append(fields, decision.FieldAlertDecisions)
  4994  	}
  4995  	return fields
  4996  }
  4997  
  4998  // Field returns the value of a field with the given name. The second boolean
  4999  // return value indicates that this field was not set, or was not defined in the
  5000  // schema.
  5001  func (m *DecisionMutation) Field(name string) (ent.Value, bool) {
  5002  	switch name {
  5003  	case decision.FieldCreatedAt:
  5004  		return m.CreatedAt()
  5005  	case decision.FieldUpdatedAt:
  5006  		return m.UpdatedAt()
  5007  	case decision.FieldUntil:
  5008  		return m.Until()
  5009  	case decision.FieldScenario:
  5010  		return m.Scenario()
  5011  	case decision.FieldType:
  5012  		return m.GetType()
  5013  	case decision.FieldStartIP:
  5014  		return m.StartIP()
  5015  	case decision.FieldEndIP:
  5016  		return m.EndIP()
  5017  	case decision.FieldStartSuffix:
  5018  		return m.StartSuffix()
  5019  	case decision.FieldEndSuffix:
  5020  		return m.EndSuffix()
  5021  	case decision.FieldIPSize:
  5022  		return m.IPSize()
  5023  	case decision.FieldScope:
  5024  		return m.Scope()
  5025  	case decision.FieldValue:
  5026  		return m.Value()
  5027  	case decision.FieldOrigin:
  5028  		return m.Origin()
  5029  	case decision.FieldSimulated:
  5030  		return m.Simulated()
  5031  	case decision.FieldUUID:
  5032  		return m.UUID()
  5033  	case decision.FieldAlertDecisions:
  5034  		return m.AlertDecisions()
  5035  	}
  5036  	return nil, false
  5037  }
  5038  
  5039  // OldField returns the old value of the field from the database. An error is
  5040  // returned if the mutation operation is not UpdateOne, or the query to the
  5041  // database failed.
  5042  func (m *DecisionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5043  	switch name {
  5044  	case decision.FieldCreatedAt:
  5045  		return m.OldCreatedAt(ctx)
  5046  	case decision.FieldUpdatedAt:
  5047  		return m.OldUpdatedAt(ctx)
  5048  	case decision.FieldUntil:
  5049  		return m.OldUntil(ctx)
  5050  	case decision.FieldScenario:
  5051  		return m.OldScenario(ctx)
  5052  	case decision.FieldType:
  5053  		return m.OldType(ctx)
  5054  	case decision.FieldStartIP:
  5055  		return m.OldStartIP(ctx)
  5056  	case decision.FieldEndIP:
  5057  		return m.OldEndIP(ctx)
  5058  	case decision.FieldStartSuffix:
  5059  		return m.OldStartSuffix(ctx)
  5060  	case decision.FieldEndSuffix:
  5061  		return m.OldEndSuffix(ctx)
  5062  	case decision.FieldIPSize:
  5063  		return m.OldIPSize(ctx)
  5064  	case decision.FieldScope:
  5065  		return m.OldScope(ctx)
  5066  	case decision.FieldValue:
  5067  		return m.OldValue(ctx)
  5068  	case decision.FieldOrigin:
  5069  		return m.OldOrigin(ctx)
  5070  	case decision.FieldSimulated:
  5071  		return m.OldSimulated(ctx)
  5072  	case decision.FieldUUID:
  5073  		return m.OldUUID(ctx)
  5074  	case decision.FieldAlertDecisions:
  5075  		return m.OldAlertDecisions(ctx)
  5076  	}
  5077  	return nil, fmt.Errorf("unknown Decision field %s", name)
  5078  }
  5079  
  5080  // SetField sets the value of a field with the given name. It returns an error if
  5081  // the field is not defined in the schema, or if the type mismatched the field
  5082  // type.
  5083  func (m *DecisionMutation) SetField(name string, value ent.Value) error {
  5084  	switch name {
  5085  	case decision.FieldCreatedAt:
  5086  		v, ok := value.(time.Time)
  5087  		if !ok {
  5088  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5089  		}
  5090  		m.SetCreatedAt(v)
  5091  		return nil
  5092  	case decision.FieldUpdatedAt:
  5093  		v, ok := value.(time.Time)
  5094  		if !ok {
  5095  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5096  		}
  5097  		m.SetUpdatedAt(v)
  5098  		return nil
  5099  	case decision.FieldUntil:
  5100  		v, ok := value.(time.Time)
  5101  		if !ok {
  5102  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5103  		}
  5104  		m.SetUntil(v)
  5105  		return nil
  5106  	case decision.FieldScenario:
  5107  		v, ok := value.(string)
  5108  		if !ok {
  5109  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5110  		}
  5111  		m.SetScenario(v)
  5112  		return nil
  5113  	case decision.FieldType:
  5114  		v, ok := value.(string)
  5115  		if !ok {
  5116  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5117  		}
  5118  		m.SetType(v)
  5119  		return nil
  5120  	case decision.FieldStartIP:
  5121  		v, ok := value.(int64)
  5122  		if !ok {
  5123  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5124  		}
  5125  		m.SetStartIP(v)
  5126  		return nil
  5127  	case decision.FieldEndIP:
  5128  		v, ok := value.(int64)
  5129  		if !ok {
  5130  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5131  		}
  5132  		m.SetEndIP(v)
  5133  		return nil
  5134  	case decision.FieldStartSuffix:
  5135  		v, ok := value.(int64)
  5136  		if !ok {
  5137  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5138  		}
  5139  		m.SetStartSuffix(v)
  5140  		return nil
  5141  	case decision.FieldEndSuffix:
  5142  		v, ok := value.(int64)
  5143  		if !ok {
  5144  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5145  		}
  5146  		m.SetEndSuffix(v)
  5147  		return nil
  5148  	case decision.FieldIPSize:
  5149  		v, ok := value.(int64)
  5150  		if !ok {
  5151  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5152  		}
  5153  		m.SetIPSize(v)
  5154  		return nil
  5155  	case decision.FieldScope:
  5156  		v, ok := value.(string)
  5157  		if !ok {
  5158  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5159  		}
  5160  		m.SetScope(v)
  5161  		return nil
  5162  	case decision.FieldValue:
  5163  		v, ok := value.(string)
  5164  		if !ok {
  5165  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5166  		}
  5167  		m.SetValue(v)
  5168  		return nil
  5169  	case decision.FieldOrigin:
  5170  		v, ok := value.(string)
  5171  		if !ok {
  5172  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5173  		}
  5174  		m.SetOrigin(v)
  5175  		return nil
  5176  	case decision.FieldSimulated:
  5177  		v, ok := value.(bool)
  5178  		if !ok {
  5179  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5180  		}
  5181  		m.SetSimulated(v)
  5182  		return nil
  5183  	case decision.FieldUUID:
  5184  		v, ok := value.(string)
  5185  		if !ok {
  5186  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5187  		}
  5188  		m.SetUUID(v)
  5189  		return nil
  5190  	case decision.FieldAlertDecisions:
  5191  		v, ok := value.(int)
  5192  		if !ok {
  5193  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5194  		}
  5195  		m.SetAlertDecisions(v)
  5196  		return nil
  5197  	}
  5198  	return fmt.Errorf("unknown Decision field %s", name)
  5199  }
  5200  
  5201  // AddedFields returns all numeric fields that were incremented/decremented during
  5202  // this mutation.
  5203  func (m *DecisionMutation) AddedFields() []string {
  5204  	var fields []string
  5205  	if m.addstart_ip != nil {
  5206  		fields = append(fields, decision.FieldStartIP)
  5207  	}
  5208  	if m.addend_ip != nil {
  5209  		fields = append(fields, decision.FieldEndIP)
  5210  	}
  5211  	if m.addstart_suffix != nil {
  5212  		fields = append(fields, decision.FieldStartSuffix)
  5213  	}
  5214  	if m.addend_suffix != nil {
  5215  		fields = append(fields, decision.FieldEndSuffix)
  5216  	}
  5217  	if m.addip_size != nil {
  5218  		fields = append(fields, decision.FieldIPSize)
  5219  	}
  5220  	return fields
  5221  }
  5222  
  5223  // AddedField returns the numeric value that was incremented/decremented on a field
  5224  // with the given name. The second boolean return value indicates that this field
  5225  // was not set, or was not defined in the schema.
  5226  func (m *DecisionMutation) AddedField(name string) (ent.Value, bool) {
  5227  	switch name {
  5228  	case decision.FieldStartIP:
  5229  		return m.AddedStartIP()
  5230  	case decision.FieldEndIP:
  5231  		return m.AddedEndIP()
  5232  	case decision.FieldStartSuffix:
  5233  		return m.AddedStartSuffix()
  5234  	case decision.FieldEndSuffix:
  5235  		return m.AddedEndSuffix()
  5236  	case decision.FieldIPSize:
  5237  		return m.AddedIPSize()
  5238  	}
  5239  	return nil, false
  5240  }
  5241  
  5242  // AddField adds the value to the field with the given name. It returns an error if
  5243  // the field is not defined in the schema, or if the type mismatched the field
  5244  // type.
  5245  func (m *DecisionMutation) AddField(name string, value ent.Value) error {
  5246  	switch name {
  5247  	case decision.FieldStartIP:
  5248  		v, ok := value.(int64)
  5249  		if !ok {
  5250  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5251  		}
  5252  		m.AddStartIP(v)
  5253  		return nil
  5254  	case decision.FieldEndIP:
  5255  		v, ok := value.(int64)
  5256  		if !ok {
  5257  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5258  		}
  5259  		m.AddEndIP(v)
  5260  		return nil
  5261  	case decision.FieldStartSuffix:
  5262  		v, ok := value.(int64)
  5263  		if !ok {
  5264  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5265  		}
  5266  		m.AddStartSuffix(v)
  5267  		return nil
  5268  	case decision.FieldEndSuffix:
  5269  		v, ok := value.(int64)
  5270  		if !ok {
  5271  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5272  		}
  5273  		m.AddEndSuffix(v)
  5274  		return nil
  5275  	case decision.FieldIPSize:
  5276  		v, ok := value.(int64)
  5277  		if !ok {
  5278  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5279  		}
  5280  		m.AddIPSize(v)
  5281  		return nil
  5282  	}
  5283  	return fmt.Errorf("unknown Decision numeric field %s", name)
  5284  }
  5285  
  5286  // ClearedFields returns all nullable fields that were cleared during this
  5287  // mutation.
  5288  func (m *DecisionMutation) ClearedFields() []string {
  5289  	var fields []string
  5290  	if m.FieldCleared(decision.FieldCreatedAt) {
  5291  		fields = append(fields, decision.FieldCreatedAt)
  5292  	}
  5293  	if m.FieldCleared(decision.FieldUpdatedAt) {
  5294  		fields = append(fields, decision.FieldUpdatedAt)
  5295  	}
  5296  	if m.FieldCleared(decision.FieldUntil) {
  5297  		fields = append(fields, decision.FieldUntil)
  5298  	}
  5299  	if m.FieldCleared(decision.FieldStartIP) {
  5300  		fields = append(fields, decision.FieldStartIP)
  5301  	}
  5302  	if m.FieldCleared(decision.FieldEndIP) {
  5303  		fields = append(fields, decision.FieldEndIP)
  5304  	}
  5305  	if m.FieldCleared(decision.FieldStartSuffix) {
  5306  		fields = append(fields, decision.FieldStartSuffix)
  5307  	}
  5308  	if m.FieldCleared(decision.FieldEndSuffix) {
  5309  		fields = append(fields, decision.FieldEndSuffix)
  5310  	}
  5311  	if m.FieldCleared(decision.FieldIPSize) {
  5312  		fields = append(fields, decision.FieldIPSize)
  5313  	}
  5314  	if m.FieldCleared(decision.FieldUUID) {
  5315  		fields = append(fields, decision.FieldUUID)
  5316  	}
  5317  	if m.FieldCleared(decision.FieldAlertDecisions) {
  5318  		fields = append(fields, decision.FieldAlertDecisions)
  5319  	}
  5320  	return fields
  5321  }
  5322  
  5323  // FieldCleared returns a boolean indicating if a field with the given name was
  5324  // cleared in this mutation.
  5325  func (m *DecisionMutation) FieldCleared(name string) bool {
  5326  	_, ok := m.clearedFields[name]
  5327  	return ok
  5328  }
  5329  
  5330  // ClearField clears the value of the field with the given name. It returns an
  5331  // error if the field is not defined in the schema.
  5332  func (m *DecisionMutation) ClearField(name string) error {
  5333  	switch name {
  5334  	case decision.FieldCreatedAt:
  5335  		m.ClearCreatedAt()
  5336  		return nil
  5337  	case decision.FieldUpdatedAt:
  5338  		m.ClearUpdatedAt()
  5339  		return nil
  5340  	case decision.FieldUntil:
  5341  		m.ClearUntil()
  5342  		return nil
  5343  	case decision.FieldStartIP:
  5344  		m.ClearStartIP()
  5345  		return nil
  5346  	case decision.FieldEndIP:
  5347  		m.ClearEndIP()
  5348  		return nil
  5349  	case decision.FieldStartSuffix:
  5350  		m.ClearStartSuffix()
  5351  		return nil
  5352  	case decision.FieldEndSuffix:
  5353  		m.ClearEndSuffix()
  5354  		return nil
  5355  	case decision.FieldIPSize:
  5356  		m.ClearIPSize()
  5357  		return nil
  5358  	case decision.FieldUUID:
  5359  		m.ClearUUID()
  5360  		return nil
  5361  	case decision.FieldAlertDecisions:
  5362  		m.ClearAlertDecisions()
  5363  		return nil
  5364  	}
  5365  	return fmt.Errorf("unknown Decision nullable field %s", name)
  5366  }
  5367  
  5368  // ResetField resets all changes in the mutation for the field with the given name.
  5369  // It returns an error if the field is not defined in the schema.
  5370  func (m *DecisionMutation) ResetField(name string) error {
  5371  	switch name {
  5372  	case decision.FieldCreatedAt:
  5373  		m.ResetCreatedAt()
  5374  		return nil
  5375  	case decision.FieldUpdatedAt:
  5376  		m.ResetUpdatedAt()
  5377  		return nil
  5378  	case decision.FieldUntil:
  5379  		m.ResetUntil()
  5380  		return nil
  5381  	case decision.FieldScenario:
  5382  		m.ResetScenario()
  5383  		return nil
  5384  	case decision.FieldType:
  5385  		m.ResetType()
  5386  		return nil
  5387  	case decision.FieldStartIP:
  5388  		m.ResetStartIP()
  5389  		return nil
  5390  	case decision.FieldEndIP:
  5391  		m.ResetEndIP()
  5392  		return nil
  5393  	case decision.FieldStartSuffix:
  5394  		m.ResetStartSuffix()
  5395  		return nil
  5396  	case decision.FieldEndSuffix:
  5397  		m.ResetEndSuffix()
  5398  		return nil
  5399  	case decision.FieldIPSize:
  5400  		m.ResetIPSize()
  5401  		return nil
  5402  	case decision.FieldScope:
  5403  		m.ResetScope()
  5404  		return nil
  5405  	case decision.FieldValue:
  5406  		m.ResetValue()
  5407  		return nil
  5408  	case decision.FieldOrigin:
  5409  		m.ResetOrigin()
  5410  		return nil
  5411  	case decision.FieldSimulated:
  5412  		m.ResetSimulated()
  5413  		return nil
  5414  	case decision.FieldUUID:
  5415  		m.ResetUUID()
  5416  		return nil
  5417  	case decision.FieldAlertDecisions:
  5418  		m.ResetAlertDecisions()
  5419  		return nil
  5420  	}
  5421  	return fmt.Errorf("unknown Decision field %s", name)
  5422  }
  5423  
  5424  // AddedEdges returns all edge names that were set/added in this mutation.
  5425  func (m *DecisionMutation) AddedEdges() []string {
  5426  	edges := make([]string, 0, 1)
  5427  	if m.owner != nil {
  5428  		edges = append(edges, decision.EdgeOwner)
  5429  	}
  5430  	return edges
  5431  }
  5432  
  5433  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5434  // name in this mutation.
  5435  func (m *DecisionMutation) AddedIDs(name string) []ent.Value {
  5436  	switch name {
  5437  	case decision.EdgeOwner:
  5438  		if id := m.owner; id != nil {
  5439  			return []ent.Value{*id}
  5440  		}
  5441  	}
  5442  	return nil
  5443  }
  5444  
  5445  // RemovedEdges returns all edge names that were removed in this mutation.
  5446  func (m *DecisionMutation) RemovedEdges() []string {
  5447  	edges := make([]string, 0, 1)
  5448  	return edges
  5449  }
  5450  
  5451  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5452  // the given name in this mutation.
  5453  func (m *DecisionMutation) RemovedIDs(name string) []ent.Value {
  5454  	return nil
  5455  }
  5456  
  5457  // ClearedEdges returns all edge names that were cleared in this mutation.
  5458  func (m *DecisionMutation) ClearedEdges() []string {
  5459  	edges := make([]string, 0, 1)
  5460  	if m.clearedowner {
  5461  		edges = append(edges, decision.EdgeOwner)
  5462  	}
  5463  	return edges
  5464  }
  5465  
  5466  // EdgeCleared returns a boolean which indicates if the edge with the given name
  5467  // was cleared in this mutation.
  5468  func (m *DecisionMutation) EdgeCleared(name string) bool {
  5469  	switch name {
  5470  	case decision.EdgeOwner:
  5471  		return m.clearedowner
  5472  	}
  5473  	return false
  5474  }
  5475  
  5476  // ClearEdge clears the value of the edge with the given name. It returns an error
  5477  // if that edge is not defined in the schema.
  5478  func (m *DecisionMutation) ClearEdge(name string) error {
  5479  	switch name {
  5480  	case decision.EdgeOwner:
  5481  		m.ClearOwner()
  5482  		return nil
  5483  	}
  5484  	return fmt.Errorf("unknown Decision unique edge %s", name)
  5485  }
  5486  
  5487  // ResetEdge resets all changes to the edge with the given name in this mutation.
  5488  // It returns an error if the edge is not defined in the schema.
  5489  func (m *DecisionMutation) ResetEdge(name string) error {
  5490  	switch name {
  5491  	case decision.EdgeOwner:
  5492  		m.ResetOwner()
  5493  		return nil
  5494  	}
  5495  	return fmt.Errorf("unknown Decision edge %s", name)
  5496  }
  5497  
  5498  // EventMutation represents an operation that mutates the Event nodes in the graph.
  5499  type EventMutation struct {
  5500  	config
  5501  	op            Op
  5502  	typ           string
  5503  	id            *int
  5504  	created_at    *time.Time
  5505  	updated_at    *time.Time
  5506  	time          *time.Time
  5507  	serialized    *string
  5508  	clearedFields map[string]struct{}
  5509  	owner         *int
  5510  	clearedowner  bool
  5511  	done          bool
  5512  	oldValue      func(context.Context) (*Event, error)
  5513  	predicates    []predicate.Event
  5514  }
  5515  
  5516  var _ ent.Mutation = (*EventMutation)(nil)
  5517  
  5518  // eventOption allows management of the mutation configuration using functional options.
  5519  type eventOption func(*EventMutation)
  5520  
  5521  // newEventMutation creates new mutation for the Event entity.
  5522  func newEventMutation(c config, op Op, opts ...eventOption) *EventMutation {
  5523  	m := &EventMutation{
  5524  		config:        c,
  5525  		op:            op,
  5526  		typ:           TypeEvent,
  5527  		clearedFields: make(map[string]struct{}),
  5528  	}
  5529  	for _, opt := range opts {
  5530  		opt(m)
  5531  	}
  5532  	return m
  5533  }
  5534  
  5535  // withEventID sets the ID field of the mutation.
  5536  func withEventID(id int) eventOption {
  5537  	return func(m *EventMutation) {
  5538  		var (
  5539  			err   error
  5540  			once  sync.Once
  5541  			value *Event
  5542  		)
  5543  		m.oldValue = func(ctx context.Context) (*Event, error) {
  5544  			once.Do(func() {
  5545  				if m.done {
  5546  					err = errors.New("querying old values post mutation is not allowed")
  5547  				} else {
  5548  					value, err = m.Client().Event.Get(ctx, id)
  5549  				}
  5550  			})
  5551  			return value, err
  5552  		}
  5553  		m.id = &id
  5554  	}
  5555  }
  5556  
  5557  // withEvent sets the old Event of the mutation.
  5558  func withEvent(node *Event) eventOption {
  5559  	return func(m *EventMutation) {
  5560  		m.oldValue = func(context.Context) (*Event, error) {
  5561  			return node, nil
  5562  		}
  5563  		m.id = &node.ID
  5564  	}
  5565  }
  5566  
  5567  // Client returns a new `ent.Client` from the mutation. If the mutation was
  5568  // executed in a transaction (ent.Tx), a transactional client is returned.
  5569  func (m EventMutation) Client() *Client {
  5570  	client := &Client{config: m.config}
  5571  	client.init()
  5572  	return client
  5573  }
  5574  
  5575  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5576  // it returns an error otherwise.
  5577  func (m EventMutation) Tx() (*Tx, error) {
  5578  	if _, ok := m.driver.(*txDriver); !ok {
  5579  		return nil, errors.New("ent: mutation is not running in a transaction")
  5580  	}
  5581  	tx := &Tx{config: m.config}
  5582  	tx.init()
  5583  	return tx, nil
  5584  }
  5585  
  5586  // ID returns the ID value in the mutation. Note that the ID is only available
  5587  // if it was provided to the builder or after it was returned from the database.
  5588  func (m *EventMutation) ID() (id int, exists bool) {
  5589  	if m.id == nil {
  5590  		return
  5591  	}
  5592  	return *m.id, true
  5593  }
  5594  
  5595  // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5596  // That means, if the mutation is applied within a transaction with an isolation level such
  5597  // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5598  // or updated by the mutation.
  5599  func (m *EventMutation) IDs(ctx context.Context) ([]int, error) {
  5600  	switch {
  5601  	case m.op.Is(OpUpdateOne | OpDeleteOne):
  5602  		id, exists := m.ID()
  5603  		if exists {
  5604  			return []int{id}, nil
  5605  		}
  5606  		fallthrough
  5607  	case m.op.Is(OpUpdate | OpDelete):
  5608  		return m.Client().Event.Query().Where(m.predicates...).IDs(ctx)
  5609  	default:
  5610  		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5611  	}
  5612  }
  5613  
  5614  // SetCreatedAt sets the "created_at" field.
  5615  func (m *EventMutation) SetCreatedAt(t time.Time) {
  5616  	m.created_at = &t
  5617  }
  5618  
  5619  // CreatedAt returns the value of the "created_at" field in the mutation.
  5620  func (m *EventMutation) CreatedAt() (r time.Time, exists bool) {
  5621  	v := m.created_at
  5622  	if v == nil {
  5623  		return
  5624  	}
  5625  	return *v, true
  5626  }
  5627  
  5628  // OldCreatedAt returns the old "created_at" field's value of the Event entity.
  5629  // If the Event object wasn't provided to the builder, the object is fetched from the database.
  5630  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5631  func (m *EventMutation) OldCreatedAt(ctx context.Context) (v *time.Time, err error) {
  5632  	if !m.op.Is(OpUpdateOne) {
  5633  		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5634  	}
  5635  	if m.id == nil || m.oldValue == nil {
  5636  		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5637  	}
  5638  	oldValue, err := m.oldValue(ctx)
  5639  	if err != nil {
  5640  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5641  	}
  5642  	return oldValue.CreatedAt, nil
  5643  }
  5644  
  5645  // ClearCreatedAt clears the value of the "created_at" field.
  5646  func (m *EventMutation) ClearCreatedAt() {
  5647  	m.created_at = nil
  5648  	m.clearedFields[event.FieldCreatedAt] = struct{}{}
  5649  }
  5650  
  5651  // CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
  5652  func (m *EventMutation) CreatedAtCleared() bool {
  5653  	_, ok := m.clearedFields[event.FieldCreatedAt]
  5654  	return ok
  5655  }
  5656  
  5657  // ResetCreatedAt resets all changes to the "created_at" field.
  5658  func (m *EventMutation) ResetCreatedAt() {
  5659  	m.created_at = nil
  5660  	delete(m.clearedFields, event.FieldCreatedAt)
  5661  }
  5662  
  5663  // SetUpdatedAt sets the "updated_at" field.
  5664  func (m *EventMutation) SetUpdatedAt(t time.Time) {
  5665  	m.updated_at = &t
  5666  }
  5667  
  5668  // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5669  func (m *EventMutation) UpdatedAt() (r time.Time, exists bool) {
  5670  	v := m.updated_at
  5671  	if v == nil {
  5672  		return
  5673  	}
  5674  	return *v, true
  5675  }
  5676  
  5677  // OldUpdatedAt returns the old "updated_at" field's value of the Event entity.
  5678  // If the Event object wasn't provided to the builder, the object is fetched from the database.
  5679  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5680  func (m *EventMutation) OldUpdatedAt(ctx context.Context) (v *time.Time, err error) {
  5681  	if !m.op.Is(OpUpdateOne) {
  5682  		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5683  	}
  5684  	if m.id == nil || m.oldValue == nil {
  5685  		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5686  	}
  5687  	oldValue, err := m.oldValue(ctx)
  5688  	if err != nil {
  5689  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5690  	}
  5691  	return oldValue.UpdatedAt, nil
  5692  }
  5693  
  5694  // ClearUpdatedAt clears the value of the "updated_at" field.
  5695  func (m *EventMutation) ClearUpdatedAt() {
  5696  	m.updated_at = nil
  5697  	m.clearedFields[event.FieldUpdatedAt] = struct{}{}
  5698  }
  5699  
  5700  // UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
  5701  func (m *EventMutation) UpdatedAtCleared() bool {
  5702  	_, ok := m.clearedFields[event.FieldUpdatedAt]
  5703  	return ok
  5704  }
  5705  
  5706  // ResetUpdatedAt resets all changes to the "updated_at" field.
  5707  func (m *EventMutation) ResetUpdatedAt() {
  5708  	m.updated_at = nil
  5709  	delete(m.clearedFields, event.FieldUpdatedAt)
  5710  }
  5711  
  5712  // SetTime sets the "time" field.
  5713  func (m *EventMutation) SetTime(t time.Time) {
  5714  	m.time = &t
  5715  }
  5716  
  5717  // Time returns the value of the "time" field in the mutation.
  5718  func (m *EventMutation) Time() (r time.Time, exists bool) {
  5719  	v := m.time
  5720  	if v == nil {
  5721  		return
  5722  	}
  5723  	return *v, true
  5724  }
  5725  
  5726  // OldTime returns the old "time" field's value of the Event entity.
  5727  // If the Event object wasn't provided to the builder, the object is fetched from the database.
  5728  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5729  func (m *EventMutation) OldTime(ctx context.Context) (v time.Time, err error) {
  5730  	if !m.op.Is(OpUpdateOne) {
  5731  		return v, errors.New("OldTime is only allowed on UpdateOne operations")
  5732  	}
  5733  	if m.id == nil || m.oldValue == nil {
  5734  		return v, errors.New("OldTime requires an ID field in the mutation")
  5735  	}
  5736  	oldValue, err := m.oldValue(ctx)
  5737  	if err != nil {
  5738  		return v, fmt.Errorf("querying old value for OldTime: %w", err)
  5739  	}
  5740  	return oldValue.Time, nil
  5741  }
  5742  
  5743  // ResetTime resets all changes to the "time" field.
  5744  func (m *EventMutation) ResetTime() {
  5745  	m.time = nil
  5746  }
  5747  
  5748  // SetSerialized sets the "serialized" field.
  5749  func (m *EventMutation) SetSerialized(s string) {
  5750  	m.serialized = &s
  5751  }
  5752  
  5753  // Serialized returns the value of the "serialized" field in the mutation.
  5754  func (m *EventMutation) Serialized() (r string, exists bool) {
  5755  	v := m.serialized
  5756  	if v == nil {
  5757  		return
  5758  	}
  5759  	return *v, true
  5760  }
  5761  
  5762  // OldSerialized returns the old "serialized" field's value of the Event entity.
  5763  // If the Event object wasn't provided to the builder, the object is fetched from the database.
  5764  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5765  func (m *EventMutation) OldSerialized(ctx context.Context) (v string, err error) {
  5766  	if !m.op.Is(OpUpdateOne) {
  5767  		return v, errors.New("OldSerialized is only allowed on UpdateOne operations")
  5768  	}
  5769  	if m.id == nil || m.oldValue == nil {
  5770  		return v, errors.New("OldSerialized requires an ID field in the mutation")
  5771  	}
  5772  	oldValue, err := m.oldValue(ctx)
  5773  	if err != nil {
  5774  		return v, fmt.Errorf("querying old value for OldSerialized: %w", err)
  5775  	}
  5776  	return oldValue.Serialized, nil
  5777  }
  5778  
  5779  // ResetSerialized resets all changes to the "serialized" field.
  5780  func (m *EventMutation) ResetSerialized() {
  5781  	m.serialized = nil
  5782  }
  5783  
  5784  // SetAlertEvents sets the "alert_events" field.
  5785  func (m *EventMutation) SetAlertEvents(i int) {
  5786  	m.owner = &i
  5787  }
  5788  
  5789  // AlertEvents returns the value of the "alert_events" field in the mutation.
  5790  func (m *EventMutation) AlertEvents() (r int, exists bool) {
  5791  	v := m.owner
  5792  	if v == nil {
  5793  		return
  5794  	}
  5795  	return *v, true
  5796  }
  5797  
  5798  // OldAlertEvents returns the old "alert_events" field's value of the Event entity.
  5799  // If the Event object wasn't provided to the builder, the object is fetched from the database.
  5800  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5801  func (m *EventMutation) OldAlertEvents(ctx context.Context) (v int, err error) {
  5802  	if !m.op.Is(OpUpdateOne) {
  5803  		return v, errors.New("OldAlertEvents is only allowed on UpdateOne operations")
  5804  	}
  5805  	if m.id == nil || m.oldValue == nil {
  5806  		return v, errors.New("OldAlertEvents requires an ID field in the mutation")
  5807  	}
  5808  	oldValue, err := m.oldValue(ctx)
  5809  	if err != nil {
  5810  		return v, fmt.Errorf("querying old value for OldAlertEvents: %w", err)
  5811  	}
  5812  	return oldValue.AlertEvents, nil
  5813  }
  5814  
  5815  // ClearAlertEvents clears the value of the "alert_events" field.
  5816  func (m *EventMutation) ClearAlertEvents() {
  5817  	m.owner = nil
  5818  	m.clearedFields[event.FieldAlertEvents] = struct{}{}
  5819  }
  5820  
  5821  // AlertEventsCleared returns if the "alert_events" field was cleared in this mutation.
  5822  func (m *EventMutation) AlertEventsCleared() bool {
  5823  	_, ok := m.clearedFields[event.FieldAlertEvents]
  5824  	return ok
  5825  }
  5826  
  5827  // ResetAlertEvents resets all changes to the "alert_events" field.
  5828  func (m *EventMutation) ResetAlertEvents() {
  5829  	m.owner = nil
  5830  	delete(m.clearedFields, event.FieldAlertEvents)
  5831  }
  5832  
  5833  // SetOwnerID sets the "owner" edge to the Alert entity by id.
  5834  func (m *EventMutation) SetOwnerID(id int) {
  5835  	m.owner = &id
  5836  }
  5837  
  5838  // ClearOwner clears the "owner" edge to the Alert entity.
  5839  func (m *EventMutation) ClearOwner() {
  5840  	m.clearedowner = true
  5841  	m.clearedFields[event.FieldAlertEvents] = struct{}{}
  5842  }
  5843  
  5844  // OwnerCleared reports if the "owner" edge to the Alert entity was cleared.
  5845  func (m *EventMutation) OwnerCleared() bool {
  5846  	return m.AlertEventsCleared() || m.clearedowner
  5847  }
  5848  
  5849  // OwnerID returns the "owner" edge ID in the mutation.
  5850  func (m *EventMutation) OwnerID() (id int, exists bool) {
  5851  	if m.owner != nil {
  5852  		return *m.owner, true
  5853  	}
  5854  	return
  5855  }
  5856  
  5857  // OwnerIDs returns the "owner" edge IDs in the mutation.
  5858  // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5859  // OwnerID instead. It exists only for internal usage by the builders.
  5860  func (m *EventMutation) OwnerIDs() (ids []int) {
  5861  	if id := m.owner; id != nil {
  5862  		ids = append(ids, *id)
  5863  	}
  5864  	return
  5865  }
  5866  
  5867  // ResetOwner resets all changes to the "owner" edge.
  5868  func (m *EventMutation) ResetOwner() {
  5869  	m.owner = nil
  5870  	m.clearedowner = false
  5871  }
  5872  
  5873  // Where appends a list predicates to the EventMutation builder.
  5874  func (m *EventMutation) Where(ps ...predicate.Event) {
  5875  	m.predicates = append(m.predicates, ps...)
  5876  }
  5877  
  5878  // WhereP appends storage-level predicates to the EventMutation builder. Using this method,
  5879  // users can use type-assertion to append predicates that do not depend on any generated package.
  5880  func (m *EventMutation) WhereP(ps ...func(*sql.Selector)) {
  5881  	p := make([]predicate.Event, len(ps))
  5882  	for i := range ps {
  5883  		p[i] = ps[i]
  5884  	}
  5885  	m.Where(p...)
  5886  }
  5887  
  5888  // Op returns the operation name.
  5889  func (m *EventMutation) Op() Op {
  5890  	return m.op
  5891  }
  5892  
  5893  // SetOp allows setting the mutation operation.
  5894  func (m *EventMutation) SetOp(op Op) {
  5895  	m.op = op
  5896  }
  5897  
  5898  // Type returns the node type of this mutation (Event).
  5899  func (m *EventMutation) Type() string {
  5900  	return m.typ
  5901  }
  5902  
  5903  // Fields returns all fields that were changed during this mutation. Note that in
  5904  // order to get all numeric fields that were incremented/decremented, call
  5905  // AddedFields().
  5906  func (m *EventMutation) Fields() []string {
  5907  	fields := make([]string, 0, 5)
  5908  	if m.created_at != nil {
  5909  		fields = append(fields, event.FieldCreatedAt)
  5910  	}
  5911  	if m.updated_at != nil {
  5912  		fields = append(fields, event.FieldUpdatedAt)
  5913  	}
  5914  	if m.time != nil {
  5915  		fields = append(fields, event.FieldTime)
  5916  	}
  5917  	if m.serialized != nil {
  5918  		fields = append(fields, event.FieldSerialized)
  5919  	}
  5920  	if m.owner != nil {
  5921  		fields = append(fields, event.FieldAlertEvents)
  5922  	}
  5923  	return fields
  5924  }
  5925  
  5926  // Field returns the value of a field with the given name. The second boolean
  5927  // return value indicates that this field was not set, or was not defined in the
  5928  // schema.
  5929  func (m *EventMutation) Field(name string) (ent.Value, bool) {
  5930  	switch name {
  5931  	case event.FieldCreatedAt:
  5932  		return m.CreatedAt()
  5933  	case event.FieldUpdatedAt:
  5934  		return m.UpdatedAt()
  5935  	case event.FieldTime:
  5936  		return m.Time()
  5937  	case event.FieldSerialized:
  5938  		return m.Serialized()
  5939  	case event.FieldAlertEvents:
  5940  		return m.AlertEvents()
  5941  	}
  5942  	return nil, false
  5943  }
  5944  
  5945  // OldField returns the old value of the field from the database. An error is
  5946  // returned if the mutation operation is not UpdateOne, or the query to the
  5947  // database failed.
  5948  func (m *EventMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5949  	switch name {
  5950  	case event.FieldCreatedAt:
  5951  		return m.OldCreatedAt(ctx)
  5952  	case event.FieldUpdatedAt:
  5953  		return m.OldUpdatedAt(ctx)
  5954  	case event.FieldTime:
  5955  		return m.OldTime(ctx)
  5956  	case event.FieldSerialized:
  5957  		return m.OldSerialized(ctx)
  5958  	case event.FieldAlertEvents:
  5959  		return m.OldAlertEvents(ctx)
  5960  	}
  5961  	return nil, fmt.Errorf("unknown Event field %s", name)
  5962  }
  5963  
  5964  // SetField sets the value of a field with the given name. It returns an error if
  5965  // the field is not defined in the schema, or if the type mismatched the field
  5966  // type.
  5967  func (m *EventMutation) SetField(name string, value ent.Value) error {
  5968  	switch name {
  5969  	case event.FieldCreatedAt:
  5970  		v, ok := value.(time.Time)
  5971  		if !ok {
  5972  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5973  		}
  5974  		m.SetCreatedAt(v)
  5975  		return nil
  5976  	case event.FieldUpdatedAt:
  5977  		v, ok := value.(time.Time)
  5978  		if !ok {
  5979  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5980  		}
  5981  		m.SetUpdatedAt(v)
  5982  		return nil
  5983  	case event.FieldTime:
  5984  		v, ok := value.(time.Time)
  5985  		if !ok {
  5986  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5987  		}
  5988  		m.SetTime(v)
  5989  		return nil
  5990  	case event.FieldSerialized:
  5991  		v, ok := value.(string)
  5992  		if !ok {
  5993  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  5994  		}
  5995  		m.SetSerialized(v)
  5996  		return nil
  5997  	case event.FieldAlertEvents:
  5998  		v, ok := value.(int)
  5999  		if !ok {
  6000  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  6001  		}
  6002  		m.SetAlertEvents(v)
  6003  		return nil
  6004  	}
  6005  	return fmt.Errorf("unknown Event field %s", name)
  6006  }
  6007  
  6008  // AddedFields returns all numeric fields that were incremented/decremented during
  6009  // this mutation.
  6010  func (m *EventMutation) AddedFields() []string {
  6011  	var fields []string
  6012  	return fields
  6013  }
  6014  
  6015  // AddedField returns the numeric value that was incremented/decremented on a field
  6016  // with the given name. The second boolean return value indicates that this field
  6017  // was not set, or was not defined in the schema.
  6018  func (m *EventMutation) AddedField(name string) (ent.Value, bool) {
  6019  	switch name {
  6020  	}
  6021  	return nil, false
  6022  }
  6023  
  6024  // AddField adds the value to the field with the given name. It returns an error if
  6025  // the field is not defined in the schema, or if the type mismatched the field
  6026  // type.
  6027  func (m *EventMutation) AddField(name string, value ent.Value) error {
  6028  	switch name {
  6029  	}
  6030  	return fmt.Errorf("unknown Event numeric field %s", name)
  6031  }
  6032  
  6033  // ClearedFields returns all nullable fields that were cleared during this
  6034  // mutation.
  6035  func (m *EventMutation) ClearedFields() []string {
  6036  	var fields []string
  6037  	if m.FieldCleared(event.FieldCreatedAt) {
  6038  		fields = append(fields, event.FieldCreatedAt)
  6039  	}
  6040  	if m.FieldCleared(event.FieldUpdatedAt) {
  6041  		fields = append(fields, event.FieldUpdatedAt)
  6042  	}
  6043  	if m.FieldCleared(event.FieldAlertEvents) {
  6044  		fields = append(fields, event.FieldAlertEvents)
  6045  	}
  6046  	return fields
  6047  }
  6048  
  6049  // FieldCleared returns a boolean indicating if a field with the given name was
  6050  // cleared in this mutation.
  6051  func (m *EventMutation) FieldCleared(name string) bool {
  6052  	_, ok := m.clearedFields[name]
  6053  	return ok
  6054  }
  6055  
  6056  // ClearField clears the value of the field with the given name. It returns an
  6057  // error if the field is not defined in the schema.
  6058  func (m *EventMutation) ClearField(name string) error {
  6059  	switch name {
  6060  	case event.FieldCreatedAt:
  6061  		m.ClearCreatedAt()
  6062  		return nil
  6063  	case event.FieldUpdatedAt:
  6064  		m.ClearUpdatedAt()
  6065  		return nil
  6066  	case event.FieldAlertEvents:
  6067  		m.ClearAlertEvents()
  6068  		return nil
  6069  	}
  6070  	return fmt.Errorf("unknown Event nullable field %s", name)
  6071  }
  6072  
  6073  // ResetField resets all changes in the mutation for the field with the given name.
  6074  // It returns an error if the field is not defined in the schema.
  6075  func (m *EventMutation) ResetField(name string) error {
  6076  	switch name {
  6077  	case event.FieldCreatedAt:
  6078  		m.ResetCreatedAt()
  6079  		return nil
  6080  	case event.FieldUpdatedAt:
  6081  		m.ResetUpdatedAt()
  6082  		return nil
  6083  	case event.FieldTime:
  6084  		m.ResetTime()
  6085  		return nil
  6086  	case event.FieldSerialized:
  6087  		m.ResetSerialized()
  6088  		return nil
  6089  	case event.FieldAlertEvents:
  6090  		m.ResetAlertEvents()
  6091  		return nil
  6092  	}
  6093  	return fmt.Errorf("unknown Event field %s", name)
  6094  }
  6095  
  6096  // AddedEdges returns all edge names that were set/added in this mutation.
  6097  func (m *EventMutation) AddedEdges() []string {
  6098  	edges := make([]string, 0, 1)
  6099  	if m.owner != nil {
  6100  		edges = append(edges, event.EdgeOwner)
  6101  	}
  6102  	return edges
  6103  }
  6104  
  6105  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6106  // name in this mutation.
  6107  func (m *EventMutation) AddedIDs(name string) []ent.Value {
  6108  	switch name {
  6109  	case event.EdgeOwner:
  6110  		if id := m.owner; id != nil {
  6111  			return []ent.Value{*id}
  6112  		}
  6113  	}
  6114  	return nil
  6115  }
  6116  
  6117  // RemovedEdges returns all edge names that were removed in this mutation.
  6118  func (m *EventMutation) RemovedEdges() []string {
  6119  	edges := make([]string, 0, 1)
  6120  	return edges
  6121  }
  6122  
  6123  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6124  // the given name in this mutation.
  6125  func (m *EventMutation) RemovedIDs(name string) []ent.Value {
  6126  	return nil
  6127  }
  6128  
  6129  // ClearedEdges returns all edge names that were cleared in this mutation.
  6130  func (m *EventMutation) ClearedEdges() []string {
  6131  	edges := make([]string, 0, 1)
  6132  	if m.clearedowner {
  6133  		edges = append(edges, event.EdgeOwner)
  6134  	}
  6135  	return edges
  6136  }
  6137  
  6138  // EdgeCleared returns a boolean which indicates if the edge with the given name
  6139  // was cleared in this mutation.
  6140  func (m *EventMutation) EdgeCleared(name string) bool {
  6141  	switch name {
  6142  	case event.EdgeOwner:
  6143  		return m.clearedowner
  6144  	}
  6145  	return false
  6146  }
  6147  
  6148  // ClearEdge clears the value of the edge with the given name. It returns an error
  6149  // if that edge is not defined in the schema.
  6150  func (m *EventMutation) ClearEdge(name string) error {
  6151  	switch name {
  6152  	case event.EdgeOwner:
  6153  		m.ClearOwner()
  6154  		return nil
  6155  	}
  6156  	return fmt.Errorf("unknown Event unique edge %s", name)
  6157  }
  6158  
  6159  // ResetEdge resets all changes to the edge with the given name in this mutation.
  6160  // It returns an error if the edge is not defined in the schema.
  6161  func (m *EventMutation) ResetEdge(name string) error {
  6162  	switch name {
  6163  	case event.EdgeOwner:
  6164  		m.ResetOwner()
  6165  		return nil
  6166  	}
  6167  	return fmt.Errorf("unknown Event edge %s", name)
  6168  }
  6169  
  6170  // LockMutation represents an operation that mutates the Lock nodes in the graph.
  6171  type LockMutation struct {
  6172  	config
  6173  	op            Op
  6174  	typ           string
  6175  	id            *int
  6176  	name          *string
  6177  	created_at    *time.Time
  6178  	clearedFields map[string]struct{}
  6179  	done          bool
  6180  	oldValue      func(context.Context) (*Lock, error)
  6181  	predicates    []predicate.Lock
  6182  }
  6183  
  6184  var _ ent.Mutation = (*LockMutation)(nil)
  6185  
  6186  // lockOption allows management of the mutation configuration using functional options.
  6187  type lockOption func(*LockMutation)
  6188  
  6189  // newLockMutation creates new mutation for the Lock entity.
  6190  func newLockMutation(c config, op Op, opts ...lockOption) *LockMutation {
  6191  	m := &LockMutation{
  6192  		config:        c,
  6193  		op:            op,
  6194  		typ:           TypeLock,
  6195  		clearedFields: make(map[string]struct{}),
  6196  	}
  6197  	for _, opt := range opts {
  6198  		opt(m)
  6199  	}
  6200  	return m
  6201  }
  6202  
  6203  // withLockID sets the ID field of the mutation.
  6204  func withLockID(id int) lockOption {
  6205  	return func(m *LockMutation) {
  6206  		var (
  6207  			err   error
  6208  			once  sync.Once
  6209  			value *Lock
  6210  		)
  6211  		m.oldValue = func(ctx context.Context) (*Lock, error) {
  6212  			once.Do(func() {
  6213  				if m.done {
  6214  					err = errors.New("querying old values post mutation is not allowed")
  6215  				} else {
  6216  					value, err = m.Client().Lock.Get(ctx, id)
  6217  				}
  6218  			})
  6219  			return value, err
  6220  		}
  6221  		m.id = &id
  6222  	}
  6223  }
  6224  
  6225  // withLock sets the old Lock of the mutation.
  6226  func withLock(node *Lock) lockOption {
  6227  	return func(m *LockMutation) {
  6228  		m.oldValue = func(context.Context) (*Lock, error) {
  6229  			return node, nil
  6230  		}
  6231  		m.id = &node.ID
  6232  	}
  6233  }
  6234  
  6235  // Client returns a new `ent.Client` from the mutation. If the mutation was
  6236  // executed in a transaction (ent.Tx), a transactional client is returned.
  6237  func (m LockMutation) Client() *Client {
  6238  	client := &Client{config: m.config}
  6239  	client.init()
  6240  	return client
  6241  }
  6242  
  6243  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6244  // it returns an error otherwise.
  6245  func (m LockMutation) Tx() (*Tx, error) {
  6246  	if _, ok := m.driver.(*txDriver); !ok {
  6247  		return nil, errors.New("ent: mutation is not running in a transaction")
  6248  	}
  6249  	tx := &Tx{config: m.config}
  6250  	tx.init()
  6251  	return tx, nil
  6252  }
  6253  
  6254  // ID returns the ID value in the mutation. Note that the ID is only available
  6255  // if it was provided to the builder or after it was returned from the database.
  6256  func (m *LockMutation) ID() (id int, exists bool) {
  6257  	if m.id == nil {
  6258  		return
  6259  	}
  6260  	return *m.id, true
  6261  }
  6262  
  6263  // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6264  // That means, if the mutation is applied within a transaction with an isolation level such
  6265  // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6266  // or updated by the mutation.
  6267  func (m *LockMutation) IDs(ctx context.Context) ([]int, error) {
  6268  	switch {
  6269  	case m.op.Is(OpUpdateOne | OpDeleteOne):
  6270  		id, exists := m.ID()
  6271  		if exists {
  6272  			return []int{id}, nil
  6273  		}
  6274  		fallthrough
  6275  	case m.op.Is(OpUpdate | OpDelete):
  6276  		return m.Client().Lock.Query().Where(m.predicates...).IDs(ctx)
  6277  	default:
  6278  		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6279  	}
  6280  }
  6281  
  6282  // SetName sets the "name" field.
  6283  func (m *LockMutation) SetName(s string) {
  6284  	m.name = &s
  6285  }
  6286  
  6287  // Name returns the value of the "name" field in the mutation.
  6288  func (m *LockMutation) Name() (r string, exists bool) {
  6289  	v := m.name
  6290  	if v == nil {
  6291  		return
  6292  	}
  6293  	return *v, true
  6294  }
  6295  
  6296  // OldName returns the old "name" field's value of the Lock entity.
  6297  // If the Lock object wasn't provided to the builder, the object is fetched from the database.
  6298  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6299  func (m *LockMutation) OldName(ctx context.Context) (v string, err error) {
  6300  	if !m.op.Is(OpUpdateOne) {
  6301  		return v, errors.New("OldName is only allowed on UpdateOne operations")
  6302  	}
  6303  	if m.id == nil || m.oldValue == nil {
  6304  		return v, errors.New("OldName requires an ID field in the mutation")
  6305  	}
  6306  	oldValue, err := m.oldValue(ctx)
  6307  	if err != nil {
  6308  		return v, fmt.Errorf("querying old value for OldName: %w", err)
  6309  	}
  6310  	return oldValue.Name, nil
  6311  }
  6312  
  6313  // ResetName resets all changes to the "name" field.
  6314  func (m *LockMutation) ResetName() {
  6315  	m.name = nil
  6316  }
  6317  
  6318  // SetCreatedAt sets the "created_at" field.
  6319  func (m *LockMutation) SetCreatedAt(t time.Time) {
  6320  	m.created_at = &t
  6321  }
  6322  
  6323  // CreatedAt returns the value of the "created_at" field in the mutation.
  6324  func (m *LockMutation) CreatedAt() (r time.Time, exists bool) {
  6325  	v := m.created_at
  6326  	if v == nil {
  6327  		return
  6328  	}
  6329  	return *v, true
  6330  }
  6331  
  6332  // OldCreatedAt returns the old "created_at" field's value of the Lock entity.
  6333  // If the Lock object wasn't provided to the builder, the object is fetched from the database.
  6334  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6335  func (m *LockMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6336  	if !m.op.Is(OpUpdateOne) {
  6337  		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6338  	}
  6339  	if m.id == nil || m.oldValue == nil {
  6340  		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6341  	}
  6342  	oldValue, err := m.oldValue(ctx)
  6343  	if err != nil {
  6344  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6345  	}
  6346  	return oldValue.CreatedAt, nil
  6347  }
  6348  
  6349  // ResetCreatedAt resets all changes to the "created_at" field.
  6350  func (m *LockMutation) ResetCreatedAt() {
  6351  	m.created_at = nil
  6352  }
  6353  
  6354  // Where appends a list predicates to the LockMutation builder.
  6355  func (m *LockMutation) Where(ps ...predicate.Lock) {
  6356  	m.predicates = append(m.predicates, ps...)
  6357  }
  6358  
  6359  // WhereP appends storage-level predicates to the LockMutation builder. Using this method,
  6360  // users can use type-assertion to append predicates that do not depend on any generated package.
  6361  func (m *LockMutation) WhereP(ps ...func(*sql.Selector)) {
  6362  	p := make([]predicate.Lock, len(ps))
  6363  	for i := range ps {
  6364  		p[i] = ps[i]
  6365  	}
  6366  	m.Where(p...)
  6367  }
  6368  
  6369  // Op returns the operation name.
  6370  func (m *LockMutation) Op() Op {
  6371  	return m.op
  6372  }
  6373  
  6374  // SetOp allows setting the mutation operation.
  6375  func (m *LockMutation) SetOp(op Op) {
  6376  	m.op = op
  6377  }
  6378  
  6379  // Type returns the node type of this mutation (Lock).
  6380  func (m *LockMutation) Type() string {
  6381  	return m.typ
  6382  }
  6383  
  6384  // Fields returns all fields that were changed during this mutation. Note that in
  6385  // order to get all numeric fields that were incremented/decremented, call
  6386  // AddedFields().
  6387  func (m *LockMutation) Fields() []string {
  6388  	fields := make([]string, 0, 2)
  6389  	if m.name != nil {
  6390  		fields = append(fields, lock.FieldName)
  6391  	}
  6392  	if m.created_at != nil {
  6393  		fields = append(fields, lock.FieldCreatedAt)
  6394  	}
  6395  	return fields
  6396  }
  6397  
  6398  // Field returns the value of a field with the given name. The second boolean
  6399  // return value indicates that this field was not set, or was not defined in the
  6400  // schema.
  6401  func (m *LockMutation) Field(name string) (ent.Value, bool) {
  6402  	switch name {
  6403  	case lock.FieldName:
  6404  		return m.Name()
  6405  	case lock.FieldCreatedAt:
  6406  		return m.CreatedAt()
  6407  	}
  6408  	return nil, false
  6409  }
  6410  
  6411  // OldField returns the old value of the field from the database. An error is
  6412  // returned if the mutation operation is not UpdateOne, or the query to the
  6413  // database failed.
  6414  func (m *LockMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6415  	switch name {
  6416  	case lock.FieldName:
  6417  		return m.OldName(ctx)
  6418  	case lock.FieldCreatedAt:
  6419  		return m.OldCreatedAt(ctx)
  6420  	}
  6421  	return nil, fmt.Errorf("unknown Lock field %s", name)
  6422  }
  6423  
  6424  // SetField sets the value of a field with the given name. It returns an error if
  6425  // the field is not defined in the schema, or if the type mismatched the field
  6426  // type.
  6427  func (m *LockMutation) SetField(name string, value ent.Value) error {
  6428  	switch name {
  6429  	case lock.FieldName:
  6430  		v, ok := value.(string)
  6431  		if !ok {
  6432  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  6433  		}
  6434  		m.SetName(v)
  6435  		return nil
  6436  	case lock.FieldCreatedAt:
  6437  		v, ok := value.(time.Time)
  6438  		if !ok {
  6439  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  6440  		}
  6441  		m.SetCreatedAt(v)
  6442  		return nil
  6443  	}
  6444  	return fmt.Errorf("unknown Lock field %s", name)
  6445  }
  6446  
  6447  // AddedFields returns all numeric fields that were incremented/decremented during
  6448  // this mutation.
  6449  func (m *LockMutation) AddedFields() []string {
  6450  	return nil
  6451  }
  6452  
  6453  // AddedField returns the numeric value that was incremented/decremented on a field
  6454  // with the given name. The second boolean return value indicates that this field
  6455  // was not set, or was not defined in the schema.
  6456  func (m *LockMutation) AddedField(name string) (ent.Value, bool) {
  6457  	return nil, false
  6458  }
  6459  
  6460  // AddField adds the value to the field with the given name. It returns an error if
  6461  // the field is not defined in the schema, or if the type mismatched the field
  6462  // type.
  6463  func (m *LockMutation) AddField(name string, value ent.Value) error {
  6464  	switch name {
  6465  	}
  6466  	return fmt.Errorf("unknown Lock numeric field %s", name)
  6467  }
  6468  
  6469  // ClearedFields returns all nullable fields that were cleared during this
  6470  // mutation.
  6471  func (m *LockMutation) ClearedFields() []string {
  6472  	return nil
  6473  }
  6474  
  6475  // FieldCleared returns a boolean indicating if a field with the given name was
  6476  // cleared in this mutation.
  6477  func (m *LockMutation) FieldCleared(name string) bool {
  6478  	_, ok := m.clearedFields[name]
  6479  	return ok
  6480  }
  6481  
  6482  // ClearField clears the value of the field with the given name. It returns an
  6483  // error if the field is not defined in the schema.
  6484  func (m *LockMutation) ClearField(name string) error {
  6485  	return fmt.Errorf("unknown Lock nullable field %s", name)
  6486  }
  6487  
  6488  // ResetField resets all changes in the mutation for the field with the given name.
  6489  // It returns an error if the field is not defined in the schema.
  6490  func (m *LockMutation) ResetField(name string) error {
  6491  	switch name {
  6492  	case lock.FieldName:
  6493  		m.ResetName()
  6494  		return nil
  6495  	case lock.FieldCreatedAt:
  6496  		m.ResetCreatedAt()
  6497  		return nil
  6498  	}
  6499  	return fmt.Errorf("unknown Lock field %s", name)
  6500  }
  6501  
  6502  // AddedEdges returns all edge names that were set/added in this mutation.
  6503  func (m *LockMutation) AddedEdges() []string {
  6504  	edges := make([]string, 0, 0)
  6505  	return edges
  6506  }
  6507  
  6508  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6509  // name in this mutation.
  6510  func (m *LockMutation) AddedIDs(name string) []ent.Value {
  6511  	return nil
  6512  }
  6513  
  6514  // RemovedEdges returns all edge names that were removed in this mutation.
  6515  func (m *LockMutation) RemovedEdges() []string {
  6516  	edges := make([]string, 0, 0)
  6517  	return edges
  6518  }
  6519  
  6520  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6521  // the given name in this mutation.
  6522  func (m *LockMutation) RemovedIDs(name string) []ent.Value {
  6523  	return nil
  6524  }
  6525  
  6526  // ClearedEdges returns all edge names that were cleared in this mutation.
  6527  func (m *LockMutation) ClearedEdges() []string {
  6528  	edges := make([]string, 0, 0)
  6529  	return edges
  6530  }
  6531  
  6532  // EdgeCleared returns a boolean which indicates if the edge with the given name
  6533  // was cleared in this mutation.
  6534  func (m *LockMutation) EdgeCleared(name string) bool {
  6535  	return false
  6536  }
  6537  
  6538  // ClearEdge clears the value of the edge with the given name. It returns an error
  6539  // if that edge is not defined in the schema.
  6540  func (m *LockMutation) ClearEdge(name string) error {
  6541  	return fmt.Errorf("unknown Lock unique edge %s", name)
  6542  }
  6543  
  6544  // ResetEdge resets all changes to the edge with the given name in this mutation.
  6545  // It returns an error if the edge is not defined in the schema.
  6546  func (m *LockMutation) ResetEdge(name string) error {
  6547  	return fmt.Errorf("unknown Lock edge %s", name)
  6548  }
  6549  
  6550  // MachineMutation represents an operation that mutates the Machine nodes in the graph.
  6551  type MachineMutation struct {
  6552  	config
  6553  	op             Op
  6554  	typ            string
  6555  	id             *int
  6556  	created_at     *time.Time
  6557  	updated_at     *time.Time
  6558  	last_push      *time.Time
  6559  	last_heartbeat *time.Time
  6560  	machineId      *string
  6561  	password       *string
  6562  	ipAddress      *string
  6563  	scenarios      *string
  6564  	version        *string
  6565  	isValidated    *bool
  6566  	status         *string
  6567  	auth_type      *string
  6568  	clearedFields  map[string]struct{}
  6569  	alerts         map[int]struct{}
  6570  	removedalerts  map[int]struct{}
  6571  	clearedalerts  bool
  6572  	done           bool
  6573  	oldValue       func(context.Context) (*Machine, error)
  6574  	predicates     []predicate.Machine
  6575  }
  6576  
  6577  var _ ent.Mutation = (*MachineMutation)(nil)
  6578  
  6579  // machineOption allows management of the mutation configuration using functional options.
  6580  type machineOption func(*MachineMutation)
  6581  
  6582  // newMachineMutation creates new mutation for the Machine entity.
  6583  func newMachineMutation(c config, op Op, opts ...machineOption) *MachineMutation {
  6584  	m := &MachineMutation{
  6585  		config:        c,
  6586  		op:            op,
  6587  		typ:           TypeMachine,
  6588  		clearedFields: make(map[string]struct{}),
  6589  	}
  6590  	for _, opt := range opts {
  6591  		opt(m)
  6592  	}
  6593  	return m
  6594  }
  6595  
  6596  // withMachineID sets the ID field of the mutation.
  6597  func withMachineID(id int) machineOption {
  6598  	return func(m *MachineMutation) {
  6599  		var (
  6600  			err   error
  6601  			once  sync.Once
  6602  			value *Machine
  6603  		)
  6604  		m.oldValue = func(ctx context.Context) (*Machine, error) {
  6605  			once.Do(func() {
  6606  				if m.done {
  6607  					err = errors.New("querying old values post mutation is not allowed")
  6608  				} else {
  6609  					value, err = m.Client().Machine.Get(ctx, id)
  6610  				}
  6611  			})
  6612  			return value, err
  6613  		}
  6614  		m.id = &id
  6615  	}
  6616  }
  6617  
  6618  // withMachine sets the old Machine of the mutation.
  6619  func withMachine(node *Machine) machineOption {
  6620  	return func(m *MachineMutation) {
  6621  		m.oldValue = func(context.Context) (*Machine, error) {
  6622  			return node, nil
  6623  		}
  6624  		m.id = &node.ID
  6625  	}
  6626  }
  6627  
  6628  // Client returns a new `ent.Client` from the mutation. If the mutation was
  6629  // executed in a transaction (ent.Tx), a transactional client is returned.
  6630  func (m MachineMutation) Client() *Client {
  6631  	client := &Client{config: m.config}
  6632  	client.init()
  6633  	return client
  6634  }
  6635  
  6636  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6637  // it returns an error otherwise.
  6638  func (m MachineMutation) Tx() (*Tx, error) {
  6639  	if _, ok := m.driver.(*txDriver); !ok {
  6640  		return nil, errors.New("ent: mutation is not running in a transaction")
  6641  	}
  6642  	tx := &Tx{config: m.config}
  6643  	tx.init()
  6644  	return tx, nil
  6645  }
  6646  
  6647  // ID returns the ID value in the mutation. Note that the ID is only available
  6648  // if it was provided to the builder or after it was returned from the database.
  6649  func (m *MachineMutation) ID() (id int, exists bool) {
  6650  	if m.id == nil {
  6651  		return
  6652  	}
  6653  	return *m.id, true
  6654  }
  6655  
  6656  // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6657  // That means, if the mutation is applied within a transaction with an isolation level such
  6658  // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6659  // or updated by the mutation.
  6660  func (m *MachineMutation) IDs(ctx context.Context) ([]int, error) {
  6661  	switch {
  6662  	case m.op.Is(OpUpdateOne | OpDeleteOne):
  6663  		id, exists := m.ID()
  6664  		if exists {
  6665  			return []int{id}, nil
  6666  		}
  6667  		fallthrough
  6668  	case m.op.Is(OpUpdate | OpDelete):
  6669  		return m.Client().Machine.Query().Where(m.predicates...).IDs(ctx)
  6670  	default:
  6671  		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6672  	}
  6673  }
  6674  
  6675  // SetCreatedAt sets the "created_at" field.
  6676  func (m *MachineMutation) SetCreatedAt(t time.Time) {
  6677  	m.created_at = &t
  6678  }
  6679  
  6680  // CreatedAt returns the value of the "created_at" field in the mutation.
  6681  func (m *MachineMutation) CreatedAt() (r time.Time, exists bool) {
  6682  	v := m.created_at
  6683  	if v == nil {
  6684  		return
  6685  	}
  6686  	return *v, true
  6687  }
  6688  
  6689  // OldCreatedAt returns the old "created_at" field's value of the Machine entity.
  6690  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  6691  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6692  func (m *MachineMutation) OldCreatedAt(ctx context.Context) (v *time.Time, err error) {
  6693  	if !m.op.Is(OpUpdateOne) {
  6694  		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6695  	}
  6696  	if m.id == nil || m.oldValue == nil {
  6697  		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6698  	}
  6699  	oldValue, err := m.oldValue(ctx)
  6700  	if err != nil {
  6701  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6702  	}
  6703  	return oldValue.CreatedAt, nil
  6704  }
  6705  
  6706  // ClearCreatedAt clears the value of the "created_at" field.
  6707  func (m *MachineMutation) ClearCreatedAt() {
  6708  	m.created_at = nil
  6709  	m.clearedFields[machine.FieldCreatedAt] = struct{}{}
  6710  }
  6711  
  6712  // CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
  6713  func (m *MachineMutation) CreatedAtCleared() bool {
  6714  	_, ok := m.clearedFields[machine.FieldCreatedAt]
  6715  	return ok
  6716  }
  6717  
  6718  // ResetCreatedAt resets all changes to the "created_at" field.
  6719  func (m *MachineMutation) ResetCreatedAt() {
  6720  	m.created_at = nil
  6721  	delete(m.clearedFields, machine.FieldCreatedAt)
  6722  }
  6723  
  6724  // SetUpdatedAt sets the "updated_at" field.
  6725  func (m *MachineMutation) SetUpdatedAt(t time.Time) {
  6726  	m.updated_at = &t
  6727  }
  6728  
  6729  // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6730  func (m *MachineMutation) UpdatedAt() (r time.Time, exists bool) {
  6731  	v := m.updated_at
  6732  	if v == nil {
  6733  		return
  6734  	}
  6735  	return *v, true
  6736  }
  6737  
  6738  // OldUpdatedAt returns the old "updated_at" field's value of the Machine entity.
  6739  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  6740  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6741  func (m *MachineMutation) OldUpdatedAt(ctx context.Context) (v *time.Time, err error) {
  6742  	if !m.op.Is(OpUpdateOne) {
  6743  		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6744  	}
  6745  	if m.id == nil || m.oldValue == nil {
  6746  		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6747  	}
  6748  	oldValue, err := m.oldValue(ctx)
  6749  	if err != nil {
  6750  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6751  	}
  6752  	return oldValue.UpdatedAt, nil
  6753  }
  6754  
  6755  // ClearUpdatedAt clears the value of the "updated_at" field.
  6756  func (m *MachineMutation) ClearUpdatedAt() {
  6757  	m.updated_at = nil
  6758  	m.clearedFields[machine.FieldUpdatedAt] = struct{}{}
  6759  }
  6760  
  6761  // UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
  6762  func (m *MachineMutation) UpdatedAtCleared() bool {
  6763  	_, ok := m.clearedFields[machine.FieldUpdatedAt]
  6764  	return ok
  6765  }
  6766  
  6767  // ResetUpdatedAt resets all changes to the "updated_at" field.
  6768  func (m *MachineMutation) ResetUpdatedAt() {
  6769  	m.updated_at = nil
  6770  	delete(m.clearedFields, machine.FieldUpdatedAt)
  6771  }
  6772  
  6773  // SetLastPush sets the "last_push" field.
  6774  func (m *MachineMutation) SetLastPush(t time.Time) {
  6775  	m.last_push = &t
  6776  }
  6777  
  6778  // LastPush returns the value of the "last_push" field in the mutation.
  6779  func (m *MachineMutation) LastPush() (r time.Time, exists bool) {
  6780  	v := m.last_push
  6781  	if v == nil {
  6782  		return
  6783  	}
  6784  	return *v, true
  6785  }
  6786  
  6787  // OldLastPush returns the old "last_push" field's value of the Machine entity.
  6788  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  6789  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6790  func (m *MachineMutation) OldLastPush(ctx context.Context) (v *time.Time, err error) {
  6791  	if !m.op.Is(OpUpdateOne) {
  6792  		return v, errors.New("OldLastPush is only allowed on UpdateOne operations")
  6793  	}
  6794  	if m.id == nil || m.oldValue == nil {
  6795  		return v, errors.New("OldLastPush requires an ID field in the mutation")
  6796  	}
  6797  	oldValue, err := m.oldValue(ctx)
  6798  	if err != nil {
  6799  		return v, fmt.Errorf("querying old value for OldLastPush: %w", err)
  6800  	}
  6801  	return oldValue.LastPush, nil
  6802  }
  6803  
  6804  // ClearLastPush clears the value of the "last_push" field.
  6805  func (m *MachineMutation) ClearLastPush() {
  6806  	m.last_push = nil
  6807  	m.clearedFields[machine.FieldLastPush] = struct{}{}
  6808  }
  6809  
  6810  // LastPushCleared returns if the "last_push" field was cleared in this mutation.
  6811  func (m *MachineMutation) LastPushCleared() bool {
  6812  	_, ok := m.clearedFields[machine.FieldLastPush]
  6813  	return ok
  6814  }
  6815  
  6816  // ResetLastPush resets all changes to the "last_push" field.
  6817  func (m *MachineMutation) ResetLastPush() {
  6818  	m.last_push = nil
  6819  	delete(m.clearedFields, machine.FieldLastPush)
  6820  }
  6821  
  6822  // SetLastHeartbeat sets the "last_heartbeat" field.
  6823  func (m *MachineMutation) SetLastHeartbeat(t time.Time) {
  6824  	m.last_heartbeat = &t
  6825  }
  6826  
  6827  // LastHeartbeat returns the value of the "last_heartbeat" field in the mutation.
  6828  func (m *MachineMutation) LastHeartbeat() (r time.Time, exists bool) {
  6829  	v := m.last_heartbeat
  6830  	if v == nil {
  6831  		return
  6832  	}
  6833  	return *v, true
  6834  }
  6835  
  6836  // OldLastHeartbeat returns the old "last_heartbeat" field's value of the Machine entity.
  6837  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  6838  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6839  func (m *MachineMutation) OldLastHeartbeat(ctx context.Context) (v *time.Time, err error) {
  6840  	if !m.op.Is(OpUpdateOne) {
  6841  		return v, errors.New("OldLastHeartbeat is only allowed on UpdateOne operations")
  6842  	}
  6843  	if m.id == nil || m.oldValue == nil {
  6844  		return v, errors.New("OldLastHeartbeat requires an ID field in the mutation")
  6845  	}
  6846  	oldValue, err := m.oldValue(ctx)
  6847  	if err != nil {
  6848  		return v, fmt.Errorf("querying old value for OldLastHeartbeat: %w", err)
  6849  	}
  6850  	return oldValue.LastHeartbeat, nil
  6851  }
  6852  
  6853  // ClearLastHeartbeat clears the value of the "last_heartbeat" field.
  6854  func (m *MachineMutation) ClearLastHeartbeat() {
  6855  	m.last_heartbeat = nil
  6856  	m.clearedFields[machine.FieldLastHeartbeat] = struct{}{}
  6857  }
  6858  
  6859  // LastHeartbeatCleared returns if the "last_heartbeat" field was cleared in this mutation.
  6860  func (m *MachineMutation) LastHeartbeatCleared() bool {
  6861  	_, ok := m.clearedFields[machine.FieldLastHeartbeat]
  6862  	return ok
  6863  }
  6864  
  6865  // ResetLastHeartbeat resets all changes to the "last_heartbeat" field.
  6866  func (m *MachineMutation) ResetLastHeartbeat() {
  6867  	m.last_heartbeat = nil
  6868  	delete(m.clearedFields, machine.FieldLastHeartbeat)
  6869  }
  6870  
  6871  // SetMachineId sets the "machineId" field.
  6872  func (m *MachineMutation) SetMachineId(s string) {
  6873  	m.machineId = &s
  6874  }
  6875  
  6876  // MachineId returns the value of the "machineId" field in the mutation.
  6877  func (m *MachineMutation) MachineId() (r string, exists bool) {
  6878  	v := m.machineId
  6879  	if v == nil {
  6880  		return
  6881  	}
  6882  	return *v, true
  6883  }
  6884  
  6885  // OldMachineId returns the old "machineId" field's value of the Machine entity.
  6886  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  6887  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6888  func (m *MachineMutation) OldMachineId(ctx context.Context) (v string, err error) {
  6889  	if !m.op.Is(OpUpdateOne) {
  6890  		return v, errors.New("OldMachineId is only allowed on UpdateOne operations")
  6891  	}
  6892  	if m.id == nil || m.oldValue == nil {
  6893  		return v, errors.New("OldMachineId requires an ID field in the mutation")
  6894  	}
  6895  	oldValue, err := m.oldValue(ctx)
  6896  	if err != nil {
  6897  		return v, fmt.Errorf("querying old value for OldMachineId: %w", err)
  6898  	}
  6899  	return oldValue.MachineId, nil
  6900  }
  6901  
  6902  // ResetMachineId resets all changes to the "machineId" field.
  6903  func (m *MachineMutation) ResetMachineId() {
  6904  	m.machineId = nil
  6905  }
  6906  
  6907  // SetPassword sets the "password" field.
  6908  func (m *MachineMutation) SetPassword(s string) {
  6909  	m.password = &s
  6910  }
  6911  
  6912  // Password returns the value of the "password" field in the mutation.
  6913  func (m *MachineMutation) Password() (r string, exists bool) {
  6914  	v := m.password
  6915  	if v == nil {
  6916  		return
  6917  	}
  6918  	return *v, true
  6919  }
  6920  
  6921  // OldPassword returns the old "password" field's value of the Machine entity.
  6922  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  6923  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6924  func (m *MachineMutation) OldPassword(ctx context.Context) (v string, err error) {
  6925  	if !m.op.Is(OpUpdateOne) {
  6926  		return v, errors.New("OldPassword is only allowed on UpdateOne operations")
  6927  	}
  6928  	if m.id == nil || m.oldValue == nil {
  6929  		return v, errors.New("OldPassword requires an ID field in the mutation")
  6930  	}
  6931  	oldValue, err := m.oldValue(ctx)
  6932  	if err != nil {
  6933  		return v, fmt.Errorf("querying old value for OldPassword: %w", err)
  6934  	}
  6935  	return oldValue.Password, nil
  6936  }
  6937  
  6938  // ResetPassword resets all changes to the "password" field.
  6939  func (m *MachineMutation) ResetPassword() {
  6940  	m.password = nil
  6941  }
  6942  
  6943  // SetIpAddress sets the "ipAddress" field.
  6944  func (m *MachineMutation) SetIpAddress(s string) {
  6945  	m.ipAddress = &s
  6946  }
  6947  
  6948  // IpAddress returns the value of the "ipAddress" field in the mutation.
  6949  func (m *MachineMutation) IpAddress() (r string, exists bool) {
  6950  	v := m.ipAddress
  6951  	if v == nil {
  6952  		return
  6953  	}
  6954  	return *v, true
  6955  }
  6956  
  6957  // OldIpAddress returns the old "ipAddress" field's value of the Machine entity.
  6958  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  6959  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6960  func (m *MachineMutation) OldIpAddress(ctx context.Context) (v string, err error) {
  6961  	if !m.op.Is(OpUpdateOne) {
  6962  		return v, errors.New("OldIpAddress is only allowed on UpdateOne operations")
  6963  	}
  6964  	if m.id == nil || m.oldValue == nil {
  6965  		return v, errors.New("OldIpAddress requires an ID field in the mutation")
  6966  	}
  6967  	oldValue, err := m.oldValue(ctx)
  6968  	if err != nil {
  6969  		return v, fmt.Errorf("querying old value for OldIpAddress: %w", err)
  6970  	}
  6971  	return oldValue.IpAddress, nil
  6972  }
  6973  
  6974  // ResetIpAddress resets all changes to the "ipAddress" field.
  6975  func (m *MachineMutation) ResetIpAddress() {
  6976  	m.ipAddress = nil
  6977  }
  6978  
  6979  // SetScenarios sets the "scenarios" field.
  6980  func (m *MachineMutation) SetScenarios(s string) {
  6981  	m.scenarios = &s
  6982  }
  6983  
  6984  // Scenarios returns the value of the "scenarios" field in the mutation.
  6985  func (m *MachineMutation) Scenarios() (r string, exists bool) {
  6986  	v := m.scenarios
  6987  	if v == nil {
  6988  		return
  6989  	}
  6990  	return *v, true
  6991  }
  6992  
  6993  // OldScenarios returns the old "scenarios" field's value of the Machine entity.
  6994  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  6995  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6996  func (m *MachineMutation) OldScenarios(ctx context.Context) (v string, err error) {
  6997  	if !m.op.Is(OpUpdateOne) {
  6998  		return v, errors.New("OldScenarios is only allowed on UpdateOne operations")
  6999  	}
  7000  	if m.id == nil || m.oldValue == nil {
  7001  		return v, errors.New("OldScenarios requires an ID field in the mutation")
  7002  	}
  7003  	oldValue, err := m.oldValue(ctx)
  7004  	if err != nil {
  7005  		return v, fmt.Errorf("querying old value for OldScenarios: %w", err)
  7006  	}
  7007  	return oldValue.Scenarios, nil
  7008  }
  7009  
  7010  // ClearScenarios clears the value of the "scenarios" field.
  7011  func (m *MachineMutation) ClearScenarios() {
  7012  	m.scenarios = nil
  7013  	m.clearedFields[machine.FieldScenarios] = struct{}{}
  7014  }
  7015  
  7016  // ScenariosCleared returns if the "scenarios" field was cleared in this mutation.
  7017  func (m *MachineMutation) ScenariosCleared() bool {
  7018  	_, ok := m.clearedFields[machine.FieldScenarios]
  7019  	return ok
  7020  }
  7021  
  7022  // ResetScenarios resets all changes to the "scenarios" field.
  7023  func (m *MachineMutation) ResetScenarios() {
  7024  	m.scenarios = nil
  7025  	delete(m.clearedFields, machine.FieldScenarios)
  7026  }
  7027  
  7028  // SetVersion sets the "version" field.
  7029  func (m *MachineMutation) SetVersion(s string) {
  7030  	m.version = &s
  7031  }
  7032  
  7033  // Version returns the value of the "version" field in the mutation.
  7034  func (m *MachineMutation) Version() (r string, exists bool) {
  7035  	v := m.version
  7036  	if v == nil {
  7037  		return
  7038  	}
  7039  	return *v, true
  7040  }
  7041  
  7042  // OldVersion returns the old "version" field's value of the Machine entity.
  7043  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  7044  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7045  func (m *MachineMutation) OldVersion(ctx context.Context) (v string, err error) {
  7046  	if !m.op.Is(OpUpdateOne) {
  7047  		return v, errors.New("OldVersion is only allowed on UpdateOne operations")
  7048  	}
  7049  	if m.id == nil || m.oldValue == nil {
  7050  		return v, errors.New("OldVersion requires an ID field in the mutation")
  7051  	}
  7052  	oldValue, err := m.oldValue(ctx)
  7053  	if err != nil {
  7054  		return v, fmt.Errorf("querying old value for OldVersion: %w", err)
  7055  	}
  7056  	return oldValue.Version, nil
  7057  }
  7058  
  7059  // ClearVersion clears the value of the "version" field.
  7060  func (m *MachineMutation) ClearVersion() {
  7061  	m.version = nil
  7062  	m.clearedFields[machine.FieldVersion] = struct{}{}
  7063  }
  7064  
  7065  // VersionCleared returns if the "version" field was cleared in this mutation.
  7066  func (m *MachineMutation) VersionCleared() bool {
  7067  	_, ok := m.clearedFields[machine.FieldVersion]
  7068  	return ok
  7069  }
  7070  
  7071  // ResetVersion resets all changes to the "version" field.
  7072  func (m *MachineMutation) ResetVersion() {
  7073  	m.version = nil
  7074  	delete(m.clearedFields, machine.FieldVersion)
  7075  }
  7076  
  7077  // SetIsValidated sets the "isValidated" field.
  7078  func (m *MachineMutation) SetIsValidated(b bool) {
  7079  	m.isValidated = &b
  7080  }
  7081  
  7082  // IsValidated returns the value of the "isValidated" field in the mutation.
  7083  func (m *MachineMutation) IsValidated() (r bool, exists bool) {
  7084  	v := m.isValidated
  7085  	if v == nil {
  7086  		return
  7087  	}
  7088  	return *v, true
  7089  }
  7090  
  7091  // OldIsValidated returns the old "isValidated" field's value of the Machine entity.
  7092  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  7093  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7094  func (m *MachineMutation) OldIsValidated(ctx context.Context) (v bool, err error) {
  7095  	if !m.op.Is(OpUpdateOne) {
  7096  		return v, errors.New("OldIsValidated is only allowed on UpdateOne operations")
  7097  	}
  7098  	if m.id == nil || m.oldValue == nil {
  7099  		return v, errors.New("OldIsValidated requires an ID field in the mutation")
  7100  	}
  7101  	oldValue, err := m.oldValue(ctx)
  7102  	if err != nil {
  7103  		return v, fmt.Errorf("querying old value for OldIsValidated: %w", err)
  7104  	}
  7105  	return oldValue.IsValidated, nil
  7106  }
  7107  
  7108  // ResetIsValidated resets all changes to the "isValidated" field.
  7109  func (m *MachineMutation) ResetIsValidated() {
  7110  	m.isValidated = nil
  7111  }
  7112  
  7113  // SetStatus sets the "status" field.
  7114  func (m *MachineMutation) SetStatus(s string) {
  7115  	m.status = &s
  7116  }
  7117  
  7118  // Status returns the value of the "status" field in the mutation.
  7119  func (m *MachineMutation) Status() (r string, exists bool) {
  7120  	v := m.status
  7121  	if v == nil {
  7122  		return
  7123  	}
  7124  	return *v, true
  7125  }
  7126  
  7127  // OldStatus returns the old "status" field's value of the Machine entity.
  7128  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  7129  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7130  func (m *MachineMutation) OldStatus(ctx context.Context) (v string, err error) {
  7131  	if !m.op.Is(OpUpdateOne) {
  7132  		return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7133  	}
  7134  	if m.id == nil || m.oldValue == nil {
  7135  		return v, errors.New("OldStatus requires an ID field in the mutation")
  7136  	}
  7137  	oldValue, err := m.oldValue(ctx)
  7138  	if err != nil {
  7139  		return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7140  	}
  7141  	return oldValue.Status, nil
  7142  }
  7143  
  7144  // ClearStatus clears the value of the "status" field.
  7145  func (m *MachineMutation) ClearStatus() {
  7146  	m.status = nil
  7147  	m.clearedFields[machine.FieldStatus] = struct{}{}
  7148  }
  7149  
  7150  // StatusCleared returns if the "status" field was cleared in this mutation.
  7151  func (m *MachineMutation) StatusCleared() bool {
  7152  	_, ok := m.clearedFields[machine.FieldStatus]
  7153  	return ok
  7154  }
  7155  
  7156  // ResetStatus resets all changes to the "status" field.
  7157  func (m *MachineMutation) ResetStatus() {
  7158  	m.status = nil
  7159  	delete(m.clearedFields, machine.FieldStatus)
  7160  }
  7161  
  7162  // SetAuthType sets the "auth_type" field.
  7163  func (m *MachineMutation) SetAuthType(s string) {
  7164  	m.auth_type = &s
  7165  }
  7166  
  7167  // AuthType returns the value of the "auth_type" field in the mutation.
  7168  func (m *MachineMutation) AuthType() (r string, exists bool) {
  7169  	v := m.auth_type
  7170  	if v == nil {
  7171  		return
  7172  	}
  7173  	return *v, true
  7174  }
  7175  
  7176  // OldAuthType returns the old "auth_type" field's value of the Machine entity.
  7177  // If the Machine object wasn't provided to the builder, the object is fetched from the database.
  7178  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7179  func (m *MachineMutation) OldAuthType(ctx context.Context) (v string, err error) {
  7180  	if !m.op.Is(OpUpdateOne) {
  7181  		return v, errors.New("OldAuthType is only allowed on UpdateOne operations")
  7182  	}
  7183  	if m.id == nil || m.oldValue == nil {
  7184  		return v, errors.New("OldAuthType requires an ID field in the mutation")
  7185  	}
  7186  	oldValue, err := m.oldValue(ctx)
  7187  	if err != nil {
  7188  		return v, fmt.Errorf("querying old value for OldAuthType: %w", err)
  7189  	}
  7190  	return oldValue.AuthType, nil
  7191  }
  7192  
  7193  // ResetAuthType resets all changes to the "auth_type" field.
  7194  func (m *MachineMutation) ResetAuthType() {
  7195  	m.auth_type = nil
  7196  }
  7197  
  7198  // AddAlertIDs adds the "alerts" edge to the Alert entity by ids.
  7199  func (m *MachineMutation) AddAlertIDs(ids ...int) {
  7200  	if m.alerts == nil {
  7201  		m.alerts = make(map[int]struct{})
  7202  	}
  7203  	for i := range ids {
  7204  		m.alerts[ids[i]] = struct{}{}
  7205  	}
  7206  }
  7207  
  7208  // ClearAlerts clears the "alerts" edge to the Alert entity.
  7209  func (m *MachineMutation) ClearAlerts() {
  7210  	m.clearedalerts = true
  7211  }
  7212  
  7213  // AlertsCleared reports if the "alerts" edge to the Alert entity was cleared.
  7214  func (m *MachineMutation) AlertsCleared() bool {
  7215  	return m.clearedalerts
  7216  }
  7217  
  7218  // RemoveAlertIDs removes the "alerts" edge to the Alert entity by IDs.
  7219  func (m *MachineMutation) RemoveAlertIDs(ids ...int) {
  7220  	if m.removedalerts == nil {
  7221  		m.removedalerts = make(map[int]struct{})
  7222  	}
  7223  	for i := range ids {
  7224  		delete(m.alerts, ids[i])
  7225  		m.removedalerts[ids[i]] = struct{}{}
  7226  	}
  7227  }
  7228  
  7229  // RemovedAlerts returns the removed IDs of the "alerts" edge to the Alert entity.
  7230  func (m *MachineMutation) RemovedAlertsIDs() (ids []int) {
  7231  	for id := range m.removedalerts {
  7232  		ids = append(ids, id)
  7233  	}
  7234  	return
  7235  }
  7236  
  7237  // AlertsIDs returns the "alerts" edge IDs in the mutation.
  7238  func (m *MachineMutation) AlertsIDs() (ids []int) {
  7239  	for id := range m.alerts {
  7240  		ids = append(ids, id)
  7241  	}
  7242  	return
  7243  }
  7244  
  7245  // ResetAlerts resets all changes to the "alerts" edge.
  7246  func (m *MachineMutation) ResetAlerts() {
  7247  	m.alerts = nil
  7248  	m.clearedalerts = false
  7249  	m.removedalerts = nil
  7250  }
  7251  
  7252  // Where appends a list predicates to the MachineMutation builder.
  7253  func (m *MachineMutation) Where(ps ...predicate.Machine) {
  7254  	m.predicates = append(m.predicates, ps...)
  7255  }
  7256  
  7257  // WhereP appends storage-level predicates to the MachineMutation builder. Using this method,
  7258  // users can use type-assertion to append predicates that do not depend on any generated package.
  7259  func (m *MachineMutation) WhereP(ps ...func(*sql.Selector)) {
  7260  	p := make([]predicate.Machine, len(ps))
  7261  	for i := range ps {
  7262  		p[i] = ps[i]
  7263  	}
  7264  	m.Where(p...)
  7265  }
  7266  
  7267  // Op returns the operation name.
  7268  func (m *MachineMutation) Op() Op {
  7269  	return m.op
  7270  }
  7271  
  7272  // SetOp allows setting the mutation operation.
  7273  func (m *MachineMutation) SetOp(op Op) {
  7274  	m.op = op
  7275  }
  7276  
  7277  // Type returns the node type of this mutation (Machine).
  7278  func (m *MachineMutation) Type() string {
  7279  	return m.typ
  7280  }
  7281  
  7282  // Fields returns all fields that were changed during this mutation. Note that in
  7283  // order to get all numeric fields that were incremented/decremented, call
  7284  // AddedFields().
  7285  func (m *MachineMutation) Fields() []string {
  7286  	fields := make([]string, 0, 12)
  7287  	if m.created_at != nil {
  7288  		fields = append(fields, machine.FieldCreatedAt)
  7289  	}
  7290  	if m.updated_at != nil {
  7291  		fields = append(fields, machine.FieldUpdatedAt)
  7292  	}
  7293  	if m.last_push != nil {
  7294  		fields = append(fields, machine.FieldLastPush)
  7295  	}
  7296  	if m.last_heartbeat != nil {
  7297  		fields = append(fields, machine.FieldLastHeartbeat)
  7298  	}
  7299  	if m.machineId != nil {
  7300  		fields = append(fields, machine.FieldMachineId)
  7301  	}
  7302  	if m.password != nil {
  7303  		fields = append(fields, machine.FieldPassword)
  7304  	}
  7305  	if m.ipAddress != nil {
  7306  		fields = append(fields, machine.FieldIpAddress)
  7307  	}
  7308  	if m.scenarios != nil {
  7309  		fields = append(fields, machine.FieldScenarios)
  7310  	}
  7311  	if m.version != nil {
  7312  		fields = append(fields, machine.FieldVersion)
  7313  	}
  7314  	if m.isValidated != nil {
  7315  		fields = append(fields, machine.FieldIsValidated)
  7316  	}
  7317  	if m.status != nil {
  7318  		fields = append(fields, machine.FieldStatus)
  7319  	}
  7320  	if m.auth_type != nil {
  7321  		fields = append(fields, machine.FieldAuthType)
  7322  	}
  7323  	return fields
  7324  }
  7325  
  7326  // Field returns the value of a field with the given name. The second boolean
  7327  // return value indicates that this field was not set, or was not defined in the
  7328  // schema.
  7329  func (m *MachineMutation) Field(name string) (ent.Value, bool) {
  7330  	switch name {
  7331  	case machine.FieldCreatedAt:
  7332  		return m.CreatedAt()
  7333  	case machine.FieldUpdatedAt:
  7334  		return m.UpdatedAt()
  7335  	case machine.FieldLastPush:
  7336  		return m.LastPush()
  7337  	case machine.FieldLastHeartbeat:
  7338  		return m.LastHeartbeat()
  7339  	case machine.FieldMachineId:
  7340  		return m.MachineId()
  7341  	case machine.FieldPassword:
  7342  		return m.Password()
  7343  	case machine.FieldIpAddress:
  7344  		return m.IpAddress()
  7345  	case machine.FieldScenarios:
  7346  		return m.Scenarios()
  7347  	case machine.FieldVersion:
  7348  		return m.Version()
  7349  	case machine.FieldIsValidated:
  7350  		return m.IsValidated()
  7351  	case machine.FieldStatus:
  7352  		return m.Status()
  7353  	case machine.FieldAuthType:
  7354  		return m.AuthType()
  7355  	}
  7356  	return nil, false
  7357  }
  7358  
  7359  // OldField returns the old value of the field from the database. An error is
  7360  // returned if the mutation operation is not UpdateOne, or the query to the
  7361  // database failed.
  7362  func (m *MachineMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7363  	switch name {
  7364  	case machine.FieldCreatedAt:
  7365  		return m.OldCreatedAt(ctx)
  7366  	case machine.FieldUpdatedAt:
  7367  		return m.OldUpdatedAt(ctx)
  7368  	case machine.FieldLastPush:
  7369  		return m.OldLastPush(ctx)
  7370  	case machine.FieldLastHeartbeat:
  7371  		return m.OldLastHeartbeat(ctx)
  7372  	case machine.FieldMachineId:
  7373  		return m.OldMachineId(ctx)
  7374  	case machine.FieldPassword:
  7375  		return m.OldPassword(ctx)
  7376  	case machine.FieldIpAddress:
  7377  		return m.OldIpAddress(ctx)
  7378  	case machine.FieldScenarios:
  7379  		return m.OldScenarios(ctx)
  7380  	case machine.FieldVersion:
  7381  		return m.OldVersion(ctx)
  7382  	case machine.FieldIsValidated:
  7383  		return m.OldIsValidated(ctx)
  7384  	case machine.FieldStatus:
  7385  		return m.OldStatus(ctx)
  7386  	case machine.FieldAuthType:
  7387  		return m.OldAuthType(ctx)
  7388  	}
  7389  	return nil, fmt.Errorf("unknown Machine field %s", name)
  7390  }
  7391  
  7392  // SetField sets the value of a field with the given name. It returns an error if
  7393  // the field is not defined in the schema, or if the type mismatched the field
  7394  // type.
  7395  func (m *MachineMutation) SetField(name string, value ent.Value) error {
  7396  	switch name {
  7397  	case machine.FieldCreatedAt:
  7398  		v, ok := value.(time.Time)
  7399  		if !ok {
  7400  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7401  		}
  7402  		m.SetCreatedAt(v)
  7403  		return nil
  7404  	case machine.FieldUpdatedAt:
  7405  		v, ok := value.(time.Time)
  7406  		if !ok {
  7407  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7408  		}
  7409  		m.SetUpdatedAt(v)
  7410  		return nil
  7411  	case machine.FieldLastPush:
  7412  		v, ok := value.(time.Time)
  7413  		if !ok {
  7414  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7415  		}
  7416  		m.SetLastPush(v)
  7417  		return nil
  7418  	case machine.FieldLastHeartbeat:
  7419  		v, ok := value.(time.Time)
  7420  		if !ok {
  7421  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7422  		}
  7423  		m.SetLastHeartbeat(v)
  7424  		return nil
  7425  	case machine.FieldMachineId:
  7426  		v, ok := value.(string)
  7427  		if !ok {
  7428  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7429  		}
  7430  		m.SetMachineId(v)
  7431  		return nil
  7432  	case machine.FieldPassword:
  7433  		v, ok := value.(string)
  7434  		if !ok {
  7435  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7436  		}
  7437  		m.SetPassword(v)
  7438  		return nil
  7439  	case machine.FieldIpAddress:
  7440  		v, ok := value.(string)
  7441  		if !ok {
  7442  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7443  		}
  7444  		m.SetIpAddress(v)
  7445  		return nil
  7446  	case machine.FieldScenarios:
  7447  		v, ok := value.(string)
  7448  		if !ok {
  7449  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7450  		}
  7451  		m.SetScenarios(v)
  7452  		return nil
  7453  	case machine.FieldVersion:
  7454  		v, ok := value.(string)
  7455  		if !ok {
  7456  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7457  		}
  7458  		m.SetVersion(v)
  7459  		return nil
  7460  	case machine.FieldIsValidated:
  7461  		v, ok := value.(bool)
  7462  		if !ok {
  7463  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7464  		}
  7465  		m.SetIsValidated(v)
  7466  		return nil
  7467  	case machine.FieldStatus:
  7468  		v, ok := value.(string)
  7469  		if !ok {
  7470  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7471  		}
  7472  		m.SetStatus(v)
  7473  		return nil
  7474  	case machine.FieldAuthType:
  7475  		v, ok := value.(string)
  7476  		if !ok {
  7477  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  7478  		}
  7479  		m.SetAuthType(v)
  7480  		return nil
  7481  	}
  7482  	return fmt.Errorf("unknown Machine field %s", name)
  7483  }
  7484  
  7485  // AddedFields returns all numeric fields that were incremented/decremented during
  7486  // this mutation.
  7487  func (m *MachineMutation) AddedFields() []string {
  7488  	return nil
  7489  }
  7490  
  7491  // AddedField returns the numeric value that was incremented/decremented on a field
  7492  // with the given name. The second boolean return value indicates that this field
  7493  // was not set, or was not defined in the schema.
  7494  func (m *MachineMutation) AddedField(name string) (ent.Value, bool) {
  7495  	return nil, false
  7496  }
  7497  
  7498  // AddField adds the value to the field with the given name. It returns an error if
  7499  // the field is not defined in the schema, or if the type mismatched the field
  7500  // type.
  7501  func (m *MachineMutation) AddField(name string, value ent.Value) error {
  7502  	switch name {
  7503  	}
  7504  	return fmt.Errorf("unknown Machine numeric field %s", name)
  7505  }
  7506  
  7507  // ClearedFields returns all nullable fields that were cleared during this
  7508  // mutation.
  7509  func (m *MachineMutation) ClearedFields() []string {
  7510  	var fields []string
  7511  	if m.FieldCleared(machine.FieldCreatedAt) {
  7512  		fields = append(fields, machine.FieldCreatedAt)
  7513  	}
  7514  	if m.FieldCleared(machine.FieldUpdatedAt) {
  7515  		fields = append(fields, machine.FieldUpdatedAt)
  7516  	}
  7517  	if m.FieldCleared(machine.FieldLastPush) {
  7518  		fields = append(fields, machine.FieldLastPush)
  7519  	}
  7520  	if m.FieldCleared(machine.FieldLastHeartbeat) {
  7521  		fields = append(fields, machine.FieldLastHeartbeat)
  7522  	}
  7523  	if m.FieldCleared(machine.FieldScenarios) {
  7524  		fields = append(fields, machine.FieldScenarios)
  7525  	}
  7526  	if m.FieldCleared(machine.FieldVersion) {
  7527  		fields = append(fields, machine.FieldVersion)
  7528  	}
  7529  	if m.FieldCleared(machine.FieldStatus) {
  7530  		fields = append(fields, machine.FieldStatus)
  7531  	}
  7532  	return fields
  7533  }
  7534  
  7535  // FieldCleared returns a boolean indicating if a field with the given name was
  7536  // cleared in this mutation.
  7537  func (m *MachineMutation) FieldCleared(name string) bool {
  7538  	_, ok := m.clearedFields[name]
  7539  	return ok
  7540  }
  7541  
  7542  // ClearField clears the value of the field with the given name. It returns an
  7543  // error if the field is not defined in the schema.
  7544  func (m *MachineMutation) ClearField(name string) error {
  7545  	switch name {
  7546  	case machine.FieldCreatedAt:
  7547  		m.ClearCreatedAt()
  7548  		return nil
  7549  	case machine.FieldUpdatedAt:
  7550  		m.ClearUpdatedAt()
  7551  		return nil
  7552  	case machine.FieldLastPush:
  7553  		m.ClearLastPush()
  7554  		return nil
  7555  	case machine.FieldLastHeartbeat:
  7556  		m.ClearLastHeartbeat()
  7557  		return nil
  7558  	case machine.FieldScenarios:
  7559  		m.ClearScenarios()
  7560  		return nil
  7561  	case machine.FieldVersion:
  7562  		m.ClearVersion()
  7563  		return nil
  7564  	case machine.FieldStatus:
  7565  		m.ClearStatus()
  7566  		return nil
  7567  	}
  7568  	return fmt.Errorf("unknown Machine nullable field %s", name)
  7569  }
  7570  
  7571  // ResetField resets all changes in the mutation for the field with the given name.
  7572  // It returns an error if the field is not defined in the schema.
  7573  func (m *MachineMutation) ResetField(name string) error {
  7574  	switch name {
  7575  	case machine.FieldCreatedAt:
  7576  		m.ResetCreatedAt()
  7577  		return nil
  7578  	case machine.FieldUpdatedAt:
  7579  		m.ResetUpdatedAt()
  7580  		return nil
  7581  	case machine.FieldLastPush:
  7582  		m.ResetLastPush()
  7583  		return nil
  7584  	case machine.FieldLastHeartbeat:
  7585  		m.ResetLastHeartbeat()
  7586  		return nil
  7587  	case machine.FieldMachineId:
  7588  		m.ResetMachineId()
  7589  		return nil
  7590  	case machine.FieldPassword:
  7591  		m.ResetPassword()
  7592  		return nil
  7593  	case machine.FieldIpAddress:
  7594  		m.ResetIpAddress()
  7595  		return nil
  7596  	case machine.FieldScenarios:
  7597  		m.ResetScenarios()
  7598  		return nil
  7599  	case machine.FieldVersion:
  7600  		m.ResetVersion()
  7601  		return nil
  7602  	case machine.FieldIsValidated:
  7603  		m.ResetIsValidated()
  7604  		return nil
  7605  	case machine.FieldStatus:
  7606  		m.ResetStatus()
  7607  		return nil
  7608  	case machine.FieldAuthType:
  7609  		m.ResetAuthType()
  7610  		return nil
  7611  	}
  7612  	return fmt.Errorf("unknown Machine field %s", name)
  7613  }
  7614  
  7615  // AddedEdges returns all edge names that were set/added in this mutation.
  7616  func (m *MachineMutation) AddedEdges() []string {
  7617  	edges := make([]string, 0, 1)
  7618  	if m.alerts != nil {
  7619  		edges = append(edges, machine.EdgeAlerts)
  7620  	}
  7621  	return edges
  7622  }
  7623  
  7624  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7625  // name in this mutation.
  7626  func (m *MachineMutation) AddedIDs(name string) []ent.Value {
  7627  	switch name {
  7628  	case machine.EdgeAlerts:
  7629  		ids := make([]ent.Value, 0, len(m.alerts))
  7630  		for id := range m.alerts {
  7631  			ids = append(ids, id)
  7632  		}
  7633  		return ids
  7634  	}
  7635  	return nil
  7636  }
  7637  
  7638  // RemovedEdges returns all edge names that were removed in this mutation.
  7639  func (m *MachineMutation) RemovedEdges() []string {
  7640  	edges := make([]string, 0, 1)
  7641  	if m.removedalerts != nil {
  7642  		edges = append(edges, machine.EdgeAlerts)
  7643  	}
  7644  	return edges
  7645  }
  7646  
  7647  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7648  // the given name in this mutation.
  7649  func (m *MachineMutation) RemovedIDs(name string) []ent.Value {
  7650  	switch name {
  7651  	case machine.EdgeAlerts:
  7652  		ids := make([]ent.Value, 0, len(m.removedalerts))
  7653  		for id := range m.removedalerts {
  7654  			ids = append(ids, id)
  7655  		}
  7656  		return ids
  7657  	}
  7658  	return nil
  7659  }
  7660  
  7661  // ClearedEdges returns all edge names that were cleared in this mutation.
  7662  func (m *MachineMutation) ClearedEdges() []string {
  7663  	edges := make([]string, 0, 1)
  7664  	if m.clearedalerts {
  7665  		edges = append(edges, machine.EdgeAlerts)
  7666  	}
  7667  	return edges
  7668  }
  7669  
  7670  // EdgeCleared returns a boolean which indicates if the edge with the given name
  7671  // was cleared in this mutation.
  7672  func (m *MachineMutation) EdgeCleared(name string) bool {
  7673  	switch name {
  7674  	case machine.EdgeAlerts:
  7675  		return m.clearedalerts
  7676  	}
  7677  	return false
  7678  }
  7679  
  7680  // ClearEdge clears the value of the edge with the given name. It returns an error
  7681  // if that edge is not defined in the schema.
  7682  func (m *MachineMutation) ClearEdge(name string) error {
  7683  	switch name {
  7684  	}
  7685  	return fmt.Errorf("unknown Machine unique edge %s", name)
  7686  }
  7687  
  7688  // ResetEdge resets all changes to the edge with the given name in this mutation.
  7689  // It returns an error if the edge is not defined in the schema.
  7690  func (m *MachineMutation) ResetEdge(name string) error {
  7691  	switch name {
  7692  	case machine.EdgeAlerts:
  7693  		m.ResetAlerts()
  7694  		return nil
  7695  	}
  7696  	return fmt.Errorf("unknown Machine edge %s", name)
  7697  }
  7698  
  7699  // MetaMutation represents an operation that mutates the Meta nodes in the graph.
  7700  type MetaMutation struct {
  7701  	config
  7702  	op            Op
  7703  	typ           string
  7704  	id            *int
  7705  	created_at    *time.Time
  7706  	updated_at    *time.Time
  7707  	key           *string
  7708  	value         *string
  7709  	clearedFields map[string]struct{}
  7710  	owner         *int
  7711  	clearedowner  bool
  7712  	done          bool
  7713  	oldValue      func(context.Context) (*Meta, error)
  7714  	predicates    []predicate.Meta
  7715  }
  7716  
  7717  var _ ent.Mutation = (*MetaMutation)(nil)
  7718  
  7719  // metaOption allows management of the mutation configuration using functional options.
  7720  type metaOption func(*MetaMutation)
  7721  
  7722  // newMetaMutation creates new mutation for the Meta entity.
  7723  func newMetaMutation(c config, op Op, opts ...metaOption) *MetaMutation {
  7724  	m := &MetaMutation{
  7725  		config:        c,
  7726  		op:            op,
  7727  		typ:           TypeMeta,
  7728  		clearedFields: make(map[string]struct{}),
  7729  	}
  7730  	for _, opt := range opts {
  7731  		opt(m)
  7732  	}
  7733  	return m
  7734  }
  7735  
  7736  // withMetaID sets the ID field of the mutation.
  7737  func withMetaID(id int) metaOption {
  7738  	return func(m *MetaMutation) {
  7739  		var (
  7740  			err   error
  7741  			once  sync.Once
  7742  			value *Meta
  7743  		)
  7744  		m.oldValue = func(ctx context.Context) (*Meta, error) {
  7745  			once.Do(func() {
  7746  				if m.done {
  7747  					err = errors.New("querying old values post mutation is not allowed")
  7748  				} else {
  7749  					value, err = m.Client().Meta.Get(ctx, id)
  7750  				}
  7751  			})
  7752  			return value, err
  7753  		}
  7754  		m.id = &id
  7755  	}
  7756  }
  7757  
  7758  // withMeta sets the old Meta of the mutation.
  7759  func withMeta(node *Meta) metaOption {
  7760  	return func(m *MetaMutation) {
  7761  		m.oldValue = func(context.Context) (*Meta, error) {
  7762  			return node, nil
  7763  		}
  7764  		m.id = &node.ID
  7765  	}
  7766  }
  7767  
  7768  // Client returns a new `ent.Client` from the mutation. If the mutation was
  7769  // executed in a transaction (ent.Tx), a transactional client is returned.
  7770  func (m MetaMutation) Client() *Client {
  7771  	client := &Client{config: m.config}
  7772  	client.init()
  7773  	return client
  7774  }
  7775  
  7776  // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7777  // it returns an error otherwise.
  7778  func (m MetaMutation) Tx() (*Tx, error) {
  7779  	if _, ok := m.driver.(*txDriver); !ok {
  7780  		return nil, errors.New("ent: mutation is not running in a transaction")
  7781  	}
  7782  	tx := &Tx{config: m.config}
  7783  	tx.init()
  7784  	return tx, nil
  7785  }
  7786  
  7787  // ID returns the ID value in the mutation. Note that the ID is only available
  7788  // if it was provided to the builder or after it was returned from the database.
  7789  func (m *MetaMutation) ID() (id int, exists bool) {
  7790  	if m.id == nil {
  7791  		return
  7792  	}
  7793  	return *m.id, true
  7794  }
  7795  
  7796  // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7797  // That means, if the mutation is applied within a transaction with an isolation level such
  7798  // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7799  // or updated by the mutation.
  7800  func (m *MetaMutation) IDs(ctx context.Context) ([]int, error) {
  7801  	switch {
  7802  	case m.op.Is(OpUpdateOne | OpDeleteOne):
  7803  		id, exists := m.ID()
  7804  		if exists {
  7805  			return []int{id}, nil
  7806  		}
  7807  		fallthrough
  7808  	case m.op.Is(OpUpdate | OpDelete):
  7809  		return m.Client().Meta.Query().Where(m.predicates...).IDs(ctx)
  7810  	default:
  7811  		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7812  	}
  7813  }
  7814  
  7815  // SetCreatedAt sets the "created_at" field.
  7816  func (m *MetaMutation) SetCreatedAt(t time.Time) {
  7817  	m.created_at = &t
  7818  }
  7819  
  7820  // CreatedAt returns the value of the "created_at" field in the mutation.
  7821  func (m *MetaMutation) CreatedAt() (r time.Time, exists bool) {
  7822  	v := m.created_at
  7823  	if v == nil {
  7824  		return
  7825  	}
  7826  	return *v, true
  7827  }
  7828  
  7829  // OldCreatedAt returns the old "created_at" field's value of the Meta entity.
  7830  // If the Meta object wasn't provided to the builder, the object is fetched from the database.
  7831  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7832  func (m *MetaMutation) OldCreatedAt(ctx context.Context) (v *time.Time, err error) {
  7833  	if !m.op.Is(OpUpdateOne) {
  7834  		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7835  	}
  7836  	if m.id == nil || m.oldValue == nil {
  7837  		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7838  	}
  7839  	oldValue, err := m.oldValue(ctx)
  7840  	if err != nil {
  7841  		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7842  	}
  7843  	return oldValue.CreatedAt, nil
  7844  }
  7845  
  7846  // ClearCreatedAt clears the value of the "created_at" field.
  7847  func (m *MetaMutation) ClearCreatedAt() {
  7848  	m.created_at = nil
  7849  	m.clearedFields[meta.FieldCreatedAt] = struct{}{}
  7850  }
  7851  
  7852  // CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
  7853  func (m *MetaMutation) CreatedAtCleared() bool {
  7854  	_, ok := m.clearedFields[meta.FieldCreatedAt]
  7855  	return ok
  7856  }
  7857  
  7858  // ResetCreatedAt resets all changes to the "created_at" field.
  7859  func (m *MetaMutation) ResetCreatedAt() {
  7860  	m.created_at = nil
  7861  	delete(m.clearedFields, meta.FieldCreatedAt)
  7862  }
  7863  
  7864  // SetUpdatedAt sets the "updated_at" field.
  7865  func (m *MetaMutation) SetUpdatedAt(t time.Time) {
  7866  	m.updated_at = &t
  7867  }
  7868  
  7869  // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7870  func (m *MetaMutation) UpdatedAt() (r time.Time, exists bool) {
  7871  	v := m.updated_at
  7872  	if v == nil {
  7873  		return
  7874  	}
  7875  	return *v, true
  7876  }
  7877  
  7878  // OldUpdatedAt returns the old "updated_at" field's value of the Meta entity.
  7879  // If the Meta object wasn't provided to the builder, the object is fetched from the database.
  7880  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7881  func (m *MetaMutation) OldUpdatedAt(ctx context.Context) (v *time.Time, err error) {
  7882  	if !m.op.Is(OpUpdateOne) {
  7883  		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7884  	}
  7885  	if m.id == nil || m.oldValue == nil {
  7886  		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7887  	}
  7888  	oldValue, err := m.oldValue(ctx)
  7889  	if err != nil {
  7890  		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7891  	}
  7892  	return oldValue.UpdatedAt, nil
  7893  }
  7894  
  7895  // ClearUpdatedAt clears the value of the "updated_at" field.
  7896  func (m *MetaMutation) ClearUpdatedAt() {
  7897  	m.updated_at = nil
  7898  	m.clearedFields[meta.FieldUpdatedAt] = struct{}{}
  7899  }
  7900  
  7901  // UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
  7902  func (m *MetaMutation) UpdatedAtCleared() bool {
  7903  	_, ok := m.clearedFields[meta.FieldUpdatedAt]
  7904  	return ok
  7905  }
  7906  
  7907  // ResetUpdatedAt resets all changes to the "updated_at" field.
  7908  func (m *MetaMutation) ResetUpdatedAt() {
  7909  	m.updated_at = nil
  7910  	delete(m.clearedFields, meta.FieldUpdatedAt)
  7911  }
  7912  
  7913  // SetKey sets the "key" field.
  7914  func (m *MetaMutation) SetKey(s string) {
  7915  	m.key = &s
  7916  }
  7917  
  7918  // Key returns the value of the "key" field in the mutation.
  7919  func (m *MetaMutation) Key() (r string, exists bool) {
  7920  	v := m.key
  7921  	if v == nil {
  7922  		return
  7923  	}
  7924  	return *v, true
  7925  }
  7926  
  7927  // OldKey returns the old "key" field's value of the Meta entity.
  7928  // If the Meta object wasn't provided to the builder, the object is fetched from the database.
  7929  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7930  func (m *MetaMutation) OldKey(ctx context.Context) (v string, err error) {
  7931  	if !m.op.Is(OpUpdateOne) {
  7932  		return v, errors.New("OldKey is only allowed on UpdateOne operations")
  7933  	}
  7934  	if m.id == nil || m.oldValue == nil {
  7935  		return v, errors.New("OldKey requires an ID field in the mutation")
  7936  	}
  7937  	oldValue, err := m.oldValue(ctx)
  7938  	if err != nil {
  7939  		return v, fmt.Errorf("querying old value for OldKey: %w", err)
  7940  	}
  7941  	return oldValue.Key, nil
  7942  }
  7943  
  7944  // ResetKey resets all changes to the "key" field.
  7945  func (m *MetaMutation) ResetKey() {
  7946  	m.key = nil
  7947  }
  7948  
  7949  // SetValue sets the "value" field.
  7950  func (m *MetaMutation) SetValue(s string) {
  7951  	m.value = &s
  7952  }
  7953  
  7954  // Value returns the value of the "value" field in the mutation.
  7955  func (m *MetaMutation) Value() (r string, exists bool) {
  7956  	v := m.value
  7957  	if v == nil {
  7958  		return
  7959  	}
  7960  	return *v, true
  7961  }
  7962  
  7963  // OldValue returns the old "value" field's value of the Meta entity.
  7964  // If the Meta object wasn't provided to the builder, the object is fetched from the database.
  7965  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7966  func (m *MetaMutation) OldValue(ctx context.Context) (v string, err error) {
  7967  	if !m.op.Is(OpUpdateOne) {
  7968  		return v, errors.New("OldValue is only allowed on UpdateOne operations")
  7969  	}
  7970  	if m.id == nil || m.oldValue == nil {
  7971  		return v, errors.New("OldValue requires an ID field in the mutation")
  7972  	}
  7973  	oldValue, err := m.oldValue(ctx)
  7974  	if err != nil {
  7975  		return v, fmt.Errorf("querying old value for OldValue: %w", err)
  7976  	}
  7977  	return oldValue.Value, nil
  7978  }
  7979  
  7980  // ResetValue resets all changes to the "value" field.
  7981  func (m *MetaMutation) ResetValue() {
  7982  	m.value = nil
  7983  }
  7984  
  7985  // SetAlertMetas sets the "alert_metas" field.
  7986  func (m *MetaMutation) SetAlertMetas(i int) {
  7987  	m.owner = &i
  7988  }
  7989  
  7990  // AlertMetas returns the value of the "alert_metas" field in the mutation.
  7991  func (m *MetaMutation) AlertMetas() (r int, exists bool) {
  7992  	v := m.owner
  7993  	if v == nil {
  7994  		return
  7995  	}
  7996  	return *v, true
  7997  }
  7998  
  7999  // OldAlertMetas returns the old "alert_metas" field's value of the Meta entity.
  8000  // If the Meta object wasn't provided to the builder, the object is fetched from the database.
  8001  // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8002  func (m *MetaMutation) OldAlertMetas(ctx context.Context) (v int, err error) {
  8003  	if !m.op.Is(OpUpdateOne) {
  8004  		return v, errors.New("OldAlertMetas is only allowed on UpdateOne operations")
  8005  	}
  8006  	if m.id == nil || m.oldValue == nil {
  8007  		return v, errors.New("OldAlertMetas requires an ID field in the mutation")
  8008  	}
  8009  	oldValue, err := m.oldValue(ctx)
  8010  	if err != nil {
  8011  		return v, fmt.Errorf("querying old value for OldAlertMetas: %w", err)
  8012  	}
  8013  	return oldValue.AlertMetas, nil
  8014  }
  8015  
  8016  // ClearAlertMetas clears the value of the "alert_metas" field.
  8017  func (m *MetaMutation) ClearAlertMetas() {
  8018  	m.owner = nil
  8019  	m.clearedFields[meta.FieldAlertMetas] = struct{}{}
  8020  }
  8021  
  8022  // AlertMetasCleared returns if the "alert_metas" field was cleared in this mutation.
  8023  func (m *MetaMutation) AlertMetasCleared() bool {
  8024  	_, ok := m.clearedFields[meta.FieldAlertMetas]
  8025  	return ok
  8026  }
  8027  
  8028  // ResetAlertMetas resets all changes to the "alert_metas" field.
  8029  func (m *MetaMutation) ResetAlertMetas() {
  8030  	m.owner = nil
  8031  	delete(m.clearedFields, meta.FieldAlertMetas)
  8032  }
  8033  
  8034  // SetOwnerID sets the "owner" edge to the Alert entity by id.
  8035  func (m *MetaMutation) SetOwnerID(id int) {
  8036  	m.owner = &id
  8037  }
  8038  
  8039  // ClearOwner clears the "owner" edge to the Alert entity.
  8040  func (m *MetaMutation) ClearOwner() {
  8041  	m.clearedowner = true
  8042  	m.clearedFields[meta.FieldAlertMetas] = struct{}{}
  8043  }
  8044  
  8045  // OwnerCleared reports if the "owner" edge to the Alert entity was cleared.
  8046  func (m *MetaMutation) OwnerCleared() bool {
  8047  	return m.AlertMetasCleared() || m.clearedowner
  8048  }
  8049  
  8050  // OwnerID returns the "owner" edge ID in the mutation.
  8051  func (m *MetaMutation) OwnerID() (id int, exists bool) {
  8052  	if m.owner != nil {
  8053  		return *m.owner, true
  8054  	}
  8055  	return
  8056  }
  8057  
  8058  // OwnerIDs returns the "owner" edge IDs in the mutation.
  8059  // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8060  // OwnerID instead. It exists only for internal usage by the builders.
  8061  func (m *MetaMutation) OwnerIDs() (ids []int) {
  8062  	if id := m.owner; id != nil {
  8063  		ids = append(ids, *id)
  8064  	}
  8065  	return
  8066  }
  8067  
  8068  // ResetOwner resets all changes to the "owner" edge.
  8069  func (m *MetaMutation) ResetOwner() {
  8070  	m.owner = nil
  8071  	m.clearedowner = false
  8072  }
  8073  
  8074  // Where appends a list predicates to the MetaMutation builder.
  8075  func (m *MetaMutation) Where(ps ...predicate.Meta) {
  8076  	m.predicates = append(m.predicates, ps...)
  8077  }
  8078  
  8079  // WhereP appends storage-level predicates to the MetaMutation builder. Using this method,
  8080  // users can use type-assertion to append predicates that do not depend on any generated package.
  8081  func (m *MetaMutation) WhereP(ps ...func(*sql.Selector)) {
  8082  	p := make([]predicate.Meta, len(ps))
  8083  	for i := range ps {
  8084  		p[i] = ps[i]
  8085  	}
  8086  	m.Where(p...)
  8087  }
  8088  
  8089  // Op returns the operation name.
  8090  func (m *MetaMutation) Op() Op {
  8091  	return m.op
  8092  }
  8093  
  8094  // SetOp allows setting the mutation operation.
  8095  func (m *MetaMutation) SetOp(op Op) {
  8096  	m.op = op
  8097  }
  8098  
  8099  // Type returns the node type of this mutation (Meta).
  8100  func (m *MetaMutation) Type() string {
  8101  	return m.typ
  8102  }
  8103  
  8104  // Fields returns all fields that were changed during this mutation. Note that in
  8105  // order to get all numeric fields that were incremented/decremented, call
  8106  // AddedFields().
  8107  func (m *MetaMutation) Fields() []string {
  8108  	fields := make([]string, 0, 5)
  8109  	if m.created_at != nil {
  8110  		fields = append(fields, meta.FieldCreatedAt)
  8111  	}
  8112  	if m.updated_at != nil {
  8113  		fields = append(fields, meta.FieldUpdatedAt)
  8114  	}
  8115  	if m.key != nil {
  8116  		fields = append(fields, meta.FieldKey)
  8117  	}
  8118  	if m.value != nil {
  8119  		fields = append(fields, meta.FieldValue)
  8120  	}
  8121  	if m.owner != nil {
  8122  		fields = append(fields, meta.FieldAlertMetas)
  8123  	}
  8124  	return fields
  8125  }
  8126  
  8127  // Field returns the value of a field with the given name. The second boolean
  8128  // return value indicates that this field was not set, or was not defined in the
  8129  // schema.
  8130  func (m *MetaMutation) Field(name string) (ent.Value, bool) {
  8131  	switch name {
  8132  	case meta.FieldCreatedAt:
  8133  		return m.CreatedAt()
  8134  	case meta.FieldUpdatedAt:
  8135  		return m.UpdatedAt()
  8136  	case meta.FieldKey:
  8137  		return m.Key()
  8138  	case meta.FieldValue:
  8139  		return m.Value()
  8140  	case meta.FieldAlertMetas:
  8141  		return m.AlertMetas()
  8142  	}
  8143  	return nil, false
  8144  }
  8145  
  8146  // OldField returns the old value of the field from the database. An error is
  8147  // returned if the mutation operation is not UpdateOne, or the query to the
  8148  // database failed.
  8149  func (m *MetaMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8150  	switch name {
  8151  	case meta.FieldCreatedAt:
  8152  		return m.OldCreatedAt(ctx)
  8153  	case meta.FieldUpdatedAt:
  8154  		return m.OldUpdatedAt(ctx)
  8155  	case meta.FieldKey:
  8156  		return m.OldKey(ctx)
  8157  	case meta.FieldValue:
  8158  		return m.OldValue(ctx)
  8159  	case meta.FieldAlertMetas:
  8160  		return m.OldAlertMetas(ctx)
  8161  	}
  8162  	return nil, fmt.Errorf("unknown Meta field %s", name)
  8163  }
  8164  
  8165  // SetField sets the value of a field with the given name. It returns an error if
  8166  // the field is not defined in the schema, or if the type mismatched the field
  8167  // type.
  8168  func (m *MetaMutation) SetField(name string, value ent.Value) error {
  8169  	switch name {
  8170  	case meta.FieldCreatedAt:
  8171  		v, ok := value.(time.Time)
  8172  		if !ok {
  8173  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  8174  		}
  8175  		m.SetCreatedAt(v)
  8176  		return nil
  8177  	case meta.FieldUpdatedAt:
  8178  		v, ok := value.(time.Time)
  8179  		if !ok {
  8180  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  8181  		}
  8182  		m.SetUpdatedAt(v)
  8183  		return nil
  8184  	case meta.FieldKey:
  8185  		v, ok := value.(string)
  8186  		if !ok {
  8187  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  8188  		}
  8189  		m.SetKey(v)
  8190  		return nil
  8191  	case meta.FieldValue:
  8192  		v, ok := value.(string)
  8193  		if !ok {
  8194  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  8195  		}
  8196  		m.SetValue(v)
  8197  		return nil
  8198  	case meta.FieldAlertMetas:
  8199  		v, ok := value.(int)
  8200  		if !ok {
  8201  			return fmt.Errorf("unexpected type %T for field %s", value, name)
  8202  		}
  8203  		m.SetAlertMetas(v)
  8204  		return nil
  8205  	}
  8206  	return fmt.Errorf("unknown Meta field %s", name)
  8207  }
  8208  
  8209  // AddedFields returns all numeric fields that were incremented/decremented during
  8210  // this mutation.
  8211  func (m *MetaMutation) AddedFields() []string {
  8212  	var fields []string
  8213  	return fields
  8214  }
  8215  
  8216  // AddedField returns the numeric value that was incremented/decremented on a field
  8217  // with the given name. The second boolean return value indicates that this field
  8218  // was not set, or was not defined in the schema.
  8219  func (m *MetaMutation) AddedField(name string) (ent.Value, bool) {
  8220  	switch name {
  8221  	}
  8222  	return nil, false
  8223  }
  8224  
  8225  // AddField adds the value to the field with the given name. It returns an error if
  8226  // the field is not defined in the schema, or if the type mismatched the field
  8227  // type.
  8228  func (m *MetaMutation) AddField(name string, value ent.Value) error {
  8229  	switch name {
  8230  	}
  8231  	return fmt.Errorf("unknown Meta numeric field %s", name)
  8232  }
  8233  
  8234  // ClearedFields returns all nullable fields that were cleared during this
  8235  // mutation.
  8236  func (m *MetaMutation) ClearedFields() []string {
  8237  	var fields []string
  8238  	if m.FieldCleared(meta.FieldCreatedAt) {
  8239  		fields = append(fields, meta.FieldCreatedAt)
  8240  	}
  8241  	if m.FieldCleared(meta.FieldUpdatedAt) {
  8242  		fields = append(fields, meta.FieldUpdatedAt)
  8243  	}
  8244  	if m.FieldCleared(meta.FieldAlertMetas) {
  8245  		fields = append(fields, meta.FieldAlertMetas)
  8246  	}
  8247  	return fields
  8248  }
  8249  
  8250  // FieldCleared returns a boolean indicating if a field with the given name was
  8251  // cleared in this mutation.
  8252  func (m *MetaMutation) FieldCleared(name string) bool {
  8253  	_, ok := m.clearedFields[name]
  8254  	return ok
  8255  }
  8256  
  8257  // ClearField clears the value of the field with the given name. It returns an
  8258  // error if the field is not defined in the schema.
  8259  func (m *MetaMutation) ClearField(name string) error {
  8260  	switch name {
  8261  	case meta.FieldCreatedAt:
  8262  		m.ClearCreatedAt()
  8263  		return nil
  8264  	case meta.FieldUpdatedAt:
  8265  		m.ClearUpdatedAt()
  8266  		return nil
  8267  	case meta.FieldAlertMetas:
  8268  		m.ClearAlertMetas()
  8269  		return nil
  8270  	}
  8271  	return fmt.Errorf("unknown Meta nullable field %s", name)
  8272  }
  8273  
  8274  // ResetField resets all changes in the mutation for the field with the given name.
  8275  // It returns an error if the field is not defined in the schema.
  8276  func (m *MetaMutation) ResetField(name string) error {
  8277  	switch name {
  8278  	case meta.FieldCreatedAt:
  8279  		m.ResetCreatedAt()
  8280  		return nil
  8281  	case meta.FieldUpdatedAt:
  8282  		m.ResetUpdatedAt()
  8283  		return nil
  8284  	case meta.FieldKey:
  8285  		m.ResetKey()
  8286  		return nil
  8287  	case meta.FieldValue:
  8288  		m.ResetValue()
  8289  		return nil
  8290  	case meta.FieldAlertMetas:
  8291  		m.ResetAlertMetas()
  8292  		return nil
  8293  	}
  8294  	return fmt.Errorf("unknown Meta field %s", name)
  8295  }
  8296  
  8297  // AddedEdges returns all edge names that were set/added in this mutation.
  8298  func (m *MetaMutation) AddedEdges() []string {
  8299  	edges := make([]string, 0, 1)
  8300  	if m.owner != nil {
  8301  		edges = append(edges, meta.EdgeOwner)
  8302  	}
  8303  	return edges
  8304  }
  8305  
  8306  // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8307  // name in this mutation.
  8308  func (m *MetaMutation) AddedIDs(name string) []ent.Value {
  8309  	switch name {
  8310  	case meta.EdgeOwner:
  8311  		if id := m.owner; id != nil {
  8312  			return []ent.Value{*id}
  8313  		}
  8314  	}
  8315  	return nil
  8316  }
  8317  
  8318  // RemovedEdges returns all edge names that were removed in this mutation.
  8319  func (m *MetaMutation) RemovedEdges() []string {
  8320  	edges := make([]string, 0, 1)
  8321  	return edges
  8322  }
  8323  
  8324  // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8325  // the given name in this mutation.
  8326  func (m *MetaMutation) RemovedIDs(name string) []ent.Value {
  8327  	return nil
  8328  }
  8329  
  8330  // ClearedEdges returns all edge names that were cleared in this mutation.
  8331  func (m *MetaMutation) ClearedEdges() []string {
  8332  	edges := make([]string, 0, 1)
  8333  	if m.clearedowner {
  8334  		edges = append(edges, meta.EdgeOwner)
  8335  	}
  8336  	return edges
  8337  }
  8338  
  8339  // EdgeCleared returns a boolean which indicates if the edge with the given name
  8340  // was cleared in this mutation.
  8341  func (m *MetaMutation) EdgeCleared(name string) bool {
  8342  	switch name {
  8343  	case meta.EdgeOwner:
  8344  		return m.clearedowner
  8345  	}
  8346  	return false
  8347  }
  8348  
  8349  // ClearEdge clears the value of the edge with the given name. It returns an error
  8350  // if that edge is not defined in the schema.
  8351  func (m *MetaMutation) ClearEdge(name string) error {
  8352  	switch name {
  8353  	case meta.EdgeOwner:
  8354  		m.ClearOwner()
  8355  		return nil
  8356  	}
  8357  	return fmt.Errorf("unknown Meta unique edge %s", name)
  8358  }
  8359  
  8360  // ResetEdge resets all changes to the edge with the given name in this mutation.
  8361  // It returns an error if the edge is not defined in the schema.
  8362  func (m *MetaMutation) ResetEdge(name string) error {
  8363  	switch name {
  8364  	case meta.EdgeOwner:
  8365  		m.ResetOwner()
  8366  		return nil
  8367  	}
  8368  	return fmt.Errorf("unknown Meta edge %s", name)
  8369  }