Files
MonkeyCode/backend/db/agentplugin.go

292 lines
11 KiB
Go

// Code generated by ent, DO NOT EDIT.
package db
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/chaitin/MonkeyCode/backend/db/agentplugin"
"github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo"
"github.com/google/uuid"
)
// AgentPlugin is the model entity for the AgentPlugin schema.
type AgentPlugin struct {
config `json:"-"`
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
// RepoID holds the value of the "repo_id" field.
RepoID uuid.UUID `json:"repo_id,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Description holds the value of the "description" field.
Description string `json:"description,omitempty"`
// ScopeType holds the value of the "scope_type" field.
ScopeType agentplugin.ScopeType `json:"scope_type,omitempty"`
// ScopeID holds the value of the "scope_id" field.
ScopeID string `json:"scope_id,omitempty"`
// CreatedBy holds the value of the "created_by" field.
CreatedBy uuid.UUID `json:"created_by,omitempty"`
// ActiveVersionID holds the value of the "active_version_id" field.
ActiveVersionID *uuid.UUID `json:"active_version_id,omitempty"`
// IsForceDelivery holds the value of the "is_force_delivery" field.
IsForceDelivery bool `json:"is_force_delivery,omitempty"`
// IsOrphan holds the value of the "is_orphan" field.
IsOrphan bool `json:"is_orphan,omitempty"`
// IsDeleted holds the value of the "is_deleted" field.
IsDeleted bool `json:"is_deleted,omitempty"`
// Enabled holds the value of the "enabled" field.
Enabled bool `json:"enabled,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the AgentPluginQuery when eager-loading is set.
Edges AgentPluginEdges `json:"edges"`
selectValues sql.SelectValues
}
// AgentPluginEdges holds the relations/edges for other nodes in the graph.
type AgentPluginEdges struct {
// Repo holds the value of the repo edge.
Repo *AgentPluginRepo `json:"repo,omitempty"`
// Versions holds the value of the versions edge.
Versions []*AgentPluginVersion `json:"versions,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [2]bool
}
// RepoOrErr returns the Repo value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AgentPluginEdges) RepoOrErr() (*AgentPluginRepo, error) {
if e.Repo != nil {
return e.Repo, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: agentpluginrepo.Label}
}
return nil, &NotLoadedError{edge: "repo"}
}
// VersionsOrErr returns the Versions value or an error if the edge
// was not loaded in eager-loading.
func (e AgentPluginEdges) VersionsOrErr() ([]*AgentPluginVersion, error) {
if e.loadedTypes[1] {
return e.Versions, nil
}
return nil, &NotLoadedError{edge: "versions"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*AgentPlugin) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case agentplugin.FieldActiveVersionID:
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
case agentplugin.FieldIsForceDelivery, agentplugin.FieldIsOrphan, agentplugin.FieldIsDeleted, agentplugin.FieldEnabled:
values[i] = new(sql.NullBool)
case agentplugin.FieldName, agentplugin.FieldDescription, agentplugin.FieldScopeType, agentplugin.FieldScopeID:
values[i] = new(sql.NullString)
case agentplugin.FieldCreatedAt, agentplugin.FieldUpdatedAt:
values[i] = new(sql.NullTime)
case agentplugin.FieldID, agentplugin.FieldRepoID, agentplugin.FieldCreatedBy:
values[i] = new(uuid.UUID)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the AgentPlugin fields.
func (_m *AgentPlugin) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case agentplugin.FieldID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
_m.ID = *value
}
case agentplugin.FieldRepoID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field repo_id", values[i])
} else if value != nil {
_m.RepoID = *value
}
case agentplugin.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case agentplugin.FieldDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field description", values[i])
} else if value.Valid {
_m.Description = value.String
}
case agentplugin.FieldScopeType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field scope_type", values[i])
} else if value.Valid {
_m.ScopeType = agentplugin.ScopeType(value.String)
}
case agentplugin.FieldScopeID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field scope_id", values[i])
} else if value.Valid {
_m.ScopeID = value.String
}
case agentplugin.FieldCreatedBy:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field created_by", values[i])
} else if value != nil {
_m.CreatedBy = *value
}
case agentplugin.FieldActiveVersionID:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field active_version_id", values[i])
} else if value.Valid {
_m.ActiveVersionID = new(uuid.UUID)
*_m.ActiveVersionID = *value.S.(*uuid.UUID)
}
case agentplugin.FieldIsForceDelivery:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field is_force_delivery", values[i])
} else if value.Valid {
_m.IsForceDelivery = value.Bool
}
case agentplugin.FieldIsOrphan:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field is_orphan", values[i])
} else if value.Valid {
_m.IsOrphan = value.Bool
}
case agentplugin.FieldIsDeleted:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field is_deleted", values[i])
} else if value.Valid {
_m.IsDeleted = value.Bool
}
case agentplugin.FieldEnabled:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field enabled", values[i])
} else if value.Valid {
_m.Enabled = value.Bool
}
case agentplugin.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case agentplugin.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the AgentPlugin.
// This includes values selected through modifiers, order, etc.
func (_m *AgentPlugin) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryRepo queries the "repo" edge of the AgentPlugin entity.
func (_m *AgentPlugin) QueryRepo() *AgentPluginRepoQuery {
return NewAgentPluginClient(_m.config).QueryRepo(_m)
}
// QueryVersions queries the "versions" edge of the AgentPlugin entity.
func (_m *AgentPlugin) QueryVersions() *AgentPluginVersionQuery {
return NewAgentPluginClient(_m.config).QueryVersions(_m)
}
// Update returns a builder for updating this AgentPlugin.
// Note that you need to call AgentPlugin.Unwrap() before calling this method if this AgentPlugin
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *AgentPlugin) Update() *AgentPluginUpdateOne {
return NewAgentPluginClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the AgentPlugin entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *AgentPlugin) Unwrap() *AgentPlugin {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("db: AgentPlugin is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *AgentPlugin) String() string {
var builder strings.Builder
builder.WriteString("AgentPlugin(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("repo_id=")
builder.WriteString(fmt.Sprintf("%v", _m.RepoID))
builder.WriteString(", ")
builder.WriteString("name=")
builder.WriteString(_m.Name)
builder.WriteString(", ")
builder.WriteString("description=")
builder.WriteString(_m.Description)
builder.WriteString(", ")
builder.WriteString("scope_type=")
builder.WriteString(fmt.Sprintf("%v", _m.ScopeType))
builder.WriteString(", ")
builder.WriteString("scope_id=")
builder.WriteString(_m.ScopeID)
builder.WriteString(", ")
builder.WriteString("created_by=")
builder.WriteString(fmt.Sprintf("%v", _m.CreatedBy))
builder.WriteString(", ")
if v := _m.ActiveVersionID; v != nil {
builder.WriteString("active_version_id=")
builder.WriteString(fmt.Sprintf("%v", *v))
}
builder.WriteString(", ")
builder.WriteString("is_force_delivery=")
builder.WriteString(fmt.Sprintf("%v", _m.IsForceDelivery))
builder.WriteString(", ")
builder.WriteString("is_orphan=")
builder.WriteString(fmt.Sprintf("%v", _m.IsOrphan))
builder.WriteString(", ")
builder.WriteString("is_deleted=")
builder.WriteString(fmt.Sprintf("%v", _m.IsDeleted))
builder.WriteString(", ")
builder.WriteString("enabled=")
builder.WriteString(fmt.Sprintf("%v", _m.Enabled))
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// AgentPlugins is a parsable slice of AgentPlugin.
type AgentPlugins []*AgentPlugin