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

     1  // Code generated by ent, DO NOT EDIT.
     2  
     3  package alert
     4  
     5  import (
     6  	"time"
     7  
     8  	"entgo.io/ent/dialect/sql"
     9  	"entgo.io/ent/dialect/sql/sqlgraph"
    10  )
    11  
    12  const (
    13  	// Label holds the string label denoting the alert type in the database.
    14  	Label = "alert"
    15  	// FieldID holds the string denoting the id field in the database.
    16  	FieldID = "id"
    17  	// FieldCreatedAt holds the string denoting the created_at field in the database.
    18  	FieldCreatedAt = "created_at"
    19  	// FieldUpdatedAt holds the string denoting the updated_at field in the database.
    20  	FieldUpdatedAt = "updated_at"
    21  	// FieldScenario holds the string denoting the scenario field in the database.
    22  	FieldScenario = "scenario"
    23  	// FieldBucketId holds the string denoting the bucketid field in the database.
    24  	FieldBucketId = "bucket_id"
    25  	// FieldMessage holds the string denoting the message field in the database.
    26  	FieldMessage = "message"
    27  	// FieldEventsCount holds the string denoting the eventscount field in the database.
    28  	FieldEventsCount = "events_count"
    29  	// FieldStartedAt holds the string denoting the startedat field in the database.
    30  	FieldStartedAt = "started_at"
    31  	// FieldStoppedAt holds the string denoting the stoppedat field in the database.
    32  	FieldStoppedAt = "stopped_at"
    33  	// FieldSourceIp holds the string denoting the sourceip field in the database.
    34  	FieldSourceIp = "source_ip"
    35  	// FieldSourceRange holds the string denoting the sourcerange field in the database.
    36  	FieldSourceRange = "source_range"
    37  	// FieldSourceAsNumber holds the string denoting the sourceasnumber field in the database.
    38  	FieldSourceAsNumber = "source_as_number"
    39  	// FieldSourceAsName holds the string denoting the sourceasname field in the database.
    40  	FieldSourceAsName = "source_as_name"
    41  	// FieldSourceCountry holds the string denoting the sourcecountry field in the database.
    42  	FieldSourceCountry = "source_country"
    43  	// FieldSourceLatitude holds the string denoting the sourcelatitude field in the database.
    44  	FieldSourceLatitude = "source_latitude"
    45  	// FieldSourceLongitude holds the string denoting the sourcelongitude field in the database.
    46  	FieldSourceLongitude = "source_longitude"
    47  	// FieldSourceScope holds the string denoting the sourcescope field in the database.
    48  	FieldSourceScope = "source_scope"
    49  	// FieldSourceValue holds the string denoting the sourcevalue field in the database.
    50  	FieldSourceValue = "source_value"
    51  	// FieldCapacity holds the string denoting the capacity field in the database.
    52  	FieldCapacity = "capacity"
    53  	// FieldLeakSpeed holds the string denoting the leakspeed field in the database.
    54  	FieldLeakSpeed = "leak_speed"
    55  	// FieldScenarioVersion holds the string denoting the scenarioversion field in the database.
    56  	FieldScenarioVersion = "scenario_version"
    57  	// FieldScenarioHash holds the string denoting the scenariohash field in the database.
    58  	FieldScenarioHash = "scenario_hash"
    59  	// FieldSimulated holds the string denoting the simulated field in the database.
    60  	FieldSimulated = "simulated"
    61  	// FieldUUID holds the string denoting the uuid field in the database.
    62  	FieldUUID = "uuid"
    63  	// EdgeOwner holds the string denoting the owner edge name in mutations.
    64  	EdgeOwner = "owner"
    65  	// EdgeDecisions holds the string denoting the decisions edge name in mutations.
    66  	EdgeDecisions = "decisions"
    67  	// EdgeEvents holds the string denoting the events edge name in mutations.
    68  	EdgeEvents = "events"
    69  	// EdgeMetas holds the string denoting the metas edge name in mutations.
    70  	EdgeMetas = "metas"
    71  	// Table holds the table name of the alert in the database.
    72  	Table = "alerts"
    73  	// OwnerTable is the table that holds the owner relation/edge.
    74  	OwnerTable = "alerts"
    75  	// OwnerInverseTable is the table name for the Machine entity.
    76  	// It exists in this package in order to avoid circular dependency with the "machine" package.
    77  	OwnerInverseTable = "machines"
    78  	// OwnerColumn is the table column denoting the owner relation/edge.
    79  	OwnerColumn = "machine_alerts"
    80  	// DecisionsTable is the table that holds the decisions relation/edge.
    81  	DecisionsTable = "decisions"
    82  	// DecisionsInverseTable is the table name for the Decision entity.
    83  	// It exists in this package in order to avoid circular dependency with the "decision" package.
    84  	DecisionsInverseTable = "decisions"
    85  	// DecisionsColumn is the table column denoting the decisions relation/edge.
    86  	DecisionsColumn = "alert_decisions"
    87  	// EventsTable is the table that holds the events relation/edge.
    88  	EventsTable = "events"
    89  	// EventsInverseTable is the table name for the Event entity.
    90  	// It exists in this package in order to avoid circular dependency with the "event" package.
    91  	EventsInverseTable = "events"
    92  	// EventsColumn is the table column denoting the events relation/edge.
    93  	EventsColumn = "alert_events"
    94  	// MetasTable is the table that holds the metas relation/edge.
    95  	MetasTable = "meta"
    96  	// MetasInverseTable is the table name for the Meta entity.
    97  	// It exists in this package in order to avoid circular dependency with the "meta" package.
    98  	MetasInverseTable = "meta"
    99  	// MetasColumn is the table column denoting the metas relation/edge.
   100  	MetasColumn = "alert_metas"
   101  )
   102  
   103  // Columns holds all SQL columns for alert fields.
   104  var Columns = []string{
   105  	FieldID,
   106  	FieldCreatedAt,
   107  	FieldUpdatedAt,
   108  	FieldScenario,
   109  	FieldBucketId,
   110  	FieldMessage,
   111  	FieldEventsCount,
   112  	FieldStartedAt,
   113  	FieldStoppedAt,
   114  	FieldSourceIp,
   115  	FieldSourceRange,
   116  	FieldSourceAsNumber,
   117  	FieldSourceAsName,
   118  	FieldSourceCountry,
   119  	FieldSourceLatitude,
   120  	FieldSourceLongitude,
   121  	FieldSourceScope,
   122  	FieldSourceValue,
   123  	FieldCapacity,
   124  	FieldLeakSpeed,
   125  	FieldScenarioVersion,
   126  	FieldScenarioHash,
   127  	FieldSimulated,
   128  	FieldUUID,
   129  }
   130  
   131  // ForeignKeys holds the SQL foreign-keys that are owned by the "alerts"
   132  // table and are not defined as standalone fields in the schema.
   133  var ForeignKeys = []string{
   134  	"machine_alerts",
   135  }
   136  
   137  // ValidColumn reports if the column name is valid (part of the table columns).
   138  func ValidColumn(column string) bool {
   139  	for i := range Columns {
   140  		if column == Columns[i] {
   141  			return true
   142  		}
   143  	}
   144  	for i := range ForeignKeys {
   145  		if column == ForeignKeys[i] {
   146  			return true
   147  		}
   148  	}
   149  	return false
   150  }
   151  
   152  var (
   153  	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
   154  	DefaultCreatedAt func() time.Time
   155  	// UpdateDefaultCreatedAt holds the default value on update for the "created_at" field.
   156  	UpdateDefaultCreatedAt func() time.Time
   157  	// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
   158  	DefaultUpdatedAt func() time.Time
   159  	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
   160  	UpdateDefaultUpdatedAt func() time.Time
   161  	// DefaultBucketId holds the default value on creation for the "bucketId" field.
   162  	DefaultBucketId string
   163  	// DefaultMessage holds the default value on creation for the "message" field.
   164  	DefaultMessage string
   165  	// DefaultEventsCount holds the default value on creation for the "eventsCount" field.
   166  	DefaultEventsCount int32
   167  	// DefaultStartedAt holds the default value on creation for the "startedAt" field.
   168  	DefaultStartedAt func() time.Time
   169  	// DefaultStoppedAt holds the default value on creation for the "stoppedAt" field.
   170  	DefaultStoppedAt func() time.Time
   171  	// DefaultSimulated holds the default value on creation for the "simulated" field.
   172  	DefaultSimulated bool
   173  )
   174  
   175  // OrderOption defines the ordering options for the Alert queries.
   176  type OrderOption func(*sql.Selector)
   177  
   178  // ByID orders the results by the id field.
   179  func ByID(opts ...sql.OrderTermOption) OrderOption {
   180  	return sql.OrderByField(FieldID, opts...).ToFunc()
   181  }
   182  
   183  // ByCreatedAt orders the results by the created_at field.
   184  func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
   185  	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
   186  }
   187  
   188  // ByUpdatedAt orders the results by the updated_at field.
   189  func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
   190  	return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
   191  }
   192  
   193  // ByScenario orders the results by the scenario field.
   194  func ByScenario(opts ...sql.OrderTermOption) OrderOption {
   195  	return sql.OrderByField(FieldScenario, opts...).ToFunc()
   196  }
   197  
   198  // ByBucketId orders the results by the bucketId field.
   199  func ByBucketId(opts ...sql.OrderTermOption) OrderOption {
   200  	return sql.OrderByField(FieldBucketId, opts...).ToFunc()
   201  }
   202  
   203  // ByMessage orders the results by the message field.
   204  func ByMessage(opts ...sql.OrderTermOption) OrderOption {
   205  	return sql.OrderByField(FieldMessage, opts...).ToFunc()
   206  }
   207  
   208  // ByEventsCountField orders the results by the eventsCount field.
   209  func ByEventsCountField(opts ...sql.OrderTermOption) OrderOption {
   210  	return sql.OrderByField(FieldEventsCount, opts...).ToFunc()
   211  }
   212  
   213  // ByStartedAt orders the results by the startedAt field.
   214  func ByStartedAt(opts ...sql.OrderTermOption) OrderOption {
   215  	return sql.OrderByField(FieldStartedAt, opts...).ToFunc()
   216  }
   217  
   218  // ByStoppedAt orders the results by the stoppedAt field.
   219  func ByStoppedAt(opts ...sql.OrderTermOption) OrderOption {
   220  	return sql.OrderByField(FieldStoppedAt, opts...).ToFunc()
   221  }
   222  
   223  // BySourceIp orders the results by the sourceIp field.
   224  func BySourceIp(opts ...sql.OrderTermOption) OrderOption {
   225  	return sql.OrderByField(FieldSourceIp, opts...).ToFunc()
   226  }
   227  
   228  // BySourceRange orders the results by the sourceRange field.
   229  func BySourceRange(opts ...sql.OrderTermOption) OrderOption {
   230  	return sql.OrderByField(FieldSourceRange, opts...).ToFunc()
   231  }
   232  
   233  // BySourceAsNumber orders the results by the sourceAsNumber field.
   234  func BySourceAsNumber(opts ...sql.OrderTermOption) OrderOption {
   235  	return sql.OrderByField(FieldSourceAsNumber, opts...).ToFunc()
   236  }
   237  
   238  // BySourceAsName orders the results by the sourceAsName field.
   239  func BySourceAsName(opts ...sql.OrderTermOption) OrderOption {
   240  	return sql.OrderByField(FieldSourceAsName, opts...).ToFunc()
   241  }
   242  
   243  // BySourceCountry orders the results by the sourceCountry field.
   244  func BySourceCountry(opts ...sql.OrderTermOption) OrderOption {
   245  	return sql.OrderByField(FieldSourceCountry, opts...).ToFunc()
   246  }
   247  
   248  // BySourceLatitude orders the results by the sourceLatitude field.
   249  func BySourceLatitude(opts ...sql.OrderTermOption) OrderOption {
   250  	return sql.OrderByField(FieldSourceLatitude, opts...).ToFunc()
   251  }
   252  
   253  // BySourceLongitude orders the results by the sourceLongitude field.
   254  func BySourceLongitude(opts ...sql.OrderTermOption) OrderOption {
   255  	return sql.OrderByField(FieldSourceLongitude, opts...).ToFunc()
   256  }
   257  
   258  // BySourceScope orders the results by the sourceScope field.
   259  func BySourceScope(opts ...sql.OrderTermOption) OrderOption {
   260  	return sql.OrderByField(FieldSourceScope, opts...).ToFunc()
   261  }
   262  
   263  // BySourceValue orders the results by the sourceValue field.
   264  func BySourceValue(opts ...sql.OrderTermOption) OrderOption {
   265  	return sql.OrderByField(FieldSourceValue, opts...).ToFunc()
   266  }
   267  
   268  // ByCapacity orders the results by the capacity field.
   269  func ByCapacity(opts ...sql.OrderTermOption) OrderOption {
   270  	return sql.OrderByField(FieldCapacity, opts...).ToFunc()
   271  }
   272  
   273  // ByLeakSpeed orders the results by the leakSpeed field.
   274  func ByLeakSpeed(opts ...sql.OrderTermOption) OrderOption {
   275  	return sql.OrderByField(FieldLeakSpeed, opts...).ToFunc()
   276  }
   277  
   278  // ByScenarioVersion orders the results by the scenarioVersion field.
   279  func ByScenarioVersion(opts ...sql.OrderTermOption) OrderOption {
   280  	return sql.OrderByField(FieldScenarioVersion, opts...).ToFunc()
   281  }
   282  
   283  // ByScenarioHash orders the results by the scenarioHash field.
   284  func ByScenarioHash(opts ...sql.OrderTermOption) OrderOption {
   285  	return sql.OrderByField(FieldScenarioHash, opts...).ToFunc()
   286  }
   287  
   288  // BySimulated orders the results by the simulated field.
   289  func BySimulated(opts ...sql.OrderTermOption) OrderOption {
   290  	return sql.OrderByField(FieldSimulated, opts...).ToFunc()
   291  }
   292  
   293  // ByUUID orders the results by the uuid field.
   294  func ByUUID(opts ...sql.OrderTermOption) OrderOption {
   295  	return sql.OrderByField(FieldUUID, opts...).ToFunc()
   296  }
   297  
   298  // ByOwnerField orders the results by owner field.
   299  func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption {
   300  	return func(s *sql.Selector) {
   301  		sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...))
   302  	}
   303  }
   304  
   305  // ByDecisionsCount orders the results by decisions count.
   306  func ByDecisionsCount(opts ...sql.OrderTermOption) OrderOption {
   307  	return func(s *sql.Selector) {
   308  		sqlgraph.OrderByNeighborsCount(s, newDecisionsStep(), opts...)
   309  	}
   310  }
   311  
   312  // ByDecisions orders the results by decisions terms.
   313  func ByDecisions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
   314  	return func(s *sql.Selector) {
   315  		sqlgraph.OrderByNeighborTerms(s, newDecisionsStep(), append([]sql.OrderTerm{term}, terms...)...)
   316  	}
   317  }
   318  
   319  // ByEventsCount orders the results by events count.
   320  func ByEventsCount(opts ...sql.OrderTermOption) OrderOption {
   321  	return func(s *sql.Selector) {
   322  		sqlgraph.OrderByNeighborsCount(s, newEventsStep(), opts...)
   323  	}
   324  }
   325  
   326  // ByEvents orders the results by events terms.
   327  func ByEvents(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
   328  	return func(s *sql.Selector) {
   329  		sqlgraph.OrderByNeighborTerms(s, newEventsStep(), append([]sql.OrderTerm{term}, terms...)...)
   330  	}
   331  }
   332  
   333  // ByMetasCount orders the results by metas count.
   334  func ByMetasCount(opts ...sql.OrderTermOption) OrderOption {
   335  	return func(s *sql.Selector) {
   336  		sqlgraph.OrderByNeighborsCount(s, newMetasStep(), opts...)
   337  	}
   338  }
   339  
   340  // ByMetas orders the results by metas terms.
   341  func ByMetas(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
   342  	return func(s *sql.Selector) {
   343  		sqlgraph.OrderByNeighborTerms(s, newMetasStep(), append([]sql.OrderTerm{term}, terms...)...)
   344  	}
   345  }
   346  func newOwnerStep() *sqlgraph.Step {
   347  	return sqlgraph.NewStep(
   348  		sqlgraph.From(Table, FieldID),
   349  		sqlgraph.To(OwnerInverseTable, FieldID),
   350  		sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
   351  	)
   352  }
   353  func newDecisionsStep() *sqlgraph.Step {
   354  	return sqlgraph.NewStep(
   355  		sqlgraph.From(Table, FieldID),
   356  		sqlgraph.To(DecisionsInverseTable, FieldID),
   357  		sqlgraph.Edge(sqlgraph.O2M, false, DecisionsTable, DecisionsColumn),
   358  	)
   359  }
   360  func newEventsStep() *sqlgraph.Step {
   361  	return sqlgraph.NewStep(
   362  		sqlgraph.From(Table, FieldID),
   363  		sqlgraph.To(EventsInverseTable, FieldID),
   364  		sqlgraph.Edge(sqlgraph.O2M, false, EventsTable, EventsColumn),
   365  	)
   366  }
   367  func newMetasStep() *sqlgraph.Step {
   368  	return sqlgraph.NewStep(
   369  		sqlgraph.From(Table, FieldID),
   370  		sqlgraph.To(MetasInverseTable, FieldID),
   371  		sqlgraph.Edge(sqlgraph.O2M, false, MetasTable, MetasColumn),
   372  	)
   373  }