|
@@ -55,22 +55,24 @@ const (
|
|
|
// AgentMutation represents an operation that mutates the Agent nodes in the graph.
|
|
|
type AgentMutation struct {
|
|
|
config
|
|
|
- op Op
|
|
|
- typ string
|
|
|
- id *uint64
|
|
|
- created_at *time.Time
|
|
|
- updated_at *time.Time
|
|
|
- deleted_at *time.Time
|
|
|
- name *string
|
|
|
- role *string
|
|
|
- status *int
|
|
|
- addstatus *int
|
|
|
- background *string
|
|
|
- examples *string
|
|
|
- clearedFields map[string]struct{}
|
|
|
- done bool
|
|
|
- oldValue func(context.Context) (*Agent, error)
|
|
|
- predicates []predicate.Agent
|
|
|
+ op Op
|
|
|
+ typ string
|
|
|
+ id *uint64
|
|
|
+ created_at *time.Time
|
|
|
+ updated_at *time.Time
|
|
|
+ deleted_at *time.Time
|
|
|
+ name *string
|
|
|
+ role *string
|
|
|
+ status *int
|
|
|
+ addstatus *int
|
|
|
+ background *string
|
|
|
+ examples *string
|
|
|
+ organization_id *uint64
|
|
|
+ addorganization_id *int64
|
|
|
+ clearedFields map[string]struct{}
|
|
|
+ done bool
|
|
|
+ oldValue func(context.Context) (*Agent, error)
|
|
|
+ predicates []predicate.Agent
|
|
|
}
|
|
|
|
|
|
var _ ent.Mutation = (*AgentMutation)(nil)
|
|
@@ -512,6 +514,62 @@ func (m *AgentMutation) ResetExamples() {
|
|
|
m.examples = nil
|
|
|
}
|
|
|
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (m *AgentMutation) 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 *AgentMutation) 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 Agent entity.
|
|
|
+// If the Agent 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 *AgentMutation) 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 *AgentMutation) 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 *AgentMutation) 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 *AgentMutation) ResetOrganizationID() {
|
|
|
+ m.organization_id = nil
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
// Where appends a list predicates to the AgentMutation builder.
|
|
|
func (m *AgentMutation) Where(ps ...predicate.Agent) {
|
|
|
m.predicates = append(m.predicates, ps...)
|
|
@@ -546,7 +604,7 @@ func (m *AgentMutation) Type() string {
|
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
|
// AddedFields().
|
|
|
func (m *AgentMutation) Fields() []string {
|
|
|
- fields := make([]string, 0, 8)
|
|
|
+ fields := make([]string, 0, 9)
|
|
|
if m.created_at != nil {
|
|
|
fields = append(fields, agent.FieldCreatedAt)
|
|
|
}
|
|
@@ -571,6 +629,9 @@ func (m *AgentMutation) Fields() []string {
|
|
|
if m.examples != nil {
|
|
|
fields = append(fields, agent.FieldExamples)
|
|
|
}
|
|
|
+ if m.organization_id != nil {
|
|
|
+ fields = append(fields, agent.FieldOrganizationID)
|
|
|
+ }
|
|
|
return fields
|
|
|
}
|
|
|
|
|
@@ -595,6 +656,8 @@ func (m *AgentMutation) Field(name string) (ent.Value, bool) {
|
|
|
return m.Background()
|
|
|
case agent.FieldExamples:
|
|
|
return m.Examples()
|
|
|
+ case agent.FieldOrganizationID:
|
|
|
+ return m.OrganizationID()
|
|
|
}
|
|
|
return nil, false
|
|
|
}
|
|
@@ -620,6 +683,8 @@ func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, e
|
|
|
return m.OldBackground(ctx)
|
|
|
case agent.FieldExamples:
|
|
|
return m.OldExamples(ctx)
|
|
|
+ case agent.FieldOrganizationID:
|
|
|
+ return m.OldOrganizationID(ctx)
|
|
|
}
|
|
|
return nil, fmt.Errorf("unknown Agent field %s", name)
|
|
|
}
|
|
@@ -685,6 +750,13 @@ func (m *AgentMutation) SetField(name string, value ent.Value) error {
|
|
|
}
|
|
|
m.SetExamples(v)
|
|
|
return nil
|
|
|
+ case agent.FieldOrganizationID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetOrganizationID(v)
|
|
|
+ return nil
|
|
|
}
|
|
|
return fmt.Errorf("unknown Agent field %s", name)
|
|
|
}
|
|
@@ -696,6 +768,9 @@ func (m *AgentMutation) AddedFields() []string {
|
|
|
if m.addstatus != nil {
|
|
|
fields = append(fields, agent.FieldStatus)
|
|
|
}
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ fields = append(fields, agent.FieldOrganizationID)
|
|
|
+ }
|
|
|
return fields
|
|
|
}
|
|
|
|
|
@@ -706,6 +781,8 @@ func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
switch name {
|
|
|
case agent.FieldStatus:
|
|
|
return m.AddedStatus()
|
|
|
+ case agent.FieldOrganizationID:
|
|
|
+ return m.AddedOrganizationID()
|
|
|
}
|
|
|
return nil, false
|
|
|
}
|
|
@@ -722,6 +799,13 @@ func (m *AgentMutation) AddField(name string, value ent.Value) error {
|
|
|
}
|
|
|
m.AddStatus(v)
|
|
|
return nil
|
|
|
+ case agent.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 Agent numeric field %s", name)
|
|
|
}
|
|
@@ -788,6 +872,9 @@ func (m *AgentMutation) ResetField(name string) error {
|
|
|
case agent.FieldExamples:
|
|
|
m.ResetExamples()
|
|
|
return nil
|
|
|
+ case agent.FieldOrganizationID:
|
|
|
+ m.ResetOrganizationID()
|
|
|
+ return nil
|
|
|
}
|
|
|
return fmt.Errorf("unknown Agent field %s", name)
|
|
|
}
|