|
@@ -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
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+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{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *AgentMutation) ClearKeyAgent() {
|
|
|
+ m.clearedkey_agent = true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *AgentMutation) KeyAgentCleared() bool {
|
|
|
+ return m.clearedkey_agent
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+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{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
|
|
|
+ for id := range m.removedkey_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
|
|
|
+ for id := range m.key_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *AgentMutation) ResetKeyAgent() {
|
|
|
+ m.key_agent = nil
|
|
|
+ m.clearedkey_agent = false
|
|
|
+ m.removedkey_agent = nil
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
func (m *AgentMutation) Where(ps ...predicate.Agent) {
|
|
|
m.predicates = append(m.predicates, ps...)
|
|
@@ -1252,7 +1311,7 @@ func (m *AgentMutation) ResetField(name string) error {
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+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)
|
|
|
+
|
|
|
+
|
|
|
+type apikeyOption func(*ApiKeyMutation)
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func withApiKey(node *ApiKey) apikeyOption {
|
|
|
+ return func(m *ApiKeyMutation) {
|
|
|
+ m.oldValue = func(context.Context) (*ApiKey, error) {
|
|
|
+ return node, nil
|
|
|
+ }
|
|
|
+ m.id = &node.ID
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m ApiKeyMutation) Client() *Client {
|
|
|
+ client := &Client{config: m.config}
|
|
|
+ client.init()
|
|
|
+ return client
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetID(id uint64) {
|
|
|
+ m.id = &id
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
|
|
|
+ if m.id == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *m.id, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
|
|
|
+ m.created_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.created_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetCreatedAt() {
|
|
|
+ m.created_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
|
|
|
+ m.updated_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.updated_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetUpdatedAt() {
|
|
|
+ m.updated_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
|
|
|
+ m.deleted_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.deleted_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ClearDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) DeletedAtCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldDeletedAt]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldDeletedAt)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetTitle(s string) {
|
|
|
+ m.title = &s
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) Title() (r string, exists bool) {
|
|
|
+ v := m.title
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ClearTitle() {
|
|
|
+ m.title = nil
|
|
|
+ m.clearedFields[apikey.FieldTitle] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) TitleCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldTitle]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetTitle() {
|
|
|
+ m.title = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldTitle)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetKey(s string) {
|
|
|
+ m.key = &s
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) Key() (r string, exists bool) {
|
|
|
+ v := m.key
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ClearKey() {
|
|
|
+ m.key = nil
|
|
|
+ m.clearedFields[apikey.FieldKey] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) KeyCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldKey]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetKey() {
|
|
|
+ m.key = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldKey)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
|
|
|
+ m.organization_id = &u
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
|
|
|
+ v := m.organization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) AddOrganizationID(u int64) {
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ *m.addorganization_id += u
|
|
|
+ } else {
|
|
|
+ m.addorganization_id = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
|
|
|
+ v := m.addorganization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetOrganizationID() {
|
|
|
+ m.organization_id = nil
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetAgentID(u uint64) {
|
|
|
+ m.agent = &u
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
|
|
|
+ v := m.agent
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetAgentID() {
|
|
|
+ m.agent = nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
|
|
|
+ m.custom_agent_base = &s
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
|
|
|
+ v := m.custom_agent_base
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ClearCustomAgentBase() {
|
|
|
+ m.custom_agent_base = nil
|
|
|
+ m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetCustomAgentBase() {
|
|
|
+ m.custom_agent_base = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldCustomAgentBase)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
|
|
|
+ m.custom_agent_key = &s
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
|
|
|
+ v := m.custom_agent_key
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ClearCustomAgentKey() {
|
|
|
+ m.custom_agent_key = nil
|
|
|
+ m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetCustomAgentKey() {
|
|
|
+ m.custom_agent_key = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldCustomAgentKey)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetOpenaiBase(s string) {
|
|
|
+ m.openai_base = &s
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
|
|
|
+ v := m.openai_base
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ClearOpenaiBase() {
|
|
|
+ m.openai_base = nil
|
|
|
+ m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldOpenaiBase]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetOpenaiBase() {
|
|
|
+ m.openai_base = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldOpenaiBase)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetOpenaiKey(s string) {
|
|
|
+ m.openai_key = &s
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
|
|
|
+ v := m.openai_key
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ClearOpenaiKey() {
|
|
|
+ m.openai_key = nil
|
|
|
+ m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
|
|
|
+ _, ok := m.clearedFields[apikey.FieldOpenaiKey]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetOpenaiKey() {
|
|
|
+ m.openai_key = nil
|
|
|
+ delete(m.clearedFields, apikey.FieldOpenaiKey)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ClearAgent() {
|
|
|
+ m.clearedagent = true
|
|
|
+ m.clearedFields[apikey.FieldAgentID] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) AgentCleared() bool {
|
|
|
+ return m.clearedagent
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
|
|
|
+ if id := m.agent; id != nil {
|
|
|
+ ids = append(ids, *id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetAgent() {
|
|
|
+ m.agent = nil
|
|
|
+ m.clearedagent = false
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
|
|
|
+ m.predicates = append(m.predicates, ps...)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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...)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) Op() Op {
|
|
|
+ return m.op
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) SetOp(op Op) {
|
|
|
+ m.op = op
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) Type() string {
|
|
|
+ return m.typ
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) AddedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ fields = append(fields, apikey.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case apikey.FieldOrganizationID:
|
|
|
+ return m.AddedOrganizationID()
|
|
|
+ }
|
|
|
+ return nil, false
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) FieldCleared(name string) bool {
|
|
|
+ _, ok := m.clearedFields[name]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) AddedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ if m.agent != nil {
|
|
|
+ edges = append(edges, apikey.EdgeAgent)
|
|
|
+ }
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) RemovedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ClearedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ if m.clearedagent {
|
|
|
+ edges = append(edges, apikey.EdgeAgent)
|
|
|
+ }
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) EdgeCleared(name string) bool {
|
|
|
+ switch name {
|
|
|
+ case apikey.EdgeAgent:
|
|
|
+ return m.clearedagent
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *ApiKeyMutation) ResetEdge(name string) error {
|
|
|
+ switch name {
|
|
|
+ case apikey.EdgeAgent:
|
|
|
+ m.ResetAgent()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ApiKey edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
type BatchMsgMutation struct {
|
|
|
config
|