Files
twurscandLydiaCai1203 cc28479493 Feat models add field (#643)
* feat: 模型配置支持配置多模态

* feat: models add is_hidden field

---------

Co-authored-by: LydiaCai1203 <1125862926@qq.com>
2026-06-02 19:59:51 +08:00

42114 lines
1.2 MiB
Plaintext

// Code generated by ent, DO NOT EDIT.
package db
import (
"context"
"errors"
"fmt"
"sync"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/chaitin/MonkeyCode/backend/consts"
"github.com/chaitin/MonkeyCode/backend/db/audit"
"github.com/chaitin/MonkeyCode/backend/db/gitbot"
"github.com/chaitin/MonkeyCode/backend/db/gitbottask"
"github.com/chaitin/MonkeyCode/backend/db/gitbotuser"
"github.com/chaitin/MonkeyCode/backend/db/gitidentity"
"github.com/chaitin/MonkeyCode/backend/db/gittask"
"github.com/chaitin/MonkeyCode/backend/db/host"
"github.com/chaitin/MonkeyCode/backend/db/image"
"github.com/chaitin/MonkeyCode/backend/db/mcptool"
"github.com/chaitin/MonkeyCode/backend/db/mcpupstream"
"github.com/chaitin/MonkeyCode/backend/db/mcpusertoolsetting"
"github.com/chaitin/MonkeyCode/backend/db/model"
"github.com/chaitin/MonkeyCode/backend/db/modelapikey"
"github.com/chaitin/MonkeyCode/backend/db/modelpricing"
"github.com/chaitin/MonkeyCode/backend/db/notifychannel"
"github.com/chaitin/MonkeyCode/backend/db/notifysendlog"
"github.com/chaitin/MonkeyCode/backend/db/notifysubscription"
"github.com/chaitin/MonkeyCode/backend/db/predicate"
"github.com/chaitin/MonkeyCode/backend/db/project"
"github.com/chaitin/MonkeyCode/backend/db/projectcollaborator"
"github.com/chaitin/MonkeyCode/backend/db/projectgitbot"
"github.com/chaitin/MonkeyCode/backend/db/projectissue"
"github.com/chaitin/MonkeyCode/backend/db/projectissuecomment"
"github.com/chaitin/MonkeyCode/backend/db/projecttask"
"github.com/chaitin/MonkeyCode/backend/db/task"
"github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch"
"github.com/chaitin/MonkeyCode/backend/db/taskusagestat"
"github.com/chaitin/MonkeyCode/backend/db/taskvirtualmachine"
"github.com/chaitin/MonkeyCode/backend/db/team"
"github.com/chaitin/MonkeyCode/backend/db/teamgroup"
"github.com/chaitin/MonkeyCode/backend/db/teamgrouphost"
"github.com/chaitin/MonkeyCode/backend/db/teamgroupimage"
"github.com/chaitin/MonkeyCode/backend/db/teamgroupmember"
"github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel"
"github.com/chaitin/MonkeyCode/backend/db/teamhost"
"github.com/chaitin/MonkeyCode/backend/db/teamimage"
"github.com/chaitin/MonkeyCode/backend/db/teammember"
"github.com/chaitin/MonkeyCode/backend/db/teammodel"
"github.com/chaitin/MonkeyCode/backend/db/user"
"github.com/chaitin/MonkeyCode/backend/db/useridentity"
"github.com/chaitin/MonkeyCode/backend/db/virtualmachine"
"github.com/chaitin/MonkeyCode/backend/ent/types"
"github.com/google/uuid"
)
const (
// Operation types.
OpCreate = ent.OpCreate
OpDelete = ent.OpDelete
OpDeleteOne = ent.OpDeleteOne
OpUpdate = ent.OpUpdate
OpUpdateOne = ent.OpUpdateOne
// Node types.
TypeAudit = "Audit"
TypeGitBot = "GitBot"
TypeGitBotTask = "GitBotTask"
TypeGitBotUser = "GitBotUser"
TypeGitIdentity = "GitIdentity"
TypeGitTask = "GitTask"
TypeHost = "Host"
TypeImage = "Image"
TypeMCPTool = "MCPTool"
TypeMCPUpstream = "MCPUpstream"
TypeMCPUserToolSetting = "MCPUserToolSetting"
TypeModel = "Model"
TypeModelApiKey = "ModelApiKey"
TypeModelPricing = "ModelPricing"
TypeNotifyChannel = "NotifyChannel"
TypeNotifySendLog = "NotifySendLog"
TypeNotifySubscription = "NotifySubscription"
TypeProject = "Project"
TypeProjectCollaborator = "ProjectCollaborator"
TypeProjectGitBot = "ProjectGitBot"
TypeProjectIssue = "ProjectIssue"
TypeProjectIssueComment = "ProjectIssueComment"
TypeProjectTask = "ProjectTask"
TypeTask = "Task"
TypeTaskModelSwitch = "TaskModelSwitch"
TypeTaskUsageStat = "TaskUsageStat"
TypeTaskVirtualMachine = "TaskVirtualMachine"
TypeTeam = "Team"
TypeTeamGroup = "TeamGroup"
TypeTeamGroupHost = "TeamGroupHost"
TypeTeamGroupImage = "TeamGroupImage"
TypeTeamGroupMember = "TeamGroupMember"
TypeTeamGroupModel = "TeamGroupModel"
TypeTeamHost = "TeamHost"
TypeTeamImage = "TeamImage"
TypeTeamMember = "TeamMember"
TypeTeamModel = "TeamModel"
TypeUser = "User"
TypeUserIdentity = "UserIdentity"
TypeVirtualMachine = "VirtualMachine"
)
// AuditMutation represents an operation that mutates the Audit nodes in the graph.
type AuditMutation struct {
config
op Op
typ string
id *uuid.UUID
operation *string
source_ip *string
user_agent *string
request *string
response *string
created_at *time.Time
clearedFields map[string]struct{}
user *uuid.UUID
cleareduser bool
done bool
oldValue func(context.Context) (*Audit, error)
predicates []predicate.Audit
}
var _ ent.Mutation = (*AuditMutation)(nil)
// auditOption allows management of the mutation configuration using functional options.
type auditOption func(*AuditMutation)
// newAuditMutation creates new mutation for the Audit entity.
func newAuditMutation(c config, op Op, opts ...auditOption) *AuditMutation {
m := &AuditMutation{
config: c,
op: op,
typ: TypeAudit,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withAuditID sets the ID field of the mutation.
func withAuditID(id uuid.UUID) auditOption {
return func(m *AuditMutation) {
var (
err error
once sync.Once
value *Audit
)
m.oldValue = func(ctx context.Context) (*Audit, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Audit.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withAudit sets the old Audit of the mutation.
func withAudit(node *Audit) auditOption {
return func(m *AuditMutation) {
m.oldValue = func(context.Context) (*Audit, 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 AuditMutation) 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 AuditMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 Audit entities.
func (m *AuditMutation) SetID(id uuid.UUID) {
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 *AuditMutation) ID() (id uuid.UUID, 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 *AuditMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().Audit.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetUserID sets the "user_id" field.
func (m *AuditMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *AuditMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the Audit entity.
// If the Audit 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 *AuditMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *AuditMutation) ResetUserID() {
m.user = nil
}
// SetOperation sets the "operation" field.
func (m *AuditMutation) SetOperation(s string) {
m.operation = &s
}
// Operation returns the value of the "operation" field in the mutation.
func (m *AuditMutation) Operation() (r string, exists bool) {
v := m.operation
if v == nil {
return
}
return *v, true
}
// OldOperation returns the old "operation" field's value of the Audit entity.
// If the Audit 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 *AuditMutation) OldOperation(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOperation is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOperation requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOperation: %w", err)
}
return oldValue.Operation, nil
}
// ResetOperation resets all changes to the "operation" field.
func (m *AuditMutation) ResetOperation() {
m.operation = nil
}
// SetSourceIP sets the "source_ip" field.
func (m *AuditMutation) SetSourceIP(s string) {
m.source_ip = &s
}
// SourceIP returns the value of the "source_ip" field in the mutation.
func (m *AuditMutation) SourceIP() (r string, exists bool) {
v := m.source_ip
if v == nil {
return
}
return *v, true
}
// OldSourceIP returns the old "source_ip" field's value of the Audit entity.
// If the Audit 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 *AuditMutation) OldSourceIP(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSourceIP is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSourceIP requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSourceIP: %w", err)
}
return oldValue.SourceIP, nil
}
// ResetSourceIP resets all changes to the "source_ip" field.
func (m *AuditMutation) ResetSourceIP() {
m.source_ip = nil
}
// SetUserAgent sets the "user_agent" field.
func (m *AuditMutation) SetUserAgent(s string) {
m.user_agent = &s
}
// UserAgent returns the value of the "user_agent" field in the mutation.
func (m *AuditMutation) UserAgent() (r string, exists bool) {
v := m.user_agent
if v == nil {
return
}
return *v, true
}
// OldUserAgent returns the old "user_agent" field's value of the Audit entity.
// If the Audit 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 *AuditMutation) OldUserAgent(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserAgent is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserAgent requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserAgent: %w", err)
}
return oldValue.UserAgent, nil
}
// ResetUserAgent resets all changes to the "user_agent" field.
func (m *AuditMutation) ResetUserAgent() {
m.user_agent = nil
}
// SetRequest sets the "request" field.
func (m *AuditMutation) SetRequest(s string) {
m.request = &s
}
// Request returns the value of the "request" field in the mutation.
func (m *AuditMutation) Request() (r string, exists bool) {
v := m.request
if v == nil {
return
}
return *v, true
}
// OldRequest returns the old "request" field's value of the Audit entity.
// If the Audit 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 *AuditMutation) OldRequest(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRequest is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRequest requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRequest: %w", err)
}
return oldValue.Request, nil
}
// ResetRequest resets all changes to the "request" field.
func (m *AuditMutation) ResetRequest() {
m.request = nil
}
// SetResponse sets the "response" field.
func (m *AuditMutation) SetResponse(s string) {
m.response = &s
}
// Response returns the value of the "response" field in the mutation.
func (m *AuditMutation) Response() (r string, exists bool) {
v := m.response
if v == nil {
return
}
return *v, true
}
// OldResponse returns the old "response" field's value of the Audit entity.
// If the Audit 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 *AuditMutation) OldResponse(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldResponse is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldResponse requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldResponse: %w", err)
}
return oldValue.Response, nil
}
// ClearResponse clears the value of the "response" field.
func (m *AuditMutation) ClearResponse() {
m.response = nil
m.clearedFields[audit.FieldResponse] = struct{}{}
}
// ResponseCleared returns if the "response" field was cleared in this mutation.
func (m *AuditMutation) ResponseCleared() bool {
_, ok := m.clearedFields[audit.FieldResponse]
return ok
}
// ResetResponse resets all changes to the "response" field.
func (m *AuditMutation) ResetResponse() {
m.response = nil
delete(m.clearedFields, audit.FieldResponse)
}
// SetCreatedAt sets the "created_at" field.
func (m *AuditMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *AuditMutation) 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 Audit entity.
// If the Audit 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 *AuditMutation) 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 *AuditMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearUser clears the "user" edge to the User entity.
func (m *AuditMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[audit.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *AuditMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *AuditMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *AuditMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// Where appends a list predicates to the AuditMutation builder.
func (m *AuditMutation) Where(ps ...predicate.Audit) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the AuditMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *AuditMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Audit, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *AuditMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *AuditMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Audit).
func (m *AuditMutation) 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 *AuditMutation) Fields() []string {
fields := make([]string, 0, 7)
if m.user != nil {
fields = append(fields, audit.FieldUserID)
}
if m.operation != nil {
fields = append(fields, audit.FieldOperation)
}
if m.source_ip != nil {
fields = append(fields, audit.FieldSourceIP)
}
if m.user_agent != nil {
fields = append(fields, audit.FieldUserAgent)
}
if m.request != nil {
fields = append(fields, audit.FieldRequest)
}
if m.response != nil {
fields = append(fields, audit.FieldResponse)
}
if m.created_at != nil {
fields = append(fields, audit.FieldCreatedAt)
}
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 *AuditMutation) Field(name string) (ent.Value, bool) {
switch name {
case audit.FieldUserID:
return m.UserID()
case audit.FieldOperation:
return m.Operation()
case audit.FieldSourceIP:
return m.SourceIP()
case audit.FieldUserAgent:
return m.UserAgent()
case audit.FieldRequest:
return m.Request()
case audit.FieldResponse:
return m.Response()
case audit.FieldCreatedAt:
return m.CreatedAt()
}
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 *AuditMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case audit.FieldUserID:
return m.OldUserID(ctx)
case audit.FieldOperation:
return m.OldOperation(ctx)
case audit.FieldSourceIP:
return m.OldSourceIP(ctx)
case audit.FieldUserAgent:
return m.OldUserAgent(ctx)
case audit.FieldRequest:
return m.OldRequest(ctx)
case audit.FieldResponse:
return m.OldResponse(ctx)
case audit.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown Audit 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 *AuditMutation) SetField(name string, value ent.Value) error {
switch name {
case audit.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case audit.FieldOperation:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOperation(v)
return nil
case audit.FieldSourceIP:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSourceIP(v)
return nil
case audit.FieldUserAgent:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserAgent(v)
return nil
case audit.FieldRequest:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRequest(v)
return nil
case audit.FieldResponse:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetResponse(v)
return nil
case audit.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown Audit field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *AuditMutation) AddedFields() []string {
return nil
}
// 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 *AuditMutation) AddedField(name string) (ent.Value, bool) {
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 *AuditMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown Audit numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *AuditMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(audit.FieldResponse) {
fields = append(fields, audit.FieldResponse)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *AuditMutation) 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 *AuditMutation) ClearField(name string) error {
switch name {
case audit.FieldResponse:
m.ClearResponse()
return nil
}
return fmt.Errorf("unknown Audit 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 *AuditMutation) ResetField(name string) error {
switch name {
case audit.FieldUserID:
m.ResetUserID()
return nil
case audit.FieldOperation:
m.ResetOperation()
return nil
case audit.FieldSourceIP:
m.ResetSourceIP()
return nil
case audit.FieldUserAgent:
m.ResetUserAgent()
return nil
case audit.FieldRequest:
m.ResetRequest()
return nil
case audit.FieldResponse:
m.ResetResponse()
return nil
case audit.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown Audit field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *AuditMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.user != nil {
edges = append(edges, audit.EdgeUser)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *AuditMutation) AddedIDs(name string) []ent.Value {
switch name {
case audit.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *AuditMutation) 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 *AuditMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *AuditMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.cleareduser {
edges = append(edges, audit.EdgeUser)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *AuditMutation) EdgeCleared(name string) bool {
switch name {
case audit.EdgeUser:
return m.cleareduser
}
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 *AuditMutation) ClearEdge(name string) error {
switch name {
case audit.EdgeUser:
m.ClearUser()
return nil
}
return fmt.Errorf("unknown Audit 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 *AuditMutation) ResetEdge(name string) error {
switch name {
case audit.EdgeUser:
m.ResetUser()
return nil
}
return fmt.Errorf("unknown Audit edge %s", name)
}
// GitBotMutation represents an operation that mutates the GitBot nodes in the graph.
type GitBotMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
user_id *uuid.UUID
name *string
token *string
secret_token *string
platform *consts.GitPlatform
created_at *time.Time
clearedFields map[string]struct{}
git_bot_tasks map[uuid.UUID]struct{}
removedgit_bot_tasks map[uuid.UUID]struct{}
clearedgit_bot_tasks bool
host *string
clearedhost bool
users map[uuid.UUID]struct{}
removedusers map[uuid.UUID]struct{}
clearedusers bool
projects map[uuid.UUID]struct{}
removedprojects map[uuid.UUID]struct{}
clearedprojects bool
git_bot_users map[uuid.UUID]struct{}
removedgit_bot_users map[uuid.UUID]struct{}
clearedgit_bot_users bool
project_git_bots map[uuid.UUID]struct{}
removedproject_git_bots map[uuid.UUID]struct{}
clearedproject_git_bots bool
done bool
oldValue func(context.Context) (*GitBot, error)
predicates []predicate.GitBot
}
var _ ent.Mutation = (*GitBotMutation)(nil)
// gitbotOption allows management of the mutation configuration using functional options.
type gitbotOption func(*GitBotMutation)
// newGitBotMutation creates new mutation for the GitBot entity.
func newGitBotMutation(c config, op Op, opts ...gitbotOption) *GitBotMutation {
m := &GitBotMutation{
config: c,
op: op,
typ: TypeGitBot,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withGitBotID sets the ID field of the mutation.
func withGitBotID(id uuid.UUID) gitbotOption {
return func(m *GitBotMutation) {
var (
err error
once sync.Once
value *GitBot
)
m.oldValue = func(ctx context.Context) (*GitBot, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().GitBot.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withGitBot sets the old GitBot of the mutation.
func withGitBot(node *GitBot) gitbotOption {
return func(m *GitBotMutation) {
m.oldValue = func(context.Context) (*GitBot, 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 GitBotMutation) 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 GitBotMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 GitBot entities.
func (m *GitBotMutation) SetID(id uuid.UUID) {
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 *GitBotMutation) ID() (id uuid.UUID, 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 *GitBotMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().GitBot.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *GitBotMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *GitBotMutation) 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 GitBot entity.
// If the GitBot 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 *GitBotMutation) 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 *GitBotMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[gitbot.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *GitBotMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[gitbot.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *GitBotMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, gitbot.FieldDeletedAt)
}
// SetUserID sets the "user_id" field.
func (m *GitBotMutation) SetUserID(u uuid.UUID) {
m.user_id = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *GitBotMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user_id
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the GitBot entity.
// If the GitBot 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 *GitBotMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *GitBotMutation) ResetUserID() {
m.user_id = nil
}
// SetName sets the "name" field.
func (m *GitBotMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *GitBotMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the GitBot entity.
// If the GitBot 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 *GitBotMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldName: %w", err)
}
return oldValue.Name, nil
}
// ClearName clears the value of the "name" field.
func (m *GitBotMutation) ClearName() {
m.name = nil
m.clearedFields[gitbot.FieldName] = struct{}{}
}
// NameCleared returns if the "name" field was cleared in this mutation.
func (m *GitBotMutation) NameCleared() bool {
_, ok := m.clearedFields[gitbot.FieldName]
return ok
}
// ResetName resets all changes to the "name" field.
func (m *GitBotMutation) ResetName() {
m.name = nil
delete(m.clearedFields, gitbot.FieldName)
}
// SetHostID sets the "host_id" field.
func (m *GitBotMutation) SetHostID(s string) {
m.host = &s
}
// HostID returns the value of the "host_id" field in the mutation.
func (m *GitBotMutation) HostID() (r string, exists bool) {
v := m.host
if v == nil {
return
}
return *v, true
}
// OldHostID returns the old "host_id" field's value of the GitBot entity.
// If the GitBot 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 *GitBotMutation) OldHostID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHostID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHostID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHostID: %w", err)
}
return oldValue.HostID, nil
}
// ResetHostID resets all changes to the "host_id" field.
func (m *GitBotMutation) ResetHostID() {
m.host = nil
}
// SetToken sets the "token" field.
func (m *GitBotMutation) SetToken(s string) {
m.token = &s
}
// Token returns the value of the "token" field in the mutation.
func (m *GitBotMutation) Token() (r string, exists bool) {
v := m.token
if v == nil {
return
}
return *v, true
}
// OldToken returns the old "token" field's value of the GitBot entity.
// If the GitBot 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 *GitBotMutation) OldToken(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldToken is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldToken requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldToken: %w", err)
}
return oldValue.Token, nil
}
// ClearToken clears the value of the "token" field.
func (m *GitBotMutation) ClearToken() {
m.token = nil
m.clearedFields[gitbot.FieldToken] = struct{}{}
}
// TokenCleared returns if the "token" field was cleared in this mutation.
func (m *GitBotMutation) TokenCleared() bool {
_, ok := m.clearedFields[gitbot.FieldToken]
return ok
}
// ResetToken resets all changes to the "token" field.
func (m *GitBotMutation) ResetToken() {
m.token = nil
delete(m.clearedFields, gitbot.FieldToken)
}
// SetSecretToken sets the "secret_token" field.
func (m *GitBotMutation) SetSecretToken(s string) {
m.secret_token = &s
}
// SecretToken returns the value of the "secret_token" field in the mutation.
func (m *GitBotMutation) SecretToken() (r string, exists bool) {
v := m.secret_token
if v == nil {
return
}
return *v, true
}
// OldSecretToken returns the old "secret_token" field's value of the GitBot entity.
// If the GitBot 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 *GitBotMutation) OldSecretToken(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSecretToken is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSecretToken requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSecretToken: %w", err)
}
return oldValue.SecretToken, nil
}
// ClearSecretToken clears the value of the "secret_token" field.
func (m *GitBotMutation) ClearSecretToken() {
m.secret_token = nil
m.clearedFields[gitbot.FieldSecretToken] = struct{}{}
}
// SecretTokenCleared returns if the "secret_token" field was cleared in this mutation.
func (m *GitBotMutation) SecretTokenCleared() bool {
_, ok := m.clearedFields[gitbot.FieldSecretToken]
return ok
}
// ResetSecretToken resets all changes to the "secret_token" field.
func (m *GitBotMutation) ResetSecretToken() {
m.secret_token = nil
delete(m.clearedFields, gitbot.FieldSecretToken)
}
// SetPlatform sets the "platform" field.
func (m *GitBotMutation) SetPlatform(cp consts.GitPlatform) {
m.platform = &cp
}
// Platform returns the value of the "platform" field in the mutation.
func (m *GitBotMutation) Platform() (r consts.GitPlatform, exists bool) {
v := m.platform
if v == nil {
return
}
return *v, true
}
// OldPlatform returns the old "platform" field's value of the GitBot entity.
// If the GitBot 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 *GitBotMutation) OldPlatform(ctx context.Context) (v consts.GitPlatform, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPlatform is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPlatform requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPlatform: %w", err)
}
return oldValue.Platform, nil
}
// ResetPlatform resets all changes to the "platform" field.
func (m *GitBotMutation) ResetPlatform() {
m.platform = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *GitBotMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *GitBotMutation) 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 GitBot entity.
// If the GitBot 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 *GitBotMutation) 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 *GitBotMutation) ResetCreatedAt() {
m.created_at = nil
}
// AddGitBotTaskIDs adds the "git_bot_tasks" edge to the GitBotTask entity by ids.
func (m *GitBotMutation) AddGitBotTaskIDs(ids ...uuid.UUID) {
if m.git_bot_tasks == nil {
m.git_bot_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.git_bot_tasks[ids[i]] = struct{}{}
}
}
// ClearGitBotTasks clears the "git_bot_tasks" edge to the GitBotTask entity.
func (m *GitBotMutation) ClearGitBotTasks() {
m.clearedgit_bot_tasks = true
}
// GitBotTasksCleared reports if the "git_bot_tasks" edge to the GitBotTask entity was cleared.
func (m *GitBotMutation) GitBotTasksCleared() bool {
return m.clearedgit_bot_tasks
}
// RemoveGitBotTaskIDs removes the "git_bot_tasks" edge to the GitBotTask entity by IDs.
func (m *GitBotMutation) RemoveGitBotTaskIDs(ids ...uuid.UUID) {
if m.removedgit_bot_tasks == nil {
m.removedgit_bot_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.git_bot_tasks, ids[i])
m.removedgit_bot_tasks[ids[i]] = struct{}{}
}
}
// RemovedGitBotTasks returns the removed IDs of the "git_bot_tasks" edge to the GitBotTask entity.
func (m *GitBotMutation) RemovedGitBotTasksIDs() (ids []uuid.UUID) {
for id := range m.removedgit_bot_tasks {
ids = append(ids, id)
}
return
}
// GitBotTasksIDs returns the "git_bot_tasks" edge IDs in the mutation.
func (m *GitBotMutation) GitBotTasksIDs() (ids []uuid.UUID) {
for id := range m.git_bot_tasks {
ids = append(ids, id)
}
return
}
// ResetGitBotTasks resets all changes to the "git_bot_tasks" edge.
func (m *GitBotMutation) ResetGitBotTasks() {
m.git_bot_tasks = nil
m.clearedgit_bot_tasks = false
m.removedgit_bot_tasks = nil
}
// ClearHost clears the "host" edge to the Host entity.
func (m *GitBotMutation) ClearHost() {
m.clearedhost = true
m.clearedFields[gitbot.FieldHostID] = struct{}{}
}
// HostCleared reports if the "host" edge to the Host entity was cleared.
func (m *GitBotMutation) HostCleared() bool {
return m.clearedhost
}
// HostIDs returns the "host" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// HostID instead. It exists only for internal usage by the builders.
func (m *GitBotMutation) HostIDs() (ids []string) {
if id := m.host; id != nil {
ids = append(ids, *id)
}
return
}
// ResetHost resets all changes to the "host" edge.
func (m *GitBotMutation) ResetHost() {
m.host = nil
m.clearedhost = false
}
// AddUserIDs adds the "users" edge to the User entity by ids.
func (m *GitBotMutation) AddUserIDs(ids ...uuid.UUID) {
if m.users == nil {
m.users = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.users[ids[i]] = struct{}{}
}
}
// ClearUsers clears the "users" edge to the User entity.
func (m *GitBotMutation) ClearUsers() {
m.clearedusers = true
}
// UsersCleared reports if the "users" edge to the User entity was cleared.
func (m *GitBotMutation) UsersCleared() bool {
return m.clearedusers
}
// RemoveUserIDs removes the "users" edge to the User entity by IDs.
func (m *GitBotMutation) RemoveUserIDs(ids ...uuid.UUID) {
if m.removedusers == nil {
m.removedusers = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.users, ids[i])
m.removedusers[ids[i]] = struct{}{}
}
}
// RemovedUsers returns the removed IDs of the "users" edge to the User entity.
func (m *GitBotMutation) RemovedUsersIDs() (ids []uuid.UUID) {
for id := range m.removedusers {
ids = append(ids, id)
}
return
}
// UsersIDs returns the "users" edge IDs in the mutation.
func (m *GitBotMutation) UsersIDs() (ids []uuid.UUID) {
for id := range m.users {
ids = append(ids, id)
}
return
}
// ResetUsers resets all changes to the "users" edge.
func (m *GitBotMutation) ResetUsers() {
m.users = nil
m.clearedusers = false
m.removedusers = nil
}
// AddProjectIDs adds the "projects" edge to the Project entity by ids.
func (m *GitBotMutation) AddProjectIDs(ids ...uuid.UUID) {
if m.projects == nil {
m.projects = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.projects[ids[i]] = struct{}{}
}
}
// ClearProjects clears the "projects" edge to the Project entity.
func (m *GitBotMutation) ClearProjects() {
m.clearedprojects = true
}
// ProjectsCleared reports if the "projects" edge to the Project entity was cleared.
func (m *GitBotMutation) ProjectsCleared() bool {
return m.clearedprojects
}
// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs.
func (m *GitBotMutation) RemoveProjectIDs(ids ...uuid.UUID) {
if m.removedprojects == nil {
m.removedprojects = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.projects, ids[i])
m.removedprojects[ids[i]] = struct{}{}
}
}
// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity.
func (m *GitBotMutation) RemovedProjectsIDs() (ids []uuid.UUID) {
for id := range m.removedprojects {
ids = append(ids, id)
}
return
}
// ProjectsIDs returns the "projects" edge IDs in the mutation.
func (m *GitBotMutation) ProjectsIDs() (ids []uuid.UUID) {
for id := range m.projects {
ids = append(ids, id)
}
return
}
// ResetProjects resets all changes to the "projects" edge.
func (m *GitBotMutation) ResetProjects() {
m.projects = nil
m.clearedprojects = false
m.removedprojects = nil
}
// AddGitBotUserIDs adds the "git_bot_users" edge to the GitBotUser entity by ids.
func (m *GitBotMutation) AddGitBotUserIDs(ids ...uuid.UUID) {
if m.git_bot_users == nil {
m.git_bot_users = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.git_bot_users[ids[i]] = struct{}{}
}
}
// ClearGitBotUsers clears the "git_bot_users" edge to the GitBotUser entity.
func (m *GitBotMutation) ClearGitBotUsers() {
m.clearedgit_bot_users = true
}
// GitBotUsersCleared reports if the "git_bot_users" edge to the GitBotUser entity was cleared.
func (m *GitBotMutation) GitBotUsersCleared() bool {
return m.clearedgit_bot_users
}
// RemoveGitBotUserIDs removes the "git_bot_users" edge to the GitBotUser entity by IDs.
func (m *GitBotMutation) RemoveGitBotUserIDs(ids ...uuid.UUID) {
if m.removedgit_bot_users == nil {
m.removedgit_bot_users = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.git_bot_users, ids[i])
m.removedgit_bot_users[ids[i]] = struct{}{}
}
}
// RemovedGitBotUsers returns the removed IDs of the "git_bot_users" edge to the GitBotUser entity.
func (m *GitBotMutation) RemovedGitBotUsersIDs() (ids []uuid.UUID) {
for id := range m.removedgit_bot_users {
ids = append(ids, id)
}
return
}
// GitBotUsersIDs returns the "git_bot_users" edge IDs in the mutation.
func (m *GitBotMutation) GitBotUsersIDs() (ids []uuid.UUID) {
for id := range m.git_bot_users {
ids = append(ids, id)
}
return
}
// ResetGitBotUsers resets all changes to the "git_bot_users" edge.
func (m *GitBotMutation) ResetGitBotUsers() {
m.git_bot_users = nil
m.clearedgit_bot_users = false
m.removedgit_bot_users = nil
}
// AddProjectGitBotIDs adds the "project_git_bots" edge to the ProjectGitBot entity by ids.
func (m *GitBotMutation) AddProjectGitBotIDs(ids ...uuid.UUID) {
if m.project_git_bots == nil {
m.project_git_bots = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.project_git_bots[ids[i]] = struct{}{}
}
}
// ClearProjectGitBots clears the "project_git_bots" edge to the ProjectGitBot entity.
func (m *GitBotMutation) ClearProjectGitBots() {
m.clearedproject_git_bots = true
}
// ProjectGitBotsCleared reports if the "project_git_bots" edge to the ProjectGitBot entity was cleared.
func (m *GitBotMutation) ProjectGitBotsCleared() bool {
return m.clearedproject_git_bots
}
// RemoveProjectGitBotIDs removes the "project_git_bots" edge to the ProjectGitBot entity by IDs.
func (m *GitBotMutation) RemoveProjectGitBotIDs(ids ...uuid.UUID) {
if m.removedproject_git_bots == nil {
m.removedproject_git_bots = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.project_git_bots, ids[i])
m.removedproject_git_bots[ids[i]] = struct{}{}
}
}
// RemovedProjectGitBots returns the removed IDs of the "project_git_bots" edge to the ProjectGitBot entity.
func (m *GitBotMutation) RemovedProjectGitBotsIDs() (ids []uuid.UUID) {
for id := range m.removedproject_git_bots {
ids = append(ids, id)
}
return
}
// ProjectGitBotsIDs returns the "project_git_bots" edge IDs in the mutation.
func (m *GitBotMutation) ProjectGitBotsIDs() (ids []uuid.UUID) {
for id := range m.project_git_bots {
ids = append(ids, id)
}
return
}
// ResetProjectGitBots resets all changes to the "project_git_bots" edge.
func (m *GitBotMutation) ResetProjectGitBots() {
m.project_git_bots = nil
m.clearedproject_git_bots = false
m.removedproject_git_bots = nil
}
// Where appends a list predicates to the GitBotMutation builder.
func (m *GitBotMutation) Where(ps ...predicate.GitBot) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the GitBotMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *GitBotMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.GitBot, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *GitBotMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *GitBotMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (GitBot).
func (m *GitBotMutation) 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 *GitBotMutation) Fields() []string {
fields := make([]string, 0, 8)
if m.deleted_at != nil {
fields = append(fields, gitbot.FieldDeletedAt)
}
if m.user_id != nil {
fields = append(fields, gitbot.FieldUserID)
}
if m.name != nil {
fields = append(fields, gitbot.FieldName)
}
if m.host != nil {
fields = append(fields, gitbot.FieldHostID)
}
if m.token != nil {
fields = append(fields, gitbot.FieldToken)
}
if m.secret_token != nil {
fields = append(fields, gitbot.FieldSecretToken)
}
if m.platform != nil {
fields = append(fields, gitbot.FieldPlatform)
}
if m.created_at != nil {
fields = append(fields, gitbot.FieldCreatedAt)
}
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 *GitBotMutation) Field(name string) (ent.Value, bool) {
switch name {
case gitbot.FieldDeletedAt:
return m.DeletedAt()
case gitbot.FieldUserID:
return m.UserID()
case gitbot.FieldName:
return m.Name()
case gitbot.FieldHostID:
return m.HostID()
case gitbot.FieldToken:
return m.Token()
case gitbot.FieldSecretToken:
return m.SecretToken()
case gitbot.FieldPlatform:
return m.Platform()
case gitbot.FieldCreatedAt:
return m.CreatedAt()
}
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 *GitBotMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case gitbot.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case gitbot.FieldUserID:
return m.OldUserID(ctx)
case gitbot.FieldName:
return m.OldName(ctx)
case gitbot.FieldHostID:
return m.OldHostID(ctx)
case gitbot.FieldToken:
return m.OldToken(ctx)
case gitbot.FieldSecretToken:
return m.OldSecretToken(ctx)
case gitbot.FieldPlatform:
return m.OldPlatform(ctx)
case gitbot.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown GitBot 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 *GitBotMutation) SetField(name string, value ent.Value) error {
switch name {
case gitbot.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 gitbot.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case gitbot.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case gitbot.FieldHostID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHostID(v)
return nil
case gitbot.FieldToken:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetToken(v)
return nil
case gitbot.FieldSecretToken:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSecretToken(v)
return nil
case gitbot.FieldPlatform:
v, ok := value.(consts.GitPlatform)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPlatform(v)
return nil
case gitbot.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown GitBot field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *GitBotMutation) AddedFields() []string {
return nil
}
// 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 *GitBotMutation) AddedField(name string) (ent.Value, bool) {
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 *GitBotMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown GitBot numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *GitBotMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(gitbot.FieldDeletedAt) {
fields = append(fields, gitbot.FieldDeletedAt)
}
if m.FieldCleared(gitbot.FieldName) {
fields = append(fields, gitbot.FieldName)
}
if m.FieldCleared(gitbot.FieldToken) {
fields = append(fields, gitbot.FieldToken)
}
if m.FieldCleared(gitbot.FieldSecretToken) {
fields = append(fields, gitbot.FieldSecretToken)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *GitBotMutation) 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 *GitBotMutation) ClearField(name string) error {
switch name {
case gitbot.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case gitbot.FieldName:
m.ClearName()
return nil
case gitbot.FieldToken:
m.ClearToken()
return nil
case gitbot.FieldSecretToken:
m.ClearSecretToken()
return nil
}
return fmt.Errorf("unknown GitBot 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 *GitBotMutation) ResetField(name string) error {
switch name {
case gitbot.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case gitbot.FieldUserID:
m.ResetUserID()
return nil
case gitbot.FieldName:
m.ResetName()
return nil
case gitbot.FieldHostID:
m.ResetHostID()
return nil
case gitbot.FieldToken:
m.ResetToken()
return nil
case gitbot.FieldSecretToken:
m.ResetSecretToken()
return nil
case gitbot.FieldPlatform:
m.ResetPlatform()
return nil
case gitbot.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown GitBot field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *GitBotMutation) AddedEdges() []string {
edges := make([]string, 0, 6)
if m.git_bot_tasks != nil {
edges = append(edges, gitbot.EdgeGitBotTasks)
}
if m.host != nil {
edges = append(edges, gitbot.EdgeHost)
}
if m.users != nil {
edges = append(edges, gitbot.EdgeUsers)
}
if m.projects != nil {
edges = append(edges, gitbot.EdgeProjects)
}
if m.git_bot_users != nil {
edges = append(edges, gitbot.EdgeGitBotUsers)
}
if m.project_git_bots != nil {
edges = append(edges, gitbot.EdgeProjectGitBots)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *GitBotMutation) AddedIDs(name string) []ent.Value {
switch name {
case gitbot.EdgeGitBotTasks:
ids := make([]ent.Value, 0, len(m.git_bot_tasks))
for id := range m.git_bot_tasks {
ids = append(ids, id)
}
return ids
case gitbot.EdgeHost:
if id := m.host; id != nil {
return []ent.Value{*id}
}
case gitbot.EdgeUsers:
ids := make([]ent.Value, 0, len(m.users))
for id := range m.users {
ids = append(ids, id)
}
return ids
case gitbot.EdgeProjects:
ids := make([]ent.Value, 0, len(m.projects))
for id := range m.projects {
ids = append(ids, id)
}
return ids
case gitbot.EdgeGitBotUsers:
ids := make([]ent.Value, 0, len(m.git_bot_users))
for id := range m.git_bot_users {
ids = append(ids, id)
}
return ids
case gitbot.EdgeProjectGitBots:
ids := make([]ent.Value, 0, len(m.project_git_bots))
for id := range m.project_git_bots {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *GitBotMutation) RemovedEdges() []string {
edges := make([]string, 0, 6)
if m.removedgit_bot_tasks != nil {
edges = append(edges, gitbot.EdgeGitBotTasks)
}
if m.removedusers != nil {
edges = append(edges, gitbot.EdgeUsers)
}
if m.removedprojects != nil {
edges = append(edges, gitbot.EdgeProjects)
}
if m.removedgit_bot_users != nil {
edges = append(edges, gitbot.EdgeGitBotUsers)
}
if m.removedproject_git_bots != nil {
edges = append(edges, gitbot.EdgeProjectGitBots)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *GitBotMutation) RemovedIDs(name string) []ent.Value {
switch name {
case gitbot.EdgeGitBotTasks:
ids := make([]ent.Value, 0, len(m.removedgit_bot_tasks))
for id := range m.removedgit_bot_tasks {
ids = append(ids, id)
}
return ids
case gitbot.EdgeUsers:
ids := make([]ent.Value, 0, len(m.removedusers))
for id := range m.removedusers {
ids = append(ids, id)
}
return ids
case gitbot.EdgeProjects:
ids := make([]ent.Value, 0, len(m.removedprojects))
for id := range m.removedprojects {
ids = append(ids, id)
}
return ids
case gitbot.EdgeGitBotUsers:
ids := make([]ent.Value, 0, len(m.removedgit_bot_users))
for id := range m.removedgit_bot_users {
ids = append(ids, id)
}
return ids
case gitbot.EdgeProjectGitBots:
ids := make([]ent.Value, 0, len(m.removedproject_git_bots))
for id := range m.removedproject_git_bots {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *GitBotMutation) ClearedEdges() []string {
edges := make([]string, 0, 6)
if m.clearedgit_bot_tasks {
edges = append(edges, gitbot.EdgeGitBotTasks)
}
if m.clearedhost {
edges = append(edges, gitbot.EdgeHost)
}
if m.clearedusers {
edges = append(edges, gitbot.EdgeUsers)
}
if m.clearedprojects {
edges = append(edges, gitbot.EdgeProjects)
}
if m.clearedgit_bot_users {
edges = append(edges, gitbot.EdgeGitBotUsers)
}
if m.clearedproject_git_bots {
edges = append(edges, gitbot.EdgeProjectGitBots)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *GitBotMutation) EdgeCleared(name string) bool {
switch name {
case gitbot.EdgeGitBotTasks:
return m.clearedgit_bot_tasks
case gitbot.EdgeHost:
return m.clearedhost
case gitbot.EdgeUsers:
return m.clearedusers
case gitbot.EdgeProjects:
return m.clearedprojects
case gitbot.EdgeGitBotUsers:
return m.clearedgit_bot_users
case gitbot.EdgeProjectGitBots:
return m.clearedproject_git_bots
}
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 *GitBotMutation) ClearEdge(name string) error {
switch name {
case gitbot.EdgeHost:
m.ClearHost()
return nil
}
return fmt.Errorf("unknown GitBot 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 *GitBotMutation) ResetEdge(name string) error {
switch name {
case gitbot.EdgeGitBotTasks:
m.ResetGitBotTasks()
return nil
case gitbot.EdgeHost:
m.ResetHost()
return nil
case gitbot.EdgeUsers:
m.ResetUsers()
return nil
case gitbot.EdgeProjects:
m.ResetProjects()
return nil
case gitbot.EdgeGitBotUsers:
m.ResetGitBotUsers()
return nil
case gitbot.EdgeProjectGitBots:
m.ResetProjectGitBots()
return nil
}
return fmt.Errorf("unknown GitBot edge %s", name)
}
// GitBotTaskMutation represents an operation that mutates the GitBotTask nodes in the graph.
type GitBotTaskMutation struct {
config
op Op
typ string
id *uuid.UUID
created_at *time.Time
clearedFields map[string]struct{}
task *uuid.UUID
clearedtask bool
git_bot *uuid.UUID
clearedgit_bot bool
done bool
oldValue func(context.Context) (*GitBotTask, error)
predicates []predicate.GitBotTask
}
var _ ent.Mutation = (*GitBotTaskMutation)(nil)
// gitbottaskOption allows management of the mutation configuration using functional options.
type gitbottaskOption func(*GitBotTaskMutation)
// newGitBotTaskMutation creates new mutation for the GitBotTask entity.
func newGitBotTaskMutation(c config, op Op, opts ...gitbottaskOption) *GitBotTaskMutation {
m := &GitBotTaskMutation{
config: c,
op: op,
typ: TypeGitBotTask,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withGitBotTaskID sets the ID field of the mutation.
func withGitBotTaskID(id uuid.UUID) gitbottaskOption {
return func(m *GitBotTaskMutation) {
var (
err error
once sync.Once
value *GitBotTask
)
m.oldValue = func(ctx context.Context) (*GitBotTask, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().GitBotTask.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withGitBotTask sets the old GitBotTask of the mutation.
func withGitBotTask(node *GitBotTask) gitbottaskOption {
return func(m *GitBotTaskMutation) {
m.oldValue = func(context.Context) (*GitBotTask, 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 GitBotTaskMutation) 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 GitBotTaskMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 GitBotTask entities.
func (m *GitBotTaskMutation) SetID(id uuid.UUID) {
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 *GitBotTaskMutation) ID() (id uuid.UUID, 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 *GitBotTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().GitBotTask.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetGitBotID sets the "git_bot_id" field.
func (m *GitBotTaskMutation) SetGitBotID(u uuid.UUID) {
m.git_bot = &u
}
// GitBotID returns the value of the "git_bot_id" field in the mutation.
func (m *GitBotTaskMutation) GitBotID() (r uuid.UUID, exists bool) {
v := m.git_bot
if v == nil {
return
}
return *v, true
}
// OldGitBotID returns the old "git_bot_id" field's value of the GitBotTask entity.
// If the GitBotTask 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 *GitBotTaskMutation) OldGitBotID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGitBotID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGitBotID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGitBotID: %w", err)
}
return oldValue.GitBotID, nil
}
// ResetGitBotID resets all changes to the "git_bot_id" field.
func (m *GitBotTaskMutation) ResetGitBotID() {
m.git_bot = nil
}
// SetTaskID sets the "task_id" field.
func (m *GitBotTaskMutation) SetTaskID(u uuid.UUID) {
m.task = &u
}
// TaskID returns the value of the "task_id" field in the mutation.
func (m *GitBotTaskMutation) TaskID() (r uuid.UUID, exists bool) {
v := m.task
if v == nil {
return
}
return *v, true
}
// OldTaskID returns the old "task_id" field's value of the GitBotTask entity.
// If the GitBotTask 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 *GitBotTaskMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTaskID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
}
return oldValue.TaskID, nil
}
// ResetTaskID resets all changes to the "task_id" field.
func (m *GitBotTaskMutation) ResetTaskID() {
m.task = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *GitBotTaskMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *GitBotTaskMutation) 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 GitBotTask entity.
// If the GitBotTask 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 *GitBotTaskMutation) 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 *GitBotTaskMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearTask clears the "task" edge to the Task entity.
func (m *GitBotTaskMutation) ClearTask() {
m.clearedtask = true
m.clearedFields[gitbottask.FieldTaskID] = struct{}{}
}
// TaskCleared reports if the "task" edge to the Task entity was cleared.
func (m *GitBotTaskMutation) TaskCleared() bool {
return m.clearedtask
}
// TaskIDs returns the "task" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// TaskID instead. It exists only for internal usage by the builders.
func (m *GitBotTaskMutation) TaskIDs() (ids []uuid.UUID) {
if id := m.task; id != nil {
ids = append(ids, *id)
}
return
}
// ResetTask resets all changes to the "task" edge.
func (m *GitBotTaskMutation) ResetTask() {
m.task = nil
m.clearedtask = false
}
// ClearGitBot clears the "git_bot" edge to the GitBot entity.
func (m *GitBotTaskMutation) ClearGitBot() {
m.clearedgit_bot = true
m.clearedFields[gitbottask.FieldGitBotID] = struct{}{}
}
// GitBotCleared reports if the "git_bot" edge to the GitBot entity was cleared.
func (m *GitBotTaskMutation) GitBotCleared() bool {
return m.clearedgit_bot
}
// GitBotIDs returns the "git_bot" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// GitBotID instead. It exists only for internal usage by the builders.
func (m *GitBotTaskMutation) GitBotIDs() (ids []uuid.UUID) {
if id := m.git_bot; id != nil {
ids = append(ids, *id)
}
return
}
// ResetGitBot resets all changes to the "git_bot" edge.
func (m *GitBotTaskMutation) ResetGitBot() {
m.git_bot = nil
m.clearedgit_bot = false
}
// Where appends a list predicates to the GitBotTaskMutation builder.
func (m *GitBotTaskMutation) Where(ps ...predicate.GitBotTask) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the GitBotTaskMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *GitBotTaskMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.GitBotTask, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *GitBotTaskMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *GitBotTaskMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (GitBotTask).
func (m *GitBotTaskMutation) 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 *GitBotTaskMutation) Fields() []string {
fields := make([]string, 0, 3)
if m.git_bot != nil {
fields = append(fields, gitbottask.FieldGitBotID)
}
if m.task != nil {
fields = append(fields, gitbottask.FieldTaskID)
}
if m.created_at != nil {
fields = append(fields, gitbottask.FieldCreatedAt)
}
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 *GitBotTaskMutation) Field(name string) (ent.Value, bool) {
switch name {
case gitbottask.FieldGitBotID:
return m.GitBotID()
case gitbottask.FieldTaskID:
return m.TaskID()
case gitbottask.FieldCreatedAt:
return m.CreatedAt()
}
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 *GitBotTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case gitbottask.FieldGitBotID:
return m.OldGitBotID(ctx)
case gitbottask.FieldTaskID:
return m.OldTaskID(ctx)
case gitbottask.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown GitBotTask 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 *GitBotTaskMutation) SetField(name string, value ent.Value) error {
switch name {
case gitbottask.FieldGitBotID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGitBotID(v)
return nil
case gitbottask.FieldTaskID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTaskID(v)
return nil
case gitbottask.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown GitBotTask field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *GitBotTaskMutation) AddedFields() []string {
return nil
}
// 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 *GitBotTaskMutation) AddedField(name string) (ent.Value, bool) {
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 *GitBotTaskMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown GitBotTask numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *GitBotTaskMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *GitBotTaskMutation) 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 *GitBotTaskMutation) ClearField(name string) error {
return fmt.Errorf("unknown GitBotTask 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 *GitBotTaskMutation) ResetField(name string) error {
switch name {
case gitbottask.FieldGitBotID:
m.ResetGitBotID()
return nil
case gitbottask.FieldTaskID:
m.ResetTaskID()
return nil
case gitbottask.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown GitBotTask field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *GitBotTaskMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.task != nil {
edges = append(edges, gitbottask.EdgeTask)
}
if m.git_bot != nil {
edges = append(edges, gitbottask.EdgeGitBot)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *GitBotTaskMutation) AddedIDs(name string) []ent.Value {
switch name {
case gitbottask.EdgeTask:
if id := m.task; id != nil {
return []ent.Value{*id}
}
case gitbottask.EdgeGitBot:
if id := m.git_bot; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *GitBotTaskMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *GitBotTaskMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *GitBotTaskMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedtask {
edges = append(edges, gitbottask.EdgeTask)
}
if m.clearedgit_bot {
edges = append(edges, gitbottask.EdgeGitBot)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *GitBotTaskMutation) EdgeCleared(name string) bool {
switch name {
case gitbottask.EdgeTask:
return m.clearedtask
case gitbottask.EdgeGitBot:
return m.clearedgit_bot
}
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 *GitBotTaskMutation) ClearEdge(name string) error {
switch name {
case gitbottask.EdgeTask:
m.ClearTask()
return nil
case gitbottask.EdgeGitBot:
m.ClearGitBot()
return nil
}
return fmt.Errorf("unknown GitBotTask 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 *GitBotTaskMutation) ResetEdge(name string) error {
switch name {
case gitbottask.EdgeTask:
m.ResetTask()
return nil
case gitbottask.EdgeGitBot:
m.ResetGitBot()
return nil
}
return fmt.Errorf("unknown GitBotTask edge %s", name)
}
// GitBotUserMutation represents an operation that mutates the GitBotUser nodes in the graph.
type GitBotUserMutation struct {
config
op Op
typ string
id *uuid.UUID
created_at *time.Time
clearedFields map[string]struct{}
git_bot *uuid.UUID
clearedgit_bot bool
user *uuid.UUID
cleareduser bool
done bool
oldValue func(context.Context) (*GitBotUser, error)
predicates []predicate.GitBotUser
}
var _ ent.Mutation = (*GitBotUserMutation)(nil)
// gitbotuserOption allows management of the mutation configuration using functional options.
type gitbotuserOption func(*GitBotUserMutation)
// newGitBotUserMutation creates new mutation for the GitBotUser entity.
func newGitBotUserMutation(c config, op Op, opts ...gitbotuserOption) *GitBotUserMutation {
m := &GitBotUserMutation{
config: c,
op: op,
typ: TypeGitBotUser,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withGitBotUserID sets the ID field of the mutation.
func withGitBotUserID(id uuid.UUID) gitbotuserOption {
return func(m *GitBotUserMutation) {
var (
err error
once sync.Once
value *GitBotUser
)
m.oldValue = func(ctx context.Context) (*GitBotUser, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().GitBotUser.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withGitBotUser sets the old GitBotUser of the mutation.
func withGitBotUser(node *GitBotUser) gitbotuserOption {
return func(m *GitBotUserMutation) {
m.oldValue = func(context.Context) (*GitBotUser, 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 GitBotUserMutation) 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 GitBotUserMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 GitBotUser entities.
func (m *GitBotUserMutation) SetID(id uuid.UUID) {
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 *GitBotUserMutation) ID() (id uuid.UUID, 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 *GitBotUserMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().GitBotUser.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetGitBotID sets the "git_bot_id" field.
func (m *GitBotUserMutation) SetGitBotID(u uuid.UUID) {
m.git_bot = &u
}
// GitBotID returns the value of the "git_bot_id" field in the mutation.
func (m *GitBotUserMutation) GitBotID() (r uuid.UUID, exists bool) {
v := m.git_bot
if v == nil {
return
}
return *v, true
}
// OldGitBotID returns the old "git_bot_id" field's value of the GitBotUser entity.
// If the GitBotUser 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 *GitBotUserMutation) OldGitBotID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGitBotID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGitBotID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGitBotID: %w", err)
}
return oldValue.GitBotID, nil
}
// ResetGitBotID resets all changes to the "git_bot_id" field.
func (m *GitBotUserMutation) ResetGitBotID() {
m.git_bot = nil
}
// SetUserID sets the "user_id" field.
func (m *GitBotUserMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *GitBotUserMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the GitBotUser entity.
// If the GitBotUser 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 *GitBotUserMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *GitBotUserMutation) ResetUserID() {
m.user = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *GitBotUserMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *GitBotUserMutation) 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 GitBotUser entity.
// If the GitBotUser 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 *GitBotUserMutation) 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 *GitBotUserMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearGitBot clears the "git_bot" edge to the GitBot entity.
func (m *GitBotUserMutation) ClearGitBot() {
m.clearedgit_bot = true
m.clearedFields[gitbotuser.FieldGitBotID] = struct{}{}
}
// GitBotCleared reports if the "git_bot" edge to the GitBot entity was cleared.
func (m *GitBotUserMutation) GitBotCleared() bool {
return m.clearedgit_bot
}
// GitBotIDs returns the "git_bot" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// GitBotID instead. It exists only for internal usage by the builders.
func (m *GitBotUserMutation) GitBotIDs() (ids []uuid.UUID) {
if id := m.git_bot; id != nil {
ids = append(ids, *id)
}
return
}
// ResetGitBot resets all changes to the "git_bot" edge.
func (m *GitBotUserMutation) ResetGitBot() {
m.git_bot = nil
m.clearedgit_bot = false
}
// ClearUser clears the "user" edge to the User entity.
func (m *GitBotUserMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[gitbotuser.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *GitBotUserMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *GitBotUserMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *GitBotUserMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// Where appends a list predicates to the GitBotUserMutation builder.
func (m *GitBotUserMutation) Where(ps ...predicate.GitBotUser) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the GitBotUserMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *GitBotUserMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.GitBotUser, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *GitBotUserMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *GitBotUserMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (GitBotUser).
func (m *GitBotUserMutation) 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 *GitBotUserMutation) Fields() []string {
fields := make([]string, 0, 3)
if m.git_bot != nil {
fields = append(fields, gitbotuser.FieldGitBotID)
}
if m.user != nil {
fields = append(fields, gitbotuser.FieldUserID)
}
if m.created_at != nil {
fields = append(fields, gitbotuser.FieldCreatedAt)
}
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 *GitBotUserMutation) Field(name string) (ent.Value, bool) {
switch name {
case gitbotuser.FieldGitBotID:
return m.GitBotID()
case gitbotuser.FieldUserID:
return m.UserID()
case gitbotuser.FieldCreatedAt:
return m.CreatedAt()
}
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 *GitBotUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case gitbotuser.FieldGitBotID:
return m.OldGitBotID(ctx)
case gitbotuser.FieldUserID:
return m.OldUserID(ctx)
case gitbotuser.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown GitBotUser 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 *GitBotUserMutation) SetField(name string, value ent.Value) error {
switch name {
case gitbotuser.FieldGitBotID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGitBotID(v)
return nil
case gitbotuser.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case gitbotuser.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown GitBotUser field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *GitBotUserMutation) AddedFields() []string {
return nil
}
// 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 *GitBotUserMutation) AddedField(name string) (ent.Value, bool) {
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 *GitBotUserMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown GitBotUser numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *GitBotUserMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *GitBotUserMutation) 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 *GitBotUserMutation) ClearField(name string) error {
return fmt.Errorf("unknown GitBotUser 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 *GitBotUserMutation) ResetField(name string) error {
switch name {
case gitbotuser.FieldGitBotID:
m.ResetGitBotID()
return nil
case gitbotuser.FieldUserID:
m.ResetUserID()
return nil
case gitbotuser.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown GitBotUser field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *GitBotUserMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.git_bot != nil {
edges = append(edges, gitbotuser.EdgeGitBot)
}
if m.user != nil {
edges = append(edges, gitbotuser.EdgeUser)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *GitBotUserMutation) AddedIDs(name string) []ent.Value {
switch name {
case gitbotuser.EdgeGitBot:
if id := m.git_bot; id != nil {
return []ent.Value{*id}
}
case gitbotuser.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *GitBotUserMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *GitBotUserMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *GitBotUserMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedgit_bot {
edges = append(edges, gitbotuser.EdgeGitBot)
}
if m.cleareduser {
edges = append(edges, gitbotuser.EdgeUser)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *GitBotUserMutation) EdgeCleared(name string) bool {
switch name {
case gitbotuser.EdgeGitBot:
return m.clearedgit_bot
case gitbotuser.EdgeUser:
return m.cleareduser
}
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 *GitBotUserMutation) ClearEdge(name string) error {
switch name {
case gitbotuser.EdgeGitBot:
m.ClearGitBot()
return nil
case gitbotuser.EdgeUser:
m.ClearUser()
return nil
}
return fmt.Errorf("unknown GitBotUser 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 *GitBotUserMutation) ResetEdge(name string) error {
switch name {
case gitbotuser.EdgeGitBot:
m.ResetGitBot()
return nil
case gitbotuser.EdgeUser:
m.ResetUser()
return nil
}
return fmt.Errorf("unknown GitBotUser edge %s", name)
}
// GitIdentityMutation represents an operation that mutates the GitIdentity nodes in the graph.
type GitIdentityMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
platform *consts.GitPlatform
base_url *string
access_token *string
username *string
email *string
installation_id *int64
addinstallation_id *int64
remark *string
oauth_refresh_token *string
oauth_expires_at *time.Time
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
user *uuid.UUID
cleareduser bool
projects map[uuid.UUID]struct{}
removedprojects map[uuid.UUID]struct{}
clearedprojects bool
project_tasks map[uuid.UUID]struct{}
removedproject_tasks map[uuid.UUID]struct{}
clearedproject_tasks bool
vms map[string]struct{}
removedvms map[string]struct{}
clearedvms bool
done bool
oldValue func(context.Context) (*GitIdentity, error)
predicates []predicate.GitIdentity
}
var _ ent.Mutation = (*GitIdentityMutation)(nil)
// gitidentityOption allows management of the mutation configuration using functional options.
type gitidentityOption func(*GitIdentityMutation)
// newGitIdentityMutation creates new mutation for the GitIdentity entity.
func newGitIdentityMutation(c config, op Op, opts ...gitidentityOption) *GitIdentityMutation {
m := &GitIdentityMutation{
config: c,
op: op,
typ: TypeGitIdentity,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withGitIdentityID sets the ID field of the mutation.
func withGitIdentityID(id uuid.UUID) gitidentityOption {
return func(m *GitIdentityMutation) {
var (
err error
once sync.Once
value *GitIdentity
)
m.oldValue = func(ctx context.Context) (*GitIdentity, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().GitIdentity.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withGitIdentity sets the old GitIdentity of the mutation.
func withGitIdentity(node *GitIdentity) gitidentityOption {
return func(m *GitIdentityMutation) {
m.oldValue = func(context.Context) (*GitIdentity, 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 GitIdentityMutation) 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 GitIdentityMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 GitIdentity entities.
func (m *GitIdentityMutation) SetID(id uuid.UUID) {
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 *GitIdentityMutation) ID() (id uuid.UUID, 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 *GitIdentityMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().GitIdentity.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *GitIdentityMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *GitIdentityMutation) 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 GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) 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 *GitIdentityMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[gitidentity.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *GitIdentityMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[gitidentity.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *GitIdentityMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, gitidentity.FieldDeletedAt)
}
// SetUserID sets the "user_id" field.
func (m *GitIdentityMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *GitIdentityMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *GitIdentityMutation) ResetUserID() {
m.user = nil
}
// SetPlatform sets the "platform" field.
func (m *GitIdentityMutation) SetPlatform(cp consts.GitPlatform) {
m.platform = &cp
}
// Platform returns the value of the "platform" field in the mutation.
func (m *GitIdentityMutation) Platform() (r consts.GitPlatform, exists bool) {
v := m.platform
if v == nil {
return
}
return *v, true
}
// OldPlatform returns the old "platform" field's value of the GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) OldPlatform(ctx context.Context) (v consts.GitPlatform, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPlatform is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPlatform requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPlatform: %w", err)
}
return oldValue.Platform, nil
}
// ResetPlatform resets all changes to the "platform" field.
func (m *GitIdentityMutation) ResetPlatform() {
m.platform = nil
}
// SetBaseURL sets the "base_url" field.
func (m *GitIdentityMutation) SetBaseURL(s string) {
m.base_url = &s
}
// BaseURL returns the value of the "base_url" field in the mutation.
func (m *GitIdentityMutation) BaseURL() (r string, exists bool) {
v := m.base_url
if v == nil {
return
}
return *v, true
}
// OldBaseURL returns the old "base_url" field's value of the GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) OldBaseURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldBaseURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldBaseURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBaseURL: %w", err)
}
return oldValue.BaseURL, nil
}
// ClearBaseURL clears the value of the "base_url" field.
func (m *GitIdentityMutation) ClearBaseURL() {
m.base_url = nil
m.clearedFields[gitidentity.FieldBaseURL] = struct{}{}
}
// BaseURLCleared returns if the "base_url" field was cleared in this mutation.
func (m *GitIdentityMutation) BaseURLCleared() bool {
_, ok := m.clearedFields[gitidentity.FieldBaseURL]
return ok
}
// ResetBaseURL resets all changes to the "base_url" field.
func (m *GitIdentityMutation) ResetBaseURL() {
m.base_url = nil
delete(m.clearedFields, gitidentity.FieldBaseURL)
}
// SetAccessToken sets the "access_token" field.
func (m *GitIdentityMutation) SetAccessToken(s string) {
m.access_token = &s
}
// AccessToken returns the value of the "access_token" field in the mutation.
func (m *GitIdentityMutation) AccessToken() (r string, exists bool) {
v := m.access_token
if v == nil {
return
}
return *v, true
}
// OldAccessToken returns the old "access_token" field's value of the GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) OldAccessToken(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAccessToken is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAccessToken requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAccessToken: %w", err)
}
return oldValue.AccessToken, nil
}
// ClearAccessToken clears the value of the "access_token" field.
func (m *GitIdentityMutation) ClearAccessToken() {
m.access_token = nil
m.clearedFields[gitidentity.FieldAccessToken] = struct{}{}
}
// AccessTokenCleared returns if the "access_token" field was cleared in this mutation.
func (m *GitIdentityMutation) AccessTokenCleared() bool {
_, ok := m.clearedFields[gitidentity.FieldAccessToken]
return ok
}
// ResetAccessToken resets all changes to the "access_token" field.
func (m *GitIdentityMutation) ResetAccessToken() {
m.access_token = nil
delete(m.clearedFields, gitidentity.FieldAccessToken)
}
// SetUsername sets the "username" field.
func (m *GitIdentityMutation) SetUsername(s string) {
m.username = &s
}
// Username returns the value of the "username" field in the mutation.
func (m *GitIdentityMutation) Username() (r string, exists bool) {
v := m.username
if v == nil {
return
}
return *v, true
}
// OldUsername returns the old "username" field's value of the GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) OldUsername(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUsername is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUsername requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUsername: %w", err)
}
return oldValue.Username, nil
}
// ClearUsername clears the value of the "username" field.
func (m *GitIdentityMutation) ClearUsername() {
m.username = nil
m.clearedFields[gitidentity.FieldUsername] = struct{}{}
}
// UsernameCleared returns if the "username" field was cleared in this mutation.
func (m *GitIdentityMutation) UsernameCleared() bool {
_, ok := m.clearedFields[gitidentity.FieldUsername]
return ok
}
// ResetUsername resets all changes to the "username" field.
func (m *GitIdentityMutation) ResetUsername() {
m.username = nil
delete(m.clearedFields, gitidentity.FieldUsername)
}
// SetEmail sets the "email" field.
func (m *GitIdentityMutation) SetEmail(s string) {
m.email = &s
}
// Email returns the value of the "email" field in the mutation.
func (m *GitIdentityMutation) Email() (r string, exists bool) {
v := m.email
if v == nil {
return
}
return *v, true
}
// OldEmail returns the old "email" field's value of the GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) OldEmail(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEmail is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEmail requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEmail: %w", err)
}
return oldValue.Email, nil
}
// ClearEmail clears the value of the "email" field.
func (m *GitIdentityMutation) ClearEmail() {
m.email = nil
m.clearedFields[gitidentity.FieldEmail] = struct{}{}
}
// EmailCleared returns if the "email" field was cleared in this mutation.
func (m *GitIdentityMutation) EmailCleared() bool {
_, ok := m.clearedFields[gitidentity.FieldEmail]
return ok
}
// ResetEmail resets all changes to the "email" field.
func (m *GitIdentityMutation) ResetEmail() {
m.email = nil
delete(m.clearedFields, gitidentity.FieldEmail)
}
// SetInstallationID sets the "installation_id" field.
func (m *GitIdentityMutation) SetInstallationID(i int64) {
m.installation_id = &i
m.addinstallation_id = nil
}
// InstallationID returns the value of the "installation_id" field in the mutation.
func (m *GitIdentityMutation) InstallationID() (r int64, exists bool) {
v := m.installation_id
if v == nil {
return
}
return *v, true
}
// OldInstallationID returns the old "installation_id" field's value of the GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) OldInstallationID(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldInstallationID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldInstallationID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInstallationID: %w", err)
}
return oldValue.InstallationID, nil
}
// AddInstallationID adds i to the "installation_id" field.
func (m *GitIdentityMutation) AddInstallationID(i int64) {
if m.addinstallation_id != nil {
*m.addinstallation_id += i
} else {
m.addinstallation_id = &i
}
}
// AddedInstallationID returns the value that was added to the "installation_id" field in this mutation.
func (m *GitIdentityMutation) AddedInstallationID() (r int64, exists bool) {
v := m.addinstallation_id
if v == nil {
return
}
return *v, true
}
// ClearInstallationID clears the value of the "installation_id" field.
func (m *GitIdentityMutation) ClearInstallationID() {
m.installation_id = nil
m.addinstallation_id = nil
m.clearedFields[gitidentity.FieldInstallationID] = struct{}{}
}
// InstallationIDCleared returns if the "installation_id" field was cleared in this mutation.
func (m *GitIdentityMutation) InstallationIDCleared() bool {
_, ok := m.clearedFields[gitidentity.FieldInstallationID]
return ok
}
// ResetInstallationID resets all changes to the "installation_id" field.
func (m *GitIdentityMutation) ResetInstallationID() {
m.installation_id = nil
m.addinstallation_id = nil
delete(m.clearedFields, gitidentity.FieldInstallationID)
}
// SetRemark sets the "remark" field.
func (m *GitIdentityMutation) SetRemark(s string) {
m.remark = &s
}
// Remark returns the value of the "remark" field in the mutation.
func (m *GitIdentityMutation) Remark() (r string, exists bool) {
v := m.remark
if v == nil {
return
}
return *v, true
}
// OldRemark returns the old "remark" field's value of the GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) OldRemark(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRemark is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRemark requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRemark: %w", err)
}
return oldValue.Remark, nil
}
// ClearRemark clears the value of the "remark" field.
func (m *GitIdentityMutation) ClearRemark() {
m.remark = nil
m.clearedFields[gitidentity.FieldRemark] = struct{}{}
}
// RemarkCleared returns if the "remark" field was cleared in this mutation.
func (m *GitIdentityMutation) RemarkCleared() bool {
_, ok := m.clearedFields[gitidentity.FieldRemark]
return ok
}
// ResetRemark resets all changes to the "remark" field.
func (m *GitIdentityMutation) ResetRemark() {
m.remark = nil
delete(m.clearedFields, gitidentity.FieldRemark)
}
// SetOauthRefreshToken sets the "oauth_refresh_token" field.
func (m *GitIdentityMutation) SetOauthRefreshToken(s string) {
m.oauth_refresh_token = &s
}
// OauthRefreshToken returns the value of the "oauth_refresh_token" field in the mutation.
func (m *GitIdentityMutation) OauthRefreshToken() (r string, exists bool) {
v := m.oauth_refresh_token
if v == nil {
return
}
return *v, true
}
// OldOauthRefreshToken returns the old "oauth_refresh_token" field's value of the GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) OldOauthRefreshToken(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOauthRefreshToken is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOauthRefreshToken requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOauthRefreshToken: %w", err)
}
return oldValue.OauthRefreshToken, nil
}
// ClearOauthRefreshToken clears the value of the "oauth_refresh_token" field.
func (m *GitIdentityMutation) ClearOauthRefreshToken() {
m.oauth_refresh_token = nil
m.clearedFields[gitidentity.FieldOauthRefreshToken] = struct{}{}
}
// OauthRefreshTokenCleared returns if the "oauth_refresh_token" field was cleared in this mutation.
func (m *GitIdentityMutation) OauthRefreshTokenCleared() bool {
_, ok := m.clearedFields[gitidentity.FieldOauthRefreshToken]
return ok
}
// ResetOauthRefreshToken resets all changes to the "oauth_refresh_token" field.
func (m *GitIdentityMutation) ResetOauthRefreshToken() {
m.oauth_refresh_token = nil
delete(m.clearedFields, gitidentity.FieldOauthRefreshToken)
}
// SetOauthExpiresAt sets the "oauth_expires_at" field.
func (m *GitIdentityMutation) SetOauthExpiresAt(t time.Time) {
m.oauth_expires_at = &t
}
// OauthExpiresAt returns the value of the "oauth_expires_at" field in the mutation.
func (m *GitIdentityMutation) OauthExpiresAt() (r time.Time, exists bool) {
v := m.oauth_expires_at
if v == nil {
return
}
return *v, true
}
// OldOauthExpiresAt returns the old "oauth_expires_at" field's value of the GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) OldOauthExpiresAt(ctx context.Context) (v *time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOauthExpiresAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOauthExpiresAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOauthExpiresAt: %w", err)
}
return oldValue.OauthExpiresAt, nil
}
// ClearOauthExpiresAt clears the value of the "oauth_expires_at" field.
func (m *GitIdentityMutation) ClearOauthExpiresAt() {
m.oauth_expires_at = nil
m.clearedFields[gitidentity.FieldOauthExpiresAt] = struct{}{}
}
// OauthExpiresAtCleared returns if the "oauth_expires_at" field was cleared in this mutation.
func (m *GitIdentityMutation) OauthExpiresAtCleared() bool {
_, ok := m.clearedFields[gitidentity.FieldOauthExpiresAt]
return ok
}
// ResetOauthExpiresAt resets all changes to the "oauth_expires_at" field.
func (m *GitIdentityMutation) ResetOauthExpiresAt() {
m.oauth_expires_at = nil
delete(m.clearedFields, gitidentity.FieldOauthExpiresAt)
}
// SetCreatedAt sets the "created_at" field.
func (m *GitIdentityMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *GitIdentityMutation) 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 GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) 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 *GitIdentityMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *GitIdentityMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *GitIdentityMutation) 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 GitIdentity entity.
// If the GitIdentity 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 *GitIdentityMutation) 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 *GitIdentityMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearUser clears the "user" edge to the User entity.
func (m *GitIdentityMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[gitidentity.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *GitIdentityMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *GitIdentityMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *GitIdentityMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// AddProjectIDs adds the "projects" edge to the Project entity by ids.
func (m *GitIdentityMutation) AddProjectIDs(ids ...uuid.UUID) {
if m.projects == nil {
m.projects = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.projects[ids[i]] = struct{}{}
}
}
// ClearProjects clears the "projects" edge to the Project entity.
func (m *GitIdentityMutation) ClearProjects() {
m.clearedprojects = true
}
// ProjectsCleared reports if the "projects" edge to the Project entity was cleared.
func (m *GitIdentityMutation) ProjectsCleared() bool {
return m.clearedprojects
}
// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs.
func (m *GitIdentityMutation) RemoveProjectIDs(ids ...uuid.UUID) {
if m.removedprojects == nil {
m.removedprojects = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.projects, ids[i])
m.removedprojects[ids[i]] = struct{}{}
}
}
// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity.
func (m *GitIdentityMutation) RemovedProjectsIDs() (ids []uuid.UUID) {
for id := range m.removedprojects {
ids = append(ids, id)
}
return
}
// ProjectsIDs returns the "projects" edge IDs in the mutation.
func (m *GitIdentityMutation) ProjectsIDs() (ids []uuid.UUID) {
for id := range m.projects {
ids = append(ids, id)
}
return
}
// ResetProjects resets all changes to the "projects" edge.
func (m *GitIdentityMutation) ResetProjects() {
m.projects = nil
m.clearedprojects = false
m.removedprojects = nil
}
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids.
func (m *GitIdentityMutation) AddProjectTaskIDs(ids ...uuid.UUID) {
if m.project_tasks == nil {
m.project_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.project_tasks[ids[i]] = struct{}{}
}
}
// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity.
func (m *GitIdentityMutation) ClearProjectTasks() {
m.clearedproject_tasks = true
}
// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared.
func (m *GitIdentityMutation) ProjectTasksCleared() bool {
return m.clearedproject_tasks
}
// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs.
func (m *GitIdentityMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) {
if m.removedproject_tasks == nil {
m.removedproject_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.project_tasks, ids[i])
m.removedproject_tasks[ids[i]] = struct{}{}
}
}
// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity.
func (m *GitIdentityMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return
}
// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation.
func (m *GitIdentityMutation) ProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.project_tasks {
ids = append(ids, id)
}
return
}
// ResetProjectTasks resets all changes to the "project_tasks" edge.
func (m *GitIdentityMutation) ResetProjectTasks() {
m.project_tasks = nil
m.clearedproject_tasks = false
m.removedproject_tasks = nil
}
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by ids.
func (m *GitIdentityMutation) AddVMIDs(ids ...string) {
if m.vms == nil {
m.vms = make(map[string]struct{})
}
for i := range ids {
m.vms[ids[i]] = struct{}{}
}
}
// ClearVms clears the "vms" edge to the VirtualMachine entity.
func (m *GitIdentityMutation) ClearVms() {
m.clearedvms = true
}
// VmsCleared reports if the "vms" edge to the VirtualMachine entity was cleared.
func (m *GitIdentityMutation) VmsCleared() bool {
return m.clearedvms
}
// RemoveVMIDs removes the "vms" edge to the VirtualMachine entity by IDs.
func (m *GitIdentityMutation) RemoveVMIDs(ids ...string) {
if m.removedvms == nil {
m.removedvms = make(map[string]struct{})
}
for i := range ids {
delete(m.vms, ids[i])
m.removedvms[ids[i]] = struct{}{}
}
}
// RemovedVms returns the removed IDs of the "vms" edge to the VirtualMachine entity.
func (m *GitIdentityMutation) RemovedVmsIDs() (ids []string) {
for id := range m.removedvms {
ids = append(ids, id)
}
return
}
// VmsIDs returns the "vms" edge IDs in the mutation.
func (m *GitIdentityMutation) VmsIDs() (ids []string) {
for id := range m.vms {
ids = append(ids, id)
}
return
}
// ResetVms resets all changes to the "vms" edge.
func (m *GitIdentityMutation) ResetVms() {
m.vms = nil
m.clearedvms = false
m.removedvms = nil
}
// Where appends a list predicates to the GitIdentityMutation builder.
func (m *GitIdentityMutation) Where(ps ...predicate.GitIdentity) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the GitIdentityMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *GitIdentityMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.GitIdentity, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *GitIdentityMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *GitIdentityMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (GitIdentity).
func (m *GitIdentityMutation) 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 *GitIdentityMutation) Fields() []string {
fields := make([]string, 0, 13)
if m.deleted_at != nil {
fields = append(fields, gitidentity.FieldDeletedAt)
}
if m.user != nil {
fields = append(fields, gitidentity.FieldUserID)
}
if m.platform != nil {
fields = append(fields, gitidentity.FieldPlatform)
}
if m.base_url != nil {
fields = append(fields, gitidentity.FieldBaseURL)
}
if m.access_token != nil {
fields = append(fields, gitidentity.FieldAccessToken)
}
if m.username != nil {
fields = append(fields, gitidentity.FieldUsername)
}
if m.email != nil {
fields = append(fields, gitidentity.FieldEmail)
}
if m.installation_id != nil {
fields = append(fields, gitidentity.FieldInstallationID)
}
if m.remark != nil {
fields = append(fields, gitidentity.FieldRemark)
}
if m.oauth_refresh_token != nil {
fields = append(fields, gitidentity.FieldOauthRefreshToken)
}
if m.oauth_expires_at != nil {
fields = append(fields, gitidentity.FieldOauthExpiresAt)
}
if m.created_at != nil {
fields = append(fields, gitidentity.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, gitidentity.FieldUpdatedAt)
}
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 *GitIdentityMutation) Field(name string) (ent.Value, bool) {
switch name {
case gitidentity.FieldDeletedAt:
return m.DeletedAt()
case gitidentity.FieldUserID:
return m.UserID()
case gitidentity.FieldPlatform:
return m.Platform()
case gitidentity.FieldBaseURL:
return m.BaseURL()
case gitidentity.FieldAccessToken:
return m.AccessToken()
case gitidentity.FieldUsername:
return m.Username()
case gitidentity.FieldEmail:
return m.Email()
case gitidentity.FieldInstallationID:
return m.InstallationID()
case gitidentity.FieldRemark:
return m.Remark()
case gitidentity.FieldOauthRefreshToken:
return m.OauthRefreshToken()
case gitidentity.FieldOauthExpiresAt:
return m.OauthExpiresAt()
case gitidentity.FieldCreatedAt:
return m.CreatedAt()
case gitidentity.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *GitIdentityMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case gitidentity.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case gitidentity.FieldUserID:
return m.OldUserID(ctx)
case gitidentity.FieldPlatform:
return m.OldPlatform(ctx)
case gitidentity.FieldBaseURL:
return m.OldBaseURL(ctx)
case gitidentity.FieldAccessToken:
return m.OldAccessToken(ctx)
case gitidentity.FieldUsername:
return m.OldUsername(ctx)
case gitidentity.FieldEmail:
return m.OldEmail(ctx)
case gitidentity.FieldInstallationID:
return m.OldInstallationID(ctx)
case gitidentity.FieldRemark:
return m.OldRemark(ctx)
case gitidentity.FieldOauthRefreshToken:
return m.OldOauthRefreshToken(ctx)
case gitidentity.FieldOauthExpiresAt:
return m.OldOauthExpiresAt(ctx)
case gitidentity.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case gitidentity.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown GitIdentity 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 *GitIdentityMutation) SetField(name string, value ent.Value) error {
switch name {
case gitidentity.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 gitidentity.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case gitidentity.FieldPlatform:
v, ok := value.(consts.GitPlatform)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPlatform(v)
return nil
case gitidentity.FieldBaseURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetBaseURL(v)
return nil
case gitidentity.FieldAccessToken:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAccessToken(v)
return nil
case gitidentity.FieldUsername:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUsername(v)
return nil
case gitidentity.FieldEmail:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEmail(v)
return nil
case gitidentity.FieldInstallationID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetInstallationID(v)
return nil
case gitidentity.FieldRemark:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRemark(v)
return nil
case gitidentity.FieldOauthRefreshToken:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOauthRefreshToken(v)
return nil
case gitidentity.FieldOauthExpiresAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOauthExpiresAt(v)
return nil
case gitidentity.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 gitidentity.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown GitIdentity field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *GitIdentityMutation) AddedFields() []string {
var fields []string
if m.addinstallation_id != nil {
fields = append(fields, gitidentity.FieldInstallationID)
}
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 *GitIdentityMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case gitidentity.FieldInstallationID:
return m.AddedInstallationID()
}
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 *GitIdentityMutation) AddField(name string, value ent.Value) error {
switch name {
case gitidentity.FieldInstallationID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddInstallationID(v)
return nil
}
return fmt.Errorf("unknown GitIdentity numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *GitIdentityMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(gitidentity.FieldDeletedAt) {
fields = append(fields, gitidentity.FieldDeletedAt)
}
if m.FieldCleared(gitidentity.FieldBaseURL) {
fields = append(fields, gitidentity.FieldBaseURL)
}
if m.FieldCleared(gitidentity.FieldAccessToken) {
fields = append(fields, gitidentity.FieldAccessToken)
}
if m.FieldCleared(gitidentity.FieldUsername) {
fields = append(fields, gitidentity.FieldUsername)
}
if m.FieldCleared(gitidentity.FieldEmail) {
fields = append(fields, gitidentity.FieldEmail)
}
if m.FieldCleared(gitidentity.FieldInstallationID) {
fields = append(fields, gitidentity.FieldInstallationID)
}
if m.FieldCleared(gitidentity.FieldRemark) {
fields = append(fields, gitidentity.FieldRemark)
}
if m.FieldCleared(gitidentity.FieldOauthRefreshToken) {
fields = append(fields, gitidentity.FieldOauthRefreshToken)
}
if m.FieldCleared(gitidentity.FieldOauthExpiresAt) {
fields = append(fields, gitidentity.FieldOauthExpiresAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *GitIdentityMutation) 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 *GitIdentityMutation) ClearField(name string) error {
switch name {
case gitidentity.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case gitidentity.FieldBaseURL:
m.ClearBaseURL()
return nil
case gitidentity.FieldAccessToken:
m.ClearAccessToken()
return nil
case gitidentity.FieldUsername:
m.ClearUsername()
return nil
case gitidentity.FieldEmail:
m.ClearEmail()
return nil
case gitidentity.FieldInstallationID:
m.ClearInstallationID()
return nil
case gitidentity.FieldRemark:
m.ClearRemark()
return nil
case gitidentity.FieldOauthRefreshToken:
m.ClearOauthRefreshToken()
return nil
case gitidentity.FieldOauthExpiresAt:
m.ClearOauthExpiresAt()
return nil
}
return fmt.Errorf("unknown GitIdentity 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 *GitIdentityMutation) ResetField(name string) error {
switch name {
case gitidentity.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case gitidentity.FieldUserID:
m.ResetUserID()
return nil
case gitidentity.FieldPlatform:
m.ResetPlatform()
return nil
case gitidentity.FieldBaseURL:
m.ResetBaseURL()
return nil
case gitidentity.FieldAccessToken:
m.ResetAccessToken()
return nil
case gitidentity.FieldUsername:
m.ResetUsername()
return nil
case gitidentity.FieldEmail:
m.ResetEmail()
return nil
case gitidentity.FieldInstallationID:
m.ResetInstallationID()
return nil
case gitidentity.FieldRemark:
m.ResetRemark()
return nil
case gitidentity.FieldOauthRefreshToken:
m.ResetOauthRefreshToken()
return nil
case gitidentity.FieldOauthExpiresAt:
m.ResetOauthExpiresAt()
return nil
case gitidentity.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case gitidentity.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown GitIdentity field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *GitIdentityMutation) AddedEdges() []string {
edges := make([]string, 0, 4)
if m.user != nil {
edges = append(edges, gitidentity.EdgeUser)
}
if m.projects != nil {
edges = append(edges, gitidentity.EdgeProjects)
}
if m.project_tasks != nil {
edges = append(edges, gitidentity.EdgeProjectTasks)
}
if m.vms != nil {
edges = append(edges, gitidentity.EdgeVms)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *GitIdentityMutation) AddedIDs(name string) []ent.Value {
switch name {
case gitidentity.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
case gitidentity.EdgeProjects:
ids := make([]ent.Value, 0, len(m.projects))
for id := range m.projects {
ids = append(ids, id)
}
return ids
case gitidentity.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.project_tasks))
for id := range m.project_tasks {
ids = append(ids, id)
}
return ids
case gitidentity.EdgeVms:
ids := make([]ent.Value, 0, len(m.vms))
for id := range m.vms {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *GitIdentityMutation) RemovedEdges() []string {
edges := make([]string, 0, 4)
if m.removedprojects != nil {
edges = append(edges, gitidentity.EdgeProjects)
}
if m.removedproject_tasks != nil {
edges = append(edges, gitidentity.EdgeProjectTasks)
}
if m.removedvms != nil {
edges = append(edges, gitidentity.EdgeVms)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *GitIdentityMutation) RemovedIDs(name string) []ent.Value {
switch name {
case gitidentity.EdgeProjects:
ids := make([]ent.Value, 0, len(m.removedprojects))
for id := range m.removedprojects {
ids = append(ids, id)
}
return ids
case gitidentity.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.removedproject_tasks))
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return ids
case gitidentity.EdgeVms:
ids := make([]ent.Value, 0, len(m.removedvms))
for id := range m.removedvms {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *GitIdentityMutation) ClearedEdges() []string {
edges := make([]string, 0, 4)
if m.cleareduser {
edges = append(edges, gitidentity.EdgeUser)
}
if m.clearedprojects {
edges = append(edges, gitidentity.EdgeProjects)
}
if m.clearedproject_tasks {
edges = append(edges, gitidentity.EdgeProjectTasks)
}
if m.clearedvms {
edges = append(edges, gitidentity.EdgeVms)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *GitIdentityMutation) EdgeCleared(name string) bool {
switch name {
case gitidentity.EdgeUser:
return m.cleareduser
case gitidentity.EdgeProjects:
return m.clearedprojects
case gitidentity.EdgeProjectTasks:
return m.clearedproject_tasks
case gitidentity.EdgeVms:
return m.clearedvms
}
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 *GitIdentityMutation) ClearEdge(name string) error {
switch name {
case gitidentity.EdgeUser:
m.ClearUser()
return nil
}
return fmt.Errorf("unknown GitIdentity 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 *GitIdentityMutation) ResetEdge(name string) error {
switch name {
case gitidentity.EdgeUser:
m.ResetUser()
return nil
case gitidentity.EdgeProjects:
m.ResetProjects()
return nil
case gitidentity.EdgeProjectTasks:
m.ResetProjectTasks()
return nil
case gitidentity.EdgeVms:
m.ResetVms()
return nil
}
return fmt.Errorf("unknown GitIdentity edge %s", name)
}
// GitTaskMutation represents an operation that mutates the GitTask nodes in the graph.
type GitTaskMutation struct {
config
op Op
typ string
id *uuid.UUID
repo_id *uuid.UUID
subject_type *string
subject_id *string
subject_number *int
addsubject_number *int
subject_url *string
subject_title *string
prompt_id *string
show_url *string
github_installation_id *int64
addgithub_installation_id *int64
created_at *time.Time
clearedFields map[string]struct{}
task *uuid.UUID
clearedtask bool
done bool
oldValue func(context.Context) (*GitTask, error)
predicates []predicate.GitTask
}
var _ ent.Mutation = (*GitTaskMutation)(nil)
// gittaskOption allows management of the mutation configuration using functional options.
type gittaskOption func(*GitTaskMutation)
// newGitTaskMutation creates new mutation for the GitTask entity.
func newGitTaskMutation(c config, op Op, opts ...gittaskOption) *GitTaskMutation {
m := &GitTaskMutation{
config: c,
op: op,
typ: TypeGitTask,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withGitTaskID sets the ID field of the mutation.
func withGitTaskID(id uuid.UUID) gittaskOption {
return func(m *GitTaskMutation) {
var (
err error
once sync.Once
value *GitTask
)
m.oldValue = func(ctx context.Context) (*GitTask, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().GitTask.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withGitTask sets the old GitTask of the mutation.
func withGitTask(node *GitTask) gittaskOption {
return func(m *GitTaskMutation) {
m.oldValue = func(context.Context) (*GitTask, 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 GitTaskMutation) 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 GitTaskMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 GitTask entities.
func (m *GitTaskMutation) SetID(id uuid.UUID) {
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 *GitTaskMutation) ID() (id uuid.UUID, 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 *GitTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().GitTask.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetTaskID sets the "task_id" field.
func (m *GitTaskMutation) SetTaskID(u uuid.UUID) {
m.task = &u
}
// TaskID returns the value of the "task_id" field in the mutation.
func (m *GitTaskMutation) TaskID() (r uuid.UUID, exists bool) {
v := m.task
if v == nil {
return
}
return *v, true
}
// OldTaskID returns the old "task_id" field's value of the GitTask entity.
// If the GitTask 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 *GitTaskMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTaskID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
}
return oldValue.TaskID, nil
}
// ResetTaskID resets all changes to the "task_id" field.
func (m *GitTaskMutation) ResetTaskID() {
m.task = nil
}
// SetRepoID sets the "repo_id" field.
func (m *GitTaskMutation) SetRepoID(u uuid.UUID) {
m.repo_id = &u
}
// RepoID returns the value of the "repo_id" field in the mutation.
func (m *GitTaskMutation) RepoID() (r uuid.UUID, exists bool) {
v := m.repo_id
if v == nil {
return
}
return *v, true
}
// OldRepoID returns the old "repo_id" field's value of the GitTask entity.
// If the GitTask 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 *GitTaskMutation) OldRepoID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRepoID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRepoID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRepoID: %w", err)
}
return oldValue.RepoID, nil
}
// ClearRepoID clears the value of the "repo_id" field.
func (m *GitTaskMutation) ClearRepoID() {
m.repo_id = nil
m.clearedFields[gittask.FieldRepoID] = struct{}{}
}
// RepoIDCleared returns if the "repo_id" field was cleared in this mutation.
func (m *GitTaskMutation) RepoIDCleared() bool {
_, ok := m.clearedFields[gittask.FieldRepoID]
return ok
}
// ResetRepoID resets all changes to the "repo_id" field.
func (m *GitTaskMutation) ResetRepoID() {
m.repo_id = nil
delete(m.clearedFields, gittask.FieldRepoID)
}
// SetSubjectType sets the "subject_type" field.
func (m *GitTaskMutation) SetSubjectType(s string) {
m.subject_type = &s
}
// SubjectType returns the value of the "subject_type" field in the mutation.
func (m *GitTaskMutation) SubjectType() (r string, exists bool) {
v := m.subject_type
if v == nil {
return
}
return *v, true
}
// OldSubjectType returns the old "subject_type" field's value of the GitTask entity.
// If the GitTask 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 *GitTaskMutation) OldSubjectType(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSubjectType is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSubjectType requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSubjectType: %w", err)
}
return oldValue.SubjectType, nil
}
// ResetSubjectType resets all changes to the "subject_type" field.
func (m *GitTaskMutation) ResetSubjectType() {
m.subject_type = nil
}
// SetSubjectID sets the "subject_id" field.
func (m *GitTaskMutation) SetSubjectID(s string) {
m.subject_id = &s
}
// SubjectID returns the value of the "subject_id" field in the mutation.
func (m *GitTaskMutation) SubjectID() (r string, exists bool) {
v := m.subject_id
if v == nil {
return
}
return *v, true
}
// OldSubjectID returns the old "subject_id" field's value of the GitTask entity.
// If the GitTask 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 *GitTaskMutation) OldSubjectID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSubjectID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSubjectID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSubjectID: %w", err)
}
return oldValue.SubjectID, nil
}
// ClearSubjectID clears the value of the "subject_id" field.
func (m *GitTaskMutation) ClearSubjectID() {
m.subject_id = nil
m.clearedFields[gittask.FieldSubjectID] = struct{}{}
}
// SubjectIDCleared returns if the "subject_id" field was cleared in this mutation.
func (m *GitTaskMutation) SubjectIDCleared() bool {
_, ok := m.clearedFields[gittask.FieldSubjectID]
return ok
}
// ResetSubjectID resets all changes to the "subject_id" field.
func (m *GitTaskMutation) ResetSubjectID() {
m.subject_id = nil
delete(m.clearedFields, gittask.FieldSubjectID)
}
// SetSubjectNumber sets the "subject_number" field.
func (m *GitTaskMutation) SetSubjectNumber(i int) {
m.subject_number = &i
m.addsubject_number = nil
}
// SubjectNumber returns the value of the "subject_number" field in the mutation.
func (m *GitTaskMutation) SubjectNumber() (r int, exists bool) {
v := m.subject_number
if v == nil {
return
}
return *v, true
}
// OldSubjectNumber returns the old "subject_number" field's value of the GitTask entity.
// If the GitTask 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 *GitTaskMutation) OldSubjectNumber(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSubjectNumber is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSubjectNumber requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSubjectNumber: %w", err)
}
return oldValue.SubjectNumber, nil
}
// AddSubjectNumber adds i to the "subject_number" field.
func (m *GitTaskMutation) AddSubjectNumber(i int) {
if m.addsubject_number != nil {
*m.addsubject_number += i
} else {
m.addsubject_number = &i
}
}
// AddedSubjectNumber returns the value that was added to the "subject_number" field in this mutation.
func (m *GitTaskMutation) AddedSubjectNumber() (r int, exists bool) {
v := m.addsubject_number
if v == nil {
return
}
return *v, true
}
// ClearSubjectNumber clears the value of the "subject_number" field.
func (m *GitTaskMutation) ClearSubjectNumber() {
m.subject_number = nil
m.addsubject_number = nil
m.clearedFields[gittask.FieldSubjectNumber] = struct{}{}
}
// SubjectNumberCleared returns if the "subject_number" field was cleared in this mutation.
func (m *GitTaskMutation) SubjectNumberCleared() bool {
_, ok := m.clearedFields[gittask.FieldSubjectNumber]
return ok
}
// ResetSubjectNumber resets all changes to the "subject_number" field.
func (m *GitTaskMutation) ResetSubjectNumber() {
m.subject_number = nil
m.addsubject_number = nil
delete(m.clearedFields, gittask.FieldSubjectNumber)
}
// SetSubjectURL sets the "subject_url" field.
func (m *GitTaskMutation) SetSubjectURL(s string) {
m.subject_url = &s
}
// SubjectURL returns the value of the "subject_url" field in the mutation.
func (m *GitTaskMutation) SubjectURL() (r string, exists bool) {
v := m.subject_url
if v == nil {
return
}
return *v, true
}
// OldSubjectURL returns the old "subject_url" field's value of the GitTask entity.
// If the GitTask 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 *GitTaskMutation) OldSubjectURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSubjectURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSubjectURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSubjectURL: %w", err)
}
return oldValue.SubjectURL, nil
}
// ClearSubjectURL clears the value of the "subject_url" field.
func (m *GitTaskMutation) ClearSubjectURL() {
m.subject_url = nil
m.clearedFields[gittask.FieldSubjectURL] = struct{}{}
}
// SubjectURLCleared returns if the "subject_url" field was cleared in this mutation.
func (m *GitTaskMutation) SubjectURLCleared() bool {
_, ok := m.clearedFields[gittask.FieldSubjectURL]
return ok
}
// ResetSubjectURL resets all changes to the "subject_url" field.
func (m *GitTaskMutation) ResetSubjectURL() {
m.subject_url = nil
delete(m.clearedFields, gittask.FieldSubjectURL)
}
// SetSubjectTitle sets the "subject_title" field.
func (m *GitTaskMutation) SetSubjectTitle(s string) {
m.subject_title = &s
}
// SubjectTitle returns the value of the "subject_title" field in the mutation.
func (m *GitTaskMutation) SubjectTitle() (r string, exists bool) {
v := m.subject_title
if v == nil {
return
}
return *v, true
}
// OldSubjectTitle returns the old "subject_title" field's value of the GitTask entity.
// If the GitTask 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 *GitTaskMutation) OldSubjectTitle(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSubjectTitle is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSubjectTitle requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSubjectTitle: %w", err)
}
return oldValue.SubjectTitle, nil
}
// ClearSubjectTitle clears the value of the "subject_title" field.
func (m *GitTaskMutation) ClearSubjectTitle() {
m.subject_title = nil
m.clearedFields[gittask.FieldSubjectTitle] = struct{}{}
}
// SubjectTitleCleared returns if the "subject_title" field was cleared in this mutation.
func (m *GitTaskMutation) SubjectTitleCleared() bool {
_, ok := m.clearedFields[gittask.FieldSubjectTitle]
return ok
}
// ResetSubjectTitle resets all changes to the "subject_title" field.
func (m *GitTaskMutation) ResetSubjectTitle() {
m.subject_title = nil
delete(m.clearedFields, gittask.FieldSubjectTitle)
}
// SetPromptID sets the "prompt_id" field.
func (m *GitTaskMutation) SetPromptID(s string) {
m.prompt_id = &s
}
// PromptID returns the value of the "prompt_id" field in the mutation.
func (m *GitTaskMutation) PromptID() (r string, exists bool) {
v := m.prompt_id
if v == nil {
return
}
return *v, true
}
// OldPromptID returns the old "prompt_id" field's value of the GitTask entity.
// If the GitTask 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 *GitTaskMutation) OldPromptID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPromptID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPromptID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPromptID: %w", err)
}
return oldValue.PromptID, nil
}
// ClearPromptID clears the value of the "prompt_id" field.
func (m *GitTaskMutation) ClearPromptID() {
m.prompt_id = nil
m.clearedFields[gittask.FieldPromptID] = struct{}{}
}
// PromptIDCleared returns if the "prompt_id" field was cleared in this mutation.
func (m *GitTaskMutation) PromptIDCleared() bool {
_, ok := m.clearedFields[gittask.FieldPromptID]
return ok
}
// ResetPromptID resets all changes to the "prompt_id" field.
func (m *GitTaskMutation) ResetPromptID() {
m.prompt_id = nil
delete(m.clearedFields, gittask.FieldPromptID)
}
// SetShowURL sets the "show_url" field.
func (m *GitTaskMutation) SetShowURL(s string) {
m.show_url = &s
}
// ShowURL returns the value of the "show_url" field in the mutation.
func (m *GitTaskMutation) ShowURL() (r string, exists bool) {
v := m.show_url
if v == nil {
return
}
return *v, true
}
// OldShowURL returns the old "show_url" field's value of the GitTask entity.
// If the GitTask 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 *GitTaskMutation) OldShowURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldShowURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldShowURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldShowURL: %w", err)
}
return oldValue.ShowURL, nil
}
// ClearShowURL clears the value of the "show_url" field.
func (m *GitTaskMutation) ClearShowURL() {
m.show_url = nil
m.clearedFields[gittask.FieldShowURL] = struct{}{}
}
// ShowURLCleared returns if the "show_url" field was cleared in this mutation.
func (m *GitTaskMutation) ShowURLCleared() bool {
_, ok := m.clearedFields[gittask.FieldShowURL]
return ok
}
// ResetShowURL resets all changes to the "show_url" field.
func (m *GitTaskMutation) ResetShowURL() {
m.show_url = nil
delete(m.clearedFields, gittask.FieldShowURL)
}
// SetGithubInstallationID sets the "github_installation_id" field.
func (m *GitTaskMutation) SetGithubInstallationID(i int64) {
m.github_installation_id = &i
m.addgithub_installation_id = nil
}
// GithubInstallationID returns the value of the "github_installation_id" field in the mutation.
func (m *GitTaskMutation) GithubInstallationID() (r int64, exists bool) {
v := m.github_installation_id
if v == nil {
return
}
return *v, true
}
// OldGithubInstallationID returns the old "github_installation_id" field's value of the GitTask entity.
// If the GitTask 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 *GitTaskMutation) OldGithubInstallationID(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGithubInstallationID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGithubInstallationID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGithubInstallationID: %w", err)
}
return oldValue.GithubInstallationID, nil
}
// AddGithubInstallationID adds i to the "github_installation_id" field.
func (m *GitTaskMutation) AddGithubInstallationID(i int64) {
if m.addgithub_installation_id != nil {
*m.addgithub_installation_id += i
} else {
m.addgithub_installation_id = &i
}
}
// AddedGithubInstallationID returns the value that was added to the "github_installation_id" field in this mutation.
func (m *GitTaskMutation) AddedGithubInstallationID() (r int64, exists bool) {
v := m.addgithub_installation_id
if v == nil {
return
}
return *v, true
}
// ClearGithubInstallationID clears the value of the "github_installation_id" field.
func (m *GitTaskMutation) ClearGithubInstallationID() {
m.github_installation_id = nil
m.addgithub_installation_id = nil
m.clearedFields[gittask.FieldGithubInstallationID] = struct{}{}
}
// GithubInstallationIDCleared returns if the "github_installation_id" field was cleared in this mutation.
func (m *GitTaskMutation) GithubInstallationIDCleared() bool {
_, ok := m.clearedFields[gittask.FieldGithubInstallationID]
return ok
}
// ResetGithubInstallationID resets all changes to the "github_installation_id" field.
func (m *GitTaskMutation) ResetGithubInstallationID() {
m.github_installation_id = nil
m.addgithub_installation_id = nil
delete(m.clearedFields, gittask.FieldGithubInstallationID)
}
// SetCreatedAt sets the "created_at" field.
func (m *GitTaskMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *GitTaskMutation) 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 GitTask entity.
// If the GitTask 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 *GitTaskMutation) 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 *GitTaskMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearTask clears the "task" edge to the Task entity.
func (m *GitTaskMutation) ClearTask() {
m.clearedtask = true
m.clearedFields[gittask.FieldTaskID] = struct{}{}
}
// TaskCleared reports if the "task" edge to the Task entity was cleared.
func (m *GitTaskMutation) TaskCleared() bool {
return m.clearedtask
}
// TaskIDs returns the "task" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// TaskID instead. It exists only for internal usage by the builders.
func (m *GitTaskMutation) TaskIDs() (ids []uuid.UUID) {
if id := m.task; id != nil {
ids = append(ids, *id)
}
return
}
// ResetTask resets all changes to the "task" edge.
func (m *GitTaskMutation) ResetTask() {
m.task = nil
m.clearedtask = false
}
// Where appends a list predicates to the GitTaskMutation builder.
func (m *GitTaskMutation) Where(ps ...predicate.GitTask) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the GitTaskMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *GitTaskMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.GitTask, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *GitTaskMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *GitTaskMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (GitTask).
func (m *GitTaskMutation) 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 *GitTaskMutation) Fields() []string {
fields := make([]string, 0, 11)
if m.task != nil {
fields = append(fields, gittask.FieldTaskID)
}
if m.repo_id != nil {
fields = append(fields, gittask.FieldRepoID)
}
if m.subject_type != nil {
fields = append(fields, gittask.FieldSubjectType)
}
if m.subject_id != nil {
fields = append(fields, gittask.FieldSubjectID)
}
if m.subject_number != nil {
fields = append(fields, gittask.FieldSubjectNumber)
}
if m.subject_url != nil {
fields = append(fields, gittask.FieldSubjectURL)
}
if m.subject_title != nil {
fields = append(fields, gittask.FieldSubjectTitle)
}
if m.prompt_id != nil {
fields = append(fields, gittask.FieldPromptID)
}
if m.show_url != nil {
fields = append(fields, gittask.FieldShowURL)
}
if m.github_installation_id != nil {
fields = append(fields, gittask.FieldGithubInstallationID)
}
if m.created_at != nil {
fields = append(fields, gittask.FieldCreatedAt)
}
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 *GitTaskMutation) Field(name string) (ent.Value, bool) {
switch name {
case gittask.FieldTaskID:
return m.TaskID()
case gittask.FieldRepoID:
return m.RepoID()
case gittask.FieldSubjectType:
return m.SubjectType()
case gittask.FieldSubjectID:
return m.SubjectID()
case gittask.FieldSubjectNumber:
return m.SubjectNumber()
case gittask.FieldSubjectURL:
return m.SubjectURL()
case gittask.FieldSubjectTitle:
return m.SubjectTitle()
case gittask.FieldPromptID:
return m.PromptID()
case gittask.FieldShowURL:
return m.ShowURL()
case gittask.FieldGithubInstallationID:
return m.GithubInstallationID()
case gittask.FieldCreatedAt:
return m.CreatedAt()
}
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 *GitTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case gittask.FieldTaskID:
return m.OldTaskID(ctx)
case gittask.FieldRepoID:
return m.OldRepoID(ctx)
case gittask.FieldSubjectType:
return m.OldSubjectType(ctx)
case gittask.FieldSubjectID:
return m.OldSubjectID(ctx)
case gittask.FieldSubjectNumber:
return m.OldSubjectNumber(ctx)
case gittask.FieldSubjectURL:
return m.OldSubjectURL(ctx)
case gittask.FieldSubjectTitle:
return m.OldSubjectTitle(ctx)
case gittask.FieldPromptID:
return m.OldPromptID(ctx)
case gittask.FieldShowURL:
return m.OldShowURL(ctx)
case gittask.FieldGithubInstallationID:
return m.OldGithubInstallationID(ctx)
case gittask.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown GitTask 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 *GitTaskMutation) SetField(name string, value ent.Value) error {
switch name {
case gittask.FieldTaskID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTaskID(v)
return nil
case gittask.FieldRepoID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRepoID(v)
return nil
case gittask.FieldSubjectType:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSubjectType(v)
return nil
case gittask.FieldSubjectID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSubjectID(v)
return nil
case gittask.FieldSubjectNumber:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSubjectNumber(v)
return nil
case gittask.FieldSubjectURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSubjectURL(v)
return nil
case gittask.FieldSubjectTitle:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSubjectTitle(v)
return nil
case gittask.FieldPromptID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPromptID(v)
return nil
case gittask.FieldShowURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetShowURL(v)
return nil
case gittask.FieldGithubInstallationID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGithubInstallationID(v)
return nil
case gittask.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown GitTask field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *GitTaskMutation) AddedFields() []string {
var fields []string
if m.addsubject_number != nil {
fields = append(fields, gittask.FieldSubjectNumber)
}
if m.addgithub_installation_id != nil {
fields = append(fields, gittask.FieldGithubInstallationID)
}
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 *GitTaskMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case gittask.FieldSubjectNumber:
return m.AddedSubjectNumber()
case gittask.FieldGithubInstallationID:
return m.AddedGithubInstallationID()
}
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 *GitTaskMutation) AddField(name string, value ent.Value) error {
switch name {
case gittask.FieldSubjectNumber:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddSubjectNumber(v)
return nil
case gittask.FieldGithubInstallationID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddGithubInstallationID(v)
return nil
}
return fmt.Errorf("unknown GitTask numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *GitTaskMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(gittask.FieldRepoID) {
fields = append(fields, gittask.FieldRepoID)
}
if m.FieldCleared(gittask.FieldSubjectID) {
fields = append(fields, gittask.FieldSubjectID)
}
if m.FieldCleared(gittask.FieldSubjectNumber) {
fields = append(fields, gittask.FieldSubjectNumber)
}
if m.FieldCleared(gittask.FieldSubjectURL) {
fields = append(fields, gittask.FieldSubjectURL)
}
if m.FieldCleared(gittask.FieldSubjectTitle) {
fields = append(fields, gittask.FieldSubjectTitle)
}
if m.FieldCleared(gittask.FieldPromptID) {
fields = append(fields, gittask.FieldPromptID)
}
if m.FieldCleared(gittask.FieldShowURL) {
fields = append(fields, gittask.FieldShowURL)
}
if m.FieldCleared(gittask.FieldGithubInstallationID) {
fields = append(fields, gittask.FieldGithubInstallationID)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *GitTaskMutation) 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 *GitTaskMutation) ClearField(name string) error {
switch name {
case gittask.FieldRepoID:
m.ClearRepoID()
return nil
case gittask.FieldSubjectID:
m.ClearSubjectID()
return nil
case gittask.FieldSubjectNumber:
m.ClearSubjectNumber()
return nil
case gittask.FieldSubjectURL:
m.ClearSubjectURL()
return nil
case gittask.FieldSubjectTitle:
m.ClearSubjectTitle()
return nil
case gittask.FieldPromptID:
m.ClearPromptID()
return nil
case gittask.FieldShowURL:
m.ClearShowURL()
return nil
case gittask.FieldGithubInstallationID:
m.ClearGithubInstallationID()
return nil
}
return fmt.Errorf("unknown GitTask 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 *GitTaskMutation) ResetField(name string) error {
switch name {
case gittask.FieldTaskID:
m.ResetTaskID()
return nil
case gittask.FieldRepoID:
m.ResetRepoID()
return nil
case gittask.FieldSubjectType:
m.ResetSubjectType()
return nil
case gittask.FieldSubjectID:
m.ResetSubjectID()
return nil
case gittask.FieldSubjectNumber:
m.ResetSubjectNumber()
return nil
case gittask.FieldSubjectURL:
m.ResetSubjectURL()
return nil
case gittask.FieldSubjectTitle:
m.ResetSubjectTitle()
return nil
case gittask.FieldPromptID:
m.ResetPromptID()
return nil
case gittask.FieldShowURL:
m.ResetShowURL()
return nil
case gittask.FieldGithubInstallationID:
m.ResetGithubInstallationID()
return nil
case gittask.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown GitTask field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *GitTaskMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.task != nil {
edges = append(edges, gittask.EdgeTask)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *GitTaskMutation) AddedIDs(name string) []ent.Value {
switch name {
case gittask.EdgeTask:
if id := m.task; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *GitTaskMutation) 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 *GitTaskMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *GitTaskMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedtask {
edges = append(edges, gittask.EdgeTask)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *GitTaskMutation) EdgeCleared(name string) bool {
switch name {
case gittask.EdgeTask:
return m.clearedtask
}
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 *GitTaskMutation) ClearEdge(name string) error {
switch name {
case gittask.EdgeTask:
m.ClearTask()
return nil
}
return fmt.Errorf("unknown GitTask 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 *GitTaskMutation) ResetEdge(name string) error {
switch name {
case gittask.EdgeTask:
m.ResetTask()
return nil
}
return fmt.Errorf("unknown GitTask edge %s", name)
}
// HostMutation represents an operation that mutates the Host nodes in the graph.
type HostMutation struct {
config
op Op
typ string
id *string
deleted_at *time.Time
hostname *string
arch *string
cores *int
addcores *int
weight *int
addweight *int
memory *int64
addmemory *int64
disk *int64
adddisk *int64
os *string
external_ip *string
internal_ip *string
version *string
machine_id *string
remark *string
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
vms map[string]struct{}
removedvms map[string]struct{}
clearedvms bool
user *uuid.UUID
cleareduser bool
groups map[uuid.UUID]struct{}
removedgroups map[uuid.UUID]struct{}
clearedgroups bool
git_bots map[uuid.UUID]struct{}
removedgit_bots map[uuid.UUID]struct{}
clearedgit_bots bool
team_group_hosts map[uuid.UUID]struct{}
removedteam_group_hosts map[uuid.UUID]struct{}
clearedteam_group_hosts bool
done bool
oldValue func(context.Context) (*Host, error)
predicates []predicate.Host
}
var _ ent.Mutation = (*HostMutation)(nil)
// hostOption allows management of the mutation configuration using functional options.
type hostOption func(*HostMutation)
// newHostMutation creates new mutation for the Host entity.
func newHostMutation(c config, op Op, opts ...hostOption) *HostMutation {
m := &HostMutation{
config: c,
op: op,
typ: TypeHost,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withHostID sets the ID field of the mutation.
func withHostID(id string) hostOption {
return func(m *HostMutation) {
var (
err error
once sync.Once
value *Host
)
m.oldValue = func(ctx context.Context) (*Host, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Host.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withHost sets the old Host of the mutation.
func withHost(node *Host) hostOption {
return func(m *HostMutation) {
m.oldValue = func(context.Context) (*Host, 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 HostMutation) 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 HostMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 Host entities.
func (m *HostMutation) SetID(id string) {
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 *HostMutation) ID() (id string, 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 *HostMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().Host.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *HostMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *HostMutation) 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 Host entity.
// If the Host 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 *HostMutation) 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 *HostMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[host.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *HostMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[host.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *HostMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, host.FieldDeletedAt)
}
// SetUserID sets the "user_id" field.
func (m *HostMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *HostMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the Host entity.
// If the Host 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 *HostMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *HostMutation) ResetUserID() {
m.user = nil
}
// SetHostname sets the "hostname" field.
func (m *HostMutation) SetHostname(s string) {
m.hostname = &s
}
// Hostname returns the value of the "hostname" field in the mutation.
func (m *HostMutation) Hostname() (r string, exists bool) {
v := m.hostname
if v == nil {
return
}
return *v, true
}
// OldHostname returns the old "hostname" field's value of the Host entity.
// If the Host 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 *HostMutation) OldHostname(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHostname is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHostname requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHostname: %w", err)
}
return oldValue.Hostname, nil
}
// ClearHostname clears the value of the "hostname" field.
func (m *HostMutation) ClearHostname() {
m.hostname = nil
m.clearedFields[host.FieldHostname] = struct{}{}
}
// HostnameCleared returns if the "hostname" field was cleared in this mutation.
func (m *HostMutation) HostnameCleared() bool {
_, ok := m.clearedFields[host.FieldHostname]
return ok
}
// ResetHostname resets all changes to the "hostname" field.
func (m *HostMutation) ResetHostname() {
m.hostname = nil
delete(m.clearedFields, host.FieldHostname)
}
// SetArch sets the "arch" field.
func (m *HostMutation) SetArch(s string) {
m.arch = &s
}
// Arch returns the value of the "arch" field in the mutation.
func (m *HostMutation) Arch() (r string, exists bool) {
v := m.arch
if v == nil {
return
}
return *v, true
}
// OldArch returns the old "arch" field's value of the Host entity.
// If the Host 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 *HostMutation) OldArch(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldArch is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldArch requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldArch: %w", err)
}
return oldValue.Arch, nil
}
// ClearArch clears the value of the "arch" field.
func (m *HostMutation) ClearArch() {
m.arch = nil
m.clearedFields[host.FieldArch] = struct{}{}
}
// ArchCleared returns if the "arch" field was cleared in this mutation.
func (m *HostMutation) ArchCleared() bool {
_, ok := m.clearedFields[host.FieldArch]
return ok
}
// ResetArch resets all changes to the "arch" field.
func (m *HostMutation) ResetArch() {
m.arch = nil
delete(m.clearedFields, host.FieldArch)
}
// SetCores sets the "cores" field.
func (m *HostMutation) SetCores(i int) {
m.cores = &i
m.addcores = nil
}
// Cores returns the value of the "cores" field in the mutation.
func (m *HostMutation) Cores() (r int, exists bool) {
v := m.cores
if v == nil {
return
}
return *v, true
}
// OldCores returns the old "cores" field's value of the Host entity.
// If the Host 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 *HostMutation) OldCores(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCores is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCores requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCores: %w", err)
}
return oldValue.Cores, nil
}
// AddCores adds i to the "cores" field.
func (m *HostMutation) AddCores(i int) {
if m.addcores != nil {
*m.addcores += i
} else {
m.addcores = &i
}
}
// AddedCores returns the value that was added to the "cores" field in this mutation.
func (m *HostMutation) AddedCores() (r int, exists bool) {
v := m.addcores
if v == nil {
return
}
return *v, true
}
// ClearCores clears the value of the "cores" field.
func (m *HostMutation) ClearCores() {
m.cores = nil
m.addcores = nil
m.clearedFields[host.FieldCores] = struct{}{}
}
// CoresCleared returns if the "cores" field was cleared in this mutation.
func (m *HostMutation) CoresCleared() bool {
_, ok := m.clearedFields[host.FieldCores]
return ok
}
// ResetCores resets all changes to the "cores" field.
func (m *HostMutation) ResetCores() {
m.cores = nil
m.addcores = nil
delete(m.clearedFields, host.FieldCores)
}
// SetWeight sets the "weight" field.
func (m *HostMutation) SetWeight(i int) {
m.weight = &i
m.addweight = nil
}
// Weight returns the value of the "weight" field in the mutation.
func (m *HostMutation) Weight() (r int, exists bool) {
v := m.weight
if v == nil {
return
}
return *v, true
}
// OldWeight returns the old "weight" field's value of the Host entity.
// If the Host 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 *HostMutation) OldWeight(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldWeight is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldWeight requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldWeight: %w", err)
}
return oldValue.Weight, nil
}
// AddWeight adds i to the "weight" field.
func (m *HostMutation) AddWeight(i int) {
if m.addweight != nil {
*m.addweight += i
} else {
m.addweight = &i
}
}
// AddedWeight returns the value that was added to the "weight" field in this mutation.
func (m *HostMutation) AddedWeight() (r int, exists bool) {
v := m.addweight
if v == nil {
return
}
return *v, true
}
// ResetWeight resets all changes to the "weight" field.
func (m *HostMutation) ResetWeight() {
m.weight = nil
m.addweight = nil
}
// SetMemory sets the "memory" field.
func (m *HostMutation) SetMemory(i int64) {
m.memory = &i
m.addmemory = nil
}
// Memory returns the value of the "memory" field in the mutation.
func (m *HostMutation) Memory() (r int64, exists bool) {
v := m.memory
if v == nil {
return
}
return *v, true
}
// OldMemory returns the old "memory" field's value of the Host entity.
// If the Host 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 *HostMutation) OldMemory(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMemory is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldMemory requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMemory: %w", err)
}
return oldValue.Memory, nil
}
// AddMemory adds i to the "memory" field.
func (m *HostMutation) AddMemory(i int64) {
if m.addmemory != nil {
*m.addmemory += i
} else {
m.addmemory = &i
}
}
// AddedMemory returns the value that was added to the "memory" field in this mutation.
func (m *HostMutation) AddedMemory() (r int64, exists bool) {
v := m.addmemory
if v == nil {
return
}
return *v, true
}
// ClearMemory clears the value of the "memory" field.
func (m *HostMutation) ClearMemory() {
m.memory = nil
m.addmemory = nil
m.clearedFields[host.FieldMemory] = struct{}{}
}
// MemoryCleared returns if the "memory" field was cleared in this mutation.
func (m *HostMutation) MemoryCleared() bool {
_, ok := m.clearedFields[host.FieldMemory]
return ok
}
// ResetMemory resets all changes to the "memory" field.
func (m *HostMutation) ResetMemory() {
m.memory = nil
m.addmemory = nil
delete(m.clearedFields, host.FieldMemory)
}
// SetDisk sets the "disk" field.
func (m *HostMutation) SetDisk(i int64) {
m.disk = &i
m.adddisk = nil
}
// Disk returns the value of the "disk" field in the mutation.
func (m *HostMutation) Disk() (r int64, exists bool) {
v := m.disk
if v == nil {
return
}
return *v, true
}
// OldDisk returns the old "disk" field's value of the Host entity.
// If the Host 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 *HostMutation) OldDisk(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDisk is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldDisk requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDisk: %w", err)
}
return oldValue.Disk, nil
}
// AddDisk adds i to the "disk" field.
func (m *HostMutation) AddDisk(i int64) {
if m.adddisk != nil {
*m.adddisk += i
} else {
m.adddisk = &i
}
}
// AddedDisk returns the value that was added to the "disk" field in this mutation.
func (m *HostMutation) AddedDisk() (r int64, exists bool) {
v := m.adddisk
if v == nil {
return
}
return *v, true
}
// ClearDisk clears the value of the "disk" field.
func (m *HostMutation) ClearDisk() {
m.disk = nil
m.adddisk = nil
m.clearedFields[host.FieldDisk] = struct{}{}
}
// DiskCleared returns if the "disk" field was cleared in this mutation.
func (m *HostMutation) DiskCleared() bool {
_, ok := m.clearedFields[host.FieldDisk]
return ok
}
// ResetDisk resets all changes to the "disk" field.
func (m *HostMutation) ResetDisk() {
m.disk = nil
m.adddisk = nil
delete(m.clearedFields, host.FieldDisk)
}
// SetOs sets the "os" field.
func (m *HostMutation) SetOs(s string) {
m.os = &s
}
// Os returns the value of the "os" field in the mutation.
func (m *HostMutation) Os() (r string, exists bool) {
v := m.os
if v == nil {
return
}
return *v, true
}
// OldOs returns the old "os" field's value of the Host entity.
// If the Host 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 *HostMutation) OldOs(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOs is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOs requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOs: %w", err)
}
return oldValue.Os, nil
}
// ClearOs clears the value of the "os" field.
func (m *HostMutation) ClearOs() {
m.os = nil
m.clearedFields[host.FieldOs] = struct{}{}
}
// OsCleared returns if the "os" field was cleared in this mutation.
func (m *HostMutation) OsCleared() bool {
_, ok := m.clearedFields[host.FieldOs]
return ok
}
// ResetOs resets all changes to the "os" field.
func (m *HostMutation) ResetOs() {
m.os = nil
delete(m.clearedFields, host.FieldOs)
}
// SetExternalIP sets the "external_ip" field.
func (m *HostMutation) SetExternalIP(s string) {
m.external_ip = &s
}
// ExternalIP returns the value of the "external_ip" field in the mutation.
func (m *HostMutation) ExternalIP() (r string, exists bool) {
v := m.external_ip
if v == nil {
return
}
return *v, true
}
// OldExternalIP returns the old "external_ip" field's value of the Host entity.
// If the Host 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 *HostMutation) OldExternalIP(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldExternalIP is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldExternalIP requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldExternalIP: %w", err)
}
return oldValue.ExternalIP, nil
}
// ClearExternalIP clears the value of the "external_ip" field.
func (m *HostMutation) ClearExternalIP() {
m.external_ip = nil
m.clearedFields[host.FieldExternalIP] = struct{}{}
}
// ExternalIPCleared returns if the "external_ip" field was cleared in this mutation.
func (m *HostMutation) ExternalIPCleared() bool {
_, ok := m.clearedFields[host.FieldExternalIP]
return ok
}
// ResetExternalIP resets all changes to the "external_ip" field.
func (m *HostMutation) ResetExternalIP() {
m.external_ip = nil
delete(m.clearedFields, host.FieldExternalIP)
}
// SetInternalIP sets the "internal_ip" field.
func (m *HostMutation) SetInternalIP(s string) {
m.internal_ip = &s
}
// InternalIP returns the value of the "internal_ip" field in the mutation.
func (m *HostMutation) InternalIP() (r string, exists bool) {
v := m.internal_ip
if v == nil {
return
}
return *v, true
}
// OldInternalIP returns the old "internal_ip" field's value of the Host entity.
// If the Host 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 *HostMutation) OldInternalIP(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldInternalIP is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldInternalIP requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInternalIP: %w", err)
}
return oldValue.InternalIP, nil
}
// ClearInternalIP clears the value of the "internal_ip" field.
func (m *HostMutation) ClearInternalIP() {
m.internal_ip = nil
m.clearedFields[host.FieldInternalIP] = struct{}{}
}
// InternalIPCleared returns if the "internal_ip" field was cleared in this mutation.
func (m *HostMutation) InternalIPCleared() bool {
_, ok := m.clearedFields[host.FieldInternalIP]
return ok
}
// ResetInternalIP resets all changes to the "internal_ip" field.
func (m *HostMutation) ResetInternalIP() {
m.internal_ip = nil
delete(m.clearedFields, host.FieldInternalIP)
}
// SetVersion sets the "version" field.
func (m *HostMutation) SetVersion(s string) {
m.version = &s
}
// Version returns the value of the "version" field in the mutation.
func (m *HostMutation) Version() (r string, exists bool) {
v := m.version
if v == nil {
return
}
return *v, true
}
// OldVersion returns the old "version" field's value of the Host entity.
// If the Host 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 *HostMutation) OldVersion(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldVersion is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldVersion requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldVersion: %w", err)
}
return oldValue.Version, nil
}
// ClearVersion clears the value of the "version" field.
func (m *HostMutation) ClearVersion() {
m.version = nil
m.clearedFields[host.FieldVersion] = struct{}{}
}
// VersionCleared returns if the "version" field was cleared in this mutation.
func (m *HostMutation) VersionCleared() bool {
_, ok := m.clearedFields[host.FieldVersion]
return ok
}
// ResetVersion resets all changes to the "version" field.
func (m *HostMutation) ResetVersion() {
m.version = nil
delete(m.clearedFields, host.FieldVersion)
}
// SetMachineID sets the "machine_id" field.
func (m *HostMutation) SetMachineID(s string) {
m.machine_id = &s
}
// MachineID returns the value of the "machine_id" field in the mutation.
func (m *HostMutation) MachineID() (r string, exists bool) {
v := m.machine_id
if v == nil {
return
}
return *v, true
}
// OldMachineID returns the old "machine_id" field's value of the Host entity.
// If the Host 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 *HostMutation) OldMachineID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMachineID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldMachineID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMachineID: %w", err)
}
return oldValue.MachineID, nil
}
// ClearMachineID clears the value of the "machine_id" field.
func (m *HostMutation) ClearMachineID() {
m.machine_id = nil
m.clearedFields[host.FieldMachineID] = struct{}{}
}
// MachineIDCleared returns if the "machine_id" field was cleared in this mutation.
func (m *HostMutation) MachineIDCleared() bool {
_, ok := m.clearedFields[host.FieldMachineID]
return ok
}
// ResetMachineID resets all changes to the "machine_id" field.
func (m *HostMutation) ResetMachineID() {
m.machine_id = nil
delete(m.clearedFields, host.FieldMachineID)
}
// SetRemark sets the "remark" field.
func (m *HostMutation) SetRemark(s string) {
m.remark = &s
}
// Remark returns the value of the "remark" field in the mutation.
func (m *HostMutation) Remark() (r string, exists bool) {
v := m.remark
if v == nil {
return
}
return *v, true
}
// OldRemark returns the old "remark" field's value of the Host entity.
// If the Host 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 *HostMutation) OldRemark(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRemark is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRemark requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRemark: %w", err)
}
return oldValue.Remark, nil
}
// ClearRemark clears the value of the "remark" field.
func (m *HostMutation) ClearRemark() {
m.remark = nil
m.clearedFields[host.FieldRemark] = struct{}{}
}
// RemarkCleared returns if the "remark" field was cleared in this mutation.
func (m *HostMutation) RemarkCleared() bool {
_, ok := m.clearedFields[host.FieldRemark]
return ok
}
// ResetRemark resets all changes to the "remark" field.
func (m *HostMutation) ResetRemark() {
m.remark = nil
delete(m.clearedFields, host.FieldRemark)
}
// SetCreatedAt sets the "created_at" field.
func (m *HostMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *HostMutation) 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 Host entity.
// If the Host 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 *HostMutation) 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 *HostMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *HostMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *HostMutation) 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 Host entity.
// If the Host 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 *HostMutation) 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 *HostMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by ids.
func (m *HostMutation) AddVMIDs(ids ...string) {
if m.vms == nil {
m.vms = make(map[string]struct{})
}
for i := range ids {
m.vms[ids[i]] = struct{}{}
}
}
// ClearVms clears the "vms" edge to the VirtualMachine entity.
func (m *HostMutation) ClearVms() {
m.clearedvms = true
}
// VmsCleared reports if the "vms" edge to the VirtualMachine entity was cleared.
func (m *HostMutation) VmsCleared() bool {
return m.clearedvms
}
// RemoveVMIDs removes the "vms" edge to the VirtualMachine entity by IDs.
func (m *HostMutation) RemoveVMIDs(ids ...string) {
if m.removedvms == nil {
m.removedvms = make(map[string]struct{})
}
for i := range ids {
delete(m.vms, ids[i])
m.removedvms[ids[i]] = struct{}{}
}
}
// RemovedVms returns the removed IDs of the "vms" edge to the VirtualMachine entity.
func (m *HostMutation) RemovedVmsIDs() (ids []string) {
for id := range m.removedvms {
ids = append(ids, id)
}
return
}
// VmsIDs returns the "vms" edge IDs in the mutation.
func (m *HostMutation) VmsIDs() (ids []string) {
for id := range m.vms {
ids = append(ids, id)
}
return
}
// ResetVms resets all changes to the "vms" edge.
func (m *HostMutation) ResetVms() {
m.vms = nil
m.clearedvms = false
m.removedvms = nil
}
// ClearUser clears the "user" edge to the User entity.
func (m *HostMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[host.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *HostMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *HostMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *HostMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids.
func (m *HostMutation) AddGroupIDs(ids ...uuid.UUID) {
if m.groups == nil {
m.groups = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.groups[ids[i]] = struct{}{}
}
}
// ClearGroups clears the "groups" edge to the TeamGroup entity.
func (m *HostMutation) ClearGroups() {
m.clearedgroups = true
}
// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared.
func (m *HostMutation) GroupsCleared() bool {
return m.clearedgroups
}
// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs.
func (m *HostMutation) RemoveGroupIDs(ids ...uuid.UUID) {
if m.removedgroups == nil {
m.removedgroups = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.groups, ids[i])
m.removedgroups[ids[i]] = struct{}{}
}
}
// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity.
func (m *HostMutation) RemovedGroupsIDs() (ids []uuid.UUID) {
for id := range m.removedgroups {
ids = append(ids, id)
}
return
}
// GroupsIDs returns the "groups" edge IDs in the mutation.
func (m *HostMutation) GroupsIDs() (ids []uuid.UUID) {
for id := range m.groups {
ids = append(ids, id)
}
return
}
// ResetGroups resets all changes to the "groups" edge.
func (m *HostMutation) ResetGroups() {
m.groups = nil
m.clearedgroups = false
m.removedgroups = nil
}
// AddGitBotIDs adds the "git_bots" edge to the GitBot entity by ids.
func (m *HostMutation) AddGitBotIDs(ids ...uuid.UUID) {
if m.git_bots == nil {
m.git_bots = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.git_bots[ids[i]] = struct{}{}
}
}
// ClearGitBots clears the "git_bots" edge to the GitBot entity.
func (m *HostMutation) ClearGitBots() {
m.clearedgit_bots = true
}
// GitBotsCleared reports if the "git_bots" edge to the GitBot entity was cleared.
func (m *HostMutation) GitBotsCleared() bool {
return m.clearedgit_bots
}
// RemoveGitBotIDs removes the "git_bots" edge to the GitBot entity by IDs.
func (m *HostMutation) RemoveGitBotIDs(ids ...uuid.UUID) {
if m.removedgit_bots == nil {
m.removedgit_bots = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.git_bots, ids[i])
m.removedgit_bots[ids[i]] = struct{}{}
}
}
// RemovedGitBots returns the removed IDs of the "git_bots" edge to the GitBot entity.
func (m *HostMutation) RemovedGitBotsIDs() (ids []uuid.UUID) {
for id := range m.removedgit_bots {
ids = append(ids, id)
}
return
}
// GitBotsIDs returns the "git_bots" edge IDs in the mutation.
func (m *HostMutation) GitBotsIDs() (ids []uuid.UUID) {
for id := range m.git_bots {
ids = append(ids, id)
}
return
}
// ResetGitBots resets all changes to the "git_bots" edge.
func (m *HostMutation) ResetGitBots() {
m.git_bots = nil
m.clearedgit_bots = false
m.removedgit_bots = nil
}
// AddTeamGroupHostIDs adds the "team_group_hosts" edge to the TeamGroupHost entity by ids.
func (m *HostMutation) AddTeamGroupHostIDs(ids ...uuid.UUID) {
if m.team_group_hosts == nil {
m.team_group_hosts = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_group_hosts[ids[i]] = struct{}{}
}
}
// ClearTeamGroupHosts clears the "team_group_hosts" edge to the TeamGroupHost entity.
func (m *HostMutation) ClearTeamGroupHosts() {
m.clearedteam_group_hosts = true
}
// TeamGroupHostsCleared reports if the "team_group_hosts" edge to the TeamGroupHost entity was cleared.
func (m *HostMutation) TeamGroupHostsCleared() bool {
return m.clearedteam_group_hosts
}
// RemoveTeamGroupHostIDs removes the "team_group_hosts" edge to the TeamGroupHost entity by IDs.
func (m *HostMutation) RemoveTeamGroupHostIDs(ids ...uuid.UUID) {
if m.removedteam_group_hosts == nil {
m.removedteam_group_hosts = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_group_hosts, ids[i])
m.removedteam_group_hosts[ids[i]] = struct{}{}
}
}
// RemovedTeamGroupHosts returns the removed IDs of the "team_group_hosts" edge to the TeamGroupHost entity.
func (m *HostMutation) RemovedTeamGroupHostsIDs() (ids []uuid.UUID) {
for id := range m.removedteam_group_hosts {
ids = append(ids, id)
}
return
}
// TeamGroupHostsIDs returns the "team_group_hosts" edge IDs in the mutation.
func (m *HostMutation) TeamGroupHostsIDs() (ids []uuid.UUID) {
for id := range m.team_group_hosts {
ids = append(ids, id)
}
return
}
// ResetTeamGroupHosts resets all changes to the "team_group_hosts" edge.
func (m *HostMutation) ResetTeamGroupHosts() {
m.team_group_hosts = nil
m.clearedteam_group_hosts = false
m.removedteam_group_hosts = nil
}
// Where appends a list predicates to the HostMutation builder.
func (m *HostMutation) Where(ps ...predicate.Host) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the HostMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *HostMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Host, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *HostMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *HostMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Host).
func (m *HostMutation) 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 *HostMutation) Fields() []string {
fields := make([]string, 0, 16)
if m.deleted_at != nil {
fields = append(fields, host.FieldDeletedAt)
}
if m.user != nil {
fields = append(fields, host.FieldUserID)
}
if m.hostname != nil {
fields = append(fields, host.FieldHostname)
}
if m.arch != nil {
fields = append(fields, host.FieldArch)
}
if m.cores != nil {
fields = append(fields, host.FieldCores)
}
if m.weight != nil {
fields = append(fields, host.FieldWeight)
}
if m.memory != nil {
fields = append(fields, host.FieldMemory)
}
if m.disk != nil {
fields = append(fields, host.FieldDisk)
}
if m.os != nil {
fields = append(fields, host.FieldOs)
}
if m.external_ip != nil {
fields = append(fields, host.FieldExternalIP)
}
if m.internal_ip != nil {
fields = append(fields, host.FieldInternalIP)
}
if m.version != nil {
fields = append(fields, host.FieldVersion)
}
if m.machine_id != nil {
fields = append(fields, host.FieldMachineID)
}
if m.remark != nil {
fields = append(fields, host.FieldRemark)
}
if m.created_at != nil {
fields = append(fields, host.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, host.FieldUpdatedAt)
}
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 *HostMutation) Field(name string) (ent.Value, bool) {
switch name {
case host.FieldDeletedAt:
return m.DeletedAt()
case host.FieldUserID:
return m.UserID()
case host.FieldHostname:
return m.Hostname()
case host.FieldArch:
return m.Arch()
case host.FieldCores:
return m.Cores()
case host.FieldWeight:
return m.Weight()
case host.FieldMemory:
return m.Memory()
case host.FieldDisk:
return m.Disk()
case host.FieldOs:
return m.Os()
case host.FieldExternalIP:
return m.ExternalIP()
case host.FieldInternalIP:
return m.InternalIP()
case host.FieldVersion:
return m.Version()
case host.FieldMachineID:
return m.MachineID()
case host.FieldRemark:
return m.Remark()
case host.FieldCreatedAt:
return m.CreatedAt()
case host.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *HostMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case host.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case host.FieldUserID:
return m.OldUserID(ctx)
case host.FieldHostname:
return m.OldHostname(ctx)
case host.FieldArch:
return m.OldArch(ctx)
case host.FieldCores:
return m.OldCores(ctx)
case host.FieldWeight:
return m.OldWeight(ctx)
case host.FieldMemory:
return m.OldMemory(ctx)
case host.FieldDisk:
return m.OldDisk(ctx)
case host.FieldOs:
return m.OldOs(ctx)
case host.FieldExternalIP:
return m.OldExternalIP(ctx)
case host.FieldInternalIP:
return m.OldInternalIP(ctx)
case host.FieldVersion:
return m.OldVersion(ctx)
case host.FieldMachineID:
return m.OldMachineID(ctx)
case host.FieldRemark:
return m.OldRemark(ctx)
case host.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case host.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown Host 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 *HostMutation) SetField(name string, value ent.Value) error {
switch name {
case host.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 host.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case host.FieldHostname:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHostname(v)
return nil
case host.FieldArch:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetArch(v)
return nil
case host.FieldCores:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCores(v)
return nil
case host.FieldWeight:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetWeight(v)
return nil
case host.FieldMemory:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMemory(v)
return nil
case host.FieldDisk:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDisk(v)
return nil
case host.FieldOs:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOs(v)
return nil
case host.FieldExternalIP:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetExternalIP(v)
return nil
case host.FieldInternalIP:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetInternalIP(v)
return nil
case host.FieldVersion:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetVersion(v)
return nil
case host.FieldMachineID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMachineID(v)
return nil
case host.FieldRemark:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRemark(v)
return nil
case host.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 host.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown Host field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *HostMutation) AddedFields() []string {
var fields []string
if m.addcores != nil {
fields = append(fields, host.FieldCores)
}
if m.addweight != nil {
fields = append(fields, host.FieldWeight)
}
if m.addmemory != nil {
fields = append(fields, host.FieldMemory)
}
if m.adddisk != nil {
fields = append(fields, host.FieldDisk)
}
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 *HostMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case host.FieldCores:
return m.AddedCores()
case host.FieldWeight:
return m.AddedWeight()
case host.FieldMemory:
return m.AddedMemory()
case host.FieldDisk:
return m.AddedDisk()
}
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 *HostMutation) AddField(name string, value ent.Value) error {
switch name {
case host.FieldCores:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddCores(v)
return nil
case host.FieldWeight:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddWeight(v)
return nil
case host.FieldMemory:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMemory(v)
return nil
case host.FieldDisk:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddDisk(v)
return nil
}
return fmt.Errorf("unknown Host numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *HostMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(host.FieldDeletedAt) {
fields = append(fields, host.FieldDeletedAt)
}
if m.FieldCleared(host.FieldHostname) {
fields = append(fields, host.FieldHostname)
}
if m.FieldCleared(host.FieldArch) {
fields = append(fields, host.FieldArch)
}
if m.FieldCleared(host.FieldCores) {
fields = append(fields, host.FieldCores)
}
if m.FieldCleared(host.FieldMemory) {
fields = append(fields, host.FieldMemory)
}
if m.FieldCleared(host.FieldDisk) {
fields = append(fields, host.FieldDisk)
}
if m.FieldCleared(host.FieldOs) {
fields = append(fields, host.FieldOs)
}
if m.FieldCleared(host.FieldExternalIP) {
fields = append(fields, host.FieldExternalIP)
}
if m.FieldCleared(host.FieldInternalIP) {
fields = append(fields, host.FieldInternalIP)
}
if m.FieldCleared(host.FieldVersion) {
fields = append(fields, host.FieldVersion)
}
if m.FieldCleared(host.FieldMachineID) {
fields = append(fields, host.FieldMachineID)
}
if m.FieldCleared(host.FieldRemark) {
fields = append(fields, host.FieldRemark)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *HostMutation) 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 *HostMutation) ClearField(name string) error {
switch name {
case host.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case host.FieldHostname:
m.ClearHostname()
return nil
case host.FieldArch:
m.ClearArch()
return nil
case host.FieldCores:
m.ClearCores()
return nil
case host.FieldMemory:
m.ClearMemory()
return nil
case host.FieldDisk:
m.ClearDisk()
return nil
case host.FieldOs:
m.ClearOs()
return nil
case host.FieldExternalIP:
m.ClearExternalIP()
return nil
case host.FieldInternalIP:
m.ClearInternalIP()
return nil
case host.FieldVersion:
m.ClearVersion()
return nil
case host.FieldMachineID:
m.ClearMachineID()
return nil
case host.FieldRemark:
m.ClearRemark()
return nil
}
return fmt.Errorf("unknown Host 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 *HostMutation) ResetField(name string) error {
switch name {
case host.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case host.FieldUserID:
m.ResetUserID()
return nil
case host.FieldHostname:
m.ResetHostname()
return nil
case host.FieldArch:
m.ResetArch()
return nil
case host.FieldCores:
m.ResetCores()
return nil
case host.FieldWeight:
m.ResetWeight()
return nil
case host.FieldMemory:
m.ResetMemory()
return nil
case host.FieldDisk:
m.ResetDisk()
return nil
case host.FieldOs:
m.ResetOs()
return nil
case host.FieldExternalIP:
m.ResetExternalIP()
return nil
case host.FieldInternalIP:
m.ResetInternalIP()
return nil
case host.FieldVersion:
m.ResetVersion()
return nil
case host.FieldMachineID:
m.ResetMachineID()
return nil
case host.FieldRemark:
m.ResetRemark()
return nil
case host.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case host.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown Host field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *HostMutation) AddedEdges() []string {
edges := make([]string, 0, 5)
if m.vms != nil {
edges = append(edges, host.EdgeVms)
}
if m.user != nil {
edges = append(edges, host.EdgeUser)
}
if m.groups != nil {
edges = append(edges, host.EdgeGroups)
}
if m.git_bots != nil {
edges = append(edges, host.EdgeGitBots)
}
if m.team_group_hosts != nil {
edges = append(edges, host.EdgeTeamGroupHosts)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *HostMutation) AddedIDs(name string) []ent.Value {
switch name {
case host.EdgeVms:
ids := make([]ent.Value, 0, len(m.vms))
for id := range m.vms {
ids = append(ids, id)
}
return ids
case host.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
case host.EdgeGroups:
ids := make([]ent.Value, 0, len(m.groups))
for id := range m.groups {
ids = append(ids, id)
}
return ids
case host.EdgeGitBots:
ids := make([]ent.Value, 0, len(m.git_bots))
for id := range m.git_bots {
ids = append(ids, id)
}
return ids
case host.EdgeTeamGroupHosts:
ids := make([]ent.Value, 0, len(m.team_group_hosts))
for id := range m.team_group_hosts {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *HostMutation) RemovedEdges() []string {
edges := make([]string, 0, 5)
if m.removedvms != nil {
edges = append(edges, host.EdgeVms)
}
if m.removedgroups != nil {
edges = append(edges, host.EdgeGroups)
}
if m.removedgit_bots != nil {
edges = append(edges, host.EdgeGitBots)
}
if m.removedteam_group_hosts != nil {
edges = append(edges, host.EdgeTeamGroupHosts)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *HostMutation) RemovedIDs(name string) []ent.Value {
switch name {
case host.EdgeVms:
ids := make([]ent.Value, 0, len(m.removedvms))
for id := range m.removedvms {
ids = append(ids, id)
}
return ids
case host.EdgeGroups:
ids := make([]ent.Value, 0, len(m.removedgroups))
for id := range m.removedgroups {
ids = append(ids, id)
}
return ids
case host.EdgeGitBots:
ids := make([]ent.Value, 0, len(m.removedgit_bots))
for id := range m.removedgit_bots {
ids = append(ids, id)
}
return ids
case host.EdgeTeamGroupHosts:
ids := make([]ent.Value, 0, len(m.removedteam_group_hosts))
for id := range m.removedteam_group_hosts {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *HostMutation) ClearedEdges() []string {
edges := make([]string, 0, 5)
if m.clearedvms {
edges = append(edges, host.EdgeVms)
}
if m.cleareduser {
edges = append(edges, host.EdgeUser)
}
if m.clearedgroups {
edges = append(edges, host.EdgeGroups)
}
if m.clearedgit_bots {
edges = append(edges, host.EdgeGitBots)
}
if m.clearedteam_group_hosts {
edges = append(edges, host.EdgeTeamGroupHosts)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *HostMutation) EdgeCleared(name string) bool {
switch name {
case host.EdgeVms:
return m.clearedvms
case host.EdgeUser:
return m.cleareduser
case host.EdgeGroups:
return m.clearedgroups
case host.EdgeGitBots:
return m.clearedgit_bots
case host.EdgeTeamGroupHosts:
return m.clearedteam_group_hosts
}
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 *HostMutation) ClearEdge(name string) error {
switch name {
case host.EdgeUser:
m.ClearUser()
return nil
}
return fmt.Errorf("unknown Host 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 *HostMutation) ResetEdge(name string) error {
switch name {
case host.EdgeVms:
m.ResetVms()
return nil
case host.EdgeUser:
m.ResetUser()
return nil
case host.EdgeGroups:
m.ResetGroups()
return nil
case host.EdgeGitBots:
m.ResetGitBots()
return nil
case host.EdgeTeamGroupHosts:
m.ResetTeamGroupHosts()
return nil
}
return fmt.Errorf("unknown Host edge %s", name)
}
// ImageMutation represents an operation that mutates the Image nodes in the graph.
type ImageMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
name *string
remark *string
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
user *uuid.UUID
cleareduser bool
teams map[uuid.UUID]struct{}
removedteams map[uuid.UUID]struct{}
clearedteams bool
groups map[uuid.UUID]struct{}
removedgroups map[uuid.UUID]struct{}
clearedgroups bool
project_tasks map[uuid.UUID]struct{}
removedproject_tasks map[uuid.UUID]struct{}
clearedproject_tasks bool
projects map[uuid.UUID]struct{}
removedprojects map[uuid.UUID]struct{}
clearedprojects bool
team_images map[uuid.UUID]struct{}
removedteam_images map[uuid.UUID]struct{}
clearedteam_images bool
team_group_images map[uuid.UUID]struct{}
removedteam_group_images map[uuid.UUID]struct{}
clearedteam_group_images bool
done bool
oldValue func(context.Context) (*Image, error)
predicates []predicate.Image
}
var _ ent.Mutation = (*ImageMutation)(nil)
// imageOption allows management of the mutation configuration using functional options.
type imageOption func(*ImageMutation)
// newImageMutation creates new mutation for the Image entity.
func newImageMutation(c config, op Op, opts ...imageOption) *ImageMutation {
m := &ImageMutation{
config: c,
op: op,
typ: TypeImage,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withImageID sets the ID field of the mutation.
func withImageID(id uuid.UUID) imageOption {
return func(m *ImageMutation) {
var (
err error
once sync.Once
value *Image
)
m.oldValue = func(ctx context.Context) (*Image, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Image.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withImage sets the old Image of the mutation.
func withImage(node *Image) imageOption {
return func(m *ImageMutation) {
m.oldValue = func(context.Context) (*Image, 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 ImageMutation) 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 ImageMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 Image entities.
func (m *ImageMutation) SetID(id uuid.UUID) {
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 *ImageMutation) ID() (id uuid.UUID, 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 *ImageMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().Image.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *ImageMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *ImageMutation) 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 Image entity.
// If the Image 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 *ImageMutation) 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 *ImageMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[image.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *ImageMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[image.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *ImageMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, image.FieldDeletedAt)
}
// SetUserID sets the "user_id" field.
func (m *ImageMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *ImageMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the Image entity.
// If the Image 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 *ImageMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *ImageMutation) ResetUserID() {
m.user = nil
}
// SetName sets the "name" field.
func (m *ImageMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *ImageMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the Image entity.
// If the Image 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 *ImageMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldName: %w", err)
}
return oldValue.Name, nil
}
// ResetName resets all changes to the "name" field.
func (m *ImageMutation) ResetName() {
m.name = nil
}
// SetRemark sets the "remark" field.
func (m *ImageMutation) SetRemark(s string) {
m.remark = &s
}
// Remark returns the value of the "remark" field in the mutation.
func (m *ImageMutation) Remark() (r string, exists bool) {
v := m.remark
if v == nil {
return
}
return *v, true
}
// OldRemark returns the old "remark" field's value of the Image entity.
// If the Image 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 *ImageMutation) OldRemark(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRemark is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRemark requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRemark: %w", err)
}
return oldValue.Remark, nil
}
// ClearRemark clears the value of the "remark" field.
func (m *ImageMutation) ClearRemark() {
m.remark = nil
m.clearedFields[image.FieldRemark] = struct{}{}
}
// RemarkCleared returns if the "remark" field was cleared in this mutation.
func (m *ImageMutation) RemarkCleared() bool {
_, ok := m.clearedFields[image.FieldRemark]
return ok
}
// ResetRemark resets all changes to the "remark" field.
func (m *ImageMutation) ResetRemark() {
m.remark = nil
delete(m.clearedFields, image.FieldRemark)
}
// SetCreatedAt sets the "created_at" field.
func (m *ImageMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ImageMutation) 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 Image entity.
// If the Image 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 *ImageMutation) 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 *ImageMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *ImageMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *ImageMutation) 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 Image entity.
// If the Image 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 *ImageMutation) 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 *ImageMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearUser clears the "user" edge to the User entity.
func (m *ImageMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[image.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *ImageMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *ImageMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *ImageMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// AddTeamIDs adds the "teams" edge to the Team entity by ids.
func (m *ImageMutation) AddTeamIDs(ids ...uuid.UUID) {
if m.teams == nil {
m.teams = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.teams[ids[i]] = struct{}{}
}
}
// ClearTeams clears the "teams" edge to the Team entity.
func (m *ImageMutation) ClearTeams() {
m.clearedteams = true
}
// TeamsCleared reports if the "teams" edge to the Team entity was cleared.
func (m *ImageMutation) TeamsCleared() bool {
return m.clearedteams
}
// RemoveTeamIDs removes the "teams" edge to the Team entity by IDs.
func (m *ImageMutation) RemoveTeamIDs(ids ...uuid.UUID) {
if m.removedteams == nil {
m.removedteams = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.teams, ids[i])
m.removedteams[ids[i]] = struct{}{}
}
}
// RemovedTeams returns the removed IDs of the "teams" edge to the Team entity.
func (m *ImageMutation) RemovedTeamsIDs() (ids []uuid.UUID) {
for id := range m.removedteams {
ids = append(ids, id)
}
return
}
// TeamsIDs returns the "teams" edge IDs in the mutation.
func (m *ImageMutation) TeamsIDs() (ids []uuid.UUID) {
for id := range m.teams {
ids = append(ids, id)
}
return
}
// ResetTeams resets all changes to the "teams" edge.
func (m *ImageMutation) ResetTeams() {
m.teams = nil
m.clearedteams = false
m.removedteams = nil
}
// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids.
func (m *ImageMutation) AddGroupIDs(ids ...uuid.UUID) {
if m.groups == nil {
m.groups = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.groups[ids[i]] = struct{}{}
}
}
// ClearGroups clears the "groups" edge to the TeamGroup entity.
func (m *ImageMutation) ClearGroups() {
m.clearedgroups = true
}
// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared.
func (m *ImageMutation) GroupsCleared() bool {
return m.clearedgroups
}
// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs.
func (m *ImageMutation) RemoveGroupIDs(ids ...uuid.UUID) {
if m.removedgroups == nil {
m.removedgroups = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.groups, ids[i])
m.removedgroups[ids[i]] = struct{}{}
}
}
// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity.
func (m *ImageMutation) RemovedGroupsIDs() (ids []uuid.UUID) {
for id := range m.removedgroups {
ids = append(ids, id)
}
return
}
// GroupsIDs returns the "groups" edge IDs in the mutation.
func (m *ImageMutation) GroupsIDs() (ids []uuid.UUID) {
for id := range m.groups {
ids = append(ids, id)
}
return
}
// ResetGroups resets all changes to the "groups" edge.
func (m *ImageMutation) ResetGroups() {
m.groups = nil
m.clearedgroups = false
m.removedgroups = nil
}
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids.
func (m *ImageMutation) AddProjectTaskIDs(ids ...uuid.UUID) {
if m.project_tasks == nil {
m.project_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.project_tasks[ids[i]] = struct{}{}
}
}
// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity.
func (m *ImageMutation) ClearProjectTasks() {
m.clearedproject_tasks = true
}
// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared.
func (m *ImageMutation) ProjectTasksCleared() bool {
return m.clearedproject_tasks
}
// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs.
func (m *ImageMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) {
if m.removedproject_tasks == nil {
m.removedproject_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.project_tasks, ids[i])
m.removedproject_tasks[ids[i]] = struct{}{}
}
}
// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity.
func (m *ImageMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return
}
// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation.
func (m *ImageMutation) ProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.project_tasks {
ids = append(ids, id)
}
return
}
// ResetProjectTasks resets all changes to the "project_tasks" edge.
func (m *ImageMutation) ResetProjectTasks() {
m.project_tasks = nil
m.clearedproject_tasks = false
m.removedproject_tasks = nil
}
// AddProjectIDs adds the "projects" edge to the Project entity by ids.
func (m *ImageMutation) AddProjectIDs(ids ...uuid.UUID) {
if m.projects == nil {
m.projects = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.projects[ids[i]] = struct{}{}
}
}
// ClearProjects clears the "projects" edge to the Project entity.
func (m *ImageMutation) ClearProjects() {
m.clearedprojects = true
}
// ProjectsCleared reports if the "projects" edge to the Project entity was cleared.
func (m *ImageMutation) ProjectsCleared() bool {
return m.clearedprojects
}
// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs.
func (m *ImageMutation) RemoveProjectIDs(ids ...uuid.UUID) {
if m.removedprojects == nil {
m.removedprojects = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.projects, ids[i])
m.removedprojects[ids[i]] = struct{}{}
}
}
// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity.
func (m *ImageMutation) RemovedProjectsIDs() (ids []uuid.UUID) {
for id := range m.removedprojects {
ids = append(ids, id)
}
return
}
// ProjectsIDs returns the "projects" edge IDs in the mutation.
func (m *ImageMutation) ProjectsIDs() (ids []uuid.UUID) {
for id := range m.projects {
ids = append(ids, id)
}
return
}
// ResetProjects resets all changes to the "projects" edge.
func (m *ImageMutation) ResetProjects() {
m.projects = nil
m.clearedprojects = false
m.removedprojects = nil
}
// AddTeamImageIDs adds the "team_images" edge to the TeamImage entity by ids.
func (m *ImageMutation) AddTeamImageIDs(ids ...uuid.UUID) {
if m.team_images == nil {
m.team_images = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_images[ids[i]] = struct{}{}
}
}
// ClearTeamImages clears the "team_images" edge to the TeamImage entity.
func (m *ImageMutation) ClearTeamImages() {
m.clearedteam_images = true
}
// TeamImagesCleared reports if the "team_images" edge to the TeamImage entity was cleared.
func (m *ImageMutation) TeamImagesCleared() bool {
return m.clearedteam_images
}
// RemoveTeamImageIDs removes the "team_images" edge to the TeamImage entity by IDs.
func (m *ImageMutation) RemoveTeamImageIDs(ids ...uuid.UUID) {
if m.removedteam_images == nil {
m.removedteam_images = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_images, ids[i])
m.removedteam_images[ids[i]] = struct{}{}
}
}
// RemovedTeamImages returns the removed IDs of the "team_images" edge to the TeamImage entity.
func (m *ImageMutation) RemovedTeamImagesIDs() (ids []uuid.UUID) {
for id := range m.removedteam_images {
ids = append(ids, id)
}
return
}
// TeamImagesIDs returns the "team_images" edge IDs in the mutation.
func (m *ImageMutation) TeamImagesIDs() (ids []uuid.UUID) {
for id := range m.team_images {
ids = append(ids, id)
}
return
}
// ResetTeamImages resets all changes to the "team_images" edge.
func (m *ImageMutation) ResetTeamImages() {
m.team_images = nil
m.clearedteam_images = false
m.removedteam_images = nil
}
// AddTeamGroupImageIDs adds the "team_group_images" edge to the TeamGroupImage entity by ids.
func (m *ImageMutation) AddTeamGroupImageIDs(ids ...uuid.UUID) {
if m.team_group_images == nil {
m.team_group_images = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_group_images[ids[i]] = struct{}{}
}
}
// ClearTeamGroupImages clears the "team_group_images" edge to the TeamGroupImage entity.
func (m *ImageMutation) ClearTeamGroupImages() {
m.clearedteam_group_images = true
}
// TeamGroupImagesCleared reports if the "team_group_images" edge to the TeamGroupImage entity was cleared.
func (m *ImageMutation) TeamGroupImagesCleared() bool {
return m.clearedteam_group_images
}
// RemoveTeamGroupImageIDs removes the "team_group_images" edge to the TeamGroupImage entity by IDs.
func (m *ImageMutation) RemoveTeamGroupImageIDs(ids ...uuid.UUID) {
if m.removedteam_group_images == nil {
m.removedteam_group_images = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_group_images, ids[i])
m.removedteam_group_images[ids[i]] = struct{}{}
}
}
// RemovedTeamGroupImages returns the removed IDs of the "team_group_images" edge to the TeamGroupImage entity.
func (m *ImageMutation) RemovedTeamGroupImagesIDs() (ids []uuid.UUID) {
for id := range m.removedteam_group_images {
ids = append(ids, id)
}
return
}
// TeamGroupImagesIDs returns the "team_group_images" edge IDs in the mutation.
func (m *ImageMutation) TeamGroupImagesIDs() (ids []uuid.UUID) {
for id := range m.team_group_images {
ids = append(ids, id)
}
return
}
// ResetTeamGroupImages resets all changes to the "team_group_images" edge.
func (m *ImageMutation) ResetTeamGroupImages() {
m.team_group_images = nil
m.clearedteam_group_images = false
m.removedteam_group_images = nil
}
// Where appends a list predicates to the ImageMutation builder.
func (m *ImageMutation) Where(ps ...predicate.Image) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ImageMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ImageMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Image, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ImageMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ImageMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Image).
func (m *ImageMutation) 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 *ImageMutation) Fields() []string {
fields := make([]string, 0, 6)
if m.deleted_at != nil {
fields = append(fields, image.FieldDeletedAt)
}
if m.user != nil {
fields = append(fields, image.FieldUserID)
}
if m.name != nil {
fields = append(fields, image.FieldName)
}
if m.remark != nil {
fields = append(fields, image.FieldRemark)
}
if m.created_at != nil {
fields = append(fields, image.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, image.FieldUpdatedAt)
}
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 *ImageMutation) Field(name string) (ent.Value, bool) {
switch name {
case image.FieldDeletedAt:
return m.DeletedAt()
case image.FieldUserID:
return m.UserID()
case image.FieldName:
return m.Name()
case image.FieldRemark:
return m.Remark()
case image.FieldCreatedAt:
return m.CreatedAt()
case image.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *ImageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case image.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case image.FieldUserID:
return m.OldUserID(ctx)
case image.FieldName:
return m.OldName(ctx)
case image.FieldRemark:
return m.OldRemark(ctx)
case image.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case image.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown Image 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 *ImageMutation) SetField(name string, value ent.Value) error {
switch name {
case image.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 image.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case image.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case image.FieldRemark:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRemark(v)
return nil
case image.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 image.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown Image field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ImageMutation) AddedFields() []string {
return nil
}
// 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 *ImageMutation) AddedField(name string) (ent.Value, bool) {
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 *ImageMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown Image numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ImageMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(image.FieldDeletedAt) {
fields = append(fields, image.FieldDeletedAt)
}
if m.FieldCleared(image.FieldRemark) {
fields = append(fields, image.FieldRemark)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ImageMutation) 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 *ImageMutation) ClearField(name string) error {
switch name {
case image.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case image.FieldRemark:
m.ClearRemark()
return nil
}
return fmt.Errorf("unknown Image 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 *ImageMutation) ResetField(name string) error {
switch name {
case image.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case image.FieldUserID:
m.ResetUserID()
return nil
case image.FieldName:
m.ResetName()
return nil
case image.FieldRemark:
m.ResetRemark()
return nil
case image.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case image.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown Image field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ImageMutation) AddedEdges() []string {
edges := make([]string, 0, 7)
if m.user != nil {
edges = append(edges, image.EdgeUser)
}
if m.teams != nil {
edges = append(edges, image.EdgeTeams)
}
if m.groups != nil {
edges = append(edges, image.EdgeGroups)
}
if m.project_tasks != nil {
edges = append(edges, image.EdgeProjectTasks)
}
if m.projects != nil {
edges = append(edges, image.EdgeProjects)
}
if m.team_images != nil {
edges = append(edges, image.EdgeTeamImages)
}
if m.team_group_images != nil {
edges = append(edges, image.EdgeTeamGroupImages)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ImageMutation) AddedIDs(name string) []ent.Value {
switch name {
case image.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
case image.EdgeTeams:
ids := make([]ent.Value, 0, len(m.teams))
for id := range m.teams {
ids = append(ids, id)
}
return ids
case image.EdgeGroups:
ids := make([]ent.Value, 0, len(m.groups))
for id := range m.groups {
ids = append(ids, id)
}
return ids
case image.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.project_tasks))
for id := range m.project_tasks {
ids = append(ids, id)
}
return ids
case image.EdgeProjects:
ids := make([]ent.Value, 0, len(m.projects))
for id := range m.projects {
ids = append(ids, id)
}
return ids
case image.EdgeTeamImages:
ids := make([]ent.Value, 0, len(m.team_images))
for id := range m.team_images {
ids = append(ids, id)
}
return ids
case image.EdgeTeamGroupImages:
ids := make([]ent.Value, 0, len(m.team_group_images))
for id := range m.team_group_images {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ImageMutation) RemovedEdges() []string {
edges := make([]string, 0, 7)
if m.removedteams != nil {
edges = append(edges, image.EdgeTeams)
}
if m.removedgroups != nil {
edges = append(edges, image.EdgeGroups)
}
if m.removedproject_tasks != nil {
edges = append(edges, image.EdgeProjectTasks)
}
if m.removedprojects != nil {
edges = append(edges, image.EdgeProjects)
}
if m.removedteam_images != nil {
edges = append(edges, image.EdgeTeamImages)
}
if m.removedteam_group_images != nil {
edges = append(edges, image.EdgeTeamGroupImages)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ImageMutation) RemovedIDs(name string) []ent.Value {
switch name {
case image.EdgeTeams:
ids := make([]ent.Value, 0, len(m.removedteams))
for id := range m.removedteams {
ids = append(ids, id)
}
return ids
case image.EdgeGroups:
ids := make([]ent.Value, 0, len(m.removedgroups))
for id := range m.removedgroups {
ids = append(ids, id)
}
return ids
case image.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.removedproject_tasks))
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return ids
case image.EdgeProjects:
ids := make([]ent.Value, 0, len(m.removedprojects))
for id := range m.removedprojects {
ids = append(ids, id)
}
return ids
case image.EdgeTeamImages:
ids := make([]ent.Value, 0, len(m.removedteam_images))
for id := range m.removedteam_images {
ids = append(ids, id)
}
return ids
case image.EdgeTeamGroupImages:
ids := make([]ent.Value, 0, len(m.removedteam_group_images))
for id := range m.removedteam_group_images {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ImageMutation) ClearedEdges() []string {
edges := make([]string, 0, 7)
if m.cleareduser {
edges = append(edges, image.EdgeUser)
}
if m.clearedteams {
edges = append(edges, image.EdgeTeams)
}
if m.clearedgroups {
edges = append(edges, image.EdgeGroups)
}
if m.clearedproject_tasks {
edges = append(edges, image.EdgeProjectTasks)
}
if m.clearedprojects {
edges = append(edges, image.EdgeProjects)
}
if m.clearedteam_images {
edges = append(edges, image.EdgeTeamImages)
}
if m.clearedteam_group_images {
edges = append(edges, image.EdgeTeamGroupImages)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ImageMutation) EdgeCleared(name string) bool {
switch name {
case image.EdgeUser:
return m.cleareduser
case image.EdgeTeams:
return m.clearedteams
case image.EdgeGroups:
return m.clearedgroups
case image.EdgeProjectTasks:
return m.clearedproject_tasks
case image.EdgeProjects:
return m.clearedprojects
case image.EdgeTeamImages:
return m.clearedteam_images
case image.EdgeTeamGroupImages:
return m.clearedteam_group_images
}
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 *ImageMutation) ClearEdge(name string) error {
switch name {
case image.EdgeUser:
m.ClearUser()
return nil
}
return fmt.Errorf("unknown Image 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 *ImageMutation) ResetEdge(name string) error {
switch name {
case image.EdgeUser:
m.ResetUser()
return nil
case image.EdgeTeams:
m.ResetTeams()
return nil
case image.EdgeGroups:
m.ResetGroups()
return nil
case image.EdgeProjectTasks:
m.ResetProjectTasks()
return nil
case image.EdgeProjects:
m.ResetProjects()
return nil
case image.EdgeTeamImages:
m.ResetTeamImages()
return nil
case image.EdgeTeamGroupImages:
m.ResetTeamGroupImages()
return nil
}
return fmt.Errorf("unknown Image edge %s", name)
}
// MCPToolMutation represents an operation that mutates the MCPTool nodes in the graph.
type MCPToolMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
name *string
namespaced_name *string
scope *mcptool.Scope
user_id *uuid.UUID
description *string
input_schema *map[string]interface{}
price *int64
addprice *int64
enabled *bool
version_hash *string
synced_at *time.Time
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
upstream *uuid.UUID
clearedupstream bool
done bool
oldValue func(context.Context) (*MCPTool, error)
predicates []predicate.MCPTool
}
var _ ent.Mutation = (*MCPToolMutation)(nil)
// mcptoolOption allows management of the mutation configuration using functional options.
type mcptoolOption func(*MCPToolMutation)
// newMCPToolMutation creates new mutation for the MCPTool entity.
func newMCPToolMutation(c config, op Op, opts ...mcptoolOption) *MCPToolMutation {
m := &MCPToolMutation{
config: c,
op: op,
typ: TypeMCPTool,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withMCPToolID sets the ID field of the mutation.
func withMCPToolID(id uuid.UUID) mcptoolOption {
return func(m *MCPToolMutation) {
var (
err error
once sync.Once
value *MCPTool
)
m.oldValue = func(ctx context.Context) (*MCPTool, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().MCPTool.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withMCPTool sets the old MCPTool of the mutation.
func withMCPTool(node *MCPTool) mcptoolOption {
return func(m *MCPToolMutation) {
m.oldValue = func(context.Context) (*MCPTool, 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 MCPToolMutation) 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 MCPToolMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 MCPTool entities.
func (m *MCPToolMutation) SetID(id uuid.UUID) {
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 *MCPToolMutation) ID() (id uuid.UUID, 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 *MCPToolMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().MCPTool.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *MCPToolMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *MCPToolMutation) 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 MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) 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 *MCPToolMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[mcptool.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *MCPToolMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[mcptool.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *MCPToolMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, mcptool.FieldDeletedAt)
}
// SetUpstreamID sets the "upstream_id" field.
func (m *MCPToolMutation) SetUpstreamID(u uuid.UUID) {
m.upstream = &u
}
// UpstreamID returns the value of the "upstream_id" field in the mutation.
func (m *MCPToolMutation) UpstreamID() (r uuid.UUID, exists bool) {
v := m.upstream
if v == nil {
return
}
return *v, true
}
// OldUpstreamID returns the old "upstream_id" field's value of the MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) OldUpstreamID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUpstreamID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUpstreamID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUpstreamID: %w", err)
}
return oldValue.UpstreamID, nil
}
// ResetUpstreamID resets all changes to the "upstream_id" field.
func (m *MCPToolMutation) ResetUpstreamID() {
m.upstream = nil
}
// SetName sets the "name" field.
func (m *MCPToolMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *MCPToolMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldName: %w", err)
}
return oldValue.Name, nil
}
// ResetName resets all changes to the "name" field.
func (m *MCPToolMutation) ResetName() {
m.name = nil
}
// SetNamespacedName sets the "namespaced_name" field.
func (m *MCPToolMutation) SetNamespacedName(s string) {
m.namespaced_name = &s
}
// NamespacedName returns the value of the "namespaced_name" field in the mutation.
func (m *MCPToolMutation) NamespacedName() (r string, exists bool) {
v := m.namespaced_name
if v == nil {
return
}
return *v, true
}
// OldNamespacedName returns the old "namespaced_name" field's value of the MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) OldNamespacedName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldNamespacedName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldNamespacedName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNamespacedName: %w", err)
}
return oldValue.NamespacedName, nil
}
// ResetNamespacedName resets all changes to the "namespaced_name" field.
func (m *MCPToolMutation) ResetNamespacedName() {
m.namespaced_name = nil
}
// SetScope sets the "scope" field.
func (m *MCPToolMutation) SetScope(value mcptool.Scope) {
m.scope = &value
}
// Scope returns the value of the "scope" field in the mutation.
func (m *MCPToolMutation) Scope() (r mcptool.Scope, exists bool) {
v := m.scope
if v == nil {
return
}
return *v, true
}
// OldScope returns the old "scope" field's value of the MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) OldScope(ctx context.Context) (v mcptool.Scope, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldScope is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldScope requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldScope: %w", err)
}
return oldValue.Scope, nil
}
// ResetScope resets all changes to the "scope" field.
func (m *MCPToolMutation) ResetScope() {
m.scope = nil
}
// SetUserID sets the "user_id" field.
func (m *MCPToolMutation) SetUserID(u uuid.UUID) {
m.user_id = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *MCPToolMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user_id
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) OldUserID(ctx context.Context) (v *uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ClearUserID clears the value of the "user_id" field.
func (m *MCPToolMutation) ClearUserID() {
m.user_id = nil
m.clearedFields[mcptool.FieldUserID] = struct{}{}
}
// UserIDCleared returns if the "user_id" field was cleared in this mutation.
func (m *MCPToolMutation) UserIDCleared() bool {
_, ok := m.clearedFields[mcptool.FieldUserID]
return ok
}
// ResetUserID resets all changes to the "user_id" field.
func (m *MCPToolMutation) ResetUserID() {
m.user_id = nil
delete(m.clearedFields, mcptool.FieldUserID)
}
// SetDescription sets the "description" field.
func (m *MCPToolMutation) SetDescription(s string) {
m.description = &s
}
// Description returns the value of the "description" field in the mutation.
func (m *MCPToolMutation) Description() (r string, exists bool) {
v := m.description
if v == nil {
return
}
return *v, true
}
// OldDescription returns the old "description" field's value of the MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) OldDescription(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDescription is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldDescription requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDescription: %w", err)
}
return oldValue.Description, nil
}
// ClearDescription clears the value of the "description" field.
func (m *MCPToolMutation) ClearDescription() {
m.description = nil
m.clearedFields[mcptool.FieldDescription] = struct{}{}
}
// DescriptionCleared returns if the "description" field was cleared in this mutation.
func (m *MCPToolMutation) DescriptionCleared() bool {
_, ok := m.clearedFields[mcptool.FieldDescription]
return ok
}
// ResetDescription resets all changes to the "description" field.
func (m *MCPToolMutation) ResetDescription() {
m.description = nil
delete(m.clearedFields, mcptool.FieldDescription)
}
// SetInputSchema sets the "input_schema" field.
func (m *MCPToolMutation) SetInputSchema(value map[string]interface{}) {
m.input_schema = &value
}
// InputSchema returns the value of the "input_schema" field in the mutation.
func (m *MCPToolMutation) InputSchema() (r map[string]interface{}, exists bool) {
v := m.input_schema
if v == nil {
return
}
return *v, true
}
// OldInputSchema returns the old "input_schema" field's value of the MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) OldInputSchema(ctx context.Context) (v map[string]interface{}, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldInputSchema is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldInputSchema requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInputSchema: %w", err)
}
return oldValue.InputSchema, nil
}
// ClearInputSchema clears the value of the "input_schema" field.
func (m *MCPToolMutation) ClearInputSchema() {
m.input_schema = nil
m.clearedFields[mcptool.FieldInputSchema] = struct{}{}
}
// InputSchemaCleared returns if the "input_schema" field was cleared in this mutation.
func (m *MCPToolMutation) InputSchemaCleared() bool {
_, ok := m.clearedFields[mcptool.FieldInputSchema]
return ok
}
// ResetInputSchema resets all changes to the "input_schema" field.
func (m *MCPToolMutation) ResetInputSchema() {
m.input_schema = nil
delete(m.clearedFields, mcptool.FieldInputSchema)
}
// SetPrice sets the "price" field.
func (m *MCPToolMutation) SetPrice(i int64) {
m.price = &i
m.addprice = nil
}
// Price returns the value of the "price" field in the mutation.
func (m *MCPToolMutation) Price() (r int64, exists bool) {
v := m.price
if v == nil {
return
}
return *v, true
}
// OldPrice returns the old "price" field's value of the MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) OldPrice(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPrice is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPrice requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPrice: %w", err)
}
return oldValue.Price, nil
}
// AddPrice adds i to the "price" field.
func (m *MCPToolMutation) AddPrice(i int64) {
if m.addprice != nil {
*m.addprice += i
} else {
m.addprice = &i
}
}
// AddedPrice returns the value that was added to the "price" field in this mutation.
func (m *MCPToolMutation) AddedPrice() (r int64, exists bool) {
v := m.addprice
if v == nil {
return
}
return *v, true
}
// ResetPrice resets all changes to the "price" field.
func (m *MCPToolMutation) ResetPrice() {
m.price = nil
m.addprice = nil
}
// SetEnabled sets the "enabled" field.
func (m *MCPToolMutation) SetEnabled(b bool) {
m.enabled = &b
}
// Enabled returns the value of the "enabled" field in the mutation.
func (m *MCPToolMutation) Enabled() (r bool, exists bool) {
v := m.enabled
if v == nil {
return
}
return *v, true
}
// OldEnabled returns the old "enabled" field's value of the MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) OldEnabled(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEnabled requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
}
return oldValue.Enabled, nil
}
// ResetEnabled resets all changes to the "enabled" field.
func (m *MCPToolMutation) ResetEnabled() {
m.enabled = nil
}
// SetVersionHash sets the "version_hash" field.
func (m *MCPToolMutation) SetVersionHash(s string) {
m.version_hash = &s
}
// VersionHash returns the value of the "version_hash" field in the mutation.
func (m *MCPToolMutation) VersionHash() (r string, exists bool) {
v := m.version_hash
if v == nil {
return
}
return *v, true
}
// OldVersionHash returns the old "version_hash" field's value of the MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) OldVersionHash(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldVersionHash is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldVersionHash requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldVersionHash: %w", err)
}
return oldValue.VersionHash, nil
}
// ClearVersionHash clears the value of the "version_hash" field.
func (m *MCPToolMutation) ClearVersionHash() {
m.version_hash = nil
m.clearedFields[mcptool.FieldVersionHash] = struct{}{}
}
// VersionHashCleared returns if the "version_hash" field was cleared in this mutation.
func (m *MCPToolMutation) VersionHashCleared() bool {
_, ok := m.clearedFields[mcptool.FieldVersionHash]
return ok
}
// ResetVersionHash resets all changes to the "version_hash" field.
func (m *MCPToolMutation) ResetVersionHash() {
m.version_hash = nil
delete(m.clearedFields, mcptool.FieldVersionHash)
}
// SetSyncedAt sets the "synced_at" field.
func (m *MCPToolMutation) SetSyncedAt(t time.Time) {
m.synced_at = &t
}
// SyncedAt returns the value of the "synced_at" field in the mutation.
func (m *MCPToolMutation) SyncedAt() (r time.Time, exists bool) {
v := m.synced_at
if v == nil {
return
}
return *v, true
}
// OldSyncedAt returns the old "synced_at" field's value of the MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) OldSyncedAt(ctx context.Context) (v *time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSyncedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSyncedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSyncedAt: %w", err)
}
return oldValue.SyncedAt, nil
}
// ClearSyncedAt clears the value of the "synced_at" field.
func (m *MCPToolMutation) ClearSyncedAt() {
m.synced_at = nil
m.clearedFields[mcptool.FieldSyncedAt] = struct{}{}
}
// SyncedAtCleared returns if the "synced_at" field was cleared in this mutation.
func (m *MCPToolMutation) SyncedAtCleared() bool {
_, ok := m.clearedFields[mcptool.FieldSyncedAt]
return ok
}
// ResetSyncedAt resets all changes to the "synced_at" field.
func (m *MCPToolMutation) ResetSyncedAt() {
m.synced_at = nil
delete(m.clearedFields, mcptool.FieldSyncedAt)
}
// SetCreatedAt sets the "created_at" field.
func (m *MCPToolMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *MCPToolMutation) 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 MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) 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 *MCPToolMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *MCPToolMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *MCPToolMutation) 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 MCPTool entity.
// If the MCPTool 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 *MCPToolMutation) 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 *MCPToolMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearUpstream clears the "upstream" edge to the MCPUpstream entity.
func (m *MCPToolMutation) ClearUpstream() {
m.clearedupstream = true
m.clearedFields[mcptool.FieldUpstreamID] = struct{}{}
}
// UpstreamCleared reports if the "upstream" edge to the MCPUpstream entity was cleared.
func (m *MCPToolMutation) UpstreamCleared() bool {
return m.clearedupstream
}
// UpstreamIDs returns the "upstream" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UpstreamID instead. It exists only for internal usage by the builders.
func (m *MCPToolMutation) UpstreamIDs() (ids []uuid.UUID) {
if id := m.upstream; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUpstream resets all changes to the "upstream" edge.
func (m *MCPToolMutation) ResetUpstream() {
m.upstream = nil
m.clearedupstream = false
}
// Where appends a list predicates to the MCPToolMutation builder.
func (m *MCPToolMutation) Where(ps ...predicate.MCPTool) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the MCPToolMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *MCPToolMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.MCPTool, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *MCPToolMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *MCPToolMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (MCPTool).
func (m *MCPToolMutation) 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 *MCPToolMutation) Fields() []string {
fields := make([]string, 0, 14)
if m.deleted_at != nil {
fields = append(fields, mcptool.FieldDeletedAt)
}
if m.upstream != nil {
fields = append(fields, mcptool.FieldUpstreamID)
}
if m.name != nil {
fields = append(fields, mcptool.FieldName)
}
if m.namespaced_name != nil {
fields = append(fields, mcptool.FieldNamespacedName)
}
if m.scope != nil {
fields = append(fields, mcptool.FieldScope)
}
if m.user_id != nil {
fields = append(fields, mcptool.FieldUserID)
}
if m.description != nil {
fields = append(fields, mcptool.FieldDescription)
}
if m.input_schema != nil {
fields = append(fields, mcptool.FieldInputSchema)
}
if m.price != nil {
fields = append(fields, mcptool.FieldPrice)
}
if m.enabled != nil {
fields = append(fields, mcptool.FieldEnabled)
}
if m.version_hash != nil {
fields = append(fields, mcptool.FieldVersionHash)
}
if m.synced_at != nil {
fields = append(fields, mcptool.FieldSyncedAt)
}
if m.created_at != nil {
fields = append(fields, mcptool.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, mcptool.FieldUpdatedAt)
}
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 *MCPToolMutation) Field(name string) (ent.Value, bool) {
switch name {
case mcptool.FieldDeletedAt:
return m.DeletedAt()
case mcptool.FieldUpstreamID:
return m.UpstreamID()
case mcptool.FieldName:
return m.Name()
case mcptool.FieldNamespacedName:
return m.NamespacedName()
case mcptool.FieldScope:
return m.Scope()
case mcptool.FieldUserID:
return m.UserID()
case mcptool.FieldDescription:
return m.Description()
case mcptool.FieldInputSchema:
return m.InputSchema()
case mcptool.FieldPrice:
return m.Price()
case mcptool.FieldEnabled:
return m.Enabled()
case mcptool.FieldVersionHash:
return m.VersionHash()
case mcptool.FieldSyncedAt:
return m.SyncedAt()
case mcptool.FieldCreatedAt:
return m.CreatedAt()
case mcptool.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *MCPToolMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case mcptool.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case mcptool.FieldUpstreamID:
return m.OldUpstreamID(ctx)
case mcptool.FieldName:
return m.OldName(ctx)
case mcptool.FieldNamespacedName:
return m.OldNamespacedName(ctx)
case mcptool.FieldScope:
return m.OldScope(ctx)
case mcptool.FieldUserID:
return m.OldUserID(ctx)
case mcptool.FieldDescription:
return m.OldDescription(ctx)
case mcptool.FieldInputSchema:
return m.OldInputSchema(ctx)
case mcptool.FieldPrice:
return m.OldPrice(ctx)
case mcptool.FieldEnabled:
return m.OldEnabled(ctx)
case mcptool.FieldVersionHash:
return m.OldVersionHash(ctx)
case mcptool.FieldSyncedAt:
return m.OldSyncedAt(ctx)
case mcptool.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case mcptool.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown MCPTool 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 *MCPToolMutation) SetField(name string, value ent.Value) error {
switch name {
case mcptool.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 mcptool.FieldUpstreamID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpstreamID(v)
return nil
case mcptool.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case mcptool.FieldNamespacedName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetNamespacedName(v)
return nil
case mcptool.FieldScope:
v, ok := value.(mcptool.Scope)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetScope(v)
return nil
case mcptool.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case mcptool.FieldDescription:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDescription(v)
return nil
case mcptool.FieldInputSchema:
v, ok := value.(map[string]interface{})
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetInputSchema(v)
return nil
case mcptool.FieldPrice:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPrice(v)
return nil
case mcptool.FieldEnabled:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEnabled(v)
return nil
case mcptool.FieldVersionHash:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetVersionHash(v)
return nil
case mcptool.FieldSyncedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSyncedAt(v)
return nil
case mcptool.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 mcptool.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown MCPTool field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *MCPToolMutation) AddedFields() []string {
var fields []string
if m.addprice != nil {
fields = append(fields, mcptool.FieldPrice)
}
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 *MCPToolMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case mcptool.FieldPrice:
return m.AddedPrice()
}
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 *MCPToolMutation) AddField(name string, value ent.Value) error {
switch name {
case mcptool.FieldPrice:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddPrice(v)
return nil
}
return fmt.Errorf("unknown MCPTool numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *MCPToolMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(mcptool.FieldDeletedAt) {
fields = append(fields, mcptool.FieldDeletedAt)
}
if m.FieldCleared(mcptool.FieldUserID) {
fields = append(fields, mcptool.FieldUserID)
}
if m.FieldCleared(mcptool.FieldDescription) {
fields = append(fields, mcptool.FieldDescription)
}
if m.FieldCleared(mcptool.FieldInputSchema) {
fields = append(fields, mcptool.FieldInputSchema)
}
if m.FieldCleared(mcptool.FieldVersionHash) {
fields = append(fields, mcptool.FieldVersionHash)
}
if m.FieldCleared(mcptool.FieldSyncedAt) {
fields = append(fields, mcptool.FieldSyncedAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *MCPToolMutation) 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 *MCPToolMutation) ClearField(name string) error {
switch name {
case mcptool.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case mcptool.FieldUserID:
m.ClearUserID()
return nil
case mcptool.FieldDescription:
m.ClearDescription()
return nil
case mcptool.FieldInputSchema:
m.ClearInputSchema()
return nil
case mcptool.FieldVersionHash:
m.ClearVersionHash()
return nil
case mcptool.FieldSyncedAt:
m.ClearSyncedAt()
return nil
}
return fmt.Errorf("unknown MCPTool 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 *MCPToolMutation) ResetField(name string) error {
switch name {
case mcptool.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case mcptool.FieldUpstreamID:
m.ResetUpstreamID()
return nil
case mcptool.FieldName:
m.ResetName()
return nil
case mcptool.FieldNamespacedName:
m.ResetNamespacedName()
return nil
case mcptool.FieldScope:
m.ResetScope()
return nil
case mcptool.FieldUserID:
m.ResetUserID()
return nil
case mcptool.FieldDescription:
m.ResetDescription()
return nil
case mcptool.FieldInputSchema:
m.ResetInputSchema()
return nil
case mcptool.FieldPrice:
m.ResetPrice()
return nil
case mcptool.FieldEnabled:
m.ResetEnabled()
return nil
case mcptool.FieldVersionHash:
m.ResetVersionHash()
return nil
case mcptool.FieldSyncedAt:
m.ResetSyncedAt()
return nil
case mcptool.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case mcptool.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown MCPTool field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *MCPToolMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.upstream != nil {
edges = append(edges, mcptool.EdgeUpstream)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *MCPToolMutation) AddedIDs(name string) []ent.Value {
switch name {
case mcptool.EdgeUpstream:
if id := m.upstream; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *MCPToolMutation) 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 *MCPToolMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *MCPToolMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedupstream {
edges = append(edges, mcptool.EdgeUpstream)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *MCPToolMutation) EdgeCleared(name string) bool {
switch name {
case mcptool.EdgeUpstream:
return m.clearedupstream
}
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 *MCPToolMutation) ClearEdge(name string) error {
switch name {
case mcptool.EdgeUpstream:
m.ClearUpstream()
return nil
}
return fmt.Errorf("unknown MCPTool 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 *MCPToolMutation) ResetEdge(name string) error {
switch name {
case mcptool.EdgeUpstream:
m.ResetUpstream()
return nil
}
return fmt.Errorf("unknown MCPTool edge %s", name)
}
// MCPUpstreamMutation represents an operation that mutates the MCPUpstream nodes in the graph.
type MCPUpstreamMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
name *string
slug *string
scope *mcpupstream.Scope
_type *string
url *string
headers *map[string]string
description *string
enabled *bool
health_status *string
sync_status *string
health_checked_at *time.Time
last_synced_at *time.Time
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
tools map[uuid.UUID]struct{}
removedtools map[uuid.UUID]struct{}
clearedtools bool
user *uuid.UUID
cleareduser bool
done bool
oldValue func(context.Context) (*MCPUpstream, error)
predicates []predicate.MCPUpstream
}
var _ ent.Mutation = (*MCPUpstreamMutation)(nil)
// mcpupstreamOption allows management of the mutation configuration using functional options.
type mcpupstreamOption func(*MCPUpstreamMutation)
// newMCPUpstreamMutation creates new mutation for the MCPUpstream entity.
func newMCPUpstreamMutation(c config, op Op, opts ...mcpupstreamOption) *MCPUpstreamMutation {
m := &MCPUpstreamMutation{
config: c,
op: op,
typ: TypeMCPUpstream,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withMCPUpstreamID sets the ID field of the mutation.
func withMCPUpstreamID(id uuid.UUID) mcpupstreamOption {
return func(m *MCPUpstreamMutation) {
var (
err error
once sync.Once
value *MCPUpstream
)
m.oldValue = func(ctx context.Context) (*MCPUpstream, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().MCPUpstream.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withMCPUpstream sets the old MCPUpstream of the mutation.
func withMCPUpstream(node *MCPUpstream) mcpupstreamOption {
return func(m *MCPUpstreamMutation) {
m.oldValue = func(context.Context) (*MCPUpstream, 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 MCPUpstreamMutation) 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 MCPUpstreamMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 MCPUpstream entities.
func (m *MCPUpstreamMutation) SetID(id uuid.UUID) {
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 *MCPUpstreamMutation) ID() (id uuid.UUID, 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 *MCPUpstreamMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().MCPUpstream.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *MCPUpstreamMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *MCPUpstreamMutation) 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 MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) 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 *MCPUpstreamMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[mcpupstream.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *MCPUpstreamMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[mcpupstream.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *MCPUpstreamMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, mcpupstream.FieldDeletedAt)
}
// SetName sets the "name" field.
func (m *MCPUpstreamMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *MCPUpstreamMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldName: %w", err)
}
return oldValue.Name, nil
}
// ResetName resets all changes to the "name" field.
func (m *MCPUpstreamMutation) ResetName() {
m.name = nil
}
// SetSlug sets the "slug" field.
func (m *MCPUpstreamMutation) SetSlug(s string) {
m.slug = &s
}
// Slug returns the value of the "slug" field in the mutation.
func (m *MCPUpstreamMutation) Slug() (r string, exists bool) {
v := m.slug
if v == nil {
return
}
return *v, true
}
// OldSlug returns the old "slug" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldSlug(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSlug is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSlug requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSlug: %w", err)
}
return oldValue.Slug, nil
}
// ResetSlug resets all changes to the "slug" field.
func (m *MCPUpstreamMutation) ResetSlug() {
m.slug = nil
}
// SetScope sets the "scope" field.
func (m *MCPUpstreamMutation) SetScope(value mcpupstream.Scope) {
m.scope = &value
}
// Scope returns the value of the "scope" field in the mutation.
func (m *MCPUpstreamMutation) Scope() (r mcpupstream.Scope, exists bool) {
v := m.scope
if v == nil {
return
}
return *v, true
}
// OldScope returns the old "scope" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldScope(ctx context.Context) (v mcpupstream.Scope, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldScope is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldScope requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldScope: %w", err)
}
return oldValue.Scope, nil
}
// ResetScope resets all changes to the "scope" field.
func (m *MCPUpstreamMutation) ResetScope() {
m.scope = nil
}
// SetUserID sets the "user_id" field.
func (m *MCPUpstreamMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *MCPUpstreamMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldUserID(ctx context.Context) (v *uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ClearUserID clears the value of the "user_id" field.
func (m *MCPUpstreamMutation) ClearUserID() {
m.user = nil
m.clearedFields[mcpupstream.FieldUserID] = struct{}{}
}
// UserIDCleared returns if the "user_id" field was cleared in this mutation.
func (m *MCPUpstreamMutation) UserIDCleared() bool {
_, ok := m.clearedFields[mcpupstream.FieldUserID]
return ok
}
// ResetUserID resets all changes to the "user_id" field.
func (m *MCPUpstreamMutation) ResetUserID() {
m.user = nil
delete(m.clearedFields, mcpupstream.FieldUserID)
}
// SetType sets the "type" field.
func (m *MCPUpstreamMutation) SetType(s string) {
m._type = &s
}
// GetType returns the value of the "type" field in the mutation.
func (m *MCPUpstreamMutation) GetType() (r string, exists bool) {
v := m._type
if v == nil {
return
}
return *v, true
}
// OldType returns the old "type" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldType(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldType is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldType requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldType: %w", err)
}
return oldValue.Type, nil
}
// ResetType resets all changes to the "type" field.
func (m *MCPUpstreamMutation) ResetType() {
m._type = nil
}
// SetURL sets the "url" field.
func (m *MCPUpstreamMutation) SetURL(s string) {
m.url = &s
}
// URL returns the value of the "url" field in the mutation.
func (m *MCPUpstreamMutation) URL() (r string, exists bool) {
v := m.url
if v == nil {
return
}
return *v, true
}
// OldURL returns the old "url" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldURL: %w", err)
}
return oldValue.URL, nil
}
// ResetURL resets all changes to the "url" field.
func (m *MCPUpstreamMutation) ResetURL() {
m.url = nil
}
// SetHeaders sets the "headers" field.
func (m *MCPUpstreamMutation) SetHeaders(value map[string]string) {
m.headers = &value
}
// Headers returns the value of the "headers" field in the mutation.
func (m *MCPUpstreamMutation) Headers() (r map[string]string, exists bool) {
v := m.headers
if v == nil {
return
}
return *v, true
}
// OldHeaders returns the old "headers" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldHeaders(ctx context.Context) (v map[string]string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHeaders is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHeaders requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHeaders: %w", err)
}
return oldValue.Headers, nil
}
// ClearHeaders clears the value of the "headers" field.
func (m *MCPUpstreamMutation) ClearHeaders() {
m.headers = nil
m.clearedFields[mcpupstream.FieldHeaders] = struct{}{}
}
// HeadersCleared returns if the "headers" field was cleared in this mutation.
func (m *MCPUpstreamMutation) HeadersCleared() bool {
_, ok := m.clearedFields[mcpupstream.FieldHeaders]
return ok
}
// ResetHeaders resets all changes to the "headers" field.
func (m *MCPUpstreamMutation) ResetHeaders() {
m.headers = nil
delete(m.clearedFields, mcpupstream.FieldHeaders)
}
// SetDescription sets the "description" field.
func (m *MCPUpstreamMutation) SetDescription(s string) {
m.description = &s
}
// Description returns the value of the "description" field in the mutation.
func (m *MCPUpstreamMutation) Description() (r string, exists bool) {
v := m.description
if v == nil {
return
}
return *v, true
}
// OldDescription returns the old "description" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldDescription(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDescription is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldDescription requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDescription: %w", err)
}
return oldValue.Description, nil
}
// ClearDescription clears the value of the "description" field.
func (m *MCPUpstreamMutation) ClearDescription() {
m.description = nil
m.clearedFields[mcpupstream.FieldDescription] = struct{}{}
}
// DescriptionCleared returns if the "description" field was cleared in this mutation.
func (m *MCPUpstreamMutation) DescriptionCleared() bool {
_, ok := m.clearedFields[mcpupstream.FieldDescription]
return ok
}
// ResetDescription resets all changes to the "description" field.
func (m *MCPUpstreamMutation) ResetDescription() {
m.description = nil
delete(m.clearedFields, mcpupstream.FieldDescription)
}
// SetEnabled sets the "enabled" field.
func (m *MCPUpstreamMutation) SetEnabled(b bool) {
m.enabled = &b
}
// Enabled returns the value of the "enabled" field in the mutation.
func (m *MCPUpstreamMutation) Enabled() (r bool, exists bool) {
v := m.enabled
if v == nil {
return
}
return *v, true
}
// OldEnabled returns the old "enabled" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldEnabled(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEnabled requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
}
return oldValue.Enabled, nil
}
// ResetEnabled resets all changes to the "enabled" field.
func (m *MCPUpstreamMutation) ResetEnabled() {
m.enabled = nil
}
// SetHealthStatus sets the "health_status" field.
func (m *MCPUpstreamMutation) SetHealthStatus(s string) {
m.health_status = &s
}
// HealthStatus returns the value of the "health_status" field in the mutation.
func (m *MCPUpstreamMutation) HealthStatus() (r string, exists bool) {
v := m.health_status
if v == nil {
return
}
return *v, true
}
// OldHealthStatus returns the old "health_status" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldHealthStatus(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHealthStatus is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHealthStatus requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHealthStatus: %w", err)
}
return oldValue.HealthStatus, nil
}
// ResetHealthStatus resets all changes to the "health_status" field.
func (m *MCPUpstreamMutation) ResetHealthStatus() {
m.health_status = nil
}
// SetSyncStatus sets the "sync_status" field.
func (m *MCPUpstreamMutation) SetSyncStatus(s string) {
m.sync_status = &s
}
// SyncStatus returns the value of the "sync_status" field in the mutation.
func (m *MCPUpstreamMutation) SyncStatus() (r string, exists bool) {
v := m.sync_status
if v == nil {
return
}
return *v, true
}
// OldSyncStatus returns the old "sync_status" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldSyncStatus(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSyncStatus is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSyncStatus requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSyncStatus: %w", err)
}
return oldValue.SyncStatus, nil
}
// ResetSyncStatus resets all changes to the "sync_status" field.
func (m *MCPUpstreamMutation) ResetSyncStatus() {
m.sync_status = nil
}
// SetHealthCheckedAt sets the "health_checked_at" field.
func (m *MCPUpstreamMutation) SetHealthCheckedAt(t time.Time) {
m.health_checked_at = &t
}
// HealthCheckedAt returns the value of the "health_checked_at" field in the mutation.
func (m *MCPUpstreamMutation) HealthCheckedAt() (r time.Time, exists bool) {
v := m.health_checked_at
if v == nil {
return
}
return *v, true
}
// OldHealthCheckedAt returns the old "health_checked_at" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldHealthCheckedAt(ctx context.Context) (v *time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHealthCheckedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHealthCheckedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHealthCheckedAt: %w", err)
}
return oldValue.HealthCheckedAt, nil
}
// ClearHealthCheckedAt clears the value of the "health_checked_at" field.
func (m *MCPUpstreamMutation) ClearHealthCheckedAt() {
m.health_checked_at = nil
m.clearedFields[mcpupstream.FieldHealthCheckedAt] = struct{}{}
}
// HealthCheckedAtCleared returns if the "health_checked_at" field was cleared in this mutation.
func (m *MCPUpstreamMutation) HealthCheckedAtCleared() bool {
_, ok := m.clearedFields[mcpupstream.FieldHealthCheckedAt]
return ok
}
// ResetHealthCheckedAt resets all changes to the "health_checked_at" field.
func (m *MCPUpstreamMutation) ResetHealthCheckedAt() {
m.health_checked_at = nil
delete(m.clearedFields, mcpupstream.FieldHealthCheckedAt)
}
// SetLastSyncedAt sets the "last_synced_at" field.
func (m *MCPUpstreamMutation) SetLastSyncedAt(t time.Time) {
m.last_synced_at = &t
}
// LastSyncedAt returns the value of the "last_synced_at" field in the mutation.
func (m *MCPUpstreamMutation) LastSyncedAt() (r time.Time, exists bool) {
v := m.last_synced_at
if v == nil {
return
}
return *v, true
}
// OldLastSyncedAt returns the old "last_synced_at" field's value of the MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) OldLastSyncedAt(ctx context.Context) (v *time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldLastSyncedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldLastSyncedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLastSyncedAt: %w", err)
}
return oldValue.LastSyncedAt, nil
}
// ClearLastSyncedAt clears the value of the "last_synced_at" field.
func (m *MCPUpstreamMutation) ClearLastSyncedAt() {
m.last_synced_at = nil
m.clearedFields[mcpupstream.FieldLastSyncedAt] = struct{}{}
}
// LastSyncedAtCleared returns if the "last_synced_at" field was cleared in this mutation.
func (m *MCPUpstreamMutation) LastSyncedAtCleared() bool {
_, ok := m.clearedFields[mcpupstream.FieldLastSyncedAt]
return ok
}
// ResetLastSyncedAt resets all changes to the "last_synced_at" field.
func (m *MCPUpstreamMutation) ResetLastSyncedAt() {
m.last_synced_at = nil
delete(m.clearedFields, mcpupstream.FieldLastSyncedAt)
}
// SetCreatedAt sets the "created_at" field.
func (m *MCPUpstreamMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *MCPUpstreamMutation) 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 MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) 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 *MCPUpstreamMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *MCPUpstreamMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *MCPUpstreamMutation) 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 MCPUpstream entity.
// If the MCPUpstream 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 *MCPUpstreamMutation) 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 *MCPUpstreamMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// AddToolIDs adds the "tools" edge to the MCPTool entity by ids.
func (m *MCPUpstreamMutation) AddToolIDs(ids ...uuid.UUID) {
if m.tools == nil {
m.tools = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.tools[ids[i]] = struct{}{}
}
}
// ClearTools clears the "tools" edge to the MCPTool entity.
func (m *MCPUpstreamMutation) ClearTools() {
m.clearedtools = true
}
// ToolsCleared reports if the "tools" edge to the MCPTool entity was cleared.
func (m *MCPUpstreamMutation) ToolsCleared() bool {
return m.clearedtools
}
// RemoveToolIDs removes the "tools" edge to the MCPTool entity by IDs.
func (m *MCPUpstreamMutation) RemoveToolIDs(ids ...uuid.UUID) {
if m.removedtools == nil {
m.removedtools = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.tools, ids[i])
m.removedtools[ids[i]] = struct{}{}
}
}
// RemovedTools returns the removed IDs of the "tools" edge to the MCPTool entity.
func (m *MCPUpstreamMutation) RemovedToolsIDs() (ids []uuid.UUID) {
for id := range m.removedtools {
ids = append(ids, id)
}
return
}
// ToolsIDs returns the "tools" edge IDs in the mutation.
func (m *MCPUpstreamMutation) ToolsIDs() (ids []uuid.UUID) {
for id := range m.tools {
ids = append(ids, id)
}
return
}
// ResetTools resets all changes to the "tools" edge.
func (m *MCPUpstreamMutation) ResetTools() {
m.tools = nil
m.clearedtools = false
m.removedtools = nil
}
// ClearUser clears the "user" edge to the User entity.
func (m *MCPUpstreamMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[mcpupstream.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *MCPUpstreamMutation) UserCleared() bool {
return m.UserIDCleared() || m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *MCPUpstreamMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *MCPUpstreamMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// Where appends a list predicates to the MCPUpstreamMutation builder.
func (m *MCPUpstreamMutation) Where(ps ...predicate.MCPUpstream) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the MCPUpstreamMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *MCPUpstreamMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.MCPUpstream, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *MCPUpstreamMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *MCPUpstreamMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (MCPUpstream).
func (m *MCPUpstreamMutation) 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 *MCPUpstreamMutation) Fields() []string {
fields := make([]string, 0, 16)
if m.deleted_at != nil {
fields = append(fields, mcpupstream.FieldDeletedAt)
}
if m.name != nil {
fields = append(fields, mcpupstream.FieldName)
}
if m.slug != nil {
fields = append(fields, mcpupstream.FieldSlug)
}
if m.scope != nil {
fields = append(fields, mcpupstream.FieldScope)
}
if m.user != nil {
fields = append(fields, mcpupstream.FieldUserID)
}
if m._type != nil {
fields = append(fields, mcpupstream.FieldType)
}
if m.url != nil {
fields = append(fields, mcpupstream.FieldURL)
}
if m.headers != nil {
fields = append(fields, mcpupstream.FieldHeaders)
}
if m.description != nil {
fields = append(fields, mcpupstream.FieldDescription)
}
if m.enabled != nil {
fields = append(fields, mcpupstream.FieldEnabled)
}
if m.health_status != nil {
fields = append(fields, mcpupstream.FieldHealthStatus)
}
if m.sync_status != nil {
fields = append(fields, mcpupstream.FieldSyncStatus)
}
if m.health_checked_at != nil {
fields = append(fields, mcpupstream.FieldHealthCheckedAt)
}
if m.last_synced_at != nil {
fields = append(fields, mcpupstream.FieldLastSyncedAt)
}
if m.created_at != nil {
fields = append(fields, mcpupstream.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, mcpupstream.FieldUpdatedAt)
}
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 *MCPUpstreamMutation) Field(name string) (ent.Value, bool) {
switch name {
case mcpupstream.FieldDeletedAt:
return m.DeletedAt()
case mcpupstream.FieldName:
return m.Name()
case mcpupstream.FieldSlug:
return m.Slug()
case mcpupstream.FieldScope:
return m.Scope()
case mcpupstream.FieldUserID:
return m.UserID()
case mcpupstream.FieldType:
return m.GetType()
case mcpupstream.FieldURL:
return m.URL()
case mcpupstream.FieldHeaders:
return m.Headers()
case mcpupstream.FieldDescription:
return m.Description()
case mcpupstream.FieldEnabled:
return m.Enabled()
case mcpupstream.FieldHealthStatus:
return m.HealthStatus()
case mcpupstream.FieldSyncStatus:
return m.SyncStatus()
case mcpupstream.FieldHealthCheckedAt:
return m.HealthCheckedAt()
case mcpupstream.FieldLastSyncedAt:
return m.LastSyncedAt()
case mcpupstream.FieldCreatedAt:
return m.CreatedAt()
case mcpupstream.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *MCPUpstreamMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case mcpupstream.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case mcpupstream.FieldName:
return m.OldName(ctx)
case mcpupstream.FieldSlug:
return m.OldSlug(ctx)
case mcpupstream.FieldScope:
return m.OldScope(ctx)
case mcpupstream.FieldUserID:
return m.OldUserID(ctx)
case mcpupstream.FieldType:
return m.OldType(ctx)
case mcpupstream.FieldURL:
return m.OldURL(ctx)
case mcpupstream.FieldHeaders:
return m.OldHeaders(ctx)
case mcpupstream.FieldDescription:
return m.OldDescription(ctx)
case mcpupstream.FieldEnabled:
return m.OldEnabled(ctx)
case mcpupstream.FieldHealthStatus:
return m.OldHealthStatus(ctx)
case mcpupstream.FieldSyncStatus:
return m.OldSyncStatus(ctx)
case mcpupstream.FieldHealthCheckedAt:
return m.OldHealthCheckedAt(ctx)
case mcpupstream.FieldLastSyncedAt:
return m.OldLastSyncedAt(ctx)
case mcpupstream.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case mcpupstream.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown MCPUpstream 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 *MCPUpstreamMutation) SetField(name string, value ent.Value) error {
switch name {
case mcpupstream.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 mcpupstream.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case mcpupstream.FieldSlug:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSlug(v)
return nil
case mcpupstream.FieldScope:
v, ok := value.(mcpupstream.Scope)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetScope(v)
return nil
case mcpupstream.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case mcpupstream.FieldType:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetType(v)
return nil
case mcpupstream.FieldURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetURL(v)
return nil
case mcpupstream.FieldHeaders:
v, ok := value.(map[string]string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHeaders(v)
return nil
case mcpupstream.FieldDescription:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDescription(v)
return nil
case mcpupstream.FieldEnabled:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEnabled(v)
return nil
case mcpupstream.FieldHealthStatus:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHealthStatus(v)
return nil
case mcpupstream.FieldSyncStatus:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSyncStatus(v)
return nil
case mcpupstream.FieldHealthCheckedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHealthCheckedAt(v)
return nil
case mcpupstream.FieldLastSyncedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLastSyncedAt(v)
return nil
case mcpupstream.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 mcpupstream.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown MCPUpstream field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *MCPUpstreamMutation) AddedFields() []string {
return nil
}
// 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 *MCPUpstreamMutation) AddedField(name string) (ent.Value, bool) {
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 *MCPUpstreamMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown MCPUpstream numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *MCPUpstreamMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(mcpupstream.FieldDeletedAt) {
fields = append(fields, mcpupstream.FieldDeletedAt)
}
if m.FieldCleared(mcpupstream.FieldUserID) {
fields = append(fields, mcpupstream.FieldUserID)
}
if m.FieldCleared(mcpupstream.FieldHeaders) {
fields = append(fields, mcpupstream.FieldHeaders)
}
if m.FieldCleared(mcpupstream.FieldDescription) {
fields = append(fields, mcpupstream.FieldDescription)
}
if m.FieldCleared(mcpupstream.FieldHealthCheckedAt) {
fields = append(fields, mcpupstream.FieldHealthCheckedAt)
}
if m.FieldCleared(mcpupstream.FieldLastSyncedAt) {
fields = append(fields, mcpupstream.FieldLastSyncedAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *MCPUpstreamMutation) 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 *MCPUpstreamMutation) ClearField(name string) error {
switch name {
case mcpupstream.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case mcpupstream.FieldUserID:
m.ClearUserID()
return nil
case mcpupstream.FieldHeaders:
m.ClearHeaders()
return nil
case mcpupstream.FieldDescription:
m.ClearDescription()
return nil
case mcpupstream.FieldHealthCheckedAt:
m.ClearHealthCheckedAt()
return nil
case mcpupstream.FieldLastSyncedAt:
m.ClearLastSyncedAt()
return nil
}
return fmt.Errorf("unknown MCPUpstream 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 *MCPUpstreamMutation) ResetField(name string) error {
switch name {
case mcpupstream.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case mcpupstream.FieldName:
m.ResetName()
return nil
case mcpupstream.FieldSlug:
m.ResetSlug()
return nil
case mcpupstream.FieldScope:
m.ResetScope()
return nil
case mcpupstream.FieldUserID:
m.ResetUserID()
return nil
case mcpupstream.FieldType:
m.ResetType()
return nil
case mcpupstream.FieldURL:
m.ResetURL()
return nil
case mcpupstream.FieldHeaders:
m.ResetHeaders()
return nil
case mcpupstream.FieldDescription:
m.ResetDescription()
return nil
case mcpupstream.FieldEnabled:
m.ResetEnabled()
return nil
case mcpupstream.FieldHealthStatus:
m.ResetHealthStatus()
return nil
case mcpupstream.FieldSyncStatus:
m.ResetSyncStatus()
return nil
case mcpupstream.FieldHealthCheckedAt:
m.ResetHealthCheckedAt()
return nil
case mcpupstream.FieldLastSyncedAt:
m.ResetLastSyncedAt()
return nil
case mcpupstream.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case mcpupstream.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown MCPUpstream field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *MCPUpstreamMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.tools != nil {
edges = append(edges, mcpupstream.EdgeTools)
}
if m.user != nil {
edges = append(edges, mcpupstream.EdgeUser)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *MCPUpstreamMutation) AddedIDs(name string) []ent.Value {
switch name {
case mcpupstream.EdgeTools:
ids := make([]ent.Value, 0, len(m.tools))
for id := range m.tools {
ids = append(ids, id)
}
return ids
case mcpupstream.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *MCPUpstreamMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
if m.removedtools != nil {
edges = append(edges, mcpupstream.EdgeTools)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *MCPUpstreamMutation) RemovedIDs(name string) []ent.Value {
switch name {
case mcpupstream.EdgeTools:
ids := make([]ent.Value, 0, len(m.removedtools))
for id := range m.removedtools {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *MCPUpstreamMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedtools {
edges = append(edges, mcpupstream.EdgeTools)
}
if m.cleareduser {
edges = append(edges, mcpupstream.EdgeUser)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *MCPUpstreamMutation) EdgeCleared(name string) bool {
switch name {
case mcpupstream.EdgeTools:
return m.clearedtools
case mcpupstream.EdgeUser:
return m.cleareduser
}
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 *MCPUpstreamMutation) ClearEdge(name string) error {
switch name {
case mcpupstream.EdgeUser:
m.ClearUser()
return nil
}
return fmt.Errorf("unknown MCPUpstream 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 *MCPUpstreamMutation) ResetEdge(name string) error {
switch name {
case mcpupstream.EdgeTools:
m.ResetTools()
return nil
case mcpupstream.EdgeUser:
m.ResetUser()
return nil
}
return fmt.Errorf("unknown MCPUpstream edge %s", name)
}
// MCPUserToolSettingMutation represents an operation that mutates the MCPUserToolSetting nodes in the graph.
type MCPUserToolSettingMutation struct {
config
op Op
typ string
id *uuid.UUID
user_id *uuid.UUID
tool_id *uuid.UUID
enabled *bool
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*MCPUserToolSetting, error)
predicates []predicate.MCPUserToolSetting
}
var _ ent.Mutation = (*MCPUserToolSettingMutation)(nil)
// mcpusertoolsettingOption allows management of the mutation configuration using functional options.
type mcpusertoolsettingOption func(*MCPUserToolSettingMutation)
// newMCPUserToolSettingMutation creates new mutation for the MCPUserToolSetting entity.
func newMCPUserToolSettingMutation(c config, op Op, opts ...mcpusertoolsettingOption) *MCPUserToolSettingMutation {
m := &MCPUserToolSettingMutation{
config: c,
op: op,
typ: TypeMCPUserToolSetting,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withMCPUserToolSettingID sets the ID field of the mutation.
func withMCPUserToolSettingID(id uuid.UUID) mcpusertoolsettingOption {
return func(m *MCPUserToolSettingMutation) {
var (
err error
once sync.Once
value *MCPUserToolSetting
)
m.oldValue = func(ctx context.Context) (*MCPUserToolSetting, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().MCPUserToolSetting.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withMCPUserToolSetting sets the old MCPUserToolSetting of the mutation.
func withMCPUserToolSetting(node *MCPUserToolSetting) mcpusertoolsettingOption {
return func(m *MCPUserToolSettingMutation) {
m.oldValue = func(context.Context) (*MCPUserToolSetting, 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 MCPUserToolSettingMutation) 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 MCPUserToolSettingMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 MCPUserToolSetting entities.
func (m *MCPUserToolSettingMutation) SetID(id uuid.UUID) {
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 *MCPUserToolSettingMutation) ID() (id uuid.UUID, 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 *MCPUserToolSettingMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().MCPUserToolSetting.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetUserID sets the "user_id" field.
func (m *MCPUserToolSettingMutation) SetUserID(u uuid.UUID) {
m.user_id = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *MCPUserToolSettingMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user_id
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the MCPUserToolSetting entity.
// If the MCPUserToolSetting 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 *MCPUserToolSettingMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *MCPUserToolSettingMutation) ResetUserID() {
m.user_id = nil
}
// SetToolID sets the "tool_id" field.
func (m *MCPUserToolSettingMutation) SetToolID(u uuid.UUID) {
m.tool_id = &u
}
// ToolID returns the value of the "tool_id" field in the mutation.
func (m *MCPUserToolSettingMutation) ToolID() (r uuid.UUID, exists bool) {
v := m.tool_id
if v == nil {
return
}
return *v, true
}
// OldToolID returns the old "tool_id" field's value of the MCPUserToolSetting entity.
// If the MCPUserToolSetting 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 *MCPUserToolSettingMutation) OldToolID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldToolID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldToolID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldToolID: %w", err)
}
return oldValue.ToolID, nil
}
// ResetToolID resets all changes to the "tool_id" field.
func (m *MCPUserToolSettingMutation) ResetToolID() {
m.tool_id = nil
}
// SetEnabled sets the "enabled" field.
func (m *MCPUserToolSettingMutation) SetEnabled(b bool) {
m.enabled = &b
}
// Enabled returns the value of the "enabled" field in the mutation.
func (m *MCPUserToolSettingMutation) Enabled() (r bool, exists bool) {
v := m.enabled
if v == nil {
return
}
return *v, true
}
// OldEnabled returns the old "enabled" field's value of the MCPUserToolSetting entity.
// If the MCPUserToolSetting 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 *MCPUserToolSettingMutation) OldEnabled(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEnabled requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
}
return oldValue.Enabled, nil
}
// ResetEnabled resets all changes to the "enabled" field.
func (m *MCPUserToolSettingMutation) ResetEnabled() {
m.enabled = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *MCPUserToolSettingMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *MCPUserToolSettingMutation) 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 MCPUserToolSetting entity.
// If the MCPUserToolSetting 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 *MCPUserToolSettingMutation) 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 *MCPUserToolSettingMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *MCPUserToolSettingMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *MCPUserToolSettingMutation) 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 MCPUserToolSetting entity.
// If the MCPUserToolSetting 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 *MCPUserToolSettingMutation) 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 *MCPUserToolSettingMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// Where appends a list predicates to the MCPUserToolSettingMutation builder.
func (m *MCPUserToolSettingMutation) Where(ps ...predicate.MCPUserToolSetting) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the MCPUserToolSettingMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *MCPUserToolSettingMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.MCPUserToolSetting, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *MCPUserToolSettingMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *MCPUserToolSettingMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (MCPUserToolSetting).
func (m *MCPUserToolSettingMutation) 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 *MCPUserToolSettingMutation) Fields() []string {
fields := make([]string, 0, 5)
if m.user_id != nil {
fields = append(fields, mcpusertoolsetting.FieldUserID)
}
if m.tool_id != nil {
fields = append(fields, mcpusertoolsetting.FieldToolID)
}
if m.enabled != nil {
fields = append(fields, mcpusertoolsetting.FieldEnabled)
}
if m.created_at != nil {
fields = append(fields, mcpusertoolsetting.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, mcpusertoolsetting.FieldUpdatedAt)
}
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 *MCPUserToolSettingMutation) Field(name string) (ent.Value, bool) {
switch name {
case mcpusertoolsetting.FieldUserID:
return m.UserID()
case mcpusertoolsetting.FieldToolID:
return m.ToolID()
case mcpusertoolsetting.FieldEnabled:
return m.Enabled()
case mcpusertoolsetting.FieldCreatedAt:
return m.CreatedAt()
case mcpusertoolsetting.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *MCPUserToolSettingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case mcpusertoolsetting.FieldUserID:
return m.OldUserID(ctx)
case mcpusertoolsetting.FieldToolID:
return m.OldToolID(ctx)
case mcpusertoolsetting.FieldEnabled:
return m.OldEnabled(ctx)
case mcpusertoolsetting.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case mcpusertoolsetting.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown MCPUserToolSetting 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 *MCPUserToolSettingMutation) SetField(name string, value ent.Value) error {
switch name {
case mcpusertoolsetting.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case mcpusertoolsetting.FieldToolID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetToolID(v)
return nil
case mcpusertoolsetting.FieldEnabled:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEnabled(v)
return nil
case mcpusertoolsetting.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 mcpusertoolsetting.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown MCPUserToolSetting field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *MCPUserToolSettingMutation) AddedFields() []string {
return nil
}
// 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 *MCPUserToolSettingMutation) AddedField(name string) (ent.Value, bool) {
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 *MCPUserToolSettingMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown MCPUserToolSetting numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *MCPUserToolSettingMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *MCPUserToolSettingMutation) 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 *MCPUserToolSettingMutation) ClearField(name string) error {
return fmt.Errorf("unknown MCPUserToolSetting 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 *MCPUserToolSettingMutation) ResetField(name string) error {
switch name {
case mcpusertoolsetting.FieldUserID:
m.ResetUserID()
return nil
case mcpusertoolsetting.FieldToolID:
m.ResetToolID()
return nil
case mcpusertoolsetting.FieldEnabled:
m.ResetEnabled()
return nil
case mcpusertoolsetting.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case mcpusertoolsetting.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown MCPUserToolSetting field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *MCPUserToolSettingMutation) AddedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *MCPUserToolSettingMutation) AddedIDs(name string) []ent.Value {
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *MCPUserToolSettingMutation) RemovedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *MCPUserToolSettingMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *MCPUserToolSettingMutation) ClearedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *MCPUserToolSettingMutation) EdgeCleared(name string) bool {
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 *MCPUserToolSettingMutation) ClearEdge(name string) error {
return fmt.Errorf("unknown MCPUserToolSetting 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 *MCPUserToolSettingMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown MCPUserToolSetting edge %s", name)
}
// ModelMutation represents an operation that mutates the Model nodes in the graph.
type ModelMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
provider *string
api_key *string
base_url *string
model *string
remark *string
temperature *float64
addtemperature *float64
interface_type *string
weight *int
addweight *int
thinking_enabled *bool
support_image *bool
is_hidden *bool
context_limit *int
addcontext_limit *int
output_limit *int
addoutput_limit *int
last_check_at *time.Time
last_check_success *bool
last_check_error *string
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
user *uuid.UUID
cleareduser bool
teams map[uuid.UUID]struct{}
removedteams map[uuid.UUID]struct{}
clearedteams bool
groups map[uuid.UUID]struct{}
removedgroups map[uuid.UUID]struct{}
clearedgroups bool
vms map[string]struct{}
removedvms map[string]struct{}
clearedvms bool
project_tasks map[uuid.UUID]struct{}
removedproject_tasks map[uuid.UUID]struct{}
clearedproject_tasks bool
pricing *uuid.UUID
clearedpricing bool
apikeys map[uuid.UUID]struct{}
removedapikeys map[uuid.UUID]struct{}
clearedapikeys bool
switches_from map[uuid.UUID]struct{}
removedswitches_from map[uuid.UUID]struct{}
clearedswitches_from bool
switches_to map[uuid.UUID]struct{}
removedswitches_to map[uuid.UUID]struct{}
clearedswitches_to bool
team_models map[uuid.UUID]struct{}
removedteam_models map[uuid.UUID]struct{}
clearedteam_models bool
team_group_models map[uuid.UUID]struct{}
removedteam_group_models map[uuid.UUID]struct{}
clearedteam_group_models bool
done bool
oldValue func(context.Context) (*Model, error)
predicates []predicate.Model
}
var _ ent.Mutation = (*ModelMutation)(nil)
// modelOption allows management of the mutation configuration using functional options.
type modelOption func(*ModelMutation)
// newModelMutation creates new mutation for the Model entity.
func newModelMutation(c config, op Op, opts ...modelOption) *ModelMutation {
m := &ModelMutation{
config: c,
op: op,
typ: TypeModel,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withModelID sets the ID field of the mutation.
func withModelID(id uuid.UUID) modelOption {
return func(m *ModelMutation) {
var (
err error
once sync.Once
value *Model
)
m.oldValue = func(ctx context.Context) (*Model, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Model.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withModel sets the old Model of the mutation.
func withModel(node *Model) modelOption {
return func(m *ModelMutation) {
m.oldValue = func(context.Context) (*Model, 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 ModelMutation) 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 ModelMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 Model entities.
func (m *ModelMutation) SetID(id uuid.UUID) {
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 *ModelMutation) ID() (id uuid.UUID, 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 *ModelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().Model.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *ModelMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *ModelMutation) 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 Model entity.
// If the Model 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 *ModelMutation) 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 *ModelMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[model.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *ModelMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[model.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *ModelMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, model.FieldDeletedAt)
}
// SetUserID sets the "user_id" field.
func (m *ModelMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *ModelMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *ModelMutation) ResetUserID() {
m.user = nil
}
// SetProvider sets the "provider" field.
func (m *ModelMutation) SetProvider(s string) {
m.provider = &s
}
// Provider returns the value of the "provider" field in the mutation.
func (m *ModelMutation) Provider() (r string, exists bool) {
v := m.provider
if v == nil {
return
}
return *v, true
}
// OldProvider returns the old "provider" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldProvider(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldProvider is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldProvider requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldProvider: %w", err)
}
return oldValue.Provider, nil
}
// ResetProvider resets all changes to the "provider" field.
func (m *ModelMutation) ResetProvider() {
m.provider = nil
}
// SetAPIKey sets the "api_key" field.
func (m *ModelMutation) SetAPIKey(s string) {
m.api_key = &s
}
// APIKey returns the value of the "api_key" field in the mutation.
func (m *ModelMutation) APIKey() (r string, exists bool) {
v := m.api_key
if v == nil {
return
}
return *v, true
}
// OldAPIKey returns the old "api_key" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldAPIKey(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAPIKey requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
}
return oldValue.APIKey, nil
}
// ResetAPIKey resets all changes to the "api_key" field.
func (m *ModelMutation) ResetAPIKey() {
m.api_key = nil
}
// SetBaseURL sets the "base_url" field.
func (m *ModelMutation) SetBaseURL(s string) {
m.base_url = &s
}
// BaseURL returns the value of the "base_url" field in the mutation.
func (m *ModelMutation) BaseURL() (r string, exists bool) {
v := m.base_url
if v == nil {
return
}
return *v, true
}
// OldBaseURL returns the old "base_url" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldBaseURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldBaseURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldBaseURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBaseURL: %w", err)
}
return oldValue.BaseURL, nil
}
// ResetBaseURL resets all changes to the "base_url" field.
func (m *ModelMutation) ResetBaseURL() {
m.base_url = nil
}
// SetModel sets the "model" field.
func (m *ModelMutation) SetModel(s string) {
m.model = &s
}
// Model returns the value of the "model" field in the mutation.
func (m *ModelMutation) Model() (r string, exists bool) {
v := m.model
if v == nil {
return
}
return *v, true
}
// OldModel returns the old "model" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldModel(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldModel is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldModel requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldModel: %w", err)
}
return oldValue.Model, nil
}
// ResetModel resets all changes to the "model" field.
func (m *ModelMutation) ResetModel() {
m.model = nil
}
// SetRemark sets the "remark" field.
func (m *ModelMutation) SetRemark(s string) {
m.remark = &s
}
// Remark returns the value of the "remark" field in the mutation.
func (m *ModelMutation) Remark() (r string, exists bool) {
v := m.remark
if v == nil {
return
}
return *v, true
}
// OldRemark returns the old "remark" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldRemark(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRemark is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRemark requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRemark: %w", err)
}
return oldValue.Remark, nil
}
// ClearRemark clears the value of the "remark" field.
func (m *ModelMutation) ClearRemark() {
m.remark = nil
m.clearedFields[model.FieldRemark] = struct{}{}
}
// RemarkCleared returns if the "remark" field was cleared in this mutation.
func (m *ModelMutation) RemarkCleared() bool {
_, ok := m.clearedFields[model.FieldRemark]
return ok
}
// ResetRemark resets all changes to the "remark" field.
func (m *ModelMutation) ResetRemark() {
m.remark = nil
delete(m.clearedFields, model.FieldRemark)
}
// SetTemperature sets the "temperature" field.
func (m *ModelMutation) SetTemperature(f float64) {
m.temperature = &f
m.addtemperature = nil
}
// Temperature returns the value of the "temperature" field in the mutation.
func (m *ModelMutation) Temperature() (r float64, exists bool) {
v := m.temperature
if v == nil {
return
}
return *v, true
}
// OldTemperature returns the old "temperature" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldTemperature(ctx context.Context) (v float64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTemperature is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTemperature requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTemperature: %w", err)
}
return oldValue.Temperature, nil
}
// AddTemperature adds f to the "temperature" field.
func (m *ModelMutation) AddTemperature(f float64) {
if m.addtemperature != nil {
*m.addtemperature += f
} else {
m.addtemperature = &f
}
}
// AddedTemperature returns the value that was added to the "temperature" field in this mutation.
func (m *ModelMutation) AddedTemperature() (r float64, exists bool) {
v := m.addtemperature
if v == nil {
return
}
return *v, true
}
// ClearTemperature clears the value of the "temperature" field.
func (m *ModelMutation) ClearTemperature() {
m.temperature = nil
m.addtemperature = nil
m.clearedFields[model.FieldTemperature] = struct{}{}
}
// TemperatureCleared returns if the "temperature" field was cleared in this mutation.
func (m *ModelMutation) TemperatureCleared() bool {
_, ok := m.clearedFields[model.FieldTemperature]
return ok
}
// ResetTemperature resets all changes to the "temperature" field.
func (m *ModelMutation) ResetTemperature() {
m.temperature = nil
m.addtemperature = nil
delete(m.clearedFields, model.FieldTemperature)
}
// SetInterfaceType sets the "interface_type" field.
func (m *ModelMutation) SetInterfaceType(s string) {
m.interface_type = &s
}
// InterfaceType returns the value of the "interface_type" field in the mutation.
func (m *ModelMutation) InterfaceType() (r string, exists bool) {
v := m.interface_type
if v == nil {
return
}
return *v, true
}
// OldInterfaceType returns the old "interface_type" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldInterfaceType(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldInterfaceType is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldInterfaceType requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInterfaceType: %w", err)
}
return oldValue.InterfaceType, nil
}
// ClearInterfaceType clears the value of the "interface_type" field.
func (m *ModelMutation) ClearInterfaceType() {
m.interface_type = nil
m.clearedFields[model.FieldInterfaceType] = struct{}{}
}
// InterfaceTypeCleared returns if the "interface_type" field was cleared in this mutation.
func (m *ModelMutation) InterfaceTypeCleared() bool {
_, ok := m.clearedFields[model.FieldInterfaceType]
return ok
}
// ResetInterfaceType resets all changes to the "interface_type" field.
func (m *ModelMutation) ResetInterfaceType() {
m.interface_type = nil
delete(m.clearedFields, model.FieldInterfaceType)
}
// SetWeight sets the "weight" field.
func (m *ModelMutation) SetWeight(i int) {
m.weight = &i
m.addweight = nil
}
// Weight returns the value of the "weight" field in the mutation.
func (m *ModelMutation) Weight() (r int, exists bool) {
v := m.weight
if v == nil {
return
}
return *v, true
}
// OldWeight returns the old "weight" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldWeight(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldWeight is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldWeight requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldWeight: %w", err)
}
return oldValue.Weight, nil
}
// AddWeight adds i to the "weight" field.
func (m *ModelMutation) AddWeight(i int) {
if m.addweight != nil {
*m.addweight += i
} else {
m.addweight = &i
}
}
// AddedWeight returns the value that was added to the "weight" field in this mutation.
func (m *ModelMutation) AddedWeight() (r int, exists bool) {
v := m.addweight
if v == nil {
return
}
return *v, true
}
// ResetWeight resets all changes to the "weight" field.
func (m *ModelMutation) ResetWeight() {
m.weight = nil
m.addweight = nil
}
// SetThinkingEnabled sets the "thinking_enabled" field.
func (m *ModelMutation) SetThinkingEnabled(b bool) {
m.thinking_enabled = &b
}
// ThinkingEnabled returns the value of the "thinking_enabled" field in the mutation.
func (m *ModelMutation) ThinkingEnabled() (r bool, exists bool) {
v := m.thinking_enabled
if v == nil {
return
}
return *v, true
}
// OldThinkingEnabled returns the old "thinking_enabled" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldThinkingEnabled(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldThinkingEnabled is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldThinkingEnabled requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldThinkingEnabled: %w", err)
}
return oldValue.ThinkingEnabled, nil
}
// ResetThinkingEnabled resets all changes to the "thinking_enabled" field.
func (m *ModelMutation) ResetThinkingEnabled() {
m.thinking_enabled = nil
}
// SetSupportImage sets the "support_image" field.
func (m *ModelMutation) SetSupportImage(b bool) {
m.support_image = &b
}
// SupportImage returns the value of the "support_image" field in the mutation.
func (m *ModelMutation) SupportImage() (r bool, exists bool) {
v := m.support_image
if v == nil {
return
}
return *v, true
}
// OldSupportImage returns the old "support_image" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldSupportImage(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSupportImage is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSupportImage requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSupportImage: %w", err)
}
return oldValue.SupportImage, nil
}
// ResetSupportImage resets all changes to the "support_image" field.
func (m *ModelMutation) ResetSupportImage() {
m.support_image = nil
}
// SetIsHidden sets the "is_hidden" field.
func (m *ModelMutation) SetIsHidden(b bool) {
m.is_hidden = &b
}
// IsHidden returns the value of the "is_hidden" field in the mutation.
func (m *ModelMutation) IsHidden() (r bool, exists bool) {
v := m.is_hidden
if v == nil {
return
}
return *v, true
}
// OldIsHidden returns the old "is_hidden" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldIsHidden(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldIsHidden is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldIsHidden requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIsHidden: %w", err)
}
return oldValue.IsHidden, nil
}
// ResetIsHidden resets all changes to the "is_hidden" field.
func (m *ModelMutation) ResetIsHidden() {
m.is_hidden = nil
}
// SetContextLimit sets the "context_limit" field.
func (m *ModelMutation) SetContextLimit(i int) {
m.context_limit = &i
m.addcontext_limit = nil
}
// ContextLimit returns the value of the "context_limit" field in the mutation.
func (m *ModelMutation) ContextLimit() (r int, exists bool) {
v := m.context_limit
if v == nil {
return
}
return *v, true
}
// OldContextLimit returns the old "context_limit" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldContextLimit(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldContextLimit is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldContextLimit requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldContextLimit: %w", err)
}
return oldValue.ContextLimit, nil
}
// AddContextLimit adds i to the "context_limit" field.
func (m *ModelMutation) AddContextLimit(i int) {
if m.addcontext_limit != nil {
*m.addcontext_limit += i
} else {
m.addcontext_limit = &i
}
}
// AddedContextLimit returns the value that was added to the "context_limit" field in this mutation.
func (m *ModelMutation) AddedContextLimit() (r int, exists bool) {
v := m.addcontext_limit
if v == nil {
return
}
return *v, true
}
// ResetContextLimit resets all changes to the "context_limit" field.
func (m *ModelMutation) ResetContextLimit() {
m.context_limit = nil
m.addcontext_limit = nil
}
// SetOutputLimit sets the "output_limit" field.
func (m *ModelMutation) SetOutputLimit(i int) {
m.output_limit = &i
m.addoutput_limit = nil
}
// OutputLimit returns the value of the "output_limit" field in the mutation.
func (m *ModelMutation) OutputLimit() (r int, exists bool) {
v := m.output_limit
if v == nil {
return
}
return *v, true
}
// OldOutputLimit returns the old "output_limit" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldOutputLimit(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOutputLimit is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOutputLimit requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOutputLimit: %w", err)
}
return oldValue.OutputLimit, nil
}
// AddOutputLimit adds i to the "output_limit" field.
func (m *ModelMutation) AddOutputLimit(i int) {
if m.addoutput_limit != nil {
*m.addoutput_limit += i
} else {
m.addoutput_limit = &i
}
}
// AddedOutputLimit returns the value that was added to the "output_limit" field in this mutation.
func (m *ModelMutation) AddedOutputLimit() (r int, exists bool) {
v := m.addoutput_limit
if v == nil {
return
}
return *v, true
}
// ResetOutputLimit resets all changes to the "output_limit" field.
func (m *ModelMutation) ResetOutputLimit() {
m.output_limit = nil
m.addoutput_limit = nil
}
// SetLastCheckAt sets the "last_check_at" field.
func (m *ModelMutation) SetLastCheckAt(t time.Time) {
m.last_check_at = &t
}
// LastCheckAt returns the value of the "last_check_at" field in the mutation.
func (m *ModelMutation) LastCheckAt() (r time.Time, exists bool) {
v := m.last_check_at
if v == nil {
return
}
return *v, true
}
// OldLastCheckAt returns the old "last_check_at" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldLastCheckAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldLastCheckAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldLastCheckAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLastCheckAt: %w", err)
}
return oldValue.LastCheckAt, nil
}
// ClearLastCheckAt clears the value of the "last_check_at" field.
func (m *ModelMutation) ClearLastCheckAt() {
m.last_check_at = nil
m.clearedFields[model.FieldLastCheckAt] = struct{}{}
}
// LastCheckAtCleared returns if the "last_check_at" field was cleared in this mutation.
func (m *ModelMutation) LastCheckAtCleared() bool {
_, ok := m.clearedFields[model.FieldLastCheckAt]
return ok
}
// ResetLastCheckAt resets all changes to the "last_check_at" field.
func (m *ModelMutation) ResetLastCheckAt() {
m.last_check_at = nil
delete(m.clearedFields, model.FieldLastCheckAt)
}
// SetLastCheckSuccess sets the "last_check_success" field.
func (m *ModelMutation) SetLastCheckSuccess(b bool) {
m.last_check_success = &b
}
// LastCheckSuccess returns the value of the "last_check_success" field in the mutation.
func (m *ModelMutation) LastCheckSuccess() (r bool, exists bool) {
v := m.last_check_success
if v == nil {
return
}
return *v, true
}
// OldLastCheckSuccess returns the old "last_check_success" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldLastCheckSuccess(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldLastCheckSuccess is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldLastCheckSuccess requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLastCheckSuccess: %w", err)
}
return oldValue.LastCheckSuccess, nil
}
// ClearLastCheckSuccess clears the value of the "last_check_success" field.
func (m *ModelMutation) ClearLastCheckSuccess() {
m.last_check_success = nil
m.clearedFields[model.FieldLastCheckSuccess] = struct{}{}
}
// LastCheckSuccessCleared returns if the "last_check_success" field was cleared in this mutation.
func (m *ModelMutation) LastCheckSuccessCleared() bool {
_, ok := m.clearedFields[model.FieldLastCheckSuccess]
return ok
}
// ResetLastCheckSuccess resets all changes to the "last_check_success" field.
func (m *ModelMutation) ResetLastCheckSuccess() {
m.last_check_success = nil
delete(m.clearedFields, model.FieldLastCheckSuccess)
}
// SetLastCheckError sets the "last_check_error" field.
func (m *ModelMutation) SetLastCheckError(s string) {
m.last_check_error = &s
}
// LastCheckError returns the value of the "last_check_error" field in the mutation.
func (m *ModelMutation) LastCheckError() (r string, exists bool) {
v := m.last_check_error
if v == nil {
return
}
return *v, true
}
// OldLastCheckError returns the old "last_check_error" field's value of the Model entity.
// If the Model 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 *ModelMutation) OldLastCheckError(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldLastCheckError is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldLastCheckError requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLastCheckError: %w", err)
}
return oldValue.LastCheckError, nil
}
// ClearLastCheckError clears the value of the "last_check_error" field.
func (m *ModelMutation) ClearLastCheckError() {
m.last_check_error = nil
m.clearedFields[model.FieldLastCheckError] = struct{}{}
}
// LastCheckErrorCleared returns if the "last_check_error" field was cleared in this mutation.
func (m *ModelMutation) LastCheckErrorCleared() bool {
_, ok := m.clearedFields[model.FieldLastCheckError]
return ok
}
// ResetLastCheckError resets all changes to the "last_check_error" field.
func (m *ModelMutation) ResetLastCheckError() {
m.last_check_error = nil
delete(m.clearedFields, model.FieldLastCheckError)
}
// SetCreatedAt sets the "created_at" field.
func (m *ModelMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ModelMutation) 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 Model entity.
// If the Model 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 *ModelMutation) 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 *ModelMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *ModelMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *ModelMutation) 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 Model entity.
// If the Model 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 *ModelMutation) 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 *ModelMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearUser clears the "user" edge to the User entity.
func (m *ModelMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[model.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *ModelMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *ModelMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *ModelMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// AddTeamIDs adds the "teams" edge to the Team entity by ids.
func (m *ModelMutation) AddTeamIDs(ids ...uuid.UUID) {
if m.teams == nil {
m.teams = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.teams[ids[i]] = struct{}{}
}
}
// ClearTeams clears the "teams" edge to the Team entity.
func (m *ModelMutation) ClearTeams() {
m.clearedteams = true
}
// TeamsCleared reports if the "teams" edge to the Team entity was cleared.
func (m *ModelMutation) TeamsCleared() bool {
return m.clearedteams
}
// RemoveTeamIDs removes the "teams" edge to the Team entity by IDs.
func (m *ModelMutation) RemoveTeamIDs(ids ...uuid.UUID) {
if m.removedteams == nil {
m.removedteams = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.teams, ids[i])
m.removedteams[ids[i]] = struct{}{}
}
}
// RemovedTeams returns the removed IDs of the "teams" edge to the Team entity.
func (m *ModelMutation) RemovedTeamsIDs() (ids []uuid.UUID) {
for id := range m.removedteams {
ids = append(ids, id)
}
return
}
// TeamsIDs returns the "teams" edge IDs in the mutation.
func (m *ModelMutation) TeamsIDs() (ids []uuid.UUID) {
for id := range m.teams {
ids = append(ids, id)
}
return
}
// ResetTeams resets all changes to the "teams" edge.
func (m *ModelMutation) ResetTeams() {
m.teams = nil
m.clearedteams = false
m.removedteams = nil
}
// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids.
func (m *ModelMutation) AddGroupIDs(ids ...uuid.UUID) {
if m.groups == nil {
m.groups = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.groups[ids[i]] = struct{}{}
}
}
// ClearGroups clears the "groups" edge to the TeamGroup entity.
func (m *ModelMutation) ClearGroups() {
m.clearedgroups = true
}
// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared.
func (m *ModelMutation) GroupsCleared() bool {
return m.clearedgroups
}
// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs.
func (m *ModelMutation) RemoveGroupIDs(ids ...uuid.UUID) {
if m.removedgroups == nil {
m.removedgroups = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.groups, ids[i])
m.removedgroups[ids[i]] = struct{}{}
}
}
// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity.
func (m *ModelMutation) RemovedGroupsIDs() (ids []uuid.UUID) {
for id := range m.removedgroups {
ids = append(ids, id)
}
return
}
// GroupsIDs returns the "groups" edge IDs in the mutation.
func (m *ModelMutation) GroupsIDs() (ids []uuid.UUID) {
for id := range m.groups {
ids = append(ids, id)
}
return
}
// ResetGroups resets all changes to the "groups" edge.
func (m *ModelMutation) ResetGroups() {
m.groups = nil
m.clearedgroups = false
m.removedgroups = nil
}
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by ids.
func (m *ModelMutation) AddVMIDs(ids ...string) {
if m.vms == nil {
m.vms = make(map[string]struct{})
}
for i := range ids {
m.vms[ids[i]] = struct{}{}
}
}
// ClearVms clears the "vms" edge to the VirtualMachine entity.
func (m *ModelMutation) ClearVms() {
m.clearedvms = true
}
// VmsCleared reports if the "vms" edge to the VirtualMachine entity was cleared.
func (m *ModelMutation) VmsCleared() bool {
return m.clearedvms
}
// RemoveVMIDs removes the "vms" edge to the VirtualMachine entity by IDs.
func (m *ModelMutation) RemoveVMIDs(ids ...string) {
if m.removedvms == nil {
m.removedvms = make(map[string]struct{})
}
for i := range ids {
delete(m.vms, ids[i])
m.removedvms[ids[i]] = struct{}{}
}
}
// RemovedVms returns the removed IDs of the "vms" edge to the VirtualMachine entity.
func (m *ModelMutation) RemovedVmsIDs() (ids []string) {
for id := range m.removedvms {
ids = append(ids, id)
}
return
}
// VmsIDs returns the "vms" edge IDs in the mutation.
func (m *ModelMutation) VmsIDs() (ids []string) {
for id := range m.vms {
ids = append(ids, id)
}
return
}
// ResetVms resets all changes to the "vms" edge.
func (m *ModelMutation) ResetVms() {
m.vms = nil
m.clearedvms = false
m.removedvms = nil
}
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids.
func (m *ModelMutation) AddProjectTaskIDs(ids ...uuid.UUID) {
if m.project_tasks == nil {
m.project_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.project_tasks[ids[i]] = struct{}{}
}
}
// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity.
func (m *ModelMutation) ClearProjectTasks() {
m.clearedproject_tasks = true
}
// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared.
func (m *ModelMutation) ProjectTasksCleared() bool {
return m.clearedproject_tasks
}
// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs.
func (m *ModelMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) {
if m.removedproject_tasks == nil {
m.removedproject_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.project_tasks, ids[i])
m.removedproject_tasks[ids[i]] = struct{}{}
}
}
// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity.
func (m *ModelMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return
}
// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation.
func (m *ModelMutation) ProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.project_tasks {
ids = append(ids, id)
}
return
}
// ResetProjectTasks resets all changes to the "project_tasks" edge.
func (m *ModelMutation) ResetProjectTasks() {
m.project_tasks = nil
m.clearedproject_tasks = false
m.removedproject_tasks = nil
}
// SetPricingID sets the "pricing" edge to the ModelPricing entity by id.
func (m *ModelMutation) SetPricingID(id uuid.UUID) {
m.pricing = &id
}
// ClearPricing clears the "pricing" edge to the ModelPricing entity.
func (m *ModelMutation) ClearPricing() {
m.clearedpricing = true
}
// PricingCleared reports if the "pricing" edge to the ModelPricing entity was cleared.
func (m *ModelMutation) PricingCleared() bool {
return m.clearedpricing
}
// PricingID returns the "pricing" edge ID in the mutation.
func (m *ModelMutation) PricingID() (id uuid.UUID, exists bool) {
if m.pricing != nil {
return *m.pricing, true
}
return
}
// PricingIDs returns the "pricing" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// PricingID instead. It exists only for internal usage by the builders.
func (m *ModelMutation) PricingIDs() (ids []uuid.UUID) {
if id := m.pricing; id != nil {
ids = append(ids, *id)
}
return
}
// ResetPricing resets all changes to the "pricing" edge.
func (m *ModelMutation) ResetPricing() {
m.pricing = nil
m.clearedpricing = false
}
// AddApikeyIDs adds the "apikeys" edge to the ModelApiKey entity by ids.
func (m *ModelMutation) AddApikeyIDs(ids ...uuid.UUID) {
if m.apikeys == nil {
m.apikeys = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.apikeys[ids[i]] = struct{}{}
}
}
// ClearApikeys clears the "apikeys" edge to the ModelApiKey entity.
func (m *ModelMutation) ClearApikeys() {
m.clearedapikeys = true
}
// ApikeysCleared reports if the "apikeys" edge to the ModelApiKey entity was cleared.
func (m *ModelMutation) ApikeysCleared() bool {
return m.clearedapikeys
}
// RemoveApikeyIDs removes the "apikeys" edge to the ModelApiKey entity by IDs.
func (m *ModelMutation) RemoveApikeyIDs(ids ...uuid.UUID) {
if m.removedapikeys == nil {
m.removedapikeys = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.apikeys, ids[i])
m.removedapikeys[ids[i]] = struct{}{}
}
}
// RemovedApikeys returns the removed IDs of the "apikeys" edge to the ModelApiKey entity.
func (m *ModelMutation) RemovedApikeysIDs() (ids []uuid.UUID) {
for id := range m.removedapikeys {
ids = append(ids, id)
}
return
}
// ApikeysIDs returns the "apikeys" edge IDs in the mutation.
func (m *ModelMutation) ApikeysIDs() (ids []uuid.UUID) {
for id := range m.apikeys {
ids = append(ids, id)
}
return
}
// ResetApikeys resets all changes to the "apikeys" edge.
func (m *ModelMutation) ResetApikeys() {
m.apikeys = nil
m.clearedapikeys = false
m.removedapikeys = nil
}
// AddSwitchesFromIDs adds the "switches_from" edge to the TaskModelSwitch entity by ids.
func (m *ModelMutation) AddSwitchesFromIDs(ids ...uuid.UUID) {
if m.switches_from == nil {
m.switches_from = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.switches_from[ids[i]] = struct{}{}
}
}
// ClearSwitchesFrom clears the "switches_from" edge to the TaskModelSwitch entity.
func (m *ModelMutation) ClearSwitchesFrom() {
m.clearedswitches_from = true
}
// SwitchesFromCleared reports if the "switches_from" edge to the TaskModelSwitch entity was cleared.
func (m *ModelMutation) SwitchesFromCleared() bool {
return m.clearedswitches_from
}
// RemoveSwitchesFromIDs removes the "switches_from" edge to the TaskModelSwitch entity by IDs.
func (m *ModelMutation) RemoveSwitchesFromIDs(ids ...uuid.UUID) {
if m.removedswitches_from == nil {
m.removedswitches_from = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.switches_from, ids[i])
m.removedswitches_from[ids[i]] = struct{}{}
}
}
// RemovedSwitchesFrom returns the removed IDs of the "switches_from" edge to the TaskModelSwitch entity.
func (m *ModelMutation) RemovedSwitchesFromIDs() (ids []uuid.UUID) {
for id := range m.removedswitches_from {
ids = append(ids, id)
}
return
}
// SwitchesFromIDs returns the "switches_from" edge IDs in the mutation.
func (m *ModelMutation) SwitchesFromIDs() (ids []uuid.UUID) {
for id := range m.switches_from {
ids = append(ids, id)
}
return
}
// ResetSwitchesFrom resets all changes to the "switches_from" edge.
func (m *ModelMutation) ResetSwitchesFrom() {
m.switches_from = nil
m.clearedswitches_from = false
m.removedswitches_from = nil
}
// AddSwitchesToIDs adds the "switches_to" edge to the TaskModelSwitch entity by ids.
func (m *ModelMutation) AddSwitchesToIDs(ids ...uuid.UUID) {
if m.switches_to == nil {
m.switches_to = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.switches_to[ids[i]] = struct{}{}
}
}
// ClearSwitchesTo clears the "switches_to" edge to the TaskModelSwitch entity.
func (m *ModelMutation) ClearSwitchesTo() {
m.clearedswitches_to = true
}
// SwitchesToCleared reports if the "switches_to" edge to the TaskModelSwitch entity was cleared.
func (m *ModelMutation) SwitchesToCleared() bool {
return m.clearedswitches_to
}
// RemoveSwitchesToIDs removes the "switches_to" edge to the TaskModelSwitch entity by IDs.
func (m *ModelMutation) RemoveSwitchesToIDs(ids ...uuid.UUID) {
if m.removedswitches_to == nil {
m.removedswitches_to = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.switches_to, ids[i])
m.removedswitches_to[ids[i]] = struct{}{}
}
}
// RemovedSwitchesTo returns the removed IDs of the "switches_to" edge to the TaskModelSwitch entity.
func (m *ModelMutation) RemovedSwitchesToIDs() (ids []uuid.UUID) {
for id := range m.removedswitches_to {
ids = append(ids, id)
}
return
}
// SwitchesToIDs returns the "switches_to" edge IDs in the mutation.
func (m *ModelMutation) SwitchesToIDs() (ids []uuid.UUID) {
for id := range m.switches_to {
ids = append(ids, id)
}
return
}
// ResetSwitchesTo resets all changes to the "switches_to" edge.
func (m *ModelMutation) ResetSwitchesTo() {
m.switches_to = nil
m.clearedswitches_to = false
m.removedswitches_to = nil
}
// AddTeamModelIDs adds the "team_models" edge to the TeamModel entity by ids.
func (m *ModelMutation) AddTeamModelIDs(ids ...uuid.UUID) {
if m.team_models == nil {
m.team_models = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_models[ids[i]] = struct{}{}
}
}
// ClearTeamModels clears the "team_models" edge to the TeamModel entity.
func (m *ModelMutation) ClearTeamModels() {
m.clearedteam_models = true
}
// TeamModelsCleared reports if the "team_models" edge to the TeamModel entity was cleared.
func (m *ModelMutation) TeamModelsCleared() bool {
return m.clearedteam_models
}
// RemoveTeamModelIDs removes the "team_models" edge to the TeamModel entity by IDs.
func (m *ModelMutation) RemoveTeamModelIDs(ids ...uuid.UUID) {
if m.removedteam_models == nil {
m.removedteam_models = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_models, ids[i])
m.removedteam_models[ids[i]] = struct{}{}
}
}
// RemovedTeamModels returns the removed IDs of the "team_models" edge to the TeamModel entity.
func (m *ModelMutation) RemovedTeamModelsIDs() (ids []uuid.UUID) {
for id := range m.removedteam_models {
ids = append(ids, id)
}
return
}
// TeamModelsIDs returns the "team_models" edge IDs in the mutation.
func (m *ModelMutation) TeamModelsIDs() (ids []uuid.UUID) {
for id := range m.team_models {
ids = append(ids, id)
}
return
}
// ResetTeamModels resets all changes to the "team_models" edge.
func (m *ModelMutation) ResetTeamModels() {
m.team_models = nil
m.clearedteam_models = false
m.removedteam_models = nil
}
// AddTeamGroupModelIDs adds the "team_group_models" edge to the TeamGroupModel entity by ids.
func (m *ModelMutation) AddTeamGroupModelIDs(ids ...uuid.UUID) {
if m.team_group_models == nil {
m.team_group_models = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_group_models[ids[i]] = struct{}{}
}
}
// ClearTeamGroupModels clears the "team_group_models" edge to the TeamGroupModel entity.
func (m *ModelMutation) ClearTeamGroupModels() {
m.clearedteam_group_models = true
}
// TeamGroupModelsCleared reports if the "team_group_models" edge to the TeamGroupModel entity was cleared.
func (m *ModelMutation) TeamGroupModelsCleared() bool {
return m.clearedteam_group_models
}
// RemoveTeamGroupModelIDs removes the "team_group_models" edge to the TeamGroupModel entity by IDs.
func (m *ModelMutation) RemoveTeamGroupModelIDs(ids ...uuid.UUID) {
if m.removedteam_group_models == nil {
m.removedteam_group_models = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_group_models, ids[i])
m.removedteam_group_models[ids[i]] = struct{}{}
}
}
// RemovedTeamGroupModels returns the removed IDs of the "team_group_models" edge to the TeamGroupModel entity.
func (m *ModelMutation) RemovedTeamGroupModelsIDs() (ids []uuid.UUID) {
for id := range m.removedteam_group_models {
ids = append(ids, id)
}
return
}
// TeamGroupModelsIDs returns the "team_group_models" edge IDs in the mutation.
func (m *ModelMutation) TeamGroupModelsIDs() (ids []uuid.UUID) {
for id := range m.team_group_models {
ids = append(ids, id)
}
return
}
// ResetTeamGroupModels resets all changes to the "team_group_models" edge.
func (m *ModelMutation) ResetTeamGroupModels() {
m.team_group_models = nil
m.clearedteam_group_models = false
m.removedteam_group_models = nil
}
// Where appends a list predicates to the ModelMutation builder.
func (m *ModelMutation) Where(ps ...predicate.Model) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ModelMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ModelMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Model, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ModelMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ModelMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Model).
func (m *ModelMutation) 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 *ModelMutation) Fields() []string {
fields := make([]string, 0, 20)
if m.deleted_at != nil {
fields = append(fields, model.FieldDeletedAt)
}
if m.user != nil {
fields = append(fields, model.FieldUserID)
}
if m.provider != nil {
fields = append(fields, model.FieldProvider)
}
if m.api_key != nil {
fields = append(fields, model.FieldAPIKey)
}
if m.base_url != nil {
fields = append(fields, model.FieldBaseURL)
}
if m.model != nil {
fields = append(fields, model.FieldModel)
}
if m.remark != nil {
fields = append(fields, model.FieldRemark)
}
if m.temperature != nil {
fields = append(fields, model.FieldTemperature)
}
if m.interface_type != nil {
fields = append(fields, model.FieldInterfaceType)
}
if m.weight != nil {
fields = append(fields, model.FieldWeight)
}
if m.thinking_enabled != nil {
fields = append(fields, model.FieldThinkingEnabled)
}
if m.support_image != nil {
fields = append(fields, model.FieldSupportImage)
}
if m.is_hidden != nil {
fields = append(fields, model.FieldIsHidden)
}
if m.context_limit != nil {
fields = append(fields, model.FieldContextLimit)
}
if m.output_limit != nil {
fields = append(fields, model.FieldOutputLimit)
}
if m.last_check_at != nil {
fields = append(fields, model.FieldLastCheckAt)
}
if m.last_check_success != nil {
fields = append(fields, model.FieldLastCheckSuccess)
}
if m.last_check_error != nil {
fields = append(fields, model.FieldLastCheckError)
}
if m.created_at != nil {
fields = append(fields, model.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, model.FieldUpdatedAt)
}
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 *ModelMutation) Field(name string) (ent.Value, bool) {
switch name {
case model.FieldDeletedAt:
return m.DeletedAt()
case model.FieldUserID:
return m.UserID()
case model.FieldProvider:
return m.Provider()
case model.FieldAPIKey:
return m.APIKey()
case model.FieldBaseURL:
return m.BaseURL()
case model.FieldModel:
return m.Model()
case model.FieldRemark:
return m.Remark()
case model.FieldTemperature:
return m.Temperature()
case model.FieldInterfaceType:
return m.InterfaceType()
case model.FieldWeight:
return m.Weight()
case model.FieldThinkingEnabled:
return m.ThinkingEnabled()
case model.FieldSupportImage:
return m.SupportImage()
case model.FieldIsHidden:
return m.IsHidden()
case model.FieldContextLimit:
return m.ContextLimit()
case model.FieldOutputLimit:
return m.OutputLimit()
case model.FieldLastCheckAt:
return m.LastCheckAt()
case model.FieldLastCheckSuccess:
return m.LastCheckSuccess()
case model.FieldLastCheckError:
return m.LastCheckError()
case model.FieldCreatedAt:
return m.CreatedAt()
case model.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *ModelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case model.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case model.FieldUserID:
return m.OldUserID(ctx)
case model.FieldProvider:
return m.OldProvider(ctx)
case model.FieldAPIKey:
return m.OldAPIKey(ctx)
case model.FieldBaseURL:
return m.OldBaseURL(ctx)
case model.FieldModel:
return m.OldModel(ctx)
case model.FieldRemark:
return m.OldRemark(ctx)
case model.FieldTemperature:
return m.OldTemperature(ctx)
case model.FieldInterfaceType:
return m.OldInterfaceType(ctx)
case model.FieldWeight:
return m.OldWeight(ctx)
case model.FieldThinkingEnabled:
return m.OldThinkingEnabled(ctx)
case model.FieldSupportImage:
return m.OldSupportImage(ctx)
case model.FieldIsHidden:
return m.OldIsHidden(ctx)
case model.FieldContextLimit:
return m.OldContextLimit(ctx)
case model.FieldOutputLimit:
return m.OldOutputLimit(ctx)
case model.FieldLastCheckAt:
return m.OldLastCheckAt(ctx)
case model.FieldLastCheckSuccess:
return m.OldLastCheckSuccess(ctx)
case model.FieldLastCheckError:
return m.OldLastCheckError(ctx)
case model.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case model.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown Model 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 *ModelMutation) SetField(name string, value ent.Value) error {
switch name {
case model.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 model.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case model.FieldProvider:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetProvider(v)
return nil
case model.FieldAPIKey:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAPIKey(v)
return nil
case model.FieldBaseURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetBaseURL(v)
return nil
case model.FieldModel:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetModel(v)
return nil
case model.FieldRemark:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRemark(v)
return nil
case model.FieldTemperature:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTemperature(v)
return nil
case model.FieldInterfaceType:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetInterfaceType(v)
return nil
case model.FieldWeight:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetWeight(v)
return nil
case model.FieldThinkingEnabled:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetThinkingEnabled(v)
return nil
case model.FieldSupportImage:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSupportImage(v)
return nil
case model.FieldIsHidden:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetIsHidden(v)
return nil
case model.FieldContextLimit:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetContextLimit(v)
return nil
case model.FieldOutputLimit:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOutputLimit(v)
return nil
case model.FieldLastCheckAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLastCheckAt(v)
return nil
case model.FieldLastCheckSuccess:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLastCheckSuccess(v)
return nil
case model.FieldLastCheckError:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLastCheckError(v)
return nil
case model.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 model.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown Model field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ModelMutation) AddedFields() []string {
var fields []string
if m.addtemperature != nil {
fields = append(fields, model.FieldTemperature)
}
if m.addweight != nil {
fields = append(fields, model.FieldWeight)
}
if m.addcontext_limit != nil {
fields = append(fields, model.FieldContextLimit)
}
if m.addoutput_limit != nil {
fields = append(fields, model.FieldOutputLimit)
}
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 *ModelMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case model.FieldTemperature:
return m.AddedTemperature()
case model.FieldWeight:
return m.AddedWeight()
case model.FieldContextLimit:
return m.AddedContextLimit()
case model.FieldOutputLimit:
return m.AddedOutputLimit()
}
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 *ModelMutation) AddField(name string, value ent.Value) error {
switch name {
case model.FieldTemperature:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddTemperature(v)
return nil
case model.FieldWeight:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddWeight(v)
return nil
case model.FieldContextLimit:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddContextLimit(v)
return nil
case model.FieldOutputLimit:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddOutputLimit(v)
return nil
}
return fmt.Errorf("unknown Model numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ModelMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(model.FieldDeletedAt) {
fields = append(fields, model.FieldDeletedAt)
}
if m.FieldCleared(model.FieldRemark) {
fields = append(fields, model.FieldRemark)
}
if m.FieldCleared(model.FieldTemperature) {
fields = append(fields, model.FieldTemperature)
}
if m.FieldCleared(model.FieldInterfaceType) {
fields = append(fields, model.FieldInterfaceType)
}
if m.FieldCleared(model.FieldLastCheckAt) {
fields = append(fields, model.FieldLastCheckAt)
}
if m.FieldCleared(model.FieldLastCheckSuccess) {
fields = append(fields, model.FieldLastCheckSuccess)
}
if m.FieldCleared(model.FieldLastCheckError) {
fields = append(fields, model.FieldLastCheckError)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ModelMutation) 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 *ModelMutation) ClearField(name string) error {
switch name {
case model.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case model.FieldRemark:
m.ClearRemark()
return nil
case model.FieldTemperature:
m.ClearTemperature()
return nil
case model.FieldInterfaceType:
m.ClearInterfaceType()
return nil
case model.FieldLastCheckAt:
m.ClearLastCheckAt()
return nil
case model.FieldLastCheckSuccess:
m.ClearLastCheckSuccess()
return nil
case model.FieldLastCheckError:
m.ClearLastCheckError()
return nil
}
return fmt.Errorf("unknown Model 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 *ModelMutation) ResetField(name string) error {
switch name {
case model.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case model.FieldUserID:
m.ResetUserID()
return nil
case model.FieldProvider:
m.ResetProvider()
return nil
case model.FieldAPIKey:
m.ResetAPIKey()
return nil
case model.FieldBaseURL:
m.ResetBaseURL()
return nil
case model.FieldModel:
m.ResetModel()
return nil
case model.FieldRemark:
m.ResetRemark()
return nil
case model.FieldTemperature:
m.ResetTemperature()
return nil
case model.FieldInterfaceType:
m.ResetInterfaceType()
return nil
case model.FieldWeight:
m.ResetWeight()
return nil
case model.FieldThinkingEnabled:
m.ResetThinkingEnabled()
return nil
case model.FieldSupportImage:
m.ResetSupportImage()
return nil
case model.FieldIsHidden:
m.ResetIsHidden()
return nil
case model.FieldContextLimit:
m.ResetContextLimit()
return nil
case model.FieldOutputLimit:
m.ResetOutputLimit()
return nil
case model.FieldLastCheckAt:
m.ResetLastCheckAt()
return nil
case model.FieldLastCheckSuccess:
m.ResetLastCheckSuccess()
return nil
case model.FieldLastCheckError:
m.ResetLastCheckError()
return nil
case model.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case model.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown Model field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ModelMutation) AddedEdges() []string {
edges := make([]string, 0, 11)
if m.user != nil {
edges = append(edges, model.EdgeUser)
}
if m.teams != nil {
edges = append(edges, model.EdgeTeams)
}
if m.groups != nil {
edges = append(edges, model.EdgeGroups)
}
if m.vms != nil {
edges = append(edges, model.EdgeVms)
}
if m.project_tasks != nil {
edges = append(edges, model.EdgeProjectTasks)
}
if m.pricing != nil {
edges = append(edges, model.EdgePricing)
}
if m.apikeys != nil {
edges = append(edges, model.EdgeApikeys)
}
if m.switches_from != nil {
edges = append(edges, model.EdgeSwitchesFrom)
}
if m.switches_to != nil {
edges = append(edges, model.EdgeSwitchesTo)
}
if m.team_models != nil {
edges = append(edges, model.EdgeTeamModels)
}
if m.team_group_models != nil {
edges = append(edges, model.EdgeTeamGroupModels)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ModelMutation) AddedIDs(name string) []ent.Value {
switch name {
case model.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
case model.EdgeTeams:
ids := make([]ent.Value, 0, len(m.teams))
for id := range m.teams {
ids = append(ids, id)
}
return ids
case model.EdgeGroups:
ids := make([]ent.Value, 0, len(m.groups))
for id := range m.groups {
ids = append(ids, id)
}
return ids
case model.EdgeVms:
ids := make([]ent.Value, 0, len(m.vms))
for id := range m.vms {
ids = append(ids, id)
}
return ids
case model.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.project_tasks))
for id := range m.project_tasks {
ids = append(ids, id)
}
return ids
case model.EdgePricing:
if id := m.pricing; id != nil {
return []ent.Value{*id}
}
case model.EdgeApikeys:
ids := make([]ent.Value, 0, len(m.apikeys))
for id := range m.apikeys {
ids = append(ids, id)
}
return ids
case model.EdgeSwitchesFrom:
ids := make([]ent.Value, 0, len(m.switches_from))
for id := range m.switches_from {
ids = append(ids, id)
}
return ids
case model.EdgeSwitchesTo:
ids := make([]ent.Value, 0, len(m.switches_to))
for id := range m.switches_to {
ids = append(ids, id)
}
return ids
case model.EdgeTeamModels:
ids := make([]ent.Value, 0, len(m.team_models))
for id := range m.team_models {
ids = append(ids, id)
}
return ids
case model.EdgeTeamGroupModels:
ids := make([]ent.Value, 0, len(m.team_group_models))
for id := range m.team_group_models {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ModelMutation) RemovedEdges() []string {
edges := make([]string, 0, 11)
if m.removedteams != nil {
edges = append(edges, model.EdgeTeams)
}
if m.removedgroups != nil {
edges = append(edges, model.EdgeGroups)
}
if m.removedvms != nil {
edges = append(edges, model.EdgeVms)
}
if m.removedproject_tasks != nil {
edges = append(edges, model.EdgeProjectTasks)
}
if m.removedapikeys != nil {
edges = append(edges, model.EdgeApikeys)
}
if m.removedswitches_from != nil {
edges = append(edges, model.EdgeSwitchesFrom)
}
if m.removedswitches_to != nil {
edges = append(edges, model.EdgeSwitchesTo)
}
if m.removedteam_models != nil {
edges = append(edges, model.EdgeTeamModels)
}
if m.removedteam_group_models != nil {
edges = append(edges, model.EdgeTeamGroupModels)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ModelMutation) RemovedIDs(name string) []ent.Value {
switch name {
case model.EdgeTeams:
ids := make([]ent.Value, 0, len(m.removedteams))
for id := range m.removedteams {
ids = append(ids, id)
}
return ids
case model.EdgeGroups:
ids := make([]ent.Value, 0, len(m.removedgroups))
for id := range m.removedgroups {
ids = append(ids, id)
}
return ids
case model.EdgeVms:
ids := make([]ent.Value, 0, len(m.removedvms))
for id := range m.removedvms {
ids = append(ids, id)
}
return ids
case model.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.removedproject_tasks))
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return ids
case model.EdgeApikeys:
ids := make([]ent.Value, 0, len(m.removedapikeys))
for id := range m.removedapikeys {
ids = append(ids, id)
}
return ids
case model.EdgeSwitchesFrom:
ids := make([]ent.Value, 0, len(m.removedswitches_from))
for id := range m.removedswitches_from {
ids = append(ids, id)
}
return ids
case model.EdgeSwitchesTo:
ids := make([]ent.Value, 0, len(m.removedswitches_to))
for id := range m.removedswitches_to {
ids = append(ids, id)
}
return ids
case model.EdgeTeamModels:
ids := make([]ent.Value, 0, len(m.removedteam_models))
for id := range m.removedteam_models {
ids = append(ids, id)
}
return ids
case model.EdgeTeamGroupModels:
ids := make([]ent.Value, 0, len(m.removedteam_group_models))
for id := range m.removedteam_group_models {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ModelMutation) ClearedEdges() []string {
edges := make([]string, 0, 11)
if m.cleareduser {
edges = append(edges, model.EdgeUser)
}
if m.clearedteams {
edges = append(edges, model.EdgeTeams)
}
if m.clearedgroups {
edges = append(edges, model.EdgeGroups)
}
if m.clearedvms {
edges = append(edges, model.EdgeVms)
}
if m.clearedproject_tasks {
edges = append(edges, model.EdgeProjectTasks)
}
if m.clearedpricing {
edges = append(edges, model.EdgePricing)
}
if m.clearedapikeys {
edges = append(edges, model.EdgeApikeys)
}
if m.clearedswitches_from {
edges = append(edges, model.EdgeSwitchesFrom)
}
if m.clearedswitches_to {
edges = append(edges, model.EdgeSwitchesTo)
}
if m.clearedteam_models {
edges = append(edges, model.EdgeTeamModels)
}
if m.clearedteam_group_models {
edges = append(edges, model.EdgeTeamGroupModels)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ModelMutation) EdgeCleared(name string) bool {
switch name {
case model.EdgeUser:
return m.cleareduser
case model.EdgeTeams:
return m.clearedteams
case model.EdgeGroups:
return m.clearedgroups
case model.EdgeVms:
return m.clearedvms
case model.EdgeProjectTasks:
return m.clearedproject_tasks
case model.EdgePricing:
return m.clearedpricing
case model.EdgeApikeys:
return m.clearedapikeys
case model.EdgeSwitchesFrom:
return m.clearedswitches_from
case model.EdgeSwitchesTo:
return m.clearedswitches_to
case model.EdgeTeamModels:
return m.clearedteam_models
case model.EdgeTeamGroupModels:
return m.clearedteam_group_models
}
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 *ModelMutation) ClearEdge(name string) error {
switch name {
case model.EdgeUser:
m.ClearUser()
return nil
case model.EdgePricing:
m.ClearPricing()
return nil
}
return fmt.Errorf("unknown Model 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 *ModelMutation) ResetEdge(name string) error {
switch name {
case model.EdgeUser:
m.ResetUser()
return nil
case model.EdgeTeams:
m.ResetTeams()
return nil
case model.EdgeGroups:
m.ResetGroups()
return nil
case model.EdgeVms:
m.ResetVms()
return nil
case model.EdgeProjectTasks:
m.ResetProjectTasks()
return nil
case model.EdgePricing:
m.ResetPricing()
return nil
case model.EdgeApikeys:
m.ResetApikeys()
return nil
case model.EdgeSwitchesFrom:
m.ResetSwitchesFrom()
return nil
case model.EdgeSwitchesTo:
m.ResetSwitchesTo()
return nil
case model.EdgeTeamModels:
m.ResetTeamModels()
return nil
case model.EdgeTeamGroupModels:
m.ResetTeamGroupModels()
return nil
}
return fmt.Errorf("unknown Model edge %s", name)
}
// ModelApiKeyMutation represents an operation that mutates the ModelApiKey nodes in the graph.
type ModelApiKeyMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
user_id *uuid.UUID
virtualmachine_id *string
api_key *string
created_at *time.Time
clearedFields map[string]struct{}
model *uuid.UUID
clearedmodel bool
done bool
oldValue func(context.Context) (*ModelApiKey, error)
predicates []predicate.ModelApiKey
}
var _ ent.Mutation = (*ModelApiKeyMutation)(nil)
// modelapikeyOption allows management of the mutation configuration using functional options.
type modelapikeyOption func(*ModelApiKeyMutation)
// newModelApiKeyMutation creates new mutation for the ModelApiKey entity.
func newModelApiKeyMutation(c config, op Op, opts ...modelapikeyOption) *ModelApiKeyMutation {
m := &ModelApiKeyMutation{
config: c,
op: op,
typ: TypeModelApiKey,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withModelApiKeyID sets the ID field of the mutation.
func withModelApiKeyID(id uuid.UUID) modelapikeyOption {
return func(m *ModelApiKeyMutation) {
var (
err error
once sync.Once
value *ModelApiKey
)
m.oldValue = func(ctx context.Context) (*ModelApiKey, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().ModelApiKey.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withModelApiKey sets the old ModelApiKey of the mutation.
func withModelApiKey(node *ModelApiKey) modelapikeyOption {
return func(m *ModelApiKeyMutation) {
m.oldValue = func(context.Context) (*ModelApiKey, 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 ModelApiKeyMutation) 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 ModelApiKeyMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 ModelApiKey entities.
func (m *ModelApiKeyMutation) SetID(id uuid.UUID) {
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 *ModelApiKeyMutation) ID() (id uuid.UUID, 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 *ModelApiKeyMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().ModelApiKey.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *ModelApiKeyMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *ModelApiKeyMutation) 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 ModelApiKey entity.
// If the ModelApiKey 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 *ModelApiKeyMutation) 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 *ModelApiKeyMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[modelapikey.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *ModelApiKeyMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[modelapikey.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *ModelApiKeyMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, modelapikey.FieldDeletedAt)
}
// SetModelID sets the "model_id" field.
func (m *ModelApiKeyMutation) SetModelID(u uuid.UUID) {
m.model = &u
}
// ModelID returns the value of the "model_id" field in the mutation.
func (m *ModelApiKeyMutation) ModelID() (r uuid.UUID, exists bool) {
v := m.model
if v == nil {
return
}
return *v, true
}
// OldModelID returns the old "model_id" field's value of the ModelApiKey entity.
// If the ModelApiKey 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 *ModelApiKeyMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldModelID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldModelID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldModelID: %w", err)
}
return oldValue.ModelID, nil
}
// ResetModelID resets all changes to the "model_id" field.
func (m *ModelApiKeyMutation) ResetModelID() {
m.model = nil
}
// SetUserID sets the "user_id" field.
func (m *ModelApiKeyMutation) SetUserID(u uuid.UUID) {
m.user_id = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *ModelApiKeyMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user_id
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the ModelApiKey entity.
// If the ModelApiKey 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 *ModelApiKeyMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *ModelApiKeyMutation) ResetUserID() {
m.user_id = nil
}
// SetVirtualmachineID sets the "virtualmachine_id" field.
func (m *ModelApiKeyMutation) SetVirtualmachineID(s string) {
m.virtualmachine_id = &s
}
// VirtualmachineID returns the value of the "virtualmachine_id" field in the mutation.
func (m *ModelApiKeyMutation) VirtualmachineID() (r string, exists bool) {
v := m.virtualmachine_id
if v == nil {
return
}
return *v, true
}
// OldVirtualmachineID returns the old "virtualmachine_id" field's value of the ModelApiKey entity.
// If the ModelApiKey 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 *ModelApiKeyMutation) OldVirtualmachineID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldVirtualmachineID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldVirtualmachineID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldVirtualmachineID: %w", err)
}
return oldValue.VirtualmachineID, nil
}
// ClearVirtualmachineID clears the value of the "virtualmachine_id" field.
func (m *ModelApiKeyMutation) ClearVirtualmachineID() {
m.virtualmachine_id = nil
m.clearedFields[modelapikey.FieldVirtualmachineID] = struct{}{}
}
// VirtualmachineIDCleared returns if the "virtualmachine_id" field was cleared in this mutation.
func (m *ModelApiKeyMutation) VirtualmachineIDCleared() bool {
_, ok := m.clearedFields[modelapikey.FieldVirtualmachineID]
return ok
}
// ResetVirtualmachineID resets all changes to the "virtualmachine_id" field.
func (m *ModelApiKeyMutation) ResetVirtualmachineID() {
m.virtualmachine_id = nil
delete(m.clearedFields, modelapikey.FieldVirtualmachineID)
}
// SetAPIKey sets the "api_key" field.
func (m *ModelApiKeyMutation) SetAPIKey(s string) {
m.api_key = &s
}
// APIKey returns the value of the "api_key" field in the mutation.
func (m *ModelApiKeyMutation) APIKey() (r string, exists bool) {
v := m.api_key
if v == nil {
return
}
return *v, true
}
// OldAPIKey returns the old "api_key" field's value of the ModelApiKey entity.
// If the ModelApiKey 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 *ModelApiKeyMutation) OldAPIKey(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAPIKey requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
}
return oldValue.APIKey, nil
}
// ResetAPIKey resets all changes to the "api_key" field.
func (m *ModelApiKeyMutation) ResetAPIKey() {
m.api_key = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *ModelApiKeyMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ModelApiKeyMutation) 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 ModelApiKey entity.
// If the ModelApiKey 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 *ModelApiKeyMutation) 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 *ModelApiKeyMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearModel clears the "model" edge to the Model entity.
func (m *ModelApiKeyMutation) ClearModel() {
m.clearedmodel = true
m.clearedFields[modelapikey.FieldModelID] = struct{}{}
}
// ModelCleared reports if the "model" edge to the Model entity was cleared.
func (m *ModelApiKeyMutation) ModelCleared() bool {
return m.clearedmodel
}
// ModelIDs returns the "model" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ModelID instead. It exists only for internal usage by the builders.
func (m *ModelApiKeyMutation) ModelIDs() (ids []uuid.UUID) {
if id := m.model; id != nil {
ids = append(ids, *id)
}
return
}
// ResetModel resets all changes to the "model" edge.
func (m *ModelApiKeyMutation) ResetModel() {
m.model = nil
m.clearedmodel = false
}
// Where appends a list predicates to the ModelApiKeyMutation builder.
func (m *ModelApiKeyMutation) Where(ps ...predicate.ModelApiKey) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ModelApiKeyMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ModelApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.ModelApiKey, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ModelApiKeyMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ModelApiKeyMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (ModelApiKey).
func (m *ModelApiKeyMutation) 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 *ModelApiKeyMutation) Fields() []string {
fields := make([]string, 0, 6)
if m.deleted_at != nil {
fields = append(fields, modelapikey.FieldDeletedAt)
}
if m.model != nil {
fields = append(fields, modelapikey.FieldModelID)
}
if m.user_id != nil {
fields = append(fields, modelapikey.FieldUserID)
}
if m.virtualmachine_id != nil {
fields = append(fields, modelapikey.FieldVirtualmachineID)
}
if m.api_key != nil {
fields = append(fields, modelapikey.FieldAPIKey)
}
if m.created_at != nil {
fields = append(fields, modelapikey.FieldCreatedAt)
}
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 *ModelApiKeyMutation) Field(name string) (ent.Value, bool) {
switch name {
case modelapikey.FieldDeletedAt:
return m.DeletedAt()
case modelapikey.FieldModelID:
return m.ModelID()
case modelapikey.FieldUserID:
return m.UserID()
case modelapikey.FieldVirtualmachineID:
return m.VirtualmachineID()
case modelapikey.FieldAPIKey:
return m.APIKey()
case modelapikey.FieldCreatedAt:
return m.CreatedAt()
}
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 *ModelApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case modelapikey.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case modelapikey.FieldModelID:
return m.OldModelID(ctx)
case modelapikey.FieldUserID:
return m.OldUserID(ctx)
case modelapikey.FieldVirtualmachineID:
return m.OldVirtualmachineID(ctx)
case modelapikey.FieldAPIKey:
return m.OldAPIKey(ctx)
case modelapikey.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown ModelApiKey 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 *ModelApiKeyMutation) SetField(name string, value ent.Value) error {
switch name {
case modelapikey.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 modelapikey.FieldModelID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetModelID(v)
return nil
case modelapikey.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case modelapikey.FieldVirtualmachineID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetVirtualmachineID(v)
return nil
case modelapikey.FieldAPIKey:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAPIKey(v)
return nil
case modelapikey.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown ModelApiKey field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ModelApiKeyMutation) AddedFields() []string {
return nil
}
// 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 *ModelApiKeyMutation) AddedField(name string) (ent.Value, bool) {
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 *ModelApiKeyMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown ModelApiKey numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ModelApiKeyMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(modelapikey.FieldDeletedAt) {
fields = append(fields, modelapikey.FieldDeletedAt)
}
if m.FieldCleared(modelapikey.FieldVirtualmachineID) {
fields = append(fields, modelapikey.FieldVirtualmachineID)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ModelApiKeyMutation) 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 *ModelApiKeyMutation) ClearField(name string) error {
switch name {
case modelapikey.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case modelapikey.FieldVirtualmachineID:
m.ClearVirtualmachineID()
return nil
}
return fmt.Errorf("unknown ModelApiKey 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 *ModelApiKeyMutation) ResetField(name string) error {
switch name {
case modelapikey.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case modelapikey.FieldModelID:
m.ResetModelID()
return nil
case modelapikey.FieldUserID:
m.ResetUserID()
return nil
case modelapikey.FieldVirtualmachineID:
m.ResetVirtualmachineID()
return nil
case modelapikey.FieldAPIKey:
m.ResetAPIKey()
return nil
case modelapikey.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown ModelApiKey field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ModelApiKeyMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.model != nil {
edges = append(edges, modelapikey.EdgeModel)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ModelApiKeyMutation) AddedIDs(name string) []ent.Value {
switch name {
case modelapikey.EdgeModel:
if id := m.model; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ModelApiKeyMutation) 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 *ModelApiKeyMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ModelApiKeyMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedmodel {
edges = append(edges, modelapikey.EdgeModel)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ModelApiKeyMutation) EdgeCleared(name string) bool {
switch name {
case modelapikey.EdgeModel:
return m.clearedmodel
}
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 *ModelApiKeyMutation) ClearEdge(name string) error {
switch name {
case modelapikey.EdgeModel:
m.ClearModel()
return nil
}
return fmt.Errorf("unknown ModelApiKey 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 *ModelApiKeyMutation) ResetEdge(name string) error {
switch name {
case modelapikey.EdgeModel:
m.ResetModel()
return nil
}
return fmt.Errorf("unknown ModelApiKey edge %s", name)
}
// ModelPricingMutation represents an operation that mutates the ModelPricing nodes in the graph.
type ModelPricingMutation struct {
config
op Op
typ string
id *uuid.UUID
access_level *string
is_free *bool
input_price *int64
addinput_price *int64
output_price *int64
addoutput_price *int64
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
model *uuid.UUID
clearedmodel bool
done bool
oldValue func(context.Context) (*ModelPricing, error)
predicates []predicate.ModelPricing
}
var _ ent.Mutation = (*ModelPricingMutation)(nil)
// modelpricingOption allows management of the mutation configuration using functional options.
type modelpricingOption func(*ModelPricingMutation)
// newModelPricingMutation creates new mutation for the ModelPricing entity.
func newModelPricingMutation(c config, op Op, opts ...modelpricingOption) *ModelPricingMutation {
m := &ModelPricingMutation{
config: c,
op: op,
typ: TypeModelPricing,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withModelPricingID sets the ID field of the mutation.
func withModelPricingID(id uuid.UUID) modelpricingOption {
return func(m *ModelPricingMutation) {
var (
err error
once sync.Once
value *ModelPricing
)
m.oldValue = func(ctx context.Context) (*ModelPricing, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().ModelPricing.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withModelPricing sets the old ModelPricing of the mutation.
func withModelPricing(node *ModelPricing) modelpricingOption {
return func(m *ModelPricingMutation) {
m.oldValue = func(context.Context) (*ModelPricing, 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 ModelPricingMutation) 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 ModelPricingMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 ModelPricing entities.
func (m *ModelPricingMutation) SetID(id uuid.UUID) {
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 *ModelPricingMutation) ID() (id uuid.UUID, 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 *ModelPricingMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().ModelPricing.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetModelID sets the "model_id" field.
func (m *ModelPricingMutation) SetModelID(u uuid.UUID) {
m.model = &u
}
// ModelID returns the value of the "model_id" field in the mutation.
func (m *ModelPricingMutation) ModelID() (r uuid.UUID, exists bool) {
v := m.model
if v == nil {
return
}
return *v, true
}
// OldModelID returns the old "model_id" field's value of the ModelPricing entity.
// If the ModelPricing 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 *ModelPricingMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldModelID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldModelID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldModelID: %w", err)
}
return oldValue.ModelID, nil
}
// ResetModelID resets all changes to the "model_id" field.
func (m *ModelPricingMutation) ResetModelID() {
m.model = nil
}
// SetAccessLevel sets the "access_level" field.
func (m *ModelPricingMutation) SetAccessLevel(s string) {
m.access_level = &s
}
// AccessLevel returns the value of the "access_level" field in the mutation.
func (m *ModelPricingMutation) AccessLevel() (r string, exists bool) {
v := m.access_level
if v == nil {
return
}
return *v, true
}
// OldAccessLevel returns the old "access_level" field's value of the ModelPricing entity.
// If the ModelPricing 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 *ModelPricingMutation) OldAccessLevel(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAccessLevel is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAccessLevel requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAccessLevel: %w", err)
}
return oldValue.AccessLevel, nil
}
// ResetAccessLevel resets all changes to the "access_level" field.
func (m *ModelPricingMutation) ResetAccessLevel() {
m.access_level = nil
}
// SetIsFree sets the "is_free" field.
func (m *ModelPricingMutation) SetIsFree(b bool) {
m.is_free = &b
}
// IsFree returns the value of the "is_free" field in the mutation.
func (m *ModelPricingMutation) IsFree() (r bool, exists bool) {
v := m.is_free
if v == nil {
return
}
return *v, true
}
// OldIsFree returns the old "is_free" field's value of the ModelPricing entity.
// If the ModelPricing 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 *ModelPricingMutation) OldIsFree(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldIsFree is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldIsFree requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIsFree: %w", err)
}
return oldValue.IsFree, nil
}
// ResetIsFree resets all changes to the "is_free" field.
func (m *ModelPricingMutation) ResetIsFree() {
m.is_free = nil
}
// SetInputPrice sets the "input_price" field.
func (m *ModelPricingMutation) SetInputPrice(i int64) {
m.input_price = &i
m.addinput_price = nil
}
// InputPrice returns the value of the "input_price" field in the mutation.
func (m *ModelPricingMutation) InputPrice() (r int64, exists bool) {
v := m.input_price
if v == nil {
return
}
return *v, true
}
// OldInputPrice returns the old "input_price" field's value of the ModelPricing entity.
// If the ModelPricing 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 *ModelPricingMutation) OldInputPrice(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldInputPrice is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldInputPrice requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInputPrice: %w", err)
}
return oldValue.InputPrice, nil
}
// AddInputPrice adds i to the "input_price" field.
func (m *ModelPricingMutation) AddInputPrice(i int64) {
if m.addinput_price != nil {
*m.addinput_price += i
} else {
m.addinput_price = &i
}
}
// AddedInputPrice returns the value that was added to the "input_price" field in this mutation.
func (m *ModelPricingMutation) AddedInputPrice() (r int64, exists bool) {
v := m.addinput_price
if v == nil {
return
}
return *v, true
}
// ResetInputPrice resets all changes to the "input_price" field.
func (m *ModelPricingMutation) ResetInputPrice() {
m.input_price = nil
m.addinput_price = nil
}
// SetOutputPrice sets the "output_price" field.
func (m *ModelPricingMutation) SetOutputPrice(i int64) {
m.output_price = &i
m.addoutput_price = nil
}
// OutputPrice returns the value of the "output_price" field in the mutation.
func (m *ModelPricingMutation) OutputPrice() (r int64, exists bool) {
v := m.output_price
if v == nil {
return
}
return *v, true
}
// OldOutputPrice returns the old "output_price" field's value of the ModelPricing entity.
// If the ModelPricing 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 *ModelPricingMutation) OldOutputPrice(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOutputPrice is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOutputPrice requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOutputPrice: %w", err)
}
return oldValue.OutputPrice, nil
}
// AddOutputPrice adds i to the "output_price" field.
func (m *ModelPricingMutation) AddOutputPrice(i int64) {
if m.addoutput_price != nil {
*m.addoutput_price += i
} else {
m.addoutput_price = &i
}
}
// AddedOutputPrice returns the value that was added to the "output_price" field in this mutation.
func (m *ModelPricingMutation) AddedOutputPrice() (r int64, exists bool) {
v := m.addoutput_price
if v == nil {
return
}
return *v, true
}
// ResetOutputPrice resets all changes to the "output_price" field.
func (m *ModelPricingMutation) ResetOutputPrice() {
m.output_price = nil
m.addoutput_price = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *ModelPricingMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ModelPricingMutation) 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 ModelPricing entity.
// If the ModelPricing 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 *ModelPricingMutation) 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 *ModelPricingMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *ModelPricingMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *ModelPricingMutation) 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 ModelPricing entity.
// If the ModelPricing 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 *ModelPricingMutation) 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 *ModelPricingMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearModel clears the "model" edge to the Model entity.
func (m *ModelPricingMutation) ClearModel() {
m.clearedmodel = true
m.clearedFields[modelpricing.FieldModelID] = struct{}{}
}
// ModelCleared reports if the "model" edge to the Model entity was cleared.
func (m *ModelPricingMutation) ModelCleared() bool {
return m.clearedmodel
}
// ModelIDs returns the "model" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ModelID instead. It exists only for internal usage by the builders.
func (m *ModelPricingMutation) ModelIDs() (ids []uuid.UUID) {
if id := m.model; id != nil {
ids = append(ids, *id)
}
return
}
// ResetModel resets all changes to the "model" edge.
func (m *ModelPricingMutation) ResetModel() {
m.model = nil
m.clearedmodel = false
}
// Where appends a list predicates to the ModelPricingMutation builder.
func (m *ModelPricingMutation) Where(ps ...predicate.ModelPricing) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ModelPricingMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ModelPricingMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.ModelPricing, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ModelPricingMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ModelPricingMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (ModelPricing).
func (m *ModelPricingMutation) 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 *ModelPricingMutation) Fields() []string {
fields := make([]string, 0, 7)
if m.model != nil {
fields = append(fields, modelpricing.FieldModelID)
}
if m.access_level != nil {
fields = append(fields, modelpricing.FieldAccessLevel)
}
if m.is_free != nil {
fields = append(fields, modelpricing.FieldIsFree)
}
if m.input_price != nil {
fields = append(fields, modelpricing.FieldInputPrice)
}
if m.output_price != nil {
fields = append(fields, modelpricing.FieldOutputPrice)
}
if m.created_at != nil {
fields = append(fields, modelpricing.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, modelpricing.FieldUpdatedAt)
}
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 *ModelPricingMutation) Field(name string) (ent.Value, bool) {
switch name {
case modelpricing.FieldModelID:
return m.ModelID()
case modelpricing.FieldAccessLevel:
return m.AccessLevel()
case modelpricing.FieldIsFree:
return m.IsFree()
case modelpricing.FieldInputPrice:
return m.InputPrice()
case modelpricing.FieldOutputPrice:
return m.OutputPrice()
case modelpricing.FieldCreatedAt:
return m.CreatedAt()
case modelpricing.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *ModelPricingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case modelpricing.FieldModelID:
return m.OldModelID(ctx)
case modelpricing.FieldAccessLevel:
return m.OldAccessLevel(ctx)
case modelpricing.FieldIsFree:
return m.OldIsFree(ctx)
case modelpricing.FieldInputPrice:
return m.OldInputPrice(ctx)
case modelpricing.FieldOutputPrice:
return m.OldOutputPrice(ctx)
case modelpricing.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case modelpricing.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown ModelPricing 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 *ModelPricingMutation) SetField(name string, value ent.Value) error {
switch name {
case modelpricing.FieldModelID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetModelID(v)
return nil
case modelpricing.FieldAccessLevel:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAccessLevel(v)
return nil
case modelpricing.FieldIsFree:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetIsFree(v)
return nil
case modelpricing.FieldInputPrice:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetInputPrice(v)
return nil
case modelpricing.FieldOutputPrice:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOutputPrice(v)
return nil
case modelpricing.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 modelpricing.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown ModelPricing field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ModelPricingMutation) AddedFields() []string {
var fields []string
if m.addinput_price != nil {
fields = append(fields, modelpricing.FieldInputPrice)
}
if m.addoutput_price != nil {
fields = append(fields, modelpricing.FieldOutputPrice)
}
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 *ModelPricingMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case modelpricing.FieldInputPrice:
return m.AddedInputPrice()
case modelpricing.FieldOutputPrice:
return m.AddedOutputPrice()
}
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 *ModelPricingMutation) AddField(name string, value ent.Value) error {
switch name {
case modelpricing.FieldInputPrice:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddInputPrice(v)
return nil
case modelpricing.FieldOutputPrice:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddOutputPrice(v)
return nil
}
return fmt.Errorf("unknown ModelPricing numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ModelPricingMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ModelPricingMutation) 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 *ModelPricingMutation) ClearField(name string) error {
return fmt.Errorf("unknown ModelPricing 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 *ModelPricingMutation) ResetField(name string) error {
switch name {
case modelpricing.FieldModelID:
m.ResetModelID()
return nil
case modelpricing.FieldAccessLevel:
m.ResetAccessLevel()
return nil
case modelpricing.FieldIsFree:
m.ResetIsFree()
return nil
case modelpricing.FieldInputPrice:
m.ResetInputPrice()
return nil
case modelpricing.FieldOutputPrice:
m.ResetOutputPrice()
return nil
case modelpricing.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case modelpricing.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown ModelPricing field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ModelPricingMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.model != nil {
edges = append(edges, modelpricing.EdgeModel)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ModelPricingMutation) AddedIDs(name string) []ent.Value {
switch name {
case modelpricing.EdgeModel:
if id := m.model; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ModelPricingMutation) 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 *ModelPricingMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ModelPricingMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedmodel {
edges = append(edges, modelpricing.EdgeModel)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ModelPricingMutation) EdgeCleared(name string) bool {
switch name {
case modelpricing.EdgeModel:
return m.clearedmodel
}
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 *ModelPricingMutation) ClearEdge(name string) error {
switch name {
case modelpricing.EdgeModel:
m.ClearModel()
return nil
}
return fmt.Errorf("unknown ModelPricing 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 *ModelPricingMutation) ResetEdge(name string) error {
switch name {
case modelpricing.EdgeModel:
m.ResetModel()
return nil
}
return fmt.Errorf("unknown ModelPricing edge %s", name)
}
// NotifyChannelMutation represents an operation that mutates the NotifyChannel nodes in the graph.
type NotifyChannelMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
owner_id *uuid.UUID
owner_type *consts.NotifyOwnerType
name *string
kind *consts.NotifyChannelKind
webhook_url *string
secret *string
headers *map[string]string
metadata *map[string]string
target_id *string
enabled *bool
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
subscriptions map[uuid.UUID]struct{}
removedsubscriptions map[uuid.UUID]struct{}
clearedsubscriptions bool
done bool
oldValue func(context.Context) (*NotifyChannel, error)
predicates []predicate.NotifyChannel
}
var _ ent.Mutation = (*NotifyChannelMutation)(nil)
// notifychannelOption allows management of the mutation configuration using functional options.
type notifychannelOption func(*NotifyChannelMutation)
// newNotifyChannelMutation creates new mutation for the NotifyChannel entity.
func newNotifyChannelMutation(c config, op Op, opts ...notifychannelOption) *NotifyChannelMutation {
m := &NotifyChannelMutation{
config: c,
op: op,
typ: TypeNotifyChannel,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withNotifyChannelID sets the ID field of the mutation.
func withNotifyChannelID(id uuid.UUID) notifychannelOption {
return func(m *NotifyChannelMutation) {
var (
err error
once sync.Once
value *NotifyChannel
)
m.oldValue = func(ctx context.Context) (*NotifyChannel, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().NotifyChannel.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withNotifyChannel sets the old NotifyChannel of the mutation.
func withNotifyChannel(node *NotifyChannel) notifychannelOption {
return func(m *NotifyChannelMutation) {
m.oldValue = func(context.Context) (*NotifyChannel, 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 NotifyChannelMutation) 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 NotifyChannelMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 NotifyChannel entities.
func (m *NotifyChannelMutation) SetID(id uuid.UUID) {
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 *NotifyChannelMutation) ID() (id uuid.UUID, 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 *NotifyChannelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().NotifyChannel.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *NotifyChannelMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *NotifyChannelMutation) 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 NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) 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 *NotifyChannelMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[notifychannel.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *NotifyChannelMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[notifychannel.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *NotifyChannelMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, notifychannel.FieldDeletedAt)
}
// SetOwnerID sets the "owner_id" field.
func (m *NotifyChannelMutation) SetOwnerID(u uuid.UUID) {
m.owner_id = &u
}
// OwnerID returns the value of the "owner_id" field in the mutation.
func (m *NotifyChannelMutation) OwnerID() (r uuid.UUID, exists bool) {
v := m.owner_id
if v == nil {
return
}
return *v, true
}
// OldOwnerID returns the old "owner_id" field's value of the NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) OldOwnerID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOwnerID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOwnerID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOwnerID: %w", err)
}
return oldValue.OwnerID, nil
}
// ResetOwnerID resets all changes to the "owner_id" field.
func (m *NotifyChannelMutation) ResetOwnerID() {
m.owner_id = nil
}
// SetOwnerType sets the "owner_type" field.
func (m *NotifyChannelMutation) SetOwnerType(cot consts.NotifyOwnerType) {
m.owner_type = &cot
}
// OwnerType returns the value of the "owner_type" field in the mutation.
func (m *NotifyChannelMutation) OwnerType() (r consts.NotifyOwnerType, exists bool) {
v := m.owner_type
if v == nil {
return
}
return *v, true
}
// OldOwnerType returns the old "owner_type" field's value of the NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) OldOwnerType(ctx context.Context) (v consts.NotifyOwnerType, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOwnerType is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOwnerType requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOwnerType: %w", err)
}
return oldValue.OwnerType, nil
}
// ResetOwnerType resets all changes to the "owner_type" field.
func (m *NotifyChannelMutation) ResetOwnerType() {
m.owner_type = nil
}
// SetName sets the "name" field.
func (m *NotifyChannelMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *NotifyChannelMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldName: %w", err)
}
return oldValue.Name, nil
}
// ResetName resets all changes to the "name" field.
func (m *NotifyChannelMutation) ResetName() {
m.name = nil
}
// SetKind sets the "kind" field.
func (m *NotifyChannelMutation) SetKind(cck consts.NotifyChannelKind) {
m.kind = &cck
}
// Kind returns the value of the "kind" field in the mutation.
func (m *NotifyChannelMutation) Kind() (r consts.NotifyChannelKind, exists bool) {
v := m.kind
if v == nil {
return
}
return *v, true
}
// OldKind returns the old "kind" field's value of the NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) OldKind(ctx context.Context) (v consts.NotifyChannelKind, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldKind is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldKind requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldKind: %w", err)
}
return oldValue.Kind, nil
}
// ResetKind resets all changes to the "kind" field.
func (m *NotifyChannelMutation) ResetKind() {
m.kind = nil
}
// SetWebhookURL sets the "webhook_url" field.
func (m *NotifyChannelMutation) SetWebhookURL(s string) {
m.webhook_url = &s
}
// WebhookURL returns the value of the "webhook_url" field in the mutation.
func (m *NotifyChannelMutation) WebhookURL() (r string, exists bool) {
v := m.webhook_url
if v == nil {
return
}
return *v, true
}
// OldWebhookURL returns the old "webhook_url" field's value of the NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) OldWebhookURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldWebhookURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldWebhookURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldWebhookURL: %w", err)
}
return oldValue.WebhookURL, nil
}
// ResetWebhookURL resets all changes to the "webhook_url" field.
func (m *NotifyChannelMutation) ResetWebhookURL() {
m.webhook_url = nil
}
// SetSecret sets the "secret" field.
func (m *NotifyChannelMutation) SetSecret(s string) {
m.secret = &s
}
// Secret returns the value of the "secret" field in the mutation.
func (m *NotifyChannelMutation) Secret() (r string, exists bool) {
v := m.secret
if v == nil {
return
}
return *v, true
}
// OldSecret returns the old "secret" field's value of the NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) OldSecret(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSecret is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSecret requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSecret: %w", err)
}
return oldValue.Secret, nil
}
// ClearSecret clears the value of the "secret" field.
func (m *NotifyChannelMutation) ClearSecret() {
m.secret = nil
m.clearedFields[notifychannel.FieldSecret] = struct{}{}
}
// SecretCleared returns if the "secret" field was cleared in this mutation.
func (m *NotifyChannelMutation) SecretCleared() bool {
_, ok := m.clearedFields[notifychannel.FieldSecret]
return ok
}
// ResetSecret resets all changes to the "secret" field.
func (m *NotifyChannelMutation) ResetSecret() {
m.secret = nil
delete(m.clearedFields, notifychannel.FieldSecret)
}
// SetHeaders sets the "headers" field.
func (m *NotifyChannelMutation) SetHeaders(value map[string]string) {
m.headers = &value
}
// Headers returns the value of the "headers" field in the mutation.
func (m *NotifyChannelMutation) Headers() (r map[string]string, exists bool) {
v := m.headers
if v == nil {
return
}
return *v, true
}
// OldHeaders returns the old "headers" field's value of the NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) OldHeaders(ctx context.Context) (v map[string]string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHeaders is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHeaders requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHeaders: %w", err)
}
return oldValue.Headers, nil
}
// ClearHeaders clears the value of the "headers" field.
func (m *NotifyChannelMutation) ClearHeaders() {
m.headers = nil
m.clearedFields[notifychannel.FieldHeaders] = struct{}{}
}
// HeadersCleared returns if the "headers" field was cleared in this mutation.
func (m *NotifyChannelMutation) HeadersCleared() bool {
_, ok := m.clearedFields[notifychannel.FieldHeaders]
return ok
}
// ResetHeaders resets all changes to the "headers" field.
func (m *NotifyChannelMutation) ResetHeaders() {
m.headers = nil
delete(m.clearedFields, notifychannel.FieldHeaders)
}
// SetMetadata sets the "metadata" field.
func (m *NotifyChannelMutation) SetMetadata(value map[string]string) {
m.metadata = &value
}
// Metadata returns the value of the "metadata" field in the mutation.
func (m *NotifyChannelMutation) Metadata() (r map[string]string, exists bool) {
v := m.metadata
if v == nil {
return
}
return *v, true
}
// OldMetadata returns the old "metadata" field's value of the NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) OldMetadata(ctx context.Context) (v map[string]string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMetadata is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldMetadata requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMetadata: %w", err)
}
return oldValue.Metadata, nil
}
// ClearMetadata clears the value of the "metadata" field.
func (m *NotifyChannelMutation) ClearMetadata() {
m.metadata = nil
m.clearedFields[notifychannel.FieldMetadata] = struct{}{}
}
// MetadataCleared returns if the "metadata" field was cleared in this mutation.
func (m *NotifyChannelMutation) MetadataCleared() bool {
_, ok := m.clearedFields[notifychannel.FieldMetadata]
return ok
}
// ResetMetadata resets all changes to the "metadata" field.
func (m *NotifyChannelMutation) ResetMetadata() {
m.metadata = nil
delete(m.clearedFields, notifychannel.FieldMetadata)
}
// SetTargetID sets the "target_id" field.
func (m *NotifyChannelMutation) SetTargetID(s string) {
m.target_id = &s
}
// TargetID returns the value of the "target_id" field in the mutation.
func (m *NotifyChannelMutation) TargetID() (r string, exists bool) {
v := m.target_id
if v == nil {
return
}
return *v, true
}
// OldTargetID returns the old "target_id" field's value of the NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) OldTargetID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTargetID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTargetID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTargetID: %w", err)
}
return oldValue.TargetID, nil
}
// ResetTargetID resets all changes to the "target_id" field.
func (m *NotifyChannelMutation) ResetTargetID() {
m.target_id = nil
}
// SetEnabled sets the "enabled" field.
func (m *NotifyChannelMutation) SetEnabled(b bool) {
m.enabled = &b
}
// Enabled returns the value of the "enabled" field in the mutation.
func (m *NotifyChannelMutation) Enabled() (r bool, exists bool) {
v := m.enabled
if v == nil {
return
}
return *v, true
}
// OldEnabled returns the old "enabled" field's value of the NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) OldEnabled(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEnabled requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
}
return oldValue.Enabled, nil
}
// ResetEnabled resets all changes to the "enabled" field.
func (m *NotifyChannelMutation) ResetEnabled() {
m.enabled = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *NotifyChannelMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *NotifyChannelMutation) 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 NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) 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 *NotifyChannelMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *NotifyChannelMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *NotifyChannelMutation) 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 NotifyChannel entity.
// If the NotifyChannel 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 *NotifyChannelMutation) 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 *NotifyChannelMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// AddSubscriptionIDs adds the "subscriptions" edge to the NotifySubscription entity by ids.
func (m *NotifyChannelMutation) AddSubscriptionIDs(ids ...uuid.UUID) {
if m.subscriptions == nil {
m.subscriptions = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.subscriptions[ids[i]] = struct{}{}
}
}
// ClearSubscriptions clears the "subscriptions" edge to the NotifySubscription entity.
func (m *NotifyChannelMutation) ClearSubscriptions() {
m.clearedsubscriptions = true
}
// SubscriptionsCleared reports if the "subscriptions" edge to the NotifySubscription entity was cleared.
func (m *NotifyChannelMutation) SubscriptionsCleared() bool {
return m.clearedsubscriptions
}
// RemoveSubscriptionIDs removes the "subscriptions" edge to the NotifySubscription entity by IDs.
func (m *NotifyChannelMutation) RemoveSubscriptionIDs(ids ...uuid.UUID) {
if m.removedsubscriptions == nil {
m.removedsubscriptions = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.subscriptions, ids[i])
m.removedsubscriptions[ids[i]] = struct{}{}
}
}
// RemovedSubscriptions returns the removed IDs of the "subscriptions" edge to the NotifySubscription entity.
func (m *NotifyChannelMutation) RemovedSubscriptionsIDs() (ids []uuid.UUID) {
for id := range m.removedsubscriptions {
ids = append(ids, id)
}
return
}
// SubscriptionsIDs returns the "subscriptions" edge IDs in the mutation.
func (m *NotifyChannelMutation) SubscriptionsIDs() (ids []uuid.UUID) {
for id := range m.subscriptions {
ids = append(ids, id)
}
return
}
// ResetSubscriptions resets all changes to the "subscriptions" edge.
func (m *NotifyChannelMutation) ResetSubscriptions() {
m.subscriptions = nil
m.clearedsubscriptions = false
m.removedsubscriptions = nil
}
// Where appends a list predicates to the NotifyChannelMutation builder.
func (m *NotifyChannelMutation) Where(ps ...predicate.NotifyChannel) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the NotifyChannelMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *NotifyChannelMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.NotifyChannel, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *NotifyChannelMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *NotifyChannelMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (NotifyChannel).
func (m *NotifyChannelMutation) 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 *NotifyChannelMutation) Fields() []string {
fields := make([]string, 0, 13)
if m.deleted_at != nil {
fields = append(fields, notifychannel.FieldDeletedAt)
}
if m.owner_id != nil {
fields = append(fields, notifychannel.FieldOwnerID)
}
if m.owner_type != nil {
fields = append(fields, notifychannel.FieldOwnerType)
}
if m.name != nil {
fields = append(fields, notifychannel.FieldName)
}
if m.kind != nil {
fields = append(fields, notifychannel.FieldKind)
}
if m.webhook_url != nil {
fields = append(fields, notifychannel.FieldWebhookURL)
}
if m.secret != nil {
fields = append(fields, notifychannel.FieldSecret)
}
if m.headers != nil {
fields = append(fields, notifychannel.FieldHeaders)
}
if m.metadata != nil {
fields = append(fields, notifychannel.FieldMetadata)
}
if m.target_id != nil {
fields = append(fields, notifychannel.FieldTargetID)
}
if m.enabled != nil {
fields = append(fields, notifychannel.FieldEnabled)
}
if m.created_at != nil {
fields = append(fields, notifychannel.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, notifychannel.FieldUpdatedAt)
}
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 *NotifyChannelMutation) Field(name string) (ent.Value, bool) {
switch name {
case notifychannel.FieldDeletedAt:
return m.DeletedAt()
case notifychannel.FieldOwnerID:
return m.OwnerID()
case notifychannel.FieldOwnerType:
return m.OwnerType()
case notifychannel.FieldName:
return m.Name()
case notifychannel.FieldKind:
return m.Kind()
case notifychannel.FieldWebhookURL:
return m.WebhookURL()
case notifychannel.FieldSecret:
return m.Secret()
case notifychannel.FieldHeaders:
return m.Headers()
case notifychannel.FieldMetadata:
return m.Metadata()
case notifychannel.FieldTargetID:
return m.TargetID()
case notifychannel.FieldEnabled:
return m.Enabled()
case notifychannel.FieldCreatedAt:
return m.CreatedAt()
case notifychannel.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *NotifyChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case notifychannel.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case notifychannel.FieldOwnerID:
return m.OldOwnerID(ctx)
case notifychannel.FieldOwnerType:
return m.OldOwnerType(ctx)
case notifychannel.FieldName:
return m.OldName(ctx)
case notifychannel.FieldKind:
return m.OldKind(ctx)
case notifychannel.FieldWebhookURL:
return m.OldWebhookURL(ctx)
case notifychannel.FieldSecret:
return m.OldSecret(ctx)
case notifychannel.FieldHeaders:
return m.OldHeaders(ctx)
case notifychannel.FieldMetadata:
return m.OldMetadata(ctx)
case notifychannel.FieldTargetID:
return m.OldTargetID(ctx)
case notifychannel.FieldEnabled:
return m.OldEnabled(ctx)
case notifychannel.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case notifychannel.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown NotifyChannel 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 *NotifyChannelMutation) SetField(name string, value ent.Value) error {
switch name {
case notifychannel.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 notifychannel.FieldOwnerID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOwnerID(v)
return nil
case notifychannel.FieldOwnerType:
v, ok := value.(consts.NotifyOwnerType)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOwnerType(v)
return nil
case notifychannel.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case notifychannel.FieldKind:
v, ok := value.(consts.NotifyChannelKind)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetKind(v)
return nil
case notifychannel.FieldWebhookURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetWebhookURL(v)
return nil
case notifychannel.FieldSecret:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSecret(v)
return nil
case notifychannel.FieldHeaders:
v, ok := value.(map[string]string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHeaders(v)
return nil
case notifychannel.FieldMetadata:
v, ok := value.(map[string]string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMetadata(v)
return nil
case notifychannel.FieldTargetID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTargetID(v)
return nil
case notifychannel.FieldEnabled:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEnabled(v)
return nil
case notifychannel.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 notifychannel.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown NotifyChannel field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *NotifyChannelMutation) AddedFields() []string {
return nil
}
// 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 *NotifyChannelMutation) AddedField(name string) (ent.Value, bool) {
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 *NotifyChannelMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown NotifyChannel numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *NotifyChannelMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(notifychannel.FieldDeletedAt) {
fields = append(fields, notifychannel.FieldDeletedAt)
}
if m.FieldCleared(notifychannel.FieldSecret) {
fields = append(fields, notifychannel.FieldSecret)
}
if m.FieldCleared(notifychannel.FieldHeaders) {
fields = append(fields, notifychannel.FieldHeaders)
}
if m.FieldCleared(notifychannel.FieldMetadata) {
fields = append(fields, notifychannel.FieldMetadata)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *NotifyChannelMutation) 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 *NotifyChannelMutation) ClearField(name string) error {
switch name {
case notifychannel.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case notifychannel.FieldSecret:
m.ClearSecret()
return nil
case notifychannel.FieldHeaders:
m.ClearHeaders()
return nil
case notifychannel.FieldMetadata:
m.ClearMetadata()
return nil
}
return fmt.Errorf("unknown NotifyChannel 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 *NotifyChannelMutation) ResetField(name string) error {
switch name {
case notifychannel.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case notifychannel.FieldOwnerID:
m.ResetOwnerID()
return nil
case notifychannel.FieldOwnerType:
m.ResetOwnerType()
return nil
case notifychannel.FieldName:
m.ResetName()
return nil
case notifychannel.FieldKind:
m.ResetKind()
return nil
case notifychannel.FieldWebhookURL:
m.ResetWebhookURL()
return nil
case notifychannel.FieldSecret:
m.ResetSecret()
return nil
case notifychannel.FieldHeaders:
m.ResetHeaders()
return nil
case notifychannel.FieldMetadata:
m.ResetMetadata()
return nil
case notifychannel.FieldTargetID:
m.ResetTargetID()
return nil
case notifychannel.FieldEnabled:
m.ResetEnabled()
return nil
case notifychannel.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case notifychannel.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown NotifyChannel field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *NotifyChannelMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.subscriptions != nil {
edges = append(edges, notifychannel.EdgeSubscriptions)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *NotifyChannelMutation) AddedIDs(name string) []ent.Value {
switch name {
case notifychannel.EdgeSubscriptions:
ids := make([]ent.Value, 0, len(m.subscriptions))
for id := range m.subscriptions {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *NotifyChannelMutation) RemovedEdges() []string {
edges := make([]string, 0, 1)
if m.removedsubscriptions != nil {
edges = append(edges, notifychannel.EdgeSubscriptions)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *NotifyChannelMutation) RemovedIDs(name string) []ent.Value {
switch name {
case notifychannel.EdgeSubscriptions:
ids := make([]ent.Value, 0, len(m.removedsubscriptions))
for id := range m.removedsubscriptions {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *NotifyChannelMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedsubscriptions {
edges = append(edges, notifychannel.EdgeSubscriptions)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *NotifyChannelMutation) EdgeCleared(name string) bool {
switch name {
case notifychannel.EdgeSubscriptions:
return m.clearedsubscriptions
}
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 *NotifyChannelMutation) ClearEdge(name string) error {
switch name {
}
return fmt.Errorf("unknown NotifyChannel 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 *NotifyChannelMutation) ResetEdge(name string) error {
switch name {
case notifychannel.EdgeSubscriptions:
m.ResetSubscriptions()
return nil
}
return fmt.Errorf("unknown NotifyChannel edge %s", name)
}
// NotifySendLogMutation represents an operation that mutates the NotifySendLog nodes in the graph.
type NotifySendLogMutation struct {
config
op Op
typ string
id *uuid.UUID
subscription_id *uuid.UUID
channel_id *uuid.UUID
event_type *consts.NotifyEventType
event_ref_id *string
status *consts.NotifySendStatus
error *string
created_at *time.Time
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*NotifySendLog, error)
predicates []predicate.NotifySendLog
}
var _ ent.Mutation = (*NotifySendLogMutation)(nil)
// notifysendlogOption allows management of the mutation configuration using functional options.
type notifysendlogOption func(*NotifySendLogMutation)
// newNotifySendLogMutation creates new mutation for the NotifySendLog entity.
func newNotifySendLogMutation(c config, op Op, opts ...notifysendlogOption) *NotifySendLogMutation {
m := &NotifySendLogMutation{
config: c,
op: op,
typ: TypeNotifySendLog,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withNotifySendLogID sets the ID field of the mutation.
func withNotifySendLogID(id uuid.UUID) notifysendlogOption {
return func(m *NotifySendLogMutation) {
var (
err error
once sync.Once
value *NotifySendLog
)
m.oldValue = func(ctx context.Context) (*NotifySendLog, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().NotifySendLog.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withNotifySendLog sets the old NotifySendLog of the mutation.
func withNotifySendLog(node *NotifySendLog) notifysendlogOption {
return func(m *NotifySendLogMutation) {
m.oldValue = func(context.Context) (*NotifySendLog, 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 NotifySendLogMutation) 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 NotifySendLogMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 NotifySendLog entities.
func (m *NotifySendLogMutation) SetID(id uuid.UUID) {
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 *NotifySendLogMutation) ID() (id uuid.UUID, 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 *NotifySendLogMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().NotifySendLog.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetSubscriptionID sets the "subscription_id" field.
func (m *NotifySendLogMutation) SetSubscriptionID(u uuid.UUID) {
m.subscription_id = &u
}
// SubscriptionID returns the value of the "subscription_id" field in the mutation.
func (m *NotifySendLogMutation) SubscriptionID() (r uuid.UUID, exists bool) {
v := m.subscription_id
if v == nil {
return
}
return *v, true
}
// OldSubscriptionID returns the old "subscription_id" field's value of the NotifySendLog entity.
// If the NotifySendLog 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 *NotifySendLogMutation) OldSubscriptionID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSubscriptionID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSubscriptionID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSubscriptionID: %w", err)
}
return oldValue.SubscriptionID, nil
}
// ResetSubscriptionID resets all changes to the "subscription_id" field.
func (m *NotifySendLogMutation) ResetSubscriptionID() {
m.subscription_id = nil
}
// SetChannelID sets the "channel_id" field.
func (m *NotifySendLogMutation) SetChannelID(u uuid.UUID) {
m.channel_id = &u
}
// ChannelID returns the value of the "channel_id" field in the mutation.
func (m *NotifySendLogMutation) ChannelID() (r uuid.UUID, exists bool) {
v := m.channel_id
if v == nil {
return
}
return *v, true
}
// OldChannelID returns the old "channel_id" field's value of the NotifySendLog entity.
// If the NotifySendLog 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 *NotifySendLogMutation) OldChannelID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldChannelID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldChannelID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldChannelID: %w", err)
}
return oldValue.ChannelID, nil
}
// ResetChannelID resets all changes to the "channel_id" field.
func (m *NotifySendLogMutation) ResetChannelID() {
m.channel_id = nil
}
// SetEventType sets the "event_type" field.
func (m *NotifySendLogMutation) SetEventType(cet consts.NotifyEventType) {
m.event_type = &cet
}
// EventType returns the value of the "event_type" field in the mutation.
func (m *NotifySendLogMutation) EventType() (r consts.NotifyEventType, exists bool) {
v := m.event_type
if v == nil {
return
}
return *v, true
}
// OldEventType returns the old "event_type" field's value of the NotifySendLog entity.
// If the NotifySendLog 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 *NotifySendLogMutation) OldEventType(ctx context.Context) (v consts.NotifyEventType, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEventType is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEventType requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEventType: %w", err)
}
return oldValue.EventType, nil
}
// ResetEventType resets all changes to the "event_type" field.
func (m *NotifySendLogMutation) ResetEventType() {
m.event_type = nil
}
// SetEventRefID sets the "event_ref_id" field.
func (m *NotifySendLogMutation) SetEventRefID(s string) {
m.event_ref_id = &s
}
// EventRefID returns the value of the "event_ref_id" field in the mutation.
func (m *NotifySendLogMutation) EventRefID() (r string, exists bool) {
v := m.event_ref_id
if v == nil {
return
}
return *v, true
}
// OldEventRefID returns the old "event_ref_id" field's value of the NotifySendLog entity.
// If the NotifySendLog 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 *NotifySendLogMutation) OldEventRefID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEventRefID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEventRefID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEventRefID: %w", err)
}
return oldValue.EventRefID, nil
}
// ResetEventRefID resets all changes to the "event_ref_id" field.
func (m *NotifySendLogMutation) ResetEventRefID() {
m.event_ref_id = nil
}
// SetStatus sets the "status" field.
func (m *NotifySendLogMutation) SetStatus(css consts.NotifySendStatus) {
m.status = &css
}
// Status returns the value of the "status" field in the mutation.
func (m *NotifySendLogMutation) Status() (r consts.NotifySendStatus, exists bool) {
v := m.status
if v == nil {
return
}
return *v, true
}
// OldStatus returns the old "status" field's value of the NotifySendLog entity.
// If the NotifySendLog 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 *NotifySendLogMutation) OldStatus(ctx context.Context) (v consts.NotifySendStatus, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldStatus is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldStatus requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStatus: %w", err)
}
return oldValue.Status, nil
}
// ResetStatus resets all changes to the "status" field.
func (m *NotifySendLogMutation) ResetStatus() {
m.status = nil
}
// SetError sets the "error" field.
func (m *NotifySendLogMutation) SetError(s string) {
m.error = &s
}
// Error returns the value of the "error" field in the mutation.
func (m *NotifySendLogMutation) Error() (r string, exists bool) {
v := m.error
if v == nil {
return
}
return *v, true
}
// OldError returns the old "error" field's value of the NotifySendLog entity.
// If the NotifySendLog 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 *NotifySendLogMutation) OldError(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldError is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldError requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldError: %w", err)
}
return oldValue.Error, nil
}
// ClearError clears the value of the "error" field.
func (m *NotifySendLogMutation) ClearError() {
m.error = nil
m.clearedFields[notifysendlog.FieldError] = struct{}{}
}
// ErrorCleared returns if the "error" field was cleared in this mutation.
func (m *NotifySendLogMutation) ErrorCleared() bool {
_, ok := m.clearedFields[notifysendlog.FieldError]
return ok
}
// ResetError resets all changes to the "error" field.
func (m *NotifySendLogMutation) ResetError() {
m.error = nil
delete(m.clearedFields, notifysendlog.FieldError)
}
// SetCreatedAt sets the "created_at" field.
func (m *NotifySendLogMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *NotifySendLogMutation) 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 NotifySendLog entity.
// If the NotifySendLog 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 *NotifySendLogMutation) 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 *NotifySendLogMutation) ResetCreatedAt() {
m.created_at = nil
}
// Where appends a list predicates to the NotifySendLogMutation builder.
func (m *NotifySendLogMutation) Where(ps ...predicate.NotifySendLog) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the NotifySendLogMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *NotifySendLogMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.NotifySendLog, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *NotifySendLogMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *NotifySendLogMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (NotifySendLog).
func (m *NotifySendLogMutation) 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 *NotifySendLogMutation) Fields() []string {
fields := make([]string, 0, 7)
if m.subscription_id != nil {
fields = append(fields, notifysendlog.FieldSubscriptionID)
}
if m.channel_id != nil {
fields = append(fields, notifysendlog.FieldChannelID)
}
if m.event_type != nil {
fields = append(fields, notifysendlog.FieldEventType)
}
if m.event_ref_id != nil {
fields = append(fields, notifysendlog.FieldEventRefID)
}
if m.status != nil {
fields = append(fields, notifysendlog.FieldStatus)
}
if m.error != nil {
fields = append(fields, notifysendlog.FieldError)
}
if m.created_at != nil {
fields = append(fields, notifysendlog.FieldCreatedAt)
}
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 *NotifySendLogMutation) Field(name string) (ent.Value, bool) {
switch name {
case notifysendlog.FieldSubscriptionID:
return m.SubscriptionID()
case notifysendlog.FieldChannelID:
return m.ChannelID()
case notifysendlog.FieldEventType:
return m.EventType()
case notifysendlog.FieldEventRefID:
return m.EventRefID()
case notifysendlog.FieldStatus:
return m.Status()
case notifysendlog.FieldError:
return m.Error()
case notifysendlog.FieldCreatedAt:
return m.CreatedAt()
}
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 *NotifySendLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case notifysendlog.FieldSubscriptionID:
return m.OldSubscriptionID(ctx)
case notifysendlog.FieldChannelID:
return m.OldChannelID(ctx)
case notifysendlog.FieldEventType:
return m.OldEventType(ctx)
case notifysendlog.FieldEventRefID:
return m.OldEventRefID(ctx)
case notifysendlog.FieldStatus:
return m.OldStatus(ctx)
case notifysendlog.FieldError:
return m.OldError(ctx)
case notifysendlog.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown NotifySendLog 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 *NotifySendLogMutation) SetField(name string, value ent.Value) error {
switch name {
case notifysendlog.FieldSubscriptionID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSubscriptionID(v)
return nil
case notifysendlog.FieldChannelID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetChannelID(v)
return nil
case notifysendlog.FieldEventType:
v, ok := value.(consts.NotifyEventType)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEventType(v)
return nil
case notifysendlog.FieldEventRefID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEventRefID(v)
return nil
case notifysendlog.FieldStatus:
v, ok := value.(consts.NotifySendStatus)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetStatus(v)
return nil
case notifysendlog.FieldError:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetError(v)
return nil
case notifysendlog.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown NotifySendLog field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *NotifySendLogMutation) AddedFields() []string {
return nil
}
// 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 *NotifySendLogMutation) AddedField(name string) (ent.Value, bool) {
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 *NotifySendLogMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown NotifySendLog numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *NotifySendLogMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(notifysendlog.FieldError) {
fields = append(fields, notifysendlog.FieldError)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *NotifySendLogMutation) 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 *NotifySendLogMutation) ClearField(name string) error {
switch name {
case notifysendlog.FieldError:
m.ClearError()
return nil
}
return fmt.Errorf("unknown NotifySendLog 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 *NotifySendLogMutation) ResetField(name string) error {
switch name {
case notifysendlog.FieldSubscriptionID:
m.ResetSubscriptionID()
return nil
case notifysendlog.FieldChannelID:
m.ResetChannelID()
return nil
case notifysendlog.FieldEventType:
m.ResetEventType()
return nil
case notifysendlog.FieldEventRefID:
m.ResetEventRefID()
return nil
case notifysendlog.FieldStatus:
m.ResetStatus()
return nil
case notifysendlog.FieldError:
m.ResetError()
return nil
case notifysendlog.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown NotifySendLog field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *NotifySendLogMutation) AddedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *NotifySendLogMutation) AddedIDs(name string) []ent.Value {
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *NotifySendLogMutation) RemovedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *NotifySendLogMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *NotifySendLogMutation) ClearedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *NotifySendLogMutation) EdgeCleared(name string) bool {
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 *NotifySendLogMutation) ClearEdge(name string) error {
return fmt.Errorf("unknown NotifySendLog 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 *NotifySendLogMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown NotifySendLog edge %s", name)
}
// NotifySubscriptionMutation represents an operation that mutates the NotifySubscription nodes in the graph.
type NotifySubscriptionMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
scope *string
event_types *[]consts.NotifyEventType
appendevent_types []consts.NotifyEventType
enabled *bool
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
channel *uuid.UUID
clearedchannel bool
done bool
oldValue func(context.Context) (*NotifySubscription, error)
predicates []predicate.NotifySubscription
}
var _ ent.Mutation = (*NotifySubscriptionMutation)(nil)
// notifysubscriptionOption allows management of the mutation configuration using functional options.
type notifysubscriptionOption func(*NotifySubscriptionMutation)
// newNotifySubscriptionMutation creates new mutation for the NotifySubscription entity.
func newNotifySubscriptionMutation(c config, op Op, opts ...notifysubscriptionOption) *NotifySubscriptionMutation {
m := &NotifySubscriptionMutation{
config: c,
op: op,
typ: TypeNotifySubscription,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withNotifySubscriptionID sets the ID field of the mutation.
func withNotifySubscriptionID(id uuid.UUID) notifysubscriptionOption {
return func(m *NotifySubscriptionMutation) {
var (
err error
once sync.Once
value *NotifySubscription
)
m.oldValue = func(ctx context.Context) (*NotifySubscription, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().NotifySubscription.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withNotifySubscription sets the old NotifySubscription of the mutation.
func withNotifySubscription(node *NotifySubscription) notifysubscriptionOption {
return func(m *NotifySubscriptionMutation) {
m.oldValue = func(context.Context) (*NotifySubscription, 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 NotifySubscriptionMutation) 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 NotifySubscriptionMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 NotifySubscription entities.
func (m *NotifySubscriptionMutation) SetID(id uuid.UUID) {
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 *NotifySubscriptionMutation) ID() (id uuid.UUID, 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 *NotifySubscriptionMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().NotifySubscription.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *NotifySubscriptionMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *NotifySubscriptionMutation) 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 NotifySubscription entity.
// If the NotifySubscription 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 *NotifySubscriptionMutation) 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 *NotifySubscriptionMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[notifysubscription.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *NotifySubscriptionMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[notifysubscription.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *NotifySubscriptionMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, notifysubscription.FieldDeletedAt)
}
// SetChannelID sets the "channel_id" field.
func (m *NotifySubscriptionMutation) SetChannelID(u uuid.UUID) {
m.channel = &u
}
// ChannelID returns the value of the "channel_id" field in the mutation.
func (m *NotifySubscriptionMutation) ChannelID() (r uuid.UUID, exists bool) {
v := m.channel
if v == nil {
return
}
return *v, true
}
// OldChannelID returns the old "channel_id" field's value of the NotifySubscription entity.
// If the NotifySubscription 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 *NotifySubscriptionMutation) OldChannelID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldChannelID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldChannelID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldChannelID: %w", err)
}
return oldValue.ChannelID, nil
}
// ResetChannelID resets all changes to the "channel_id" field.
func (m *NotifySubscriptionMutation) ResetChannelID() {
m.channel = nil
}
// SetScope sets the "scope" field.
func (m *NotifySubscriptionMutation) SetScope(s string) {
m.scope = &s
}
// Scope returns the value of the "scope" field in the mutation.
func (m *NotifySubscriptionMutation) Scope() (r string, exists bool) {
v := m.scope
if v == nil {
return
}
return *v, true
}
// OldScope returns the old "scope" field's value of the NotifySubscription entity.
// If the NotifySubscription 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 *NotifySubscriptionMutation) OldScope(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldScope is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldScope requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldScope: %w", err)
}
return oldValue.Scope, nil
}
// ResetScope resets all changes to the "scope" field.
func (m *NotifySubscriptionMutation) ResetScope() {
m.scope = nil
}
// SetEventTypes sets the "event_types" field.
func (m *NotifySubscriptionMutation) SetEventTypes(cet []consts.NotifyEventType) {
m.event_types = &cet
m.appendevent_types = nil
}
// EventTypes returns the value of the "event_types" field in the mutation.
func (m *NotifySubscriptionMutation) EventTypes() (r []consts.NotifyEventType, exists bool) {
v := m.event_types
if v == nil {
return
}
return *v, true
}
// OldEventTypes returns the old "event_types" field's value of the NotifySubscription entity.
// If the NotifySubscription 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 *NotifySubscriptionMutation) OldEventTypes(ctx context.Context) (v []consts.NotifyEventType, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEventTypes is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEventTypes requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEventTypes: %w", err)
}
return oldValue.EventTypes, nil
}
// AppendEventTypes adds cet to the "event_types" field.
func (m *NotifySubscriptionMutation) AppendEventTypes(cet []consts.NotifyEventType) {
m.appendevent_types = append(m.appendevent_types, cet...)
}
// AppendedEventTypes returns the list of values that were appended to the "event_types" field in this mutation.
func (m *NotifySubscriptionMutation) AppendedEventTypes() ([]consts.NotifyEventType, bool) {
if len(m.appendevent_types) == 0 {
return nil, false
}
return m.appendevent_types, true
}
// ResetEventTypes resets all changes to the "event_types" field.
func (m *NotifySubscriptionMutation) ResetEventTypes() {
m.event_types = nil
m.appendevent_types = nil
}
// SetEnabled sets the "enabled" field.
func (m *NotifySubscriptionMutation) SetEnabled(b bool) {
m.enabled = &b
}
// Enabled returns the value of the "enabled" field in the mutation.
func (m *NotifySubscriptionMutation) Enabled() (r bool, exists bool) {
v := m.enabled
if v == nil {
return
}
return *v, true
}
// OldEnabled returns the old "enabled" field's value of the NotifySubscription entity.
// If the NotifySubscription 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 *NotifySubscriptionMutation) OldEnabled(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEnabled requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
}
return oldValue.Enabled, nil
}
// ResetEnabled resets all changes to the "enabled" field.
func (m *NotifySubscriptionMutation) ResetEnabled() {
m.enabled = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *NotifySubscriptionMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *NotifySubscriptionMutation) 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 NotifySubscription entity.
// If the NotifySubscription 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 *NotifySubscriptionMutation) 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 *NotifySubscriptionMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *NotifySubscriptionMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *NotifySubscriptionMutation) 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 NotifySubscription entity.
// If the NotifySubscription 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 *NotifySubscriptionMutation) 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 *NotifySubscriptionMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearChannel clears the "channel" edge to the NotifyChannel entity.
func (m *NotifySubscriptionMutation) ClearChannel() {
m.clearedchannel = true
m.clearedFields[notifysubscription.FieldChannelID] = struct{}{}
}
// ChannelCleared reports if the "channel" edge to the NotifyChannel entity was cleared.
func (m *NotifySubscriptionMutation) ChannelCleared() bool {
return m.clearedchannel
}
// ChannelIDs returns the "channel" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ChannelID instead. It exists only for internal usage by the builders.
func (m *NotifySubscriptionMutation) ChannelIDs() (ids []uuid.UUID) {
if id := m.channel; id != nil {
ids = append(ids, *id)
}
return
}
// ResetChannel resets all changes to the "channel" edge.
func (m *NotifySubscriptionMutation) ResetChannel() {
m.channel = nil
m.clearedchannel = false
}
// Where appends a list predicates to the NotifySubscriptionMutation builder.
func (m *NotifySubscriptionMutation) Where(ps ...predicate.NotifySubscription) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the NotifySubscriptionMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *NotifySubscriptionMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.NotifySubscription, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *NotifySubscriptionMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *NotifySubscriptionMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (NotifySubscription).
func (m *NotifySubscriptionMutation) 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 *NotifySubscriptionMutation) Fields() []string {
fields := make([]string, 0, 7)
if m.deleted_at != nil {
fields = append(fields, notifysubscription.FieldDeletedAt)
}
if m.channel != nil {
fields = append(fields, notifysubscription.FieldChannelID)
}
if m.scope != nil {
fields = append(fields, notifysubscription.FieldScope)
}
if m.event_types != nil {
fields = append(fields, notifysubscription.FieldEventTypes)
}
if m.enabled != nil {
fields = append(fields, notifysubscription.FieldEnabled)
}
if m.created_at != nil {
fields = append(fields, notifysubscription.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, notifysubscription.FieldUpdatedAt)
}
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 *NotifySubscriptionMutation) Field(name string) (ent.Value, bool) {
switch name {
case notifysubscription.FieldDeletedAt:
return m.DeletedAt()
case notifysubscription.FieldChannelID:
return m.ChannelID()
case notifysubscription.FieldScope:
return m.Scope()
case notifysubscription.FieldEventTypes:
return m.EventTypes()
case notifysubscription.FieldEnabled:
return m.Enabled()
case notifysubscription.FieldCreatedAt:
return m.CreatedAt()
case notifysubscription.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *NotifySubscriptionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case notifysubscription.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case notifysubscription.FieldChannelID:
return m.OldChannelID(ctx)
case notifysubscription.FieldScope:
return m.OldScope(ctx)
case notifysubscription.FieldEventTypes:
return m.OldEventTypes(ctx)
case notifysubscription.FieldEnabled:
return m.OldEnabled(ctx)
case notifysubscription.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case notifysubscription.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown NotifySubscription 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 *NotifySubscriptionMutation) SetField(name string, value ent.Value) error {
switch name {
case notifysubscription.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 notifysubscription.FieldChannelID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetChannelID(v)
return nil
case notifysubscription.FieldScope:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetScope(v)
return nil
case notifysubscription.FieldEventTypes:
v, ok := value.([]consts.NotifyEventType)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEventTypes(v)
return nil
case notifysubscription.FieldEnabled:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEnabled(v)
return nil
case notifysubscription.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 notifysubscription.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown NotifySubscription field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *NotifySubscriptionMutation) AddedFields() []string {
return nil
}
// 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 *NotifySubscriptionMutation) AddedField(name string) (ent.Value, bool) {
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 *NotifySubscriptionMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown NotifySubscription numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *NotifySubscriptionMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(notifysubscription.FieldDeletedAt) {
fields = append(fields, notifysubscription.FieldDeletedAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *NotifySubscriptionMutation) 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 *NotifySubscriptionMutation) ClearField(name string) error {
switch name {
case notifysubscription.FieldDeletedAt:
m.ClearDeletedAt()
return nil
}
return fmt.Errorf("unknown NotifySubscription 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 *NotifySubscriptionMutation) ResetField(name string) error {
switch name {
case notifysubscription.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case notifysubscription.FieldChannelID:
m.ResetChannelID()
return nil
case notifysubscription.FieldScope:
m.ResetScope()
return nil
case notifysubscription.FieldEventTypes:
m.ResetEventTypes()
return nil
case notifysubscription.FieldEnabled:
m.ResetEnabled()
return nil
case notifysubscription.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case notifysubscription.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown NotifySubscription field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *NotifySubscriptionMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.channel != nil {
edges = append(edges, notifysubscription.EdgeChannel)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *NotifySubscriptionMutation) AddedIDs(name string) []ent.Value {
switch name {
case notifysubscription.EdgeChannel:
if id := m.channel; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *NotifySubscriptionMutation) 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 *NotifySubscriptionMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *NotifySubscriptionMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedchannel {
edges = append(edges, notifysubscription.EdgeChannel)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *NotifySubscriptionMutation) EdgeCleared(name string) bool {
switch name {
case notifysubscription.EdgeChannel:
return m.clearedchannel
}
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 *NotifySubscriptionMutation) ClearEdge(name string) error {
switch name {
case notifysubscription.EdgeChannel:
m.ClearChannel()
return nil
}
return fmt.Errorf("unknown NotifySubscription 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 *NotifySubscriptionMutation) ResetEdge(name string) error {
switch name {
case notifysubscription.EdgeChannel:
m.ResetChannel()
return nil
}
return fmt.Errorf("unknown NotifySubscription edge %s", name)
}
// ProjectMutation represents an operation that mutates the Project nodes in the graph.
type ProjectMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
name *string
description *string
platform *consts.GitPlatform
repo_url *string
branch *string
env_variables *map[string]interface{}
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
user *uuid.UUID
cleareduser bool
git_identity *uuid.UUID
clearedgit_identity bool
image *uuid.UUID
clearedimage bool
issues map[uuid.UUID]struct{}
removedissues map[uuid.UUID]struct{}
clearedissues bool
collaborators map[uuid.UUID]struct{}
removedcollaborators map[uuid.UUID]struct{}
clearedcollaborators bool
project_tasks map[uuid.UUID]struct{}
removedproject_tasks map[uuid.UUID]struct{}
clearedproject_tasks bool
git_bots map[uuid.UUID]struct{}
removedgit_bots map[uuid.UUID]struct{}
clearedgit_bots bool
project_git_bots map[uuid.UUID]struct{}
removedproject_git_bots map[uuid.UUID]struct{}
clearedproject_git_bots bool
done bool
oldValue func(context.Context) (*Project, error)
predicates []predicate.Project
}
var _ ent.Mutation = (*ProjectMutation)(nil)
// projectOption allows management of the mutation configuration using functional options.
type projectOption func(*ProjectMutation)
// newProjectMutation creates new mutation for the Project entity.
func newProjectMutation(c config, op Op, opts ...projectOption) *ProjectMutation {
m := &ProjectMutation{
config: c,
op: op,
typ: TypeProject,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withProjectID sets the ID field of the mutation.
func withProjectID(id uuid.UUID) projectOption {
return func(m *ProjectMutation) {
var (
err error
once sync.Once
value *Project
)
m.oldValue = func(ctx context.Context) (*Project, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Project.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withProject sets the old Project of the mutation.
func withProject(node *Project) projectOption {
return func(m *ProjectMutation) {
m.oldValue = func(context.Context) (*Project, 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 ProjectMutation) 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 ProjectMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 Project entities.
func (m *ProjectMutation) SetID(id uuid.UUID) {
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 *ProjectMutation) ID() (id uuid.UUID, 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 *ProjectMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().Project.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *ProjectMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *ProjectMutation) 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 Project entity.
// If the Project 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 *ProjectMutation) 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 *ProjectMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[project.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *ProjectMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[project.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *ProjectMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, project.FieldDeletedAt)
}
// SetUserID sets the "user_id" field.
func (m *ProjectMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *ProjectMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *ProjectMutation) ResetUserID() {
m.user = nil
}
// SetName sets the "name" field.
func (m *ProjectMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *ProjectMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldName: %w", err)
}
return oldValue.Name, nil
}
// ResetName resets all changes to the "name" field.
func (m *ProjectMutation) ResetName() {
m.name = nil
}
// SetDescription sets the "description" field.
func (m *ProjectMutation) SetDescription(s string) {
m.description = &s
}
// Description returns the value of the "description" field in the mutation.
func (m *ProjectMutation) Description() (r string, exists bool) {
v := m.description
if v == nil {
return
}
return *v, true
}
// OldDescription returns the old "description" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldDescription(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDescription is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldDescription requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDescription: %w", err)
}
return oldValue.Description, nil
}
// ClearDescription clears the value of the "description" field.
func (m *ProjectMutation) ClearDescription() {
m.description = nil
m.clearedFields[project.FieldDescription] = struct{}{}
}
// DescriptionCleared returns if the "description" field was cleared in this mutation.
func (m *ProjectMutation) DescriptionCleared() bool {
_, ok := m.clearedFields[project.FieldDescription]
return ok
}
// ResetDescription resets all changes to the "description" field.
func (m *ProjectMutation) ResetDescription() {
m.description = nil
delete(m.clearedFields, project.FieldDescription)
}
// SetPlatform sets the "platform" field.
func (m *ProjectMutation) SetPlatform(cp consts.GitPlatform) {
m.platform = &cp
}
// Platform returns the value of the "platform" field in the mutation.
func (m *ProjectMutation) Platform() (r consts.GitPlatform, exists bool) {
v := m.platform
if v == nil {
return
}
return *v, true
}
// OldPlatform returns the old "platform" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldPlatform(ctx context.Context) (v consts.GitPlatform, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPlatform is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPlatform requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPlatform: %w", err)
}
return oldValue.Platform, nil
}
// ClearPlatform clears the value of the "platform" field.
func (m *ProjectMutation) ClearPlatform() {
m.platform = nil
m.clearedFields[project.FieldPlatform] = struct{}{}
}
// PlatformCleared returns if the "platform" field was cleared in this mutation.
func (m *ProjectMutation) PlatformCleared() bool {
_, ok := m.clearedFields[project.FieldPlatform]
return ok
}
// ResetPlatform resets all changes to the "platform" field.
func (m *ProjectMutation) ResetPlatform() {
m.platform = nil
delete(m.clearedFields, project.FieldPlatform)
}
// SetRepoURL sets the "repo_url" field.
func (m *ProjectMutation) SetRepoURL(s string) {
m.repo_url = &s
}
// RepoURL returns the value of the "repo_url" field in the mutation.
func (m *ProjectMutation) RepoURL() (r string, exists bool) {
v := m.repo_url
if v == nil {
return
}
return *v, true
}
// OldRepoURL returns the old "repo_url" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldRepoURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRepoURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRepoURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRepoURL: %w", err)
}
return oldValue.RepoURL, nil
}
// ClearRepoURL clears the value of the "repo_url" field.
func (m *ProjectMutation) ClearRepoURL() {
m.repo_url = nil
m.clearedFields[project.FieldRepoURL] = struct{}{}
}
// RepoURLCleared returns if the "repo_url" field was cleared in this mutation.
func (m *ProjectMutation) RepoURLCleared() bool {
_, ok := m.clearedFields[project.FieldRepoURL]
return ok
}
// ResetRepoURL resets all changes to the "repo_url" field.
func (m *ProjectMutation) ResetRepoURL() {
m.repo_url = nil
delete(m.clearedFields, project.FieldRepoURL)
}
// SetBranch sets the "branch" field.
func (m *ProjectMutation) SetBranch(s string) {
m.branch = &s
}
// Branch returns the value of the "branch" field in the mutation.
func (m *ProjectMutation) Branch() (r string, exists bool) {
v := m.branch
if v == nil {
return
}
return *v, true
}
// OldBranch returns the old "branch" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldBranch(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldBranch is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldBranch requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBranch: %w", err)
}
return oldValue.Branch, nil
}
// ClearBranch clears the value of the "branch" field.
func (m *ProjectMutation) ClearBranch() {
m.branch = nil
m.clearedFields[project.FieldBranch] = struct{}{}
}
// BranchCleared returns if the "branch" field was cleared in this mutation.
func (m *ProjectMutation) BranchCleared() bool {
_, ok := m.clearedFields[project.FieldBranch]
return ok
}
// ResetBranch resets all changes to the "branch" field.
func (m *ProjectMutation) ResetBranch() {
m.branch = nil
delete(m.clearedFields, project.FieldBranch)
}
// SetGitIdentityID sets the "git_identity_id" field.
func (m *ProjectMutation) SetGitIdentityID(u uuid.UUID) {
m.git_identity = &u
}
// GitIdentityID returns the value of the "git_identity_id" field in the mutation.
func (m *ProjectMutation) GitIdentityID() (r uuid.UUID, exists bool) {
v := m.git_identity
if v == nil {
return
}
return *v, true
}
// OldGitIdentityID returns the old "git_identity_id" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldGitIdentityID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGitIdentityID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGitIdentityID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGitIdentityID: %w", err)
}
return oldValue.GitIdentityID, nil
}
// ClearGitIdentityID clears the value of the "git_identity_id" field.
func (m *ProjectMutation) ClearGitIdentityID() {
m.git_identity = nil
m.clearedFields[project.FieldGitIdentityID] = struct{}{}
}
// GitIdentityIDCleared returns if the "git_identity_id" field was cleared in this mutation.
func (m *ProjectMutation) GitIdentityIDCleared() bool {
_, ok := m.clearedFields[project.FieldGitIdentityID]
return ok
}
// ResetGitIdentityID resets all changes to the "git_identity_id" field.
func (m *ProjectMutation) ResetGitIdentityID() {
m.git_identity = nil
delete(m.clearedFields, project.FieldGitIdentityID)
}
// SetImageID sets the "image_id" field.
func (m *ProjectMutation) SetImageID(u uuid.UUID) {
m.image = &u
}
// ImageID returns the value of the "image_id" field in the mutation.
func (m *ProjectMutation) ImageID() (r uuid.UUID, exists bool) {
v := m.image
if v == nil {
return
}
return *v, true
}
// OldImageID returns the old "image_id" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldImageID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldImageID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldImageID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldImageID: %w", err)
}
return oldValue.ImageID, nil
}
// ClearImageID clears the value of the "image_id" field.
func (m *ProjectMutation) ClearImageID() {
m.image = nil
m.clearedFields[project.FieldImageID] = struct{}{}
}
// ImageIDCleared returns if the "image_id" field was cleared in this mutation.
func (m *ProjectMutation) ImageIDCleared() bool {
_, ok := m.clearedFields[project.FieldImageID]
return ok
}
// ResetImageID resets all changes to the "image_id" field.
func (m *ProjectMutation) ResetImageID() {
m.image = nil
delete(m.clearedFields, project.FieldImageID)
}
// SetEnvVariables sets the "env_variables" field.
func (m *ProjectMutation) SetEnvVariables(value map[string]interface{}) {
m.env_variables = &value
}
// EnvVariables returns the value of the "env_variables" field in the mutation.
func (m *ProjectMutation) EnvVariables() (r map[string]interface{}, exists bool) {
v := m.env_variables
if v == nil {
return
}
return *v, true
}
// OldEnvVariables returns the old "env_variables" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldEnvVariables(ctx context.Context) (v map[string]interface{}, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEnvVariables is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEnvVariables requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEnvVariables: %w", err)
}
return oldValue.EnvVariables, nil
}
// ClearEnvVariables clears the value of the "env_variables" field.
func (m *ProjectMutation) ClearEnvVariables() {
m.env_variables = nil
m.clearedFields[project.FieldEnvVariables] = struct{}{}
}
// EnvVariablesCleared returns if the "env_variables" field was cleared in this mutation.
func (m *ProjectMutation) EnvVariablesCleared() bool {
_, ok := m.clearedFields[project.FieldEnvVariables]
return ok
}
// ResetEnvVariables resets all changes to the "env_variables" field.
func (m *ProjectMutation) ResetEnvVariables() {
m.env_variables = nil
delete(m.clearedFields, project.FieldEnvVariables)
}
// SetCreatedAt sets the "created_at" field.
func (m *ProjectMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ProjectMutation) 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 Project entity.
// If the Project 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 *ProjectMutation) 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 *ProjectMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *ProjectMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *ProjectMutation) 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 Project entity.
// If the Project 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 *ProjectMutation) 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 *ProjectMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearUser clears the "user" edge to the User entity.
func (m *ProjectMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[project.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *ProjectMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *ProjectMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *ProjectMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// ClearGitIdentity clears the "git_identity" edge to the GitIdentity entity.
func (m *ProjectMutation) ClearGitIdentity() {
m.clearedgit_identity = true
m.clearedFields[project.FieldGitIdentityID] = struct{}{}
}
// GitIdentityCleared reports if the "git_identity" edge to the GitIdentity entity was cleared.
func (m *ProjectMutation) GitIdentityCleared() bool {
return m.GitIdentityIDCleared() || m.clearedgit_identity
}
// GitIdentityIDs returns the "git_identity" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// GitIdentityID instead. It exists only for internal usage by the builders.
func (m *ProjectMutation) GitIdentityIDs() (ids []uuid.UUID) {
if id := m.git_identity; id != nil {
ids = append(ids, *id)
}
return
}
// ResetGitIdentity resets all changes to the "git_identity" edge.
func (m *ProjectMutation) ResetGitIdentity() {
m.git_identity = nil
m.clearedgit_identity = false
}
// ClearImage clears the "image" edge to the Image entity.
func (m *ProjectMutation) ClearImage() {
m.clearedimage = true
m.clearedFields[project.FieldImageID] = struct{}{}
}
// ImageCleared reports if the "image" edge to the Image entity was cleared.
func (m *ProjectMutation) ImageCleared() bool {
return m.ImageIDCleared() || m.clearedimage
}
// ImageIDs returns the "image" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ImageID instead. It exists only for internal usage by the builders.
func (m *ProjectMutation) ImageIDs() (ids []uuid.UUID) {
if id := m.image; id != nil {
ids = append(ids, *id)
}
return
}
// ResetImage resets all changes to the "image" edge.
func (m *ProjectMutation) ResetImage() {
m.image = nil
m.clearedimage = false
}
// AddIssueIDs adds the "issues" edge to the ProjectIssue entity by ids.
func (m *ProjectMutation) AddIssueIDs(ids ...uuid.UUID) {
if m.issues == nil {
m.issues = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.issues[ids[i]] = struct{}{}
}
}
// ClearIssues clears the "issues" edge to the ProjectIssue entity.
func (m *ProjectMutation) ClearIssues() {
m.clearedissues = true
}
// IssuesCleared reports if the "issues" edge to the ProjectIssue entity was cleared.
func (m *ProjectMutation) IssuesCleared() bool {
return m.clearedissues
}
// RemoveIssueIDs removes the "issues" edge to the ProjectIssue entity by IDs.
func (m *ProjectMutation) RemoveIssueIDs(ids ...uuid.UUID) {
if m.removedissues == nil {
m.removedissues = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.issues, ids[i])
m.removedissues[ids[i]] = struct{}{}
}
}
// RemovedIssues returns the removed IDs of the "issues" edge to the ProjectIssue entity.
func (m *ProjectMutation) RemovedIssuesIDs() (ids []uuid.UUID) {
for id := range m.removedissues {
ids = append(ids, id)
}
return
}
// IssuesIDs returns the "issues" edge IDs in the mutation.
func (m *ProjectMutation) IssuesIDs() (ids []uuid.UUID) {
for id := range m.issues {
ids = append(ids, id)
}
return
}
// ResetIssues resets all changes to the "issues" edge.
func (m *ProjectMutation) ResetIssues() {
m.issues = nil
m.clearedissues = false
m.removedissues = nil
}
// AddCollaboratorIDs adds the "collaborators" edge to the ProjectCollaborator entity by ids.
func (m *ProjectMutation) AddCollaboratorIDs(ids ...uuid.UUID) {
if m.collaborators == nil {
m.collaborators = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.collaborators[ids[i]] = struct{}{}
}
}
// ClearCollaborators clears the "collaborators" edge to the ProjectCollaborator entity.
func (m *ProjectMutation) ClearCollaborators() {
m.clearedcollaborators = true
}
// CollaboratorsCleared reports if the "collaborators" edge to the ProjectCollaborator entity was cleared.
func (m *ProjectMutation) CollaboratorsCleared() bool {
return m.clearedcollaborators
}
// RemoveCollaboratorIDs removes the "collaborators" edge to the ProjectCollaborator entity by IDs.
func (m *ProjectMutation) RemoveCollaboratorIDs(ids ...uuid.UUID) {
if m.removedcollaborators == nil {
m.removedcollaborators = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.collaborators, ids[i])
m.removedcollaborators[ids[i]] = struct{}{}
}
}
// RemovedCollaborators returns the removed IDs of the "collaborators" edge to the ProjectCollaborator entity.
func (m *ProjectMutation) RemovedCollaboratorsIDs() (ids []uuid.UUID) {
for id := range m.removedcollaborators {
ids = append(ids, id)
}
return
}
// CollaboratorsIDs returns the "collaborators" edge IDs in the mutation.
func (m *ProjectMutation) CollaboratorsIDs() (ids []uuid.UUID) {
for id := range m.collaborators {
ids = append(ids, id)
}
return
}
// ResetCollaborators resets all changes to the "collaborators" edge.
func (m *ProjectMutation) ResetCollaborators() {
m.collaborators = nil
m.clearedcollaborators = false
m.removedcollaborators = nil
}
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids.
func (m *ProjectMutation) AddProjectTaskIDs(ids ...uuid.UUID) {
if m.project_tasks == nil {
m.project_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.project_tasks[ids[i]] = struct{}{}
}
}
// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity.
func (m *ProjectMutation) ClearProjectTasks() {
m.clearedproject_tasks = true
}
// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared.
func (m *ProjectMutation) ProjectTasksCleared() bool {
return m.clearedproject_tasks
}
// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs.
func (m *ProjectMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) {
if m.removedproject_tasks == nil {
m.removedproject_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.project_tasks, ids[i])
m.removedproject_tasks[ids[i]] = struct{}{}
}
}
// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity.
func (m *ProjectMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return
}
// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation.
func (m *ProjectMutation) ProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.project_tasks {
ids = append(ids, id)
}
return
}
// ResetProjectTasks resets all changes to the "project_tasks" edge.
func (m *ProjectMutation) ResetProjectTasks() {
m.project_tasks = nil
m.clearedproject_tasks = false
m.removedproject_tasks = nil
}
// AddGitBotIDs adds the "git_bots" edge to the GitBot entity by ids.
func (m *ProjectMutation) AddGitBotIDs(ids ...uuid.UUID) {
if m.git_bots == nil {
m.git_bots = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.git_bots[ids[i]] = struct{}{}
}
}
// ClearGitBots clears the "git_bots" edge to the GitBot entity.
func (m *ProjectMutation) ClearGitBots() {
m.clearedgit_bots = true
}
// GitBotsCleared reports if the "git_bots" edge to the GitBot entity was cleared.
func (m *ProjectMutation) GitBotsCleared() bool {
return m.clearedgit_bots
}
// RemoveGitBotIDs removes the "git_bots" edge to the GitBot entity by IDs.
func (m *ProjectMutation) RemoveGitBotIDs(ids ...uuid.UUID) {
if m.removedgit_bots == nil {
m.removedgit_bots = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.git_bots, ids[i])
m.removedgit_bots[ids[i]] = struct{}{}
}
}
// RemovedGitBots returns the removed IDs of the "git_bots" edge to the GitBot entity.
func (m *ProjectMutation) RemovedGitBotsIDs() (ids []uuid.UUID) {
for id := range m.removedgit_bots {
ids = append(ids, id)
}
return
}
// GitBotsIDs returns the "git_bots" edge IDs in the mutation.
func (m *ProjectMutation) GitBotsIDs() (ids []uuid.UUID) {
for id := range m.git_bots {
ids = append(ids, id)
}
return
}
// ResetGitBots resets all changes to the "git_bots" edge.
func (m *ProjectMutation) ResetGitBots() {
m.git_bots = nil
m.clearedgit_bots = false
m.removedgit_bots = nil
}
// AddProjectGitBotIDs adds the "project_git_bots" edge to the ProjectGitBot entity by ids.
func (m *ProjectMutation) AddProjectGitBotIDs(ids ...uuid.UUID) {
if m.project_git_bots == nil {
m.project_git_bots = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.project_git_bots[ids[i]] = struct{}{}
}
}
// ClearProjectGitBots clears the "project_git_bots" edge to the ProjectGitBot entity.
func (m *ProjectMutation) ClearProjectGitBots() {
m.clearedproject_git_bots = true
}
// ProjectGitBotsCleared reports if the "project_git_bots" edge to the ProjectGitBot entity was cleared.
func (m *ProjectMutation) ProjectGitBotsCleared() bool {
return m.clearedproject_git_bots
}
// RemoveProjectGitBotIDs removes the "project_git_bots" edge to the ProjectGitBot entity by IDs.
func (m *ProjectMutation) RemoveProjectGitBotIDs(ids ...uuid.UUID) {
if m.removedproject_git_bots == nil {
m.removedproject_git_bots = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.project_git_bots, ids[i])
m.removedproject_git_bots[ids[i]] = struct{}{}
}
}
// RemovedProjectGitBots returns the removed IDs of the "project_git_bots" edge to the ProjectGitBot entity.
func (m *ProjectMutation) RemovedProjectGitBotsIDs() (ids []uuid.UUID) {
for id := range m.removedproject_git_bots {
ids = append(ids, id)
}
return
}
// ProjectGitBotsIDs returns the "project_git_bots" edge IDs in the mutation.
func (m *ProjectMutation) ProjectGitBotsIDs() (ids []uuid.UUID) {
for id := range m.project_git_bots {
ids = append(ids, id)
}
return
}
// ResetProjectGitBots resets all changes to the "project_git_bots" edge.
func (m *ProjectMutation) ResetProjectGitBots() {
m.project_git_bots = nil
m.clearedproject_git_bots = false
m.removedproject_git_bots = nil
}
// Where appends a list predicates to the ProjectMutation builder.
func (m *ProjectMutation) Where(ps ...predicate.Project) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ProjectMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ProjectMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Project, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ProjectMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ProjectMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Project).
func (m *ProjectMutation) 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 *ProjectMutation) Fields() []string {
fields := make([]string, 0, 12)
if m.deleted_at != nil {
fields = append(fields, project.FieldDeletedAt)
}
if m.user != nil {
fields = append(fields, project.FieldUserID)
}
if m.name != nil {
fields = append(fields, project.FieldName)
}
if m.description != nil {
fields = append(fields, project.FieldDescription)
}
if m.platform != nil {
fields = append(fields, project.FieldPlatform)
}
if m.repo_url != nil {
fields = append(fields, project.FieldRepoURL)
}
if m.branch != nil {
fields = append(fields, project.FieldBranch)
}
if m.git_identity != nil {
fields = append(fields, project.FieldGitIdentityID)
}
if m.image != nil {
fields = append(fields, project.FieldImageID)
}
if m.env_variables != nil {
fields = append(fields, project.FieldEnvVariables)
}
if m.created_at != nil {
fields = append(fields, project.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, project.FieldUpdatedAt)
}
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 *ProjectMutation) Field(name string) (ent.Value, bool) {
switch name {
case project.FieldDeletedAt:
return m.DeletedAt()
case project.FieldUserID:
return m.UserID()
case project.FieldName:
return m.Name()
case project.FieldDescription:
return m.Description()
case project.FieldPlatform:
return m.Platform()
case project.FieldRepoURL:
return m.RepoURL()
case project.FieldBranch:
return m.Branch()
case project.FieldGitIdentityID:
return m.GitIdentityID()
case project.FieldImageID:
return m.ImageID()
case project.FieldEnvVariables:
return m.EnvVariables()
case project.FieldCreatedAt:
return m.CreatedAt()
case project.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *ProjectMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case project.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case project.FieldUserID:
return m.OldUserID(ctx)
case project.FieldName:
return m.OldName(ctx)
case project.FieldDescription:
return m.OldDescription(ctx)
case project.FieldPlatform:
return m.OldPlatform(ctx)
case project.FieldRepoURL:
return m.OldRepoURL(ctx)
case project.FieldBranch:
return m.OldBranch(ctx)
case project.FieldGitIdentityID:
return m.OldGitIdentityID(ctx)
case project.FieldImageID:
return m.OldImageID(ctx)
case project.FieldEnvVariables:
return m.OldEnvVariables(ctx)
case project.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case project.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown Project 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 *ProjectMutation) SetField(name string, value ent.Value) error {
switch name {
case project.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 project.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case project.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case project.FieldDescription:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDescription(v)
return nil
case project.FieldPlatform:
v, ok := value.(consts.GitPlatform)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPlatform(v)
return nil
case project.FieldRepoURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRepoURL(v)
return nil
case project.FieldBranch:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetBranch(v)
return nil
case project.FieldGitIdentityID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGitIdentityID(v)
return nil
case project.FieldImageID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetImageID(v)
return nil
case project.FieldEnvVariables:
v, ok := value.(map[string]interface{})
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEnvVariables(v)
return nil
case project.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 project.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown Project field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ProjectMutation) AddedFields() []string {
return nil
}
// 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 *ProjectMutation) AddedField(name string) (ent.Value, bool) {
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 *ProjectMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown Project numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ProjectMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(project.FieldDeletedAt) {
fields = append(fields, project.FieldDeletedAt)
}
if m.FieldCleared(project.FieldDescription) {
fields = append(fields, project.FieldDescription)
}
if m.FieldCleared(project.FieldPlatform) {
fields = append(fields, project.FieldPlatform)
}
if m.FieldCleared(project.FieldRepoURL) {
fields = append(fields, project.FieldRepoURL)
}
if m.FieldCleared(project.FieldBranch) {
fields = append(fields, project.FieldBranch)
}
if m.FieldCleared(project.FieldGitIdentityID) {
fields = append(fields, project.FieldGitIdentityID)
}
if m.FieldCleared(project.FieldImageID) {
fields = append(fields, project.FieldImageID)
}
if m.FieldCleared(project.FieldEnvVariables) {
fields = append(fields, project.FieldEnvVariables)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ProjectMutation) 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 *ProjectMutation) ClearField(name string) error {
switch name {
case project.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case project.FieldDescription:
m.ClearDescription()
return nil
case project.FieldPlatform:
m.ClearPlatform()
return nil
case project.FieldRepoURL:
m.ClearRepoURL()
return nil
case project.FieldBranch:
m.ClearBranch()
return nil
case project.FieldGitIdentityID:
m.ClearGitIdentityID()
return nil
case project.FieldImageID:
m.ClearImageID()
return nil
case project.FieldEnvVariables:
m.ClearEnvVariables()
return nil
}
return fmt.Errorf("unknown Project 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 *ProjectMutation) ResetField(name string) error {
switch name {
case project.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case project.FieldUserID:
m.ResetUserID()
return nil
case project.FieldName:
m.ResetName()
return nil
case project.FieldDescription:
m.ResetDescription()
return nil
case project.FieldPlatform:
m.ResetPlatform()
return nil
case project.FieldRepoURL:
m.ResetRepoURL()
return nil
case project.FieldBranch:
m.ResetBranch()
return nil
case project.FieldGitIdentityID:
m.ResetGitIdentityID()
return nil
case project.FieldImageID:
m.ResetImageID()
return nil
case project.FieldEnvVariables:
m.ResetEnvVariables()
return nil
case project.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case project.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown Project field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ProjectMutation) AddedEdges() []string {
edges := make([]string, 0, 8)
if m.user != nil {
edges = append(edges, project.EdgeUser)
}
if m.git_identity != nil {
edges = append(edges, project.EdgeGitIdentity)
}
if m.image != nil {
edges = append(edges, project.EdgeImage)
}
if m.issues != nil {
edges = append(edges, project.EdgeIssues)
}
if m.collaborators != nil {
edges = append(edges, project.EdgeCollaborators)
}
if m.project_tasks != nil {
edges = append(edges, project.EdgeProjectTasks)
}
if m.git_bots != nil {
edges = append(edges, project.EdgeGitBots)
}
if m.project_git_bots != nil {
edges = append(edges, project.EdgeProjectGitBots)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ProjectMutation) AddedIDs(name string) []ent.Value {
switch name {
case project.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
case project.EdgeGitIdentity:
if id := m.git_identity; id != nil {
return []ent.Value{*id}
}
case project.EdgeImage:
if id := m.image; id != nil {
return []ent.Value{*id}
}
case project.EdgeIssues:
ids := make([]ent.Value, 0, len(m.issues))
for id := range m.issues {
ids = append(ids, id)
}
return ids
case project.EdgeCollaborators:
ids := make([]ent.Value, 0, len(m.collaborators))
for id := range m.collaborators {
ids = append(ids, id)
}
return ids
case project.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.project_tasks))
for id := range m.project_tasks {
ids = append(ids, id)
}
return ids
case project.EdgeGitBots:
ids := make([]ent.Value, 0, len(m.git_bots))
for id := range m.git_bots {
ids = append(ids, id)
}
return ids
case project.EdgeProjectGitBots:
ids := make([]ent.Value, 0, len(m.project_git_bots))
for id := range m.project_git_bots {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ProjectMutation) RemovedEdges() []string {
edges := make([]string, 0, 8)
if m.removedissues != nil {
edges = append(edges, project.EdgeIssues)
}
if m.removedcollaborators != nil {
edges = append(edges, project.EdgeCollaborators)
}
if m.removedproject_tasks != nil {
edges = append(edges, project.EdgeProjectTasks)
}
if m.removedgit_bots != nil {
edges = append(edges, project.EdgeGitBots)
}
if m.removedproject_git_bots != nil {
edges = append(edges, project.EdgeProjectGitBots)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ProjectMutation) RemovedIDs(name string) []ent.Value {
switch name {
case project.EdgeIssues:
ids := make([]ent.Value, 0, len(m.removedissues))
for id := range m.removedissues {
ids = append(ids, id)
}
return ids
case project.EdgeCollaborators:
ids := make([]ent.Value, 0, len(m.removedcollaborators))
for id := range m.removedcollaborators {
ids = append(ids, id)
}
return ids
case project.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.removedproject_tasks))
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return ids
case project.EdgeGitBots:
ids := make([]ent.Value, 0, len(m.removedgit_bots))
for id := range m.removedgit_bots {
ids = append(ids, id)
}
return ids
case project.EdgeProjectGitBots:
ids := make([]ent.Value, 0, len(m.removedproject_git_bots))
for id := range m.removedproject_git_bots {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ProjectMutation) ClearedEdges() []string {
edges := make([]string, 0, 8)
if m.cleareduser {
edges = append(edges, project.EdgeUser)
}
if m.clearedgit_identity {
edges = append(edges, project.EdgeGitIdentity)
}
if m.clearedimage {
edges = append(edges, project.EdgeImage)
}
if m.clearedissues {
edges = append(edges, project.EdgeIssues)
}
if m.clearedcollaborators {
edges = append(edges, project.EdgeCollaborators)
}
if m.clearedproject_tasks {
edges = append(edges, project.EdgeProjectTasks)
}
if m.clearedgit_bots {
edges = append(edges, project.EdgeGitBots)
}
if m.clearedproject_git_bots {
edges = append(edges, project.EdgeProjectGitBots)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ProjectMutation) EdgeCleared(name string) bool {
switch name {
case project.EdgeUser:
return m.cleareduser
case project.EdgeGitIdentity:
return m.clearedgit_identity
case project.EdgeImage:
return m.clearedimage
case project.EdgeIssues:
return m.clearedissues
case project.EdgeCollaborators:
return m.clearedcollaborators
case project.EdgeProjectTasks:
return m.clearedproject_tasks
case project.EdgeGitBots:
return m.clearedgit_bots
case project.EdgeProjectGitBots:
return m.clearedproject_git_bots
}
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 *ProjectMutation) ClearEdge(name string) error {
switch name {
case project.EdgeUser:
m.ClearUser()
return nil
case project.EdgeGitIdentity:
m.ClearGitIdentity()
return nil
case project.EdgeImage:
m.ClearImage()
return nil
}
return fmt.Errorf("unknown Project 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 *ProjectMutation) ResetEdge(name string) error {
switch name {
case project.EdgeUser:
m.ResetUser()
return nil
case project.EdgeGitIdentity:
m.ResetGitIdentity()
return nil
case project.EdgeImage:
m.ResetImage()
return nil
case project.EdgeIssues:
m.ResetIssues()
return nil
case project.EdgeCollaborators:
m.ResetCollaborators()
return nil
case project.EdgeProjectTasks:
m.ResetProjectTasks()
return nil
case project.EdgeGitBots:
m.ResetGitBots()
return nil
case project.EdgeProjectGitBots:
m.ResetProjectGitBots()
return nil
}
return fmt.Errorf("unknown Project edge %s", name)
}
// ProjectCollaboratorMutation represents an operation that mutates the ProjectCollaborator nodes in the graph.
type ProjectCollaboratorMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
role *consts.ProjectCollaboratorRole
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
user *uuid.UUID
cleareduser bool
project *uuid.UUID
clearedproject bool
done bool
oldValue func(context.Context) (*ProjectCollaborator, error)
predicates []predicate.ProjectCollaborator
}
var _ ent.Mutation = (*ProjectCollaboratorMutation)(nil)
// projectcollaboratorOption allows management of the mutation configuration using functional options.
type projectcollaboratorOption func(*ProjectCollaboratorMutation)
// newProjectCollaboratorMutation creates new mutation for the ProjectCollaborator entity.
func newProjectCollaboratorMutation(c config, op Op, opts ...projectcollaboratorOption) *ProjectCollaboratorMutation {
m := &ProjectCollaboratorMutation{
config: c,
op: op,
typ: TypeProjectCollaborator,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withProjectCollaboratorID sets the ID field of the mutation.
func withProjectCollaboratorID(id uuid.UUID) projectcollaboratorOption {
return func(m *ProjectCollaboratorMutation) {
var (
err error
once sync.Once
value *ProjectCollaborator
)
m.oldValue = func(ctx context.Context) (*ProjectCollaborator, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().ProjectCollaborator.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withProjectCollaborator sets the old ProjectCollaborator of the mutation.
func withProjectCollaborator(node *ProjectCollaborator) projectcollaboratorOption {
return func(m *ProjectCollaboratorMutation) {
m.oldValue = func(context.Context) (*ProjectCollaborator, 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 ProjectCollaboratorMutation) 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 ProjectCollaboratorMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 ProjectCollaborator entities.
func (m *ProjectCollaboratorMutation) SetID(id uuid.UUID) {
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 *ProjectCollaboratorMutation) ID() (id uuid.UUID, 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 *ProjectCollaboratorMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().ProjectCollaborator.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *ProjectCollaboratorMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *ProjectCollaboratorMutation) 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 ProjectCollaborator entity.
// If the ProjectCollaborator 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 *ProjectCollaboratorMutation) 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 *ProjectCollaboratorMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[projectcollaborator.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *ProjectCollaboratorMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[projectcollaborator.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *ProjectCollaboratorMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, projectcollaborator.FieldDeletedAt)
}
// SetProjectID sets the "project_id" field.
func (m *ProjectCollaboratorMutation) SetProjectID(u uuid.UUID) {
m.project = &u
}
// ProjectID returns the value of the "project_id" field in the mutation.
func (m *ProjectCollaboratorMutation) ProjectID() (r uuid.UUID, exists bool) {
v := m.project
if v == nil {
return
}
return *v, true
}
// OldProjectID returns the old "project_id" field's value of the ProjectCollaborator entity.
// If the ProjectCollaborator 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 *ProjectCollaboratorMutation) OldProjectID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldProjectID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldProjectID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldProjectID: %w", err)
}
return oldValue.ProjectID, nil
}
// ResetProjectID resets all changes to the "project_id" field.
func (m *ProjectCollaboratorMutation) ResetProjectID() {
m.project = nil
}
// SetUserID sets the "user_id" field.
func (m *ProjectCollaboratorMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *ProjectCollaboratorMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the ProjectCollaborator entity.
// If the ProjectCollaborator 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 *ProjectCollaboratorMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *ProjectCollaboratorMutation) ResetUserID() {
m.user = nil
}
// SetRole sets the "role" field.
func (m *ProjectCollaboratorMutation) SetRole(ccr consts.ProjectCollaboratorRole) {
m.role = &ccr
}
// Role returns the value of the "role" field in the mutation.
func (m *ProjectCollaboratorMutation) Role() (r consts.ProjectCollaboratorRole, exists bool) {
v := m.role
if v == nil {
return
}
return *v, true
}
// OldRole returns the old "role" field's value of the ProjectCollaborator entity.
// If the ProjectCollaborator 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 *ProjectCollaboratorMutation) OldRole(ctx context.Context) (v consts.ProjectCollaboratorRole, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRole is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRole requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRole: %w", err)
}
return oldValue.Role, nil
}
// ResetRole resets all changes to the "role" field.
func (m *ProjectCollaboratorMutation) ResetRole() {
m.role = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *ProjectCollaboratorMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ProjectCollaboratorMutation) 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 ProjectCollaborator entity.
// If the ProjectCollaborator 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 *ProjectCollaboratorMutation) 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 *ProjectCollaboratorMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *ProjectCollaboratorMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *ProjectCollaboratorMutation) 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 ProjectCollaborator entity.
// If the ProjectCollaborator 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 *ProjectCollaboratorMutation) 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 *ProjectCollaboratorMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearUser clears the "user" edge to the User entity.
func (m *ProjectCollaboratorMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[projectcollaborator.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *ProjectCollaboratorMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *ProjectCollaboratorMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *ProjectCollaboratorMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// ClearProject clears the "project" edge to the Project entity.
func (m *ProjectCollaboratorMutation) ClearProject() {
m.clearedproject = true
m.clearedFields[projectcollaborator.FieldProjectID] = struct{}{}
}
// ProjectCleared reports if the "project" edge to the Project entity was cleared.
func (m *ProjectCollaboratorMutation) ProjectCleared() bool {
return m.clearedproject
}
// ProjectIDs returns the "project" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ProjectID instead. It exists only for internal usage by the builders.
func (m *ProjectCollaboratorMutation) ProjectIDs() (ids []uuid.UUID) {
if id := m.project; id != nil {
ids = append(ids, *id)
}
return
}
// ResetProject resets all changes to the "project" edge.
func (m *ProjectCollaboratorMutation) ResetProject() {
m.project = nil
m.clearedproject = false
}
// Where appends a list predicates to the ProjectCollaboratorMutation builder.
func (m *ProjectCollaboratorMutation) Where(ps ...predicate.ProjectCollaborator) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ProjectCollaboratorMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ProjectCollaboratorMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.ProjectCollaborator, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ProjectCollaboratorMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ProjectCollaboratorMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (ProjectCollaborator).
func (m *ProjectCollaboratorMutation) 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 *ProjectCollaboratorMutation) Fields() []string {
fields := make([]string, 0, 6)
if m.deleted_at != nil {
fields = append(fields, projectcollaborator.FieldDeletedAt)
}
if m.project != nil {
fields = append(fields, projectcollaborator.FieldProjectID)
}
if m.user != nil {
fields = append(fields, projectcollaborator.FieldUserID)
}
if m.role != nil {
fields = append(fields, projectcollaborator.FieldRole)
}
if m.created_at != nil {
fields = append(fields, projectcollaborator.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, projectcollaborator.FieldUpdatedAt)
}
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 *ProjectCollaboratorMutation) Field(name string) (ent.Value, bool) {
switch name {
case projectcollaborator.FieldDeletedAt:
return m.DeletedAt()
case projectcollaborator.FieldProjectID:
return m.ProjectID()
case projectcollaborator.FieldUserID:
return m.UserID()
case projectcollaborator.FieldRole:
return m.Role()
case projectcollaborator.FieldCreatedAt:
return m.CreatedAt()
case projectcollaborator.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *ProjectCollaboratorMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case projectcollaborator.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case projectcollaborator.FieldProjectID:
return m.OldProjectID(ctx)
case projectcollaborator.FieldUserID:
return m.OldUserID(ctx)
case projectcollaborator.FieldRole:
return m.OldRole(ctx)
case projectcollaborator.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case projectcollaborator.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown ProjectCollaborator 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 *ProjectCollaboratorMutation) SetField(name string, value ent.Value) error {
switch name {
case projectcollaborator.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 projectcollaborator.FieldProjectID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetProjectID(v)
return nil
case projectcollaborator.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case projectcollaborator.FieldRole:
v, ok := value.(consts.ProjectCollaboratorRole)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRole(v)
return nil
case projectcollaborator.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 projectcollaborator.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown ProjectCollaborator field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ProjectCollaboratorMutation) AddedFields() []string {
return nil
}
// 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 *ProjectCollaboratorMutation) AddedField(name string) (ent.Value, bool) {
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 *ProjectCollaboratorMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown ProjectCollaborator numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ProjectCollaboratorMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(projectcollaborator.FieldDeletedAt) {
fields = append(fields, projectcollaborator.FieldDeletedAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ProjectCollaboratorMutation) 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 *ProjectCollaboratorMutation) ClearField(name string) error {
switch name {
case projectcollaborator.FieldDeletedAt:
m.ClearDeletedAt()
return nil
}
return fmt.Errorf("unknown ProjectCollaborator 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 *ProjectCollaboratorMutation) ResetField(name string) error {
switch name {
case projectcollaborator.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case projectcollaborator.FieldProjectID:
m.ResetProjectID()
return nil
case projectcollaborator.FieldUserID:
m.ResetUserID()
return nil
case projectcollaborator.FieldRole:
m.ResetRole()
return nil
case projectcollaborator.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case projectcollaborator.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown ProjectCollaborator field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ProjectCollaboratorMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.user != nil {
edges = append(edges, projectcollaborator.EdgeUser)
}
if m.project != nil {
edges = append(edges, projectcollaborator.EdgeProject)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ProjectCollaboratorMutation) AddedIDs(name string) []ent.Value {
switch name {
case projectcollaborator.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
case projectcollaborator.EdgeProject:
if id := m.project; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ProjectCollaboratorMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ProjectCollaboratorMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ProjectCollaboratorMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.cleareduser {
edges = append(edges, projectcollaborator.EdgeUser)
}
if m.clearedproject {
edges = append(edges, projectcollaborator.EdgeProject)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ProjectCollaboratorMutation) EdgeCleared(name string) bool {
switch name {
case projectcollaborator.EdgeUser:
return m.cleareduser
case projectcollaborator.EdgeProject:
return m.clearedproject
}
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 *ProjectCollaboratorMutation) ClearEdge(name string) error {
switch name {
case projectcollaborator.EdgeUser:
m.ClearUser()
return nil
case projectcollaborator.EdgeProject:
m.ClearProject()
return nil
}
return fmt.Errorf("unknown ProjectCollaborator 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 *ProjectCollaboratorMutation) ResetEdge(name string) error {
switch name {
case projectcollaborator.EdgeUser:
m.ResetUser()
return nil
case projectcollaborator.EdgeProject:
m.ResetProject()
return nil
}
return fmt.Errorf("unknown ProjectCollaborator edge %s", name)
}
// ProjectGitBotMutation represents an operation that mutates the ProjectGitBot nodes in the graph.
type ProjectGitBotMutation struct {
config
op Op
typ string
id *uuid.UUID
created_at *time.Time
clearedFields map[string]struct{}
project *uuid.UUID
clearedproject bool
git_bot *uuid.UUID
clearedgit_bot bool
done bool
oldValue func(context.Context) (*ProjectGitBot, error)
predicates []predicate.ProjectGitBot
}
var _ ent.Mutation = (*ProjectGitBotMutation)(nil)
// projectgitbotOption allows management of the mutation configuration using functional options.
type projectgitbotOption func(*ProjectGitBotMutation)
// newProjectGitBotMutation creates new mutation for the ProjectGitBot entity.
func newProjectGitBotMutation(c config, op Op, opts ...projectgitbotOption) *ProjectGitBotMutation {
m := &ProjectGitBotMutation{
config: c,
op: op,
typ: TypeProjectGitBot,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withProjectGitBotID sets the ID field of the mutation.
func withProjectGitBotID(id uuid.UUID) projectgitbotOption {
return func(m *ProjectGitBotMutation) {
var (
err error
once sync.Once
value *ProjectGitBot
)
m.oldValue = func(ctx context.Context) (*ProjectGitBot, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().ProjectGitBot.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withProjectGitBot sets the old ProjectGitBot of the mutation.
func withProjectGitBot(node *ProjectGitBot) projectgitbotOption {
return func(m *ProjectGitBotMutation) {
m.oldValue = func(context.Context) (*ProjectGitBot, 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 ProjectGitBotMutation) 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 ProjectGitBotMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 ProjectGitBot entities.
func (m *ProjectGitBotMutation) SetID(id uuid.UUID) {
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 *ProjectGitBotMutation) ID() (id uuid.UUID, 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 *ProjectGitBotMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().ProjectGitBot.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetProjectID sets the "project_id" field.
func (m *ProjectGitBotMutation) SetProjectID(u uuid.UUID) {
m.project = &u
}
// ProjectID returns the value of the "project_id" field in the mutation.
func (m *ProjectGitBotMutation) ProjectID() (r uuid.UUID, exists bool) {
v := m.project
if v == nil {
return
}
return *v, true
}
// OldProjectID returns the old "project_id" field's value of the ProjectGitBot entity.
// If the ProjectGitBot 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 *ProjectGitBotMutation) OldProjectID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldProjectID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldProjectID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldProjectID: %w", err)
}
return oldValue.ProjectID, nil
}
// ResetProjectID resets all changes to the "project_id" field.
func (m *ProjectGitBotMutation) ResetProjectID() {
m.project = nil
}
// SetGitBotID sets the "git_bot_id" field.
func (m *ProjectGitBotMutation) SetGitBotID(u uuid.UUID) {
m.git_bot = &u
}
// GitBotID returns the value of the "git_bot_id" field in the mutation.
func (m *ProjectGitBotMutation) GitBotID() (r uuid.UUID, exists bool) {
v := m.git_bot
if v == nil {
return
}
return *v, true
}
// OldGitBotID returns the old "git_bot_id" field's value of the ProjectGitBot entity.
// If the ProjectGitBot 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 *ProjectGitBotMutation) OldGitBotID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGitBotID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGitBotID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGitBotID: %w", err)
}
return oldValue.GitBotID, nil
}
// ResetGitBotID resets all changes to the "git_bot_id" field.
func (m *ProjectGitBotMutation) ResetGitBotID() {
m.git_bot = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *ProjectGitBotMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ProjectGitBotMutation) 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 ProjectGitBot entity.
// If the ProjectGitBot 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 *ProjectGitBotMutation) 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 *ProjectGitBotMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearProject clears the "project" edge to the Project entity.
func (m *ProjectGitBotMutation) ClearProject() {
m.clearedproject = true
m.clearedFields[projectgitbot.FieldProjectID] = struct{}{}
}
// ProjectCleared reports if the "project" edge to the Project entity was cleared.
func (m *ProjectGitBotMutation) ProjectCleared() bool {
return m.clearedproject
}
// ProjectIDs returns the "project" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ProjectID instead. It exists only for internal usage by the builders.
func (m *ProjectGitBotMutation) ProjectIDs() (ids []uuid.UUID) {
if id := m.project; id != nil {
ids = append(ids, *id)
}
return
}
// ResetProject resets all changes to the "project" edge.
func (m *ProjectGitBotMutation) ResetProject() {
m.project = nil
m.clearedproject = false
}
// ClearGitBot clears the "git_bot" edge to the GitBot entity.
func (m *ProjectGitBotMutation) ClearGitBot() {
m.clearedgit_bot = true
m.clearedFields[projectgitbot.FieldGitBotID] = struct{}{}
}
// GitBotCleared reports if the "git_bot" edge to the GitBot entity was cleared.
func (m *ProjectGitBotMutation) GitBotCleared() bool {
return m.clearedgit_bot
}
// GitBotIDs returns the "git_bot" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// GitBotID instead. It exists only for internal usage by the builders.
func (m *ProjectGitBotMutation) GitBotIDs() (ids []uuid.UUID) {
if id := m.git_bot; id != nil {
ids = append(ids, *id)
}
return
}
// ResetGitBot resets all changes to the "git_bot" edge.
func (m *ProjectGitBotMutation) ResetGitBot() {
m.git_bot = nil
m.clearedgit_bot = false
}
// Where appends a list predicates to the ProjectGitBotMutation builder.
func (m *ProjectGitBotMutation) Where(ps ...predicate.ProjectGitBot) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ProjectGitBotMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ProjectGitBotMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.ProjectGitBot, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ProjectGitBotMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ProjectGitBotMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (ProjectGitBot).
func (m *ProjectGitBotMutation) 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 *ProjectGitBotMutation) Fields() []string {
fields := make([]string, 0, 3)
if m.project != nil {
fields = append(fields, projectgitbot.FieldProjectID)
}
if m.git_bot != nil {
fields = append(fields, projectgitbot.FieldGitBotID)
}
if m.created_at != nil {
fields = append(fields, projectgitbot.FieldCreatedAt)
}
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 *ProjectGitBotMutation) Field(name string) (ent.Value, bool) {
switch name {
case projectgitbot.FieldProjectID:
return m.ProjectID()
case projectgitbot.FieldGitBotID:
return m.GitBotID()
case projectgitbot.FieldCreatedAt:
return m.CreatedAt()
}
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 *ProjectGitBotMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case projectgitbot.FieldProjectID:
return m.OldProjectID(ctx)
case projectgitbot.FieldGitBotID:
return m.OldGitBotID(ctx)
case projectgitbot.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown ProjectGitBot 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 *ProjectGitBotMutation) SetField(name string, value ent.Value) error {
switch name {
case projectgitbot.FieldProjectID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetProjectID(v)
return nil
case projectgitbot.FieldGitBotID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGitBotID(v)
return nil
case projectgitbot.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown ProjectGitBot field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ProjectGitBotMutation) AddedFields() []string {
return nil
}
// 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 *ProjectGitBotMutation) AddedField(name string) (ent.Value, bool) {
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 *ProjectGitBotMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown ProjectGitBot numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ProjectGitBotMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ProjectGitBotMutation) 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 *ProjectGitBotMutation) ClearField(name string) error {
return fmt.Errorf("unknown ProjectGitBot 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 *ProjectGitBotMutation) ResetField(name string) error {
switch name {
case projectgitbot.FieldProjectID:
m.ResetProjectID()
return nil
case projectgitbot.FieldGitBotID:
m.ResetGitBotID()
return nil
case projectgitbot.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown ProjectGitBot field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ProjectGitBotMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.project != nil {
edges = append(edges, projectgitbot.EdgeProject)
}
if m.git_bot != nil {
edges = append(edges, projectgitbot.EdgeGitBot)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ProjectGitBotMutation) AddedIDs(name string) []ent.Value {
switch name {
case projectgitbot.EdgeProject:
if id := m.project; id != nil {
return []ent.Value{*id}
}
case projectgitbot.EdgeGitBot:
if id := m.git_bot; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ProjectGitBotMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ProjectGitBotMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ProjectGitBotMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedproject {
edges = append(edges, projectgitbot.EdgeProject)
}
if m.clearedgit_bot {
edges = append(edges, projectgitbot.EdgeGitBot)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ProjectGitBotMutation) EdgeCleared(name string) bool {
switch name {
case projectgitbot.EdgeProject:
return m.clearedproject
case projectgitbot.EdgeGitBot:
return m.clearedgit_bot
}
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 *ProjectGitBotMutation) ClearEdge(name string) error {
switch name {
case projectgitbot.EdgeProject:
m.ClearProject()
return nil
case projectgitbot.EdgeGitBot:
m.ClearGitBot()
return nil
}
return fmt.Errorf("unknown ProjectGitBot 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 *ProjectGitBotMutation) ResetEdge(name string) error {
switch name {
case projectgitbot.EdgeProject:
m.ResetProject()
return nil
case projectgitbot.EdgeGitBot:
m.ResetGitBot()
return nil
}
return fmt.Errorf("unknown ProjectGitBot edge %s", name)
}
// ProjectIssueMutation represents an operation that mutates the ProjectIssue nodes in the graph.
type ProjectIssueMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
status *consts.ProjectIssueStatus
title *string
requirement_document *string
design_document *string
summary *string
priority *consts.ProjectIssuePriority
addpriority *consts.ProjectIssuePriority
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
user *uuid.UUID
cleareduser bool
assignee *uuid.UUID
clearedassignee bool
project *uuid.UUID
clearedproject bool
comments map[uuid.UUID]struct{}
removedcomments map[uuid.UUID]struct{}
clearedcomments bool
project_tasks map[uuid.UUID]struct{}
removedproject_tasks map[uuid.UUID]struct{}
clearedproject_tasks bool
done bool
oldValue func(context.Context) (*ProjectIssue, error)
predicates []predicate.ProjectIssue
}
var _ ent.Mutation = (*ProjectIssueMutation)(nil)
// projectissueOption allows management of the mutation configuration using functional options.
type projectissueOption func(*ProjectIssueMutation)
// newProjectIssueMutation creates new mutation for the ProjectIssue entity.
func newProjectIssueMutation(c config, op Op, opts ...projectissueOption) *ProjectIssueMutation {
m := &ProjectIssueMutation{
config: c,
op: op,
typ: TypeProjectIssue,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withProjectIssueID sets the ID field of the mutation.
func withProjectIssueID(id uuid.UUID) projectissueOption {
return func(m *ProjectIssueMutation) {
var (
err error
once sync.Once
value *ProjectIssue
)
m.oldValue = func(ctx context.Context) (*ProjectIssue, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().ProjectIssue.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withProjectIssue sets the old ProjectIssue of the mutation.
func withProjectIssue(node *ProjectIssue) projectissueOption {
return func(m *ProjectIssueMutation) {
m.oldValue = func(context.Context) (*ProjectIssue, 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 ProjectIssueMutation) 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 ProjectIssueMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 ProjectIssue entities.
func (m *ProjectIssueMutation) SetID(id uuid.UUID) {
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 *ProjectIssueMutation) ID() (id uuid.UUID, 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 *ProjectIssueMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().ProjectIssue.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *ProjectIssueMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *ProjectIssueMutation) 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 ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) 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 *ProjectIssueMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[projectissue.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *ProjectIssueMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[projectissue.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *ProjectIssueMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, projectissue.FieldDeletedAt)
}
// SetUserID sets the "user_id" field.
func (m *ProjectIssueMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *ProjectIssueMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *ProjectIssueMutation) ResetUserID() {
m.user = nil
}
// SetProjectID sets the "project_id" field.
func (m *ProjectIssueMutation) SetProjectID(u uuid.UUID) {
m.project = &u
}
// ProjectID returns the value of the "project_id" field in the mutation.
func (m *ProjectIssueMutation) ProjectID() (r uuid.UUID, exists bool) {
v := m.project
if v == nil {
return
}
return *v, true
}
// OldProjectID returns the old "project_id" field's value of the ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) OldProjectID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldProjectID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldProjectID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldProjectID: %w", err)
}
return oldValue.ProjectID, nil
}
// ResetProjectID resets all changes to the "project_id" field.
func (m *ProjectIssueMutation) ResetProjectID() {
m.project = nil
}
// SetStatus sets the "status" field.
func (m *ProjectIssueMutation) SetStatus(cis consts.ProjectIssueStatus) {
m.status = &cis
}
// Status returns the value of the "status" field in the mutation.
func (m *ProjectIssueMutation) Status() (r consts.ProjectIssueStatus, exists bool) {
v := m.status
if v == nil {
return
}
return *v, true
}
// OldStatus returns the old "status" field's value of the ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) OldStatus(ctx context.Context) (v consts.ProjectIssueStatus, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldStatus is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldStatus requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStatus: %w", err)
}
return oldValue.Status, nil
}
// ResetStatus resets all changes to the "status" field.
func (m *ProjectIssueMutation) ResetStatus() {
m.status = nil
}
// SetTitle sets the "title" field.
func (m *ProjectIssueMutation) SetTitle(s string) {
m.title = &s
}
// Title returns the value of the "title" field in the mutation.
func (m *ProjectIssueMutation) 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 ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) 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
}
// ResetTitle resets all changes to the "title" field.
func (m *ProjectIssueMutation) ResetTitle() {
m.title = nil
}
// SetRequirementDocument sets the "requirement_document" field.
func (m *ProjectIssueMutation) SetRequirementDocument(s string) {
m.requirement_document = &s
}
// RequirementDocument returns the value of the "requirement_document" field in the mutation.
func (m *ProjectIssueMutation) RequirementDocument() (r string, exists bool) {
v := m.requirement_document
if v == nil {
return
}
return *v, true
}
// OldRequirementDocument returns the old "requirement_document" field's value of the ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) OldRequirementDocument(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRequirementDocument is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRequirementDocument requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRequirementDocument: %w", err)
}
return oldValue.RequirementDocument, nil
}
// ClearRequirementDocument clears the value of the "requirement_document" field.
func (m *ProjectIssueMutation) ClearRequirementDocument() {
m.requirement_document = nil
m.clearedFields[projectissue.FieldRequirementDocument] = struct{}{}
}
// RequirementDocumentCleared returns if the "requirement_document" field was cleared in this mutation.
func (m *ProjectIssueMutation) RequirementDocumentCleared() bool {
_, ok := m.clearedFields[projectissue.FieldRequirementDocument]
return ok
}
// ResetRequirementDocument resets all changes to the "requirement_document" field.
func (m *ProjectIssueMutation) ResetRequirementDocument() {
m.requirement_document = nil
delete(m.clearedFields, projectissue.FieldRequirementDocument)
}
// SetDesignDocument sets the "design_document" field.
func (m *ProjectIssueMutation) SetDesignDocument(s string) {
m.design_document = &s
}
// DesignDocument returns the value of the "design_document" field in the mutation.
func (m *ProjectIssueMutation) DesignDocument() (r string, exists bool) {
v := m.design_document
if v == nil {
return
}
return *v, true
}
// OldDesignDocument returns the old "design_document" field's value of the ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) OldDesignDocument(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDesignDocument is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldDesignDocument requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDesignDocument: %w", err)
}
return oldValue.DesignDocument, nil
}
// ClearDesignDocument clears the value of the "design_document" field.
func (m *ProjectIssueMutation) ClearDesignDocument() {
m.design_document = nil
m.clearedFields[projectissue.FieldDesignDocument] = struct{}{}
}
// DesignDocumentCleared returns if the "design_document" field was cleared in this mutation.
func (m *ProjectIssueMutation) DesignDocumentCleared() bool {
_, ok := m.clearedFields[projectissue.FieldDesignDocument]
return ok
}
// ResetDesignDocument resets all changes to the "design_document" field.
func (m *ProjectIssueMutation) ResetDesignDocument() {
m.design_document = nil
delete(m.clearedFields, projectissue.FieldDesignDocument)
}
// SetSummary sets the "summary" field.
func (m *ProjectIssueMutation) SetSummary(s string) {
m.summary = &s
}
// Summary returns the value of the "summary" field in the mutation.
func (m *ProjectIssueMutation) Summary() (r string, exists bool) {
v := m.summary
if v == nil {
return
}
return *v, true
}
// OldSummary returns the old "summary" field's value of the ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) OldSummary(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSummary is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSummary requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSummary: %w", err)
}
return oldValue.Summary, nil
}
// ClearSummary clears the value of the "summary" field.
func (m *ProjectIssueMutation) ClearSummary() {
m.summary = nil
m.clearedFields[projectissue.FieldSummary] = struct{}{}
}
// SummaryCleared returns if the "summary" field was cleared in this mutation.
func (m *ProjectIssueMutation) SummaryCleared() bool {
_, ok := m.clearedFields[projectissue.FieldSummary]
return ok
}
// ResetSummary resets all changes to the "summary" field.
func (m *ProjectIssueMutation) ResetSummary() {
m.summary = nil
delete(m.clearedFields, projectissue.FieldSummary)
}
// SetAssigneeID sets the "assignee_id" field.
func (m *ProjectIssueMutation) SetAssigneeID(u uuid.UUID) {
m.assignee = &u
}
// AssigneeID returns the value of the "assignee_id" field in the mutation.
func (m *ProjectIssueMutation) AssigneeID() (r uuid.UUID, exists bool) {
v := m.assignee
if v == nil {
return
}
return *v, true
}
// OldAssigneeID returns the old "assignee_id" field's value of the ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) OldAssigneeID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAssigneeID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAssigneeID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAssigneeID: %w", err)
}
return oldValue.AssigneeID, nil
}
// ClearAssigneeID clears the value of the "assignee_id" field.
func (m *ProjectIssueMutation) ClearAssigneeID() {
m.assignee = nil
m.clearedFields[projectissue.FieldAssigneeID] = struct{}{}
}
// AssigneeIDCleared returns if the "assignee_id" field was cleared in this mutation.
func (m *ProjectIssueMutation) AssigneeIDCleared() bool {
_, ok := m.clearedFields[projectissue.FieldAssigneeID]
return ok
}
// ResetAssigneeID resets all changes to the "assignee_id" field.
func (m *ProjectIssueMutation) ResetAssigneeID() {
m.assignee = nil
delete(m.clearedFields, projectissue.FieldAssigneeID)
}
// SetPriority sets the "priority" field.
func (m *ProjectIssueMutation) SetPriority(cip consts.ProjectIssuePriority) {
m.priority = &cip
m.addpriority = nil
}
// Priority returns the value of the "priority" field in the mutation.
func (m *ProjectIssueMutation) Priority() (r consts.ProjectIssuePriority, exists bool) {
v := m.priority
if v == nil {
return
}
return *v, true
}
// OldPriority returns the old "priority" field's value of the ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) OldPriority(ctx context.Context) (v consts.ProjectIssuePriority, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPriority is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPriority requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPriority: %w", err)
}
return oldValue.Priority, nil
}
// AddPriority adds cip to the "priority" field.
func (m *ProjectIssueMutation) AddPriority(cip consts.ProjectIssuePriority) {
if m.addpriority != nil {
*m.addpriority += cip
} else {
m.addpriority = &cip
}
}
// AddedPriority returns the value that was added to the "priority" field in this mutation.
func (m *ProjectIssueMutation) AddedPriority() (r consts.ProjectIssuePriority, exists bool) {
v := m.addpriority
if v == nil {
return
}
return *v, true
}
// ResetPriority resets all changes to the "priority" field.
func (m *ProjectIssueMutation) ResetPriority() {
m.priority = nil
m.addpriority = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *ProjectIssueMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ProjectIssueMutation) 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 ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) 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 *ProjectIssueMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *ProjectIssueMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *ProjectIssueMutation) 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 ProjectIssue entity.
// If the ProjectIssue 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 *ProjectIssueMutation) 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 *ProjectIssueMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearUser clears the "user" edge to the User entity.
func (m *ProjectIssueMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[projectissue.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *ProjectIssueMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *ProjectIssueMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *ProjectIssueMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// ClearAssignee clears the "assignee" edge to the User entity.
func (m *ProjectIssueMutation) ClearAssignee() {
m.clearedassignee = true
m.clearedFields[projectissue.FieldAssigneeID] = struct{}{}
}
// AssigneeCleared reports if the "assignee" edge to the User entity was cleared.
func (m *ProjectIssueMutation) AssigneeCleared() bool {
return m.AssigneeIDCleared() || m.clearedassignee
}
// AssigneeIDs returns the "assignee" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// AssigneeID instead. It exists only for internal usage by the builders.
func (m *ProjectIssueMutation) AssigneeIDs() (ids []uuid.UUID) {
if id := m.assignee; id != nil {
ids = append(ids, *id)
}
return
}
// ResetAssignee resets all changes to the "assignee" edge.
func (m *ProjectIssueMutation) ResetAssignee() {
m.assignee = nil
m.clearedassignee = false
}
// ClearProject clears the "project" edge to the Project entity.
func (m *ProjectIssueMutation) ClearProject() {
m.clearedproject = true
m.clearedFields[projectissue.FieldProjectID] = struct{}{}
}
// ProjectCleared reports if the "project" edge to the Project entity was cleared.
func (m *ProjectIssueMutation) ProjectCleared() bool {
return m.clearedproject
}
// ProjectIDs returns the "project" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ProjectID instead. It exists only for internal usage by the builders.
func (m *ProjectIssueMutation) ProjectIDs() (ids []uuid.UUID) {
if id := m.project; id != nil {
ids = append(ids, *id)
}
return
}
// ResetProject resets all changes to the "project" edge.
func (m *ProjectIssueMutation) ResetProject() {
m.project = nil
m.clearedproject = false
}
// AddCommentIDs adds the "comments" edge to the ProjectIssueComment entity by ids.
func (m *ProjectIssueMutation) AddCommentIDs(ids ...uuid.UUID) {
if m.comments == nil {
m.comments = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.comments[ids[i]] = struct{}{}
}
}
// ClearComments clears the "comments" edge to the ProjectIssueComment entity.
func (m *ProjectIssueMutation) ClearComments() {
m.clearedcomments = true
}
// CommentsCleared reports if the "comments" edge to the ProjectIssueComment entity was cleared.
func (m *ProjectIssueMutation) CommentsCleared() bool {
return m.clearedcomments
}
// RemoveCommentIDs removes the "comments" edge to the ProjectIssueComment entity by IDs.
func (m *ProjectIssueMutation) RemoveCommentIDs(ids ...uuid.UUID) {
if m.removedcomments == nil {
m.removedcomments = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.comments, ids[i])
m.removedcomments[ids[i]] = struct{}{}
}
}
// RemovedComments returns the removed IDs of the "comments" edge to the ProjectIssueComment entity.
func (m *ProjectIssueMutation) RemovedCommentsIDs() (ids []uuid.UUID) {
for id := range m.removedcomments {
ids = append(ids, id)
}
return
}
// CommentsIDs returns the "comments" edge IDs in the mutation.
func (m *ProjectIssueMutation) CommentsIDs() (ids []uuid.UUID) {
for id := range m.comments {
ids = append(ids, id)
}
return
}
// ResetComments resets all changes to the "comments" edge.
func (m *ProjectIssueMutation) ResetComments() {
m.comments = nil
m.clearedcomments = false
m.removedcomments = nil
}
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids.
func (m *ProjectIssueMutation) AddProjectTaskIDs(ids ...uuid.UUID) {
if m.project_tasks == nil {
m.project_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.project_tasks[ids[i]] = struct{}{}
}
}
// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity.
func (m *ProjectIssueMutation) ClearProjectTasks() {
m.clearedproject_tasks = true
}
// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared.
func (m *ProjectIssueMutation) ProjectTasksCleared() bool {
return m.clearedproject_tasks
}
// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs.
func (m *ProjectIssueMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) {
if m.removedproject_tasks == nil {
m.removedproject_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.project_tasks, ids[i])
m.removedproject_tasks[ids[i]] = struct{}{}
}
}
// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity.
func (m *ProjectIssueMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return
}
// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation.
func (m *ProjectIssueMutation) ProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.project_tasks {
ids = append(ids, id)
}
return
}
// ResetProjectTasks resets all changes to the "project_tasks" edge.
func (m *ProjectIssueMutation) ResetProjectTasks() {
m.project_tasks = nil
m.clearedproject_tasks = false
m.removedproject_tasks = nil
}
// Where appends a list predicates to the ProjectIssueMutation builder.
func (m *ProjectIssueMutation) Where(ps ...predicate.ProjectIssue) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ProjectIssueMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ProjectIssueMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.ProjectIssue, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ProjectIssueMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ProjectIssueMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (ProjectIssue).
func (m *ProjectIssueMutation) 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 *ProjectIssueMutation) Fields() []string {
fields := make([]string, 0, 12)
if m.deleted_at != nil {
fields = append(fields, projectissue.FieldDeletedAt)
}
if m.user != nil {
fields = append(fields, projectissue.FieldUserID)
}
if m.project != nil {
fields = append(fields, projectissue.FieldProjectID)
}
if m.status != nil {
fields = append(fields, projectissue.FieldStatus)
}
if m.title != nil {
fields = append(fields, projectissue.FieldTitle)
}
if m.requirement_document != nil {
fields = append(fields, projectissue.FieldRequirementDocument)
}
if m.design_document != nil {
fields = append(fields, projectissue.FieldDesignDocument)
}
if m.summary != nil {
fields = append(fields, projectissue.FieldSummary)
}
if m.assignee != nil {
fields = append(fields, projectissue.FieldAssigneeID)
}
if m.priority != nil {
fields = append(fields, projectissue.FieldPriority)
}
if m.created_at != nil {
fields = append(fields, projectissue.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, projectissue.FieldUpdatedAt)
}
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 *ProjectIssueMutation) Field(name string) (ent.Value, bool) {
switch name {
case projectissue.FieldDeletedAt:
return m.DeletedAt()
case projectissue.FieldUserID:
return m.UserID()
case projectissue.FieldProjectID:
return m.ProjectID()
case projectissue.FieldStatus:
return m.Status()
case projectissue.FieldTitle:
return m.Title()
case projectissue.FieldRequirementDocument:
return m.RequirementDocument()
case projectissue.FieldDesignDocument:
return m.DesignDocument()
case projectissue.FieldSummary:
return m.Summary()
case projectissue.FieldAssigneeID:
return m.AssigneeID()
case projectissue.FieldPriority:
return m.Priority()
case projectissue.FieldCreatedAt:
return m.CreatedAt()
case projectissue.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *ProjectIssueMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case projectissue.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case projectissue.FieldUserID:
return m.OldUserID(ctx)
case projectissue.FieldProjectID:
return m.OldProjectID(ctx)
case projectissue.FieldStatus:
return m.OldStatus(ctx)
case projectissue.FieldTitle:
return m.OldTitle(ctx)
case projectissue.FieldRequirementDocument:
return m.OldRequirementDocument(ctx)
case projectissue.FieldDesignDocument:
return m.OldDesignDocument(ctx)
case projectissue.FieldSummary:
return m.OldSummary(ctx)
case projectissue.FieldAssigneeID:
return m.OldAssigneeID(ctx)
case projectissue.FieldPriority:
return m.OldPriority(ctx)
case projectissue.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case projectissue.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown ProjectIssue 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 *ProjectIssueMutation) SetField(name string, value ent.Value) error {
switch name {
case projectissue.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 projectissue.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case projectissue.FieldProjectID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetProjectID(v)
return nil
case projectissue.FieldStatus:
v, ok := value.(consts.ProjectIssueStatus)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetStatus(v)
return nil
case projectissue.FieldTitle:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTitle(v)
return nil
case projectissue.FieldRequirementDocument:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRequirementDocument(v)
return nil
case projectissue.FieldDesignDocument:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDesignDocument(v)
return nil
case projectissue.FieldSummary:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSummary(v)
return nil
case projectissue.FieldAssigneeID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAssigneeID(v)
return nil
case projectissue.FieldPriority:
v, ok := value.(consts.ProjectIssuePriority)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPriority(v)
return nil
case projectissue.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 projectissue.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown ProjectIssue field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ProjectIssueMutation) AddedFields() []string {
var fields []string
if m.addpriority != nil {
fields = append(fields, projectissue.FieldPriority)
}
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 *ProjectIssueMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case projectissue.FieldPriority:
return m.AddedPriority()
}
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 *ProjectIssueMutation) AddField(name string, value ent.Value) error {
switch name {
case projectissue.FieldPriority:
v, ok := value.(consts.ProjectIssuePriority)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddPriority(v)
return nil
}
return fmt.Errorf("unknown ProjectIssue numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ProjectIssueMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(projectissue.FieldDeletedAt) {
fields = append(fields, projectissue.FieldDeletedAt)
}
if m.FieldCleared(projectissue.FieldRequirementDocument) {
fields = append(fields, projectissue.FieldRequirementDocument)
}
if m.FieldCleared(projectissue.FieldDesignDocument) {
fields = append(fields, projectissue.FieldDesignDocument)
}
if m.FieldCleared(projectissue.FieldSummary) {
fields = append(fields, projectissue.FieldSummary)
}
if m.FieldCleared(projectissue.FieldAssigneeID) {
fields = append(fields, projectissue.FieldAssigneeID)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ProjectIssueMutation) 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 *ProjectIssueMutation) ClearField(name string) error {
switch name {
case projectissue.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case projectissue.FieldRequirementDocument:
m.ClearRequirementDocument()
return nil
case projectissue.FieldDesignDocument:
m.ClearDesignDocument()
return nil
case projectissue.FieldSummary:
m.ClearSummary()
return nil
case projectissue.FieldAssigneeID:
m.ClearAssigneeID()
return nil
}
return fmt.Errorf("unknown ProjectIssue 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 *ProjectIssueMutation) ResetField(name string) error {
switch name {
case projectissue.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case projectissue.FieldUserID:
m.ResetUserID()
return nil
case projectissue.FieldProjectID:
m.ResetProjectID()
return nil
case projectissue.FieldStatus:
m.ResetStatus()
return nil
case projectissue.FieldTitle:
m.ResetTitle()
return nil
case projectissue.FieldRequirementDocument:
m.ResetRequirementDocument()
return nil
case projectissue.FieldDesignDocument:
m.ResetDesignDocument()
return nil
case projectissue.FieldSummary:
m.ResetSummary()
return nil
case projectissue.FieldAssigneeID:
m.ResetAssigneeID()
return nil
case projectissue.FieldPriority:
m.ResetPriority()
return nil
case projectissue.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case projectissue.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown ProjectIssue field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ProjectIssueMutation) AddedEdges() []string {
edges := make([]string, 0, 5)
if m.user != nil {
edges = append(edges, projectissue.EdgeUser)
}
if m.assignee != nil {
edges = append(edges, projectissue.EdgeAssignee)
}
if m.project != nil {
edges = append(edges, projectissue.EdgeProject)
}
if m.comments != nil {
edges = append(edges, projectissue.EdgeComments)
}
if m.project_tasks != nil {
edges = append(edges, projectissue.EdgeProjectTasks)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ProjectIssueMutation) AddedIDs(name string) []ent.Value {
switch name {
case projectissue.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
case projectissue.EdgeAssignee:
if id := m.assignee; id != nil {
return []ent.Value{*id}
}
case projectissue.EdgeProject:
if id := m.project; id != nil {
return []ent.Value{*id}
}
case projectissue.EdgeComments:
ids := make([]ent.Value, 0, len(m.comments))
for id := range m.comments {
ids = append(ids, id)
}
return ids
case projectissue.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.project_tasks))
for id := range m.project_tasks {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ProjectIssueMutation) RemovedEdges() []string {
edges := make([]string, 0, 5)
if m.removedcomments != nil {
edges = append(edges, projectissue.EdgeComments)
}
if m.removedproject_tasks != nil {
edges = append(edges, projectissue.EdgeProjectTasks)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ProjectIssueMutation) RemovedIDs(name string) []ent.Value {
switch name {
case projectissue.EdgeComments:
ids := make([]ent.Value, 0, len(m.removedcomments))
for id := range m.removedcomments {
ids = append(ids, id)
}
return ids
case projectissue.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.removedproject_tasks))
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ProjectIssueMutation) ClearedEdges() []string {
edges := make([]string, 0, 5)
if m.cleareduser {
edges = append(edges, projectissue.EdgeUser)
}
if m.clearedassignee {
edges = append(edges, projectissue.EdgeAssignee)
}
if m.clearedproject {
edges = append(edges, projectissue.EdgeProject)
}
if m.clearedcomments {
edges = append(edges, projectissue.EdgeComments)
}
if m.clearedproject_tasks {
edges = append(edges, projectissue.EdgeProjectTasks)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ProjectIssueMutation) EdgeCleared(name string) bool {
switch name {
case projectissue.EdgeUser:
return m.cleareduser
case projectissue.EdgeAssignee:
return m.clearedassignee
case projectissue.EdgeProject:
return m.clearedproject
case projectissue.EdgeComments:
return m.clearedcomments
case projectissue.EdgeProjectTasks:
return m.clearedproject_tasks
}
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 *ProjectIssueMutation) ClearEdge(name string) error {
switch name {
case projectissue.EdgeUser:
m.ClearUser()
return nil
case projectissue.EdgeAssignee:
m.ClearAssignee()
return nil
case projectissue.EdgeProject:
m.ClearProject()
return nil
}
return fmt.Errorf("unknown ProjectIssue 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 *ProjectIssueMutation) ResetEdge(name string) error {
switch name {
case projectissue.EdgeUser:
m.ResetUser()
return nil
case projectissue.EdgeAssignee:
m.ResetAssignee()
return nil
case projectissue.EdgeProject:
m.ResetProject()
return nil
case projectissue.EdgeComments:
m.ResetComments()
return nil
case projectissue.EdgeProjectTasks:
m.ResetProjectTasks()
return nil
}
return fmt.Errorf("unknown ProjectIssue edge %s", name)
}
// ProjectIssueCommentMutation represents an operation that mutates the ProjectIssueComment nodes in the graph.
type ProjectIssueCommentMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
comment *string
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
user *uuid.UUID
cleareduser bool
issue *uuid.UUID
clearedissue bool
parent *uuid.UUID
clearedparent bool
replies map[uuid.UUID]struct{}
removedreplies map[uuid.UUID]struct{}
clearedreplies bool
done bool
oldValue func(context.Context) (*ProjectIssueComment, error)
predicates []predicate.ProjectIssueComment
}
var _ ent.Mutation = (*ProjectIssueCommentMutation)(nil)
// projectissuecommentOption allows management of the mutation configuration using functional options.
type projectissuecommentOption func(*ProjectIssueCommentMutation)
// newProjectIssueCommentMutation creates new mutation for the ProjectIssueComment entity.
func newProjectIssueCommentMutation(c config, op Op, opts ...projectissuecommentOption) *ProjectIssueCommentMutation {
m := &ProjectIssueCommentMutation{
config: c,
op: op,
typ: TypeProjectIssueComment,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withProjectIssueCommentID sets the ID field of the mutation.
func withProjectIssueCommentID(id uuid.UUID) projectissuecommentOption {
return func(m *ProjectIssueCommentMutation) {
var (
err error
once sync.Once
value *ProjectIssueComment
)
m.oldValue = func(ctx context.Context) (*ProjectIssueComment, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().ProjectIssueComment.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withProjectIssueComment sets the old ProjectIssueComment of the mutation.
func withProjectIssueComment(node *ProjectIssueComment) projectissuecommentOption {
return func(m *ProjectIssueCommentMutation) {
m.oldValue = func(context.Context) (*ProjectIssueComment, 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 ProjectIssueCommentMutation) 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 ProjectIssueCommentMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 ProjectIssueComment entities.
func (m *ProjectIssueCommentMutation) SetID(id uuid.UUID) {
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 *ProjectIssueCommentMutation) ID() (id uuid.UUID, 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 *ProjectIssueCommentMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().ProjectIssueComment.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *ProjectIssueCommentMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *ProjectIssueCommentMutation) 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 ProjectIssueComment entity.
// If the ProjectIssueComment 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 *ProjectIssueCommentMutation) 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 *ProjectIssueCommentMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[projectissuecomment.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *ProjectIssueCommentMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[projectissuecomment.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *ProjectIssueCommentMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, projectissuecomment.FieldDeletedAt)
}
// SetUserID sets the "user_id" field.
func (m *ProjectIssueCommentMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *ProjectIssueCommentMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the ProjectIssueComment entity.
// If the ProjectIssueComment 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 *ProjectIssueCommentMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *ProjectIssueCommentMutation) ResetUserID() {
m.user = nil
}
// SetIssueID sets the "issue_id" field.
func (m *ProjectIssueCommentMutation) SetIssueID(u uuid.UUID) {
m.issue = &u
}
// IssueID returns the value of the "issue_id" field in the mutation.
func (m *ProjectIssueCommentMutation) IssueID() (r uuid.UUID, exists bool) {
v := m.issue
if v == nil {
return
}
return *v, true
}
// OldIssueID returns the old "issue_id" field's value of the ProjectIssueComment entity.
// If the ProjectIssueComment 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 *ProjectIssueCommentMutation) OldIssueID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldIssueID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldIssueID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIssueID: %w", err)
}
return oldValue.IssueID, nil
}
// ResetIssueID resets all changes to the "issue_id" field.
func (m *ProjectIssueCommentMutation) ResetIssueID() {
m.issue = nil
}
// SetParentID sets the "parent_id" field.
func (m *ProjectIssueCommentMutation) SetParentID(u uuid.UUID) {
m.parent = &u
}
// ParentID returns the value of the "parent_id" field in the mutation.
func (m *ProjectIssueCommentMutation) ParentID() (r uuid.UUID, exists bool) {
v := m.parent
if v == nil {
return
}
return *v, true
}
// OldParentID returns the old "parent_id" field's value of the ProjectIssueComment entity.
// If the ProjectIssueComment 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 *ProjectIssueCommentMutation) OldParentID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldParentID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldParentID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldParentID: %w", err)
}
return oldValue.ParentID, nil
}
// ClearParentID clears the value of the "parent_id" field.
func (m *ProjectIssueCommentMutation) ClearParentID() {
m.parent = nil
m.clearedFields[projectissuecomment.FieldParentID] = struct{}{}
}
// ParentIDCleared returns if the "parent_id" field was cleared in this mutation.
func (m *ProjectIssueCommentMutation) ParentIDCleared() bool {
_, ok := m.clearedFields[projectissuecomment.FieldParentID]
return ok
}
// ResetParentID resets all changes to the "parent_id" field.
func (m *ProjectIssueCommentMutation) ResetParentID() {
m.parent = nil
delete(m.clearedFields, projectissuecomment.FieldParentID)
}
// SetComment sets the "comment" field.
func (m *ProjectIssueCommentMutation) SetComment(s string) {
m.comment = &s
}
// Comment returns the value of the "comment" field in the mutation.
func (m *ProjectIssueCommentMutation) Comment() (r string, exists bool) {
v := m.comment
if v == nil {
return
}
return *v, true
}
// OldComment returns the old "comment" field's value of the ProjectIssueComment entity.
// If the ProjectIssueComment 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 *ProjectIssueCommentMutation) OldComment(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldComment is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldComment requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldComment: %w", err)
}
return oldValue.Comment, nil
}
// ResetComment resets all changes to the "comment" field.
func (m *ProjectIssueCommentMutation) ResetComment() {
m.comment = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *ProjectIssueCommentMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ProjectIssueCommentMutation) 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 ProjectIssueComment entity.
// If the ProjectIssueComment 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 *ProjectIssueCommentMutation) 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 *ProjectIssueCommentMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *ProjectIssueCommentMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *ProjectIssueCommentMutation) 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 ProjectIssueComment entity.
// If the ProjectIssueComment 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 *ProjectIssueCommentMutation) 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 *ProjectIssueCommentMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearUser clears the "user" edge to the User entity.
func (m *ProjectIssueCommentMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[projectissuecomment.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *ProjectIssueCommentMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *ProjectIssueCommentMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *ProjectIssueCommentMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// ClearIssue clears the "issue" edge to the ProjectIssue entity.
func (m *ProjectIssueCommentMutation) ClearIssue() {
m.clearedissue = true
m.clearedFields[projectissuecomment.FieldIssueID] = struct{}{}
}
// IssueCleared reports if the "issue" edge to the ProjectIssue entity was cleared.
func (m *ProjectIssueCommentMutation) IssueCleared() bool {
return m.clearedissue
}
// IssueIDs returns the "issue" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// IssueID instead. It exists only for internal usage by the builders.
func (m *ProjectIssueCommentMutation) IssueIDs() (ids []uuid.UUID) {
if id := m.issue; id != nil {
ids = append(ids, *id)
}
return
}
// ResetIssue resets all changes to the "issue" edge.
func (m *ProjectIssueCommentMutation) ResetIssue() {
m.issue = nil
m.clearedissue = false
}
// ClearParent clears the "parent" edge to the ProjectIssueComment entity.
func (m *ProjectIssueCommentMutation) ClearParent() {
m.clearedparent = true
m.clearedFields[projectissuecomment.FieldParentID] = struct{}{}
}
// ParentCleared reports if the "parent" edge to the ProjectIssueComment entity was cleared.
func (m *ProjectIssueCommentMutation) ParentCleared() bool {
return m.ParentIDCleared() || m.clearedparent
}
// ParentIDs returns the "parent" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ParentID instead. It exists only for internal usage by the builders.
func (m *ProjectIssueCommentMutation) ParentIDs() (ids []uuid.UUID) {
if id := m.parent; id != nil {
ids = append(ids, *id)
}
return
}
// ResetParent resets all changes to the "parent" edge.
func (m *ProjectIssueCommentMutation) ResetParent() {
m.parent = nil
m.clearedparent = false
}
// AddReplyIDs adds the "replies" edge to the ProjectIssueComment entity by ids.
func (m *ProjectIssueCommentMutation) AddReplyIDs(ids ...uuid.UUID) {
if m.replies == nil {
m.replies = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.replies[ids[i]] = struct{}{}
}
}
// ClearReplies clears the "replies" edge to the ProjectIssueComment entity.
func (m *ProjectIssueCommentMutation) ClearReplies() {
m.clearedreplies = true
}
// RepliesCleared reports if the "replies" edge to the ProjectIssueComment entity was cleared.
func (m *ProjectIssueCommentMutation) RepliesCleared() bool {
return m.clearedreplies
}
// RemoveReplyIDs removes the "replies" edge to the ProjectIssueComment entity by IDs.
func (m *ProjectIssueCommentMutation) RemoveReplyIDs(ids ...uuid.UUID) {
if m.removedreplies == nil {
m.removedreplies = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.replies, ids[i])
m.removedreplies[ids[i]] = struct{}{}
}
}
// RemovedReplies returns the removed IDs of the "replies" edge to the ProjectIssueComment entity.
func (m *ProjectIssueCommentMutation) RemovedRepliesIDs() (ids []uuid.UUID) {
for id := range m.removedreplies {
ids = append(ids, id)
}
return
}
// RepliesIDs returns the "replies" edge IDs in the mutation.
func (m *ProjectIssueCommentMutation) RepliesIDs() (ids []uuid.UUID) {
for id := range m.replies {
ids = append(ids, id)
}
return
}
// ResetReplies resets all changes to the "replies" edge.
func (m *ProjectIssueCommentMutation) ResetReplies() {
m.replies = nil
m.clearedreplies = false
m.removedreplies = nil
}
// Where appends a list predicates to the ProjectIssueCommentMutation builder.
func (m *ProjectIssueCommentMutation) Where(ps ...predicate.ProjectIssueComment) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ProjectIssueCommentMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ProjectIssueCommentMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.ProjectIssueComment, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ProjectIssueCommentMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ProjectIssueCommentMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (ProjectIssueComment).
func (m *ProjectIssueCommentMutation) 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 *ProjectIssueCommentMutation) Fields() []string {
fields := make([]string, 0, 7)
if m.deleted_at != nil {
fields = append(fields, projectissuecomment.FieldDeletedAt)
}
if m.user != nil {
fields = append(fields, projectissuecomment.FieldUserID)
}
if m.issue != nil {
fields = append(fields, projectissuecomment.FieldIssueID)
}
if m.parent != nil {
fields = append(fields, projectissuecomment.FieldParentID)
}
if m.comment != nil {
fields = append(fields, projectissuecomment.FieldComment)
}
if m.created_at != nil {
fields = append(fields, projectissuecomment.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, projectissuecomment.FieldUpdatedAt)
}
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 *ProjectIssueCommentMutation) Field(name string) (ent.Value, bool) {
switch name {
case projectissuecomment.FieldDeletedAt:
return m.DeletedAt()
case projectissuecomment.FieldUserID:
return m.UserID()
case projectissuecomment.FieldIssueID:
return m.IssueID()
case projectissuecomment.FieldParentID:
return m.ParentID()
case projectissuecomment.FieldComment:
return m.Comment()
case projectissuecomment.FieldCreatedAt:
return m.CreatedAt()
case projectissuecomment.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *ProjectIssueCommentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case projectissuecomment.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case projectissuecomment.FieldUserID:
return m.OldUserID(ctx)
case projectissuecomment.FieldIssueID:
return m.OldIssueID(ctx)
case projectissuecomment.FieldParentID:
return m.OldParentID(ctx)
case projectissuecomment.FieldComment:
return m.OldComment(ctx)
case projectissuecomment.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case projectissuecomment.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown ProjectIssueComment 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 *ProjectIssueCommentMutation) SetField(name string, value ent.Value) error {
switch name {
case projectissuecomment.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 projectissuecomment.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case projectissuecomment.FieldIssueID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetIssueID(v)
return nil
case projectissuecomment.FieldParentID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetParentID(v)
return nil
case projectissuecomment.FieldComment:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetComment(v)
return nil
case projectissuecomment.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 projectissuecomment.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown ProjectIssueComment field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ProjectIssueCommentMutation) AddedFields() []string {
return nil
}
// 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 *ProjectIssueCommentMutation) AddedField(name string) (ent.Value, bool) {
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 *ProjectIssueCommentMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown ProjectIssueComment numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ProjectIssueCommentMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(projectissuecomment.FieldDeletedAt) {
fields = append(fields, projectissuecomment.FieldDeletedAt)
}
if m.FieldCleared(projectissuecomment.FieldParentID) {
fields = append(fields, projectissuecomment.FieldParentID)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ProjectIssueCommentMutation) 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 *ProjectIssueCommentMutation) ClearField(name string) error {
switch name {
case projectissuecomment.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case projectissuecomment.FieldParentID:
m.ClearParentID()
return nil
}
return fmt.Errorf("unknown ProjectIssueComment 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 *ProjectIssueCommentMutation) ResetField(name string) error {
switch name {
case projectissuecomment.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case projectissuecomment.FieldUserID:
m.ResetUserID()
return nil
case projectissuecomment.FieldIssueID:
m.ResetIssueID()
return nil
case projectissuecomment.FieldParentID:
m.ResetParentID()
return nil
case projectissuecomment.FieldComment:
m.ResetComment()
return nil
case projectissuecomment.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case projectissuecomment.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown ProjectIssueComment field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ProjectIssueCommentMutation) AddedEdges() []string {
edges := make([]string, 0, 4)
if m.user != nil {
edges = append(edges, projectissuecomment.EdgeUser)
}
if m.issue != nil {
edges = append(edges, projectissuecomment.EdgeIssue)
}
if m.parent != nil {
edges = append(edges, projectissuecomment.EdgeParent)
}
if m.replies != nil {
edges = append(edges, projectissuecomment.EdgeReplies)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ProjectIssueCommentMutation) AddedIDs(name string) []ent.Value {
switch name {
case projectissuecomment.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
case projectissuecomment.EdgeIssue:
if id := m.issue; id != nil {
return []ent.Value{*id}
}
case projectissuecomment.EdgeParent:
if id := m.parent; id != nil {
return []ent.Value{*id}
}
case projectissuecomment.EdgeReplies:
ids := make([]ent.Value, 0, len(m.replies))
for id := range m.replies {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ProjectIssueCommentMutation) RemovedEdges() []string {
edges := make([]string, 0, 4)
if m.removedreplies != nil {
edges = append(edges, projectissuecomment.EdgeReplies)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ProjectIssueCommentMutation) RemovedIDs(name string) []ent.Value {
switch name {
case projectissuecomment.EdgeReplies:
ids := make([]ent.Value, 0, len(m.removedreplies))
for id := range m.removedreplies {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ProjectIssueCommentMutation) ClearedEdges() []string {
edges := make([]string, 0, 4)
if m.cleareduser {
edges = append(edges, projectissuecomment.EdgeUser)
}
if m.clearedissue {
edges = append(edges, projectissuecomment.EdgeIssue)
}
if m.clearedparent {
edges = append(edges, projectissuecomment.EdgeParent)
}
if m.clearedreplies {
edges = append(edges, projectissuecomment.EdgeReplies)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ProjectIssueCommentMutation) EdgeCleared(name string) bool {
switch name {
case projectissuecomment.EdgeUser:
return m.cleareduser
case projectissuecomment.EdgeIssue:
return m.clearedissue
case projectissuecomment.EdgeParent:
return m.clearedparent
case projectissuecomment.EdgeReplies:
return m.clearedreplies
}
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 *ProjectIssueCommentMutation) ClearEdge(name string) error {
switch name {
case projectissuecomment.EdgeUser:
m.ClearUser()
return nil
case projectissuecomment.EdgeIssue:
m.ClearIssue()
return nil
case projectissuecomment.EdgeParent:
m.ClearParent()
return nil
}
return fmt.Errorf("unknown ProjectIssueComment 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 *ProjectIssueCommentMutation) ResetEdge(name string) error {
switch name {
case projectissuecomment.EdgeUser:
m.ResetUser()
return nil
case projectissuecomment.EdgeIssue:
m.ResetIssue()
return nil
case projectissuecomment.EdgeParent:
m.ResetParent()
return nil
case projectissuecomment.EdgeReplies:
m.ResetReplies()
return nil
}
return fmt.Errorf("unknown ProjectIssueComment edge %s", name)
}
// ProjectTaskMutation represents an operation that mutates the ProjectTask nodes in the graph.
type ProjectTaskMutation struct {
config
op Op
typ string
id *uuid.UUID
repo_url *string
repo_filename *string
branch *string
cli_name *consts.CliName
created_at *time.Time
clearedFields map[string]struct{}
task *uuid.UUID
clearedtask bool
model *uuid.UUID
clearedmodel bool
image *uuid.UUID
clearedimage bool
git_identity *uuid.UUID
clearedgit_identity bool
project *uuid.UUID
clearedproject bool
issue *uuid.UUID
clearedissue bool
done bool
oldValue func(context.Context) (*ProjectTask, error)
predicates []predicate.ProjectTask
}
var _ ent.Mutation = (*ProjectTaskMutation)(nil)
// projecttaskOption allows management of the mutation configuration using functional options.
type projecttaskOption func(*ProjectTaskMutation)
// newProjectTaskMutation creates new mutation for the ProjectTask entity.
func newProjectTaskMutation(c config, op Op, opts ...projecttaskOption) *ProjectTaskMutation {
m := &ProjectTaskMutation{
config: c,
op: op,
typ: TypeProjectTask,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withProjectTaskID sets the ID field of the mutation.
func withProjectTaskID(id uuid.UUID) projecttaskOption {
return func(m *ProjectTaskMutation) {
var (
err error
once sync.Once
value *ProjectTask
)
m.oldValue = func(ctx context.Context) (*ProjectTask, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().ProjectTask.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withProjectTask sets the old ProjectTask of the mutation.
func withProjectTask(node *ProjectTask) projecttaskOption {
return func(m *ProjectTaskMutation) {
m.oldValue = func(context.Context) (*ProjectTask, 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 ProjectTaskMutation) 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 ProjectTaskMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 ProjectTask entities.
func (m *ProjectTaskMutation) SetID(id uuid.UUID) {
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 *ProjectTaskMutation) ID() (id uuid.UUID, 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 *ProjectTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().ProjectTask.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetTaskID sets the "task_id" field.
func (m *ProjectTaskMutation) SetTaskID(u uuid.UUID) {
m.task = &u
}
// TaskID returns the value of the "task_id" field in the mutation.
func (m *ProjectTaskMutation) TaskID() (r uuid.UUID, exists bool) {
v := m.task
if v == nil {
return
}
return *v, true
}
// OldTaskID returns the old "task_id" field's value of the ProjectTask entity.
// If the ProjectTask 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 *ProjectTaskMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTaskID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
}
return oldValue.TaskID, nil
}
// ResetTaskID resets all changes to the "task_id" field.
func (m *ProjectTaskMutation) ResetTaskID() {
m.task = nil
}
// SetModelID sets the "model_id" field.
func (m *ProjectTaskMutation) SetModelID(u uuid.UUID) {
m.model = &u
}
// ModelID returns the value of the "model_id" field in the mutation.
func (m *ProjectTaskMutation) ModelID() (r uuid.UUID, exists bool) {
v := m.model
if v == nil {
return
}
return *v, true
}
// OldModelID returns the old "model_id" field's value of the ProjectTask entity.
// If the ProjectTask 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 *ProjectTaskMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldModelID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldModelID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldModelID: %w", err)
}
return oldValue.ModelID, nil
}
// ResetModelID resets all changes to the "model_id" field.
func (m *ProjectTaskMutation) ResetModelID() {
m.model = nil
}
// SetImageID sets the "image_id" field.
func (m *ProjectTaskMutation) SetImageID(u uuid.UUID) {
m.image = &u
}
// ImageID returns the value of the "image_id" field in the mutation.
func (m *ProjectTaskMutation) ImageID() (r uuid.UUID, exists bool) {
v := m.image
if v == nil {
return
}
return *v, true
}
// OldImageID returns the old "image_id" field's value of the ProjectTask entity.
// If the ProjectTask 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 *ProjectTaskMutation) OldImageID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldImageID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldImageID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldImageID: %w", err)
}
return oldValue.ImageID, nil
}
// ResetImageID resets all changes to the "image_id" field.
func (m *ProjectTaskMutation) ResetImageID() {
m.image = nil
}
// SetGitIdentityID sets the "git_identity_id" field.
func (m *ProjectTaskMutation) SetGitIdentityID(u uuid.UUID) {
m.git_identity = &u
}
// GitIdentityID returns the value of the "git_identity_id" field in the mutation.
func (m *ProjectTaskMutation) GitIdentityID() (r uuid.UUID, exists bool) {
v := m.git_identity
if v == nil {
return
}
return *v, true
}
// OldGitIdentityID returns the old "git_identity_id" field's value of the ProjectTask entity.
// If the ProjectTask 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 *ProjectTaskMutation) OldGitIdentityID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGitIdentityID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGitIdentityID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGitIdentityID: %w", err)
}
return oldValue.GitIdentityID, nil
}
// ClearGitIdentityID clears the value of the "git_identity_id" field.
func (m *ProjectTaskMutation) ClearGitIdentityID() {
m.git_identity = nil
m.clearedFields[projecttask.FieldGitIdentityID] = struct{}{}
}
// GitIdentityIDCleared returns if the "git_identity_id" field was cleared in this mutation.
func (m *ProjectTaskMutation) GitIdentityIDCleared() bool {
_, ok := m.clearedFields[projecttask.FieldGitIdentityID]
return ok
}
// ResetGitIdentityID resets all changes to the "git_identity_id" field.
func (m *ProjectTaskMutation) ResetGitIdentityID() {
m.git_identity = nil
delete(m.clearedFields, projecttask.FieldGitIdentityID)
}
// SetProjectID sets the "project_id" field.
func (m *ProjectTaskMutation) SetProjectID(u uuid.UUID) {
m.project = &u
}
// ProjectID returns the value of the "project_id" field in the mutation.
func (m *ProjectTaskMutation) ProjectID() (r uuid.UUID, exists bool) {
v := m.project
if v == nil {
return
}
return *v, true
}
// OldProjectID returns the old "project_id" field's value of the ProjectTask entity.
// If the ProjectTask 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 *ProjectTaskMutation) OldProjectID(ctx context.Context) (v *uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldProjectID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldProjectID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldProjectID: %w", err)
}
return oldValue.ProjectID, nil
}
// ClearProjectID clears the value of the "project_id" field.
func (m *ProjectTaskMutation) ClearProjectID() {
m.project = nil
m.clearedFields[projecttask.FieldProjectID] = struct{}{}
}
// ProjectIDCleared returns if the "project_id" field was cleared in this mutation.
func (m *ProjectTaskMutation) ProjectIDCleared() bool {
_, ok := m.clearedFields[projecttask.FieldProjectID]
return ok
}
// ResetProjectID resets all changes to the "project_id" field.
func (m *ProjectTaskMutation) ResetProjectID() {
m.project = nil
delete(m.clearedFields, projecttask.FieldProjectID)
}
// SetIssueID sets the "issue_id" field.
func (m *ProjectTaskMutation) SetIssueID(u uuid.UUID) {
m.issue = &u
}
// IssueID returns the value of the "issue_id" field in the mutation.
func (m *ProjectTaskMutation) IssueID() (r uuid.UUID, exists bool) {
v := m.issue
if v == nil {
return
}
return *v, true
}
// OldIssueID returns the old "issue_id" field's value of the ProjectTask entity.
// If the ProjectTask 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 *ProjectTaskMutation) OldIssueID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldIssueID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldIssueID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIssueID: %w", err)
}
return oldValue.IssueID, nil
}
// ClearIssueID clears the value of the "issue_id" field.
func (m *ProjectTaskMutation) ClearIssueID() {
m.issue = nil
m.clearedFields[projecttask.FieldIssueID] = struct{}{}
}
// IssueIDCleared returns if the "issue_id" field was cleared in this mutation.
func (m *ProjectTaskMutation) IssueIDCleared() bool {
_, ok := m.clearedFields[projecttask.FieldIssueID]
return ok
}
// ResetIssueID resets all changes to the "issue_id" field.
func (m *ProjectTaskMutation) ResetIssueID() {
m.issue = nil
delete(m.clearedFields, projecttask.FieldIssueID)
}
// SetRepoURL sets the "repo_url" field.
func (m *ProjectTaskMutation) SetRepoURL(s string) {
m.repo_url = &s
}
// RepoURL returns the value of the "repo_url" field in the mutation.
func (m *ProjectTaskMutation) RepoURL() (r string, exists bool) {
v := m.repo_url
if v == nil {
return
}
return *v, true
}
// OldRepoURL returns the old "repo_url" field's value of the ProjectTask entity.
// If the ProjectTask 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 *ProjectTaskMutation) OldRepoURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRepoURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRepoURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRepoURL: %w", err)
}
return oldValue.RepoURL, nil
}
// ClearRepoURL clears the value of the "repo_url" field.
func (m *ProjectTaskMutation) ClearRepoURL() {
m.repo_url = nil
m.clearedFields[projecttask.FieldRepoURL] = struct{}{}
}
// RepoURLCleared returns if the "repo_url" field was cleared in this mutation.
func (m *ProjectTaskMutation) RepoURLCleared() bool {
_, ok := m.clearedFields[projecttask.FieldRepoURL]
return ok
}
// ResetRepoURL resets all changes to the "repo_url" field.
func (m *ProjectTaskMutation) ResetRepoURL() {
m.repo_url = nil
delete(m.clearedFields, projecttask.FieldRepoURL)
}
// SetRepoFilename sets the "repo_filename" field.
func (m *ProjectTaskMutation) SetRepoFilename(s string) {
m.repo_filename = &s
}
// RepoFilename returns the value of the "repo_filename" field in the mutation.
func (m *ProjectTaskMutation) RepoFilename() (r string, exists bool) {
v := m.repo_filename
if v == nil {
return
}
return *v, true
}
// OldRepoFilename returns the old "repo_filename" field's value of the ProjectTask entity.
// If the ProjectTask 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 *ProjectTaskMutation) OldRepoFilename(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRepoFilename is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRepoFilename requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRepoFilename: %w", err)
}
return oldValue.RepoFilename, nil
}
// ClearRepoFilename clears the value of the "repo_filename" field.
func (m *ProjectTaskMutation) ClearRepoFilename() {
m.repo_filename = nil
m.clearedFields[projecttask.FieldRepoFilename] = struct{}{}
}
// RepoFilenameCleared returns if the "repo_filename" field was cleared in this mutation.
func (m *ProjectTaskMutation) RepoFilenameCleared() bool {
_, ok := m.clearedFields[projecttask.FieldRepoFilename]
return ok
}
// ResetRepoFilename resets all changes to the "repo_filename" field.
func (m *ProjectTaskMutation) ResetRepoFilename() {
m.repo_filename = nil
delete(m.clearedFields, projecttask.FieldRepoFilename)
}
// SetBranch sets the "branch" field.
func (m *ProjectTaskMutation) SetBranch(s string) {
m.branch = &s
}
// Branch returns the value of the "branch" field in the mutation.
func (m *ProjectTaskMutation) Branch() (r string, exists bool) {
v := m.branch
if v == nil {
return
}
return *v, true
}
// OldBranch returns the old "branch" field's value of the ProjectTask entity.
// If the ProjectTask 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 *ProjectTaskMutation) OldBranch(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldBranch is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldBranch requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBranch: %w", err)
}
return oldValue.Branch, nil
}
// ClearBranch clears the value of the "branch" field.
func (m *ProjectTaskMutation) ClearBranch() {
m.branch = nil
m.clearedFields[projecttask.FieldBranch] = struct{}{}
}
// BranchCleared returns if the "branch" field was cleared in this mutation.
func (m *ProjectTaskMutation) BranchCleared() bool {
_, ok := m.clearedFields[projecttask.FieldBranch]
return ok
}
// ResetBranch resets all changes to the "branch" field.
func (m *ProjectTaskMutation) ResetBranch() {
m.branch = nil
delete(m.clearedFields, projecttask.FieldBranch)
}
// SetCliName sets the "cli_name" field.
func (m *ProjectTaskMutation) SetCliName(cn consts.CliName) {
m.cli_name = &cn
}
// CliName returns the value of the "cli_name" field in the mutation.
func (m *ProjectTaskMutation) CliName() (r consts.CliName, exists bool) {
v := m.cli_name
if v == nil {
return
}
return *v, true
}
// OldCliName returns the old "cli_name" field's value of the ProjectTask entity.
// If the ProjectTask 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 *ProjectTaskMutation) OldCliName(ctx context.Context) (v consts.CliName, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCliName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCliName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCliName: %w", err)
}
return oldValue.CliName, nil
}
// ResetCliName resets all changes to the "cli_name" field.
func (m *ProjectTaskMutation) ResetCliName() {
m.cli_name = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *ProjectTaskMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ProjectTaskMutation) 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 ProjectTask entity.
// If the ProjectTask 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 *ProjectTaskMutation) 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 *ProjectTaskMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearTask clears the "task" edge to the Task entity.
func (m *ProjectTaskMutation) ClearTask() {
m.clearedtask = true
m.clearedFields[projecttask.FieldTaskID] = struct{}{}
}
// TaskCleared reports if the "task" edge to the Task entity was cleared.
func (m *ProjectTaskMutation) TaskCleared() bool {
return m.clearedtask
}
// TaskIDs returns the "task" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// TaskID instead. It exists only for internal usage by the builders.
func (m *ProjectTaskMutation) TaskIDs() (ids []uuid.UUID) {
if id := m.task; id != nil {
ids = append(ids, *id)
}
return
}
// ResetTask resets all changes to the "task" edge.
func (m *ProjectTaskMutation) ResetTask() {
m.task = nil
m.clearedtask = false
}
// ClearModel clears the "model" edge to the Model entity.
func (m *ProjectTaskMutation) ClearModel() {
m.clearedmodel = true
m.clearedFields[projecttask.FieldModelID] = struct{}{}
}
// ModelCleared reports if the "model" edge to the Model entity was cleared.
func (m *ProjectTaskMutation) ModelCleared() bool {
return m.clearedmodel
}
// ModelIDs returns the "model" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ModelID instead. It exists only for internal usage by the builders.
func (m *ProjectTaskMutation) ModelIDs() (ids []uuid.UUID) {
if id := m.model; id != nil {
ids = append(ids, *id)
}
return
}
// ResetModel resets all changes to the "model" edge.
func (m *ProjectTaskMutation) ResetModel() {
m.model = nil
m.clearedmodel = false
}
// ClearImage clears the "image" edge to the Image entity.
func (m *ProjectTaskMutation) ClearImage() {
m.clearedimage = true
m.clearedFields[projecttask.FieldImageID] = struct{}{}
}
// ImageCleared reports if the "image" edge to the Image entity was cleared.
func (m *ProjectTaskMutation) ImageCleared() bool {
return m.clearedimage
}
// ImageIDs returns the "image" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ImageID instead. It exists only for internal usage by the builders.
func (m *ProjectTaskMutation) ImageIDs() (ids []uuid.UUID) {
if id := m.image; id != nil {
ids = append(ids, *id)
}
return
}
// ResetImage resets all changes to the "image" edge.
func (m *ProjectTaskMutation) ResetImage() {
m.image = nil
m.clearedimage = false
}
// ClearGitIdentity clears the "git_identity" edge to the GitIdentity entity.
func (m *ProjectTaskMutation) ClearGitIdentity() {
m.clearedgit_identity = true
m.clearedFields[projecttask.FieldGitIdentityID] = struct{}{}
}
// GitIdentityCleared reports if the "git_identity" edge to the GitIdentity entity was cleared.
func (m *ProjectTaskMutation) GitIdentityCleared() bool {
return m.GitIdentityIDCleared() || m.clearedgit_identity
}
// GitIdentityIDs returns the "git_identity" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// GitIdentityID instead. It exists only for internal usage by the builders.
func (m *ProjectTaskMutation) GitIdentityIDs() (ids []uuid.UUID) {
if id := m.git_identity; id != nil {
ids = append(ids, *id)
}
return
}
// ResetGitIdentity resets all changes to the "git_identity" edge.
func (m *ProjectTaskMutation) ResetGitIdentity() {
m.git_identity = nil
m.clearedgit_identity = false
}
// ClearProject clears the "project" edge to the Project entity.
func (m *ProjectTaskMutation) ClearProject() {
m.clearedproject = true
m.clearedFields[projecttask.FieldProjectID] = struct{}{}
}
// ProjectCleared reports if the "project" edge to the Project entity was cleared.
func (m *ProjectTaskMutation) ProjectCleared() bool {
return m.ProjectIDCleared() || m.clearedproject
}
// ProjectIDs returns the "project" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ProjectID instead. It exists only for internal usage by the builders.
func (m *ProjectTaskMutation) ProjectIDs() (ids []uuid.UUID) {
if id := m.project; id != nil {
ids = append(ids, *id)
}
return
}
// ResetProject resets all changes to the "project" edge.
func (m *ProjectTaskMutation) ResetProject() {
m.project = nil
m.clearedproject = false
}
// ClearIssue clears the "issue" edge to the ProjectIssue entity.
func (m *ProjectTaskMutation) ClearIssue() {
m.clearedissue = true
m.clearedFields[projecttask.FieldIssueID] = struct{}{}
}
// IssueCleared reports if the "issue" edge to the ProjectIssue entity was cleared.
func (m *ProjectTaskMutation) IssueCleared() bool {
return m.IssueIDCleared() || m.clearedissue
}
// IssueIDs returns the "issue" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// IssueID instead. It exists only for internal usage by the builders.
func (m *ProjectTaskMutation) IssueIDs() (ids []uuid.UUID) {
if id := m.issue; id != nil {
ids = append(ids, *id)
}
return
}
// ResetIssue resets all changes to the "issue" edge.
func (m *ProjectTaskMutation) ResetIssue() {
m.issue = nil
m.clearedissue = false
}
// Where appends a list predicates to the ProjectTaskMutation builder.
func (m *ProjectTaskMutation) Where(ps ...predicate.ProjectTask) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ProjectTaskMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ProjectTaskMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.ProjectTask, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ProjectTaskMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ProjectTaskMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (ProjectTask).
func (m *ProjectTaskMutation) 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 *ProjectTaskMutation) Fields() []string {
fields := make([]string, 0, 11)
if m.task != nil {
fields = append(fields, projecttask.FieldTaskID)
}
if m.model != nil {
fields = append(fields, projecttask.FieldModelID)
}
if m.image != nil {
fields = append(fields, projecttask.FieldImageID)
}
if m.git_identity != nil {
fields = append(fields, projecttask.FieldGitIdentityID)
}
if m.project != nil {
fields = append(fields, projecttask.FieldProjectID)
}
if m.issue != nil {
fields = append(fields, projecttask.FieldIssueID)
}
if m.repo_url != nil {
fields = append(fields, projecttask.FieldRepoURL)
}
if m.repo_filename != nil {
fields = append(fields, projecttask.FieldRepoFilename)
}
if m.branch != nil {
fields = append(fields, projecttask.FieldBranch)
}
if m.cli_name != nil {
fields = append(fields, projecttask.FieldCliName)
}
if m.created_at != nil {
fields = append(fields, projecttask.FieldCreatedAt)
}
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 *ProjectTaskMutation) Field(name string) (ent.Value, bool) {
switch name {
case projecttask.FieldTaskID:
return m.TaskID()
case projecttask.FieldModelID:
return m.ModelID()
case projecttask.FieldImageID:
return m.ImageID()
case projecttask.FieldGitIdentityID:
return m.GitIdentityID()
case projecttask.FieldProjectID:
return m.ProjectID()
case projecttask.FieldIssueID:
return m.IssueID()
case projecttask.FieldRepoURL:
return m.RepoURL()
case projecttask.FieldRepoFilename:
return m.RepoFilename()
case projecttask.FieldBranch:
return m.Branch()
case projecttask.FieldCliName:
return m.CliName()
case projecttask.FieldCreatedAt:
return m.CreatedAt()
}
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 *ProjectTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case projecttask.FieldTaskID:
return m.OldTaskID(ctx)
case projecttask.FieldModelID:
return m.OldModelID(ctx)
case projecttask.FieldImageID:
return m.OldImageID(ctx)
case projecttask.FieldGitIdentityID:
return m.OldGitIdentityID(ctx)
case projecttask.FieldProjectID:
return m.OldProjectID(ctx)
case projecttask.FieldIssueID:
return m.OldIssueID(ctx)
case projecttask.FieldRepoURL:
return m.OldRepoURL(ctx)
case projecttask.FieldRepoFilename:
return m.OldRepoFilename(ctx)
case projecttask.FieldBranch:
return m.OldBranch(ctx)
case projecttask.FieldCliName:
return m.OldCliName(ctx)
case projecttask.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown ProjectTask 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 *ProjectTaskMutation) SetField(name string, value ent.Value) error {
switch name {
case projecttask.FieldTaskID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTaskID(v)
return nil
case projecttask.FieldModelID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetModelID(v)
return nil
case projecttask.FieldImageID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetImageID(v)
return nil
case projecttask.FieldGitIdentityID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGitIdentityID(v)
return nil
case projecttask.FieldProjectID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetProjectID(v)
return nil
case projecttask.FieldIssueID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetIssueID(v)
return nil
case projecttask.FieldRepoURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRepoURL(v)
return nil
case projecttask.FieldRepoFilename:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRepoFilename(v)
return nil
case projecttask.FieldBranch:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetBranch(v)
return nil
case projecttask.FieldCliName:
v, ok := value.(consts.CliName)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCliName(v)
return nil
case projecttask.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown ProjectTask field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ProjectTaskMutation) AddedFields() []string {
return nil
}
// 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 *ProjectTaskMutation) AddedField(name string) (ent.Value, bool) {
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 *ProjectTaskMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown ProjectTask numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ProjectTaskMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(projecttask.FieldGitIdentityID) {
fields = append(fields, projecttask.FieldGitIdentityID)
}
if m.FieldCleared(projecttask.FieldProjectID) {
fields = append(fields, projecttask.FieldProjectID)
}
if m.FieldCleared(projecttask.FieldIssueID) {
fields = append(fields, projecttask.FieldIssueID)
}
if m.FieldCleared(projecttask.FieldRepoURL) {
fields = append(fields, projecttask.FieldRepoURL)
}
if m.FieldCleared(projecttask.FieldRepoFilename) {
fields = append(fields, projecttask.FieldRepoFilename)
}
if m.FieldCleared(projecttask.FieldBranch) {
fields = append(fields, projecttask.FieldBranch)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ProjectTaskMutation) 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 *ProjectTaskMutation) ClearField(name string) error {
switch name {
case projecttask.FieldGitIdentityID:
m.ClearGitIdentityID()
return nil
case projecttask.FieldProjectID:
m.ClearProjectID()
return nil
case projecttask.FieldIssueID:
m.ClearIssueID()
return nil
case projecttask.FieldRepoURL:
m.ClearRepoURL()
return nil
case projecttask.FieldRepoFilename:
m.ClearRepoFilename()
return nil
case projecttask.FieldBranch:
m.ClearBranch()
return nil
}
return fmt.Errorf("unknown ProjectTask 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 *ProjectTaskMutation) ResetField(name string) error {
switch name {
case projecttask.FieldTaskID:
m.ResetTaskID()
return nil
case projecttask.FieldModelID:
m.ResetModelID()
return nil
case projecttask.FieldImageID:
m.ResetImageID()
return nil
case projecttask.FieldGitIdentityID:
m.ResetGitIdentityID()
return nil
case projecttask.FieldProjectID:
m.ResetProjectID()
return nil
case projecttask.FieldIssueID:
m.ResetIssueID()
return nil
case projecttask.FieldRepoURL:
m.ResetRepoURL()
return nil
case projecttask.FieldRepoFilename:
m.ResetRepoFilename()
return nil
case projecttask.FieldBranch:
m.ResetBranch()
return nil
case projecttask.FieldCliName:
m.ResetCliName()
return nil
case projecttask.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown ProjectTask field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ProjectTaskMutation) AddedEdges() []string {
edges := make([]string, 0, 6)
if m.task != nil {
edges = append(edges, projecttask.EdgeTask)
}
if m.model != nil {
edges = append(edges, projecttask.EdgeModel)
}
if m.image != nil {
edges = append(edges, projecttask.EdgeImage)
}
if m.git_identity != nil {
edges = append(edges, projecttask.EdgeGitIdentity)
}
if m.project != nil {
edges = append(edges, projecttask.EdgeProject)
}
if m.issue != nil {
edges = append(edges, projecttask.EdgeIssue)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ProjectTaskMutation) AddedIDs(name string) []ent.Value {
switch name {
case projecttask.EdgeTask:
if id := m.task; id != nil {
return []ent.Value{*id}
}
case projecttask.EdgeModel:
if id := m.model; id != nil {
return []ent.Value{*id}
}
case projecttask.EdgeImage:
if id := m.image; id != nil {
return []ent.Value{*id}
}
case projecttask.EdgeGitIdentity:
if id := m.git_identity; id != nil {
return []ent.Value{*id}
}
case projecttask.EdgeProject:
if id := m.project; id != nil {
return []ent.Value{*id}
}
case projecttask.EdgeIssue:
if id := m.issue; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ProjectTaskMutation) RemovedEdges() []string {
edges := make([]string, 0, 6)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ProjectTaskMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ProjectTaskMutation) ClearedEdges() []string {
edges := make([]string, 0, 6)
if m.clearedtask {
edges = append(edges, projecttask.EdgeTask)
}
if m.clearedmodel {
edges = append(edges, projecttask.EdgeModel)
}
if m.clearedimage {
edges = append(edges, projecttask.EdgeImage)
}
if m.clearedgit_identity {
edges = append(edges, projecttask.EdgeGitIdentity)
}
if m.clearedproject {
edges = append(edges, projecttask.EdgeProject)
}
if m.clearedissue {
edges = append(edges, projecttask.EdgeIssue)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ProjectTaskMutation) EdgeCleared(name string) bool {
switch name {
case projecttask.EdgeTask:
return m.clearedtask
case projecttask.EdgeModel:
return m.clearedmodel
case projecttask.EdgeImage:
return m.clearedimage
case projecttask.EdgeGitIdentity:
return m.clearedgit_identity
case projecttask.EdgeProject:
return m.clearedproject
case projecttask.EdgeIssue:
return m.clearedissue
}
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 *ProjectTaskMutation) ClearEdge(name string) error {
switch name {
case projecttask.EdgeTask:
m.ClearTask()
return nil
case projecttask.EdgeModel:
m.ClearModel()
return nil
case projecttask.EdgeImage:
m.ClearImage()
return nil
case projecttask.EdgeGitIdentity:
m.ClearGitIdentity()
return nil
case projecttask.EdgeProject:
m.ClearProject()
return nil
case projecttask.EdgeIssue:
m.ClearIssue()
return nil
}
return fmt.Errorf("unknown ProjectTask 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 *ProjectTaskMutation) ResetEdge(name string) error {
switch name {
case projecttask.EdgeTask:
m.ResetTask()
return nil
case projecttask.EdgeModel:
m.ResetModel()
return nil
case projecttask.EdgeImage:
m.ResetImage()
return nil
case projecttask.EdgeGitIdentity:
m.ResetGitIdentity()
return nil
case projecttask.EdgeProject:
m.ResetProject()
return nil
case projecttask.EdgeIssue:
m.ResetIssue()
return nil
}
return fmt.Errorf("unknown ProjectTask edge %s", name)
}
// TaskMutation represents an operation that mutates the Task nodes in the graph.
type TaskMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
kind *consts.TaskType
sub_type *consts.TaskSubType
content *string
title *string
summary *string
status *consts.TaskStatus
log_store *consts.LogStore
created_at *time.Time
last_active_at *time.Time
updated_at *time.Time
completed_at *time.Time
clearedFields map[string]struct{}
project_tasks map[uuid.UUID]struct{}
removedproject_tasks map[uuid.UUID]struct{}
clearedproject_tasks bool
git_tasks *uuid.UUID
clearedgit_tasks bool
user *uuid.UUID
cleareduser bool
vms map[string]struct{}
removedvms map[string]struct{}
clearedvms bool
git_bot_tasks map[uuid.UUID]struct{}
removedgit_bot_tasks map[uuid.UUID]struct{}
clearedgit_bot_tasks bool
model_switches map[uuid.UUID]struct{}
removedmodel_switches map[uuid.UUID]struct{}
clearedmodel_switches bool
task_vms map[uuid.UUID]struct{}
removedtask_vms map[uuid.UUID]struct{}
clearedtask_vms bool
done bool
oldValue func(context.Context) (*Task, error)
predicates []predicate.Task
}
var _ ent.Mutation = (*TaskMutation)(nil)
// taskOption allows management of the mutation configuration using functional options.
type taskOption func(*TaskMutation)
// newTaskMutation creates new mutation for the Task entity.
func newTaskMutation(c config, op Op, opts ...taskOption) *TaskMutation {
m := &TaskMutation{
config: c,
op: op,
typ: TypeTask,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTaskID sets the ID field of the mutation.
func withTaskID(id uuid.UUID) taskOption {
return func(m *TaskMutation) {
var (
err error
once sync.Once
value *Task
)
m.oldValue = func(ctx context.Context) (*Task, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Task.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTask sets the old Task of the mutation.
func withTask(node *Task) taskOption {
return func(m *TaskMutation) {
m.oldValue = func(context.Context) (*Task, 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 TaskMutation) 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 TaskMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 Task entities.
func (m *TaskMutation) SetID(id uuid.UUID) {
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 *TaskMutation) ID() (id uuid.UUID, 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 *TaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().Task.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *TaskMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *TaskMutation) 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 Task entity.
// If the Task 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 *TaskMutation) 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 *TaskMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[task.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *TaskMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[task.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *TaskMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, task.FieldDeletedAt)
}
// SetUserID sets the "user_id" field.
func (m *TaskMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *TaskMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *TaskMutation) ResetUserID() {
m.user = nil
}
// SetKind sets the "kind" field.
func (m *TaskMutation) SetKind(ct consts.TaskType) {
m.kind = &ct
}
// Kind returns the value of the "kind" field in the mutation.
func (m *TaskMutation) Kind() (r consts.TaskType, exists bool) {
v := m.kind
if v == nil {
return
}
return *v, true
}
// OldKind returns the old "kind" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldKind(ctx context.Context) (v consts.TaskType, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldKind is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldKind requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldKind: %w", err)
}
return oldValue.Kind, nil
}
// ResetKind resets all changes to the "kind" field.
func (m *TaskMutation) ResetKind() {
m.kind = nil
}
// SetSubType sets the "sub_type" field.
func (m *TaskMutation) SetSubType(cst consts.TaskSubType) {
m.sub_type = &cst
}
// SubType returns the value of the "sub_type" field in the mutation.
func (m *TaskMutation) SubType() (r consts.TaskSubType, exists bool) {
v := m.sub_type
if v == nil {
return
}
return *v, true
}
// OldSubType returns the old "sub_type" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldSubType(ctx context.Context) (v consts.TaskSubType, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSubType is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSubType requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSubType: %w", err)
}
return oldValue.SubType, nil
}
// ClearSubType clears the value of the "sub_type" field.
func (m *TaskMutation) ClearSubType() {
m.sub_type = nil
m.clearedFields[task.FieldSubType] = struct{}{}
}
// SubTypeCleared returns if the "sub_type" field was cleared in this mutation.
func (m *TaskMutation) SubTypeCleared() bool {
_, ok := m.clearedFields[task.FieldSubType]
return ok
}
// ResetSubType resets all changes to the "sub_type" field.
func (m *TaskMutation) ResetSubType() {
m.sub_type = nil
delete(m.clearedFields, task.FieldSubType)
}
// SetContent sets the "content" field.
func (m *TaskMutation) SetContent(s string) {
m.content = &s
}
// Content returns the value of the "content" field in the mutation.
func (m *TaskMutation) Content() (r string, exists bool) {
v := m.content
if v == nil {
return
}
return *v, true
}
// OldContent returns the old "content" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldContent(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldContent is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldContent requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldContent: %w", err)
}
return oldValue.Content, nil
}
// ResetContent resets all changes to the "content" field.
func (m *TaskMutation) ResetContent() {
m.content = nil
}
// SetTitle sets the "title" field.
func (m *TaskMutation) SetTitle(s string) {
m.title = &s
}
// Title returns the value of the "title" field in the mutation.
func (m *TaskMutation) 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 Task entity.
// If the Task 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 *TaskMutation) 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 *TaskMutation) ClearTitle() {
m.title = nil
m.clearedFields[task.FieldTitle] = struct{}{}
}
// TitleCleared returns if the "title" field was cleared in this mutation.
func (m *TaskMutation) TitleCleared() bool {
_, ok := m.clearedFields[task.FieldTitle]
return ok
}
// ResetTitle resets all changes to the "title" field.
func (m *TaskMutation) ResetTitle() {
m.title = nil
delete(m.clearedFields, task.FieldTitle)
}
// SetSummary sets the "summary" field.
func (m *TaskMutation) SetSummary(s string) {
m.summary = &s
}
// Summary returns the value of the "summary" field in the mutation.
func (m *TaskMutation) Summary() (r string, exists bool) {
v := m.summary
if v == nil {
return
}
return *v, true
}
// OldSummary returns the old "summary" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldSummary(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSummary is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSummary requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSummary: %w", err)
}
return oldValue.Summary, nil
}
// ClearSummary clears the value of the "summary" field.
func (m *TaskMutation) ClearSummary() {
m.summary = nil
m.clearedFields[task.FieldSummary] = struct{}{}
}
// SummaryCleared returns if the "summary" field was cleared in this mutation.
func (m *TaskMutation) SummaryCleared() bool {
_, ok := m.clearedFields[task.FieldSummary]
return ok
}
// ResetSummary resets all changes to the "summary" field.
func (m *TaskMutation) ResetSummary() {
m.summary = nil
delete(m.clearedFields, task.FieldSummary)
}
// SetStatus sets the "status" field.
func (m *TaskMutation) SetStatus(cs consts.TaskStatus) {
m.status = &cs
}
// Status returns the value of the "status" field in the mutation.
func (m *TaskMutation) Status() (r consts.TaskStatus, exists bool) {
v := m.status
if v == nil {
return
}
return *v, true
}
// OldStatus returns the old "status" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldStatus(ctx context.Context) (v consts.TaskStatus, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldStatus is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldStatus requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStatus: %w", err)
}
return oldValue.Status, nil
}
// ResetStatus resets all changes to the "status" field.
func (m *TaskMutation) ResetStatus() {
m.status = nil
}
// SetLogStore sets the "log_store" field.
func (m *TaskMutation) SetLogStore(cs consts.LogStore) {
m.log_store = &cs
}
// LogStore returns the value of the "log_store" field in the mutation.
func (m *TaskMutation) LogStore() (r consts.LogStore, exists bool) {
v := m.log_store
if v == nil {
return
}
return *v, true
}
// OldLogStore returns the old "log_store" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldLogStore(ctx context.Context) (v *consts.LogStore, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldLogStore is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldLogStore requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLogStore: %w", err)
}
return oldValue.LogStore, nil
}
// ClearLogStore clears the value of the "log_store" field.
func (m *TaskMutation) ClearLogStore() {
m.log_store = nil
m.clearedFields[task.FieldLogStore] = struct{}{}
}
// LogStoreCleared returns if the "log_store" field was cleared in this mutation.
func (m *TaskMutation) LogStoreCleared() bool {
_, ok := m.clearedFields[task.FieldLogStore]
return ok
}
// ResetLogStore resets all changes to the "log_store" field.
func (m *TaskMutation) ResetLogStore() {
m.log_store = nil
delete(m.clearedFields, task.FieldLogStore)
}
// SetCreatedAt sets the "created_at" field.
func (m *TaskMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TaskMutation) 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 Task entity.
// If the Task 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 *TaskMutation) 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 *TaskMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetLastActiveAt sets the "last_active_at" field.
func (m *TaskMutation) SetLastActiveAt(t time.Time) {
m.last_active_at = &t
}
// LastActiveAt returns the value of the "last_active_at" field in the mutation.
func (m *TaskMutation) LastActiveAt() (r time.Time, exists bool) {
v := m.last_active_at
if v == nil {
return
}
return *v, true
}
// OldLastActiveAt returns the old "last_active_at" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldLastActiveAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldLastActiveAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldLastActiveAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLastActiveAt: %w", err)
}
return oldValue.LastActiveAt, nil
}
// ResetLastActiveAt resets all changes to the "last_active_at" field.
func (m *TaskMutation) ResetLastActiveAt() {
m.last_active_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *TaskMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *TaskMutation) 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 Task entity.
// If the Task 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 *TaskMutation) 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 *TaskMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// SetCompletedAt sets the "completed_at" field.
func (m *TaskMutation) SetCompletedAt(t time.Time) {
m.completed_at = &t
}
// CompletedAt returns the value of the "completed_at" field in the mutation.
func (m *TaskMutation) CompletedAt() (r time.Time, exists bool) {
v := m.completed_at
if v == nil {
return
}
return *v, true
}
// OldCompletedAt returns the old "completed_at" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldCompletedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCompletedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCompletedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCompletedAt: %w", err)
}
return oldValue.CompletedAt, nil
}
// ClearCompletedAt clears the value of the "completed_at" field.
func (m *TaskMutation) ClearCompletedAt() {
m.completed_at = nil
m.clearedFields[task.FieldCompletedAt] = struct{}{}
}
// CompletedAtCleared returns if the "completed_at" field was cleared in this mutation.
func (m *TaskMutation) CompletedAtCleared() bool {
_, ok := m.clearedFields[task.FieldCompletedAt]
return ok
}
// ResetCompletedAt resets all changes to the "completed_at" field.
func (m *TaskMutation) ResetCompletedAt() {
m.completed_at = nil
delete(m.clearedFields, task.FieldCompletedAt)
}
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids.
func (m *TaskMutation) AddProjectTaskIDs(ids ...uuid.UUID) {
if m.project_tasks == nil {
m.project_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.project_tasks[ids[i]] = struct{}{}
}
}
// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity.
func (m *TaskMutation) ClearProjectTasks() {
m.clearedproject_tasks = true
}
// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared.
func (m *TaskMutation) ProjectTasksCleared() bool {
return m.clearedproject_tasks
}
// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs.
func (m *TaskMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) {
if m.removedproject_tasks == nil {
m.removedproject_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.project_tasks, ids[i])
m.removedproject_tasks[ids[i]] = struct{}{}
}
}
// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity.
func (m *TaskMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return
}
// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation.
func (m *TaskMutation) ProjectTasksIDs() (ids []uuid.UUID) {
for id := range m.project_tasks {
ids = append(ids, id)
}
return
}
// ResetProjectTasks resets all changes to the "project_tasks" edge.
func (m *TaskMutation) ResetProjectTasks() {
m.project_tasks = nil
m.clearedproject_tasks = false
m.removedproject_tasks = nil
}
// SetGitTasksID sets the "git_tasks" edge to the GitTask entity by id.
func (m *TaskMutation) SetGitTasksID(id uuid.UUID) {
m.git_tasks = &id
}
// ClearGitTasks clears the "git_tasks" edge to the GitTask entity.
func (m *TaskMutation) ClearGitTasks() {
m.clearedgit_tasks = true
}
// GitTasksCleared reports if the "git_tasks" edge to the GitTask entity was cleared.
func (m *TaskMutation) GitTasksCleared() bool {
return m.clearedgit_tasks
}
// GitTasksID returns the "git_tasks" edge ID in the mutation.
func (m *TaskMutation) GitTasksID() (id uuid.UUID, exists bool) {
if m.git_tasks != nil {
return *m.git_tasks, true
}
return
}
// GitTasksIDs returns the "git_tasks" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// GitTasksID instead. It exists only for internal usage by the builders.
func (m *TaskMutation) GitTasksIDs() (ids []uuid.UUID) {
if id := m.git_tasks; id != nil {
ids = append(ids, *id)
}
return
}
// ResetGitTasks resets all changes to the "git_tasks" edge.
func (m *TaskMutation) ResetGitTasks() {
m.git_tasks = nil
m.clearedgit_tasks = false
}
// ClearUser clears the "user" edge to the User entity.
func (m *TaskMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[task.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *TaskMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *TaskMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *TaskMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by ids.
func (m *TaskMutation) AddVMIDs(ids ...string) {
if m.vms == nil {
m.vms = make(map[string]struct{})
}
for i := range ids {
m.vms[ids[i]] = struct{}{}
}
}
// ClearVms clears the "vms" edge to the VirtualMachine entity.
func (m *TaskMutation) ClearVms() {
m.clearedvms = true
}
// VmsCleared reports if the "vms" edge to the VirtualMachine entity was cleared.
func (m *TaskMutation) VmsCleared() bool {
return m.clearedvms
}
// RemoveVMIDs removes the "vms" edge to the VirtualMachine entity by IDs.
func (m *TaskMutation) RemoveVMIDs(ids ...string) {
if m.removedvms == nil {
m.removedvms = make(map[string]struct{})
}
for i := range ids {
delete(m.vms, ids[i])
m.removedvms[ids[i]] = struct{}{}
}
}
// RemovedVms returns the removed IDs of the "vms" edge to the VirtualMachine entity.
func (m *TaskMutation) RemovedVmsIDs() (ids []string) {
for id := range m.removedvms {
ids = append(ids, id)
}
return
}
// VmsIDs returns the "vms" edge IDs in the mutation.
func (m *TaskMutation) VmsIDs() (ids []string) {
for id := range m.vms {
ids = append(ids, id)
}
return
}
// ResetVms resets all changes to the "vms" edge.
func (m *TaskMutation) ResetVms() {
m.vms = nil
m.clearedvms = false
m.removedvms = nil
}
// AddGitBotTaskIDs adds the "git_bot_tasks" edge to the GitBotTask entity by ids.
func (m *TaskMutation) AddGitBotTaskIDs(ids ...uuid.UUID) {
if m.git_bot_tasks == nil {
m.git_bot_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.git_bot_tasks[ids[i]] = struct{}{}
}
}
// ClearGitBotTasks clears the "git_bot_tasks" edge to the GitBotTask entity.
func (m *TaskMutation) ClearGitBotTasks() {
m.clearedgit_bot_tasks = true
}
// GitBotTasksCleared reports if the "git_bot_tasks" edge to the GitBotTask entity was cleared.
func (m *TaskMutation) GitBotTasksCleared() bool {
return m.clearedgit_bot_tasks
}
// RemoveGitBotTaskIDs removes the "git_bot_tasks" edge to the GitBotTask entity by IDs.
func (m *TaskMutation) RemoveGitBotTaskIDs(ids ...uuid.UUID) {
if m.removedgit_bot_tasks == nil {
m.removedgit_bot_tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.git_bot_tasks, ids[i])
m.removedgit_bot_tasks[ids[i]] = struct{}{}
}
}
// RemovedGitBotTasks returns the removed IDs of the "git_bot_tasks" edge to the GitBotTask entity.
func (m *TaskMutation) RemovedGitBotTasksIDs() (ids []uuid.UUID) {
for id := range m.removedgit_bot_tasks {
ids = append(ids, id)
}
return
}
// GitBotTasksIDs returns the "git_bot_tasks" edge IDs in the mutation.
func (m *TaskMutation) GitBotTasksIDs() (ids []uuid.UUID) {
for id := range m.git_bot_tasks {
ids = append(ids, id)
}
return
}
// ResetGitBotTasks resets all changes to the "git_bot_tasks" edge.
func (m *TaskMutation) ResetGitBotTasks() {
m.git_bot_tasks = nil
m.clearedgit_bot_tasks = false
m.removedgit_bot_tasks = nil
}
// AddModelSwitchIDs adds the "model_switches" edge to the TaskModelSwitch entity by ids.
func (m *TaskMutation) AddModelSwitchIDs(ids ...uuid.UUID) {
if m.model_switches == nil {
m.model_switches = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.model_switches[ids[i]] = struct{}{}
}
}
// ClearModelSwitches clears the "model_switches" edge to the TaskModelSwitch entity.
func (m *TaskMutation) ClearModelSwitches() {
m.clearedmodel_switches = true
}
// ModelSwitchesCleared reports if the "model_switches" edge to the TaskModelSwitch entity was cleared.
func (m *TaskMutation) ModelSwitchesCleared() bool {
return m.clearedmodel_switches
}
// RemoveModelSwitchIDs removes the "model_switches" edge to the TaskModelSwitch entity by IDs.
func (m *TaskMutation) RemoveModelSwitchIDs(ids ...uuid.UUID) {
if m.removedmodel_switches == nil {
m.removedmodel_switches = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.model_switches, ids[i])
m.removedmodel_switches[ids[i]] = struct{}{}
}
}
// RemovedModelSwitches returns the removed IDs of the "model_switches" edge to the TaskModelSwitch entity.
func (m *TaskMutation) RemovedModelSwitchesIDs() (ids []uuid.UUID) {
for id := range m.removedmodel_switches {
ids = append(ids, id)
}
return
}
// ModelSwitchesIDs returns the "model_switches" edge IDs in the mutation.
func (m *TaskMutation) ModelSwitchesIDs() (ids []uuid.UUID) {
for id := range m.model_switches {
ids = append(ids, id)
}
return
}
// ResetModelSwitches resets all changes to the "model_switches" edge.
func (m *TaskMutation) ResetModelSwitches() {
m.model_switches = nil
m.clearedmodel_switches = false
m.removedmodel_switches = nil
}
// AddTaskVMIDs adds the "task_vms" edge to the TaskVirtualMachine entity by ids.
func (m *TaskMutation) AddTaskVMIDs(ids ...uuid.UUID) {
if m.task_vms == nil {
m.task_vms = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.task_vms[ids[i]] = struct{}{}
}
}
// ClearTaskVms clears the "task_vms" edge to the TaskVirtualMachine entity.
func (m *TaskMutation) ClearTaskVms() {
m.clearedtask_vms = true
}
// TaskVmsCleared reports if the "task_vms" edge to the TaskVirtualMachine entity was cleared.
func (m *TaskMutation) TaskVmsCleared() bool {
return m.clearedtask_vms
}
// RemoveTaskVMIDs removes the "task_vms" edge to the TaskVirtualMachine entity by IDs.
func (m *TaskMutation) RemoveTaskVMIDs(ids ...uuid.UUID) {
if m.removedtask_vms == nil {
m.removedtask_vms = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.task_vms, ids[i])
m.removedtask_vms[ids[i]] = struct{}{}
}
}
// RemovedTaskVms returns the removed IDs of the "task_vms" edge to the TaskVirtualMachine entity.
func (m *TaskMutation) RemovedTaskVmsIDs() (ids []uuid.UUID) {
for id := range m.removedtask_vms {
ids = append(ids, id)
}
return
}
// TaskVmsIDs returns the "task_vms" edge IDs in the mutation.
func (m *TaskMutation) TaskVmsIDs() (ids []uuid.UUID) {
for id := range m.task_vms {
ids = append(ids, id)
}
return
}
// ResetTaskVms resets all changes to the "task_vms" edge.
func (m *TaskMutation) ResetTaskVms() {
m.task_vms = nil
m.clearedtask_vms = false
m.removedtask_vms = nil
}
// Where appends a list predicates to the TaskMutation builder.
func (m *TaskMutation) Where(ps ...predicate.Task) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TaskMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TaskMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Task, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TaskMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TaskMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Task).
func (m *TaskMutation) 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 *TaskMutation) Fields() []string {
fields := make([]string, 0, 13)
if m.deleted_at != nil {
fields = append(fields, task.FieldDeletedAt)
}
if m.user != nil {
fields = append(fields, task.FieldUserID)
}
if m.kind != nil {
fields = append(fields, task.FieldKind)
}
if m.sub_type != nil {
fields = append(fields, task.FieldSubType)
}
if m.content != nil {
fields = append(fields, task.FieldContent)
}
if m.title != nil {
fields = append(fields, task.FieldTitle)
}
if m.summary != nil {
fields = append(fields, task.FieldSummary)
}
if m.status != nil {
fields = append(fields, task.FieldStatus)
}
if m.log_store != nil {
fields = append(fields, task.FieldLogStore)
}
if m.created_at != nil {
fields = append(fields, task.FieldCreatedAt)
}
if m.last_active_at != nil {
fields = append(fields, task.FieldLastActiveAt)
}
if m.updated_at != nil {
fields = append(fields, task.FieldUpdatedAt)
}
if m.completed_at != nil {
fields = append(fields, task.FieldCompletedAt)
}
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 *TaskMutation) Field(name string) (ent.Value, bool) {
switch name {
case task.FieldDeletedAt:
return m.DeletedAt()
case task.FieldUserID:
return m.UserID()
case task.FieldKind:
return m.Kind()
case task.FieldSubType:
return m.SubType()
case task.FieldContent:
return m.Content()
case task.FieldTitle:
return m.Title()
case task.FieldSummary:
return m.Summary()
case task.FieldStatus:
return m.Status()
case task.FieldLogStore:
return m.LogStore()
case task.FieldCreatedAt:
return m.CreatedAt()
case task.FieldLastActiveAt:
return m.LastActiveAt()
case task.FieldUpdatedAt:
return m.UpdatedAt()
case task.FieldCompletedAt:
return m.CompletedAt()
}
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 *TaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case task.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case task.FieldUserID:
return m.OldUserID(ctx)
case task.FieldKind:
return m.OldKind(ctx)
case task.FieldSubType:
return m.OldSubType(ctx)
case task.FieldContent:
return m.OldContent(ctx)
case task.FieldTitle:
return m.OldTitle(ctx)
case task.FieldSummary:
return m.OldSummary(ctx)
case task.FieldStatus:
return m.OldStatus(ctx)
case task.FieldLogStore:
return m.OldLogStore(ctx)
case task.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case task.FieldLastActiveAt:
return m.OldLastActiveAt(ctx)
case task.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
case task.FieldCompletedAt:
return m.OldCompletedAt(ctx)
}
return nil, fmt.Errorf("unknown Task 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 *TaskMutation) SetField(name string, value ent.Value) error {
switch name {
case task.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 task.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case task.FieldKind:
v, ok := value.(consts.TaskType)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetKind(v)
return nil
case task.FieldSubType:
v, ok := value.(consts.TaskSubType)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSubType(v)
return nil
case task.FieldContent:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetContent(v)
return nil
case task.FieldTitle:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTitle(v)
return nil
case task.FieldSummary:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSummary(v)
return nil
case task.FieldStatus:
v, ok := value.(consts.TaskStatus)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetStatus(v)
return nil
case task.FieldLogStore:
v, ok := value.(consts.LogStore)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLogStore(v)
return nil
case task.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 task.FieldLastActiveAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLastActiveAt(v)
return nil
case task.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 task.FieldCompletedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCompletedAt(v)
return nil
}
return fmt.Errorf("unknown Task field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TaskMutation) AddedFields() []string {
return nil
}
// 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 *TaskMutation) AddedField(name string) (ent.Value, bool) {
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 *TaskMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown Task numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TaskMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(task.FieldDeletedAt) {
fields = append(fields, task.FieldDeletedAt)
}
if m.FieldCleared(task.FieldSubType) {
fields = append(fields, task.FieldSubType)
}
if m.FieldCleared(task.FieldTitle) {
fields = append(fields, task.FieldTitle)
}
if m.FieldCleared(task.FieldSummary) {
fields = append(fields, task.FieldSummary)
}
if m.FieldCleared(task.FieldLogStore) {
fields = append(fields, task.FieldLogStore)
}
if m.FieldCleared(task.FieldCompletedAt) {
fields = append(fields, task.FieldCompletedAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TaskMutation) 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 *TaskMutation) ClearField(name string) error {
switch name {
case task.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case task.FieldSubType:
m.ClearSubType()
return nil
case task.FieldTitle:
m.ClearTitle()
return nil
case task.FieldSummary:
m.ClearSummary()
return nil
case task.FieldLogStore:
m.ClearLogStore()
return nil
case task.FieldCompletedAt:
m.ClearCompletedAt()
return nil
}
return fmt.Errorf("unknown Task 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 *TaskMutation) ResetField(name string) error {
switch name {
case task.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case task.FieldUserID:
m.ResetUserID()
return nil
case task.FieldKind:
m.ResetKind()
return nil
case task.FieldSubType:
m.ResetSubType()
return nil
case task.FieldContent:
m.ResetContent()
return nil
case task.FieldTitle:
m.ResetTitle()
return nil
case task.FieldSummary:
m.ResetSummary()
return nil
case task.FieldStatus:
m.ResetStatus()
return nil
case task.FieldLogStore:
m.ResetLogStore()
return nil
case task.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case task.FieldLastActiveAt:
m.ResetLastActiveAt()
return nil
case task.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
case task.FieldCompletedAt:
m.ResetCompletedAt()
return nil
}
return fmt.Errorf("unknown Task field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TaskMutation) AddedEdges() []string {
edges := make([]string, 0, 7)
if m.project_tasks != nil {
edges = append(edges, task.EdgeProjectTasks)
}
if m.git_tasks != nil {
edges = append(edges, task.EdgeGitTasks)
}
if m.user != nil {
edges = append(edges, task.EdgeUser)
}
if m.vms != nil {
edges = append(edges, task.EdgeVms)
}
if m.git_bot_tasks != nil {
edges = append(edges, task.EdgeGitBotTasks)
}
if m.model_switches != nil {
edges = append(edges, task.EdgeModelSwitches)
}
if m.task_vms != nil {
edges = append(edges, task.EdgeTaskVms)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TaskMutation) AddedIDs(name string) []ent.Value {
switch name {
case task.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.project_tasks))
for id := range m.project_tasks {
ids = append(ids, id)
}
return ids
case task.EdgeGitTasks:
if id := m.git_tasks; id != nil {
return []ent.Value{*id}
}
case task.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
case task.EdgeVms:
ids := make([]ent.Value, 0, len(m.vms))
for id := range m.vms {
ids = append(ids, id)
}
return ids
case task.EdgeGitBotTasks:
ids := make([]ent.Value, 0, len(m.git_bot_tasks))
for id := range m.git_bot_tasks {
ids = append(ids, id)
}
return ids
case task.EdgeModelSwitches:
ids := make([]ent.Value, 0, len(m.model_switches))
for id := range m.model_switches {
ids = append(ids, id)
}
return ids
case task.EdgeTaskVms:
ids := make([]ent.Value, 0, len(m.task_vms))
for id := range m.task_vms {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TaskMutation) RemovedEdges() []string {
edges := make([]string, 0, 7)
if m.removedproject_tasks != nil {
edges = append(edges, task.EdgeProjectTasks)
}
if m.removedvms != nil {
edges = append(edges, task.EdgeVms)
}
if m.removedgit_bot_tasks != nil {
edges = append(edges, task.EdgeGitBotTasks)
}
if m.removedmodel_switches != nil {
edges = append(edges, task.EdgeModelSwitches)
}
if m.removedtask_vms != nil {
edges = append(edges, task.EdgeTaskVms)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TaskMutation) RemovedIDs(name string) []ent.Value {
switch name {
case task.EdgeProjectTasks:
ids := make([]ent.Value, 0, len(m.removedproject_tasks))
for id := range m.removedproject_tasks {
ids = append(ids, id)
}
return ids
case task.EdgeVms:
ids := make([]ent.Value, 0, len(m.removedvms))
for id := range m.removedvms {
ids = append(ids, id)
}
return ids
case task.EdgeGitBotTasks:
ids := make([]ent.Value, 0, len(m.removedgit_bot_tasks))
for id := range m.removedgit_bot_tasks {
ids = append(ids, id)
}
return ids
case task.EdgeModelSwitches:
ids := make([]ent.Value, 0, len(m.removedmodel_switches))
for id := range m.removedmodel_switches {
ids = append(ids, id)
}
return ids
case task.EdgeTaskVms:
ids := make([]ent.Value, 0, len(m.removedtask_vms))
for id := range m.removedtask_vms {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TaskMutation) ClearedEdges() []string {
edges := make([]string, 0, 7)
if m.clearedproject_tasks {
edges = append(edges, task.EdgeProjectTasks)
}
if m.clearedgit_tasks {
edges = append(edges, task.EdgeGitTasks)
}
if m.cleareduser {
edges = append(edges, task.EdgeUser)
}
if m.clearedvms {
edges = append(edges, task.EdgeVms)
}
if m.clearedgit_bot_tasks {
edges = append(edges, task.EdgeGitBotTasks)
}
if m.clearedmodel_switches {
edges = append(edges, task.EdgeModelSwitches)
}
if m.clearedtask_vms {
edges = append(edges, task.EdgeTaskVms)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TaskMutation) EdgeCleared(name string) bool {
switch name {
case task.EdgeProjectTasks:
return m.clearedproject_tasks
case task.EdgeGitTasks:
return m.clearedgit_tasks
case task.EdgeUser:
return m.cleareduser
case task.EdgeVms:
return m.clearedvms
case task.EdgeGitBotTasks:
return m.clearedgit_bot_tasks
case task.EdgeModelSwitches:
return m.clearedmodel_switches
case task.EdgeTaskVms:
return m.clearedtask_vms
}
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 *TaskMutation) ClearEdge(name string) error {
switch name {
case task.EdgeGitTasks:
m.ClearGitTasks()
return nil
case task.EdgeUser:
m.ClearUser()
return nil
}
return fmt.Errorf("unknown Task 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 *TaskMutation) ResetEdge(name string) error {
switch name {
case task.EdgeProjectTasks:
m.ResetProjectTasks()
return nil
case task.EdgeGitTasks:
m.ResetGitTasks()
return nil
case task.EdgeUser:
m.ResetUser()
return nil
case task.EdgeVms:
m.ResetVms()
return nil
case task.EdgeGitBotTasks:
m.ResetGitBotTasks()
return nil
case task.EdgeModelSwitches:
m.ResetModelSwitches()
return nil
case task.EdgeTaskVms:
m.ResetTaskVms()
return nil
}
return fmt.Errorf("unknown Task edge %s", name)
}
// TaskModelSwitchMutation represents an operation that mutates the TaskModelSwitch nodes in the graph.
type TaskModelSwitchMutation struct {
config
op Op
typ string
id *uuid.UUID
request_id *string
load_session *bool
success *bool
message *string
session_id *string
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
task *uuid.UUID
clearedtask bool
user *uuid.UUID
cleareduser bool
from_model *uuid.UUID
clearedfrom_model bool
to_model *uuid.UUID
clearedto_model bool
done bool
oldValue func(context.Context) (*TaskModelSwitch, error)
predicates []predicate.TaskModelSwitch
}
var _ ent.Mutation = (*TaskModelSwitchMutation)(nil)
// taskmodelswitchOption allows management of the mutation configuration using functional options.
type taskmodelswitchOption func(*TaskModelSwitchMutation)
// newTaskModelSwitchMutation creates new mutation for the TaskModelSwitch entity.
func newTaskModelSwitchMutation(c config, op Op, opts ...taskmodelswitchOption) *TaskModelSwitchMutation {
m := &TaskModelSwitchMutation{
config: c,
op: op,
typ: TypeTaskModelSwitch,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTaskModelSwitchID sets the ID field of the mutation.
func withTaskModelSwitchID(id uuid.UUID) taskmodelswitchOption {
return func(m *TaskModelSwitchMutation) {
var (
err error
once sync.Once
value *TaskModelSwitch
)
m.oldValue = func(ctx context.Context) (*TaskModelSwitch, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TaskModelSwitch.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTaskModelSwitch sets the old TaskModelSwitch of the mutation.
func withTaskModelSwitch(node *TaskModelSwitch) taskmodelswitchOption {
return func(m *TaskModelSwitchMutation) {
m.oldValue = func(context.Context) (*TaskModelSwitch, 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 TaskModelSwitchMutation) 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 TaskModelSwitchMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TaskModelSwitch entities.
func (m *TaskModelSwitchMutation) SetID(id uuid.UUID) {
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 *TaskModelSwitchMutation) ID() (id uuid.UUID, 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 *TaskModelSwitchMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TaskModelSwitch.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetTaskID sets the "task_id" field.
func (m *TaskModelSwitchMutation) SetTaskID(u uuid.UUID) {
m.task = &u
}
// TaskID returns the value of the "task_id" field in the mutation.
func (m *TaskModelSwitchMutation) TaskID() (r uuid.UUID, exists bool) {
v := m.task
if v == nil {
return
}
return *v, true
}
// OldTaskID returns the old "task_id" field's value of the TaskModelSwitch entity.
// If the TaskModelSwitch 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 *TaskModelSwitchMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTaskID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
}
return oldValue.TaskID, nil
}
// ResetTaskID resets all changes to the "task_id" field.
func (m *TaskModelSwitchMutation) ResetTaskID() {
m.task = nil
}
// SetUserID sets the "user_id" field.
func (m *TaskModelSwitchMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *TaskModelSwitchMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the TaskModelSwitch entity.
// If the TaskModelSwitch 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 *TaskModelSwitchMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *TaskModelSwitchMutation) ResetUserID() {
m.user = nil
}
// SetFromModelID sets the "from_model_id" field.
func (m *TaskModelSwitchMutation) SetFromModelID(u uuid.UUID) {
m.from_model = &u
}
// FromModelID returns the value of the "from_model_id" field in the mutation.
func (m *TaskModelSwitchMutation) FromModelID() (r uuid.UUID, exists bool) {
v := m.from_model
if v == nil {
return
}
return *v, true
}
// OldFromModelID returns the old "from_model_id" field's value of the TaskModelSwitch entity.
// If the TaskModelSwitch 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 *TaskModelSwitchMutation) OldFromModelID(ctx context.Context) (v *uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldFromModelID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldFromModelID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldFromModelID: %w", err)
}
return oldValue.FromModelID, nil
}
// ClearFromModelID clears the value of the "from_model_id" field.
func (m *TaskModelSwitchMutation) ClearFromModelID() {
m.from_model = nil
m.clearedFields[taskmodelswitch.FieldFromModelID] = struct{}{}
}
// FromModelIDCleared returns if the "from_model_id" field was cleared in this mutation.
func (m *TaskModelSwitchMutation) FromModelIDCleared() bool {
_, ok := m.clearedFields[taskmodelswitch.FieldFromModelID]
return ok
}
// ResetFromModelID resets all changes to the "from_model_id" field.
func (m *TaskModelSwitchMutation) ResetFromModelID() {
m.from_model = nil
delete(m.clearedFields, taskmodelswitch.FieldFromModelID)
}
// SetToModelID sets the "to_model_id" field.
func (m *TaskModelSwitchMutation) SetToModelID(u uuid.UUID) {
m.to_model = &u
}
// ToModelID returns the value of the "to_model_id" field in the mutation.
func (m *TaskModelSwitchMutation) ToModelID() (r uuid.UUID, exists bool) {
v := m.to_model
if v == nil {
return
}
return *v, true
}
// OldToModelID returns the old "to_model_id" field's value of the TaskModelSwitch entity.
// If the TaskModelSwitch 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 *TaskModelSwitchMutation) OldToModelID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldToModelID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldToModelID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldToModelID: %w", err)
}
return oldValue.ToModelID, nil
}
// ResetToModelID resets all changes to the "to_model_id" field.
func (m *TaskModelSwitchMutation) ResetToModelID() {
m.to_model = nil
}
// SetRequestID sets the "request_id" field.
func (m *TaskModelSwitchMutation) SetRequestID(s string) {
m.request_id = &s
}
// RequestID returns the value of the "request_id" field in the mutation.
func (m *TaskModelSwitchMutation) RequestID() (r string, exists bool) {
v := m.request_id
if v == nil {
return
}
return *v, true
}
// OldRequestID returns the old "request_id" field's value of the TaskModelSwitch entity.
// If the TaskModelSwitch 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 *TaskModelSwitchMutation) OldRequestID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRequestID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRequestID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRequestID: %w", err)
}
return oldValue.RequestID, nil
}
// ResetRequestID resets all changes to the "request_id" field.
func (m *TaskModelSwitchMutation) ResetRequestID() {
m.request_id = nil
}
// SetLoadSession sets the "load_session" field.
func (m *TaskModelSwitchMutation) SetLoadSession(b bool) {
m.load_session = &b
}
// LoadSession returns the value of the "load_session" field in the mutation.
func (m *TaskModelSwitchMutation) LoadSession() (r bool, exists bool) {
v := m.load_session
if v == nil {
return
}
return *v, true
}
// OldLoadSession returns the old "load_session" field's value of the TaskModelSwitch entity.
// If the TaskModelSwitch 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 *TaskModelSwitchMutation) OldLoadSession(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldLoadSession is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldLoadSession requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLoadSession: %w", err)
}
return oldValue.LoadSession, nil
}
// ResetLoadSession resets all changes to the "load_session" field.
func (m *TaskModelSwitchMutation) ResetLoadSession() {
m.load_session = nil
}
// SetSuccess sets the "success" field.
func (m *TaskModelSwitchMutation) SetSuccess(b bool) {
m.success = &b
}
// Success returns the value of the "success" field in the mutation.
func (m *TaskModelSwitchMutation) Success() (r bool, exists bool) {
v := m.success
if v == nil {
return
}
return *v, true
}
// OldSuccess returns the old "success" field's value of the TaskModelSwitch entity.
// If the TaskModelSwitch 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 *TaskModelSwitchMutation) OldSuccess(ctx context.Context) (v *bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSuccess requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
}
return oldValue.Success, nil
}
// ClearSuccess clears the value of the "success" field.
func (m *TaskModelSwitchMutation) ClearSuccess() {
m.success = nil
m.clearedFields[taskmodelswitch.FieldSuccess] = struct{}{}
}
// SuccessCleared returns if the "success" field was cleared in this mutation.
func (m *TaskModelSwitchMutation) SuccessCleared() bool {
_, ok := m.clearedFields[taskmodelswitch.FieldSuccess]
return ok
}
// ResetSuccess resets all changes to the "success" field.
func (m *TaskModelSwitchMutation) ResetSuccess() {
m.success = nil
delete(m.clearedFields, taskmodelswitch.FieldSuccess)
}
// SetMessage sets the "message" field.
func (m *TaskModelSwitchMutation) SetMessage(s string) {
m.message = &s
}
// Message returns the value of the "message" field in the mutation.
func (m *TaskModelSwitchMutation) Message() (r string, exists bool) {
v := m.message
if v == nil {
return
}
return *v, true
}
// OldMessage returns the old "message" field's value of the TaskModelSwitch entity.
// If the TaskModelSwitch 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 *TaskModelSwitchMutation) OldMessage(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMessage is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldMessage requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMessage: %w", err)
}
return oldValue.Message, nil
}
// ResetMessage resets all changes to the "message" field.
func (m *TaskModelSwitchMutation) ResetMessage() {
m.message = nil
}
// SetSessionID sets the "session_id" field.
func (m *TaskModelSwitchMutation) SetSessionID(s string) {
m.session_id = &s
}
// SessionID returns the value of the "session_id" field in the mutation.
func (m *TaskModelSwitchMutation) SessionID() (r string, exists bool) {
v := m.session_id
if v == nil {
return
}
return *v, true
}
// OldSessionID returns the old "session_id" field's value of the TaskModelSwitch entity.
// If the TaskModelSwitch 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 *TaskModelSwitchMutation) OldSessionID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSessionID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
}
return oldValue.SessionID, nil
}
// ResetSessionID resets all changes to the "session_id" field.
func (m *TaskModelSwitchMutation) ResetSessionID() {
m.session_id = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TaskModelSwitchMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TaskModelSwitchMutation) 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 TaskModelSwitch entity.
// If the TaskModelSwitch 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 *TaskModelSwitchMutation) 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 *TaskModelSwitchMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *TaskModelSwitchMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *TaskModelSwitchMutation) 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 TaskModelSwitch entity.
// If the TaskModelSwitch 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 *TaskModelSwitchMutation) 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 *TaskModelSwitchMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearTask clears the "task" edge to the Task entity.
func (m *TaskModelSwitchMutation) ClearTask() {
m.clearedtask = true
m.clearedFields[taskmodelswitch.FieldTaskID] = struct{}{}
}
// TaskCleared reports if the "task" edge to the Task entity was cleared.
func (m *TaskModelSwitchMutation) TaskCleared() bool {
return m.clearedtask
}
// TaskIDs returns the "task" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// TaskID instead. It exists only for internal usage by the builders.
func (m *TaskModelSwitchMutation) TaskIDs() (ids []uuid.UUID) {
if id := m.task; id != nil {
ids = append(ids, *id)
}
return
}
// ResetTask resets all changes to the "task" edge.
func (m *TaskModelSwitchMutation) ResetTask() {
m.task = nil
m.clearedtask = false
}
// ClearUser clears the "user" edge to the User entity.
func (m *TaskModelSwitchMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[taskmodelswitch.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *TaskModelSwitchMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *TaskModelSwitchMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *TaskModelSwitchMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// ClearFromModel clears the "from_model" edge to the Model entity.
func (m *TaskModelSwitchMutation) ClearFromModel() {
m.clearedfrom_model = true
m.clearedFields[taskmodelswitch.FieldFromModelID] = struct{}{}
}
// FromModelCleared reports if the "from_model" edge to the Model entity was cleared.
func (m *TaskModelSwitchMutation) FromModelCleared() bool {
return m.FromModelIDCleared() || m.clearedfrom_model
}
// FromModelIDs returns the "from_model" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// FromModelID instead. It exists only for internal usage by the builders.
func (m *TaskModelSwitchMutation) FromModelIDs() (ids []uuid.UUID) {
if id := m.from_model; id != nil {
ids = append(ids, *id)
}
return
}
// ResetFromModel resets all changes to the "from_model" edge.
func (m *TaskModelSwitchMutation) ResetFromModel() {
m.from_model = nil
m.clearedfrom_model = false
}
// ClearToModel clears the "to_model" edge to the Model entity.
func (m *TaskModelSwitchMutation) ClearToModel() {
m.clearedto_model = true
m.clearedFields[taskmodelswitch.FieldToModelID] = struct{}{}
}
// ToModelCleared reports if the "to_model" edge to the Model entity was cleared.
func (m *TaskModelSwitchMutation) ToModelCleared() bool {
return m.clearedto_model
}
// ToModelIDs returns the "to_model" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ToModelID instead. It exists only for internal usage by the builders.
func (m *TaskModelSwitchMutation) ToModelIDs() (ids []uuid.UUID) {
if id := m.to_model; id != nil {
ids = append(ids, *id)
}
return
}
// ResetToModel resets all changes to the "to_model" edge.
func (m *TaskModelSwitchMutation) ResetToModel() {
m.to_model = nil
m.clearedto_model = false
}
// Where appends a list predicates to the TaskModelSwitchMutation builder.
func (m *TaskModelSwitchMutation) Where(ps ...predicate.TaskModelSwitch) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TaskModelSwitchMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TaskModelSwitchMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TaskModelSwitch, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TaskModelSwitchMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TaskModelSwitchMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TaskModelSwitch).
func (m *TaskModelSwitchMutation) 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 *TaskModelSwitchMutation) Fields() []string {
fields := make([]string, 0, 11)
if m.task != nil {
fields = append(fields, taskmodelswitch.FieldTaskID)
}
if m.user != nil {
fields = append(fields, taskmodelswitch.FieldUserID)
}
if m.from_model != nil {
fields = append(fields, taskmodelswitch.FieldFromModelID)
}
if m.to_model != nil {
fields = append(fields, taskmodelswitch.FieldToModelID)
}
if m.request_id != nil {
fields = append(fields, taskmodelswitch.FieldRequestID)
}
if m.load_session != nil {
fields = append(fields, taskmodelswitch.FieldLoadSession)
}
if m.success != nil {
fields = append(fields, taskmodelswitch.FieldSuccess)
}
if m.message != nil {
fields = append(fields, taskmodelswitch.FieldMessage)
}
if m.session_id != nil {
fields = append(fields, taskmodelswitch.FieldSessionID)
}
if m.created_at != nil {
fields = append(fields, taskmodelswitch.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, taskmodelswitch.FieldUpdatedAt)
}
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 *TaskModelSwitchMutation) Field(name string) (ent.Value, bool) {
switch name {
case taskmodelswitch.FieldTaskID:
return m.TaskID()
case taskmodelswitch.FieldUserID:
return m.UserID()
case taskmodelswitch.FieldFromModelID:
return m.FromModelID()
case taskmodelswitch.FieldToModelID:
return m.ToModelID()
case taskmodelswitch.FieldRequestID:
return m.RequestID()
case taskmodelswitch.FieldLoadSession:
return m.LoadSession()
case taskmodelswitch.FieldSuccess:
return m.Success()
case taskmodelswitch.FieldMessage:
return m.Message()
case taskmodelswitch.FieldSessionID:
return m.SessionID()
case taskmodelswitch.FieldCreatedAt:
return m.CreatedAt()
case taskmodelswitch.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *TaskModelSwitchMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case taskmodelswitch.FieldTaskID:
return m.OldTaskID(ctx)
case taskmodelswitch.FieldUserID:
return m.OldUserID(ctx)
case taskmodelswitch.FieldFromModelID:
return m.OldFromModelID(ctx)
case taskmodelswitch.FieldToModelID:
return m.OldToModelID(ctx)
case taskmodelswitch.FieldRequestID:
return m.OldRequestID(ctx)
case taskmodelswitch.FieldLoadSession:
return m.OldLoadSession(ctx)
case taskmodelswitch.FieldSuccess:
return m.OldSuccess(ctx)
case taskmodelswitch.FieldMessage:
return m.OldMessage(ctx)
case taskmodelswitch.FieldSessionID:
return m.OldSessionID(ctx)
case taskmodelswitch.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case taskmodelswitch.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown TaskModelSwitch 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 *TaskModelSwitchMutation) SetField(name string, value ent.Value) error {
switch name {
case taskmodelswitch.FieldTaskID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTaskID(v)
return nil
case taskmodelswitch.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case taskmodelswitch.FieldFromModelID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetFromModelID(v)
return nil
case taskmodelswitch.FieldToModelID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetToModelID(v)
return nil
case taskmodelswitch.FieldRequestID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRequestID(v)
return nil
case taskmodelswitch.FieldLoadSession:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLoadSession(v)
return nil
case taskmodelswitch.FieldSuccess:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSuccess(v)
return nil
case taskmodelswitch.FieldMessage:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMessage(v)
return nil
case taskmodelswitch.FieldSessionID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSessionID(v)
return nil
case taskmodelswitch.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 taskmodelswitch.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown TaskModelSwitch field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TaskModelSwitchMutation) AddedFields() []string {
return nil
}
// 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 *TaskModelSwitchMutation) AddedField(name string) (ent.Value, bool) {
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 *TaskModelSwitchMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TaskModelSwitch numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TaskModelSwitchMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(taskmodelswitch.FieldFromModelID) {
fields = append(fields, taskmodelswitch.FieldFromModelID)
}
if m.FieldCleared(taskmodelswitch.FieldSuccess) {
fields = append(fields, taskmodelswitch.FieldSuccess)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TaskModelSwitchMutation) 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 *TaskModelSwitchMutation) ClearField(name string) error {
switch name {
case taskmodelswitch.FieldFromModelID:
m.ClearFromModelID()
return nil
case taskmodelswitch.FieldSuccess:
m.ClearSuccess()
return nil
}
return fmt.Errorf("unknown TaskModelSwitch 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 *TaskModelSwitchMutation) ResetField(name string) error {
switch name {
case taskmodelswitch.FieldTaskID:
m.ResetTaskID()
return nil
case taskmodelswitch.FieldUserID:
m.ResetUserID()
return nil
case taskmodelswitch.FieldFromModelID:
m.ResetFromModelID()
return nil
case taskmodelswitch.FieldToModelID:
m.ResetToModelID()
return nil
case taskmodelswitch.FieldRequestID:
m.ResetRequestID()
return nil
case taskmodelswitch.FieldLoadSession:
m.ResetLoadSession()
return nil
case taskmodelswitch.FieldSuccess:
m.ResetSuccess()
return nil
case taskmodelswitch.FieldMessage:
m.ResetMessage()
return nil
case taskmodelswitch.FieldSessionID:
m.ResetSessionID()
return nil
case taskmodelswitch.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case taskmodelswitch.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown TaskModelSwitch field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TaskModelSwitchMutation) AddedEdges() []string {
edges := make([]string, 0, 4)
if m.task != nil {
edges = append(edges, taskmodelswitch.EdgeTask)
}
if m.user != nil {
edges = append(edges, taskmodelswitch.EdgeUser)
}
if m.from_model != nil {
edges = append(edges, taskmodelswitch.EdgeFromModel)
}
if m.to_model != nil {
edges = append(edges, taskmodelswitch.EdgeToModel)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TaskModelSwitchMutation) AddedIDs(name string) []ent.Value {
switch name {
case taskmodelswitch.EdgeTask:
if id := m.task; id != nil {
return []ent.Value{*id}
}
case taskmodelswitch.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
case taskmodelswitch.EdgeFromModel:
if id := m.from_model; id != nil {
return []ent.Value{*id}
}
case taskmodelswitch.EdgeToModel:
if id := m.to_model; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TaskModelSwitchMutation) RemovedEdges() []string {
edges := make([]string, 0, 4)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TaskModelSwitchMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TaskModelSwitchMutation) ClearedEdges() []string {
edges := make([]string, 0, 4)
if m.clearedtask {
edges = append(edges, taskmodelswitch.EdgeTask)
}
if m.cleareduser {
edges = append(edges, taskmodelswitch.EdgeUser)
}
if m.clearedfrom_model {
edges = append(edges, taskmodelswitch.EdgeFromModel)
}
if m.clearedto_model {
edges = append(edges, taskmodelswitch.EdgeToModel)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TaskModelSwitchMutation) EdgeCleared(name string) bool {
switch name {
case taskmodelswitch.EdgeTask:
return m.clearedtask
case taskmodelswitch.EdgeUser:
return m.cleareduser
case taskmodelswitch.EdgeFromModel:
return m.clearedfrom_model
case taskmodelswitch.EdgeToModel:
return m.clearedto_model
}
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 *TaskModelSwitchMutation) ClearEdge(name string) error {
switch name {
case taskmodelswitch.EdgeTask:
m.ClearTask()
return nil
case taskmodelswitch.EdgeUser:
m.ClearUser()
return nil
case taskmodelswitch.EdgeFromModel:
m.ClearFromModel()
return nil
case taskmodelswitch.EdgeToModel:
m.ClearToModel()
return nil
}
return fmt.Errorf("unknown TaskModelSwitch 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 *TaskModelSwitchMutation) ResetEdge(name string) error {
switch name {
case taskmodelswitch.EdgeTask:
m.ResetTask()
return nil
case taskmodelswitch.EdgeUser:
m.ResetUser()
return nil
case taskmodelswitch.EdgeFromModel:
m.ResetFromModel()
return nil
case taskmodelswitch.EdgeToModel:
m.ResetToModel()
return nil
}
return fmt.Errorf("unknown TaskModelSwitch edge %s", name)
}
// TaskUsageStatMutation represents an operation that mutates the TaskUsageStat nodes in the graph.
type TaskUsageStatMutation struct {
config
op Op
typ string
id *uuid.UUID
task_id *uuid.UUID
user_id *uuid.UUID
model *string
input_tokens *int64
addinput_tokens *int64
output_tokens *int64
addoutput_tokens *int64
total_tokens *int64
addtotal_tokens *int64
created_at *time.Time
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*TaskUsageStat, error)
predicates []predicate.TaskUsageStat
}
var _ ent.Mutation = (*TaskUsageStatMutation)(nil)
// taskusagestatOption allows management of the mutation configuration using functional options.
type taskusagestatOption func(*TaskUsageStatMutation)
// newTaskUsageStatMutation creates new mutation for the TaskUsageStat entity.
func newTaskUsageStatMutation(c config, op Op, opts ...taskusagestatOption) *TaskUsageStatMutation {
m := &TaskUsageStatMutation{
config: c,
op: op,
typ: TypeTaskUsageStat,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTaskUsageStatID sets the ID field of the mutation.
func withTaskUsageStatID(id uuid.UUID) taskusagestatOption {
return func(m *TaskUsageStatMutation) {
var (
err error
once sync.Once
value *TaskUsageStat
)
m.oldValue = func(ctx context.Context) (*TaskUsageStat, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TaskUsageStat.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTaskUsageStat sets the old TaskUsageStat of the mutation.
func withTaskUsageStat(node *TaskUsageStat) taskusagestatOption {
return func(m *TaskUsageStatMutation) {
m.oldValue = func(context.Context) (*TaskUsageStat, 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 TaskUsageStatMutation) 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 TaskUsageStatMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TaskUsageStat entities.
func (m *TaskUsageStatMutation) SetID(id uuid.UUID) {
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 *TaskUsageStatMutation) ID() (id uuid.UUID, 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 *TaskUsageStatMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TaskUsageStat.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetTaskID sets the "task_id" field.
func (m *TaskUsageStatMutation) SetTaskID(u uuid.UUID) {
m.task_id = &u
}
// TaskID returns the value of the "task_id" field in the mutation.
func (m *TaskUsageStatMutation) TaskID() (r uuid.UUID, exists bool) {
v := m.task_id
if v == nil {
return
}
return *v, true
}
// OldTaskID returns the old "task_id" field's value of the TaskUsageStat entity.
// If the TaskUsageStat 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 *TaskUsageStatMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTaskID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
}
return oldValue.TaskID, nil
}
// ResetTaskID resets all changes to the "task_id" field.
func (m *TaskUsageStatMutation) ResetTaskID() {
m.task_id = nil
}
// SetUserID sets the "user_id" field.
func (m *TaskUsageStatMutation) SetUserID(u uuid.UUID) {
m.user_id = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *TaskUsageStatMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user_id
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the TaskUsageStat entity.
// If the TaskUsageStat 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 *TaskUsageStatMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *TaskUsageStatMutation) ResetUserID() {
m.user_id = nil
}
// SetModel sets the "model" field.
func (m *TaskUsageStatMutation) SetModel(s string) {
m.model = &s
}
// Model returns the value of the "model" field in the mutation.
func (m *TaskUsageStatMutation) Model() (r string, exists bool) {
v := m.model
if v == nil {
return
}
return *v, true
}
// OldModel returns the old "model" field's value of the TaskUsageStat entity.
// If the TaskUsageStat 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 *TaskUsageStatMutation) OldModel(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldModel is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldModel requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldModel: %w", err)
}
return oldValue.Model, nil
}
// ResetModel resets all changes to the "model" field.
func (m *TaskUsageStatMutation) ResetModel() {
m.model = nil
}
// SetInputTokens sets the "input_tokens" field.
func (m *TaskUsageStatMutation) SetInputTokens(i int64) {
m.input_tokens = &i
m.addinput_tokens = nil
}
// InputTokens returns the value of the "input_tokens" field in the mutation.
func (m *TaskUsageStatMutation) InputTokens() (r int64, exists bool) {
v := m.input_tokens
if v == nil {
return
}
return *v, true
}
// OldInputTokens returns the old "input_tokens" field's value of the TaskUsageStat entity.
// If the TaskUsageStat 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 *TaskUsageStatMutation) OldInputTokens(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldInputTokens is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldInputTokens requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInputTokens: %w", err)
}
return oldValue.InputTokens, nil
}
// AddInputTokens adds i to the "input_tokens" field.
func (m *TaskUsageStatMutation) AddInputTokens(i int64) {
if m.addinput_tokens != nil {
*m.addinput_tokens += i
} else {
m.addinput_tokens = &i
}
}
// AddedInputTokens returns the value that was added to the "input_tokens" field in this mutation.
func (m *TaskUsageStatMutation) AddedInputTokens() (r int64, exists bool) {
v := m.addinput_tokens
if v == nil {
return
}
return *v, true
}
// ResetInputTokens resets all changes to the "input_tokens" field.
func (m *TaskUsageStatMutation) ResetInputTokens() {
m.input_tokens = nil
m.addinput_tokens = nil
}
// SetOutputTokens sets the "output_tokens" field.
func (m *TaskUsageStatMutation) SetOutputTokens(i int64) {
m.output_tokens = &i
m.addoutput_tokens = nil
}
// OutputTokens returns the value of the "output_tokens" field in the mutation.
func (m *TaskUsageStatMutation) OutputTokens() (r int64, exists bool) {
v := m.output_tokens
if v == nil {
return
}
return *v, true
}
// OldOutputTokens returns the old "output_tokens" field's value of the TaskUsageStat entity.
// If the TaskUsageStat 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 *TaskUsageStatMutation) OldOutputTokens(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOutputTokens is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOutputTokens requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOutputTokens: %w", err)
}
return oldValue.OutputTokens, nil
}
// AddOutputTokens adds i to the "output_tokens" field.
func (m *TaskUsageStatMutation) AddOutputTokens(i int64) {
if m.addoutput_tokens != nil {
*m.addoutput_tokens += i
} else {
m.addoutput_tokens = &i
}
}
// AddedOutputTokens returns the value that was added to the "output_tokens" field in this mutation.
func (m *TaskUsageStatMutation) AddedOutputTokens() (r int64, exists bool) {
v := m.addoutput_tokens
if v == nil {
return
}
return *v, true
}
// ResetOutputTokens resets all changes to the "output_tokens" field.
func (m *TaskUsageStatMutation) ResetOutputTokens() {
m.output_tokens = nil
m.addoutput_tokens = nil
}
// SetTotalTokens sets the "total_tokens" field.
func (m *TaskUsageStatMutation) SetTotalTokens(i int64) {
m.total_tokens = &i
m.addtotal_tokens = nil
}
// TotalTokens returns the value of the "total_tokens" field in the mutation.
func (m *TaskUsageStatMutation) TotalTokens() (r int64, exists bool) {
v := m.total_tokens
if v == nil {
return
}
return *v, true
}
// OldTotalTokens returns the old "total_tokens" field's value of the TaskUsageStat entity.
// If the TaskUsageStat 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 *TaskUsageStatMutation) OldTotalTokens(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTotalTokens requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
}
return oldValue.TotalTokens, nil
}
// AddTotalTokens adds i to the "total_tokens" field.
func (m *TaskUsageStatMutation) AddTotalTokens(i int64) {
if m.addtotal_tokens != nil {
*m.addtotal_tokens += i
} else {
m.addtotal_tokens = &i
}
}
// AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
func (m *TaskUsageStatMutation) AddedTotalTokens() (r int64, exists bool) {
v := m.addtotal_tokens
if v == nil {
return
}
return *v, true
}
// ResetTotalTokens resets all changes to the "total_tokens" field.
func (m *TaskUsageStatMutation) ResetTotalTokens() {
m.total_tokens = nil
m.addtotal_tokens = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TaskUsageStatMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TaskUsageStatMutation) 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 TaskUsageStat entity.
// If the TaskUsageStat 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 *TaskUsageStatMutation) 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 *TaskUsageStatMutation) ResetCreatedAt() {
m.created_at = nil
}
// Where appends a list predicates to the TaskUsageStatMutation builder.
func (m *TaskUsageStatMutation) Where(ps ...predicate.TaskUsageStat) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TaskUsageStatMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TaskUsageStatMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TaskUsageStat, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TaskUsageStatMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TaskUsageStatMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TaskUsageStat).
func (m *TaskUsageStatMutation) 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 *TaskUsageStatMutation) Fields() []string {
fields := make([]string, 0, 7)
if m.task_id != nil {
fields = append(fields, taskusagestat.FieldTaskID)
}
if m.user_id != nil {
fields = append(fields, taskusagestat.FieldUserID)
}
if m.model != nil {
fields = append(fields, taskusagestat.FieldModel)
}
if m.input_tokens != nil {
fields = append(fields, taskusagestat.FieldInputTokens)
}
if m.output_tokens != nil {
fields = append(fields, taskusagestat.FieldOutputTokens)
}
if m.total_tokens != nil {
fields = append(fields, taskusagestat.FieldTotalTokens)
}
if m.created_at != nil {
fields = append(fields, taskusagestat.FieldCreatedAt)
}
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 *TaskUsageStatMutation) Field(name string) (ent.Value, bool) {
switch name {
case taskusagestat.FieldTaskID:
return m.TaskID()
case taskusagestat.FieldUserID:
return m.UserID()
case taskusagestat.FieldModel:
return m.Model()
case taskusagestat.FieldInputTokens:
return m.InputTokens()
case taskusagestat.FieldOutputTokens:
return m.OutputTokens()
case taskusagestat.FieldTotalTokens:
return m.TotalTokens()
case taskusagestat.FieldCreatedAt:
return m.CreatedAt()
}
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 *TaskUsageStatMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case taskusagestat.FieldTaskID:
return m.OldTaskID(ctx)
case taskusagestat.FieldUserID:
return m.OldUserID(ctx)
case taskusagestat.FieldModel:
return m.OldModel(ctx)
case taskusagestat.FieldInputTokens:
return m.OldInputTokens(ctx)
case taskusagestat.FieldOutputTokens:
return m.OldOutputTokens(ctx)
case taskusagestat.FieldTotalTokens:
return m.OldTotalTokens(ctx)
case taskusagestat.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown TaskUsageStat 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 *TaskUsageStatMutation) SetField(name string, value ent.Value) error {
switch name {
case taskusagestat.FieldTaskID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTaskID(v)
return nil
case taskusagestat.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case taskusagestat.FieldModel:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetModel(v)
return nil
case taskusagestat.FieldInputTokens:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetInputTokens(v)
return nil
case taskusagestat.FieldOutputTokens:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOutputTokens(v)
return nil
case taskusagestat.FieldTotalTokens:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTotalTokens(v)
return nil
case taskusagestat.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown TaskUsageStat field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TaskUsageStatMutation) AddedFields() []string {
var fields []string
if m.addinput_tokens != nil {
fields = append(fields, taskusagestat.FieldInputTokens)
}
if m.addoutput_tokens != nil {
fields = append(fields, taskusagestat.FieldOutputTokens)
}
if m.addtotal_tokens != nil {
fields = append(fields, taskusagestat.FieldTotalTokens)
}
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 *TaskUsageStatMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case taskusagestat.FieldInputTokens:
return m.AddedInputTokens()
case taskusagestat.FieldOutputTokens:
return m.AddedOutputTokens()
case taskusagestat.FieldTotalTokens:
return m.AddedTotalTokens()
}
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 *TaskUsageStatMutation) AddField(name string, value ent.Value) error {
switch name {
case taskusagestat.FieldInputTokens:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddInputTokens(v)
return nil
case taskusagestat.FieldOutputTokens:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddOutputTokens(v)
return nil
case taskusagestat.FieldTotalTokens:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddTotalTokens(v)
return nil
}
return fmt.Errorf("unknown TaskUsageStat numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TaskUsageStatMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TaskUsageStatMutation) 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 *TaskUsageStatMutation) ClearField(name string) error {
return fmt.Errorf("unknown TaskUsageStat 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 *TaskUsageStatMutation) ResetField(name string) error {
switch name {
case taskusagestat.FieldTaskID:
m.ResetTaskID()
return nil
case taskusagestat.FieldUserID:
m.ResetUserID()
return nil
case taskusagestat.FieldModel:
m.ResetModel()
return nil
case taskusagestat.FieldInputTokens:
m.ResetInputTokens()
return nil
case taskusagestat.FieldOutputTokens:
m.ResetOutputTokens()
return nil
case taskusagestat.FieldTotalTokens:
m.ResetTotalTokens()
return nil
case taskusagestat.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown TaskUsageStat field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TaskUsageStatMutation) AddedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TaskUsageStatMutation) AddedIDs(name string) []ent.Value {
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TaskUsageStatMutation) RemovedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TaskUsageStatMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TaskUsageStatMutation) ClearedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TaskUsageStatMutation) EdgeCleared(name string) bool {
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 *TaskUsageStatMutation) ClearEdge(name string) error {
return fmt.Errorf("unknown TaskUsageStat 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 *TaskUsageStatMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown TaskUsageStat edge %s", name)
}
// TaskVirtualMachineMutation represents an operation that mutates the TaskVirtualMachine nodes in the graph.
type TaskVirtualMachineMutation struct {
config
op Op
typ string
id *uuid.UUID
created_at *time.Time
clearedFields map[string]struct{}
task *uuid.UUID
clearedtask bool
virtualmachine *string
clearedvirtualmachine bool
done bool
oldValue func(context.Context) (*TaskVirtualMachine, error)
predicates []predicate.TaskVirtualMachine
}
var _ ent.Mutation = (*TaskVirtualMachineMutation)(nil)
// taskvirtualmachineOption allows management of the mutation configuration using functional options.
type taskvirtualmachineOption func(*TaskVirtualMachineMutation)
// newTaskVirtualMachineMutation creates new mutation for the TaskVirtualMachine entity.
func newTaskVirtualMachineMutation(c config, op Op, opts ...taskvirtualmachineOption) *TaskVirtualMachineMutation {
m := &TaskVirtualMachineMutation{
config: c,
op: op,
typ: TypeTaskVirtualMachine,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTaskVirtualMachineID sets the ID field of the mutation.
func withTaskVirtualMachineID(id uuid.UUID) taskvirtualmachineOption {
return func(m *TaskVirtualMachineMutation) {
var (
err error
once sync.Once
value *TaskVirtualMachine
)
m.oldValue = func(ctx context.Context) (*TaskVirtualMachine, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TaskVirtualMachine.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTaskVirtualMachine sets the old TaskVirtualMachine of the mutation.
func withTaskVirtualMachine(node *TaskVirtualMachine) taskvirtualmachineOption {
return func(m *TaskVirtualMachineMutation) {
m.oldValue = func(context.Context) (*TaskVirtualMachine, 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 TaskVirtualMachineMutation) 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 TaskVirtualMachineMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TaskVirtualMachine entities.
func (m *TaskVirtualMachineMutation) SetID(id uuid.UUID) {
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 *TaskVirtualMachineMutation) ID() (id uuid.UUID, 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 *TaskVirtualMachineMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TaskVirtualMachine.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetTaskID sets the "task_id" field.
func (m *TaskVirtualMachineMutation) SetTaskID(u uuid.UUID) {
m.task = &u
}
// TaskID returns the value of the "task_id" field in the mutation.
func (m *TaskVirtualMachineMutation) TaskID() (r uuid.UUID, exists bool) {
v := m.task
if v == nil {
return
}
return *v, true
}
// OldTaskID returns the old "task_id" field's value of the TaskVirtualMachine entity.
// If the TaskVirtualMachine 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 *TaskVirtualMachineMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTaskID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
}
return oldValue.TaskID, nil
}
// ResetTaskID resets all changes to the "task_id" field.
func (m *TaskVirtualMachineMutation) ResetTaskID() {
m.task = nil
}
// SetVirtualmachineID sets the "virtualmachine_id" field.
func (m *TaskVirtualMachineMutation) SetVirtualmachineID(s string) {
m.virtualmachine = &s
}
// VirtualmachineID returns the value of the "virtualmachine_id" field in the mutation.
func (m *TaskVirtualMachineMutation) VirtualmachineID() (r string, exists bool) {
v := m.virtualmachine
if v == nil {
return
}
return *v, true
}
// OldVirtualmachineID returns the old "virtualmachine_id" field's value of the TaskVirtualMachine entity.
// If the TaskVirtualMachine 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 *TaskVirtualMachineMutation) OldVirtualmachineID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldVirtualmachineID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldVirtualmachineID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldVirtualmachineID: %w", err)
}
return oldValue.VirtualmachineID, nil
}
// ResetVirtualmachineID resets all changes to the "virtualmachine_id" field.
func (m *TaskVirtualMachineMutation) ResetVirtualmachineID() {
m.virtualmachine = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TaskVirtualMachineMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TaskVirtualMachineMutation) 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 TaskVirtualMachine entity.
// If the TaskVirtualMachine 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 *TaskVirtualMachineMutation) 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 *TaskVirtualMachineMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearTask clears the "task" edge to the Task entity.
func (m *TaskVirtualMachineMutation) ClearTask() {
m.clearedtask = true
m.clearedFields[taskvirtualmachine.FieldTaskID] = struct{}{}
}
// TaskCleared reports if the "task" edge to the Task entity was cleared.
func (m *TaskVirtualMachineMutation) TaskCleared() bool {
return m.clearedtask
}
// TaskIDs returns the "task" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// TaskID instead. It exists only for internal usage by the builders.
func (m *TaskVirtualMachineMutation) TaskIDs() (ids []uuid.UUID) {
if id := m.task; id != nil {
ids = append(ids, *id)
}
return
}
// ResetTask resets all changes to the "task" edge.
func (m *TaskVirtualMachineMutation) ResetTask() {
m.task = nil
m.clearedtask = false
}
// ClearVirtualmachine clears the "virtualmachine" edge to the VirtualMachine entity.
func (m *TaskVirtualMachineMutation) ClearVirtualmachine() {
m.clearedvirtualmachine = true
m.clearedFields[taskvirtualmachine.FieldVirtualmachineID] = struct{}{}
}
// VirtualmachineCleared reports if the "virtualmachine" edge to the VirtualMachine entity was cleared.
func (m *TaskVirtualMachineMutation) VirtualmachineCleared() bool {
return m.clearedvirtualmachine
}
// VirtualmachineIDs returns the "virtualmachine" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// VirtualmachineID instead. It exists only for internal usage by the builders.
func (m *TaskVirtualMachineMutation) VirtualmachineIDs() (ids []string) {
if id := m.virtualmachine; id != nil {
ids = append(ids, *id)
}
return
}
// ResetVirtualmachine resets all changes to the "virtualmachine" edge.
func (m *TaskVirtualMachineMutation) ResetVirtualmachine() {
m.virtualmachine = nil
m.clearedvirtualmachine = false
}
// Where appends a list predicates to the TaskVirtualMachineMutation builder.
func (m *TaskVirtualMachineMutation) Where(ps ...predicate.TaskVirtualMachine) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TaskVirtualMachineMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TaskVirtualMachineMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TaskVirtualMachine, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TaskVirtualMachineMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TaskVirtualMachineMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TaskVirtualMachine).
func (m *TaskVirtualMachineMutation) 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 *TaskVirtualMachineMutation) Fields() []string {
fields := make([]string, 0, 3)
if m.task != nil {
fields = append(fields, taskvirtualmachine.FieldTaskID)
}
if m.virtualmachine != nil {
fields = append(fields, taskvirtualmachine.FieldVirtualmachineID)
}
if m.created_at != nil {
fields = append(fields, taskvirtualmachine.FieldCreatedAt)
}
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 *TaskVirtualMachineMutation) Field(name string) (ent.Value, bool) {
switch name {
case taskvirtualmachine.FieldTaskID:
return m.TaskID()
case taskvirtualmachine.FieldVirtualmachineID:
return m.VirtualmachineID()
case taskvirtualmachine.FieldCreatedAt:
return m.CreatedAt()
}
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 *TaskVirtualMachineMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case taskvirtualmachine.FieldTaskID:
return m.OldTaskID(ctx)
case taskvirtualmachine.FieldVirtualmachineID:
return m.OldVirtualmachineID(ctx)
case taskvirtualmachine.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown TaskVirtualMachine 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 *TaskVirtualMachineMutation) SetField(name string, value ent.Value) error {
switch name {
case taskvirtualmachine.FieldTaskID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTaskID(v)
return nil
case taskvirtualmachine.FieldVirtualmachineID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetVirtualmachineID(v)
return nil
case taskvirtualmachine.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown TaskVirtualMachine field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TaskVirtualMachineMutation) AddedFields() []string {
return nil
}
// 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 *TaskVirtualMachineMutation) AddedField(name string) (ent.Value, bool) {
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 *TaskVirtualMachineMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TaskVirtualMachine numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TaskVirtualMachineMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TaskVirtualMachineMutation) 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 *TaskVirtualMachineMutation) ClearField(name string) error {
return fmt.Errorf("unknown TaskVirtualMachine 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 *TaskVirtualMachineMutation) ResetField(name string) error {
switch name {
case taskvirtualmachine.FieldTaskID:
m.ResetTaskID()
return nil
case taskvirtualmachine.FieldVirtualmachineID:
m.ResetVirtualmachineID()
return nil
case taskvirtualmachine.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown TaskVirtualMachine field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TaskVirtualMachineMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.task != nil {
edges = append(edges, taskvirtualmachine.EdgeTask)
}
if m.virtualmachine != nil {
edges = append(edges, taskvirtualmachine.EdgeVirtualmachine)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TaskVirtualMachineMutation) AddedIDs(name string) []ent.Value {
switch name {
case taskvirtualmachine.EdgeTask:
if id := m.task; id != nil {
return []ent.Value{*id}
}
case taskvirtualmachine.EdgeVirtualmachine:
if id := m.virtualmachine; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TaskVirtualMachineMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TaskVirtualMachineMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TaskVirtualMachineMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedtask {
edges = append(edges, taskvirtualmachine.EdgeTask)
}
if m.clearedvirtualmachine {
edges = append(edges, taskvirtualmachine.EdgeVirtualmachine)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TaskVirtualMachineMutation) EdgeCleared(name string) bool {
switch name {
case taskvirtualmachine.EdgeTask:
return m.clearedtask
case taskvirtualmachine.EdgeVirtualmachine:
return m.clearedvirtualmachine
}
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 *TaskVirtualMachineMutation) ClearEdge(name string) error {
switch name {
case taskvirtualmachine.EdgeTask:
m.ClearTask()
return nil
case taskvirtualmachine.EdgeVirtualmachine:
m.ClearVirtualmachine()
return nil
}
return fmt.Errorf("unknown TaskVirtualMachine 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 *TaskVirtualMachineMutation) ResetEdge(name string) error {
switch name {
case taskvirtualmachine.EdgeTask:
m.ResetTask()
return nil
case taskvirtualmachine.EdgeVirtualmachine:
m.ResetVirtualmachine()
return nil
}
return fmt.Errorf("unknown TaskVirtualMachine edge %s", name)
}
// TeamMutation represents an operation that mutates the Team nodes in the graph.
type TeamMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
name *string
member_limit *int
addmember_limit *int
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
groups map[uuid.UUID]struct{}
removedgroups map[uuid.UUID]struct{}
clearedgroups bool
members map[uuid.UUID]struct{}
removedmembers map[uuid.UUID]struct{}
clearedmembers bool
models map[uuid.UUID]struct{}
removedmodels map[uuid.UUID]struct{}
clearedmodels bool
images map[uuid.UUID]struct{}
removedimages map[uuid.UUID]struct{}
clearedimages bool
team_members map[uuid.UUID]struct{}
removedteam_members map[uuid.UUID]struct{}
clearedteam_members bool
team_models map[uuid.UUID]struct{}
removedteam_models map[uuid.UUID]struct{}
clearedteam_models bool
team_images map[uuid.UUID]struct{}
removedteam_images map[uuid.UUID]struct{}
clearedteam_images bool
done bool
oldValue func(context.Context) (*Team, error)
predicates []predicate.Team
}
var _ ent.Mutation = (*TeamMutation)(nil)
// teamOption allows management of the mutation configuration using functional options.
type teamOption func(*TeamMutation)
// newTeamMutation creates new mutation for the Team entity.
func newTeamMutation(c config, op Op, opts ...teamOption) *TeamMutation {
m := &TeamMutation{
config: c,
op: op,
typ: TypeTeam,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTeamID sets the ID field of the mutation.
func withTeamID(id uuid.UUID) teamOption {
return func(m *TeamMutation) {
var (
err error
once sync.Once
value *Team
)
m.oldValue = func(ctx context.Context) (*Team, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Team.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTeam sets the old Team of the mutation.
func withTeam(node *Team) teamOption {
return func(m *TeamMutation) {
m.oldValue = func(context.Context) (*Team, 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 TeamMutation) 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 TeamMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 Team entities.
func (m *TeamMutation) SetID(id uuid.UUID) {
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 *TeamMutation) ID() (id uuid.UUID, 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 *TeamMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().Team.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *TeamMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *TeamMutation) 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 Team entity.
// If the Team 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 *TeamMutation) 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 *TeamMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[team.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *TeamMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[team.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *TeamMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, team.FieldDeletedAt)
}
// SetName sets the "name" field.
func (m *TeamMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *TeamMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the Team entity.
// If the Team 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 *TeamMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldName: %w", err)
}
return oldValue.Name, nil
}
// ResetName resets all changes to the "name" field.
func (m *TeamMutation) ResetName() {
m.name = nil
}
// SetMemberLimit sets the "member_limit" field.
func (m *TeamMutation) SetMemberLimit(i int) {
m.member_limit = &i
m.addmember_limit = nil
}
// MemberLimit returns the value of the "member_limit" field in the mutation.
func (m *TeamMutation) MemberLimit() (r int, exists bool) {
v := m.member_limit
if v == nil {
return
}
return *v, true
}
// OldMemberLimit returns the old "member_limit" field's value of the Team entity.
// If the Team 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 *TeamMutation) OldMemberLimit(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMemberLimit is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldMemberLimit requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMemberLimit: %w", err)
}
return oldValue.MemberLimit, nil
}
// AddMemberLimit adds i to the "member_limit" field.
func (m *TeamMutation) AddMemberLimit(i int) {
if m.addmember_limit != nil {
*m.addmember_limit += i
} else {
m.addmember_limit = &i
}
}
// AddedMemberLimit returns the value that was added to the "member_limit" field in this mutation.
func (m *TeamMutation) AddedMemberLimit() (r int, exists bool) {
v := m.addmember_limit
if v == nil {
return
}
return *v, true
}
// ResetMemberLimit resets all changes to the "member_limit" field.
func (m *TeamMutation) ResetMemberLimit() {
m.member_limit = nil
m.addmember_limit = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TeamMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TeamMutation) 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 Team entity.
// If the Team 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 *TeamMutation) 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 *TeamMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *TeamMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *TeamMutation) 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 Team entity.
// If the Team 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 *TeamMutation) 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 *TeamMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids.
func (m *TeamMutation) AddGroupIDs(ids ...uuid.UUID) {
if m.groups == nil {
m.groups = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.groups[ids[i]] = struct{}{}
}
}
// ClearGroups clears the "groups" edge to the TeamGroup entity.
func (m *TeamMutation) ClearGroups() {
m.clearedgroups = true
}
// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared.
func (m *TeamMutation) GroupsCleared() bool {
return m.clearedgroups
}
// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs.
func (m *TeamMutation) RemoveGroupIDs(ids ...uuid.UUID) {
if m.removedgroups == nil {
m.removedgroups = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.groups, ids[i])
m.removedgroups[ids[i]] = struct{}{}
}
}
// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity.
func (m *TeamMutation) RemovedGroupsIDs() (ids []uuid.UUID) {
for id := range m.removedgroups {
ids = append(ids, id)
}
return
}
// GroupsIDs returns the "groups" edge IDs in the mutation.
func (m *TeamMutation) GroupsIDs() (ids []uuid.UUID) {
for id := range m.groups {
ids = append(ids, id)
}
return
}
// ResetGroups resets all changes to the "groups" edge.
func (m *TeamMutation) ResetGroups() {
m.groups = nil
m.clearedgroups = false
m.removedgroups = nil
}
// AddMemberIDs adds the "members" edge to the User entity by ids.
func (m *TeamMutation) AddMemberIDs(ids ...uuid.UUID) {
if m.members == nil {
m.members = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.members[ids[i]] = struct{}{}
}
}
// ClearMembers clears the "members" edge to the User entity.
func (m *TeamMutation) ClearMembers() {
m.clearedmembers = true
}
// MembersCleared reports if the "members" edge to the User entity was cleared.
func (m *TeamMutation) MembersCleared() bool {
return m.clearedmembers
}
// RemoveMemberIDs removes the "members" edge to the User entity by IDs.
func (m *TeamMutation) RemoveMemberIDs(ids ...uuid.UUID) {
if m.removedmembers == nil {
m.removedmembers = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.members, ids[i])
m.removedmembers[ids[i]] = struct{}{}
}
}
// RemovedMembers returns the removed IDs of the "members" edge to the User entity.
func (m *TeamMutation) RemovedMembersIDs() (ids []uuid.UUID) {
for id := range m.removedmembers {
ids = append(ids, id)
}
return
}
// MembersIDs returns the "members" edge IDs in the mutation.
func (m *TeamMutation) MembersIDs() (ids []uuid.UUID) {
for id := range m.members {
ids = append(ids, id)
}
return
}
// ResetMembers resets all changes to the "members" edge.
func (m *TeamMutation) ResetMembers() {
m.members = nil
m.clearedmembers = false
m.removedmembers = nil
}
// AddModelIDs adds the "models" edge to the Model entity by ids.
func (m *TeamMutation) AddModelIDs(ids ...uuid.UUID) {
if m.models == nil {
m.models = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.models[ids[i]] = struct{}{}
}
}
// ClearModels clears the "models" edge to the Model entity.
func (m *TeamMutation) ClearModels() {
m.clearedmodels = true
}
// ModelsCleared reports if the "models" edge to the Model entity was cleared.
func (m *TeamMutation) ModelsCleared() bool {
return m.clearedmodels
}
// RemoveModelIDs removes the "models" edge to the Model entity by IDs.
func (m *TeamMutation) RemoveModelIDs(ids ...uuid.UUID) {
if m.removedmodels == nil {
m.removedmodels = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.models, ids[i])
m.removedmodels[ids[i]] = struct{}{}
}
}
// RemovedModels returns the removed IDs of the "models" edge to the Model entity.
func (m *TeamMutation) RemovedModelsIDs() (ids []uuid.UUID) {
for id := range m.removedmodels {
ids = append(ids, id)
}
return
}
// ModelsIDs returns the "models" edge IDs in the mutation.
func (m *TeamMutation) ModelsIDs() (ids []uuid.UUID) {
for id := range m.models {
ids = append(ids, id)
}
return
}
// ResetModels resets all changes to the "models" edge.
func (m *TeamMutation) ResetModels() {
m.models = nil
m.clearedmodels = false
m.removedmodels = nil
}
// AddImageIDs adds the "images" edge to the Image entity by ids.
func (m *TeamMutation) AddImageIDs(ids ...uuid.UUID) {
if m.images == nil {
m.images = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.images[ids[i]] = struct{}{}
}
}
// ClearImages clears the "images" edge to the Image entity.
func (m *TeamMutation) ClearImages() {
m.clearedimages = true
}
// ImagesCleared reports if the "images" edge to the Image entity was cleared.
func (m *TeamMutation) ImagesCleared() bool {
return m.clearedimages
}
// RemoveImageIDs removes the "images" edge to the Image entity by IDs.
func (m *TeamMutation) RemoveImageIDs(ids ...uuid.UUID) {
if m.removedimages == nil {
m.removedimages = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.images, ids[i])
m.removedimages[ids[i]] = struct{}{}
}
}
// RemovedImages returns the removed IDs of the "images" edge to the Image entity.
func (m *TeamMutation) RemovedImagesIDs() (ids []uuid.UUID) {
for id := range m.removedimages {
ids = append(ids, id)
}
return
}
// ImagesIDs returns the "images" edge IDs in the mutation.
func (m *TeamMutation) ImagesIDs() (ids []uuid.UUID) {
for id := range m.images {
ids = append(ids, id)
}
return
}
// ResetImages resets all changes to the "images" edge.
func (m *TeamMutation) ResetImages() {
m.images = nil
m.clearedimages = false
m.removedimages = nil
}
// AddTeamMemberIDs adds the "team_members" edge to the TeamMember entity by ids.
func (m *TeamMutation) AddTeamMemberIDs(ids ...uuid.UUID) {
if m.team_members == nil {
m.team_members = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_members[ids[i]] = struct{}{}
}
}
// ClearTeamMembers clears the "team_members" edge to the TeamMember entity.
func (m *TeamMutation) ClearTeamMembers() {
m.clearedteam_members = true
}
// TeamMembersCleared reports if the "team_members" edge to the TeamMember entity was cleared.
func (m *TeamMutation) TeamMembersCleared() bool {
return m.clearedteam_members
}
// RemoveTeamMemberIDs removes the "team_members" edge to the TeamMember entity by IDs.
func (m *TeamMutation) RemoveTeamMemberIDs(ids ...uuid.UUID) {
if m.removedteam_members == nil {
m.removedteam_members = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_members, ids[i])
m.removedteam_members[ids[i]] = struct{}{}
}
}
// RemovedTeamMembers returns the removed IDs of the "team_members" edge to the TeamMember entity.
func (m *TeamMutation) RemovedTeamMembersIDs() (ids []uuid.UUID) {
for id := range m.removedteam_members {
ids = append(ids, id)
}
return
}
// TeamMembersIDs returns the "team_members" edge IDs in the mutation.
func (m *TeamMutation) TeamMembersIDs() (ids []uuid.UUID) {
for id := range m.team_members {
ids = append(ids, id)
}
return
}
// ResetTeamMembers resets all changes to the "team_members" edge.
func (m *TeamMutation) ResetTeamMembers() {
m.team_members = nil
m.clearedteam_members = false
m.removedteam_members = nil
}
// AddTeamModelIDs adds the "team_models" edge to the TeamModel entity by ids.
func (m *TeamMutation) AddTeamModelIDs(ids ...uuid.UUID) {
if m.team_models == nil {
m.team_models = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_models[ids[i]] = struct{}{}
}
}
// ClearTeamModels clears the "team_models" edge to the TeamModel entity.
func (m *TeamMutation) ClearTeamModels() {
m.clearedteam_models = true
}
// TeamModelsCleared reports if the "team_models" edge to the TeamModel entity was cleared.
func (m *TeamMutation) TeamModelsCleared() bool {
return m.clearedteam_models
}
// RemoveTeamModelIDs removes the "team_models" edge to the TeamModel entity by IDs.
func (m *TeamMutation) RemoveTeamModelIDs(ids ...uuid.UUID) {
if m.removedteam_models == nil {
m.removedteam_models = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_models, ids[i])
m.removedteam_models[ids[i]] = struct{}{}
}
}
// RemovedTeamModels returns the removed IDs of the "team_models" edge to the TeamModel entity.
func (m *TeamMutation) RemovedTeamModelsIDs() (ids []uuid.UUID) {
for id := range m.removedteam_models {
ids = append(ids, id)
}
return
}
// TeamModelsIDs returns the "team_models" edge IDs in the mutation.
func (m *TeamMutation) TeamModelsIDs() (ids []uuid.UUID) {
for id := range m.team_models {
ids = append(ids, id)
}
return
}
// ResetTeamModels resets all changes to the "team_models" edge.
func (m *TeamMutation) ResetTeamModels() {
m.team_models = nil
m.clearedteam_models = false
m.removedteam_models = nil
}
// AddTeamImageIDs adds the "team_images" edge to the TeamImage entity by ids.
func (m *TeamMutation) AddTeamImageIDs(ids ...uuid.UUID) {
if m.team_images == nil {
m.team_images = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_images[ids[i]] = struct{}{}
}
}
// ClearTeamImages clears the "team_images" edge to the TeamImage entity.
func (m *TeamMutation) ClearTeamImages() {
m.clearedteam_images = true
}
// TeamImagesCleared reports if the "team_images" edge to the TeamImage entity was cleared.
func (m *TeamMutation) TeamImagesCleared() bool {
return m.clearedteam_images
}
// RemoveTeamImageIDs removes the "team_images" edge to the TeamImage entity by IDs.
func (m *TeamMutation) RemoveTeamImageIDs(ids ...uuid.UUID) {
if m.removedteam_images == nil {
m.removedteam_images = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_images, ids[i])
m.removedteam_images[ids[i]] = struct{}{}
}
}
// RemovedTeamImages returns the removed IDs of the "team_images" edge to the TeamImage entity.
func (m *TeamMutation) RemovedTeamImagesIDs() (ids []uuid.UUID) {
for id := range m.removedteam_images {
ids = append(ids, id)
}
return
}
// TeamImagesIDs returns the "team_images" edge IDs in the mutation.
func (m *TeamMutation) TeamImagesIDs() (ids []uuid.UUID) {
for id := range m.team_images {
ids = append(ids, id)
}
return
}
// ResetTeamImages resets all changes to the "team_images" edge.
func (m *TeamMutation) ResetTeamImages() {
m.team_images = nil
m.clearedteam_images = false
m.removedteam_images = nil
}
// Where appends a list predicates to the TeamMutation builder.
func (m *TeamMutation) Where(ps ...predicate.Team) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TeamMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TeamMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Team, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TeamMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TeamMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Team).
func (m *TeamMutation) 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 *TeamMutation) Fields() []string {
fields := make([]string, 0, 5)
if m.deleted_at != nil {
fields = append(fields, team.FieldDeletedAt)
}
if m.name != nil {
fields = append(fields, team.FieldName)
}
if m.member_limit != nil {
fields = append(fields, team.FieldMemberLimit)
}
if m.created_at != nil {
fields = append(fields, team.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, team.FieldUpdatedAt)
}
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 *TeamMutation) Field(name string) (ent.Value, bool) {
switch name {
case team.FieldDeletedAt:
return m.DeletedAt()
case team.FieldName:
return m.Name()
case team.FieldMemberLimit:
return m.MemberLimit()
case team.FieldCreatedAt:
return m.CreatedAt()
case team.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *TeamMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case team.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case team.FieldName:
return m.OldName(ctx)
case team.FieldMemberLimit:
return m.OldMemberLimit(ctx)
case team.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case team.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown Team 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 *TeamMutation) SetField(name string, value ent.Value) error {
switch name {
case team.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 team.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case team.FieldMemberLimit:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMemberLimit(v)
return nil
case team.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 team.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown Team field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TeamMutation) AddedFields() []string {
var fields []string
if m.addmember_limit != nil {
fields = append(fields, team.FieldMemberLimit)
}
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 *TeamMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case team.FieldMemberLimit:
return m.AddedMemberLimit()
}
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 *TeamMutation) AddField(name string, value ent.Value) error {
switch name {
case team.FieldMemberLimit:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMemberLimit(v)
return nil
}
return fmt.Errorf("unknown Team numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TeamMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(team.FieldDeletedAt) {
fields = append(fields, team.FieldDeletedAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TeamMutation) 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 *TeamMutation) ClearField(name string) error {
switch name {
case team.FieldDeletedAt:
m.ClearDeletedAt()
return nil
}
return fmt.Errorf("unknown Team 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 *TeamMutation) ResetField(name string) error {
switch name {
case team.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case team.FieldName:
m.ResetName()
return nil
case team.FieldMemberLimit:
m.ResetMemberLimit()
return nil
case team.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case team.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown Team field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TeamMutation) AddedEdges() []string {
edges := make([]string, 0, 7)
if m.groups != nil {
edges = append(edges, team.EdgeGroups)
}
if m.members != nil {
edges = append(edges, team.EdgeMembers)
}
if m.models != nil {
edges = append(edges, team.EdgeModels)
}
if m.images != nil {
edges = append(edges, team.EdgeImages)
}
if m.team_members != nil {
edges = append(edges, team.EdgeTeamMembers)
}
if m.team_models != nil {
edges = append(edges, team.EdgeTeamModels)
}
if m.team_images != nil {
edges = append(edges, team.EdgeTeamImages)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TeamMutation) AddedIDs(name string) []ent.Value {
switch name {
case team.EdgeGroups:
ids := make([]ent.Value, 0, len(m.groups))
for id := range m.groups {
ids = append(ids, id)
}
return ids
case team.EdgeMembers:
ids := make([]ent.Value, 0, len(m.members))
for id := range m.members {
ids = append(ids, id)
}
return ids
case team.EdgeModels:
ids := make([]ent.Value, 0, len(m.models))
for id := range m.models {
ids = append(ids, id)
}
return ids
case team.EdgeImages:
ids := make([]ent.Value, 0, len(m.images))
for id := range m.images {
ids = append(ids, id)
}
return ids
case team.EdgeTeamMembers:
ids := make([]ent.Value, 0, len(m.team_members))
for id := range m.team_members {
ids = append(ids, id)
}
return ids
case team.EdgeTeamModels:
ids := make([]ent.Value, 0, len(m.team_models))
for id := range m.team_models {
ids = append(ids, id)
}
return ids
case team.EdgeTeamImages:
ids := make([]ent.Value, 0, len(m.team_images))
for id := range m.team_images {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TeamMutation) RemovedEdges() []string {
edges := make([]string, 0, 7)
if m.removedgroups != nil {
edges = append(edges, team.EdgeGroups)
}
if m.removedmembers != nil {
edges = append(edges, team.EdgeMembers)
}
if m.removedmodels != nil {
edges = append(edges, team.EdgeModels)
}
if m.removedimages != nil {
edges = append(edges, team.EdgeImages)
}
if m.removedteam_members != nil {
edges = append(edges, team.EdgeTeamMembers)
}
if m.removedteam_models != nil {
edges = append(edges, team.EdgeTeamModels)
}
if m.removedteam_images != nil {
edges = append(edges, team.EdgeTeamImages)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TeamMutation) RemovedIDs(name string) []ent.Value {
switch name {
case team.EdgeGroups:
ids := make([]ent.Value, 0, len(m.removedgroups))
for id := range m.removedgroups {
ids = append(ids, id)
}
return ids
case team.EdgeMembers:
ids := make([]ent.Value, 0, len(m.removedmembers))
for id := range m.removedmembers {
ids = append(ids, id)
}
return ids
case team.EdgeModels:
ids := make([]ent.Value, 0, len(m.removedmodels))
for id := range m.removedmodels {
ids = append(ids, id)
}
return ids
case team.EdgeImages:
ids := make([]ent.Value, 0, len(m.removedimages))
for id := range m.removedimages {
ids = append(ids, id)
}
return ids
case team.EdgeTeamMembers:
ids := make([]ent.Value, 0, len(m.removedteam_members))
for id := range m.removedteam_members {
ids = append(ids, id)
}
return ids
case team.EdgeTeamModels:
ids := make([]ent.Value, 0, len(m.removedteam_models))
for id := range m.removedteam_models {
ids = append(ids, id)
}
return ids
case team.EdgeTeamImages:
ids := make([]ent.Value, 0, len(m.removedteam_images))
for id := range m.removedteam_images {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TeamMutation) ClearedEdges() []string {
edges := make([]string, 0, 7)
if m.clearedgroups {
edges = append(edges, team.EdgeGroups)
}
if m.clearedmembers {
edges = append(edges, team.EdgeMembers)
}
if m.clearedmodels {
edges = append(edges, team.EdgeModels)
}
if m.clearedimages {
edges = append(edges, team.EdgeImages)
}
if m.clearedteam_members {
edges = append(edges, team.EdgeTeamMembers)
}
if m.clearedteam_models {
edges = append(edges, team.EdgeTeamModels)
}
if m.clearedteam_images {
edges = append(edges, team.EdgeTeamImages)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TeamMutation) EdgeCleared(name string) bool {
switch name {
case team.EdgeGroups:
return m.clearedgroups
case team.EdgeMembers:
return m.clearedmembers
case team.EdgeModels:
return m.clearedmodels
case team.EdgeImages:
return m.clearedimages
case team.EdgeTeamMembers:
return m.clearedteam_members
case team.EdgeTeamModels:
return m.clearedteam_models
case team.EdgeTeamImages:
return m.clearedteam_images
}
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 *TeamMutation) ClearEdge(name string) error {
switch name {
}
return fmt.Errorf("unknown Team 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 *TeamMutation) ResetEdge(name string) error {
switch name {
case team.EdgeGroups:
m.ResetGroups()
return nil
case team.EdgeMembers:
m.ResetMembers()
return nil
case team.EdgeModels:
m.ResetModels()
return nil
case team.EdgeImages:
m.ResetImages()
return nil
case team.EdgeTeamMembers:
m.ResetTeamMembers()
return nil
case team.EdgeTeamModels:
m.ResetTeamModels()
return nil
case team.EdgeTeamImages:
m.ResetTeamImages()
return nil
}
return fmt.Errorf("unknown Team edge %s", name)
}
// TeamGroupMutation represents an operation that mutates the TeamGroup nodes in the graph.
type TeamGroupMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
name *string
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
members map[uuid.UUID]struct{}
removedmembers map[uuid.UUID]struct{}
clearedmembers bool
team *uuid.UUID
clearedteam bool
models map[uuid.UUID]struct{}
removedmodels map[uuid.UUID]struct{}
clearedmodels bool
images map[uuid.UUID]struct{}
removedimages map[uuid.UUID]struct{}
clearedimages bool
hosts map[string]struct{}
removedhosts map[string]struct{}
clearedhosts bool
team_group_members map[uuid.UUID]struct{}
removedteam_group_members map[uuid.UUID]struct{}
clearedteam_group_members bool
team_group_models map[uuid.UUID]struct{}
removedteam_group_models map[uuid.UUID]struct{}
clearedteam_group_models bool
team_group_images map[uuid.UUID]struct{}
removedteam_group_images map[uuid.UUID]struct{}
clearedteam_group_images bool
team_group_hosts map[uuid.UUID]struct{}
removedteam_group_hosts map[uuid.UUID]struct{}
clearedteam_group_hosts bool
done bool
oldValue func(context.Context) (*TeamGroup, error)
predicates []predicate.TeamGroup
}
var _ ent.Mutation = (*TeamGroupMutation)(nil)
// teamgroupOption allows management of the mutation configuration using functional options.
type teamgroupOption func(*TeamGroupMutation)
// newTeamGroupMutation creates new mutation for the TeamGroup entity.
func newTeamGroupMutation(c config, op Op, opts ...teamgroupOption) *TeamGroupMutation {
m := &TeamGroupMutation{
config: c,
op: op,
typ: TypeTeamGroup,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTeamGroupID sets the ID field of the mutation.
func withTeamGroupID(id uuid.UUID) teamgroupOption {
return func(m *TeamGroupMutation) {
var (
err error
once sync.Once
value *TeamGroup
)
m.oldValue = func(ctx context.Context) (*TeamGroup, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TeamGroup.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTeamGroup sets the old TeamGroup of the mutation.
func withTeamGroup(node *TeamGroup) teamgroupOption {
return func(m *TeamGroupMutation) {
m.oldValue = func(context.Context) (*TeamGroup, 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 TeamGroupMutation) 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 TeamGroupMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TeamGroup entities.
func (m *TeamGroupMutation) SetID(id uuid.UUID) {
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 *TeamGroupMutation) ID() (id uuid.UUID, 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 *TeamGroupMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TeamGroup.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *TeamGroupMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *TeamGroupMutation) 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 TeamGroup entity.
// If the TeamGroup 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 *TeamGroupMutation) 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 *TeamGroupMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[teamgroup.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *TeamGroupMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[teamgroup.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *TeamGroupMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, teamgroup.FieldDeletedAt)
}
// SetTeamID sets the "team_id" field.
func (m *TeamGroupMutation) SetTeamID(u uuid.UUID) {
m.team = &u
}
// TeamID returns the value of the "team_id" field in the mutation.
func (m *TeamGroupMutation) TeamID() (r uuid.UUID, exists bool) {
v := m.team
if v == nil {
return
}
return *v, true
}
// OldTeamID returns the old "team_id" field's value of the TeamGroup entity.
// If the TeamGroup 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 *TeamGroupMutation) OldTeamID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTeamID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTeamID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTeamID: %w", err)
}
return oldValue.TeamID, nil
}
// ResetTeamID resets all changes to the "team_id" field.
func (m *TeamGroupMutation) ResetTeamID() {
m.team = nil
}
// SetName sets the "name" field.
func (m *TeamGroupMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *TeamGroupMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the TeamGroup entity.
// If the TeamGroup 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 *TeamGroupMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldName: %w", err)
}
return oldValue.Name, nil
}
// ResetName resets all changes to the "name" field.
func (m *TeamGroupMutation) ResetName() {
m.name = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TeamGroupMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TeamGroupMutation) 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 TeamGroup entity.
// If the TeamGroup 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 *TeamGroupMutation) 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 *TeamGroupMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *TeamGroupMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *TeamGroupMutation) 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 TeamGroup entity.
// If the TeamGroup 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 *TeamGroupMutation) 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 *TeamGroupMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// AddMemberIDs adds the "members" edge to the User entity by ids.
func (m *TeamGroupMutation) AddMemberIDs(ids ...uuid.UUID) {
if m.members == nil {
m.members = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.members[ids[i]] = struct{}{}
}
}
// ClearMembers clears the "members" edge to the User entity.
func (m *TeamGroupMutation) ClearMembers() {
m.clearedmembers = true
}
// MembersCleared reports if the "members" edge to the User entity was cleared.
func (m *TeamGroupMutation) MembersCleared() bool {
return m.clearedmembers
}
// RemoveMemberIDs removes the "members" edge to the User entity by IDs.
func (m *TeamGroupMutation) RemoveMemberIDs(ids ...uuid.UUID) {
if m.removedmembers == nil {
m.removedmembers = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.members, ids[i])
m.removedmembers[ids[i]] = struct{}{}
}
}
// RemovedMembers returns the removed IDs of the "members" edge to the User entity.
func (m *TeamGroupMutation) RemovedMembersIDs() (ids []uuid.UUID) {
for id := range m.removedmembers {
ids = append(ids, id)
}
return
}
// MembersIDs returns the "members" edge IDs in the mutation.
func (m *TeamGroupMutation) MembersIDs() (ids []uuid.UUID) {
for id := range m.members {
ids = append(ids, id)
}
return
}
// ResetMembers resets all changes to the "members" edge.
func (m *TeamGroupMutation) ResetMembers() {
m.members = nil
m.clearedmembers = false
m.removedmembers = nil
}
// ClearTeam clears the "team" edge to the Team entity.
func (m *TeamGroupMutation) ClearTeam() {
m.clearedteam = true
m.clearedFields[teamgroup.FieldTeamID] = struct{}{}
}
// TeamCleared reports if the "team" edge to the Team entity was cleared.
func (m *TeamGroupMutation) TeamCleared() bool {
return m.clearedteam
}
// TeamIDs returns the "team" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// TeamID instead. It exists only for internal usage by the builders.
func (m *TeamGroupMutation) TeamIDs() (ids []uuid.UUID) {
if id := m.team; id != nil {
ids = append(ids, *id)
}
return
}
// ResetTeam resets all changes to the "team" edge.
func (m *TeamGroupMutation) ResetTeam() {
m.team = nil
m.clearedteam = false
}
// AddModelIDs adds the "models" edge to the Model entity by ids.
func (m *TeamGroupMutation) AddModelIDs(ids ...uuid.UUID) {
if m.models == nil {
m.models = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.models[ids[i]] = struct{}{}
}
}
// ClearModels clears the "models" edge to the Model entity.
func (m *TeamGroupMutation) ClearModels() {
m.clearedmodels = true
}
// ModelsCleared reports if the "models" edge to the Model entity was cleared.
func (m *TeamGroupMutation) ModelsCleared() bool {
return m.clearedmodels
}
// RemoveModelIDs removes the "models" edge to the Model entity by IDs.
func (m *TeamGroupMutation) RemoveModelIDs(ids ...uuid.UUID) {
if m.removedmodels == nil {
m.removedmodels = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.models, ids[i])
m.removedmodels[ids[i]] = struct{}{}
}
}
// RemovedModels returns the removed IDs of the "models" edge to the Model entity.
func (m *TeamGroupMutation) RemovedModelsIDs() (ids []uuid.UUID) {
for id := range m.removedmodels {
ids = append(ids, id)
}
return
}
// ModelsIDs returns the "models" edge IDs in the mutation.
func (m *TeamGroupMutation) ModelsIDs() (ids []uuid.UUID) {
for id := range m.models {
ids = append(ids, id)
}
return
}
// ResetModels resets all changes to the "models" edge.
func (m *TeamGroupMutation) ResetModels() {
m.models = nil
m.clearedmodels = false
m.removedmodels = nil
}
// AddImageIDs adds the "images" edge to the Image entity by ids.
func (m *TeamGroupMutation) AddImageIDs(ids ...uuid.UUID) {
if m.images == nil {
m.images = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.images[ids[i]] = struct{}{}
}
}
// ClearImages clears the "images" edge to the Image entity.
func (m *TeamGroupMutation) ClearImages() {
m.clearedimages = true
}
// ImagesCleared reports if the "images" edge to the Image entity was cleared.
func (m *TeamGroupMutation) ImagesCleared() bool {
return m.clearedimages
}
// RemoveImageIDs removes the "images" edge to the Image entity by IDs.
func (m *TeamGroupMutation) RemoveImageIDs(ids ...uuid.UUID) {
if m.removedimages == nil {
m.removedimages = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.images, ids[i])
m.removedimages[ids[i]] = struct{}{}
}
}
// RemovedImages returns the removed IDs of the "images" edge to the Image entity.
func (m *TeamGroupMutation) RemovedImagesIDs() (ids []uuid.UUID) {
for id := range m.removedimages {
ids = append(ids, id)
}
return
}
// ImagesIDs returns the "images" edge IDs in the mutation.
func (m *TeamGroupMutation) ImagesIDs() (ids []uuid.UUID) {
for id := range m.images {
ids = append(ids, id)
}
return
}
// ResetImages resets all changes to the "images" edge.
func (m *TeamGroupMutation) ResetImages() {
m.images = nil
m.clearedimages = false
m.removedimages = nil
}
// AddHostIDs adds the "hosts" edge to the Host entity by ids.
func (m *TeamGroupMutation) AddHostIDs(ids ...string) {
if m.hosts == nil {
m.hosts = make(map[string]struct{})
}
for i := range ids {
m.hosts[ids[i]] = struct{}{}
}
}
// ClearHosts clears the "hosts" edge to the Host entity.
func (m *TeamGroupMutation) ClearHosts() {
m.clearedhosts = true
}
// HostsCleared reports if the "hosts" edge to the Host entity was cleared.
func (m *TeamGroupMutation) HostsCleared() bool {
return m.clearedhosts
}
// RemoveHostIDs removes the "hosts" edge to the Host entity by IDs.
func (m *TeamGroupMutation) RemoveHostIDs(ids ...string) {
if m.removedhosts == nil {
m.removedhosts = make(map[string]struct{})
}
for i := range ids {
delete(m.hosts, ids[i])
m.removedhosts[ids[i]] = struct{}{}
}
}
// RemovedHosts returns the removed IDs of the "hosts" edge to the Host entity.
func (m *TeamGroupMutation) RemovedHostsIDs() (ids []string) {
for id := range m.removedhosts {
ids = append(ids, id)
}
return
}
// HostsIDs returns the "hosts" edge IDs in the mutation.
func (m *TeamGroupMutation) HostsIDs() (ids []string) {
for id := range m.hosts {
ids = append(ids, id)
}
return
}
// ResetHosts resets all changes to the "hosts" edge.
func (m *TeamGroupMutation) ResetHosts() {
m.hosts = nil
m.clearedhosts = false
m.removedhosts = nil
}
// AddTeamGroupMemberIDs adds the "team_group_members" edge to the TeamGroupMember entity by ids.
func (m *TeamGroupMutation) AddTeamGroupMemberIDs(ids ...uuid.UUID) {
if m.team_group_members == nil {
m.team_group_members = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_group_members[ids[i]] = struct{}{}
}
}
// ClearTeamGroupMembers clears the "team_group_members" edge to the TeamGroupMember entity.
func (m *TeamGroupMutation) ClearTeamGroupMembers() {
m.clearedteam_group_members = true
}
// TeamGroupMembersCleared reports if the "team_group_members" edge to the TeamGroupMember entity was cleared.
func (m *TeamGroupMutation) TeamGroupMembersCleared() bool {
return m.clearedteam_group_members
}
// RemoveTeamGroupMemberIDs removes the "team_group_members" edge to the TeamGroupMember entity by IDs.
func (m *TeamGroupMutation) RemoveTeamGroupMemberIDs(ids ...uuid.UUID) {
if m.removedteam_group_members == nil {
m.removedteam_group_members = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_group_members, ids[i])
m.removedteam_group_members[ids[i]] = struct{}{}
}
}
// RemovedTeamGroupMembers returns the removed IDs of the "team_group_members" edge to the TeamGroupMember entity.
func (m *TeamGroupMutation) RemovedTeamGroupMembersIDs() (ids []uuid.UUID) {
for id := range m.removedteam_group_members {
ids = append(ids, id)
}
return
}
// TeamGroupMembersIDs returns the "team_group_members" edge IDs in the mutation.
func (m *TeamGroupMutation) TeamGroupMembersIDs() (ids []uuid.UUID) {
for id := range m.team_group_members {
ids = append(ids, id)
}
return
}
// ResetTeamGroupMembers resets all changes to the "team_group_members" edge.
func (m *TeamGroupMutation) ResetTeamGroupMembers() {
m.team_group_members = nil
m.clearedteam_group_members = false
m.removedteam_group_members = nil
}
// AddTeamGroupModelIDs adds the "team_group_models" edge to the TeamGroupModel entity by ids.
func (m *TeamGroupMutation) AddTeamGroupModelIDs(ids ...uuid.UUID) {
if m.team_group_models == nil {
m.team_group_models = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_group_models[ids[i]] = struct{}{}
}
}
// ClearTeamGroupModels clears the "team_group_models" edge to the TeamGroupModel entity.
func (m *TeamGroupMutation) ClearTeamGroupModels() {
m.clearedteam_group_models = true
}
// TeamGroupModelsCleared reports if the "team_group_models" edge to the TeamGroupModel entity was cleared.
func (m *TeamGroupMutation) TeamGroupModelsCleared() bool {
return m.clearedteam_group_models
}
// RemoveTeamGroupModelIDs removes the "team_group_models" edge to the TeamGroupModel entity by IDs.
func (m *TeamGroupMutation) RemoveTeamGroupModelIDs(ids ...uuid.UUID) {
if m.removedteam_group_models == nil {
m.removedteam_group_models = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_group_models, ids[i])
m.removedteam_group_models[ids[i]] = struct{}{}
}
}
// RemovedTeamGroupModels returns the removed IDs of the "team_group_models" edge to the TeamGroupModel entity.
func (m *TeamGroupMutation) RemovedTeamGroupModelsIDs() (ids []uuid.UUID) {
for id := range m.removedteam_group_models {
ids = append(ids, id)
}
return
}
// TeamGroupModelsIDs returns the "team_group_models" edge IDs in the mutation.
func (m *TeamGroupMutation) TeamGroupModelsIDs() (ids []uuid.UUID) {
for id := range m.team_group_models {
ids = append(ids, id)
}
return
}
// ResetTeamGroupModels resets all changes to the "team_group_models" edge.
func (m *TeamGroupMutation) ResetTeamGroupModels() {
m.team_group_models = nil
m.clearedteam_group_models = false
m.removedteam_group_models = nil
}
// AddTeamGroupImageIDs adds the "team_group_images" edge to the TeamGroupImage entity by ids.
func (m *TeamGroupMutation) AddTeamGroupImageIDs(ids ...uuid.UUID) {
if m.team_group_images == nil {
m.team_group_images = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_group_images[ids[i]] = struct{}{}
}
}
// ClearTeamGroupImages clears the "team_group_images" edge to the TeamGroupImage entity.
func (m *TeamGroupMutation) ClearTeamGroupImages() {
m.clearedteam_group_images = true
}
// TeamGroupImagesCleared reports if the "team_group_images" edge to the TeamGroupImage entity was cleared.
func (m *TeamGroupMutation) TeamGroupImagesCleared() bool {
return m.clearedteam_group_images
}
// RemoveTeamGroupImageIDs removes the "team_group_images" edge to the TeamGroupImage entity by IDs.
func (m *TeamGroupMutation) RemoveTeamGroupImageIDs(ids ...uuid.UUID) {
if m.removedteam_group_images == nil {
m.removedteam_group_images = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_group_images, ids[i])
m.removedteam_group_images[ids[i]] = struct{}{}
}
}
// RemovedTeamGroupImages returns the removed IDs of the "team_group_images" edge to the TeamGroupImage entity.
func (m *TeamGroupMutation) RemovedTeamGroupImagesIDs() (ids []uuid.UUID) {
for id := range m.removedteam_group_images {
ids = append(ids, id)
}
return
}
// TeamGroupImagesIDs returns the "team_group_images" edge IDs in the mutation.
func (m *TeamGroupMutation) TeamGroupImagesIDs() (ids []uuid.UUID) {
for id := range m.team_group_images {
ids = append(ids, id)
}
return
}
// ResetTeamGroupImages resets all changes to the "team_group_images" edge.
func (m *TeamGroupMutation) ResetTeamGroupImages() {
m.team_group_images = nil
m.clearedteam_group_images = false
m.removedteam_group_images = nil
}
// AddTeamGroupHostIDs adds the "team_group_hosts" edge to the TeamGroupHost entity by ids.
func (m *TeamGroupMutation) AddTeamGroupHostIDs(ids ...uuid.UUID) {
if m.team_group_hosts == nil {
m.team_group_hosts = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_group_hosts[ids[i]] = struct{}{}
}
}
// ClearTeamGroupHosts clears the "team_group_hosts" edge to the TeamGroupHost entity.
func (m *TeamGroupMutation) ClearTeamGroupHosts() {
m.clearedteam_group_hosts = true
}
// TeamGroupHostsCleared reports if the "team_group_hosts" edge to the TeamGroupHost entity was cleared.
func (m *TeamGroupMutation) TeamGroupHostsCleared() bool {
return m.clearedteam_group_hosts
}
// RemoveTeamGroupHostIDs removes the "team_group_hosts" edge to the TeamGroupHost entity by IDs.
func (m *TeamGroupMutation) RemoveTeamGroupHostIDs(ids ...uuid.UUID) {
if m.removedteam_group_hosts == nil {
m.removedteam_group_hosts = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_group_hosts, ids[i])
m.removedteam_group_hosts[ids[i]] = struct{}{}
}
}
// RemovedTeamGroupHosts returns the removed IDs of the "team_group_hosts" edge to the TeamGroupHost entity.
func (m *TeamGroupMutation) RemovedTeamGroupHostsIDs() (ids []uuid.UUID) {
for id := range m.removedteam_group_hosts {
ids = append(ids, id)
}
return
}
// TeamGroupHostsIDs returns the "team_group_hosts" edge IDs in the mutation.
func (m *TeamGroupMutation) TeamGroupHostsIDs() (ids []uuid.UUID) {
for id := range m.team_group_hosts {
ids = append(ids, id)
}
return
}
// ResetTeamGroupHosts resets all changes to the "team_group_hosts" edge.
func (m *TeamGroupMutation) ResetTeamGroupHosts() {
m.team_group_hosts = nil
m.clearedteam_group_hosts = false
m.removedteam_group_hosts = nil
}
// Where appends a list predicates to the TeamGroupMutation builder.
func (m *TeamGroupMutation) Where(ps ...predicate.TeamGroup) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TeamGroupMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TeamGroupMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TeamGroup, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TeamGroupMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TeamGroupMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TeamGroup).
func (m *TeamGroupMutation) 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 *TeamGroupMutation) Fields() []string {
fields := make([]string, 0, 5)
if m.deleted_at != nil {
fields = append(fields, teamgroup.FieldDeletedAt)
}
if m.team != nil {
fields = append(fields, teamgroup.FieldTeamID)
}
if m.name != nil {
fields = append(fields, teamgroup.FieldName)
}
if m.created_at != nil {
fields = append(fields, teamgroup.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, teamgroup.FieldUpdatedAt)
}
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 *TeamGroupMutation) Field(name string) (ent.Value, bool) {
switch name {
case teamgroup.FieldDeletedAt:
return m.DeletedAt()
case teamgroup.FieldTeamID:
return m.TeamID()
case teamgroup.FieldName:
return m.Name()
case teamgroup.FieldCreatedAt:
return m.CreatedAt()
case teamgroup.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *TeamGroupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case teamgroup.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case teamgroup.FieldTeamID:
return m.OldTeamID(ctx)
case teamgroup.FieldName:
return m.OldName(ctx)
case teamgroup.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case teamgroup.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown TeamGroup 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 *TeamGroupMutation) SetField(name string, value ent.Value) error {
switch name {
case teamgroup.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 teamgroup.FieldTeamID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTeamID(v)
return nil
case teamgroup.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case teamgroup.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 teamgroup.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown TeamGroup field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TeamGroupMutation) AddedFields() []string {
return nil
}
// 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 *TeamGroupMutation) AddedField(name string) (ent.Value, bool) {
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 *TeamGroupMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TeamGroup numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TeamGroupMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(teamgroup.FieldDeletedAt) {
fields = append(fields, teamgroup.FieldDeletedAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TeamGroupMutation) 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 *TeamGroupMutation) ClearField(name string) error {
switch name {
case teamgroup.FieldDeletedAt:
m.ClearDeletedAt()
return nil
}
return fmt.Errorf("unknown TeamGroup 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 *TeamGroupMutation) ResetField(name string) error {
switch name {
case teamgroup.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case teamgroup.FieldTeamID:
m.ResetTeamID()
return nil
case teamgroup.FieldName:
m.ResetName()
return nil
case teamgroup.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case teamgroup.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown TeamGroup field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TeamGroupMutation) AddedEdges() []string {
edges := make([]string, 0, 9)
if m.members != nil {
edges = append(edges, teamgroup.EdgeMembers)
}
if m.team != nil {
edges = append(edges, teamgroup.EdgeTeam)
}
if m.models != nil {
edges = append(edges, teamgroup.EdgeModels)
}
if m.images != nil {
edges = append(edges, teamgroup.EdgeImages)
}
if m.hosts != nil {
edges = append(edges, teamgroup.EdgeHosts)
}
if m.team_group_members != nil {
edges = append(edges, teamgroup.EdgeTeamGroupMembers)
}
if m.team_group_models != nil {
edges = append(edges, teamgroup.EdgeTeamGroupModels)
}
if m.team_group_images != nil {
edges = append(edges, teamgroup.EdgeTeamGroupImages)
}
if m.team_group_hosts != nil {
edges = append(edges, teamgroup.EdgeTeamGroupHosts)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TeamGroupMutation) AddedIDs(name string) []ent.Value {
switch name {
case teamgroup.EdgeMembers:
ids := make([]ent.Value, 0, len(m.members))
for id := range m.members {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeTeam:
if id := m.team; id != nil {
return []ent.Value{*id}
}
case teamgroup.EdgeModels:
ids := make([]ent.Value, 0, len(m.models))
for id := range m.models {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeImages:
ids := make([]ent.Value, 0, len(m.images))
for id := range m.images {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeHosts:
ids := make([]ent.Value, 0, len(m.hosts))
for id := range m.hosts {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeTeamGroupMembers:
ids := make([]ent.Value, 0, len(m.team_group_members))
for id := range m.team_group_members {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeTeamGroupModels:
ids := make([]ent.Value, 0, len(m.team_group_models))
for id := range m.team_group_models {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeTeamGroupImages:
ids := make([]ent.Value, 0, len(m.team_group_images))
for id := range m.team_group_images {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeTeamGroupHosts:
ids := make([]ent.Value, 0, len(m.team_group_hosts))
for id := range m.team_group_hosts {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TeamGroupMutation) RemovedEdges() []string {
edges := make([]string, 0, 9)
if m.removedmembers != nil {
edges = append(edges, teamgroup.EdgeMembers)
}
if m.removedmodels != nil {
edges = append(edges, teamgroup.EdgeModels)
}
if m.removedimages != nil {
edges = append(edges, teamgroup.EdgeImages)
}
if m.removedhosts != nil {
edges = append(edges, teamgroup.EdgeHosts)
}
if m.removedteam_group_members != nil {
edges = append(edges, teamgroup.EdgeTeamGroupMembers)
}
if m.removedteam_group_models != nil {
edges = append(edges, teamgroup.EdgeTeamGroupModels)
}
if m.removedteam_group_images != nil {
edges = append(edges, teamgroup.EdgeTeamGroupImages)
}
if m.removedteam_group_hosts != nil {
edges = append(edges, teamgroup.EdgeTeamGroupHosts)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TeamGroupMutation) RemovedIDs(name string) []ent.Value {
switch name {
case teamgroup.EdgeMembers:
ids := make([]ent.Value, 0, len(m.removedmembers))
for id := range m.removedmembers {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeModels:
ids := make([]ent.Value, 0, len(m.removedmodels))
for id := range m.removedmodels {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeImages:
ids := make([]ent.Value, 0, len(m.removedimages))
for id := range m.removedimages {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeHosts:
ids := make([]ent.Value, 0, len(m.removedhosts))
for id := range m.removedhosts {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeTeamGroupMembers:
ids := make([]ent.Value, 0, len(m.removedteam_group_members))
for id := range m.removedteam_group_members {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeTeamGroupModels:
ids := make([]ent.Value, 0, len(m.removedteam_group_models))
for id := range m.removedteam_group_models {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeTeamGroupImages:
ids := make([]ent.Value, 0, len(m.removedteam_group_images))
for id := range m.removedteam_group_images {
ids = append(ids, id)
}
return ids
case teamgroup.EdgeTeamGroupHosts:
ids := make([]ent.Value, 0, len(m.removedteam_group_hosts))
for id := range m.removedteam_group_hosts {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TeamGroupMutation) ClearedEdges() []string {
edges := make([]string, 0, 9)
if m.clearedmembers {
edges = append(edges, teamgroup.EdgeMembers)
}
if m.clearedteam {
edges = append(edges, teamgroup.EdgeTeam)
}
if m.clearedmodels {
edges = append(edges, teamgroup.EdgeModels)
}
if m.clearedimages {
edges = append(edges, teamgroup.EdgeImages)
}
if m.clearedhosts {
edges = append(edges, teamgroup.EdgeHosts)
}
if m.clearedteam_group_members {
edges = append(edges, teamgroup.EdgeTeamGroupMembers)
}
if m.clearedteam_group_models {
edges = append(edges, teamgroup.EdgeTeamGroupModels)
}
if m.clearedteam_group_images {
edges = append(edges, teamgroup.EdgeTeamGroupImages)
}
if m.clearedteam_group_hosts {
edges = append(edges, teamgroup.EdgeTeamGroupHosts)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TeamGroupMutation) EdgeCleared(name string) bool {
switch name {
case teamgroup.EdgeMembers:
return m.clearedmembers
case teamgroup.EdgeTeam:
return m.clearedteam
case teamgroup.EdgeModels:
return m.clearedmodels
case teamgroup.EdgeImages:
return m.clearedimages
case teamgroup.EdgeHosts:
return m.clearedhosts
case teamgroup.EdgeTeamGroupMembers:
return m.clearedteam_group_members
case teamgroup.EdgeTeamGroupModels:
return m.clearedteam_group_models
case teamgroup.EdgeTeamGroupImages:
return m.clearedteam_group_images
case teamgroup.EdgeTeamGroupHosts:
return m.clearedteam_group_hosts
}
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 *TeamGroupMutation) ClearEdge(name string) error {
switch name {
case teamgroup.EdgeTeam:
m.ClearTeam()
return nil
}
return fmt.Errorf("unknown TeamGroup 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 *TeamGroupMutation) ResetEdge(name string) error {
switch name {
case teamgroup.EdgeMembers:
m.ResetMembers()
return nil
case teamgroup.EdgeTeam:
m.ResetTeam()
return nil
case teamgroup.EdgeModels:
m.ResetModels()
return nil
case teamgroup.EdgeImages:
m.ResetImages()
return nil
case teamgroup.EdgeHosts:
m.ResetHosts()
return nil
case teamgroup.EdgeTeamGroupMembers:
m.ResetTeamGroupMembers()
return nil
case teamgroup.EdgeTeamGroupModels:
m.ResetTeamGroupModels()
return nil
case teamgroup.EdgeTeamGroupImages:
m.ResetTeamGroupImages()
return nil
case teamgroup.EdgeTeamGroupHosts:
m.ResetTeamGroupHosts()
return nil
}
return fmt.Errorf("unknown TeamGroup edge %s", name)
}
// TeamGroupHostMutation represents an operation that mutates the TeamGroupHost nodes in the graph.
type TeamGroupHostMutation struct {
config
op Op
typ string
id *uuid.UUID
created_at *time.Time
clearedFields map[string]struct{}
group *uuid.UUID
clearedgroup bool
host *string
clearedhost bool
done bool
oldValue func(context.Context) (*TeamGroupHost, error)
predicates []predicate.TeamGroupHost
}
var _ ent.Mutation = (*TeamGroupHostMutation)(nil)
// teamgrouphostOption allows management of the mutation configuration using functional options.
type teamgrouphostOption func(*TeamGroupHostMutation)
// newTeamGroupHostMutation creates new mutation for the TeamGroupHost entity.
func newTeamGroupHostMutation(c config, op Op, opts ...teamgrouphostOption) *TeamGroupHostMutation {
m := &TeamGroupHostMutation{
config: c,
op: op,
typ: TypeTeamGroupHost,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTeamGroupHostID sets the ID field of the mutation.
func withTeamGroupHostID(id uuid.UUID) teamgrouphostOption {
return func(m *TeamGroupHostMutation) {
var (
err error
once sync.Once
value *TeamGroupHost
)
m.oldValue = func(ctx context.Context) (*TeamGroupHost, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TeamGroupHost.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTeamGroupHost sets the old TeamGroupHost of the mutation.
func withTeamGroupHost(node *TeamGroupHost) teamgrouphostOption {
return func(m *TeamGroupHostMutation) {
m.oldValue = func(context.Context) (*TeamGroupHost, 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 TeamGroupHostMutation) 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 TeamGroupHostMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TeamGroupHost entities.
func (m *TeamGroupHostMutation) SetID(id uuid.UUID) {
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 *TeamGroupHostMutation) ID() (id uuid.UUID, 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 *TeamGroupHostMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TeamGroupHost.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetGroupID sets the "group_id" field.
func (m *TeamGroupHostMutation) SetGroupID(u uuid.UUID) {
m.group = &u
}
// GroupID returns the value of the "group_id" field in the mutation.
func (m *TeamGroupHostMutation) GroupID() (r uuid.UUID, exists bool) {
v := m.group
if v == nil {
return
}
return *v, true
}
// OldGroupID returns the old "group_id" field's value of the TeamGroupHost entity.
// If the TeamGroupHost 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 *TeamGroupHostMutation) OldGroupID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGroupID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
}
return oldValue.GroupID, nil
}
// ResetGroupID resets all changes to the "group_id" field.
func (m *TeamGroupHostMutation) ResetGroupID() {
m.group = nil
}
// SetHostID sets the "host_id" field.
func (m *TeamGroupHostMutation) SetHostID(s string) {
m.host = &s
}
// HostID returns the value of the "host_id" field in the mutation.
func (m *TeamGroupHostMutation) HostID() (r string, exists bool) {
v := m.host
if v == nil {
return
}
return *v, true
}
// OldHostID returns the old "host_id" field's value of the TeamGroupHost entity.
// If the TeamGroupHost 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 *TeamGroupHostMutation) OldHostID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHostID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHostID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHostID: %w", err)
}
return oldValue.HostID, nil
}
// ResetHostID resets all changes to the "host_id" field.
func (m *TeamGroupHostMutation) ResetHostID() {
m.host = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TeamGroupHostMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TeamGroupHostMutation) 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 TeamGroupHost entity.
// If the TeamGroupHost 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 *TeamGroupHostMutation) 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 *TeamGroupHostMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearGroup clears the "group" edge to the TeamGroup entity.
func (m *TeamGroupHostMutation) ClearGroup() {
m.clearedgroup = true
m.clearedFields[teamgrouphost.FieldGroupID] = struct{}{}
}
// GroupCleared reports if the "group" edge to the TeamGroup entity was cleared.
func (m *TeamGroupHostMutation) GroupCleared() bool {
return m.clearedgroup
}
// GroupIDs returns the "group" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// GroupID instead. It exists only for internal usage by the builders.
func (m *TeamGroupHostMutation) GroupIDs() (ids []uuid.UUID) {
if id := m.group; id != nil {
ids = append(ids, *id)
}
return
}
// ResetGroup resets all changes to the "group" edge.
func (m *TeamGroupHostMutation) ResetGroup() {
m.group = nil
m.clearedgroup = false
}
// ClearHost clears the "host" edge to the Host entity.
func (m *TeamGroupHostMutation) ClearHost() {
m.clearedhost = true
m.clearedFields[teamgrouphost.FieldHostID] = struct{}{}
}
// HostCleared reports if the "host" edge to the Host entity was cleared.
func (m *TeamGroupHostMutation) HostCleared() bool {
return m.clearedhost
}
// HostIDs returns the "host" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// HostID instead. It exists only for internal usage by the builders.
func (m *TeamGroupHostMutation) HostIDs() (ids []string) {
if id := m.host; id != nil {
ids = append(ids, *id)
}
return
}
// ResetHost resets all changes to the "host" edge.
func (m *TeamGroupHostMutation) ResetHost() {
m.host = nil
m.clearedhost = false
}
// Where appends a list predicates to the TeamGroupHostMutation builder.
func (m *TeamGroupHostMutation) Where(ps ...predicate.TeamGroupHost) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TeamGroupHostMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TeamGroupHostMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TeamGroupHost, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TeamGroupHostMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TeamGroupHostMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TeamGroupHost).
func (m *TeamGroupHostMutation) 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 *TeamGroupHostMutation) Fields() []string {
fields := make([]string, 0, 3)
if m.group != nil {
fields = append(fields, teamgrouphost.FieldGroupID)
}
if m.host != nil {
fields = append(fields, teamgrouphost.FieldHostID)
}
if m.created_at != nil {
fields = append(fields, teamgrouphost.FieldCreatedAt)
}
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 *TeamGroupHostMutation) Field(name string) (ent.Value, bool) {
switch name {
case teamgrouphost.FieldGroupID:
return m.GroupID()
case teamgrouphost.FieldHostID:
return m.HostID()
case teamgrouphost.FieldCreatedAt:
return m.CreatedAt()
}
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 *TeamGroupHostMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case teamgrouphost.FieldGroupID:
return m.OldGroupID(ctx)
case teamgrouphost.FieldHostID:
return m.OldHostID(ctx)
case teamgrouphost.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown TeamGroupHost 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 *TeamGroupHostMutation) SetField(name string, value ent.Value) error {
switch name {
case teamgrouphost.FieldGroupID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGroupID(v)
return nil
case teamgrouphost.FieldHostID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHostID(v)
return nil
case teamgrouphost.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown TeamGroupHost field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TeamGroupHostMutation) AddedFields() []string {
return nil
}
// 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 *TeamGroupHostMutation) AddedField(name string) (ent.Value, bool) {
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 *TeamGroupHostMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TeamGroupHost numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TeamGroupHostMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TeamGroupHostMutation) 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 *TeamGroupHostMutation) ClearField(name string) error {
return fmt.Errorf("unknown TeamGroupHost 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 *TeamGroupHostMutation) ResetField(name string) error {
switch name {
case teamgrouphost.FieldGroupID:
m.ResetGroupID()
return nil
case teamgrouphost.FieldHostID:
m.ResetHostID()
return nil
case teamgrouphost.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown TeamGroupHost field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TeamGroupHostMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.group != nil {
edges = append(edges, teamgrouphost.EdgeGroup)
}
if m.host != nil {
edges = append(edges, teamgrouphost.EdgeHost)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TeamGroupHostMutation) AddedIDs(name string) []ent.Value {
switch name {
case teamgrouphost.EdgeGroup:
if id := m.group; id != nil {
return []ent.Value{*id}
}
case teamgrouphost.EdgeHost:
if id := m.host; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TeamGroupHostMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TeamGroupHostMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TeamGroupHostMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedgroup {
edges = append(edges, teamgrouphost.EdgeGroup)
}
if m.clearedhost {
edges = append(edges, teamgrouphost.EdgeHost)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TeamGroupHostMutation) EdgeCleared(name string) bool {
switch name {
case teamgrouphost.EdgeGroup:
return m.clearedgroup
case teamgrouphost.EdgeHost:
return m.clearedhost
}
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 *TeamGroupHostMutation) ClearEdge(name string) error {
switch name {
case teamgrouphost.EdgeGroup:
m.ClearGroup()
return nil
case teamgrouphost.EdgeHost:
m.ClearHost()
return nil
}
return fmt.Errorf("unknown TeamGroupHost 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 *TeamGroupHostMutation) ResetEdge(name string) error {
switch name {
case teamgrouphost.EdgeGroup:
m.ResetGroup()
return nil
case teamgrouphost.EdgeHost:
m.ResetHost()
return nil
}
return fmt.Errorf("unknown TeamGroupHost edge %s", name)
}
// TeamGroupImageMutation represents an operation that mutates the TeamGroupImage nodes in the graph.
type TeamGroupImageMutation struct {
config
op Op
typ string
id *uuid.UUID
created_at *time.Time
clearedFields map[string]struct{}
group *uuid.UUID
clearedgroup bool
image *uuid.UUID
clearedimage bool
done bool
oldValue func(context.Context) (*TeamGroupImage, error)
predicates []predicate.TeamGroupImage
}
var _ ent.Mutation = (*TeamGroupImageMutation)(nil)
// teamgroupimageOption allows management of the mutation configuration using functional options.
type teamgroupimageOption func(*TeamGroupImageMutation)
// newTeamGroupImageMutation creates new mutation for the TeamGroupImage entity.
func newTeamGroupImageMutation(c config, op Op, opts ...teamgroupimageOption) *TeamGroupImageMutation {
m := &TeamGroupImageMutation{
config: c,
op: op,
typ: TypeTeamGroupImage,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTeamGroupImageID sets the ID field of the mutation.
func withTeamGroupImageID(id uuid.UUID) teamgroupimageOption {
return func(m *TeamGroupImageMutation) {
var (
err error
once sync.Once
value *TeamGroupImage
)
m.oldValue = func(ctx context.Context) (*TeamGroupImage, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TeamGroupImage.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTeamGroupImage sets the old TeamGroupImage of the mutation.
func withTeamGroupImage(node *TeamGroupImage) teamgroupimageOption {
return func(m *TeamGroupImageMutation) {
m.oldValue = func(context.Context) (*TeamGroupImage, 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 TeamGroupImageMutation) 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 TeamGroupImageMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TeamGroupImage entities.
func (m *TeamGroupImageMutation) SetID(id uuid.UUID) {
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 *TeamGroupImageMutation) ID() (id uuid.UUID, 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 *TeamGroupImageMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TeamGroupImage.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetGroupID sets the "group_id" field.
func (m *TeamGroupImageMutation) SetGroupID(u uuid.UUID) {
m.group = &u
}
// GroupID returns the value of the "group_id" field in the mutation.
func (m *TeamGroupImageMutation) GroupID() (r uuid.UUID, exists bool) {
v := m.group
if v == nil {
return
}
return *v, true
}
// OldGroupID returns the old "group_id" field's value of the TeamGroupImage entity.
// If the TeamGroupImage 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 *TeamGroupImageMutation) OldGroupID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGroupID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
}
return oldValue.GroupID, nil
}
// ResetGroupID resets all changes to the "group_id" field.
func (m *TeamGroupImageMutation) ResetGroupID() {
m.group = nil
}
// SetImageID sets the "image_id" field.
func (m *TeamGroupImageMutation) SetImageID(u uuid.UUID) {
m.image = &u
}
// ImageID returns the value of the "image_id" field in the mutation.
func (m *TeamGroupImageMutation) ImageID() (r uuid.UUID, exists bool) {
v := m.image
if v == nil {
return
}
return *v, true
}
// OldImageID returns the old "image_id" field's value of the TeamGroupImage entity.
// If the TeamGroupImage 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 *TeamGroupImageMutation) OldImageID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldImageID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldImageID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldImageID: %w", err)
}
return oldValue.ImageID, nil
}
// ResetImageID resets all changes to the "image_id" field.
func (m *TeamGroupImageMutation) ResetImageID() {
m.image = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TeamGroupImageMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TeamGroupImageMutation) 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 TeamGroupImage entity.
// If the TeamGroupImage 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 *TeamGroupImageMutation) 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 *TeamGroupImageMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearGroup clears the "group" edge to the TeamGroup entity.
func (m *TeamGroupImageMutation) ClearGroup() {
m.clearedgroup = true
m.clearedFields[teamgroupimage.FieldGroupID] = struct{}{}
}
// GroupCleared reports if the "group" edge to the TeamGroup entity was cleared.
func (m *TeamGroupImageMutation) GroupCleared() bool {
return m.clearedgroup
}
// GroupIDs returns the "group" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// GroupID instead. It exists only for internal usage by the builders.
func (m *TeamGroupImageMutation) GroupIDs() (ids []uuid.UUID) {
if id := m.group; id != nil {
ids = append(ids, *id)
}
return
}
// ResetGroup resets all changes to the "group" edge.
func (m *TeamGroupImageMutation) ResetGroup() {
m.group = nil
m.clearedgroup = false
}
// ClearImage clears the "image" edge to the Image entity.
func (m *TeamGroupImageMutation) ClearImage() {
m.clearedimage = true
m.clearedFields[teamgroupimage.FieldImageID] = struct{}{}
}
// ImageCleared reports if the "image" edge to the Image entity was cleared.
func (m *TeamGroupImageMutation) ImageCleared() bool {
return m.clearedimage
}
// ImageIDs returns the "image" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ImageID instead. It exists only for internal usage by the builders.
func (m *TeamGroupImageMutation) ImageIDs() (ids []uuid.UUID) {
if id := m.image; id != nil {
ids = append(ids, *id)
}
return
}
// ResetImage resets all changes to the "image" edge.
func (m *TeamGroupImageMutation) ResetImage() {
m.image = nil
m.clearedimage = false
}
// Where appends a list predicates to the TeamGroupImageMutation builder.
func (m *TeamGroupImageMutation) Where(ps ...predicate.TeamGroupImage) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TeamGroupImageMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TeamGroupImageMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TeamGroupImage, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TeamGroupImageMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TeamGroupImageMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TeamGroupImage).
func (m *TeamGroupImageMutation) 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 *TeamGroupImageMutation) Fields() []string {
fields := make([]string, 0, 3)
if m.group != nil {
fields = append(fields, teamgroupimage.FieldGroupID)
}
if m.image != nil {
fields = append(fields, teamgroupimage.FieldImageID)
}
if m.created_at != nil {
fields = append(fields, teamgroupimage.FieldCreatedAt)
}
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 *TeamGroupImageMutation) Field(name string) (ent.Value, bool) {
switch name {
case teamgroupimage.FieldGroupID:
return m.GroupID()
case teamgroupimage.FieldImageID:
return m.ImageID()
case teamgroupimage.FieldCreatedAt:
return m.CreatedAt()
}
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 *TeamGroupImageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case teamgroupimage.FieldGroupID:
return m.OldGroupID(ctx)
case teamgroupimage.FieldImageID:
return m.OldImageID(ctx)
case teamgroupimage.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown TeamGroupImage 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 *TeamGroupImageMutation) SetField(name string, value ent.Value) error {
switch name {
case teamgroupimage.FieldGroupID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGroupID(v)
return nil
case teamgroupimage.FieldImageID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetImageID(v)
return nil
case teamgroupimage.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown TeamGroupImage field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TeamGroupImageMutation) AddedFields() []string {
return nil
}
// 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 *TeamGroupImageMutation) AddedField(name string) (ent.Value, bool) {
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 *TeamGroupImageMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TeamGroupImage numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TeamGroupImageMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TeamGroupImageMutation) 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 *TeamGroupImageMutation) ClearField(name string) error {
return fmt.Errorf("unknown TeamGroupImage 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 *TeamGroupImageMutation) ResetField(name string) error {
switch name {
case teamgroupimage.FieldGroupID:
m.ResetGroupID()
return nil
case teamgroupimage.FieldImageID:
m.ResetImageID()
return nil
case teamgroupimage.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown TeamGroupImage field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TeamGroupImageMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.group != nil {
edges = append(edges, teamgroupimage.EdgeGroup)
}
if m.image != nil {
edges = append(edges, teamgroupimage.EdgeImage)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TeamGroupImageMutation) AddedIDs(name string) []ent.Value {
switch name {
case teamgroupimage.EdgeGroup:
if id := m.group; id != nil {
return []ent.Value{*id}
}
case teamgroupimage.EdgeImage:
if id := m.image; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TeamGroupImageMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TeamGroupImageMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TeamGroupImageMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedgroup {
edges = append(edges, teamgroupimage.EdgeGroup)
}
if m.clearedimage {
edges = append(edges, teamgroupimage.EdgeImage)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TeamGroupImageMutation) EdgeCleared(name string) bool {
switch name {
case teamgroupimage.EdgeGroup:
return m.clearedgroup
case teamgroupimage.EdgeImage:
return m.clearedimage
}
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 *TeamGroupImageMutation) ClearEdge(name string) error {
switch name {
case teamgroupimage.EdgeGroup:
m.ClearGroup()
return nil
case teamgroupimage.EdgeImage:
m.ClearImage()
return nil
}
return fmt.Errorf("unknown TeamGroupImage 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 *TeamGroupImageMutation) ResetEdge(name string) error {
switch name {
case teamgroupimage.EdgeGroup:
m.ResetGroup()
return nil
case teamgroupimage.EdgeImage:
m.ResetImage()
return nil
}
return fmt.Errorf("unknown TeamGroupImage edge %s", name)
}
// TeamGroupMemberMutation represents an operation that mutates the TeamGroupMember nodes in the graph.
type TeamGroupMemberMutation struct {
config
op Op
typ string
id *uuid.UUID
created_at *time.Time
clearedFields map[string]struct{}
group *uuid.UUID
clearedgroup bool
user *uuid.UUID
cleareduser bool
done bool
oldValue func(context.Context) (*TeamGroupMember, error)
predicates []predicate.TeamGroupMember
}
var _ ent.Mutation = (*TeamGroupMemberMutation)(nil)
// teamgroupmemberOption allows management of the mutation configuration using functional options.
type teamgroupmemberOption func(*TeamGroupMemberMutation)
// newTeamGroupMemberMutation creates new mutation for the TeamGroupMember entity.
func newTeamGroupMemberMutation(c config, op Op, opts ...teamgroupmemberOption) *TeamGroupMemberMutation {
m := &TeamGroupMemberMutation{
config: c,
op: op,
typ: TypeTeamGroupMember,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTeamGroupMemberID sets the ID field of the mutation.
func withTeamGroupMemberID(id uuid.UUID) teamgroupmemberOption {
return func(m *TeamGroupMemberMutation) {
var (
err error
once sync.Once
value *TeamGroupMember
)
m.oldValue = func(ctx context.Context) (*TeamGroupMember, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TeamGroupMember.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTeamGroupMember sets the old TeamGroupMember of the mutation.
func withTeamGroupMember(node *TeamGroupMember) teamgroupmemberOption {
return func(m *TeamGroupMemberMutation) {
m.oldValue = func(context.Context) (*TeamGroupMember, 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 TeamGroupMemberMutation) 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 TeamGroupMemberMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TeamGroupMember entities.
func (m *TeamGroupMemberMutation) SetID(id uuid.UUID) {
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 *TeamGroupMemberMutation) ID() (id uuid.UUID, 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 *TeamGroupMemberMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TeamGroupMember.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetGroupID sets the "group_id" field.
func (m *TeamGroupMemberMutation) SetGroupID(u uuid.UUID) {
m.group = &u
}
// GroupID returns the value of the "group_id" field in the mutation.
func (m *TeamGroupMemberMutation) GroupID() (r uuid.UUID, exists bool) {
v := m.group
if v == nil {
return
}
return *v, true
}
// OldGroupID returns the old "group_id" field's value of the TeamGroupMember entity.
// If the TeamGroupMember 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 *TeamGroupMemberMutation) OldGroupID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGroupID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
}
return oldValue.GroupID, nil
}
// ResetGroupID resets all changes to the "group_id" field.
func (m *TeamGroupMemberMutation) ResetGroupID() {
m.group = nil
}
// SetUserID sets the "user_id" field.
func (m *TeamGroupMemberMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *TeamGroupMemberMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the TeamGroupMember entity.
// If the TeamGroupMember 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 *TeamGroupMemberMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *TeamGroupMemberMutation) ResetUserID() {
m.user = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TeamGroupMemberMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TeamGroupMemberMutation) 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 TeamGroupMember entity.
// If the TeamGroupMember 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 *TeamGroupMemberMutation) 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 *TeamGroupMemberMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearGroup clears the "group" edge to the TeamGroup entity.
func (m *TeamGroupMemberMutation) ClearGroup() {
m.clearedgroup = true
m.clearedFields[teamgroupmember.FieldGroupID] = struct{}{}
}
// GroupCleared reports if the "group" edge to the TeamGroup entity was cleared.
func (m *TeamGroupMemberMutation) GroupCleared() bool {
return m.clearedgroup
}
// GroupIDs returns the "group" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// GroupID instead. It exists only for internal usage by the builders.
func (m *TeamGroupMemberMutation) GroupIDs() (ids []uuid.UUID) {
if id := m.group; id != nil {
ids = append(ids, *id)
}
return
}
// ResetGroup resets all changes to the "group" edge.
func (m *TeamGroupMemberMutation) ResetGroup() {
m.group = nil
m.clearedgroup = false
}
// ClearUser clears the "user" edge to the User entity.
func (m *TeamGroupMemberMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[teamgroupmember.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *TeamGroupMemberMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *TeamGroupMemberMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *TeamGroupMemberMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// Where appends a list predicates to the TeamGroupMemberMutation builder.
func (m *TeamGroupMemberMutation) Where(ps ...predicate.TeamGroupMember) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TeamGroupMemberMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TeamGroupMemberMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TeamGroupMember, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TeamGroupMemberMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TeamGroupMemberMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TeamGroupMember).
func (m *TeamGroupMemberMutation) 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 *TeamGroupMemberMutation) Fields() []string {
fields := make([]string, 0, 3)
if m.group != nil {
fields = append(fields, teamgroupmember.FieldGroupID)
}
if m.user != nil {
fields = append(fields, teamgroupmember.FieldUserID)
}
if m.created_at != nil {
fields = append(fields, teamgroupmember.FieldCreatedAt)
}
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 *TeamGroupMemberMutation) Field(name string) (ent.Value, bool) {
switch name {
case teamgroupmember.FieldGroupID:
return m.GroupID()
case teamgroupmember.FieldUserID:
return m.UserID()
case teamgroupmember.FieldCreatedAt:
return m.CreatedAt()
}
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 *TeamGroupMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case teamgroupmember.FieldGroupID:
return m.OldGroupID(ctx)
case teamgroupmember.FieldUserID:
return m.OldUserID(ctx)
case teamgroupmember.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown TeamGroupMember 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 *TeamGroupMemberMutation) SetField(name string, value ent.Value) error {
switch name {
case teamgroupmember.FieldGroupID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGroupID(v)
return nil
case teamgroupmember.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case teamgroupmember.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown TeamGroupMember field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TeamGroupMemberMutation) AddedFields() []string {
return nil
}
// 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 *TeamGroupMemberMutation) AddedField(name string) (ent.Value, bool) {
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 *TeamGroupMemberMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TeamGroupMember numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TeamGroupMemberMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TeamGroupMemberMutation) 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 *TeamGroupMemberMutation) ClearField(name string) error {
return fmt.Errorf("unknown TeamGroupMember 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 *TeamGroupMemberMutation) ResetField(name string) error {
switch name {
case teamgroupmember.FieldGroupID:
m.ResetGroupID()
return nil
case teamgroupmember.FieldUserID:
m.ResetUserID()
return nil
case teamgroupmember.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown TeamGroupMember field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TeamGroupMemberMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.group != nil {
edges = append(edges, teamgroupmember.EdgeGroup)
}
if m.user != nil {
edges = append(edges, teamgroupmember.EdgeUser)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TeamGroupMemberMutation) AddedIDs(name string) []ent.Value {
switch name {
case teamgroupmember.EdgeGroup:
if id := m.group; id != nil {
return []ent.Value{*id}
}
case teamgroupmember.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TeamGroupMemberMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TeamGroupMemberMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TeamGroupMemberMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedgroup {
edges = append(edges, teamgroupmember.EdgeGroup)
}
if m.cleareduser {
edges = append(edges, teamgroupmember.EdgeUser)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TeamGroupMemberMutation) EdgeCleared(name string) bool {
switch name {
case teamgroupmember.EdgeGroup:
return m.clearedgroup
case teamgroupmember.EdgeUser:
return m.cleareduser
}
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 *TeamGroupMemberMutation) ClearEdge(name string) error {
switch name {
case teamgroupmember.EdgeGroup:
m.ClearGroup()
return nil
case teamgroupmember.EdgeUser:
m.ClearUser()
return nil
}
return fmt.Errorf("unknown TeamGroupMember 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 *TeamGroupMemberMutation) ResetEdge(name string) error {
switch name {
case teamgroupmember.EdgeGroup:
m.ResetGroup()
return nil
case teamgroupmember.EdgeUser:
m.ResetUser()
return nil
}
return fmt.Errorf("unknown TeamGroupMember edge %s", name)
}
// TeamGroupModelMutation represents an operation that mutates the TeamGroupModel nodes in the graph.
type TeamGroupModelMutation struct {
config
op Op
typ string
id *uuid.UUID
created_at *time.Time
clearedFields map[string]struct{}
group *uuid.UUID
clearedgroup bool
model *uuid.UUID
clearedmodel bool
done bool
oldValue func(context.Context) (*TeamGroupModel, error)
predicates []predicate.TeamGroupModel
}
var _ ent.Mutation = (*TeamGroupModelMutation)(nil)
// teamgroupmodelOption allows management of the mutation configuration using functional options.
type teamgroupmodelOption func(*TeamGroupModelMutation)
// newTeamGroupModelMutation creates new mutation for the TeamGroupModel entity.
func newTeamGroupModelMutation(c config, op Op, opts ...teamgroupmodelOption) *TeamGroupModelMutation {
m := &TeamGroupModelMutation{
config: c,
op: op,
typ: TypeTeamGroupModel,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTeamGroupModelID sets the ID field of the mutation.
func withTeamGroupModelID(id uuid.UUID) teamgroupmodelOption {
return func(m *TeamGroupModelMutation) {
var (
err error
once sync.Once
value *TeamGroupModel
)
m.oldValue = func(ctx context.Context) (*TeamGroupModel, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TeamGroupModel.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTeamGroupModel sets the old TeamGroupModel of the mutation.
func withTeamGroupModel(node *TeamGroupModel) teamgroupmodelOption {
return func(m *TeamGroupModelMutation) {
m.oldValue = func(context.Context) (*TeamGroupModel, 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 TeamGroupModelMutation) 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 TeamGroupModelMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TeamGroupModel entities.
func (m *TeamGroupModelMutation) SetID(id uuid.UUID) {
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 *TeamGroupModelMutation) ID() (id uuid.UUID, 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 *TeamGroupModelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TeamGroupModel.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetGroupID sets the "group_id" field.
func (m *TeamGroupModelMutation) SetGroupID(u uuid.UUID) {
m.group = &u
}
// GroupID returns the value of the "group_id" field in the mutation.
func (m *TeamGroupModelMutation) GroupID() (r uuid.UUID, exists bool) {
v := m.group
if v == nil {
return
}
return *v, true
}
// OldGroupID returns the old "group_id" field's value of the TeamGroupModel entity.
// If the TeamGroupModel 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 *TeamGroupModelMutation) OldGroupID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGroupID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
}
return oldValue.GroupID, nil
}
// ResetGroupID resets all changes to the "group_id" field.
func (m *TeamGroupModelMutation) ResetGroupID() {
m.group = nil
}
// SetModelID sets the "model_id" field.
func (m *TeamGroupModelMutation) SetModelID(u uuid.UUID) {
m.model = &u
}
// ModelID returns the value of the "model_id" field in the mutation.
func (m *TeamGroupModelMutation) ModelID() (r uuid.UUID, exists bool) {
v := m.model
if v == nil {
return
}
return *v, true
}
// OldModelID returns the old "model_id" field's value of the TeamGroupModel entity.
// If the TeamGroupModel 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 *TeamGroupModelMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldModelID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldModelID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldModelID: %w", err)
}
return oldValue.ModelID, nil
}
// ResetModelID resets all changes to the "model_id" field.
func (m *TeamGroupModelMutation) ResetModelID() {
m.model = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TeamGroupModelMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TeamGroupModelMutation) 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 TeamGroupModel entity.
// If the TeamGroupModel 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 *TeamGroupModelMutation) 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 *TeamGroupModelMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearGroup clears the "group" edge to the TeamGroup entity.
func (m *TeamGroupModelMutation) ClearGroup() {
m.clearedgroup = true
m.clearedFields[teamgroupmodel.FieldGroupID] = struct{}{}
}
// GroupCleared reports if the "group" edge to the TeamGroup entity was cleared.
func (m *TeamGroupModelMutation) GroupCleared() bool {
return m.clearedgroup
}
// GroupIDs returns the "group" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// GroupID instead. It exists only for internal usage by the builders.
func (m *TeamGroupModelMutation) GroupIDs() (ids []uuid.UUID) {
if id := m.group; id != nil {
ids = append(ids, *id)
}
return
}
// ResetGroup resets all changes to the "group" edge.
func (m *TeamGroupModelMutation) ResetGroup() {
m.group = nil
m.clearedgroup = false
}
// ClearModel clears the "model" edge to the Model entity.
func (m *TeamGroupModelMutation) ClearModel() {
m.clearedmodel = true
m.clearedFields[teamgroupmodel.FieldModelID] = struct{}{}
}
// ModelCleared reports if the "model" edge to the Model entity was cleared.
func (m *TeamGroupModelMutation) ModelCleared() bool {
return m.clearedmodel
}
// ModelIDs returns the "model" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ModelID instead. It exists only for internal usage by the builders.
func (m *TeamGroupModelMutation) ModelIDs() (ids []uuid.UUID) {
if id := m.model; id != nil {
ids = append(ids, *id)
}
return
}
// ResetModel resets all changes to the "model" edge.
func (m *TeamGroupModelMutation) ResetModel() {
m.model = nil
m.clearedmodel = false
}
// Where appends a list predicates to the TeamGroupModelMutation builder.
func (m *TeamGroupModelMutation) Where(ps ...predicate.TeamGroupModel) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TeamGroupModelMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TeamGroupModelMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TeamGroupModel, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TeamGroupModelMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TeamGroupModelMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TeamGroupModel).
func (m *TeamGroupModelMutation) 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 *TeamGroupModelMutation) Fields() []string {
fields := make([]string, 0, 3)
if m.group != nil {
fields = append(fields, teamgroupmodel.FieldGroupID)
}
if m.model != nil {
fields = append(fields, teamgroupmodel.FieldModelID)
}
if m.created_at != nil {
fields = append(fields, teamgroupmodel.FieldCreatedAt)
}
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 *TeamGroupModelMutation) Field(name string) (ent.Value, bool) {
switch name {
case teamgroupmodel.FieldGroupID:
return m.GroupID()
case teamgroupmodel.FieldModelID:
return m.ModelID()
case teamgroupmodel.FieldCreatedAt:
return m.CreatedAt()
}
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 *TeamGroupModelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case teamgroupmodel.FieldGroupID:
return m.OldGroupID(ctx)
case teamgroupmodel.FieldModelID:
return m.OldModelID(ctx)
case teamgroupmodel.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown TeamGroupModel 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 *TeamGroupModelMutation) SetField(name string, value ent.Value) error {
switch name {
case teamgroupmodel.FieldGroupID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGroupID(v)
return nil
case teamgroupmodel.FieldModelID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetModelID(v)
return nil
case teamgroupmodel.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown TeamGroupModel field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TeamGroupModelMutation) AddedFields() []string {
return nil
}
// 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 *TeamGroupModelMutation) AddedField(name string) (ent.Value, bool) {
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 *TeamGroupModelMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TeamGroupModel numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TeamGroupModelMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TeamGroupModelMutation) 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 *TeamGroupModelMutation) ClearField(name string) error {
return fmt.Errorf("unknown TeamGroupModel 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 *TeamGroupModelMutation) ResetField(name string) error {
switch name {
case teamgroupmodel.FieldGroupID:
m.ResetGroupID()
return nil
case teamgroupmodel.FieldModelID:
m.ResetModelID()
return nil
case teamgroupmodel.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown TeamGroupModel field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TeamGroupModelMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.group != nil {
edges = append(edges, teamgroupmodel.EdgeGroup)
}
if m.model != nil {
edges = append(edges, teamgroupmodel.EdgeModel)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TeamGroupModelMutation) AddedIDs(name string) []ent.Value {
switch name {
case teamgroupmodel.EdgeGroup:
if id := m.group; id != nil {
return []ent.Value{*id}
}
case teamgroupmodel.EdgeModel:
if id := m.model; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TeamGroupModelMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TeamGroupModelMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TeamGroupModelMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedgroup {
edges = append(edges, teamgroupmodel.EdgeGroup)
}
if m.clearedmodel {
edges = append(edges, teamgroupmodel.EdgeModel)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TeamGroupModelMutation) EdgeCleared(name string) bool {
switch name {
case teamgroupmodel.EdgeGroup:
return m.clearedgroup
case teamgroupmodel.EdgeModel:
return m.clearedmodel
}
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 *TeamGroupModelMutation) ClearEdge(name string) error {
switch name {
case teamgroupmodel.EdgeGroup:
m.ClearGroup()
return nil
case teamgroupmodel.EdgeModel:
m.ClearModel()
return nil
}
return fmt.Errorf("unknown TeamGroupModel 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 *TeamGroupModelMutation) ResetEdge(name string) error {
switch name {
case teamgroupmodel.EdgeGroup:
m.ResetGroup()
return nil
case teamgroupmodel.EdgeModel:
m.ResetModel()
return nil
}
return fmt.Errorf("unknown TeamGroupModel edge %s", name)
}
// TeamHostMutation represents an operation that mutates the TeamHost nodes in the graph.
type TeamHostMutation struct {
config
op Op
typ string
id *uuid.UUID
created_at *time.Time
clearedFields map[string]struct{}
team *uuid.UUID
clearedteam bool
host *string
clearedhost bool
done bool
oldValue func(context.Context) (*TeamHost, error)
predicates []predicate.TeamHost
}
var _ ent.Mutation = (*TeamHostMutation)(nil)
// teamhostOption allows management of the mutation configuration using functional options.
type teamhostOption func(*TeamHostMutation)
// newTeamHostMutation creates new mutation for the TeamHost entity.
func newTeamHostMutation(c config, op Op, opts ...teamhostOption) *TeamHostMutation {
m := &TeamHostMutation{
config: c,
op: op,
typ: TypeTeamHost,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTeamHostID sets the ID field of the mutation.
func withTeamHostID(id uuid.UUID) teamhostOption {
return func(m *TeamHostMutation) {
var (
err error
once sync.Once
value *TeamHost
)
m.oldValue = func(ctx context.Context) (*TeamHost, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TeamHost.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTeamHost sets the old TeamHost of the mutation.
func withTeamHost(node *TeamHost) teamhostOption {
return func(m *TeamHostMutation) {
m.oldValue = func(context.Context) (*TeamHost, 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 TeamHostMutation) 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 TeamHostMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TeamHost entities.
func (m *TeamHostMutation) SetID(id uuid.UUID) {
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 *TeamHostMutation) ID() (id uuid.UUID, 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 *TeamHostMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TeamHost.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetTeamID sets the "team_id" field.
func (m *TeamHostMutation) SetTeamID(u uuid.UUID) {
m.team = &u
}
// TeamID returns the value of the "team_id" field in the mutation.
func (m *TeamHostMutation) TeamID() (r uuid.UUID, exists bool) {
v := m.team
if v == nil {
return
}
return *v, true
}
// OldTeamID returns the old "team_id" field's value of the TeamHost entity.
// If the TeamHost 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 *TeamHostMutation) OldTeamID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTeamID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTeamID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTeamID: %w", err)
}
return oldValue.TeamID, nil
}
// ResetTeamID resets all changes to the "team_id" field.
func (m *TeamHostMutation) ResetTeamID() {
m.team = nil
}
// SetHostID sets the "host_id" field.
func (m *TeamHostMutation) SetHostID(s string) {
m.host = &s
}
// HostID returns the value of the "host_id" field in the mutation.
func (m *TeamHostMutation) HostID() (r string, exists bool) {
v := m.host
if v == nil {
return
}
return *v, true
}
// OldHostID returns the old "host_id" field's value of the TeamHost entity.
// If the TeamHost 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 *TeamHostMutation) OldHostID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHostID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHostID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHostID: %w", err)
}
return oldValue.HostID, nil
}
// ResetHostID resets all changes to the "host_id" field.
func (m *TeamHostMutation) ResetHostID() {
m.host = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TeamHostMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TeamHostMutation) 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 TeamHost entity.
// If the TeamHost 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 *TeamHostMutation) 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 *TeamHostMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearTeam clears the "team" edge to the Team entity.
func (m *TeamHostMutation) ClearTeam() {
m.clearedteam = true
m.clearedFields[teamhost.FieldTeamID] = struct{}{}
}
// TeamCleared reports if the "team" edge to the Team entity was cleared.
func (m *TeamHostMutation) TeamCleared() bool {
return m.clearedteam
}
// TeamIDs returns the "team" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// TeamID instead. It exists only for internal usage by the builders.
func (m *TeamHostMutation) TeamIDs() (ids []uuid.UUID) {
if id := m.team; id != nil {
ids = append(ids, *id)
}
return
}
// ResetTeam resets all changes to the "team" edge.
func (m *TeamHostMutation) ResetTeam() {
m.team = nil
m.clearedteam = false
}
// ClearHost clears the "host" edge to the Host entity.
func (m *TeamHostMutation) ClearHost() {
m.clearedhost = true
m.clearedFields[teamhost.FieldHostID] = struct{}{}
}
// HostCleared reports if the "host" edge to the Host entity was cleared.
func (m *TeamHostMutation) HostCleared() bool {
return m.clearedhost
}
// HostIDs returns the "host" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// HostID instead. It exists only for internal usage by the builders.
func (m *TeamHostMutation) HostIDs() (ids []string) {
if id := m.host; id != nil {
ids = append(ids, *id)
}
return
}
// ResetHost resets all changes to the "host" edge.
func (m *TeamHostMutation) ResetHost() {
m.host = nil
m.clearedhost = false
}
// Where appends a list predicates to the TeamHostMutation builder.
func (m *TeamHostMutation) Where(ps ...predicate.TeamHost) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TeamHostMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TeamHostMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TeamHost, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TeamHostMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TeamHostMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TeamHost).
func (m *TeamHostMutation) 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 *TeamHostMutation) Fields() []string {
fields := make([]string, 0, 3)
if m.team != nil {
fields = append(fields, teamhost.FieldTeamID)
}
if m.host != nil {
fields = append(fields, teamhost.FieldHostID)
}
if m.created_at != nil {
fields = append(fields, teamhost.FieldCreatedAt)
}
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 *TeamHostMutation) Field(name string) (ent.Value, bool) {
switch name {
case teamhost.FieldTeamID:
return m.TeamID()
case teamhost.FieldHostID:
return m.HostID()
case teamhost.FieldCreatedAt:
return m.CreatedAt()
}
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 *TeamHostMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case teamhost.FieldTeamID:
return m.OldTeamID(ctx)
case teamhost.FieldHostID:
return m.OldHostID(ctx)
case teamhost.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown TeamHost 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 *TeamHostMutation) SetField(name string, value ent.Value) error {
switch name {
case teamhost.FieldTeamID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTeamID(v)
return nil
case teamhost.FieldHostID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHostID(v)
return nil
case teamhost.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown TeamHost field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TeamHostMutation) AddedFields() []string {
return nil
}
// 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 *TeamHostMutation) AddedField(name string) (ent.Value, bool) {
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 *TeamHostMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TeamHost numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TeamHostMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TeamHostMutation) 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 *TeamHostMutation) ClearField(name string) error {
return fmt.Errorf("unknown TeamHost 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 *TeamHostMutation) ResetField(name string) error {
switch name {
case teamhost.FieldTeamID:
m.ResetTeamID()
return nil
case teamhost.FieldHostID:
m.ResetHostID()
return nil
case teamhost.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown TeamHost field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TeamHostMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.team != nil {
edges = append(edges, teamhost.EdgeTeam)
}
if m.host != nil {
edges = append(edges, teamhost.EdgeHost)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TeamHostMutation) AddedIDs(name string) []ent.Value {
switch name {
case teamhost.EdgeTeam:
if id := m.team; id != nil {
return []ent.Value{*id}
}
case teamhost.EdgeHost:
if id := m.host; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TeamHostMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TeamHostMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TeamHostMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedteam {
edges = append(edges, teamhost.EdgeTeam)
}
if m.clearedhost {
edges = append(edges, teamhost.EdgeHost)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TeamHostMutation) EdgeCleared(name string) bool {
switch name {
case teamhost.EdgeTeam:
return m.clearedteam
case teamhost.EdgeHost:
return m.clearedhost
}
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 *TeamHostMutation) ClearEdge(name string) error {
switch name {
case teamhost.EdgeTeam:
m.ClearTeam()
return nil
case teamhost.EdgeHost:
m.ClearHost()
return nil
}
return fmt.Errorf("unknown TeamHost 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 *TeamHostMutation) ResetEdge(name string) error {
switch name {
case teamhost.EdgeTeam:
m.ResetTeam()
return nil
case teamhost.EdgeHost:
m.ResetHost()
return nil
}
return fmt.Errorf("unknown TeamHost edge %s", name)
}
// TeamImageMutation represents an operation that mutates the TeamImage nodes in the graph.
type TeamImageMutation struct {
config
op Op
typ string
id *uuid.UUID
created_at *time.Time
clearedFields map[string]struct{}
team *uuid.UUID
clearedteam bool
image *uuid.UUID
clearedimage bool
done bool
oldValue func(context.Context) (*TeamImage, error)
predicates []predicate.TeamImage
}
var _ ent.Mutation = (*TeamImageMutation)(nil)
// teamimageOption allows management of the mutation configuration using functional options.
type teamimageOption func(*TeamImageMutation)
// newTeamImageMutation creates new mutation for the TeamImage entity.
func newTeamImageMutation(c config, op Op, opts ...teamimageOption) *TeamImageMutation {
m := &TeamImageMutation{
config: c,
op: op,
typ: TypeTeamImage,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTeamImageID sets the ID field of the mutation.
func withTeamImageID(id uuid.UUID) teamimageOption {
return func(m *TeamImageMutation) {
var (
err error
once sync.Once
value *TeamImage
)
m.oldValue = func(ctx context.Context) (*TeamImage, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TeamImage.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTeamImage sets the old TeamImage of the mutation.
func withTeamImage(node *TeamImage) teamimageOption {
return func(m *TeamImageMutation) {
m.oldValue = func(context.Context) (*TeamImage, 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 TeamImageMutation) 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 TeamImageMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TeamImage entities.
func (m *TeamImageMutation) SetID(id uuid.UUID) {
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 *TeamImageMutation) ID() (id uuid.UUID, 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 *TeamImageMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TeamImage.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetTeamID sets the "team_id" field.
func (m *TeamImageMutation) SetTeamID(u uuid.UUID) {
m.team = &u
}
// TeamID returns the value of the "team_id" field in the mutation.
func (m *TeamImageMutation) TeamID() (r uuid.UUID, exists bool) {
v := m.team
if v == nil {
return
}
return *v, true
}
// OldTeamID returns the old "team_id" field's value of the TeamImage entity.
// If the TeamImage 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 *TeamImageMutation) OldTeamID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTeamID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTeamID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTeamID: %w", err)
}
return oldValue.TeamID, nil
}
// ResetTeamID resets all changes to the "team_id" field.
func (m *TeamImageMutation) ResetTeamID() {
m.team = nil
}
// SetImageID sets the "image_id" field.
func (m *TeamImageMutation) SetImageID(u uuid.UUID) {
m.image = &u
}
// ImageID returns the value of the "image_id" field in the mutation.
func (m *TeamImageMutation) ImageID() (r uuid.UUID, exists bool) {
v := m.image
if v == nil {
return
}
return *v, true
}
// OldImageID returns the old "image_id" field's value of the TeamImage entity.
// If the TeamImage 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 *TeamImageMutation) OldImageID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldImageID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldImageID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldImageID: %w", err)
}
return oldValue.ImageID, nil
}
// ResetImageID resets all changes to the "image_id" field.
func (m *TeamImageMutation) ResetImageID() {
m.image = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TeamImageMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TeamImageMutation) 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 TeamImage entity.
// If the TeamImage 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 *TeamImageMutation) 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 *TeamImageMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearTeam clears the "team" edge to the Team entity.
func (m *TeamImageMutation) ClearTeam() {
m.clearedteam = true
m.clearedFields[teamimage.FieldTeamID] = struct{}{}
}
// TeamCleared reports if the "team" edge to the Team entity was cleared.
func (m *TeamImageMutation) TeamCleared() bool {
return m.clearedteam
}
// TeamIDs returns the "team" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// TeamID instead. It exists only for internal usage by the builders.
func (m *TeamImageMutation) TeamIDs() (ids []uuid.UUID) {
if id := m.team; id != nil {
ids = append(ids, *id)
}
return
}
// ResetTeam resets all changes to the "team" edge.
func (m *TeamImageMutation) ResetTeam() {
m.team = nil
m.clearedteam = false
}
// ClearImage clears the "image" edge to the Image entity.
func (m *TeamImageMutation) ClearImage() {
m.clearedimage = true
m.clearedFields[teamimage.FieldImageID] = struct{}{}
}
// ImageCleared reports if the "image" edge to the Image entity was cleared.
func (m *TeamImageMutation) ImageCleared() bool {
return m.clearedimage
}
// ImageIDs returns the "image" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ImageID instead. It exists only for internal usage by the builders.
func (m *TeamImageMutation) ImageIDs() (ids []uuid.UUID) {
if id := m.image; id != nil {
ids = append(ids, *id)
}
return
}
// ResetImage resets all changes to the "image" edge.
func (m *TeamImageMutation) ResetImage() {
m.image = nil
m.clearedimage = false
}
// Where appends a list predicates to the TeamImageMutation builder.
func (m *TeamImageMutation) Where(ps ...predicate.TeamImage) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TeamImageMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TeamImageMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TeamImage, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TeamImageMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TeamImageMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TeamImage).
func (m *TeamImageMutation) 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 *TeamImageMutation) Fields() []string {
fields := make([]string, 0, 3)
if m.team != nil {
fields = append(fields, teamimage.FieldTeamID)
}
if m.image != nil {
fields = append(fields, teamimage.FieldImageID)
}
if m.created_at != nil {
fields = append(fields, teamimage.FieldCreatedAt)
}
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 *TeamImageMutation) Field(name string) (ent.Value, bool) {
switch name {
case teamimage.FieldTeamID:
return m.TeamID()
case teamimage.FieldImageID:
return m.ImageID()
case teamimage.FieldCreatedAt:
return m.CreatedAt()
}
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 *TeamImageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case teamimage.FieldTeamID:
return m.OldTeamID(ctx)
case teamimage.FieldImageID:
return m.OldImageID(ctx)
case teamimage.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown TeamImage 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 *TeamImageMutation) SetField(name string, value ent.Value) error {
switch name {
case teamimage.FieldTeamID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTeamID(v)
return nil
case teamimage.FieldImageID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetImageID(v)
return nil
case teamimage.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown TeamImage field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TeamImageMutation) AddedFields() []string {
return nil
}
// 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 *TeamImageMutation) AddedField(name string) (ent.Value, bool) {
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 *TeamImageMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TeamImage numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TeamImageMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TeamImageMutation) 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 *TeamImageMutation) ClearField(name string) error {
return fmt.Errorf("unknown TeamImage 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 *TeamImageMutation) ResetField(name string) error {
switch name {
case teamimage.FieldTeamID:
m.ResetTeamID()
return nil
case teamimage.FieldImageID:
m.ResetImageID()
return nil
case teamimage.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown TeamImage field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TeamImageMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.team != nil {
edges = append(edges, teamimage.EdgeTeam)
}
if m.image != nil {
edges = append(edges, teamimage.EdgeImage)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TeamImageMutation) AddedIDs(name string) []ent.Value {
switch name {
case teamimage.EdgeTeam:
if id := m.team; id != nil {
return []ent.Value{*id}
}
case teamimage.EdgeImage:
if id := m.image; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TeamImageMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TeamImageMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TeamImageMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedteam {
edges = append(edges, teamimage.EdgeTeam)
}
if m.clearedimage {
edges = append(edges, teamimage.EdgeImage)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TeamImageMutation) EdgeCleared(name string) bool {
switch name {
case teamimage.EdgeTeam:
return m.clearedteam
case teamimage.EdgeImage:
return m.clearedimage
}
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 *TeamImageMutation) ClearEdge(name string) error {
switch name {
case teamimage.EdgeTeam:
m.ClearTeam()
return nil
case teamimage.EdgeImage:
m.ClearImage()
return nil
}
return fmt.Errorf("unknown TeamImage 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 *TeamImageMutation) ResetEdge(name string) error {
switch name {
case teamimage.EdgeTeam:
m.ResetTeam()
return nil
case teamimage.EdgeImage:
m.ResetImage()
return nil
}
return fmt.Errorf("unknown TeamImage edge %s", name)
}
// TeamMemberMutation represents an operation that mutates the TeamMember nodes in the graph.
type TeamMemberMutation struct {
config
op Op
typ string
id *uuid.UUID
role *consts.TeamMemberRole
created_at *time.Time
clearedFields map[string]struct{}
team *uuid.UUID
clearedteam bool
user *uuid.UUID
cleareduser bool
done bool
oldValue func(context.Context) (*TeamMember, error)
predicates []predicate.TeamMember
}
var _ ent.Mutation = (*TeamMemberMutation)(nil)
// teammemberOption allows management of the mutation configuration using functional options.
type teammemberOption func(*TeamMemberMutation)
// newTeamMemberMutation creates new mutation for the TeamMember entity.
func newTeamMemberMutation(c config, op Op, opts ...teammemberOption) *TeamMemberMutation {
m := &TeamMemberMutation{
config: c,
op: op,
typ: TypeTeamMember,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTeamMemberID sets the ID field of the mutation.
func withTeamMemberID(id uuid.UUID) teammemberOption {
return func(m *TeamMemberMutation) {
var (
err error
once sync.Once
value *TeamMember
)
m.oldValue = func(ctx context.Context) (*TeamMember, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TeamMember.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTeamMember sets the old TeamMember of the mutation.
func withTeamMember(node *TeamMember) teammemberOption {
return func(m *TeamMemberMutation) {
m.oldValue = func(context.Context) (*TeamMember, 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 TeamMemberMutation) 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 TeamMemberMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TeamMember entities.
func (m *TeamMemberMutation) SetID(id uuid.UUID) {
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 *TeamMemberMutation) ID() (id uuid.UUID, 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 *TeamMemberMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TeamMember.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetTeamID sets the "team_id" field.
func (m *TeamMemberMutation) SetTeamID(u uuid.UUID) {
m.team = &u
}
// TeamID returns the value of the "team_id" field in the mutation.
func (m *TeamMemberMutation) TeamID() (r uuid.UUID, exists bool) {
v := m.team
if v == nil {
return
}
return *v, true
}
// OldTeamID returns the old "team_id" field's value of the TeamMember entity.
// If the TeamMember 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 *TeamMemberMutation) OldTeamID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTeamID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTeamID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTeamID: %w", err)
}
return oldValue.TeamID, nil
}
// ResetTeamID resets all changes to the "team_id" field.
func (m *TeamMemberMutation) ResetTeamID() {
m.team = nil
}
// SetUserID sets the "user_id" field.
func (m *TeamMemberMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *TeamMemberMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the TeamMember entity.
// If the TeamMember 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 *TeamMemberMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *TeamMemberMutation) ResetUserID() {
m.user = nil
}
// SetRole sets the "role" field.
func (m *TeamMemberMutation) SetRole(cmr consts.TeamMemberRole) {
m.role = &cmr
}
// Role returns the value of the "role" field in the mutation.
func (m *TeamMemberMutation) Role() (r consts.TeamMemberRole, exists bool) {
v := m.role
if v == nil {
return
}
return *v, true
}
// OldRole returns the old "role" field's value of the TeamMember entity.
// If the TeamMember 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 *TeamMemberMutation) OldRole(ctx context.Context) (v consts.TeamMemberRole, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRole is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRole requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRole: %w", err)
}
return oldValue.Role, nil
}
// ResetRole resets all changes to the "role" field.
func (m *TeamMemberMutation) ResetRole() {
m.role = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TeamMemberMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TeamMemberMutation) 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 TeamMember entity.
// If the TeamMember 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 *TeamMemberMutation) 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 *TeamMemberMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearTeam clears the "team" edge to the Team entity.
func (m *TeamMemberMutation) ClearTeam() {
m.clearedteam = true
m.clearedFields[teammember.FieldTeamID] = struct{}{}
}
// TeamCleared reports if the "team" edge to the Team entity was cleared.
func (m *TeamMemberMutation) TeamCleared() bool {
return m.clearedteam
}
// TeamIDs returns the "team" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// TeamID instead. It exists only for internal usage by the builders.
func (m *TeamMemberMutation) TeamIDs() (ids []uuid.UUID) {
if id := m.team; id != nil {
ids = append(ids, *id)
}
return
}
// ResetTeam resets all changes to the "team" edge.
func (m *TeamMemberMutation) ResetTeam() {
m.team = nil
m.clearedteam = false
}
// ClearUser clears the "user" edge to the User entity.
func (m *TeamMemberMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[teammember.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *TeamMemberMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *TeamMemberMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *TeamMemberMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// Where appends a list predicates to the TeamMemberMutation builder.
func (m *TeamMemberMutation) Where(ps ...predicate.TeamMember) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TeamMemberMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TeamMemberMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TeamMember, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TeamMemberMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TeamMemberMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TeamMember).
func (m *TeamMemberMutation) 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 *TeamMemberMutation) Fields() []string {
fields := make([]string, 0, 4)
if m.team != nil {
fields = append(fields, teammember.FieldTeamID)
}
if m.user != nil {
fields = append(fields, teammember.FieldUserID)
}
if m.role != nil {
fields = append(fields, teammember.FieldRole)
}
if m.created_at != nil {
fields = append(fields, teammember.FieldCreatedAt)
}
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 *TeamMemberMutation) Field(name string) (ent.Value, bool) {
switch name {
case teammember.FieldTeamID:
return m.TeamID()
case teammember.FieldUserID:
return m.UserID()
case teammember.FieldRole:
return m.Role()
case teammember.FieldCreatedAt:
return m.CreatedAt()
}
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 *TeamMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case teammember.FieldTeamID:
return m.OldTeamID(ctx)
case teammember.FieldUserID:
return m.OldUserID(ctx)
case teammember.FieldRole:
return m.OldRole(ctx)
case teammember.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown TeamMember 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 *TeamMemberMutation) SetField(name string, value ent.Value) error {
switch name {
case teammember.FieldTeamID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTeamID(v)
return nil
case teammember.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case teammember.FieldRole:
v, ok := value.(consts.TeamMemberRole)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRole(v)
return nil
case teammember.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown TeamMember field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TeamMemberMutation) AddedFields() []string {
return nil
}
// 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 *TeamMemberMutation) AddedField(name string) (ent.Value, bool) {
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 *TeamMemberMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TeamMember numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TeamMemberMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TeamMemberMutation) 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 *TeamMemberMutation) ClearField(name string) error {
return fmt.Errorf("unknown TeamMember 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 *TeamMemberMutation) ResetField(name string) error {
switch name {
case teammember.FieldTeamID:
m.ResetTeamID()
return nil
case teammember.FieldUserID:
m.ResetUserID()
return nil
case teammember.FieldRole:
m.ResetRole()
return nil
case teammember.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown TeamMember field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TeamMemberMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.team != nil {
edges = append(edges, teammember.EdgeTeam)
}
if m.user != nil {
edges = append(edges, teammember.EdgeUser)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TeamMemberMutation) AddedIDs(name string) []ent.Value {
switch name {
case teammember.EdgeTeam:
if id := m.team; id != nil {
return []ent.Value{*id}
}
case teammember.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TeamMemberMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TeamMemberMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TeamMemberMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedteam {
edges = append(edges, teammember.EdgeTeam)
}
if m.cleareduser {
edges = append(edges, teammember.EdgeUser)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TeamMemberMutation) EdgeCleared(name string) bool {
switch name {
case teammember.EdgeTeam:
return m.clearedteam
case teammember.EdgeUser:
return m.cleareduser
}
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 *TeamMemberMutation) ClearEdge(name string) error {
switch name {
case teammember.EdgeTeam:
m.ClearTeam()
return nil
case teammember.EdgeUser:
m.ClearUser()
return nil
}
return fmt.Errorf("unknown TeamMember 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 *TeamMemberMutation) ResetEdge(name string) error {
switch name {
case teammember.EdgeTeam:
m.ResetTeam()
return nil
case teammember.EdgeUser:
m.ResetUser()
return nil
}
return fmt.Errorf("unknown TeamMember edge %s", name)
}
// TeamModelMutation represents an operation that mutates the TeamModel nodes in the graph.
type TeamModelMutation struct {
config
op Op
typ string
id *uuid.UUID
created_at *time.Time
clearedFields map[string]struct{}
team *uuid.UUID
clearedteam bool
model *uuid.UUID
clearedmodel bool
done bool
oldValue func(context.Context) (*TeamModel, error)
predicates []predicate.TeamModel
}
var _ ent.Mutation = (*TeamModelMutation)(nil)
// teammodelOption allows management of the mutation configuration using functional options.
type teammodelOption func(*TeamModelMutation)
// newTeamModelMutation creates new mutation for the TeamModel entity.
func newTeamModelMutation(c config, op Op, opts ...teammodelOption) *TeamModelMutation {
m := &TeamModelMutation{
config: c,
op: op,
typ: TypeTeamModel,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTeamModelID sets the ID field of the mutation.
func withTeamModelID(id uuid.UUID) teammodelOption {
return func(m *TeamModelMutation) {
var (
err error
once sync.Once
value *TeamModel
)
m.oldValue = func(ctx context.Context) (*TeamModel, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TeamModel.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTeamModel sets the old TeamModel of the mutation.
func withTeamModel(node *TeamModel) teammodelOption {
return func(m *TeamModelMutation) {
m.oldValue = func(context.Context) (*TeamModel, 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 TeamModelMutation) 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 TeamModelMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 TeamModel entities.
func (m *TeamModelMutation) SetID(id uuid.UUID) {
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 *TeamModelMutation) ID() (id uuid.UUID, 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 *TeamModelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().TeamModel.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetTeamID sets the "team_id" field.
func (m *TeamModelMutation) SetTeamID(u uuid.UUID) {
m.team = &u
}
// TeamID returns the value of the "team_id" field in the mutation.
func (m *TeamModelMutation) TeamID() (r uuid.UUID, exists bool) {
v := m.team
if v == nil {
return
}
return *v, true
}
// OldTeamID returns the old "team_id" field's value of the TeamModel entity.
// If the TeamModel 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 *TeamModelMutation) OldTeamID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTeamID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTeamID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTeamID: %w", err)
}
return oldValue.TeamID, nil
}
// ResetTeamID resets all changes to the "team_id" field.
func (m *TeamModelMutation) ResetTeamID() {
m.team = nil
}
// SetModelID sets the "model_id" field.
func (m *TeamModelMutation) SetModelID(u uuid.UUID) {
m.model = &u
}
// ModelID returns the value of the "model_id" field in the mutation.
func (m *TeamModelMutation) ModelID() (r uuid.UUID, exists bool) {
v := m.model
if v == nil {
return
}
return *v, true
}
// OldModelID returns the old "model_id" field's value of the TeamModel entity.
// If the TeamModel 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 *TeamModelMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldModelID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldModelID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldModelID: %w", err)
}
return oldValue.ModelID, nil
}
// ResetModelID resets all changes to the "model_id" field.
func (m *TeamModelMutation) ResetModelID() {
m.model = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *TeamModelMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *TeamModelMutation) 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 TeamModel entity.
// If the TeamModel 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 *TeamModelMutation) 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 *TeamModelMutation) ResetCreatedAt() {
m.created_at = nil
}
// ClearTeam clears the "team" edge to the Team entity.
func (m *TeamModelMutation) ClearTeam() {
m.clearedteam = true
m.clearedFields[teammodel.FieldTeamID] = struct{}{}
}
// TeamCleared reports if the "team" edge to the Team entity was cleared.
func (m *TeamModelMutation) TeamCleared() bool {
return m.clearedteam
}
// TeamIDs returns the "team" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// TeamID instead. It exists only for internal usage by the builders.
func (m *TeamModelMutation) TeamIDs() (ids []uuid.UUID) {
if id := m.team; id != nil {
ids = append(ids, *id)
}
return
}
// ResetTeam resets all changes to the "team" edge.
func (m *TeamModelMutation) ResetTeam() {
m.team = nil
m.clearedteam = false
}
// ClearModel clears the "model" edge to the Model entity.
func (m *TeamModelMutation) ClearModel() {
m.clearedmodel = true
m.clearedFields[teammodel.FieldModelID] = struct{}{}
}
// ModelCleared reports if the "model" edge to the Model entity was cleared.
func (m *TeamModelMutation) ModelCleared() bool {
return m.clearedmodel
}
// ModelIDs returns the "model" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ModelID instead. It exists only for internal usage by the builders.
func (m *TeamModelMutation) ModelIDs() (ids []uuid.UUID) {
if id := m.model; id != nil {
ids = append(ids, *id)
}
return
}
// ResetModel resets all changes to the "model" edge.
func (m *TeamModelMutation) ResetModel() {
m.model = nil
m.clearedmodel = false
}
// Where appends a list predicates to the TeamModelMutation builder.
func (m *TeamModelMutation) Where(ps ...predicate.TeamModel) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TeamModelMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TeamModelMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TeamModel, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TeamModelMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TeamModelMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TeamModel).
func (m *TeamModelMutation) 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 *TeamModelMutation) Fields() []string {
fields := make([]string, 0, 3)
if m.team != nil {
fields = append(fields, teammodel.FieldTeamID)
}
if m.model != nil {
fields = append(fields, teammodel.FieldModelID)
}
if m.created_at != nil {
fields = append(fields, teammodel.FieldCreatedAt)
}
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 *TeamModelMutation) Field(name string) (ent.Value, bool) {
switch name {
case teammodel.FieldTeamID:
return m.TeamID()
case teammodel.FieldModelID:
return m.ModelID()
case teammodel.FieldCreatedAt:
return m.CreatedAt()
}
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 *TeamModelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case teammodel.FieldTeamID:
return m.OldTeamID(ctx)
case teammodel.FieldModelID:
return m.OldModelID(ctx)
case teammodel.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
return nil, fmt.Errorf("unknown TeamModel 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 *TeamModelMutation) SetField(name string, value ent.Value) error {
switch name {
case teammodel.FieldTeamID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTeamID(v)
return nil
case teammodel.FieldModelID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetModelID(v)
return nil
case teammodel.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
}
return fmt.Errorf("unknown TeamModel field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TeamModelMutation) AddedFields() []string {
return nil
}
// 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 *TeamModelMutation) AddedField(name string) (ent.Value, bool) {
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 *TeamModelMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TeamModel numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TeamModelMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TeamModelMutation) 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 *TeamModelMutation) ClearField(name string) error {
return fmt.Errorf("unknown TeamModel 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 *TeamModelMutation) ResetField(name string) error {
switch name {
case teammodel.FieldTeamID:
m.ResetTeamID()
return nil
case teammodel.FieldModelID:
m.ResetModelID()
return nil
case teammodel.FieldCreatedAt:
m.ResetCreatedAt()
return nil
}
return fmt.Errorf("unknown TeamModel field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TeamModelMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.team != nil {
edges = append(edges, teammodel.EdgeTeam)
}
if m.model != nil {
edges = append(edges, teammodel.EdgeModel)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TeamModelMutation) AddedIDs(name string) []ent.Value {
switch name {
case teammodel.EdgeTeam:
if id := m.team; id != nil {
return []ent.Value{*id}
}
case teammodel.EdgeModel:
if id := m.model; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TeamModelMutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TeamModelMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TeamModelMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedteam {
edges = append(edges, teammodel.EdgeTeam)
}
if m.clearedmodel {
edges = append(edges, teammodel.EdgeModel)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TeamModelMutation) EdgeCleared(name string) bool {
switch name {
case teammodel.EdgeTeam:
return m.clearedteam
case teammodel.EdgeModel:
return m.clearedmodel
}
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 *TeamModelMutation) ClearEdge(name string) error {
switch name {
case teammodel.EdgeTeam:
m.ClearTeam()
return nil
case teammodel.EdgeModel:
m.ClearModel()
return nil
}
return fmt.Errorf("unknown TeamModel 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 *TeamModelMutation) ResetEdge(name string) error {
switch name {
case teammodel.EdgeTeam:
m.ResetTeam()
return nil
case teammodel.EdgeModel:
m.ResetModel()
return nil
}
return fmt.Errorf("unknown TeamModel edge %s", name)
}
// UserMutation represents an operation that mutates the User nodes in the graph.
type UserMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
name *string
email *string
avatar_url *string
password *string
role *consts.UserRole
status *consts.UserStatus
is_blocked *bool
default_configs *map[consts.DefaultConfigType]uuid.UUID
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
identities map[uuid.UUID]struct{}
removedidentities map[uuid.UUID]struct{}
clearedidentities bool
audits map[uuid.UUID]struct{}
removedaudits map[uuid.UUID]struct{}
clearedaudits bool
teams map[uuid.UUID]struct{}
removedteams map[uuid.UUID]struct{}
clearedteams bool
groups map[uuid.UUID]struct{}
removedgroups map[uuid.UUID]struct{}
clearedgroups bool
models map[uuid.UUID]struct{}
removedmodels map[uuid.UUID]struct{}
clearedmodels bool
images map[uuid.UUID]struct{}
removedimages map[uuid.UUID]struct{}
clearedimages bool
hosts map[string]struct{}
removedhosts map[string]struct{}
clearedhosts bool
vms map[string]struct{}
removedvms map[string]struct{}
clearedvms bool
tasks map[uuid.UUID]struct{}
removedtasks map[uuid.UUID]struct{}
clearedtasks bool
task_model_switches map[uuid.UUID]struct{}
removedtask_model_switches map[uuid.UUID]struct{}
clearedtask_model_switches bool
git_identities map[uuid.UUID]struct{}
removedgit_identities map[uuid.UUID]struct{}
clearedgit_identities bool
projects map[uuid.UUID]struct{}
removedprojects map[uuid.UUID]struct{}
clearedprojects bool
project_issues map[uuid.UUID]struct{}
removedproject_issues map[uuid.UUID]struct{}
clearedproject_issues bool
assigned_issues map[uuid.UUID]struct{}
removedassigned_issues map[uuid.UUID]struct{}
clearedassigned_issues bool
project_collaborators map[uuid.UUID]struct{}
removedproject_collaborators map[uuid.UUID]struct{}
clearedproject_collaborators bool
project_issue_comments map[uuid.UUID]struct{}
removedproject_issue_comments map[uuid.UUID]struct{}
clearedproject_issue_comments bool
git_bots map[uuid.UUID]struct{}
removedgit_bots map[uuid.UUID]struct{}
clearedgit_bots bool
mcp_upstreams map[uuid.UUID]struct{}
removedmcp_upstreams map[uuid.UUID]struct{}
clearedmcp_upstreams bool
team_members map[uuid.UUID]struct{}
removedteam_members map[uuid.UUID]struct{}
clearedteam_members bool
team_group_members map[uuid.UUID]struct{}
removedteam_group_members map[uuid.UUID]struct{}
clearedteam_group_members bool
git_bot_users map[uuid.UUID]struct{}
removedgit_bot_users map[uuid.UUID]struct{}
clearedgit_bot_users bool
done bool
oldValue func(context.Context) (*User, error)
predicates []predicate.User
}
var _ ent.Mutation = (*UserMutation)(nil)
// userOption allows management of the mutation configuration using functional options.
type userOption func(*UserMutation)
// newUserMutation creates new mutation for the User entity.
func newUserMutation(c config, op Op, opts ...userOption) *UserMutation {
m := &UserMutation{
config: c,
op: op,
typ: TypeUser,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withUserID sets the ID field of the mutation.
func withUserID(id uuid.UUID) userOption {
return func(m *UserMutation) {
var (
err error
once sync.Once
value *User
)
m.oldValue = func(ctx context.Context) (*User, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().User.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withUser sets the old User of the mutation.
func withUser(node *User) userOption {
return func(m *UserMutation) {
m.oldValue = func(context.Context) (*User, 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 UserMutation) 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 UserMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 User entities.
func (m *UserMutation) SetID(id uuid.UUID) {
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 *UserMutation) ID() (id uuid.UUID, 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 *UserMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().User.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *UserMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *UserMutation) 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 User entity.
// If the User 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 *UserMutation) 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 *UserMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[user.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *UserMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[user.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *UserMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, user.FieldDeletedAt)
}
// SetName sets the "name" field.
func (m *UserMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *UserMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the User entity.
// If the User 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 *UserMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldName: %w", err)
}
return oldValue.Name, nil
}
// ResetName resets all changes to the "name" field.
func (m *UserMutation) ResetName() {
m.name = nil
}
// SetEmail sets the "email" field.
func (m *UserMutation) SetEmail(s string) {
m.email = &s
}
// Email returns the value of the "email" field in the mutation.
func (m *UserMutation) Email() (r string, exists bool) {
v := m.email
if v == nil {
return
}
return *v, true
}
// OldEmail returns the old "email" field's value of the User entity.
// If the User 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 *UserMutation) OldEmail(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEmail is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEmail requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEmail: %w", err)
}
return oldValue.Email, nil
}
// ClearEmail clears the value of the "email" field.
func (m *UserMutation) ClearEmail() {
m.email = nil
m.clearedFields[user.FieldEmail] = struct{}{}
}
// EmailCleared returns if the "email" field was cleared in this mutation.
func (m *UserMutation) EmailCleared() bool {
_, ok := m.clearedFields[user.FieldEmail]
return ok
}
// ResetEmail resets all changes to the "email" field.
func (m *UserMutation) ResetEmail() {
m.email = nil
delete(m.clearedFields, user.FieldEmail)
}
// SetAvatarURL sets the "avatar_url" field.
func (m *UserMutation) SetAvatarURL(s string) {
m.avatar_url = &s
}
// AvatarURL returns the value of the "avatar_url" field in the mutation.
func (m *UserMutation) AvatarURL() (r string, exists bool) {
v := m.avatar_url
if v == nil {
return
}
return *v, true
}
// OldAvatarURL returns the old "avatar_url" field's value of the User entity.
// If the User 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 *UserMutation) OldAvatarURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAvatarURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAvatarURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAvatarURL: %w", err)
}
return oldValue.AvatarURL, nil
}
// ClearAvatarURL clears the value of the "avatar_url" field.
func (m *UserMutation) ClearAvatarURL() {
m.avatar_url = nil
m.clearedFields[user.FieldAvatarURL] = struct{}{}
}
// AvatarURLCleared returns if the "avatar_url" field was cleared in this mutation.
func (m *UserMutation) AvatarURLCleared() bool {
_, ok := m.clearedFields[user.FieldAvatarURL]
return ok
}
// ResetAvatarURL resets all changes to the "avatar_url" field.
func (m *UserMutation) ResetAvatarURL() {
m.avatar_url = nil
delete(m.clearedFields, user.FieldAvatarURL)
}
// SetPassword sets the "password" field.
func (m *UserMutation) SetPassword(s string) {
m.password = &s
}
// Password returns the value of the "password" field in the mutation.
func (m *UserMutation) Password() (r string, exists bool) {
v := m.password
if v == nil {
return
}
return *v, true
}
// OldPassword returns the old "password" field's value of the User entity.
// If the User 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 *UserMutation) OldPassword(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPassword is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPassword requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPassword: %w", err)
}
return oldValue.Password, nil
}
// ClearPassword clears the value of the "password" field.
func (m *UserMutation) ClearPassword() {
m.password = nil
m.clearedFields[user.FieldPassword] = struct{}{}
}
// PasswordCleared returns if the "password" field was cleared in this mutation.
func (m *UserMutation) PasswordCleared() bool {
_, ok := m.clearedFields[user.FieldPassword]
return ok
}
// ResetPassword resets all changes to the "password" field.
func (m *UserMutation) ResetPassword() {
m.password = nil
delete(m.clearedFields, user.FieldPassword)
}
// SetRole sets the "role" field.
func (m *UserMutation) SetRole(cr consts.UserRole) {
m.role = &cr
}
// Role returns the value of the "role" field in the mutation.
func (m *UserMutation) Role() (r consts.UserRole, exists bool) {
v := m.role
if v == nil {
return
}
return *v, true
}
// OldRole returns the old "role" field's value of the User entity.
// If the User 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 *UserMutation) OldRole(ctx context.Context) (v consts.UserRole, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRole is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRole requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRole: %w", err)
}
return oldValue.Role, nil
}
// ResetRole resets all changes to the "role" field.
func (m *UserMutation) ResetRole() {
m.role = nil
}
// SetStatus sets the "status" field.
func (m *UserMutation) SetStatus(cs consts.UserStatus) {
m.status = &cs
}
// Status returns the value of the "status" field in the mutation.
func (m *UserMutation) Status() (r consts.UserStatus, exists bool) {
v := m.status
if v == nil {
return
}
return *v, true
}
// OldStatus returns the old "status" field's value of the User entity.
// If the User 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 *UserMutation) OldStatus(ctx context.Context) (v consts.UserStatus, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldStatus is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldStatus requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStatus: %w", err)
}
return oldValue.Status, nil
}
// ResetStatus resets all changes to the "status" field.
func (m *UserMutation) ResetStatus() {
m.status = nil
}
// SetIsBlocked sets the "is_blocked" field.
func (m *UserMutation) SetIsBlocked(b bool) {
m.is_blocked = &b
}
// IsBlocked returns the value of the "is_blocked" field in the mutation.
func (m *UserMutation) IsBlocked() (r bool, exists bool) {
v := m.is_blocked
if v == nil {
return
}
return *v, true
}
// OldIsBlocked returns the old "is_blocked" field's value of the User entity.
// If the User 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 *UserMutation) OldIsBlocked(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldIsBlocked is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldIsBlocked requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIsBlocked: %w", err)
}
return oldValue.IsBlocked, nil
}
// ResetIsBlocked resets all changes to the "is_blocked" field.
func (m *UserMutation) ResetIsBlocked() {
m.is_blocked = nil
}
// SetDefaultConfigs sets the "default_configs" field.
func (m *UserMutation) SetDefaultConfigs(mct map[consts.DefaultConfigType]uuid.UUID) {
m.default_configs = &mct
}
// DefaultConfigs returns the value of the "default_configs" field in the mutation.
func (m *UserMutation) DefaultConfigs() (r map[consts.DefaultConfigType]uuid.UUID, exists bool) {
v := m.default_configs
if v == nil {
return
}
return *v, true
}
// OldDefaultConfigs returns the old "default_configs" field's value of the User entity.
// If the User 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 *UserMutation) OldDefaultConfigs(ctx context.Context) (v map[consts.DefaultConfigType]uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDefaultConfigs is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldDefaultConfigs requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDefaultConfigs: %w", err)
}
return oldValue.DefaultConfigs, nil
}
// ClearDefaultConfigs clears the value of the "default_configs" field.
func (m *UserMutation) ClearDefaultConfigs() {
m.default_configs = nil
m.clearedFields[user.FieldDefaultConfigs] = struct{}{}
}
// DefaultConfigsCleared returns if the "default_configs" field was cleared in this mutation.
func (m *UserMutation) DefaultConfigsCleared() bool {
_, ok := m.clearedFields[user.FieldDefaultConfigs]
return ok
}
// ResetDefaultConfigs resets all changes to the "default_configs" field.
func (m *UserMutation) ResetDefaultConfigs() {
m.default_configs = nil
delete(m.clearedFields, user.FieldDefaultConfigs)
}
// SetCreatedAt sets the "created_at" field.
func (m *UserMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *UserMutation) 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 User entity.
// If the User 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 *UserMutation) 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 *UserMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *UserMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *UserMutation) 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 User entity.
// If the User 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 *UserMutation) 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 *UserMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// AddIdentityIDs adds the "identities" edge to the UserIdentity entity by ids.
func (m *UserMutation) AddIdentityIDs(ids ...uuid.UUID) {
if m.identities == nil {
m.identities = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.identities[ids[i]] = struct{}{}
}
}
// ClearIdentities clears the "identities" edge to the UserIdentity entity.
func (m *UserMutation) ClearIdentities() {
m.clearedidentities = true
}
// IdentitiesCleared reports if the "identities" edge to the UserIdentity entity was cleared.
func (m *UserMutation) IdentitiesCleared() bool {
return m.clearedidentities
}
// RemoveIdentityIDs removes the "identities" edge to the UserIdentity entity by IDs.
func (m *UserMutation) RemoveIdentityIDs(ids ...uuid.UUID) {
if m.removedidentities == nil {
m.removedidentities = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.identities, ids[i])
m.removedidentities[ids[i]] = struct{}{}
}
}
// RemovedIdentities returns the removed IDs of the "identities" edge to the UserIdentity entity.
func (m *UserMutation) RemovedIdentitiesIDs() (ids []uuid.UUID) {
for id := range m.removedidentities {
ids = append(ids, id)
}
return
}
// IdentitiesIDs returns the "identities" edge IDs in the mutation.
func (m *UserMutation) IdentitiesIDs() (ids []uuid.UUID) {
for id := range m.identities {
ids = append(ids, id)
}
return
}
// ResetIdentities resets all changes to the "identities" edge.
func (m *UserMutation) ResetIdentities() {
m.identities = nil
m.clearedidentities = false
m.removedidentities = nil
}
// AddAuditIDs adds the "audits" edge to the Audit entity by ids.
func (m *UserMutation) AddAuditIDs(ids ...uuid.UUID) {
if m.audits == nil {
m.audits = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.audits[ids[i]] = struct{}{}
}
}
// ClearAudits clears the "audits" edge to the Audit entity.
func (m *UserMutation) ClearAudits() {
m.clearedaudits = true
}
// AuditsCleared reports if the "audits" edge to the Audit entity was cleared.
func (m *UserMutation) AuditsCleared() bool {
return m.clearedaudits
}
// RemoveAuditIDs removes the "audits" edge to the Audit entity by IDs.
func (m *UserMutation) RemoveAuditIDs(ids ...uuid.UUID) {
if m.removedaudits == nil {
m.removedaudits = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.audits, ids[i])
m.removedaudits[ids[i]] = struct{}{}
}
}
// RemovedAudits returns the removed IDs of the "audits" edge to the Audit entity.
func (m *UserMutation) RemovedAuditsIDs() (ids []uuid.UUID) {
for id := range m.removedaudits {
ids = append(ids, id)
}
return
}
// AuditsIDs returns the "audits" edge IDs in the mutation.
func (m *UserMutation) AuditsIDs() (ids []uuid.UUID) {
for id := range m.audits {
ids = append(ids, id)
}
return
}
// ResetAudits resets all changes to the "audits" edge.
func (m *UserMutation) ResetAudits() {
m.audits = nil
m.clearedaudits = false
m.removedaudits = nil
}
// AddTeamIDs adds the "teams" edge to the Team entity by ids.
func (m *UserMutation) AddTeamIDs(ids ...uuid.UUID) {
if m.teams == nil {
m.teams = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.teams[ids[i]] = struct{}{}
}
}
// ClearTeams clears the "teams" edge to the Team entity.
func (m *UserMutation) ClearTeams() {
m.clearedteams = true
}
// TeamsCleared reports if the "teams" edge to the Team entity was cleared.
func (m *UserMutation) TeamsCleared() bool {
return m.clearedteams
}
// RemoveTeamIDs removes the "teams" edge to the Team entity by IDs.
func (m *UserMutation) RemoveTeamIDs(ids ...uuid.UUID) {
if m.removedteams == nil {
m.removedteams = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.teams, ids[i])
m.removedteams[ids[i]] = struct{}{}
}
}
// RemovedTeams returns the removed IDs of the "teams" edge to the Team entity.
func (m *UserMutation) RemovedTeamsIDs() (ids []uuid.UUID) {
for id := range m.removedteams {
ids = append(ids, id)
}
return
}
// TeamsIDs returns the "teams" edge IDs in the mutation.
func (m *UserMutation) TeamsIDs() (ids []uuid.UUID) {
for id := range m.teams {
ids = append(ids, id)
}
return
}
// ResetTeams resets all changes to the "teams" edge.
func (m *UserMutation) ResetTeams() {
m.teams = nil
m.clearedteams = false
m.removedteams = nil
}
// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids.
func (m *UserMutation) AddGroupIDs(ids ...uuid.UUID) {
if m.groups == nil {
m.groups = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.groups[ids[i]] = struct{}{}
}
}
// ClearGroups clears the "groups" edge to the TeamGroup entity.
func (m *UserMutation) ClearGroups() {
m.clearedgroups = true
}
// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared.
func (m *UserMutation) GroupsCleared() bool {
return m.clearedgroups
}
// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs.
func (m *UserMutation) RemoveGroupIDs(ids ...uuid.UUID) {
if m.removedgroups == nil {
m.removedgroups = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.groups, ids[i])
m.removedgroups[ids[i]] = struct{}{}
}
}
// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity.
func (m *UserMutation) RemovedGroupsIDs() (ids []uuid.UUID) {
for id := range m.removedgroups {
ids = append(ids, id)
}
return
}
// GroupsIDs returns the "groups" edge IDs in the mutation.
func (m *UserMutation) GroupsIDs() (ids []uuid.UUID) {
for id := range m.groups {
ids = append(ids, id)
}
return
}
// ResetGroups resets all changes to the "groups" edge.
func (m *UserMutation) ResetGroups() {
m.groups = nil
m.clearedgroups = false
m.removedgroups = nil
}
// AddModelIDs adds the "models" edge to the Model entity by ids.
func (m *UserMutation) AddModelIDs(ids ...uuid.UUID) {
if m.models == nil {
m.models = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.models[ids[i]] = struct{}{}
}
}
// ClearModels clears the "models" edge to the Model entity.
func (m *UserMutation) ClearModels() {
m.clearedmodels = true
}
// ModelsCleared reports if the "models" edge to the Model entity was cleared.
func (m *UserMutation) ModelsCleared() bool {
return m.clearedmodels
}
// RemoveModelIDs removes the "models" edge to the Model entity by IDs.
func (m *UserMutation) RemoveModelIDs(ids ...uuid.UUID) {
if m.removedmodels == nil {
m.removedmodels = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.models, ids[i])
m.removedmodels[ids[i]] = struct{}{}
}
}
// RemovedModels returns the removed IDs of the "models" edge to the Model entity.
func (m *UserMutation) RemovedModelsIDs() (ids []uuid.UUID) {
for id := range m.removedmodels {
ids = append(ids, id)
}
return
}
// ModelsIDs returns the "models" edge IDs in the mutation.
func (m *UserMutation) ModelsIDs() (ids []uuid.UUID) {
for id := range m.models {
ids = append(ids, id)
}
return
}
// ResetModels resets all changes to the "models" edge.
func (m *UserMutation) ResetModels() {
m.models = nil
m.clearedmodels = false
m.removedmodels = nil
}
// AddImageIDs adds the "images" edge to the Image entity by ids.
func (m *UserMutation) AddImageIDs(ids ...uuid.UUID) {
if m.images == nil {
m.images = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.images[ids[i]] = struct{}{}
}
}
// ClearImages clears the "images" edge to the Image entity.
func (m *UserMutation) ClearImages() {
m.clearedimages = true
}
// ImagesCleared reports if the "images" edge to the Image entity was cleared.
func (m *UserMutation) ImagesCleared() bool {
return m.clearedimages
}
// RemoveImageIDs removes the "images" edge to the Image entity by IDs.
func (m *UserMutation) RemoveImageIDs(ids ...uuid.UUID) {
if m.removedimages == nil {
m.removedimages = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.images, ids[i])
m.removedimages[ids[i]] = struct{}{}
}
}
// RemovedImages returns the removed IDs of the "images" edge to the Image entity.
func (m *UserMutation) RemovedImagesIDs() (ids []uuid.UUID) {
for id := range m.removedimages {
ids = append(ids, id)
}
return
}
// ImagesIDs returns the "images" edge IDs in the mutation.
func (m *UserMutation) ImagesIDs() (ids []uuid.UUID) {
for id := range m.images {
ids = append(ids, id)
}
return
}
// ResetImages resets all changes to the "images" edge.
func (m *UserMutation) ResetImages() {
m.images = nil
m.clearedimages = false
m.removedimages = nil
}
// AddHostIDs adds the "hosts" edge to the Host entity by ids.
func (m *UserMutation) AddHostIDs(ids ...string) {
if m.hosts == nil {
m.hosts = make(map[string]struct{})
}
for i := range ids {
m.hosts[ids[i]] = struct{}{}
}
}
// ClearHosts clears the "hosts" edge to the Host entity.
func (m *UserMutation) ClearHosts() {
m.clearedhosts = true
}
// HostsCleared reports if the "hosts" edge to the Host entity was cleared.
func (m *UserMutation) HostsCleared() bool {
return m.clearedhosts
}
// RemoveHostIDs removes the "hosts" edge to the Host entity by IDs.
func (m *UserMutation) RemoveHostIDs(ids ...string) {
if m.removedhosts == nil {
m.removedhosts = make(map[string]struct{})
}
for i := range ids {
delete(m.hosts, ids[i])
m.removedhosts[ids[i]] = struct{}{}
}
}
// RemovedHosts returns the removed IDs of the "hosts" edge to the Host entity.
func (m *UserMutation) RemovedHostsIDs() (ids []string) {
for id := range m.removedhosts {
ids = append(ids, id)
}
return
}
// HostsIDs returns the "hosts" edge IDs in the mutation.
func (m *UserMutation) HostsIDs() (ids []string) {
for id := range m.hosts {
ids = append(ids, id)
}
return
}
// ResetHosts resets all changes to the "hosts" edge.
func (m *UserMutation) ResetHosts() {
m.hosts = nil
m.clearedhosts = false
m.removedhosts = nil
}
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by ids.
func (m *UserMutation) AddVMIDs(ids ...string) {
if m.vms == nil {
m.vms = make(map[string]struct{})
}
for i := range ids {
m.vms[ids[i]] = struct{}{}
}
}
// ClearVms clears the "vms" edge to the VirtualMachine entity.
func (m *UserMutation) ClearVms() {
m.clearedvms = true
}
// VmsCleared reports if the "vms" edge to the VirtualMachine entity was cleared.
func (m *UserMutation) VmsCleared() bool {
return m.clearedvms
}
// RemoveVMIDs removes the "vms" edge to the VirtualMachine entity by IDs.
func (m *UserMutation) RemoveVMIDs(ids ...string) {
if m.removedvms == nil {
m.removedvms = make(map[string]struct{})
}
for i := range ids {
delete(m.vms, ids[i])
m.removedvms[ids[i]] = struct{}{}
}
}
// RemovedVms returns the removed IDs of the "vms" edge to the VirtualMachine entity.
func (m *UserMutation) RemovedVmsIDs() (ids []string) {
for id := range m.removedvms {
ids = append(ids, id)
}
return
}
// VmsIDs returns the "vms" edge IDs in the mutation.
func (m *UserMutation) VmsIDs() (ids []string) {
for id := range m.vms {
ids = append(ids, id)
}
return
}
// ResetVms resets all changes to the "vms" edge.
func (m *UserMutation) ResetVms() {
m.vms = nil
m.clearedvms = false
m.removedvms = nil
}
// AddTaskIDs adds the "tasks" edge to the Task entity by ids.
func (m *UserMutation) AddTaskIDs(ids ...uuid.UUID) {
if m.tasks == nil {
m.tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.tasks[ids[i]] = struct{}{}
}
}
// ClearTasks clears the "tasks" edge to the Task entity.
func (m *UserMutation) ClearTasks() {
m.clearedtasks = true
}
// TasksCleared reports if the "tasks" edge to the Task entity was cleared.
func (m *UserMutation) TasksCleared() bool {
return m.clearedtasks
}
// RemoveTaskIDs removes the "tasks" edge to the Task entity by IDs.
func (m *UserMutation) RemoveTaskIDs(ids ...uuid.UUID) {
if m.removedtasks == nil {
m.removedtasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.tasks, ids[i])
m.removedtasks[ids[i]] = struct{}{}
}
}
// RemovedTasks returns the removed IDs of the "tasks" edge to the Task entity.
func (m *UserMutation) RemovedTasksIDs() (ids []uuid.UUID) {
for id := range m.removedtasks {
ids = append(ids, id)
}
return
}
// TasksIDs returns the "tasks" edge IDs in the mutation.
func (m *UserMutation) TasksIDs() (ids []uuid.UUID) {
for id := range m.tasks {
ids = append(ids, id)
}
return
}
// ResetTasks resets all changes to the "tasks" edge.
func (m *UserMutation) ResetTasks() {
m.tasks = nil
m.clearedtasks = false
m.removedtasks = nil
}
// AddTaskModelSwitchIDs adds the "task_model_switches" edge to the TaskModelSwitch entity by ids.
func (m *UserMutation) AddTaskModelSwitchIDs(ids ...uuid.UUID) {
if m.task_model_switches == nil {
m.task_model_switches = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.task_model_switches[ids[i]] = struct{}{}
}
}
// ClearTaskModelSwitches clears the "task_model_switches" edge to the TaskModelSwitch entity.
func (m *UserMutation) ClearTaskModelSwitches() {
m.clearedtask_model_switches = true
}
// TaskModelSwitchesCleared reports if the "task_model_switches" edge to the TaskModelSwitch entity was cleared.
func (m *UserMutation) TaskModelSwitchesCleared() bool {
return m.clearedtask_model_switches
}
// RemoveTaskModelSwitchIDs removes the "task_model_switches" edge to the TaskModelSwitch entity by IDs.
func (m *UserMutation) RemoveTaskModelSwitchIDs(ids ...uuid.UUID) {
if m.removedtask_model_switches == nil {
m.removedtask_model_switches = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.task_model_switches, ids[i])
m.removedtask_model_switches[ids[i]] = struct{}{}
}
}
// RemovedTaskModelSwitches returns the removed IDs of the "task_model_switches" edge to the TaskModelSwitch entity.
func (m *UserMutation) RemovedTaskModelSwitchesIDs() (ids []uuid.UUID) {
for id := range m.removedtask_model_switches {
ids = append(ids, id)
}
return
}
// TaskModelSwitchesIDs returns the "task_model_switches" edge IDs in the mutation.
func (m *UserMutation) TaskModelSwitchesIDs() (ids []uuid.UUID) {
for id := range m.task_model_switches {
ids = append(ids, id)
}
return
}
// ResetTaskModelSwitches resets all changes to the "task_model_switches" edge.
func (m *UserMutation) ResetTaskModelSwitches() {
m.task_model_switches = nil
m.clearedtask_model_switches = false
m.removedtask_model_switches = nil
}
// AddGitIdentityIDs adds the "git_identities" edge to the GitIdentity entity by ids.
func (m *UserMutation) AddGitIdentityIDs(ids ...uuid.UUID) {
if m.git_identities == nil {
m.git_identities = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.git_identities[ids[i]] = struct{}{}
}
}
// ClearGitIdentities clears the "git_identities" edge to the GitIdentity entity.
func (m *UserMutation) ClearGitIdentities() {
m.clearedgit_identities = true
}
// GitIdentitiesCleared reports if the "git_identities" edge to the GitIdentity entity was cleared.
func (m *UserMutation) GitIdentitiesCleared() bool {
return m.clearedgit_identities
}
// RemoveGitIdentityIDs removes the "git_identities" edge to the GitIdentity entity by IDs.
func (m *UserMutation) RemoveGitIdentityIDs(ids ...uuid.UUID) {
if m.removedgit_identities == nil {
m.removedgit_identities = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.git_identities, ids[i])
m.removedgit_identities[ids[i]] = struct{}{}
}
}
// RemovedGitIdentities returns the removed IDs of the "git_identities" edge to the GitIdentity entity.
func (m *UserMutation) RemovedGitIdentitiesIDs() (ids []uuid.UUID) {
for id := range m.removedgit_identities {
ids = append(ids, id)
}
return
}
// GitIdentitiesIDs returns the "git_identities" edge IDs in the mutation.
func (m *UserMutation) GitIdentitiesIDs() (ids []uuid.UUID) {
for id := range m.git_identities {
ids = append(ids, id)
}
return
}
// ResetGitIdentities resets all changes to the "git_identities" edge.
func (m *UserMutation) ResetGitIdentities() {
m.git_identities = nil
m.clearedgit_identities = false
m.removedgit_identities = nil
}
// AddProjectIDs adds the "projects" edge to the Project entity by ids.
func (m *UserMutation) AddProjectIDs(ids ...uuid.UUID) {
if m.projects == nil {
m.projects = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.projects[ids[i]] = struct{}{}
}
}
// ClearProjects clears the "projects" edge to the Project entity.
func (m *UserMutation) ClearProjects() {
m.clearedprojects = true
}
// ProjectsCleared reports if the "projects" edge to the Project entity was cleared.
func (m *UserMutation) ProjectsCleared() bool {
return m.clearedprojects
}
// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs.
func (m *UserMutation) RemoveProjectIDs(ids ...uuid.UUID) {
if m.removedprojects == nil {
m.removedprojects = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.projects, ids[i])
m.removedprojects[ids[i]] = struct{}{}
}
}
// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity.
func (m *UserMutation) RemovedProjectsIDs() (ids []uuid.UUID) {
for id := range m.removedprojects {
ids = append(ids, id)
}
return
}
// ProjectsIDs returns the "projects" edge IDs in the mutation.
func (m *UserMutation) ProjectsIDs() (ids []uuid.UUID) {
for id := range m.projects {
ids = append(ids, id)
}
return
}
// ResetProjects resets all changes to the "projects" edge.
func (m *UserMutation) ResetProjects() {
m.projects = nil
m.clearedprojects = false
m.removedprojects = nil
}
// AddProjectIssueIDs adds the "project_issues" edge to the ProjectIssue entity by ids.
func (m *UserMutation) AddProjectIssueIDs(ids ...uuid.UUID) {
if m.project_issues == nil {
m.project_issues = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.project_issues[ids[i]] = struct{}{}
}
}
// ClearProjectIssues clears the "project_issues" edge to the ProjectIssue entity.
func (m *UserMutation) ClearProjectIssues() {
m.clearedproject_issues = true
}
// ProjectIssuesCleared reports if the "project_issues" edge to the ProjectIssue entity was cleared.
func (m *UserMutation) ProjectIssuesCleared() bool {
return m.clearedproject_issues
}
// RemoveProjectIssueIDs removes the "project_issues" edge to the ProjectIssue entity by IDs.
func (m *UserMutation) RemoveProjectIssueIDs(ids ...uuid.UUID) {
if m.removedproject_issues == nil {
m.removedproject_issues = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.project_issues, ids[i])
m.removedproject_issues[ids[i]] = struct{}{}
}
}
// RemovedProjectIssues returns the removed IDs of the "project_issues" edge to the ProjectIssue entity.
func (m *UserMutation) RemovedProjectIssuesIDs() (ids []uuid.UUID) {
for id := range m.removedproject_issues {
ids = append(ids, id)
}
return
}
// ProjectIssuesIDs returns the "project_issues" edge IDs in the mutation.
func (m *UserMutation) ProjectIssuesIDs() (ids []uuid.UUID) {
for id := range m.project_issues {
ids = append(ids, id)
}
return
}
// ResetProjectIssues resets all changes to the "project_issues" edge.
func (m *UserMutation) ResetProjectIssues() {
m.project_issues = nil
m.clearedproject_issues = false
m.removedproject_issues = nil
}
// AddAssignedIssueIDs adds the "assigned_issues" edge to the ProjectIssue entity by ids.
func (m *UserMutation) AddAssignedIssueIDs(ids ...uuid.UUID) {
if m.assigned_issues == nil {
m.assigned_issues = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.assigned_issues[ids[i]] = struct{}{}
}
}
// ClearAssignedIssues clears the "assigned_issues" edge to the ProjectIssue entity.
func (m *UserMutation) ClearAssignedIssues() {
m.clearedassigned_issues = true
}
// AssignedIssuesCleared reports if the "assigned_issues" edge to the ProjectIssue entity was cleared.
func (m *UserMutation) AssignedIssuesCleared() bool {
return m.clearedassigned_issues
}
// RemoveAssignedIssueIDs removes the "assigned_issues" edge to the ProjectIssue entity by IDs.
func (m *UserMutation) RemoveAssignedIssueIDs(ids ...uuid.UUID) {
if m.removedassigned_issues == nil {
m.removedassigned_issues = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.assigned_issues, ids[i])
m.removedassigned_issues[ids[i]] = struct{}{}
}
}
// RemovedAssignedIssues returns the removed IDs of the "assigned_issues" edge to the ProjectIssue entity.
func (m *UserMutation) RemovedAssignedIssuesIDs() (ids []uuid.UUID) {
for id := range m.removedassigned_issues {
ids = append(ids, id)
}
return
}
// AssignedIssuesIDs returns the "assigned_issues" edge IDs in the mutation.
func (m *UserMutation) AssignedIssuesIDs() (ids []uuid.UUID) {
for id := range m.assigned_issues {
ids = append(ids, id)
}
return
}
// ResetAssignedIssues resets all changes to the "assigned_issues" edge.
func (m *UserMutation) ResetAssignedIssues() {
m.assigned_issues = nil
m.clearedassigned_issues = false
m.removedassigned_issues = nil
}
// AddProjectCollaboratorIDs adds the "project_collaborators" edge to the ProjectCollaborator entity by ids.
func (m *UserMutation) AddProjectCollaboratorIDs(ids ...uuid.UUID) {
if m.project_collaborators == nil {
m.project_collaborators = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.project_collaborators[ids[i]] = struct{}{}
}
}
// ClearProjectCollaborators clears the "project_collaborators" edge to the ProjectCollaborator entity.
func (m *UserMutation) ClearProjectCollaborators() {
m.clearedproject_collaborators = true
}
// ProjectCollaboratorsCleared reports if the "project_collaborators" edge to the ProjectCollaborator entity was cleared.
func (m *UserMutation) ProjectCollaboratorsCleared() bool {
return m.clearedproject_collaborators
}
// RemoveProjectCollaboratorIDs removes the "project_collaborators" edge to the ProjectCollaborator entity by IDs.
func (m *UserMutation) RemoveProjectCollaboratorIDs(ids ...uuid.UUID) {
if m.removedproject_collaborators == nil {
m.removedproject_collaborators = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.project_collaborators, ids[i])
m.removedproject_collaborators[ids[i]] = struct{}{}
}
}
// RemovedProjectCollaborators returns the removed IDs of the "project_collaborators" edge to the ProjectCollaborator entity.
func (m *UserMutation) RemovedProjectCollaboratorsIDs() (ids []uuid.UUID) {
for id := range m.removedproject_collaborators {
ids = append(ids, id)
}
return
}
// ProjectCollaboratorsIDs returns the "project_collaborators" edge IDs in the mutation.
func (m *UserMutation) ProjectCollaboratorsIDs() (ids []uuid.UUID) {
for id := range m.project_collaborators {
ids = append(ids, id)
}
return
}
// ResetProjectCollaborators resets all changes to the "project_collaborators" edge.
func (m *UserMutation) ResetProjectCollaborators() {
m.project_collaborators = nil
m.clearedproject_collaborators = false
m.removedproject_collaborators = nil
}
// AddProjectIssueCommentIDs adds the "project_issue_comments" edge to the ProjectIssueComment entity by ids.
func (m *UserMutation) AddProjectIssueCommentIDs(ids ...uuid.UUID) {
if m.project_issue_comments == nil {
m.project_issue_comments = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.project_issue_comments[ids[i]] = struct{}{}
}
}
// ClearProjectIssueComments clears the "project_issue_comments" edge to the ProjectIssueComment entity.
func (m *UserMutation) ClearProjectIssueComments() {
m.clearedproject_issue_comments = true
}
// ProjectIssueCommentsCleared reports if the "project_issue_comments" edge to the ProjectIssueComment entity was cleared.
func (m *UserMutation) ProjectIssueCommentsCleared() bool {
return m.clearedproject_issue_comments
}
// RemoveProjectIssueCommentIDs removes the "project_issue_comments" edge to the ProjectIssueComment entity by IDs.
func (m *UserMutation) RemoveProjectIssueCommentIDs(ids ...uuid.UUID) {
if m.removedproject_issue_comments == nil {
m.removedproject_issue_comments = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.project_issue_comments, ids[i])
m.removedproject_issue_comments[ids[i]] = struct{}{}
}
}
// RemovedProjectIssueComments returns the removed IDs of the "project_issue_comments" edge to the ProjectIssueComment entity.
func (m *UserMutation) RemovedProjectIssueCommentsIDs() (ids []uuid.UUID) {
for id := range m.removedproject_issue_comments {
ids = append(ids, id)
}
return
}
// ProjectIssueCommentsIDs returns the "project_issue_comments" edge IDs in the mutation.
func (m *UserMutation) ProjectIssueCommentsIDs() (ids []uuid.UUID) {
for id := range m.project_issue_comments {
ids = append(ids, id)
}
return
}
// ResetProjectIssueComments resets all changes to the "project_issue_comments" edge.
func (m *UserMutation) ResetProjectIssueComments() {
m.project_issue_comments = nil
m.clearedproject_issue_comments = false
m.removedproject_issue_comments = nil
}
// AddGitBotIDs adds the "git_bots" edge to the GitBot entity by ids.
func (m *UserMutation) AddGitBotIDs(ids ...uuid.UUID) {
if m.git_bots == nil {
m.git_bots = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.git_bots[ids[i]] = struct{}{}
}
}
// ClearGitBots clears the "git_bots" edge to the GitBot entity.
func (m *UserMutation) ClearGitBots() {
m.clearedgit_bots = true
}
// GitBotsCleared reports if the "git_bots" edge to the GitBot entity was cleared.
func (m *UserMutation) GitBotsCleared() bool {
return m.clearedgit_bots
}
// RemoveGitBotIDs removes the "git_bots" edge to the GitBot entity by IDs.
func (m *UserMutation) RemoveGitBotIDs(ids ...uuid.UUID) {
if m.removedgit_bots == nil {
m.removedgit_bots = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.git_bots, ids[i])
m.removedgit_bots[ids[i]] = struct{}{}
}
}
// RemovedGitBots returns the removed IDs of the "git_bots" edge to the GitBot entity.
func (m *UserMutation) RemovedGitBotsIDs() (ids []uuid.UUID) {
for id := range m.removedgit_bots {
ids = append(ids, id)
}
return
}
// GitBotsIDs returns the "git_bots" edge IDs in the mutation.
func (m *UserMutation) GitBotsIDs() (ids []uuid.UUID) {
for id := range m.git_bots {
ids = append(ids, id)
}
return
}
// ResetGitBots resets all changes to the "git_bots" edge.
func (m *UserMutation) ResetGitBots() {
m.git_bots = nil
m.clearedgit_bots = false
m.removedgit_bots = nil
}
// AddMcpUpstreamIDs adds the "mcp_upstreams" edge to the MCPUpstream entity by ids.
func (m *UserMutation) AddMcpUpstreamIDs(ids ...uuid.UUID) {
if m.mcp_upstreams == nil {
m.mcp_upstreams = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.mcp_upstreams[ids[i]] = struct{}{}
}
}
// ClearMcpUpstreams clears the "mcp_upstreams" edge to the MCPUpstream entity.
func (m *UserMutation) ClearMcpUpstreams() {
m.clearedmcp_upstreams = true
}
// McpUpstreamsCleared reports if the "mcp_upstreams" edge to the MCPUpstream entity was cleared.
func (m *UserMutation) McpUpstreamsCleared() bool {
return m.clearedmcp_upstreams
}
// RemoveMcpUpstreamIDs removes the "mcp_upstreams" edge to the MCPUpstream entity by IDs.
func (m *UserMutation) RemoveMcpUpstreamIDs(ids ...uuid.UUID) {
if m.removedmcp_upstreams == nil {
m.removedmcp_upstreams = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.mcp_upstreams, ids[i])
m.removedmcp_upstreams[ids[i]] = struct{}{}
}
}
// RemovedMcpUpstreams returns the removed IDs of the "mcp_upstreams" edge to the MCPUpstream entity.
func (m *UserMutation) RemovedMcpUpstreamsIDs() (ids []uuid.UUID) {
for id := range m.removedmcp_upstreams {
ids = append(ids, id)
}
return
}
// McpUpstreamsIDs returns the "mcp_upstreams" edge IDs in the mutation.
func (m *UserMutation) McpUpstreamsIDs() (ids []uuid.UUID) {
for id := range m.mcp_upstreams {
ids = append(ids, id)
}
return
}
// ResetMcpUpstreams resets all changes to the "mcp_upstreams" edge.
func (m *UserMutation) ResetMcpUpstreams() {
m.mcp_upstreams = nil
m.clearedmcp_upstreams = false
m.removedmcp_upstreams = nil
}
// AddTeamMemberIDs adds the "team_members" edge to the TeamMember entity by ids.
func (m *UserMutation) AddTeamMemberIDs(ids ...uuid.UUID) {
if m.team_members == nil {
m.team_members = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_members[ids[i]] = struct{}{}
}
}
// ClearTeamMembers clears the "team_members" edge to the TeamMember entity.
func (m *UserMutation) ClearTeamMembers() {
m.clearedteam_members = true
}
// TeamMembersCleared reports if the "team_members" edge to the TeamMember entity was cleared.
func (m *UserMutation) TeamMembersCleared() bool {
return m.clearedteam_members
}
// RemoveTeamMemberIDs removes the "team_members" edge to the TeamMember entity by IDs.
func (m *UserMutation) RemoveTeamMemberIDs(ids ...uuid.UUID) {
if m.removedteam_members == nil {
m.removedteam_members = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_members, ids[i])
m.removedteam_members[ids[i]] = struct{}{}
}
}
// RemovedTeamMembers returns the removed IDs of the "team_members" edge to the TeamMember entity.
func (m *UserMutation) RemovedTeamMembersIDs() (ids []uuid.UUID) {
for id := range m.removedteam_members {
ids = append(ids, id)
}
return
}
// TeamMembersIDs returns the "team_members" edge IDs in the mutation.
func (m *UserMutation) TeamMembersIDs() (ids []uuid.UUID) {
for id := range m.team_members {
ids = append(ids, id)
}
return
}
// ResetTeamMembers resets all changes to the "team_members" edge.
func (m *UserMutation) ResetTeamMembers() {
m.team_members = nil
m.clearedteam_members = false
m.removedteam_members = nil
}
// AddTeamGroupMemberIDs adds the "team_group_members" edge to the TeamGroupMember entity by ids.
func (m *UserMutation) AddTeamGroupMemberIDs(ids ...uuid.UUID) {
if m.team_group_members == nil {
m.team_group_members = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.team_group_members[ids[i]] = struct{}{}
}
}
// ClearTeamGroupMembers clears the "team_group_members" edge to the TeamGroupMember entity.
func (m *UserMutation) ClearTeamGroupMembers() {
m.clearedteam_group_members = true
}
// TeamGroupMembersCleared reports if the "team_group_members" edge to the TeamGroupMember entity was cleared.
func (m *UserMutation) TeamGroupMembersCleared() bool {
return m.clearedteam_group_members
}
// RemoveTeamGroupMemberIDs removes the "team_group_members" edge to the TeamGroupMember entity by IDs.
func (m *UserMutation) RemoveTeamGroupMemberIDs(ids ...uuid.UUID) {
if m.removedteam_group_members == nil {
m.removedteam_group_members = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.team_group_members, ids[i])
m.removedteam_group_members[ids[i]] = struct{}{}
}
}
// RemovedTeamGroupMembers returns the removed IDs of the "team_group_members" edge to the TeamGroupMember entity.
func (m *UserMutation) RemovedTeamGroupMembersIDs() (ids []uuid.UUID) {
for id := range m.removedteam_group_members {
ids = append(ids, id)
}
return
}
// TeamGroupMembersIDs returns the "team_group_members" edge IDs in the mutation.
func (m *UserMutation) TeamGroupMembersIDs() (ids []uuid.UUID) {
for id := range m.team_group_members {
ids = append(ids, id)
}
return
}
// ResetTeamGroupMembers resets all changes to the "team_group_members" edge.
func (m *UserMutation) ResetTeamGroupMembers() {
m.team_group_members = nil
m.clearedteam_group_members = false
m.removedteam_group_members = nil
}
// AddGitBotUserIDs adds the "git_bot_users" edge to the GitBotUser entity by ids.
func (m *UserMutation) AddGitBotUserIDs(ids ...uuid.UUID) {
if m.git_bot_users == nil {
m.git_bot_users = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.git_bot_users[ids[i]] = struct{}{}
}
}
// ClearGitBotUsers clears the "git_bot_users" edge to the GitBotUser entity.
func (m *UserMutation) ClearGitBotUsers() {
m.clearedgit_bot_users = true
}
// GitBotUsersCleared reports if the "git_bot_users" edge to the GitBotUser entity was cleared.
func (m *UserMutation) GitBotUsersCleared() bool {
return m.clearedgit_bot_users
}
// RemoveGitBotUserIDs removes the "git_bot_users" edge to the GitBotUser entity by IDs.
func (m *UserMutation) RemoveGitBotUserIDs(ids ...uuid.UUID) {
if m.removedgit_bot_users == nil {
m.removedgit_bot_users = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.git_bot_users, ids[i])
m.removedgit_bot_users[ids[i]] = struct{}{}
}
}
// RemovedGitBotUsers returns the removed IDs of the "git_bot_users" edge to the GitBotUser entity.
func (m *UserMutation) RemovedGitBotUsersIDs() (ids []uuid.UUID) {
for id := range m.removedgit_bot_users {
ids = append(ids, id)
}
return
}
// GitBotUsersIDs returns the "git_bot_users" edge IDs in the mutation.
func (m *UserMutation) GitBotUsersIDs() (ids []uuid.UUID) {
for id := range m.git_bot_users {
ids = append(ids, id)
}
return
}
// ResetGitBotUsers resets all changes to the "git_bot_users" edge.
func (m *UserMutation) ResetGitBotUsers() {
m.git_bot_users = nil
m.clearedgit_bot_users = false
m.removedgit_bot_users = nil
}
// Where appends a list predicates to the UserMutation builder.
func (m *UserMutation) Where(ps ...predicate.User) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the UserMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.User, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *UserMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *UserMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (User).
func (m *UserMutation) 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 *UserMutation) Fields() []string {
fields := make([]string, 0, 11)
if m.deleted_at != nil {
fields = append(fields, user.FieldDeletedAt)
}
if m.name != nil {
fields = append(fields, user.FieldName)
}
if m.email != nil {
fields = append(fields, user.FieldEmail)
}
if m.avatar_url != nil {
fields = append(fields, user.FieldAvatarURL)
}
if m.password != nil {
fields = append(fields, user.FieldPassword)
}
if m.role != nil {
fields = append(fields, user.FieldRole)
}
if m.status != nil {
fields = append(fields, user.FieldStatus)
}
if m.is_blocked != nil {
fields = append(fields, user.FieldIsBlocked)
}
if m.default_configs != nil {
fields = append(fields, user.FieldDefaultConfigs)
}
if m.created_at != nil {
fields = append(fields, user.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, user.FieldUpdatedAt)
}
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 *UserMutation) Field(name string) (ent.Value, bool) {
switch name {
case user.FieldDeletedAt:
return m.DeletedAt()
case user.FieldName:
return m.Name()
case user.FieldEmail:
return m.Email()
case user.FieldAvatarURL:
return m.AvatarURL()
case user.FieldPassword:
return m.Password()
case user.FieldRole:
return m.Role()
case user.FieldStatus:
return m.Status()
case user.FieldIsBlocked:
return m.IsBlocked()
case user.FieldDefaultConfigs:
return m.DefaultConfigs()
case user.FieldCreatedAt:
return m.CreatedAt()
case user.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case user.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case user.FieldName:
return m.OldName(ctx)
case user.FieldEmail:
return m.OldEmail(ctx)
case user.FieldAvatarURL:
return m.OldAvatarURL(ctx)
case user.FieldPassword:
return m.OldPassword(ctx)
case user.FieldRole:
return m.OldRole(ctx)
case user.FieldStatus:
return m.OldStatus(ctx)
case user.FieldIsBlocked:
return m.OldIsBlocked(ctx)
case user.FieldDefaultConfigs:
return m.OldDefaultConfigs(ctx)
case user.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case user.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown User 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 *UserMutation) SetField(name string, value ent.Value) error {
switch name {
case user.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 user.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case user.FieldEmail:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEmail(v)
return nil
case user.FieldAvatarURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAvatarURL(v)
return nil
case user.FieldPassword:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPassword(v)
return nil
case user.FieldRole:
v, ok := value.(consts.UserRole)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRole(v)
return nil
case user.FieldStatus:
v, ok := value.(consts.UserStatus)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetStatus(v)
return nil
case user.FieldIsBlocked:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetIsBlocked(v)
return nil
case user.FieldDefaultConfigs:
v, ok := value.(map[consts.DefaultConfigType]uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDefaultConfigs(v)
return nil
case user.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 user.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown User field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *UserMutation) AddedFields() []string {
return nil
}
// 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 *UserMutation) AddedField(name string) (ent.Value, bool) {
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 *UserMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown User numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *UserMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(user.FieldDeletedAt) {
fields = append(fields, user.FieldDeletedAt)
}
if m.FieldCleared(user.FieldEmail) {
fields = append(fields, user.FieldEmail)
}
if m.FieldCleared(user.FieldAvatarURL) {
fields = append(fields, user.FieldAvatarURL)
}
if m.FieldCleared(user.FieldPassword) {
fields = append(fields, user.FieldPassword)
}
if m.FieldCleared(user.FieldDefaultConfigs) {
fields = append(fields, user.FieldDefaultConfigs)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *UserMutation) 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 *UserMutation) ClearField(name string) error {
switch name {
case user.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case user.FieldEmail:
m.ClearEmail()
return nil
case user.FieldAvatarURL:
m.ClearAvatarURL()
return nil
case user.FieldPassword:
m.ClearPassword()
return nil
case user.FieldDefaultConfigs:
m.ClearDefaultConfigs()
return nil
}
return fmt.Errorf("unknown User 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 *UserMutation) ResetField(name string) error {
switch name {
case user.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case user.FieldName:
m.ResetName()
return nil
case user.FieldEmail:
m.ResetEmail()
return nil
case user.FieldAvatarURL:
m.ResetAvatarURL()
return nil
case user.FieldPassword:
m.ResetPassword()
return nil
case user.FieldRole:
m.ResetRole()
return nil
case user.FieldStatus:
m.ResetStatus()
return nil
case user.FieldIsBlocked:
m.ResetIsBlocked()
return nil
case user.FieldDefaultConfigs:
m.ResetDefaultConfigs()
return nil
case user.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case user.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown User field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *UserMutation) AddedEdges() []string {
edges := make([]string, 0, 21)
if m.identities != nil {
edges = append(edges, user.EdgeIdentities)
}
if m.audits != nil {
edges = append(edges, user.EdgeAudits)
}
if m.teams != nil {
edges = append(edges, user.EdgeTeams)
}
if m.groups != nil {
edges = append(edges, user.EdgeGroups)
}
if m.models != nil {
edges = append(edges, user.EdgeModels)
}
if m.images != nil {
edges = append(edges, user.EdgeImages)
}
if m.hosts != nil {
edges = append(edges, user.EdgeHosts)
}
if m.vms != nil {
edges = append(edges, user.EdgeVms)
}
if m.tasks != nil {
edges = append(edges, user.EdgeTasks)
}
if m.task_model_switches != nil {
edges = append(edges, user.EdgeTaskModelSwitches)
}
if m.git_identities != nil {
edges = append(edges, user.EdgeGitIdentities)
}
if m.projects != nil {
edges = append(edges, user.EdgeProjects)
}
if m.project_issues != nil {
edges = append(edges, user.EdgeProjectIssues)
}
if m.assigned_issues != nil {
edges = append(edges, user.EdgeAssignedIssues)
}
if m.project_collaborators != nil {
edges = append(edges, user.EdgeProjectCollaborators)
}
if m.project_issue_comments != nil {
edges = append(edges, user.EdgeProjectIssueComments)
}
if m.git_bots != nil {
edges = append(edges, user.EdgeGitBots)
}
if m.mcp_upstreams != nil {
edges = append(edges, user.EdgeMcpUpstreams)
}
if m.team_members != nil {
edges = append(edges, user.EdgeTeamMembers)
}
if m.team_group_members != nil {
edges = append(edges, user.EdgeTeamGroupMembers)
}
if m.git_bot_users != nil {
edges = append(edges, user.EdgeGitBotUsers)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *UserMutation) AddedIDs(name string) []ent.Value {
switch name {
case user.EdgeIdentities:
ids := make([]ent.Value, 0, len(m.identities))
for id := range m.identities {
ids = append(ids, id)
}
return ids
case user.EdgeAudits:
ids := make([]ent.Value, 0, len(m.audits))
for id := range m.audits {
ids = append(ids, id)
}
return ids
case user.EdgeTeams:
ids := make([]ent.Value, 0, len(m.teams))
for id := range m.teams {
ids = append(ids, id)
}
return ids
case user.EdgeGroups:
ids := make([]ent.Value, 0, len(m.groups))
for id := range m.groups {
ids = append(ids, id)
}
return ids
case user.EdgeModels:
ids := make([]ent.Value, 0, len(m.models))
for id := range m.models {
ids = append(ids, id)
}
return ids
case user.EdgeImages:
ids := make([]ent.Value, 0, len(m.images))
for id := range m.images {
ids = append(ids, id)
}
return ids
case user.EdgeHosts:
ids := make([]ent.Value, 0, len(m.hosts))
for id := range m.hosts {
ids = append(ids, id)
}
return ids
case user.EdgeVms:
ids := make([]ent.Value, 0, len(m.vms))
for id := range m.vms {
ids = append(ids, id)
}
return ids
case user.EdgeTasks:
ids := make([]ent.Value, 0, len(m.tasks))
for id := range m.tasks {
ids = append(ids, id)
}
return ids
case user.EdgeTaskModelSwitches:
ids := make([]ent.Value, 0, len(m.task_model_switches))
for id := range m.task_model_switches {
ids = append(ids, id)
}
return ids
case user.EdgeGitIdentities:
ids := make([]ent.Value, 0, len(m.git_identities))
for id := range m.git_identities {
ids = append(ids, id)
}
return ids
case user.EdgeProjects:
ids := make([]ent.Value, 0, len(m.projects))
for id := range m.projects {
ids = append(ids, id)
}
return ids
case user.EdgeProjectIssues:
ids := make([]ent.Value, 0, len(m.project_issues))
for id := range m.project_issues {
ids = append(ids, id)
}
return ids
case user.EdgeAssignedIssues:
ids := make([]ent.Value, 0, len(m.assigned_issues))
for id := range m.assigned_issues {
ids = append(ids, id)
}
return ids
case user.EdgeProjectCollaborators:
ids := make([]ent.Value, 0, len(m.project_collaborators))
for id := range m.project_collaborators {
ids = append(ids, id)
}
return ids
case user.EdgeProjectIssueComments:
ids := make([]ent.Value, 0, len(m.project_issue_comments))
for id := range m.project_issue_comments {
ids = append(ids, id)
}
return ids
case user.EdgeGitBots:
ids := make([]ent.Value, 0, len(m.git_bots))
for id := range m.git_bots {
ids = append(ids, id)
}
return ids
case user.EdgeMcpUpstreams:
ids := make([]ent.Value, 0, len(m.mcp_upstreams))
for id := range m.mcp_upstreams {
ids = append(ids, id)
}
return ids
case user.EdgeTeamMembers:
ids := make([]ent.Value, 0, len(m.team_members))
for id := range m.team_members {
ids = append(ids, id)
}
return ids
case user.EdgeTeamGroupMembers:
ids := make([]ent.Value, 0, len(m.team_group_members))
for id := range m.team_group_members {
ids = append(ids, id)
}
return ids
case user.EdgeGitBotUsers:
ids := make([]ent.Value, 0, len(m.git_bot_users))
for id := range m.git_bot_users {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *UserMutation) RemovedEdges() []string {
edges := make([]string, 0, 21)
if m.removedidentities != nil {
edges = append(edges, user.EdgeIdentities)
}
if m.removedaudits != nil {
edges = append(edges, user.EdgeAudits)
}
if m.removedteams != nil {
edges = append(edges, user.EdgeTeams)
}
if m.removedgroups != nil {
edges = append(edges, user.EdgeGroups)
}
if m.removedmodels != nil {
edges = append(edges, user.EdgeModels)
}
if m.removedimages != nil {
edges = append(edges, user.EdgeImages)
}
if m.removedhosts != nil {
edges = append(edges, user.EdgeHosts)
}
if m.removedvms != nil {
edges = append(edges, user.EdgeVms)
}
if m.removedtasks != nil {
edges = append(edges, user.EdgeTasks)
}
if m.removedtask_model_switches != nil {
edges = append(edges, user.EdgeTaskModelSwitches)
}
if m.removedgit_identities != nil {
edges = append(edges, user.EdgeGitIdentities)
}
if m.removedprojects != nil {
edges = append(edges, user.EdgeProjects)
}
if m.removedproject_issues != nil {
edges = append(edges, user.EdgeProjectIssues)
}
if m.removedassigned_issues != nil {
edges = append(edges, user.EdgeAssignedIssues)
}
if m.removedproject_collaborators != nil {
edges = append(edges, user.EdgeProjectCollaborators)
}
if m.removedproject_issue_comments != nil {
edges = append(edges, user.EdgeProjectIssueComments)
}
if m.removedgit_bots != nil {
edges = append(edges, user.EdgeGitBots)
}
if m.removedmcp_upstreams != nil {
edges = append(edges, user.EdgeMcpUpstreams)
}
if m.removedteam_members != nil {
edges = append(edges, user.EdgeTeamMembers)
}
if m.removedteam_group_members != nil {
edges = append(edges, user.EdgeTeamGroupMembers)
}
if m.removedgit_bot_users != nil {
edges = append(edges, user.EdgeGitBotUsers)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *UserMutation) RemovedIDs(name string) []ent.Value {
switch name {
case user.EdgeIdentities:
ids := make([]ent.Value, 0, len(m.removedidentities))
for id := range m.removedidentities {
ids = append(ids, id)
}
return ids
case user.EdgeAudits:
ids := make([]ent.Value, 0, len(m.removedaudits))
for id := range m.removedaudits {
ids = append(ids, id)
}
return ids
case user.EdgeTeams:
ids := make([]ent.Value, 0, len(m.removedteams))
for id := range m.removedteams {
ids = append(ids, id)
}
return ids
case user.EdgeGroups:
ids := make([]ent.Value, 0, len(m.removedgroups))
for id := range m.removedgroups {
ids = append(ids, id)
}
return ids
case user.EdgeModels:
ids := make([]ent.Value, 0, len(m.removedmodels))
for id := range m.removedmodels {
ids = append(ids, id)
}
return ids
case user.EdgeImages:
ids := make([]ent.Value, 0, len(m.removedimages))
for id := range m.removedimages {
ids = append(ids, id)
}
return ids
case user.EdgeHosts:
ids := make([]ent.Value, 0, len(m.removedhosts))
for id := range m.removedhosts {
ids = append(ids, id)
}
return ids
case user.EdgeVms:
ids := make([]ent.Value, 0, len(m.removedvms))
for id := range m.removedvms {
ids = append(ids, id)
}
return ids
case user.EdgeTasks:
ids := make([]ent.Value, 0, len(m.removedtasks))
for id := range m.removedtasks {
ids = append(ids, id)
}
return ids
case user.EdgeTaskModelSwitches:
ids := make([]ent.Value, 0, len(m.removedtask_model_switches))
for id := range m.removedtask_model_switches {
ids = append(ids, id)
}
return ids
case user.EdgeGitIdentities:
ids := make([]ent.Value, 0, len(m.removedgit_identities))
for id := range m.removedgit_identities {
ids = append(ids, id)
}
return ids
case user.EdgeProjects:
ids := make([]ent.Value, 0, len(m.removedprojects))
for id := range m.removedprojects {
ids = append(ids, id)
}
return ids
case user.EdgeProjectIssues:
ids := make([]ent.Value, 0, len(m.removedproject_issues))
for id := range m.removedproject_issues {
ids = append(ids, id)
}
return ids
case user.EdgeAssignedIssues:
ids := make([]ent.Value, 0, len(m.removedassigned_issues))
for id := range m.removedassigned_issues {
ids = append(ids, id)
}
return ids
case user.EdgeProjectCollaborators:
ids := make([]ent.Value, 0, len(m.removedproject_collaborators))
for id := range m.removedproject_collaborators {
ids = append(ids, id)
}
return ids
case user.EdgeProjectIssueComments:
ids := make([]ent.Value, 0, len(m.removedproject_issue_comments))
for id := range m.removedproject_issue_comments {
ids = append(ids, id)
}
return ids
case user.EdgeGitBots:
ids := make([]ent.Value, 0, len(m.removedgit_bots))
for id := range m.removedgit_bots {
ids = append(ids, id)
}
return ids
case user.EdgeMcpUpstreams:
ids := make([]ent.Value, 0, len(m.removedmcp_upstreams))
for id := range m.removedmcp_upstreams {
ids = append(ids, id)
}
return ids
case user.EdgeTeamMembers:
ids := make([]ent.Value, 0, len(m.removedteam_members))
for id := range m.removedteam_members {
ids = append(ids, id)
}
return ids
case user.EdgeTeamGroupMembers:
ids := make([]ent.Value, 0, len(m.removedteam_group_members))
for id := range m.removedteam_group_members {
ids = append(ids, id)
}
return ids
case user.EdgeGitBotUsers:
ids := make([]ent.Value, 0, len(m.removedgit_bot_users))
for id := range m.removedgit_bot_users {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *UserMutation) ClearedEdges() []string {
edges := make([]string, 0, 21)
if m.clearedidentities {
edges = append(edges, user.EdgeIdentities)
}
if m.clearedaudits {
edges = append(edges, user.EdgeAudits)
}
if m.clearedteams {
edges = append(edges, user.EdgeTeams)
}
if m.clearedgroups {
edges = append(edges, user.EdgeGroups)
}
if m.clearedmodels {
edges = append(edges, user.EdgeModels)
}
if m.clearedimages {
edges = append(edges, user.EdgeImages)
}
if m.clearedhosts {
edges = append(edges, user.EdgeHosts)
}
if m.clearedvms {
edges = append(edges, user.EdgeVms)
}
if m.clearedtasks {
edges = append(edges, user.EdgeTasks)
}
if m.clearedtask_model_switches {
edges = append(edges, user.EdgeTaskModelSwitches)
}
if m.clearedgit_identities {
edges = append(edges, user.EdgeGitIdentities)
}
if m.clearedprojects {
edges = append(edges, user.EdgeProjects)
}
if m.clearedproject_issues {
edges = append(edges, user.EdgeProjectIssues)
}
if m.clearedassigned_issues {
edges = append(edges, user.EdgeAssignedIssues)
}
if m.clearedproject_collaborators {
edges = append(edges, user.EdgeProjectCollaborators)
}
if m.clearedproject_issue_comments {
edges = append(edges, user.EdgeProjectIssueComments)
}
if m.clearedgit_bots {
edges = append(edges, user.EdgeGitBots)
}
if m.clearedmcp_upstreams {
edges = append(edges, user.EdgeMcpUpstreams)
}
if m.clearedteam_members {
edges = append(edges, user.EdgeTeamMembers)
}
if m.clearedteam_group_members {
edges = append(edges, user.EdgeTeamGroupMembers)
}
if m.clearedgit_bot_users {
edges = append(edges, user.EdgeGitBotUsers)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *UserMutation) EdgeCleared(name string) bool {
switch name {
case user.EdgeIdentities:
return m.clearedidentities
case user.EdgeAudits:
return m.clearedaudits
case user.EdgeTeams:
return m.clearedteams
case user.EdgeGroups:
return m.clearedgroups
case user.EdgeModels:
return m.clearedmodels
case user.EdgeImages:
return m.clearedimages
case user.EdgeHosts:
return m.clearedhosts
case user.EdgeVms:
return m.clearedvms
case user.EdgeTasks:
return m.clearedtasks
case user.EdgeTaskModelSwitches:
return m.clearedtask_model_switches
case user.EdgeGitIdentities:
return m.clearedgit_identities
case user.EdgeProjects:
return m.clearedprojects
case user.EdgeProjectIssues:
return m.clearedproject_issues
case user.EdgeAssignedIssues:
return m.clearedassigned_issues
case user.EdgeProjectCollaborators:
return m.clearedproject_collaborators
case user.EdgeProjectIssueComments:
return m.clearedproject_issue_comments
case user.EdgeGitBots:
return m.clearedgit_bots
case user.EdgeMcpUpstreams:
return m.clearedmcp_upstreams
case user.EdgeTeamMembers:
return m.clearedteam_members
case user.EdgeTeamGroupMembers:
return m.clearedteam_group_members
case user.EdgeGitBotUsers:
return m.clearedgit_bot_users
}
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 *UserMutation) ClearEdge(name string) error {
switch name {
}
return fmt.Errorf("unknown User 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 *UserMutation) ResetEdge(name string) error {
switch name {
case user.EdgeIdentities:
m.ResetIdentities()
return nil
case user.EdgeAudits:
m.ResetAudits()
return nil
case user.EdgeTeams:
m.ResetTeams()
return nil
case user.EdgeGroups:
m.ResetGroups()
return nil
case user.EdgeModels:
m.ResetModels()
return nil
case user.EdgeImages:
m.ResetImages()
return nil
case user.EdgeHosts:
m.ResetHosts()
return nil
case user.EdgeVms:
m.ResetVms()
return nil
case user.EdgeTasks:
m.ResetTasks()
return nil
case user.EdgeTaskModelSwitches:
m.ResetTaskModelSwitches()
return nil
case user.EdgeGitIdentities:
m.ResetGitIdentities()
return nil
case user.EdgeProjects:
m.ResetProjects()
return nil
case user.EdgeProjectIssues:
m.ResetProjectIssues()
return nil
case user.EdgeAssignedIssues:
m.ResetAssignedIssues()
return nil
case user.EdgeProjectCollaborators:
m.ResetProjectCollaborators()
return nil
case user.EdgeProjectIssueComments:
m.ResetProjectIssueComments()
return nil
case user.EdgeGitBots:
m.ResetGitBots()
return nil
case user.EdgeMcpUpstreams:
m.ResetMcpUpstreams()
return nil
case user.EdgeTeamMembers:
m.ResetTeamMembers()
return nil
case user.EdgeTeamGroupMembers:
m.ResetTeamGroupMembers()
return nil
case user.EdgeGitBotUsers:
m.ResetGitBotUsers()
return nil
}
return fmt.Errorf("unknown User edge %s", name)
}
// UserIdentityMutation represents an operation that mutates the UserIdentity nodes in the graph.
type UserIdentityMutation struct {
config
op Op
typ string
id *uuid.UUID
deleted_at *time.Time
platform *consts.UserPlatform
identity_id *string
username *string
email *string
avatar_url *string
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
user *uuid.UUID
cleareduser bool
done bool
oldValue func(context.Context) (*UserIdentity, error)
predicates []predicate.UserIdentity
}
var _ ent.Mutation = (*UserIdentityMutation)(nil)
// useridentityOption allows management of the mutation configuration using functional options.
type useridentityOption func(*UserIdentityMutation)
// newUserIdentityMutation creates new mutation for the UserIdentity entity.
func newUserIdentityMutation(c config, op Op, opts ...useridentityOption) *UserIdentityMutation {
m := &UserIdentityMutation{
config: c,
op: op,
typ: TypeUserIdentity,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withUserIdentityID sets the ID field of the mutation.
func withUserIdentityID(id uuid.UUID) useridentityOption {
return func(m *UserIdentityMutation) {
var (
err error
once sync.Once
value *UserIdentity
)
m.oldValue = func(ctx context.Context) (*UserIdentity, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().UserIdentity.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withUserIdentity sets the old UserIdentity of the mutation.
func withUserIdentity(node *UserIdentity) useridentityOption {
return func(m *UserIdentityMutation) {
m.oldValue = func(context.Context) (*UserIdentity, 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 UserIdentityMutation) 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 UserIdentityMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 UserIdentity entities.
func (m *UserIdentityMutation) SetID(id uuid.UUID) {
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 *UserIdentityMutation) ID() (id uuid.UUID, 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 *UserIdentityMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []uuid.UUID{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().UserIdentity.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *UserIdentityMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *UserIdentityMutation) 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 UserIdentity entity.
// If the UserIdentity 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 *UserIdentityMutation) 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 *UserIdentityMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[useridentity.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *UserIdentityMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[useridentity.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *UserIdentityMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, useridentity.FieldDeletedAt)
}
// SetUserID sets the "user_id" field.
func (m *UserIdentityMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *UserIdentityMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the UserIdentity entity.
// If the UserIdentity 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 *UserIdentityMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ResetUserID resets all changes to the "user_id" field.
func (m *UserIdentityMutation) ResetUserID() {
m.user = nil
}
// SetPlatform sets the "platform" field.
func (m *UserIdentityMutation) SetPlatform(cp consts.UserPlatform) {
m.platform = &cp
}
// Platform returns the value of the "platform" field in the mutation.
func (m *UserIdentityMutation) Platform() (r consts.UserPlatform, exists bool) {
v := m.platform
if v == nil {
return
}
return *v, true
}
// OldPlatform returns the old "platform" field's value of the UserIdentity entity.
// If the UserIdentity 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 *UserIdentityMutation) OldPlatform(ctx context.Context) (v consts.UserPlatform, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPlatform is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPlatform requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPlatform: %w", err)
}
return oldValue.Platform, nil
}
// ResetPlatform resets all changes to the "platform" field.
func (m *UserIdentityMutation) ResetPlatform() {
m.platform = nil
}
// SetIdentityID sets the "identity_id" field.
func (m *UserIdentityMutation) SetIdentityID(s string) {
m.identity_id = &s
}
// IdentityID returns the value of the "identity_id" field in the mutation.
func (m *UserIdentityMutation) IdentityID() (r string, exists bool) {
v := m.identity_id
if v == nil {
return
}
return *v, true
}
// OldIdentityID returns the old "identity_id" field's value of the UserIdentity entity.
// If the UserIdentity 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 *UserIdentityMutation) OldIdentityID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldIdentityID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldIdentityID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIdentityID: %w", err)
}
return oldValue.IdentityID, nil
}
// ResetIdentityID resets all changes to the "identity_id" field.
func (m *UserIdentityMutation) ResetIdentityID() {
m.identity_id = nil
}
// SetUsername sets the "username" field.
func (m *UserIdentityMutation) SetUsername(s string) {
m.username = &s
}
// Username returns the value of the "username" field in the mutation.
func (m *UserIdentityMutation) Username() (r string, exists bool) {
v := m.username
if v == nil {
return
}
return *v, true
}
// OldUsername returns the old "username" field's value of the UserIdentity entity.
// If the UserIdentity 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 *UserIdentityMutation) OldUsername(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUsername is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUsername requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUsername: %w", err)
}
return oldValue.Username, nil
}
// ResetUsername resets all changes to the "username" field.
func (m *UserIdentityMutation) ResetUsername() {
m.username = nil
}
// SetEmail sets the "email" field.
func (m *UserIdentityMutation) SetEmail(s string) {
m.email = &s
}
// Email returns the value of the "email" field in the mutation.
func (m *UserIdentityMutation) Email() (r string, exists bool) {
v := m.email
if v == nil {
return
}
return *v, true
}
// OldEmail returns the old "email" field's value of the UserIdentity entity.
// If the UserIdentity 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 *UserIdentityMutation) OldEmail(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEmail is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEmail requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEmail: %w", err)
}
return oldValue.Email, nil
}
// ClearEmail clears the value of the "email" field.
func (m *UserIdentityMutation) ClearEmail() {
m.email = nil
m.clearedFields[useridentity.FieldEmail] = struct{}{}
}
// EmailCleared returns if the "email" field was cleared in this mutation.
func (m *UserIdentityMutation) EmailCleared() bool {
_, ok := m.clearedFields[useridentity.FieldEmail]
return ok
}
// ResetEmail resets all changes to the "email" field.
func (m *UserIdentityMutation) ResetEmail() {
m.email = nil
delete(m.clearedFields, useridentity.FieldEmail)
}
// SetAvatarURL sets the "avatar_url" field.
func (m *UserIdentityMutation) SetAvatarURL(s string) {
m.avatar_url = &s
}
// AvatarURL returns the value of the "avatar_url" field in the mutation.
func (m *UserIdentityMutation) AvatarURL() (r string, exists bool) {
v := m.avatar_url
if v == nil {
return
}
return *v, true
}
// OldAvatarURL returns the old "avatar_url" field's value of the UserIdentity entity.
// If the UserIdentity 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 *UserIdentityMutation) OldAvatarURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAvatarURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAvatarURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAvatarURL: %w", err)
}
return oldValue.AvatarURL, nil
}
// ClearAvatarURL clears the value of the "avatar_url" field.
func (m *UserIdentityMutation) ClearAvatarURL() {
m.avatar_url = nil
m.clearedFields[useridentity.FieldAvatarURL] = struct{}{}
}
// AvatarURLCleared returns if the "avatar_url" field was cleared in this mutation.
func (m *UserIdentityMutation) AvatarURLCleared() bool {
_, ok := m.clearedFields[useridentity.FieldAvatarURL]
return ok
}
// ResetAvatarURL resets all changes to the "avatar_url" field.
func (m *UserIdentityMutation) ResetAvatarURL() {
m.avatar_url = nil
delete(m.clearedFields, useridentity.FieldAvatarURL)
}
// SetCreatedAt sets the "created_at" field.
func (m *UserIdentityMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *UserIdentityMutation) 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 UserIdentity entity.
// If the UserIdentity 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 *UserIdentityMutation) 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 *UserIdentityMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *UserIdentityMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *UserIdentityMutation) 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 UserIdentity entity.
// If the UserIdentity 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 *UserIdentityMutation) 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
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (m *UserIdentityMutation) ClearUpdatedAt() {
m.updated_at = nil
m.clearedFields[useridentity.FieldUpdatedAt] = struct{}{}
}
// UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
func (m *UserIdentityMutation) UpdatedAtCleared() bool {
_, ok := m.clearedFields[useridentity.FieldUpdatedAt]
return ok
}
// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *UserIdentityMutation) ResetUpdatedAt() {
m.updated_at = nil
delete(m.clearedFields, useridentity.FieldUpdatedAt)
}
// ClearUser clears the "user" edge to the User entity.
func (m *UserIdentityMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[useridentity.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *UserIdentityMutation) UserCleared() bool {
return m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *UserIdentityMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *UserIdentityMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// Where appends a list predicates to the UserIdentityMutation builder.
func (m *UserIdentityMutation) Where(ps ...predicate.UserIdentity) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the UserIdentityMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *UserIdentityMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.UserIdentity, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *UserIdentityMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *UserIdentityMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (UserIdentity).
func (m *UserIdentityMutation) 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 *UserIdentityMutation) Fields() []string {
fields := make([]string, 0, 9)
if m.deleted_at != nil {
fields = append(fields, useridentity.FieldDeletedAt)
}
if m.user != nil {
fields = append(fields, useridentity.FieldUserID)
}
if m.platform != nil {
fields = append(fields, useridentity.FieldPlatform)
}
if m.identity_id != nil {
fields = append(fields, useridentity.FieldIdentityID)
}
if m.username != nil {
fields = append(fields, useridentity.FieldUsername)
}
if m.email != nil {
fields = append(fields, useridentity.FieldEmail)
}
if m.avatar_url != nil {
fields = append(fields, useridentity.FieldAvatarURL)
}
if m.created_at != nil {
fields = append(fields, useridentity.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, useridentity.FieldUpdatedAt)
}
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 *UserIdentityMutation) Field(name string) (ent.Value, bool) {
switch name {
case useridentity.FieldDeletedAt:
return m.DeletedAt()
case useridentity.FieldUserID:
return m.UserID()
case useridentity.FieldPlatform:
return m.Platform()
case useridentity.FieldIdentityID:
return m.IdentityID()
case useridentity.FieldUsername:
return m.Username()
case useridentity.FieldEmail:
return m.Email()
case useridentity.FieldAvatarURL:
return m.AvatarURL()
case useridentity.FieldCreatedAt:
return m.CreatedAt()
case useridentity.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *UserIdentityMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case useridentity.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case useridentity.FieldUserID:
return m.OldUserID(ctx)
case useridentity.FieldPlatform:
return m.OldPlatform(ctx)
case useridentity.FieldIdentityID:
return m.OldIdentityID(ctx)
case useridentity.FieldUsername:
return m.OldUsername(ctx)
case useridentity.FieldEmail:
return m.OldEmail(ctx)
case useridentity.FieldAvatarURL:
return m.OldAvatarURL(ctx)
case useridentity.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case useridentity.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown UserIdentity 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 *UserIdentityMutation) SetField(name string, value ent.Value) error {
switch name {
case useridentity.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 useridentity.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case useridentity.FieldPlatform:
v, ok := value.(consts.UserPlatform)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPlatform(v)
return nil
case useridentity.FieldIdentityID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetIdentityID(v)
return nil
case useridentity.FieldUsername:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUsername(v)
return nil
case useridentity.FieldEmail:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEmail(v)
return nil
case useridentity.FieldAvatarURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAvatarURL(v)
return nil
case useridentity.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 useridentity.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown UserIdentity field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *UserIdentityMutation) AddedFields() []string {
return nil
}
// 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 *UserIdentityMutation) AddedField(name string) (ent.Value, bool) {
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 *UserIdentityMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown UserIdentity numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *UserIdentityMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(useridentity.FieldDeletedAt) {
fields = append(fields, useridentity.FieldDeletedAt)
}
if m.FieldCleared(useridentity.FieldEmail) {
fields = append(fields, useridentity.FieldEmail)
}
if m.FieldCleared(useridentity.FieldAvatarURL) {
fields = append(fields, useridentity.FieldAvatarURL)
}
if m.FieldCleared(useridentity.FieldUpdatedAt) {
fields = append(fields, useridentity.FieldUpdatedAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *UserIdentityMutation) 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 *UserIdentityMutation) ClearField(name string) error {
switch name {
case useridentity.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case useridentity.FieldEmail:
m.ClearEmail()
return nil
case useridentity.FieldAvatarURL:
m.ClearAvatarURL()
return nil
case useridentity.FieldUpdatedAt:
m.ClearUpdatedAt()
return nil
}
return fmt.Errorf("unknown UserIdentity 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 *UserIdentityMutation) ResetField(name string) error {
switch name {
case useridentity.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case useridentity.FieldUserID:
m.ResetUserID()
return nil
case useridentity.FieldPlatform:
m.ResetPlatform()
return nil
case useridentity.FieldIdentityID:
m.ResetIdentityID()
return nil
case useridentity.FieldUsername:
m.ResetUsername()
return nil
case useridentity.FieldEmail:
m.ResetEmail()
return nil
case useridentity.FieldAvatarURL:
m.ResetAvatarURL()
return nil
case useridentity.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case useridentity.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown UserIdentity field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *UserIdentityMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.user != nil {
edges = append(edges, useridentity.EdgeUser)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *UserIdentityMutation) AddedIDs(name string) []ent.Value {
switch name {
case useridentity.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *UserIdentityMutation) 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 *UserIdentityMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *UserIdentityMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.cleareduser {
edges = append(edges, useridentity.EdgeUser)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *UserIdentityMutation) EdgeCleared(name string) bool {
switch name {
case useridentity.EdgeUser:
return m.cleareduser
}
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 *UserIdentityMutation) ClearEdge(name string) error {
switch name {
case useridentity.EdgeUser:
m.ClearUser()
return nil
}
return fmt.Errorf("unknown UserIdentity 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 *UserIdentityMutation) ResetEdge(name string) error {
switch name {
case useridentity.EdgeUser:
m.ResetUser()
return nil
}
return fmt.Errorf("unknown UserIdentity edge %s", name)
}
// VirtualMachineMutation represents an operation that mutates the VirtualMachine nodes in the graph.
type VirtualMachineMutation struct {
config
op Op
typ string
id *string
deleted_at *time.Time
access_token *string
environment_id *string
name *string
hostname *string
arch *string
cores *int
addcores *int
memory *int64
addmemory *int64
os *string
external_ip *string
internal_ip *string
version *string
machine_id *string
repo_url *string
repo_filename *string
branch *string
is_recycled *bool
conditions **types.VirtualMachineCondition
expired_at *time.Time
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
host *string
clearedhost bool
model *uuid.UUID
clearedmodel bool
user *uuid.UUID
cleareduser bool
git_identity *uuid.UUID
clearedgit_identity bool
tasks map[uuid.UUID]struct{}
removedtasks map[uuid.UUID]struct{}
clearedtasks bool
task_vms map[uuid.UUID]struct{}
removedtask_vms map[uuid.UUID]struct{}
clearedtask_vms bool
done bool
oldValue func(context.Context) (*VirtualMachine, error)
predicates []predicate.VirtualMachine
}
var _ ent.Mutation = (*VirtualMachineMutation)(nil)
// virtualmachineOption allows management of the mutation configuration using functional options.
type virtualmachineOption func(*VirtualMachineMutation)
// newVirtualMachineMutation creates new mutation for the VirtualMachine entity.
func newVirtualMachineMutation(c config, op Op, opts ...virtualmachineOption) *VirtualMachineMutation {
m := &VirtualMachineMutation{
config: c,
op: op,
typ: TypeVirtualMachine,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withVirtualMachineID sets the ID field of the mutation.
func withVirtualMachineID(id string) virtualmachineOption {
return func(m *VirtualMachineMutation) {
var (
err error
once sync.Once
value *VirtualMachine
)
m.oldValue = func(ctx context.Context) (*VirtualMachine, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().VirtualMachine.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withVirtualMachine sets the old VirtualMachine of the mutation.
func withVirtualMachine(node *VirtualMachine) virtualmachineOption {
return func(m *VirtualMachineMutation) {
m.oldValue = func(context.Context) (*VirtualMachine, 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 VirtualMachineMutation) 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 VirtualMachineMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("db: 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 VirtualMachine entities.
func (m *VirtualMachineMutation) SetID(id string) {
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 *VirtualMachineMutation) ID() (id string, 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 *VirtualMachineMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().VirtualMachine.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDeletedAt sets the "deleted_at" field.
func (m *VirtualMachineMutation) SetDeletedAt(t time.Time) {
m.deleted_at = &t
}
// DeletedAt returns the value of the "deleted_at" field in the mutation.
func (m *VirtualMachineMutation) 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 VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) 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 *VirtualMachineMutation) ClearDeletedAt() {
m.deleted_at = nil
m.clearedFields[virtualmachine.FieldDeletedAt] = struct{}{}
}
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
func (m *VirtualMachineMutation) DeletedAtCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldDeletedAt]
return ok
}
// ResetDeletedAt resets all changes to the "deleted_at" field.
func (m *VirtualMachineMutation) ResetDeletedAt() {
m.deleted_at = nil
delete(m.clearedFields, virtualmachine.FieldDeletedAt)
}
// SetAccessToken sets the "access_token" field.
func (m *VirtualMachineMutation) SetAccessToken(s string) {
m.access_token = &s
}
// AccessToken returns the value of the "access_token" field in the mutation.
func (m *VirtualMachineMutation) AccessToken() (r string, exists bool) {
v := m.access_token
if v == nil {
return
}
return *v, true
}
// OldAccessToken returns the old "access_token" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldAccessToken(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAccessToken is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAccessToken requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAccessToken: %w", err)
}
return oldValue.AccessToken, nil
}
// ClearAccessToken clears the value of the "access_token" field.
func (m *VirtualMachineMutation) ClearAccessToken() {
m.access_token = nil
m.clearedFields[virtualmachine.FieldAccessToken] = struct{}{}
}
// AccessTokenCleared returns if the "access_token" field was cleared in this mutation.
func (m *VirtualMachineMutation) AccessTokenCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldAccessToken]
return ok
}
// ResetAccessToken resets all changes to the "access_token" field.
func (m *VirtualMachineMutation) ResetAccessToken() {
m.access_token = nil
delete(m.clearedFields, virtualmachine.FieldAccessToken)
}
// SetHostID sets the "host_id" field.
func (m *VirtualMachineMutation) SetHostID(s string) {
m.host = &s
}
// HostID returns the value of the "host_id" field in the mutation.
func (m *VirtualMachineMutation) HostID() (r string, exists bool) {
v := m.host
if v == nil {
return
}
return *v, true
}
// OldHostID returns the old "host_id" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldHostID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHostID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHostID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHostID: %w", err)
}
return oldValue.HostID, nil
}
// ResetHostID resets all changes to the "host_id" field.
func (m *VirtualMachineMutation) ResetHostID() {
m.host = nil
}
// SetUserID sets the "user_id" field.
func (m *VirtualMachineMutation) SetUserID(u uuid.UUID) {
m.user = &u
}
// UserID returns the value of the "user_id" field in the mutation.
func (m *VirtualMachineMutation) UserID() (r uuid.UUID, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUserID returns the old "user_id" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUserID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
}
return oldValue.UserID, nil
}
// ClearUserID clears the value of the "user_id" field.
func (m *VirtualMachineMutation) ClearUserID() {
m.user = nil
m.clearedFields[virtualmachine.FieldUserID] = struct{}{}
}
// UserIDCleared returns if the "user_id" field was cleared in this mutation.
func (m *VirtualMachineMutation) UserIDCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldUserID]
return ok
}
// ResetUserID resets all changes to the "user_id" field.
func (m *VirtualMachineMutation) ResetUserID() {
m.user = nil
delete(m.clearedFields, virtualmachine.FieldUserID)
}
// SetModelID sets the "model_id" field.
func (m *VirtualMachineMutation) SetModelID(u uuid.UUID) {
m.model = &u
}
// ModelID returns the value of the "model_id" field in the mutation.
func (m *VirtualMachineMutation) ModelID() (r uuid.UUID, exists bool) {
v := m.model
if v == nil {
return
}
return *v, true
}
// OldModelID returns the old "model_id" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldModelID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldModelID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldModelID: %w", err)
}
return oldValue.ModelID, nil
}
// ClearModelID clears the value of the "model_id" field.
func (m *VirtualMachineMutation) ClearModelID() {
m.model = nil
m.clearedFields[virtualmachine.FieldModelID] = struct{}{}
}
// ModelIDCleared returns if the "model_id" field was cleared in this mutation.
func (m *VirtualMachineMutation) ModelIDCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldModelID]
return ok
}
// ResetModelID resets all changes to the "model_id" field.
func (m *VirtualMachineMutation) ResetModelID() {
m.model = nil
delete(m.clearedFields, virtualmachine.FieldModelID)
}
// SetEnvironmentID sets the "environment_id" field.
func (m *VirtualMachineMutation) SetEnvironmentID(s string) {
m.environment_id = &s
}
// EnvironmentID returns the value of the "environment_id" field in the mutation.
func (m *VirtualMachineMutation) EnvironmentID() (r string, exists bool) {
v := m.environment_id
if v == nil {
return
}
return *v, true
}
// OldEnvironmentID returns the old "environment_id" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldEnvironmentID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEnvironmentID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldEnvironmentID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEnvironmentID: %w", err)
}
return oldValue.EnvironmentID, nil
}
// ClearEnvironmentID clears the value of the "environment_id" field.
func (m *VirtualMachineMutation) ClearEnvironmentID() {
m.environment_id = nil
m.clearedFields[virtualmachine.FieldEnvironmentID] = struct{}{}
}
// EnvironmentIDCleared returns if the "environment_id" field was cleared in this mutation.
func (m *VirtualMachineMutation) EnvironmentIDCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldEnvironmentID]
return ok
}
// ResetEnvironmentID resets all changes to the "environment_id" field.
func (m *VirtualMachineMutation) ResetEnvironmentID() {
m.environment_id = nil
delete(m.clearedFields, virtualmachine.FieldEnvironmentID)
}
// SetName sets the "name" field.
func (m *VirtualMachineMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *VirtualMachineMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldName: %w", err)
}
return oldValue.Name, nil
}
// ResetName resets all changes to the "name" field.
func (m *VirtualMachineMutation) ResetName() {
m.name = nil
}
// SetHostname sets the "hostname" field.
func (m *VirtualMachineMutation) SetHostname(s string) {
m.hostname = &s
}
// Hostname returns the value of the "hostname" field in the mutation.
func (m *VirtualMachineMutation) Hostname() (r string, exists bool) {
v := m.hostname
if v == nil {
return
}
return *v, true
}
// OldHostname returns the old "hostname" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldHostname(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHostname is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHostname requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHostname: %w", err)
}
return oldValue.Hostname, nil
}
// ClearHostname clears the value of the "hostname" field.
func (m *VirtualMachineMutation) ClearHostname() {
m.hostname = nil
m.clearedFields[virtualmachine.FieldHostname] = struct{}{}
}
// HostnameCleared returns if the "hostname" field was cleared in this mutation.
func (m *VirtualMachineMutation) HostnameCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldHostname]
return ok
}
// ResetHostname resets all changes to the "hostname" field.
func (m *VirtualMachineMutation) ResetHostname() {
m.hostname = nil
delete(m.clearedFields, virtualmachine.FieldHostname)
}
// SetArch sets the "arch" field.
func (m *VirtualMachineMutation) SetArch(s string) {
m.arch = &s
}
// Arch returns the value of the "arch" field in the mutation.
func (m *VirtualMachineMutation) Arch() (r string, exists bool) {
v := m.arch
if v == nil {
return
}
return *v, true
}
// OldArch returns the old "arch" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldArch(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldArch is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldArch requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldArch: %w", err)
}
return oldValue.Arch, nil
}
// ClearArch clears the value of the "arch" field.
func (m *VirtualMachineMutation) ClearArch() {
m.arch = nil
m.clearedFields[virtualmachine.FieldArch] = struct{}{}
}
// ArchCleared returns if the "arch" field was cleared in this mutation.
func (m *VirtualMachineMutation) ArchCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldArch]
return ok
}
// ResetArch resets all changes to the "arch" field.
func (m *VirtualMachineMutation) ResetArch() {
m.arch = nil
delete(m.clearedFields, virtualmachine.FieldArch)
}
// SetCores sets the "cores" field.
func (m *VirtualMachineMutation) SetCores(i int) {
m.cores = &i
m.addcores = nil
}
// Cores returns the value of the "cores" field in the mutation.
func (m *VirtualMachineMutation) Cores() (r int, exists bool) {
v := m.cores
if v == nil {
return
}
return *v, true
}
// OldCores returns the old "cores" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldCores(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCores is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCores requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCores: %w", err)
}
return oldValue.Cores, nil
}
// AddCores adds i to the "cores" field.
func (m *VirtualMachineMutation) AddCores(i int) {
if m.addcores != nil {
*m.addcores += i
} else {
m.addcores = &i
}
}
// AddedCores returns the value that was added to the "cores" field in this mutation.
func (m *VirtualMachineMutation) AddedCores() (r int, exists bool) {
v := m.addcores
if v == nil {
return
}
return *v, true
}
// ClearCores clears the value of the "cores" field.
func (m *VirtualMachineMutation) ClearCores() {
m.cores = nil
m.addcores = nil
m.clearedFields[virtualmachine.FieldCores] = struct{}{}
}
// CoresCleared returns if the "cores" field was cleared in this mutation.
func (m *VirtualMachineMutation) CoresCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldCores]
return ok
}
// ResetCores resets all changes to the "cores" field.
func (m *VirtualMachineMutation) ResetCores() {
m.cores = nil
m.addcores = nil
delete(m.clearedFields, virtualmachine.FieldCores)
}
// SetMemory sets the "memory" field.
func (m *VirtualMachineMutation) SetMemory(i int64) {
m.memory = &i
m.addmemory = nil
}
// Memory returns the value of the "memory" field in the mutation.
func (m *VirtualMachineMutation) Memory() (r int64, exists bool) {
v := m.memory
if v == nil {
return
}
return *v, true
}
// OldMemory returns the old "memory" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldMemory(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMemory is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldMemory requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMemory: %w", err)
}
return oldValue.Memory, nil
}
// AddMemory adds i to the "memory" field.
func (m *VirtualMachineMutation) AddMemory(i int64) {
if m.addmemory != nil {
*m.addmemory += i
} else {
m.addmemory = &i
}
}
// AddedMemory returns the value that was added to the "memory" field in this mutation.
func (m *VirtualMachineMutation) AddedMemory() (r int64, exists bool) {
v := m.addmemory
if v == nil {
return
}
return *v, true
}
// ClearMemory clears the value of the "memory" field.
func (m *VirtualMachineMutation) ClearMemory() {
m.memory = nil
m.addmemory = nil
m.clearedFields[virtualmachine.FieldMemory] = struct{}{}
}
// MemoryCleared returns if the "memory" field was cleared in this mutation.
func (m *VirtualMachineMutation) MemoryCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldMemory]
return ok
}
// ResetMemory resets all changes to the "memory" field.
func (m *VirtualMachineMutation) ResetMemory() {
m.memory = nil
m.addmemory = nil
delete(m.clearedFields, virtualmachine.FieldMemory)
}
// SetOs sets the "os" field.
func (m *VirtualMachineMutation) SetOs(s string) {
m.os = &s
}
// Os returns the value of the "os" field in the mutation.
func (m *VirtualMachineMutation) Os() (r string, exists bool) {
v := m.os
if v == nil {
return
}
return *v, true
}
// OldOs returns the old "os" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldOs(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOs is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOs requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOs: %w", err)
}
return oldValue.Os, nil
}
// ClearOs clears the value of the "os" field.
func (m *VirtualMachineMutation) ClearOs() {
m.os = nil
m.clearedFields[virtualmachine.FieldOs] = struct{}{}
}
// OsCleared returns if the "os" field was cleared in this mutation.
func (m *VirtualMachineMutation) OsCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldOs]
return ok
}
// ResetOs resets all changes to the "os" field.
func (m *VirtualMachineMutation) ResetOs() {
m.os = nil
delete(m.clearedFields, virtualmachine.FieldOs)
}
// SetExternalIP sets the "external_ip" field.
func (m *VirtualMachineMutation) SetExternalIP(s string) {
m.external_ip = &s
}
// ExternalIP returns the value of the "external_ip" field in the mutation.
func (m *VirtualMachineMutation) ExternalIP() (r string, exists bool) {
v := m.external_ip
if v == nil {
return
}
return *v, true
}
// OldExternalIP returns the old "external_ip" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldExternalIP(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldExternalIP is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldExternalIP requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldExternalIP: %w", err)
}
return oldValue.ExternalIP, nil
}
// ClearExternalIP clears the value of the "external_ip" field.
func (m *VirtualMachineMutation) ClearExternalIP() {
m.external_ip = nil
m.clearedFields[virtualmachine.FieldExternalIP] = struct{}{}
}
// ExternalIPCleared returns if the "external_ip" field was cleared in this mutation.
func (m *VirtualMachineMutation) ExternalIPCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldExternalIP]
return ok
}
// ResetExternalIP resets all changes to the "external_ip" field.
func (m *VirtualMachineMutation) ResetExternalIP() {
m.external_ip = nil
delete(m.clearedFields, virtualmachine.FieldExternalIP)
}
// SetInternalIP sets the "internal_ip" field.
func (m *VirtualMachineMutation) SetInternalIP(s string) {
m.internal_ip = &s
}
// InternalIP returns the value of the "internal_ip" field in the mutation.
func (m *VirtualMachineMutation) InternalIP() (r string, exists bool) {
v := m.internal_ip
if v == nil {
return
}
return *v, true
}
// OldInternalIP returns the old "internal_ip" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldInternalIP(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldInternalIP is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldInternalIP requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInternalIP: %w", err)
}
return oldValue.InternalIP, nil
}
// ClearInternalIP clears the value of the "internal_ip" field.
func (m *VirtualMachineMutation) ClearInternalIP() {
m.internal_ip = nil
m.clearedFields[virtualmachine.FieldInternalIP] = struct{}{}
}
// InternalIPCleared returns if the "internal_ip" field was cleared in this mutation.
func (m *VirtualMachineMutation) InternalIPCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldInternalIP]
return ok
}
// ResetInternalIP resets all changes to the "internal_ip" field.
func (m *VirtualMachineMutation) ResetInternalIP() {
m.internal_ip = nil
delete(m.clearedFields, virtualmachine.FieldInternalIP)
}
// SetVersion sets the "version" field.
func (m *VirtualMachineMutation) SetVersion(s string) {
m.version = &s
}
// Version returns the value of the "version" field in the mutation.
func (m *VirtualMachineMutation) Version() (r string, exists bool) {
v := m.version
if v == nil {
return
}
return *v, true
}
// OldVersion returns the old "version" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldVersion(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldVersion is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldVersion requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldVersion: %w", err)
}
return oldValue.Version, nil
}
// ClearVersion clears the value of the "version" field.
func (m *VirtualMachineMutation) ClearVersion() {
m.version = nil
m.clearedFields[virtualmachine.FieldVersion] = struct{}{}
}
// VersionCleared returns if the "version" field was cleared in this mutation.
func (m *VirtualMachineMutation) VersionCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldVersion]
return ok
}
// ResetVersion resets all changes to the "version" field.
func (m *VirtualMachineMutation) ResetVersion() {
m.version = nil
delete(m.clearedFields, virtualmachine.FieldVersion)
}
// SetMachineID sets the "machine_id" field.
func (m *VirtualMachineMutation) SetMachineID(s string) {
m.machine_id = &s
}
// MachineID returns the value of the "machine_id" field in the mutation.
func (m *VirtualMachineMutation) MachineID() (r string, exists bool) {
v := m.machine_id
if v == nil {
return
}
return *v, true
}
// OldMachineID returns the old "machine_id" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldMachineID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMachineID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldMachineID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMachineID: %w", err)
}
return oldValue.MachineID, nil
}
// ClearMachineID clears the value of the "machine_id" field.
func (m *VirtualMachineMutation) ClearMachineID() {
m.machine_id = nil
m.clearedFields[virtualmachine.FieldMachineID] = struct{}{}
}
// MachineIDCleared returns if the "machine_id" field was cleared in this mutation.
func (m *VirtualMachineMutation) MachineIDCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldMachineID]
return ok
}
// ResetMachineID resets all changes to the "machine_id" field.
func (m *VirtualMachineMutation) ResetMachineID() {
m.machine_id = nil
delete(m.clearedFields, virtualmachine.FieldMachineID)
}
// SetRepoURL sets the "repo_url" field.
func (m *VirtualMachineMutation) SetRepoURL(s string) {
m.repo_url = &s
}
// RepoURL returns the value of the "repo_url" field in the mutation.
func (m *VirtualMachineMutation) RepoURL() (r string, exists bool) {
v := m.repo_url
if v == nil {
return
}
return *v, true
}
// OldRepoURL returns the old "repo_url" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldRepoURL(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRepoURL is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRepoURL requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRepoURL: %w", err)
}
return oldValue.RepoURL, nil
}
// ClearRepoURL clears the value of the "repo_url" field.
func (m *VirtualMachineMutation) ClearRepoURL() {
m.repo_url = nil
m.clearedFields[virtualmachine.FieldRepoURL] = struct{}{}
}
// RepoURLCleared returns if the "repo_url" field was cleared in this mutation.
func (m *VirtualMachineMutation) RepoURLCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldRepoURL]
return ok
}
// ResetRepoURL resets all changes to the "repo_url" field.
func (m *VirtualMachineMutation) ResetRepoURL() {
m.repo_url = nil
delete(m.clearedFields, virtualmachine.FieldRepoURL)
}
// SetRepoFilename sets the "repo_filename" field.
func (m *VirtualMachineMutation) SetRepoFilename(s string) {
m.repo_filename = &s
}
// RepoFilename returns the value of the "repo_filename" field in the mutation.
func (m *VirtualMachineMutation) RepoFilename() (r string, exists bool) {
v := m.repo_filename
if v == nil {
return
}
return *v, true
}
// OldRepoFilename returns the old "repo_filename" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldRepoFilename(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRepoFilename is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRepoFilename requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRepoFilename: %w", err)
}
return oldValue.RepoFilename, nil
}
// ClearRepoFilename clears the value of the "repo_filename" field.
func (m *VirtualMachineMutation) ClearRepoFilename() {
m.repo_filename = nil
m.clearedFields[virtualmachine.FieldRepoFilename] = struct{}{}
}
// RepoFilenameCleared returns if the "repo_filename" field was cleared in this mutation.
func (m *VirtualMachineMutation) RepoFilenameCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldRepoFilename]
return ok
}
// ResetRepoFilename resets all changes to the "repo_filename" field.
func (m *VirtualMachineMutation) ResetRepoFilename() {
m.repo_filename = nil
delete(m.clearedFields, virtualmachine.FieldRepoFilename)
}
// SetBranch sets the "branch" field.
func (m *VirtualMachineMutation) SetBranch(s string) {
m.branch = &s
}
// Branch returns the value of the "branch" field in the mutation.
func (m *VirtualMachineMutation) Branch() (r string, exists bool) {
v := m.branch
if v == nil {
return
}
return *v, true
}
// OldBranch returns the old "branch" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldBranch(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldBranch is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldBranch requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBranch: %w", err)
}
return oldValue.Branch, nil
}
// ClearBranch clears the value of the "branch" field.
func (m *VirtualMachineMutation) ClearBranch() {
m.branch = nil
m.clearedFields[virtualmachine.FieldBranch] = struct{}{}
}
// BranchCleared returns if the "branch" field was cleared in this mutation.
func (m *VirtualMachineMutation) BranchCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldBranch]
return ok
}
// ResetBranch resets all changes to the "branch" field.
func (m *VirtualMachineMutation) ResetBranch() {
m.branch = nil
delete(m.clearedFields, virtualmachine.FieldBranch)
}
// SetGitIdentityID sets the "git_identity_id" field.
func (m *VirtualMachineMutation) SetGitIdentityID(u uuid.UUID) {
m.git_identity = &u
}
// GitIdentityID returns the value of the "git_identity_id" field in the mutation.
func (m *VirtualMachineMutation) GitIdentityID() (r uuid.UUID, exists bool) {
v := m.git_identity
if v == nil {
return
}
return *v, true
}
// OldGitIdentityID returns the old "git_identity_id" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldGitIdentityID(ctx context.Context) (v uuid.UUID, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGitIdentityID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGitIdentityID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGitIdentityID: %w", err)
}
return oldValue.GitIdentityID, nil
}
// ClearGitIdentityID clears the value of the "git_identity_id" field.
func (m *VirtualMachineMutation) ClearGitIdentityID() {
m.git_identity = nil
m.clearedFields[virtualmachine.FieldGitIdentityID] = struct{}{}
}
// GitIdentityIDCleared returns if the "git_identity_id" field was cleared in this mutation.
func (m *VirtualMachineMutation) GitIdentityIDCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldGitIdentityID]
return ok
}
// ResetGitIdentityID resets all changes to the "git_identity_id" field.
func (m *VirtualMachineMutation) ResetGitIdentityID() {
m.git_identity = nil
delete(m.clearedFields, virtualmachine.FieldGitIdentityID)
}
// SetIsRecycled sets the "is_recycled" field.
func (m *VirtualMachineMutation) SetIsRecycled(b bool) {
m.is_recycled = &b
}
// IsRecycled returns the value of the "is_recycled" field in the mutation.
func (m *VirtualMachineMutation) IsRecycled() (r bool, exists bool) {
v := m.is_recycled
if v == nil {
return
}
return *v, true
}
// OldIsRecycled returns the old "is_recycled" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldIsRecycled(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldIsRecycled is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldIsRecycled requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIsRecycled: %w", err)
}
return oldValue.IsRecycled, nil
}
// ClearIsRecycled clears the value of the "is_recycled" field.
func (m *VirtualMachineMutation) ClearIsRecycled() {
m.is_recycled = nil
m.clearedFields[virtualmachine.FieldIsRecycled] = struct{}{}
}
// IsRecycledCleared returns if the "is_recycled" field was cleared in this mutation.
func (m *VirtualMachineMutation) IsRecycledCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldIsRecycled]
return ok
}
// ResetIsRecycled resets all changes to the "is_recycled" field.
func (m *VirtualMachineMutation) ResetIsRecycled() {
m.is_recycled = nil
delete(m.clearedFields, virtualmachine.FieldIsRecycled)
}
// SetConditions sets the "conditions" field.
func (m *VirtualMachineMutation) SetConditions(tmc *types.VirtualMachineCondition) {
m.conditions = &tmc
}
// Conditions returns the value of the "conditions" field in the mutation.
func (m *VirtualMachineMutation) Conditions() (r *types.VirtualMachineCondition, exists bool) {
v := m.conditions
if v == nil {
return
}
return *v, true
}
// OldConditions returns the old "conditions" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldConditions(ctx context.Context) (v *types.VirtualMachineCondition, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldConditions is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldConditions requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldConditions: %w", err)
}
return oldValue.Conditions, nil
}
// ClearConditions clears the value of the "conditions" field.
func (m *VirtualMachineMutation) ClearConditions() {
m.conditions = nil
m.clearedFields[virtualmachine.FieldConditions] = struct{}{}
}
// ConditionsCleared returns if the "conditions" field was cleared in this mutation.
func (m *VirtualMachineMutation) ConditionsCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldConditions]
return ok
}
// ResetConditions resets all changes to the "conditions" field.
func (m *VirtualMachineMutation) ResetConditions() {
m.conditions = nil
delete(m.clearedFields, virtualmachine.FieldConditions)
}
// SetExpiredAt sets the "expired_at" field.
func (m *VirtualMachineMutation) SetExpiredAt(t time.Time) {
m.expired_at = &t
}
// ExpiredAt returns the value of the "expired_at" field in the mutation.
func (m *VirtualMachineMutation) ExpiredAt() (r time.Time, exists bool) {
v := m.expired_at
if v == nil {
return
}
return *v, true
}
// OldExpiredAt returns the old "expired_at" field's value of the VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) OldExpiredAt(ctx context.Context) (v *time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldExpiredAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldExpiredAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldExpiredAt: %w", err)
}
return oldValue.ExpiredAt, nil
}
// ClearExpiredAt clears the value of the "expired_at" field.
func (m *VirtualMachineMutation) ClearExpiredAt() {
m.expired_at = nil
m.clearedFields[virtualmachine.FieldExpiredAt] = struct{}{}
}
// ExpiredAtCleared returns if the "expired_at" field was cleared in this mutation.
func (m *VirtualMachineMutation) ExpiredAtCleared() bool {
_, ok := m.clearedFields[virtualmachine.FieldExpiredAt]
return ok
}
// ResetExpiredAt resets all changes to the "expired_at" field.
func (m *VirtualMachineMutation) ResetExpiredAt() {
m.expired_at = nil
delete(m.clearedFields, virtualmachine.FieldExpiredAt)
}
// SetCreatedAt sets the "created_at" field.
func (m *VirtualMachineMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *VirtualMachineMutation) 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 VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) 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 *VirtualMachineMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *VirtualMachineMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *VirtualMachineMutation) 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 VirtualMachine entity.
// If the VirtualMachine 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 *VirtualMachineMutation) 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 *VirtualMachineMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// ClearHost clears the "host" edge to the Host entity.
func (m *VirtualMachineMutation) ClearHost() {
m.clearedhost = true
m.clearedFields[virtualmachine.FieldHostID] = struct{}{}
}
// HostCleared reports if the "host" edge to the Host entity was cleared.
func (m *VirtualMachineMutation) HostCleared() bool {
return m.clearedhost
}
// HostIDs returns the "host" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// HostID instead. It exists only for internal usage by the builders.
func (m *VirtualMachineMutation) HostIDs() (ids []string) {
if id := m.host; id != nil {
ids = append(ids, *id)
}
return
}
// ResetHost resets all changes to the "host" edge.
func (m *VirtualMachineMutation) ResetHost() {
m.host = nil
m.clearedhost = false
}
// ClearModel clears the "model" edge to the Model entity.
func (m *VirtualMachineMutation) ClearModel() {
m.clearedmodel = true
m.clearedFields[virtualmachine.FieldModelID] = struct{}{}
}
// ModelCleared reports if the "model" edge to the Model entity was cleared.
func (m *VirtualMachineMutation) ModelCleared() bool {
return m.ModelIDCleared() || m.clearedmodel
}
// ModelIDs returns the "model" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ModelID instead. It exists only for internal usage by the builders.
func (m *VirtualMachineMutation) ModelIDs() (ids []uuid.UUID) {
if id := m.model; id != nil {
ids = append(ids, *id)
}
return
}
// ResetModel resets all changes to the "model" edge.
func (m *VirtualMachineMutation) ResetModel() {
m.model = nil
m.clearedmodel = false
}
// ClearUser clears the "user" edge to the User entity.
func (m *VirtualMachineMutation) ClearUser() {
m.cleareduser = true
m.clearedFields[virtualmachine.FieldUserID] = struct{}{}
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *VirtualMachineMutation) UserCleared() bool {
return m.UserIDCleared() || m.cleareduser
}
// UserIDs returns the "user" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// UserID instead. It exists only for internal usage by the builders.
func (m *VirtualMachineMutation) UserIDs() (ids []uuid.UUID) {
if id := m.user; id != nil {
ids = append(ids, *id)
}
return
}
// ResetUser resets all changes to the "user" edge.
func (m *VirtualMachineMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// ClearGitIdentity clears the "git_identity" edge to the GitIdentity entity.
func (m *VirtualMachineMutation) ClearGitIdentity() {
m.clearedgit_identity = true
m.clearedFields[virtualmachine.FieldGitIdentityID] = struct{}{}
}
// GitIdentityCleared reports if the "git_identity" edge to the GitIdentity entity was cleared.
func (m *VirtualMachineMutation) GitIdentityCleared() bool {
return m.GitIdentityIDCleared() || m.clearedgit_identity
}
// GitIdentityIDs returns the "git_identity" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// GitIdentityID instead. It exists only for internal usage by the builders.
func (m *VirtualMachineMutation) GitIdentityIDs() (ids []uuid.UUID) {
if id := m.git_identity; id != nil {
ids = append(ids, *id)
}
return
}
// ResetGitIdentity resets all changes to the "git_identity" edge.
func (m *VirtualMachineMutation) ResetGitIdentity() {
m.git_identity = nil
m.clearedgit_identity = false
}
// AddTaskIDs adds the "tasks" edge to the Task entity by ids.
func (m *VirtualMachineMutation) AddTaskIDs(ids ...uuid.UUID) {
if m.tasks == nil {
m.tasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.tasks[ids[i]] = struct{}{}
}
}
// ClearTasks clears the "tasks" edge to the Task entity.
func (m *VirtualMachineMutation) ClearTasks() {
m.clearedtasks = true
}
// TasksCleared reports if the "tasks" edge to the Task entity was cleared.
func (m *VirtualMachineMutation) TasksCleared() bool {
return m.clearedtasks
}
// RemoveTaskIDs removes the "tasks" edge to the Task entity by IDs.
func (m *VirtualMachineMutation) RemoveTaskIDs(ids ...uuid.UUID) {
if m.removedtasks == nil {
m.removedtasks = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.tasks, ids[i])
m.removedtasks[ids[i]] = struct{}{}
}
}
// RemovedTasks returns the removed IDs of the "tasks" edge to the Task entity.
func (m *VirtualMachineMutation) RemovedTasksIDs() (ids []uuid.UUID) {
for id := range m.removedtasks {
ids = append(ids, id)
}
return
}
// TasksIDs returns the "tasks" edge IDs in the mutation.
func (m *VirtualMachineMutation) TasksIDs() (ids []uuid.UUID) {
for id := range m.tasks {
ids = append(ids, id)
}
return
}
// ResetTasks resets all changes to the "tasks" edge.
func (m *VirtualMachineMutation) ResetTasks() {
m.tasks = nil
m.clearedtasks = false
m.removedtasks = nil
}
// AddTaskVMIDs adds the "task_vms" edge to the TaskVirtualMachine entity by ids.
func (m *VirtualMachineMutation) AddTaskVMIDs(ids ...uuid.UUID) {
if m.task_vms == nil {
m.task_vms = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.task_vms[ids[i]] = struct{}{}
}
}
// ClearTaskVms clears the "task_vms" edge to the TaskVirtualMachine entity.
func (m *VirtualMachineMutation) ClearTaskVms() {
m.clearedtask_vms = true
}
// TaskVmsCleared reports if the "task_vms" edge to the TaskVirtualMachine entity was cleared.
func (m *VirtualMachineMutation) TaskVmsCleared() bool {
return m.clearedtask_vms
}
// RemoveTaskVMIDs removes the "task_vms" edge to the TaskVirtualMachine entity by IDs.
func (m *VirtualMachineMutation) RemoveTaskVMIDs(ids ...uuid.UUID) {
if m.removedtask_vms == nil {
m.removedtask_vms = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.task_vms, ids[i])
m.removedtask_vms[ids[i]] = struct{}{}
}
}
// RemovedTaskVms returns the removed IDs of the "task_vms" edge to the TaskVirtualMachine entity.
func (m *VirtualMachineMutation) RemovedTaskVmsIDs() (ids []uuid.UUID) {
for id := range m.removedtask_vms {
ids = append(ids, id)
}
return
}
// TaskVmsIDs returns the "task_vms" edge IDs in the mutation.
func (m *VirtualMachineMutation) TaskVmsIDs() (ids []uuid.UUID) {
for id := range m.task_vms {
ids = append(ids, id)
}
return
}
// ResetTaskVms resets all changes to the "task_vms" edge.
func (m *VirtualMachineMutation) ResetTaskVms() {
m.task_vms = nil
m.clearedtask_vms = false
m.removedtask_vms = nil
}
// Where appends a list predicates to the VirtualMachineMutation builder.
func (m *VirtualMachineMutation) Where(ps ...predicate.VirtualMachine) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the VirtualMachineMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *VirtualMachineMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.VirtualMachine, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *VirtualMachineMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *VirtualMachineMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (VirtualMachine).
func (m *VirtualMachineMutation) 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 *VirtualMachineMutation) Fields() []string {
fields := make([]string, 0, 25)
if m.deleted_at != nil {
fields = append(fields, virtualmachine.FieldDeletedAt)
}
if m.access_token != nil {
fields = append(fields, virtualmachine.FieldAccessToken)
}
if m.host != nil {
fields = append(fields, virtualmachine.FieldHostID)
}
if m.user != nil {
fields = append(fields, virtualmachine.FieldUserID)
}
if m.model != nil {
fields = append(fields, virtualmachine.FieldModelID)
}
if m.environment_id != nil {
fields = append(fields, virtualmachine.FieldEnvironmentID)
}
if m.name != nil {
fields = append(fields, virtualmachine.FieldName)
}
if m.hostname != nil {
fields = append(fields, virtualmachine.FieldHostname)
}
if m.arch != nil {
fields = append(fields, virtualmachine.FieldArch)
}
if m.cores != nil {
fields = append(fields, virtualmachine.FieldCores)
}
if m.memory != nil {
fields = append(fields, virtualmachine.FieldMemory)
}
if m.os != nil {
fields = append(fields, virtualmachine.FieldOs)
}
if m.external_ip != nil {
fields = append(fields, virtualmachine.FieldExternalIP)
}
if m.internal_ip != nil {
fields = append(fields, virtualmachine.FieldInternalIP)
}
if m.version != nil {
fields = append(fields, virtualmachine.FieldVersion)
}
if m.machine_id != nil {
fields = append(fields, virtualmachine.FieldMachineID)
}
if m.repo_url != nil {
fields = append(fields, virtualmachine.FieldRepoURL)
}
if m.repo_filename != nil {
fields = append(fields, virtualmachine.FieldRepoFilename)
}
if m.branch != nil {
fields = append(fields, virtualmachine.FieldBranch)
}
if m.git_identity != nil {
fields = append(fields, virtualmachine.FieldGitIdentityID)
}
if m.is_recycled != nil {
fields = append(fields, virtualmachine.FieldIsRecycled)
}
if m.conditions != nil {
fields = append(fields, virtualmachine.FieldConditions)
}
if m.expired_at != nil {
fields = append(fields, virtualmachine.FieldExpiredAt)
}
if m.created_at != nil {
fields = append(fields, virtualmachine.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, virtualmachine.FieldUpdatedAt)
}
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 *VirtualMachineMutation) Field(name string) (ent.Value, bool) {
switch name {
case virtualmachine.FieldDeletedAt:
return m.DeletedAt()
case virtualmachine.FieldAccessToken:
return m.AccessToken()
case virtualmachine.FieldHostID:
return m.HostID()
case virtualmachine.FieldUserID:
return m.UserID()
case virtualmachine.FieldModelID:
return m.ModelID()
case virtualmachine.FieldEnvironmentID:
return m.EnvironmentID()
case virtualmachine.FieldName:
return m.Name()
case virtualmachine.FieldHostname:
return m.Hostname()
case virtualmachine.FieldArch:
return m.Arch()
case virtualmachine.FieldCores:
return m.Cores()
case virtualmachine.FieldMemory:
return m.Memory()
case virtualmachine.FieldOs:
return m.Os()
case virtualmachine.FieldExternalIP:
return m.ExternalIP()
case virtualmachine.FieldInternalIP:
return m.InternalIP()
case virtualmachine.FieldVersion:
return m.Version()
case virtualmachine.FieldMachineID:
return m.MachineID()
case virtualmachine.FieldRepoURL:
return m.RepoURL()
case virtualmachine.FieldRepoFilename:
return m.RepoFilename()
case virtualmachine.FieldBranch:
return m.Branch()
case virtualmachine.FieldGitIdentityID:
return m.GitIdentityID()
case virtualmachine.FieldIsRecycled:
return m.IsRecycled()
case virtualmachine.FieldConditions:
return m.Conditions()
case virtualmachine.FieldExpiredAt:
return m.ExpiredAt()
case virtualmachine.FieldCreatedAt:
return m.CreatedAt()
case virtualmachine.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *VirtualMachineMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case virtualmachine.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case virtualmachine.FieldAccessToken:
return m.OldAccessToken(ctx)
case virtualmachine.FieldHostID:
return m.OldHostID(ctx)
case virtualmachine.FieldUserID:
return m.OldUserID(ctx)
case virtualmachine.FieldModelID:
return m.OldModelID(ctx)
case virtualmachine.FieldEnvironmentID:
return m.OldEnvironmentID(ctx)
case virtualmachine.FieldName:
return m.OldName(ctx)
case virtualmachine.FieldHostname:
return m.OldHostname(ctx)
case virtualmachine.FieldArch:
return m.OldArch(ctx)
case virtualmachine.FieldCores:
return m.OldCores(ctx)
case virtualmachine.FieldMemory:
return m.OldMemory(ctx)
case virtualmachine.FieldOs:
return m.OldOs(ctx)
case virtualmachine.FieldExternalIP:
return m.OldExternalIP(ctx)
case virtualmachine.FieldInternalIP:
return m.OldInternalIP(ctx)
case virtualmachine.FieldVersion:
return m.OldVersion(ctx)
case virtualmachine.FieldMachineID:
return m.OldMachineID(ctx)
case virtualmachine.FieldRepoURL:
return m.OldRepoURL(ctx)
case virtualmachine.FieldRepoFilename:
return m.OldRepoFilename(ctx)
case virtualmachine.FieldBranch:
return m.OldBranch(ctx)
case virtualmachine.FieldGitIdentityID:
return m.OldGitIdentityID(ctx)
case virtualmachine.FieldIsRecycled:
return m.OldIsRecycled(ctx)
case virtualmachine.FieldConditions:
return m.OldConditions(ctx)
case virtualmachine.FieldExpiredAt:
return m.OldExpiredAt(ctx)
case virtualmachine.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case virtualmachine.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown VirtualMachine 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 *VirtualMachineMutation) SetField(name string, value ent.Value) error {
switch name {
case virtualmachine.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 virtualmachine.FieldAccessToken:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAccessToken(v)
return nil
case virtualmachine.FieldHostID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHostID(v)
return nil
case virtualmachine.FieldUserID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUserID(v)
return nil
case virtualmachine.FieldModelID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetModelID(v)
return nil
case virtualmachine.FieldEnvironmentID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEnvironmentID(v)
return nil
case virtualmachine.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case virtualmachine.FieldHostname:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHostname(v)
return nil
case virtualmachine.FieldArch:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetArch(v)
return nil
case virtualmachine.FieldCores:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCores(v)
return nil
case virtualmachine.FieldMemory:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMemory(v)
return nil
case virtualmachine.FieldOs:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOs(v)
return nil
case virtualmachine.FieldExternalIP:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetExternalIP(v)
return nil
case virtualmachine.FieldInternalIP:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetInternalIP(v)
return nil
case virtualmachine.FieldVersion:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetVersion(v)
return nil
case virtualmachine.FieldMachineID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMachineID(v)
return nil
case virtualmachine.FieldRepoURL:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRepoURL(v)
return nil
case virtualmachine.FieldRepoFilename:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRepoFilename(v)
return nil
case virtualmachine.FieldBranch:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetBranch(v)
return nil
case virtualmachine.FieldGitIdentityID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGitIdentityID(v)
return nil
case virtualmachine.FieldIsRecycled:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetIsRecycled(v)
return nil
case virtualmachine.FieldConditions:
v, ok := value.(*types.VirtualMachineCondition)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetConditions(v)
return nil
case virtualmachine.FieldExpiredAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetExpiredAt(v)
return nil
case virtualmachine.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 virtualmachine.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown VirtualMachine field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *VirtualMachineMutation) AddedFields() []string {
var fields []string
if m.addcores != nil {
fields = append(fields, virtualmachine.FieldCores)
}
if m.addmemory != nil {
fields = append(fields, virtualmachine.FieldMemory)
}
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 *VirtualMachineMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case virtualmachine.FieldCores:
return m.AddedCores()
case virtualmachine.FieldMemory:
return m.AddedMemory()
}
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 *VirtualMachineMutation) AddField(name string, value ent.Value) error {
switch name {
case virtualmachine.FieldCores:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddCores(v)
return nil
case virtualmachine.FieldMemory:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMemory(v)
return nil
}
return fmt.Errorf("unknown VirtualMachine numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *VirtualMachineMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(virtualmachine.FieldDeletedAt) {
fields = append(fields, virtualmachine.FieldDeletedAt)
}
if m.FieldCleared(virtualmachine.FieldAccessToken) {
fields = append(fields, virtualmachine.FieldAccessToken)
}
if m.FieldCleared(virtualmachine.FieldUserID) {
fields = append(fields, virtualmachine.FieldUserID)
}
if m.FieldCleared(virtualmachine.FieldModelID) {
fields = append(fields, virtualmachine.FieldModelID)
}
if m.FieldCleared(virtualmachine.FieldEnvironmentID) {
fields = append(fields, virtualmachine.FieldEnvironmentID)
}
if m.FieldCleared(virtualmachine.FieldHostname) {
fields = append(fields, virtualmachine.FieldHostname)
}
if m.FieldCleared(virtualmachine.FieldArch) {
fields = append(fields, virtualmachine.FieldArch)
}
if m.FieldCleared(virtualmachine.FieldCores) {
fields = append(fields, virtualmachine.FieldCores)
}
if m.FieldCleared(virtualmachine.FieldMemory) {
fields = append(fields, virtualmachine.FieldMemory)
}
if m.FieldCleared(virtualmachine.FieldOs) {
fields = append(fields, virtualmachine.FieldOs)
}
if m.FieldCleared(virtualmachine.FieldExternalIP) {
fields = append(fields, virtualmachine.FieldExternalIP)
}
if m.FieldCleared(virtualmachine.FieldInternalIP) {
fields = append(fields, virtualmachine.FieldInternalIP)
}
if m.FieldCleared(virtualmachine.FieldVersion) {
fields = append(fields, virtualmachine.FieldVersion)
}
if m.FieldCleared(virtualmachine.FieldMachineID) {
fields = append(fields, virtualmachine.FieldMachineID)
}
if m.FieldCleared(virtualmachine.FieldRepoURL) {
fields = append(fields, virtualmachine.FieldRepoURL)
}
if m.FieldCleared(virtualmachine.FieldRepoFilename) {
fields = append(fields, virtualmachine.FieldRepoFilename)
}
if m.FieldCleared(virtualmachine.FieldBranch) {
fields = append(fields, virtualmachine.FieldBranch)
}
if m.FieldCleared(virtualmachine.FieldGitIdentityID) {
fields = append(fields, virtualmachine.FieldGitIdentityID)
}
if m.FieldCleared(virtualmachine.FieldIsRecycled) {
fields = append(fields, virtualmachine.FieldIsRecycled)
}
if m.FieldCleared(virtualmachine.FieldConditions) {
fields = append(fields, virtualmachine.FieldConditions)
}
if m.FieldCleared(virtualmachine.FieldExpiredAt) {
fields = append(fields, virtualmachine.FieldExpiredAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *VirtualMachineMutation) 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 *VirtualMachineMutation) ClearField(name string) error {
switch name {
case virtualmachine.FieldDeletedAt:
m.ClearDeletedAt()
return nil
case virtualmachine.FieldAccessToken:
m.ClearAccessToken()
return nil
case virtualmachine.FieldUserID:
m.ClearUserID()
return nil
case virtualmachine.FieldModelID:
m.ClearModelID()
return nil
case virtualmachine.FieldEnvironmentID:
m.ClearEnvironmentID()
return nil
case virtualmachine.FieldHostname:
m.ClearHostname()
return nil
case virtualmachine.FieldArch:
m.ClearArch()
return nil
case virtualmachine.FieldCores:
m.ClearCores()
return nil
case virtualmachine.FieldMemory:
m.ClearMemory()
return nil
case virtualmachine.FieldOs:
m.ClearOs()
return nil
case virtualmachine.FieldExternalIP:
m.ClearExternalIP()
return nil
case virtualmachine.FieldInternalIP:
m.ClearInternalIP()
return nil
case virtualmachine.FieldVersion:
m.ClearVersion()
return nil
case virtualmachine.FieldMachineID:
m.ClearMachineID()
return nil
case virtualmachine.FieldRepoURL:
m.ClearRepoURL()
return nil
case virtualmachine.FieldRepoFilename:
m.ClearRepoFilename()
return nil
case virtualmachine.FieldBranch:
m.ClearBranch()
return nil
case virtualmachine.FieldGitIdentityID:
m.ClearGitIdentityID()
return nil
case virtualmachine.FieldIsRecycled:
m.ClearIsRecycled()
return nil
case virtualmachine.FieldConditions:
m.ClearConditions()
return nil
case virtualmachine.FieldExpiredAt:
m.ClearExpiredAt()
return nil
}
return fmt.Errorf("unknown VirtualMachine 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 *VirtualMachineMutation) ResetField(name string) error {
switch name {
case virtualmachine.FieldDeletedAt:
m.ResetDeletedAt()
return nil
case virtualmachine.FieldAccessToken:
m.ResetAccessToken()
return nil
case virtualmachine.FieldHostID:
m.ResetHostID()
return nil
case virtualmachine.FieldUserID:
m.ResetUserID()
return nil
case virtualmachine.FieldModelID:
m.ResetModelID()
return nil
case virtualmachine.FieldEnvironmentID:
m.ResetEnvironmentID()
return nil
case virtualmachine.FieldName:
m.ResetName()
return nil
case virtualmachine.FieldHostname:
m.ResetHostname()
return nil
case virtualmachine.FieldArch:
m.ResetArch()
return nil
case virtualmachine.FieldCores:
m.ResetCores()
return nil
case virtualmachine.FieldMemory:
m.ResetMemory()
return nil
case virtualmachine.FieldOs:
m.ResetOs()
return nil
case virtualmachine.FieldExternalIP:
m.ResetExternalIP()
return nil
case virtualmachine.FieldInternalIP:
m.ResetInternalIP()
return nil
case virtualmachine.FieldVersion:
m.ResetVersion()
return nil
case virtualmachine.FieldMachineID:
m.ResetMachineID()
return nil
case virtualmachine.FieldRepoURL:
m.ResetRepoURL()
return nil
case virtualmachine.FieldRepoFilename:
m.ResetRepoFilename()
return nil
case virtualmachine.FieldBranch:
m.ResetBranch()
return nil
case virtualmachine.FieldGitIdentityID:
m.ResetGitIdentityID()
return nil
case virtualmachine.FieldIsRecycled:
m.ResetIsRecycled()
return nil
case virtualmachine.FieldConditions:
m.ResetConditions()
return nil
case virtualmachine.FieldExpiredAt:
m.ResetExpiredAt()
return nil
case virtualmachine.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case virtualmachine.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown VirtualMachine field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *VirtualMachineMutation) AddedEdges() []string {
edges := make([]string, 0, 6)
if m.host != nil {
edges = append(edges, virtualmachine.EdgeHost)
}
if m.model != nil {
edges = append(edges, virtualmachine.EdgeModel)
}
if m.user != nil {
edges = append(edges, virtualmachine.EdgeUser)
}
if m.git_identity != nil {
edges = append(edges, virtualmachine.EdgeGitIdentity)
}
if m.tasks != nil {
edges = append(edges, virtualmachine.EdgeTasks)
}
if m.task_vms != nil {
edges = append(edges, virtualmachine.EdgeTaskVms)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *VirtualMachineMutation) AddedIDs(name string) []ent.Value {
switch name {
case virtualmachine.EdgeHost:
if id := m.host; id != nil {
return []ent.Value{*id}
}
case virtualmachine.EdgeModel:
if id := m.model; id != nil {
return []ent.Value{*id}
}
case virtualmachine.EdgeUser:
if id := m.user; id != nil {
return []ent.Value{*id}
}
case virtualmachine.EdgeGitIdentity:
if id := m.git_identity; id != nil {
return []ent.Value{*id}
}
case virtualmachine.EdgeTasks:
ids := make([]ent.Value, 0, len(m.tasks))
for id := range m.tasks {
ids = append(ids, id)
}
return ids
case virtualmachine.EdgeTaskVms:
ids := make([]ent.Value, 0, len(m.task_vms))
for id := range m.task_vms {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *VirtualMachineMutation) RemovedEdges() []string {
edges := make([]string, 0, 6)
if m.removedtasks != nil {
edges = append(edges, virtualmachine.EdgeTasks)
}
if m.removedtask_vms != nil {
edges = append(edges, virtualmachine.EdgeTaskVms)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *VirtualMachineMutation) RemovedIDs(name string) []ent.Value {
switch name {
case virtualmachine.EdgeTasks:
ids := make([]ent.Value, 0, len(m.removedtasks))
for id := range m.removedtasks {
ids = append(ids, id)
}
return ids
case virtualmachine.EdgeTaskVms:
ids := make([]ent.Value, 0, len(m.removedtask_vms))
for id := range m.removedtask_vms {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *VirtualMachineMutation) ClearedEdges() []string {
edges := make([]string, 0, 6)
if m.clearedhost {
edges = append(edges, virtualmachine.EdgeHost)
}
if m.clearedmodel {
edges = append(edges, virtualmachine.EdgeModel)
}
if m.cleareduser {
edges = append(edges, virtualmachine.EdgeUser)
}
if m.clearedgit_identity {
edges = append(edges, virtualmachine.EdgeGitIdentity)
}
if m.clearedtasks {
edges = append(edges, virtualmachine.EdgeTasks)
}
if m.clearedtask_vms {
edges = append(edges, virtualmachine.EdgeTaskVms)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *VirtualMachineMutation) EdgeCleared(name string) bool {
switch name {
case virtualmachine.EdgeHost:
return m.clearedhost
case virtualmachine.EdgeModel:
return m.clearedmodel
case virtualmachine.EdgeUser:
return m.cleareduser
case virtualmachine.EdgeGitIdentity:
return m.clearedgit_identity
case virtualmachine.EdgeTasks:
return m.clearedtasks
case virtualmachine.EdgeTaskVms:
return m.clearedtask_vms
}
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 *VirtualMachineMutation) ClearEdge(name string) error {
switch name {
case virtualmachine.EdgeHost:
m.ClearHost()
return nil
case virtualmachine.EdgeModel:
m.ClearModel()
return nil
case virtualmachine.EdgeUser:
m.ClearUser()
return nil
case virtualmachine.EdgeGitIdentity:
m.ClearGitIdentity()
return nil
}
return fmt.Errorf("unknown VirtualMachine 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 *VirtualMachineMutation) ResetEdge(name string) error {
switch name {
case virtualmachine.EdgeHost:
m.ResetHost()
return nil
case virtualmachine.EdgeModel:
m.ResetModel()
return nil
case virtualmachine.EdgeUser:
m.ResetUser()
return nil
case virtualmachine.EdgeGitIdentity:
m.ResetGitIdentity()
return nil
case virtualmachine.EdgeTasks:
m.ResetTasks()
return nil
case virtualmachine.EdgeTaskVms:
m.ResetTaskVms()
return nil
}
return fmt.Errorf("unknown VirtualMachine edge %s", name)
}