// Code generated by ent, DO NOT EDIT. package db import ( "encoding/json" "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/chaitin/MonkeyCode/backend/db/agentplugin" "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" "github.com/chaitin/MonkeyCode/backend/ent/types" "github.com/google/uuid" ) // AgentPluginVersion is the model entity for the AgentPluginVersion schema. type AgentPluginVersion struct { config `json:"-"` // ID of the ent. ID uuid.UUID `json:"id,omitempty"` // ResourceID holds the value of the "resource_id" field. ResourceID uuid.UUID `json:"resource_id,omitempty"` // Version holds the value of the "version" field. Version string `json:"version,omitempty"` // S3Key holds the value of the "s3_key" field. S3Key string `json:"s3_key,omitempty"` // ParsedMeta holds the value of the "parsed_meta" field. ParsedMeta types.PluginParsedMeta `json:"parsed_meta,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the AgentPluginVersionQuery when eager-loading is set. Edges AgentPluginVersionEdges `json:"edges"` selectValues sql.SelectValues } // AgentPluginVersionEdges holds the relations/edges for other nodes in the graph. type AgentPluginVersionEdges struct { // Plugin holds the value of the plugin edge. Plugin *AgentPlugin `json:"plugin,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } // PluginOrErr returns the Plugin value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e AgentPluginVersionEdges) PluginOrErr() (*AgentPlugin, error) { if e.Plugin != nil { return e.Plugin, nil } else if e.loadedTypes[0] { return nil, &NotFoundError{label: agentplugin.Label} } return nil, &NotLoadedError{edge: "plugin"} } // scanValues returns the types for scanning values from sql.Rows. func (*AgentPluginVersion) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case agentpluginversion.FieldParsedMeta: values[i] = new([]byte) case agentpluginversion.FieldVersion, agentpluginversion.FieldS3Key: values[i] = new(sql.NullString) case agentpluginversion.FieldCreatedAt: values[i] = new(sql.NullTime) case agentpluginversion.FieldID, agentpluginversion.FieldResourceID: 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 AgentPluginVersion fields. func (_m *AgentPluginVersion) 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 agentpluginversion.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 agentpluginversion.FieldResourceID: if value, ok := values[i].(*uuid.UUID); !ok { return fmt.Errorf("unexpected type %T for field resource_id", values[i]) } else if value != nil { _m.ResourceID = *value } case agentpluginversion.FieldVersion: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field version", values[i]) } else if value.Valid { _m.Version = value.String } case agentpluginversion.FieldS3Key: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field s3_key", values[i]) } else if value.Valid { _m.S3Key = value.String } case agentpluginversion.FieldParsedMeta: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field parsed_meta", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.ParsedMeta); err != nil { return fmt.Errorf("unmarshal field parsed_meta: %w", err) } } case agentpluginversion.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 } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the AgentPluginVersion. // This includes values selected through modifiers, order, etc. func (_m *AgentPluginVersion) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // QueryPlugin queries the "plugin" edge of the AgentPluginVersion entity. func (_m *AgentPluginVersion) QueryPlugin() *AgentPluginQuery { return NewAgentPluginVersionClient(_m.config).QueryPlugin(_m) } // Update returns a builder for updating this AgentPluginVersion. // Note that you need to call AgentPluginVersion.Unwrap() before calling this method if this AgentPluginVersion // was returned from a transaction, and the transaction was committed or rolled back. func (_m *AgentPluginVersion) Update() *AgentPluginVersionUpdateOne { return NewAgentPluginVersionClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the AgentPluginVersion 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 *AgentPluginVersion) Unwrap() *AgentPluginVersion { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("db: AgentPluginVersion is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *AgentPluginVersion) String() string { var builder strings.Builder builder.WriteString("AgentPluginVersion(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("resource_id=") builder.WriteString(fmt.Sprintf("%v", _m.ResourceID)) builder.WriteString(", ") builder.WriteString("version=") builder.WriteString(_m.Version) builder.WriteString(", ") builder.WriteString("s3_key=") builder.WriteString(_m.S3Key) builder.WriteString(", ") builder.WriteString("parsed_meta=") builder.WriteString(fmt.Sprintf("%v", _m.ParsedMeta)) builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } // AgentPluginVersions is a parsable slice of AgentPluginVersion. type AgentPluginVersions []*AgentPluginVersion