// Code generated by ent, DO NOT EDIT.

package apikey

import (
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
)

const (
	// Label holds the string label denoting the apikey type in the database.
	Label = "api_key"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldCreatedAt holds the string denoting the created_at field in the database.
	FieldCreatedAt = "created_at"
	// FieldUpdatedAt holds the string denoting the updated_at field in the database.
	FieldUpdatedAt = "updated_at"
	// FieldDeletedAt holds the string denoting the deleted_at field in the database.
	FieldDeletedAt = "deleted_at"
	// FieldUserID holds the string denoting the user_id field in the database.
	FieldUserID = "user_id"
	// FieldKey holds the string denoting the key field in the database.
	FieldKey = "key"
	// FieldName holds the string denoting the name field in the database.
	FieldName = "name"
	// FieldGroupID holds the string denoting the group_id field in the database.
	FieldGroupID = "group_id"
	// FieldStatus holds the string denoting the status field in the database.
	FieldStatus = "status"
	// FieldLastUsedAt holds the string denoting the last_used_at field in the database.
	FieldLastUsedAt = "last_used_at"
	// FieldIPWhitelist holds the string denoting the ip_whitelist field in the database.
	FieldIPWhitelist = "ip_whitelist"
	// FieldIPBlacklist holds the string denoting the ip_blacklist field in the database.
	FieldIPBlacklist = "ip_blacklist"
	// FieldQuota holds the string denoting the quota field in the database.
	FieldQuota = "quota"
	// FieldQuotaUsed holds the string denoting the quota_used field in the database.
	FieldQuotaUsed = "quota_used"
	// FieldExpiresAt holds the string denoting the expires_at field in the database.
	FieldExpiresAt = "expires_at"
	// FieldRateLimit5h holds the string denoting the rate_limit_5h field in the database.
	FieldRateLimit5h = "rate_limit_5h"
	// FieldRateLimit1d holds the string denoting the rate_limit_1d field in the database.
	FieldRateLimit1d = "rate_limit_1d"
	// FieldRateLimit7d holds the string denoting the rate_limit_7d field in the database.
	FieldRateLimit7d = "rate_limit_7d"
	// FieldUsage5h holds the string denoting the usage_5h field in the database.
	FieldUsage5h = "usage_5h"
	// FieldUsage1d holds the string denoting the usage_1d field in the database.
	FieldUsage1d = "usage_1d"
	// FieldUsage7d holds the string denoting the usage_7d field in the database.
	FieldUsage7d = "usage_7d"
	// FieldWindow5hStart holds the string denoting the window_5h_start field in the database.
	FieldWindow5hStart = "window_5h_start"
	// FieldWindow1dStart holds the string denoting the window_1d_start field in the database.
	FieldWindow1dStart = "window_1d_start"
	// FieldWindow7dStart holds the string denoting the window_7d_start field in the database.
	FieldWindow7dStart = "window_7d_start"
	// FieldCaptureRequests holds the string denoting the capture_requests field in the database.
	FieldCaptureRequests = "capture_requests"
	// EdgeUser holds the string denoting the user edge name in mutations.
	EdgeUser = "user"
	// EdgeGroup holds the string denoting the group edge name in mutations.
	EdgeGroup = "group"
	// EdgeUsageLogs holds the string denoting the usage_logs edge name in mutations.
	EdgeUsageLogs = "usage_logs"
	// Table holds the table name of the apikey in the database.
	Table = "api_keys"
	// UserTable is the table that holds the user relation/edge.
	UserTable = "api_keys"
	// UserInverseTable is the table name for the User entity.
	// It exists in this package in order to avoid circular dependency with the "user" package.
	UserInverseTable = "users"
	// UserColumn is the table column denoting the user relation/edge.
	UserColumn = "user_id"
	// GroupTable is the table that holds the group relation/edge.
	GroupTable = "api_keys"
	// GroupInverseTable is the table name for the Group entity.
	// It exists in this package in order to avoid circular dependency with the "group" package.
	GroupInverseTable = "groups"
	// GroupColumn is the table column denoting the group relation/edge.
	GroupColumn = "group_id"
	// UsageLogsTable is the table that holds the usage_logs relation/edge.
	UsageLogsTable = "usage_logs"
	// UsageLogsInverseTable is the table name for the UsageLog entity.
	// It exists in this package in order to avoid circular dependency with the "usagelog" package.
	UsageLogsInverseTable = "usage_logs"
	// UsageLogsColumn is the table column denoting the usage_logs relation/edge.
	UsageLogsColumn = "api_key_id"
)

// Columns holds all SQL columns for apikey fields.
var Columns = []string{
	FieldID,
	FieldCreatedAt,
	FieldUpdatedAt,
	FieldDeletedAt,
	FieldUserID,
	FieldKey,
	FieldName,
	FieldGroupID,
	FieldStatus,
	FieldLastUsedAt,
	FieldIPWhitelist,
	FieldIPBlacklist,
	FieldQuota,
	FieldQuotaUsed,
	FieldExpiresAt,
	FieldRateLimit5h,
	FieldRateLimit1d,
	FieldRateLimit7d,
	FieldUsage5h,
	FieldUsage1d,
	FieldUsage7d,
	FieldWindow5hStart,
	FieldWindow1dStart,
	FieldWindow7dStart,
	FieldCaptureRequests,
}

// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
	for i := range Columns {
		if column == Columns[i] {
			return true
		}
	}
	return false
}

// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
//	import _ "github.com/Wei-Shaw/sub2api/ent/runtime"
var (
	Hooks        [1]ent.Hook
	Interceptors [1]ent.Interceptor
	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
	DefaultCreatedAt func() time.Time
	// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
	DefaultUpdatedAt func() time.Time
	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
	UpdateDefaultUpdatedAt func() time.Time
	// KeyValidator is a validator for the "key" field. It is called by the builders before save.
	KeyValidator func(string) error
	// NameValidator is a validator for the "name" field. It is called by the builders before save.
	NameValidator func(string) error
	// DefaultStatus holds the default value on creation for the "status" field.
	DefaultStatus string
	// StatusValidator is a validator for the "status" field. It is called by the builders before save.
	StatusValidator func(string) error
	// DefaultQuota holds the default value on creation for the "quota" field.
	DefaultQuota float64
	// DefaultQuotaUsed holds the default value on creation for the "quota_used" field.
	DefaultQuotaUsed float64
	// DefaultRateLimit5h holds the default value on creation for the "rate_limit_5h" field.
	DefaultRateLimit5h float64
	// DefaultRateLimit1d holds the default value on creation for the "rate_limit_1d" field.
	DefaultRateLimit1d float64
	// DefaultRateLimit7d holds the default value on creation for the "rate_limit_7d" field.
	DefaultRateLimit7d float64
	// DefaultUsage5h holds the default value on creation for the "usage_5h" field.
	DefaultUsage5h float64
	// DefaultUsage1d holds the default value on creation for the "usage_1d" field.
	DefaultUsage1d float64
	// DefaultUsage7d holds the default value on creation for the "usage_7d" field.
	DefaultUsage7d float64
	// DefaultCaptureRequests holds the default value on creation for the "capture_requests" field.
	DefaultCaptureRequests bool
)

// OrderOption defines the ordering options for the APIKey queries.
type OrderOption func(*sql.Selector)

// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldID, opts...).ToFunc()
}

// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}

// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}

// ByDeletedAt orders the results by the deleted_at field.
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
}

// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUserID, opts...).ToFunc()
}

// ByKey orders the results by the key field.
func ByKey(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldKey, opts...).ToFunc()
}

// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldName, opts...).ToFunc()
}

// ByGroupID orders the results by the group_id field.
func ByGroupID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldGroupID, opts...).ToFunc()
}

// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldStatus, opts...).ToFunc()
}

// ByLastUsedAt orders the results by the last_used_at field.
func ByLastUsedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLastUsedAt, opts...).ToFunc()
}

// ByQuota orders the results by the quota field.
func ByQuota(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldQuota, opts...).ToFunc()
}

// ByQuotaUsed orders the results by the quota_used field.
func ByQuotaUsed(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldQuotaUsed, opts...).ToFunc()
}

// ByExpiresAt orders the results by the expires_at field.
func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldExpiresAt, opts...).ToFunc()
}

// ByRateLimit5h orders the results by the rate_limit_5h field.
func ByRateLimit5h(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRateLimit5h, opts...).ToFunc()
}

// ByRateLimit1d orders the results by the rate_limit_1d field.
func ByRateLimit1d(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRateLimit1d, opts...).ToFunc()
}

// ByRateLimit7d orders the results by the rate_limit_7d field.
func ByRateLimit7d(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRateLimit7d, opts...).ToFunc()
}

// ByUsage5h orders the results by the usage_5h field.
func ByUsage5h(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUsage5h, opts...).ToFunc()
}

// ByUsage1d orders the results by the usage_1d field.
func ByUsage1d(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUsage1d, opts...).ToFunc()
}

// ByUsage7d orders the results by the usage_7d field.
func ByUsage7d(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUsage7d, opts...).ToFunc()
}

// ByWindow5hStart orders the results by the window_5h_start field.
func ByWindow5hStart(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldWindow5hStart, opts...).ToFunc()
}

// ByWindow1dStart orders the results by the window_1d_start field.
func ByWindow1dStart(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldWindow1dStart, opts...).ToFunc()
}

// ByWindow7dStart orders the results by the window_7d_start field.
func ByWindow7dStart(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldWindow7dStart, opts...).ToFunc()
}

// ByCaptureRequests orders the results by the capture_requests field.
func ByCaptureRequests(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCaptureRequests, opts...).ToFunc()
}

// ByUserField orders the results by user field.
func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
	}
}

// ByGroupField orders the results by group field.
func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newGroupStep(), sql.OrderByField(field, opts...))
	}
}

// ByUsageLogsCount orders the results by usage_logs count.
func ByUsageLogsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newUsageLogsStep(), opts...)
	}
}

// ByUsageLogs orders the results by usage_logs terms.
func ByUsageLogs(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newUsageLogsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newUserStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(UserInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
	)
}
func newGroupStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(GroupInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
	)
}
func newUsageLogsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(UsageLogsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, UsageLogsTable, UsageLogsColumn),
	)
}
