|
@@ -12,6 +12,7 @@ import (
|
|
|
"wechat-api/ent/agentbase"
|
|
|
"wechat-api/ent/aliyunavatar"
|
|
|
"wechat-api/ent/allocagent"
|
|
|
+ "wechat-api/ent/apikey"
|
|
|
"wechat-api/ent/batchmsg"
|
|
|
"wechat-api/ent/category"
|
|
|
"wechat-api/ent/chatrecords"
|
|
@@ -68,6 +69,7 @@ const (
|
|
|
TypeAgentBase = "AgentBase"
|
|
|
TypeAliyunAvatar = "AliyunAvatar"
|
|
|
TypeAllocAgent = "AllocAgent"
|
|
|
+ TypeApiKey = "ApiKey"
|
|
|
TypeBatchMsg = "BatchMsg"
|
|
|
TypeCategory = "Category"
|
|
|
TypeChatRecords = "ChatRecords"
|
|
@@ -135,6 +137,9 @@ type AgentMutation struct {
|
|
|
wa_agent map[uint64]struct{}
|
|
|
removedwa_agent map[uint64]struct{}
|
|
|
clearedwa_agent bool
|
|
|
+ key_agent map[uint64]struct{}
|
|
|
+ removedkey_agent map[uint64]struct{}
|
|
|
+ clearedkey_agent bool
|
|
|
done bool
|
|
|
oldValue func(context.Context) (*Agent, error)
|
|
|
predicates []predicate.Agent
|
|
@@ -895,6 +900,60 @@ func (m *AgentMutation) ResetWaAgent() {
|
|
|
m.removedwa_agent = nil
|
|
|
}
|
|
|
|
|
|
+// AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
|
|
|
+func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
|
|
|
+ if m.key_agent == nil {
|
|
|
+ m.key_agent = make(map[uint64]struct{})
|
|
|
+ }
|
|
|
+ for i := range ids {
|
|
|
+ m.key_agent[ids[i]] = struct{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
|
|
|
+func (m *AgentMutation) ClearKeyAgent() {
|
|
|
+ m.clearedkey_agent = true
|
|
|
+}
|
|
|
+
|
|
|
+// KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
|
|
|
+func (m *AgentMutation) KeyAgentCleared() bool {
|
|
|
+ return m.clearedkey_agent
|
|
|
+}
|
|
|
+
|
|
|
+// RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
|
|
|
+func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
|
|
|
+ if m.removedkey_agent == nil {
|
|
|
+ m.removedkey_agent = make(map[uint64]struct{})
|
|
|
+ }
|
|
|
+ for i := range ids {
|
|
|
+ delete(m.key_agent, ids[i])
|
|
|
+ m.removedkey_agent[ids[i]] = struct{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
|
|
|
+func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
|
|
|
+ for id := range m.removedkey_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
|
|
|
+func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
|
|
|
+ for id := range m.key_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// ResetKeyAgent resets all changes to the "key_agent" edge.
|
|
|
+func (m *AgentMutation) ResetKeyAgent() {
|
|
|
+ m.key_agent = nil
|
|
|
+ m.clearedkey_agent = false
|
|
|
+ m.removedkey_agent = nil
|
|
|
+}
|
|
|
+
|
|
|
// Where appends a list predicates to the AgentMutation builder.
|
|
|
func (m *AgentMutation) Where(ps ...predicate.Agent) {
|
|
|
m.predicates = append(m.predicates, ps...)
|
|
@@ -1252,7 +1311,7 @@ func (m *AgentMutation) ResetField(name string) error {
|
|
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
func (m *AgentMutation) AddedEdges() []string {
|
|
|
- edges := make([]string, 0, 3)
|
|
|
+ edges := make([]string, 0, 4)
|
|
|
if m.wx_agent != nil {
|
|
|
edges = append(edges, agent.EdgeWxAgent)
|
|
|
}
|
|
@@ -1262,6 +1321,9 @@ func (m *AgentMutation) AddedEdges() []string {
|
|
|
if m.wa_agent != nil {
|
|
|
edges = append(edges, agent.EdgeWaAgent)
|
|
|
}
|
|
|
+ if m.key_agent != nil {
|
|
|
+ edges = append(edges, agent.EdgeKeyAgent)
|
|
|
+ }
|
|
|
return edges
|
|
|
}
|
|
|
|
|
@@ -1287,13 +1349,19 @@ func (m *AgentMutation) AddedIDs(name string) []ent.Value {
|
|
|
ids = append(ids, id)
|
|
|
}
|
|
|
return ids
|
|
|
+ case agent.EdgeKeyAgent:
|
|
|
+ ids := make([]ent.Value, 0, len(m.key_agent))
|
|
|
+ for id := range m.key_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return ids
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
func (m *AgentMutation) RemovedEdges() []string {
|
|
|
- edges := make([]string, 0, 3)
|
|
|
+ edges := make([]string, 0, 4)
|
|
|
if m.removedwx_agent != nil {
|
|
|
edges = append(edges, agent.EdgeWxAgent)
|
|
|
}
|
|
@@ -1303,6 +1371,9 @@ func (m *AgentMutation) RemovedEdges() []string {
|
|
|
if m.removedwa_agent != nil {
|
|
|
edges = append(edges, agent.EdgeWaAgent)
|
|
|
}
|
|
|
+ if m.removedkey_agent != nil {
|
|
|
+ edges = append(edges, agent.EdgeKeyAgent)
|
|
|
+ }
|
|
|
return edges
|
|
|
}
|
|
|
|
|
@@ -1328,13 +1399,19 @@ func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
|
|
|
ids = append(ids, id)
|
|
|
}
|
|
|
return ids
|
|
|
+ case agent.EdgeKeyAgent:
|
|
|
+ ids := make([]ent.Value, 0, len(m.removedkey_agent))
|
|
|
+ for id := range m.removedkey_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return ids
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
func (m *AgentMutation) ClearedEdges() []string {
|
|
|
- edges := make([]string, 0, 3)
|
|
|
+ edges := make([]string, 0, 4)
|
|
|
if m.clearedwx_agent {
|
|
|
edges = append(edges, agent.EdgeWxAgent)
|
|
|
}
|
|
@@ -1344,6 +1421,9 @@ func (m *AgentMutation) ClearedEdges() []string {
|
|
|
if m.clearedwa_agent {
|
|
|
edges = append(edges, agent.EdgeWaAgent)
|
|
|
}
|
|
|
+ if m.clearedkey_agent {
|
|
|
+ edges = append(edges, agent.EdgeKeyAgent)
|
|
|
+ }
|
|
|
return edges
|
|
|
}
|
|
|
|
|
@@ -1357,6 +1437,8 @@ func (m *AgentMutation) EdgeCleared(name string) bool {
|
|
|
return m.clearedtoken_agent
|
|
|
case agent.EdgeWaAgent:
|
|
|
return m.clearedwa_agent
|
|
|
+ case agent.EdgeKeyAgent:
|
|
|
+ return m.clearedkey_agent
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
@@ -1382,6 +1464,9 @@ func (m *AgentMutation) ResetEdge(name string) error {
|
|
|
case agent.EdgeWaAgent:
|
|
|
m.ResetWaAgent()
|
|
|
return nil
|
|
|
+ case agent.EdgeKeyAgent:
|
|
|
+ m.ResetKeyAgent()
|
|
|
+ return nil
|
|
|
}
|
|
|
return fmt.Errorf("unknown Agent edge %s", name)
|
|
|
}
|
|
@@ -4343,6 +4428,1104 @@ func (m *AllocAgentMutation) ResetEdge(name string) error {
|
|
|
return fmt.Errorf("unknown AllocAgent edge %s", name)
|
|
|
}
|
|
|
|
|
|
+// ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
|
|
|
+type ApiKeyMutation struct {
|
|
|
+ config
|
|
|
+ op Op
|
|
|
+ typ string
|
|
|
+ id *uint64
|
|
|
+ created_at *time.Time
|
|
|
+ updated_at *time.Time
|
|
|
+ deleted_at *time.Time
|
|
|
+ title *string
|
|
|
+ key *string
|
|
|
+ organization_id *uint64
|
|
|
+ addorganization_id *int64
|
|
|
+ custom_agent_base *string
|
|
|
+ custom_agent_key *string
|
|
|
+ openai_base *string
|
|
|
+ openai_key *string
|
|
|
+ clearedFields map[string]struct{}
|
|
|
+ agent *uint64
|
|
|
+ clearedagent bool
|
|
|
+ done bool
|
|
|
+ oldValue func(context.Context) (*ApiKey, error)
|
|
|
+ predicates []predicate.ApiKey
|
|
|
+}
|
|
|
+
|
|
|
+var _ ent.Mutation = (*ApiKeyMutation)(nil)
|
|
|
+
|
|
|
+// apikeyOption allows management of the mutation configuration using functional options.
|
|
|
+type apikeyOption func(*ApiKeyMutation)
|
|
|
+
|
|
|
+// newApiKeyMutation creates new mutation for the ApiKey entity.
|
|
|
+func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
|
|
|
+ m := &ApiKeyMutation{
|
|
|
+ config: c,
|
|
|
+ op: op,
|
|
|
+ typ: TypeApiKey,
|
|
|
+ clearedFields: make(map[string]struct{}),
|
|
|
+ }
|
|
|
+ for _, opt := range opts {
|
|
|
+ opt(m)
|
|
|
+ }
|
|
|
+ return m
|
|
|
+}
|
|
|
+
|
|
|
+// withApiKeyID sets the ID field of the mutation.
|
|
|
+func withApiKeyID(id uint64) apikeyOption {
|
|
|
+ return func(m *ApiKeyMutation) {
|
|
|
+ var (
|
|
|
+ err error
|
|
|
+ once sync.Once
|
|
|
+ value *ApiKey
|
|
|
+ )
|
|
|
+ m.oldValue = func(ctx context.Context) (*ApiKey, error) {
|
|
|
+ once.Do(func() {
|
|
|
+ if m.done {
|
|
|
+ err = errors.New("querying old values post mutation is not allowed")
|
|
|
+ } else {
|
|
|
+ value, err = m.Client().ApiKey.Get(ctx, id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return value, err
|
|
|
+ }
|
|
|
+ m.id = &id
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// withApiKey sets the old ApiKey of the mutation.
|
|
|
+func withApiKey(node *ApiKey) apikeyOption {
|
|
|
+ return func(m *ApiKeyMutation) {
|
|
|
+ m.oldValue = func(context.Context) (*ApiKey, error) {
|
|
|
+ return node, nil
|
|
|
+ }
|
|
|
+ m.id = &node.ID
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
|
+// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
|
+func (m ApiKeyMutation) Client() *Client {
|
|
|
+ client := &Client{config: m.config}
|
|
|
+ client.init()
|
|
|
+ return client
|
|
|
+}
|
|
|
+
|
|
|
+// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
|
+// it returns an error otherwise.
|
|
|
+func (m ApiKeyMutation) Tx() (*Tx, error) {
|
|
|
+ if _, ok := m.driver.(*txDriver); !ok {
|
|
|
+ return nil, errors.New("ent: mutation is not running in a transaction")
|
|
|
+ }
|
|
|
+ tx := &Tx{config: m.config}
|
|
|
+ tx.init()
|
|
|
+ return tx, nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetID sets the value of the id field. Note that this
|
|
|
+// operation is only accepted on creation of ApiKey entities.
|
|
|
+func (m *ApiKeyMutation) SetID(id uint64) {
|
|
|
+ m.id = &id
|
|
|
+}
|
|
|
+
|
|
|
+// ID returns the ID value in the mutation. Note that the ID is only available
|
|
|
+// if it was provided to the builder or after it was returned from the database.
|
|
|
+func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
|
|
|
+ if m.id == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *m.id, true
|
|
|
+}
|
|
|
+
|
|
|
+// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
|
+// That means, if the mutation is applied within a transaction with an isolation level such
|
|
|
+// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
|
+// or updated by the mutation.
|
|
|
+func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
|
|
|
+ switch {
|
|
|
+ case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
|
+ id, exists := m.ID()
|
|
|
+ if exists {
|
|
|
+ return []uint64{id}, nil
|
|
|
+ }
|
|
|
+ fallthrough
|
|
|
+ case m.op.Is(OpUpdate | OpDelete):
|
|
|
+ return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
|
|
|
+ default:
|
|
|
+ return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// SetCreatedAt sets the "created_at" field.
|
|
|
+func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
|
|
|
+ m.created_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
|
+func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.created_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
|
|
|
+// If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CreatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCreatedAt resets all changes to the "created_at" field.
|
|
|
+func (m *ApiKeyMutation) ResetCreatedAt() {
|
|
|
+ m.created_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
|
|
|
+ m.updated_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
|
+func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.updated_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
|
|
|
+// If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.UpdatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
|
+func (m *ApiKeyMutation) ResetUpdatedAt() {
|
|
|
+ m.updated_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
|
|
|
+ m.deleted_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
|
+func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.deleted_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
|
|
|
+// If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.DeletedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
|
+func (m *ApiKeyMutation) ClearDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
|
+func (m *ApiKeyMutation) DeletedAtCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldDeletedAt]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
|
+func (m *ApiKeyMutation) ResetDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldDeletedAt)
|
|
|
+}
|
|
|
+
|
|
|
+// SetTitle sets the "title" field.
|
|
|
+func (m *ApiKeyMutation) SetTitle(s string) {
|
|
|
+ m.title = &s
|
|
|
+}
|
|
|
+
|
|
|
+// Title returns the value of the "title" field in the mutation.
|
|
|
+func (m *ApiKeyMutation) Title() (r string, exists bool) {
|
|
|
+ v := m.title
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldTitle returns the old "title" field's value of the ApiKey entity.
|
|
|
+// If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldTitle is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldTitle requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldTitle: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Title, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearTitle clears the value of the "title" field.
|
|
|
+func (m *ApiKeyMutation) ClearTitle() {
|
|
|
+ m.title = nil
|
|
|
+ m.clearedFields[apikey.FieldTitle] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// TitleCleared returns if the "title" field was cleared in this mutation.
|
|
|
+func (m *ApiKeyMutation) TitleCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldTitle]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetTitle resets all changes to the "title" field.
|
|
|
+func (m *ApiKeyMutation) ResetTitle() {
|
|
|
+ m.title = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldTitle)
|
|
|
+}
|
|
|
+
|
|
|
+// SetKey sets the "key" field.
|
|
|
+func (m *ApiKeyMutation) SetKey(s string) {
|
|
|
+ m.key = &s
|
|
|
+}
|
|
|
+
|
|
|
+// Key returns the value of the "key" field in the mutation.
|
|
|
+func (m *ApiKeyMutation) Key() (r string, exists bool) {
|
|
|
+ v := m.key
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldKey returns the old "key" field's value of the ApiKey entity.
|
|
|
+// If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldKey is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldKey requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldKey: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Key, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearKey clears the value of the "key" field.
|
|
|
+func (m *ApiKeyMutation) ClearKey() {
|
|
|
+ m.key = nil
|
|
|
+ m.clearedFields[apikey.FieldKey] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// KeyCleared returns if the "key" field was cleared in this mutation.
|
|
|
+func (m *ApiKeyMutation) KeyCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldKey]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetKey resets all changes to the "key" field.
|
|
|
+func (m *ApiKeyMutation) ResetKey() {
|
|
|
+ m.key = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldKey)
|
|
|
+}
|
|
|
+
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
|
|
|
+ m.organization_id = &u
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// OrganizationID returns the value of the "organization_id" field in the mutation.
|
|
|
+func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
|
|
|
+ v := m.organization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
|
|
|
+// If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldOrganizationID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.OrganizationID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddOrganizationID adds u to the "organization_id" field.
|
|
|
+func (m *ApiKeyMutation) AddOrganizationID(u int64) {
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ *m.addorganization_id += u
|
|
|
+ } else {
|
|
|
+ m.addorganization_id = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
|
|
|
+func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
|
|
|
+ v := m.addorganization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ResetOrganizationID resets all changes to the "organization_id" field.
|
|
|
+func (m *ApiKeyMutation) ResetOrganizationID() {
|
|
|
+ m.organization_id = nil
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetAgentID sets the "agent_id" field.
|
|
|
+func (m *ApiKeyMutation) SetAgentID(u uint64) {
|
|
|
+ m.agent = &u
|
|
|
+}
|
|
|
+
|
|
|
+// AgentID returns the value of the "agent_id" field in the mutation.
|
|
|
+func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
|
|
|
+ v := m.agent
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
|
|
|
+// If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldAgentID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.AgentID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetAgentID resets all changes to the "agent_id" field.
|
|
|
+func (m *ApiKeyMutation) ResetAgentID() {
|
|
|
+ m.agent = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetCustomAgentBase sets the "custom_agent_base" field.
|
|
|
+func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
|
|
|
+ m.custom_agent_base = &s
|
|
|
+}
|
|
|
+
|
|
|
+// CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
|
|
|
+func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
|
|
|
+ v := m.custom_agent_base
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
|
|
|
+// If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CustomAgentBase, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearCustomAgentBase clears the value of the "custom_agent_base" field.
|
|
|
+func (m *ApiKeyMutation) ClearCustomAgentBase() {
|
|
|
+ m.custom_agent_base = nil
|
|
|
+ m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
|
|
|
+func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
|
|
|
+func (m *ApiKeyMutation) ResetCustomAgentBase() {
|
|
|
+ m.custom_agent_base = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldCustomAgentBase)
|
|
|
+}
|
|
|
+
|
|
|
+// SetCustomAgentKey sets the "custom_agent_key" field.
|
|
|
+func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
|
|
|
+ m.custom_agent_key = &s
|
|
|
+}
|
|
|
+
|
|
|
+// CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
|
|
|
+func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
|
|
|
+ v := m.custom_agent_key
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
|
|
|
+// If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CustomAgentKey, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearCustomAgentKey clears the value of the "custom_agent_key" field.
|
|
|
+func (m *ApiKeyMutation) ClearCustomAgentKey() {
|
|
|
+ m.custom_agent_key = nil
|
|
|
+ m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
|
|
|
+func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
|
|
|
+func (m *ApiKeyMutation) ResetCustomAgentKey() {
|
|
|
+ m.custom_agent_key = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldCustomAgentKey)
|
|
|
+}
|
|
|
+
|
|
|
+// SetOpenaiBase sets the "openai_base" field.
|
|
|
+func (m *ApiKeyMutation) SetOpenaiBase(s string) {
|
|
|
+ m.openai_base = &s
|
|
|
+}
|
|
|
+
|
|
|
+// OpenaiBase returns the value of the "openai_base" field in the mutation.
|
|
|
+func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
|
|
|
+ v := m.openai_base
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
|
|
|
+// If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.OpenaiBase, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearOpenaiBase clears the value of the "openai_base" field.
|
|
|
+func (m *ApiKeyMutation) ClearOpenaiBase() {
|
|
|
+ m.openai_base = nil
|
|
|
+ m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
|
|
|
+func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldOpenaiBase]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetOpenaiBase resets all changes to the "openai_base" field.
|
|
|
+func (m *ApiKeyMutation) ResetOpenaiBase() {
|
|
|
+ m.openai_base = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldOpenaiBase)
|
|
|
+}
|
|
|
+
|
|
|
+// SetOpenaiKey sets the "openai_key" field.
|
|
|
+func (m *ApiKeyMutation) SetOpenaiKey(s string) {
|
|
|
+ m.openai_key = &s
|
|
|
+}
|
|
|
+
|
|
|
+// OpenaiKey returns the value of the "openai_key" field in the mutation.
|
|
|
+func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
|
|
|
+ v := m.openai_key
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
|
|
|
+// If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.OpenaiKey, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearOpenaiKey clears the value of the "openai_key" field.
|
|
|
+func (m *ApiKeyMutation) ClearOpenaiKey() {
|
|
|
+ m.openai_key = nil
|
|
|
+ m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
|
|
|
+func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldOpenaiKey]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetOpenaiKey resets all changes to the "openai_key" field.
|
|
|
+func (m *ApiKeyMutation) ResetOpenaiKey() {
|
|
|
+ m.openai_key = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldOpenaiKey)
|
|
|
+}
|
|
|
+
|
|
|
+// ClearAgent clears the "agent" edge to the Agent entity.
|
|
|
+func (m *ApiKeyMutation) ClearAgent() {
|
|
|
+ m.clearedagent = true
|
|
|
+ m.clearedFields[apikey.FieldAgentID] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// AgentCleared reports if the "agent" edge to the Agent entity was cleared.
|
|
|
+func (m *ApiKeyMutation) AgentCleared() bool {
|
|
|
+ return m.clearedagent
|
|
|
+}
|
|
|
+
|
|
|
+// AgentIDs returns the "agent" edge IDs in the mutation.
|
|
|
+// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
|
+// AgentID instead. It exists only for internal usage by the builders.
|
|
|
+func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
|
|
|
+ if id := m.agent; id != nil {
|
|
|
+ ids = append(ids, *id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// ResetAgent resets all changes to the "agent" edge.
|
|
|
+func (m *ApiKeyMutation) ResetAgent() {
|
|
|
+ m.agent = nil
|
|
|
+ m.clearedagent = false
|
|
|
+}
|
|
|
+
|
|
|
+// Where appends a list predicates to the ApiKeyMutation builder.
|
|
|
+func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
|
|
|
+ m.predicates = append(m.predicates, ps...)
|
|
|
+}
|
|
|
+
|
|
|
+// WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
|
|
|
+// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
+func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
+ p := make([]predicate.ApiKey, len(ps))
|
|
|
+ for i := range ps {
|
|
|
+ p[i] = ps[i]
|
|
|
+ }
|
|
|
+ m.Where(p...)
|
|
|
+}
|
|
|
+
|
|
|
+// Op returns the operation name.
|
|
|
+func (m *ApiKeyMutation) Op() Op {
|
|
|
+ return m.op
|
|
|
+}
|
|
|
+
|
|
|
+// SetOp allows setting the mutation operation.
|
|
|
+func (m *ApiKeyMutation) SetOp(op Op) {
|
|
|
+ m.op = op
|
|
|
+}
|
|
|
+
|
|
|
+// Type returns the node type of this mutation (ApiKey).
|
|
|
+func (m *ApiKeyMutation) Type() string {
|
|
|
+ return m.typ
|
|
|
+}
|
|
|
+
|
|
|
+// Fields returns all fields that were changed during this mutation. Note that in
|
|
|
+// order to get all numeric fields that were incremented/decremented, call
|
|
|
+// AddedFields().
|
|
|
+func (m *ApiKeyMutation) Fields() []string {
|
|
|
+ fields := make([]string, 0, 11)
|
|
|
+ if m.created_at != nil {
|
|
|
+ fields = append(fields, apikey.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ if m.updated_at != nil {
|
|
|
+ fields = append(fields, apikey.FieldUpdatedAt)
|
|
|
+ }
|
|
|
+ if m.deleted_at != nil {
|
|
|
+ fields = append(fields, apikey.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ if m.title != nil {
|
|
|
+ fields = append(fields, apikey.FieldTitle)
|
|
|
+ }
|
|
|
+ if m.key != nil {
|
|
|
+ fields = append(fields, apikey.FieldKey)
|
|
|
+ }
|
|
|
+ if m.organization_id != nil {
|
|
|
+ fields = append(fields, apikey.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ if m.agent != nil {
|
|
|
+ fields = append(fields, apikey.FieldAgentID)
|
|
|
+ }
|
|
|
+ if m.custom_agent_base != nil {
|
|
|
+ fields = append(fields, apikey.FieldCustomAgentBase)
|
|
|
+ }
|
|
|
+ if m.custom_agent_key != nil {
|
|
|
+ fields = append(fields, apikey.FieldCustomAgentKey)
|
|
|
+ }
|
|
|
+ if m.openai_base != nil {
|
|
|
+ fields = append(fields, apikey.FieldOpenaiBase)
|
|
|
+ }
|
|
|
+ if m.openai_key != nil {
|
|
|
+ fields = append(fields, apikey.FieldOpenaiKey)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// Field returns the value of a field with the given name. The second boolean
|
|
|
+// return value indicates that this field was not set, or was not defined in the
|
|
|
+// schema.
|
|
|
+func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case apikey.FieldCreatedAt:
|
|
|
+ return m.CreatedAt()
|
|
|
+ case apikey.FieldUpdatedAt:
|
|
|
+ return m.UpdatedAt()
|
|
|
+ case apikey.FieldDeletedAt:
|
|
|
+ return m.DeletedAt()
|
|
|
+ case apikey.FieldTitle:
|
|
|
+ return m.Title()
|
|
|
+ case apikey.FieldKey:
|
|
|
+ return m.Key()
|
|
|
+ case apikey.FieldOrganizationID:
|
|
|
+ return m.OrganizationID()
|
|
|
+ case apikey.FieldAgentID:
|
|
|
+ return m.AgentID()
|
|
|
+ case apikey.FieldCustomAgentBase:
|
|
|
+ return m.CustomAgentBase()
|
|
|
+ case apikey.FieldCustomAgentKey:
|
|
|
+ return m.CustomAgentKey()
|
|
|
+ case apikey.FieldOpenaiBase:
|
|
|
+ return m.OpenaiBase()
|
|
|
+ case apikey.FieldOpenaiKey:
|
|
|
+ return m.OpenaiKey()
|
|
|
+ }
|
|
|
+ return nil, false
|
|
|
+}
|
|
|
+
|
|
|
+// OldField returns the old value of the field from the database. An error is
|
|
|
+// returned if the mutation operation is not UpdateOne, or the query to the
|
|
|
+// database failed.
|
|
|
+func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
+ switch name {
|
|
|
+ case apikey.FieldCreatedAt:
|
|
|
+ return m.OldCreatedAt(ctx)
|
|
|
+ case apikey.FieldUpdatedAt:
|
|
|
+ return m.OldUpdatedAt(ctx)
|
|
|
+ case apikey.FieldDeletedAt:
|
|
|
+ return m.OldDeletedAt(ctx)
|
|
|
+ case apikey.FieldTitle:
|
|
|
+ return m.OldTitle(ctx)
|
|
|
+ case apikey.FieldKey:
|
|
|
+ return m.OldKey(ctx)
|
|
|
+ case apikey.FieldOrganizationID:
|
|
|
+ return m.OldOrganizationID(ctx)
|
|
|
+ case apikey.FieldAgentID:
|
|
|
+ return m.OldAgentID(ctx)
|
|
|
+ case apikey.FieldCustomAgentBase:
|
|
|
+ return m.OldCustomAgentBase(ctx)
|
|
|
+ case apikey.FieldCustomAgentKey:
|
|
|
+ return m.OldCustomAgentKey(ctx)
|
|
|
+ case apikey.FieldOpenaiBase:
|
|
|
+ return m.OldOpenaiBase(ctx)
|
|
|
+ case apikey.FieldOpenaiKey:
|
|
|
+ return m.OldOpenaiKey(ctx)
|
|
|
+ }
|
|
|
+ return nil, fmt.Errorf("unknown ApiKey field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// SetField sets the value of a field with the given name. It returns an error if
|
|
|
+// the field is not defined in the schema, or if the type mismatched the field
|
|
|
+// type.
|
|
|
+func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case apikey.FieldCreatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCreatedAt(v)
|
|
|
+ return nil
|
|
|
+ case apikey.FieldUpdatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetUpdatedAt(v)
|
|
|
+ return nil
|
|
|
+ case apikey.FieldDeletedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetDeletedAt(v)
|
|
|
+ return nil
|
|
|
+ case apikey.FieldTitle:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetTitle(v)
|
|
|
+ return nil
|
|
|
+ case apikey.FieldKey:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetKey(v)
|
|
|
+ return nil
|
|
|
+ case apikey.FieldOrganizationID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ case apikey.FieldAgentID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetAgentID(v)
|
|
|
+ return nil
|
|
|
+ case apikey.FieldCustomAgentBase:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCustomAgentBase(v)
|
|
|
+ return nil
|
|
|
+ case apikey.FieldCustomAgentKey:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCustomAgentKey(v)
|
|
|
+ return nil
|
|
|
+ case apikey.FieldOpenaiBase:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetOpenaiBase(v)
|
|
|
+ return nil
|
|
|
+ case apikey.FieldOpenaiKey:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetOpenaiKey(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ApiKey field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
+// this mutation.
|
|
|
+func (m *ApiKeyMutation) AddedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ fields = append(fields, apikey.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// AddedField returns the numeric value that was incremented/decremented on a field
|
|
|
+// with the given name. The second boolean return value indicates that this field
|
|
|
+// was not set, or was not defined in the schema.
|
|
|
+func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case apikey.FieldOrganizationID:
|
|
|
+ return m.AddedOrganizationID()
|
|
|
+ }
|
|
|
+ return nil, false
|
|
|
+}
|
|
|
+
|
|
|
+// AddField adds the value to the field with the given name. It returns an error if
|
|
|
+// the field is not defined in the schema, or if the type mismatched the field
|
|
|
+// type.
|
|
|
+func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case apikey.FieldOrganizationID:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ApiKey numeric field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedFields returns all nullable fields that were cleared during this
|
|
|
+// mutation.
|
|
|
+func (m *ApiKeyMutation) ClearedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.FieldCleared(apikey.FieldDeletedAt) {
|
|
|
+ fields = append(fields, apikey.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(apikey.FieldTitle) {
|
|
|
+ fields = append(fields, apikey.FieldTitle)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(apikey.FieldKey) {
|
|
|
+ fields = append(fields, apikey.FieldKey)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(apikey.FieldCustomAgentBase) {
|
|
|
+ fields = append(fields, apikey.FieldCustomAgentBase)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(apikey.FieldCustomAgentKey) {
|
|
|
+ fields = append(fields, apikey.FieldCustomAgentKey)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(apikey.FieldOpenaiBase) {
|
|
|
+ fields = append(fields, apikey.FieldOpenaiBase)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(apikey.FieldOpenaiKey) {
|
|
|
+ fields = append(fields, apikey.FieldOpenaiKey)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
+// cleared in this mutation.
|
|
|
+func (m *ApiKeyMutation) FieldCleared(name string) bool {
|
|
|
+ _, ok := m.clearedFields[name]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ClearField clears the value of the field with the given name. It returns an
|
|
|
+// error if the field is not defined in the schema.
|
|
|
+func (m *ApiKeyMutation) ClearField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case apikey.FieldDeletedAt:
|
|
|
+ m.ClearDeletedAt()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldTitle:
|
|
|
+ m.ClearTitle()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldKey:
|
|
|
+ m.ClearKey()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldCustomAgentBase:
|
|
|
+ m.ClearCustomAgentBase()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldCustomAgentKey:
|
|
|
+ m.ClearCustomAgentKey()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldOpenaiBase:
|
|
|
+ m.ClearOpenaiBase()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldOpenaiKey:
|
|
|
+ m.ClearOpenaiKey()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ApiKey nullable field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ResetField resets all changes in the mutation for the field with the given name.
|
|
|
+// It returns an error if the field is not defined in the schema.
|
|
|
+func (m *ApiKeyMutation) ResetField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case apikey.FieldCreatedAt:
|
|
|
+ m.ResetCreatedAt()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldUpdatedAt:
|
|
|
+ m.ResetUpdatedAt()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldDeletedAt:
|
|
|
+ m.ResetDeletedAt()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldTitle:
|
|
|
+ m.ResetTitle()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldKey:
|
|
|
+ m.ResetKey()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldOrganizationID:
|
|
|
+ m.ResetOrganizationID()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldAgentID:
|
|
|
+ m.ResetAgentID()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldCustomAgentBase:
|
|
|
+ m.ResetCustomAgentBase()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldCustomAgentKey:
|
|
|
+ m.ResetCustomAgentKey()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldOpenaiBase:
|
|
|
+ m.ResetOpenaiBase()
|
|
|
+ return nil
|
|
|
+ case apikey.FieldOpenaiKey:
|
|
|
+ m.ResetOpenaiKey()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ApiKey field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
+func (m *ApiKeyMutation) AddedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ if m.agent != nil {
|
|
|
+ edges = append(edges, apikey.EdgeAgent)
|
|
|
+ }
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
+// name in this mutation.
|
|
|
+func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
|
|
|
+ switch name {
|
|
|
+ case apikey.EdgeAgent:
|
|
|
+ if id := m.agent; id != nil {
|
|
|
+ return []ent.Value{*id}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
+func (m *ApiKeyMutation) RemovedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
+// the given name in this mutation.
|
|
|
+func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
+func (m *ApiKeyMutation) ClearedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ if m.clearedagent {
|
|
|
+ edges = append(edges, apikey.EdgeAgent)
|
|
|
+ }
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
+// was cleared in this mutation.
|
|
|
+func (m *ApiKeyMutation) EdgeCleared(name string) bool {
|
|
|
+ switch name {
|
|
|
+ case apikey.EdgeAgent:
|
|
|
+ return m.clearedagent
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
|
+// if that edge is not defined in the schema.
|
|
|
+func (m *ApiKeyMutation) ClearEdge(name string) error {
|
|
|
+ switch name {
|
|
|
+ case apikey.EdgeAgent:
|
|
|
+ m.ClearAgent()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ApiKey unique edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
|
+// It returns an error if the edge is not defined in the schema.
|
|
|
+func (m *ApiKeyMutation) ResetEdge(name string) error {
|
|
|
+ switch name {
|
|
|
+ case apikey.EdgeAgent:
|
|
|
+ m.ResetAgent()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ApiKey edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
// BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
|
|
|
type BatchMsgMutation struct {
|
|
|
config
|