axonhub / internal /ent /request /request.go
llzai's picture
Upload 1793 files
9853396 verified
Raw
History Blame Contribute Delete
18 kB
// Code generated by ent, DO NOT EDIT.
package request
import (
"fmt"
"io"
"strconv"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the request type in the database.
Label = "request"
// 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"
// FieldAPIKeyID holds the string denoting the api_key_id field in the database.
FieldAPIKeyID = "api_key_id"
// FieldProjectID holds the string denoting the project_id field in the database.
FieldProjectID = "project_id"
// FieldTraceID holds the string denoting the trace_id field in the database.
FieldTraceID = "trace_id"
// FieldDataStorageID holds the string denoting the data_storage_id field in the database.
FieldDataStorageID = "data_storage_id"
// FieldSource holds the string denoting the source field in the database.
FieldSource = "source"
// FieldModelID holds the string denoting the model_id field in the database.
FieldModelID = "model_id"
// FieldFormat holds the string denoting the format field in the database.
FieldFormat = "format"
// FieldRequestHeaders holds the string denoting the request_headers field in the database.
FieldRequestHeaders = "request_headers"
// FieldRequestBody holds the string denoting the request_body field in the database.
FieldRequestBody = "request_body"
// FieldResponseBody holds the string denoting the response_body field in the database.
FieldResponseBody = "response_body"
// FieldResponseChunks holds the string denoting the response_chunks field in the database.
FieldResponseChunks = "response_chunks"
// FieldChannelID holds the string denoting the channel_id field in the database.
FieldChannelID = "channel_id"
// FieldExternalID holds the string denoting the external_id field in the database.
FieldExternalID = "external_id"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldStream holds the string denoting the stream field in the database.
FieldStream = "stream"
// FieldClientIP holds the string denoting the client_ip field in the database.
FieldClientIP = "client_ip"
// FieldMetricsLatencyMs holds the string denoting the metrics_latency_ms field in the database.
FieldMetricsLatencyMs = "metrics_latency_ms"
// FieldMetricsFirstTokenLatencyMs holds the string denoting the metrics_first_token_latency_ms field in the database.
FieldMetricsFirstTokenLatencyMs = "metrics_first_token_latency_ms"
// EdgeAPIKey holds the string denoting the api_key edge name in mutations.
EdgeAPIKey = "api_key"
// EdgeProject holds the string denoting the project edge name in mutations.
EdgeProject = "project"
// EdgeTrace holds the string denoting the trace edge name in mutations.
EdgeTrace = "trace"
// EdgeDataStorage holds the string denoting the data_storage edge name in mutations.
EdgeDataStorage = "data_storage"
// EdgeExecutions holds the string denoting the executions edge name in mutations.
EdgeExecutions = "executions"
// EdgeChannel holds the string denoting the channel edge name in mutations.
EdgeChannel = "channel"
// EdgeUsageLogs holds the string denoting the usage_logs edge name in mutations.
EdgeUsageLogs = "usage_logs"
// Table holds the table name of the request in the database.
Table = "requests"
// APIKeyTable is the table that holds the api_key relation/edge.
APIKeyTable = "requests"
// APIKeyInverseTable is the table name for the APIKey entity.
// It exists in this package in order to avoid circular dependency with the "apikey" package.
APIKeyInverseTable = "api_keys"
// APIKeyColumn is the table column denoting the api_key relation/edge.
APIKeyColumn = "api_key_id"
// ProjectTable is the table that holds the project relation/edge.
ProjectTable = "requests"
// ProjectInverseTable is the table name for the Project entity.
// It exists in this package in order to avoid circular dependency with the "project" package.
ProjectInverseTable = "projects"
// ProjectColumn is the table column denoting the project relation/edge.
ProjectColumn = "project_id"
// TraceTable is the table that holds the trace relation/edge.
TraceTable = "requests"
// TraceInverseTable is the table name for the Trace entity.
// It exists in this package in order to avoid circular dependency with the "trace" package.
TraceInverseTable = "traces"
// TraceColumn is the table column denoting the trace relation/edge.
TraceColumn = "trace_id"
// DataStorageTable is the table that holds the data_storage relation/edge.
DataStorageTable = "requests"
// DataStorageInverseTable is the table name for the DataStorage entity.
// It exists in this package in order to avoid circular dependency with the "datastorage" package.
DataStorageInverseTable = "data_storages"
// DataStorageColumn is the table column denoting the data_storage relation/edge.
DataStorageColumn = "data_storage_id"
// ExecutionsTable is the table that holds the executions relation/edge.
ExecutionsTable = "request_executions"
// ExecutionsInverseTable is the table name for the RequestExecution entity.
// It exists in this package in order to avoid circular dependency with the "requestexecution" package.
ExecutionsInverseTable = "request_executions"
// ExecutionsColumn is the table column denoting the executions relation/edge.
ExecutionsColumn = "request_id"
// ChannelTable is the table that holds the channel relation/edge.
ChannelTable = "requests"
// ChannelInverseTable is the table name for the Channel entity.
// It exists in this package in order to avoid circular dependency with the "channel" package.
ChannelInverseTable = "channels"
// ChannelColumn is the table column denoting the channel relation/edge.
ChannelColumn = "channel_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 = "request_id"
)
// Columns holds all SQL columns for request fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldAPIKeyID,
FieldProjectID,
FieldTraceID,
FieldDataStorageID,
FieldSource,
FieldModelID,
FieldFormat,
FieldRequestHeaders,
FieldRequestBody,
FieldResponseBody,
FieldResponseChunks,
FieldChannelID,
FieldExternalID,
FieldStatus,
FieldStream,
FieldClientIP,
FieldMetricsLatencyMs,
FieldMetricsFirstTokenLatencyMs,
}
// 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/looplj/axonhub/internal/ent/runtime"
var (
Hooks [1]ent.Hook
Policy ent.Policy
// 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
// DefaultProjectID holds the default value on creation for the "project_id" field.
DefaultProjectID int
// DefaultFormat holds the default value on creation for the "format" field.
DefaultFormat string
// DefaultStream holds the default value on creation for the "stream" field.
DefaultStream bool
// DefaultClientIP holds the default value on creation for the "client_ip" field.
DefaultClientIP string
)
// Source defines the type for the "source" enum field.
type Source string
// SourceAPI is the default value of the Source enum.
const DefaultSource = SourceAPI
// Source values.
const (
SourceAPI Source = "api"
SourcePlayground Source = "playground"
SourceTest Source = "test"
)
func (s Source) String() string {
return string(s)
}
// SourceValidator is a validator for the "source" field enum values. It is called by the builders before save.
func SourceValidator(s Source) error {
switch s {
case SourceAPI, SourcePlayground, SourceTest:
return nil
default:
return fmt.Errorf("request: invalid enum value for source field: %q", s)
}
}
// Status defines the type for the "status" enum field.
type Status string
// Status values.
const (
StatusPending Status = "pending"
StatusProcessing Status = "processing"
StatusCompleted Status = "completed"
StatusFailed Status = "failed"
StatusCanceled Status = "canceled"
)
func (s Status) String() string {
return string(s)
}
// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
func StatusValidator(s Status) error {
switch s {
case StatusPending, StatusProcessing, StatusCompleted, StatusFailed, StatusCanceled:
return nil
default:
return fmt.Errorf("request: invalid enum value for status field: %q", s)
}
}
// OrderOption defines the ordering options for the Request 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()
}
// ByAPIKeyID orders the results by the api_key_id field.
func ByAPIKeyID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAPIKeyID, opts...).ToFunc()
}
// ByProjectID orders the results by the project_id field.
func ByProjectID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProjectID, opts...).ToFunc()
}
// ByTraceID orders the results by the trace_id field.
func ByTraceID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTraceID, opts...).ToFunc()
}
// ByDataStorageID orders the results by the data_storage_id field.
func ByDataStorageID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDataStorageID, opts...).ToFunc()
}
// BySource orders the results by the source field.
func BySource(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSource, opts...).ToFunc()
}
// ByModelID orders the results by the model_id field.
func ByModelID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModelID, opts...).ToFunc()
}
// ByFormat orders the results by the format field.
func ByFormat(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFormat, opts...).ToFunc()
}
// ByChannelID orders the results by the channel_id field.
func ByChannelID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldChannelID, opts...).ToFunc()
}
// ByExternalID orders the results by the external_id field.
func ByExternalID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldExternalID, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByStream orders the results by the stream field.
func ByStream(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStream, opts...).ToFunc()
}
// ByClientIP orders the results by the client_ip field.
func ByClientIP(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldClientIP, opts...).ToFunc()
}
// ByMetricsLatencyMs orders the results by the metrics_latency_ms field.
func ByMetricsLatencyMs(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMetricsLatencyMs, opts...).ToFunc()
}
// ByMetricsFirstTokenLatencyMs orders the results by the metrics_first_token_latency_ms field.
func ByMetricsFirstTokenLatencyMs(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMetricsFirstTokenLatencyMs, opts...).ToFunc()
}
// ByAPIKeyField orders the results by api_key field.
func ByAPIKeyField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newAPIKeyStep(), sql.OrderByField(field, opts...))
}
}
// ByProjectField orders the results by project field.
func ByProjectField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newProjectStep(), sql.OrderByField(field, opts...))
}
}
// ByTraceField orders the results by trace field.
func ByTraceField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newTraceStep(), sql.OrderByField(field, opts...))
}
}
// ByDataStorageField orders the results by data_storage field.
func ByDataStorageField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newDataStorageStep(), sql.OrderByField(field, opts...))
}
}
// ByExecutionsCount orders the results by executions count.
func ByExecutionsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newExecutionsStep(), opts...)
}
}
// ByExecutions orders the results by executions terms.
func ByExecutions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newExecutionsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByChannelField orders the results by channel field.
func ByChannelField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newChannelStep(), 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 newAPIKeyStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(APIKeyInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, APIKeyTable, APIKeyColumn),
)
}
func newProjectStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ProjectInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ProjectTable, ProjectColumn),
)
}
func newTraceStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(TraceInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, TraceTable, TraceColumn),
)
}
func newDataStorageStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(DataStorageInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, DataStorageTable, DataStorageColumn),
)
}
func newExecutionsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ExecutionsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ExecutionsTable, ExecutionsColumn),
)
}
func newChannelStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ChannelInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ChannelTable, ChannelColumn),
)
}
func newUsageLogsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(UsageLogsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, UsageLogsTable, UsageLogsColumn),
)
}
// MarshalGQL implements graphql.Marshaler interface.
func (e Source) MarshalGQL(w io.Writer) {
io.WriteString(w, strconv.Quote(e.String()))
}
// UnmarshalGQL implements graphql.Unmarshaler interface.
func (e *Source) UnmarshalGQL(val interface{}) error {
str, ok := val.(string)
if !ok {
return fmt.Errorf("enum %T must be a string", val)
}
*e = Source(str)
if err := SourceValidator(*e); err != nil {
return fmt.Errorf("%s is not a valid Source", str)
}
return nil
}
// MarshalGQL implements graphql.Marshaler interface.
func (e Status) MarshalGQL(w io.Writer) {
io.WriteString(w, strconv.Quote(e.String()))
}
// UnmarshalGQL implements graphql.Unmarshaler interface.
func (e *Status) UnmarshalGQL(val interface{}) error {
str, ok := val.(string)
if !ok {
return fmt.Errorf("enum %T must be a string", val)
}
*e = Status(str)
if err := StatusValidator(*e); err != nil {
return fmt.Errorf("%s is not a valid Status", str)
}
return nil
}