mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
2432 lines
73 KiB
Go
2432 lines
73 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect"
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/chaitin/MonkeyCode/backend/consts"
|
|
"github.com/chaitin/MonkeyCode/backend/db/host"
|
|
"github.com/chaitin/MonkeyCode/backend/db/model"
|
|
"github.com/chaitin/MonkeyCode/backend/db/task"
|
|
"github.com/chaitin/MonkeyCode/backend/db/taskvirtualmachine"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/chaitin/MonkeyCode/backend/db/virtualmachine"
|
|
"github.com/chaitin/MonkeyCode/backend/ent/types"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// VirtualMachineCreate is the builder for creating a VirtualMachine entity.
|
|
type VirtualMachineCreate struct {
|
|
config
|
|
mutation *VirtualMachineMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_c *VirtualMachineCreate) SetDeletedAt(v time.Time) *VirtualMachineCreate {
|
|
_c.mutation.SetDeletedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableDeletedAt(v *time.Time) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetDeletedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetHostID sets the "host_id" field.
|
|
func (_c *VirtualMachineCreate) SetHostID(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetHostID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_c *VirtualMachineCreate) SetUserID(v uuid.UUID) *VirtualMachineCreate {
|
|
_c.mutation.SetUserID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableUserID(v *uuid.UUID) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetUserID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetModelID sets the "model_id" field.
|
|
func (_c *VirtualMachineCreate) SetModelID(v uuid.UUID) *VirtualMachineCreate {
|
|
_c.mutation.SetModelID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableModelID sets the "model_id" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableModelID(v *uuid.UUID) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetModelID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetEnvironmentID sets the "environment_id" field.
|
|
func (_c *VirtualMachineCreate) SetEnvironmentID(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetEnvironmentID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableEnvironmentID sets the "environment_id" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableEnvironmentID(v *string) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetEnvironmentID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_c *VirtualMachineCreate) SetName(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetHostname sets the "hostname" field.
|
|
func (_c *VirtualMachineCreate) SetHostname(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetHostname(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableHostname sets the "hostname" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableHostname(v *string) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetHostname(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetArch sets the "arch" field.
|
|
func (_c *VirtualMachineCreate) SetArch(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetArch(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableArch sets the "arch" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableArch(v *string) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetArch(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCores sets the "cores" field.
|
|
func (_c *VirtualMachineCreate) SetCores(v int) *VirtualMachineCreate {
|
|
_c.mutation.SetCores(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCores sets the "cores" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableCores(v *int) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetCores(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetMemory sets the "memory" field.
|
|
func (_c *VirtualMachineCreate) SetMemory(v int64) *VirtualMachineCreate {
|
|
_c.mutation.SetMemory(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableMemory sets the "memory" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableMemory(v *int64) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetMemory(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetOs sets the "os" field.
|
|
func (_c *VirtualMachineCreate) SetOs(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetOs(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableOs sets the "os" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableOs(v *string) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetOs(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetExternalIP sets the "external_ip" field.
|
|
func (_c *VirtualMachineCreate) SetExternalIP(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetExternalIP(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableExternalIP sets the "external_ip" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableExternalIP(v *string) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetExternalIP(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetInternalIP sets the "internal_ip" field.
|
|
func (_c *VirtualMachineCreate) SetInternalIP(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetInternalIP(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableInternalIP sets the "internal_ip" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableInternalIP(v *string) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetInternalIP(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetTTLKind sets the "ttl_kind" field.
|
|
func (_c *VirtualMachineCreate) SetTTLKind(v consts.VirtualmachineTTLKind) *VirtualMachineCreate {
|
|
_c.mutation.SetTTLKind(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableTTLKind sets the "ttl_kind" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableTTLKind(v *consts.VirtualmachineTTLKind) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetTTLKind(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetTTL sets the "ttl" field.
|
|
func (_c *VirtualMachineCreate) SetTTL(v int64) *VirtualMachineCreate {
|
|
_c.mutation.SetTTL(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableTTL sets the "ttl" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableTTL(v *int64) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetTTL(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetVersion sets the "version" field.
|
|
func (_c *VirtualMachineCreate) SetVersion(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetVersion(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableVersion sets the "version" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableVersion(v *string) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetVersion(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetMachineID sets the "machine_id" field.
|
|
func (_c *VirtualMachineCreate) SetMachineID(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetMachineID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableMachineID sets the "machine_id" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableMachineID(v *string) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetMachineID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRepoURL sets the "repo_url" field.
|
|
func (_c *VirtualMachineCreate) SetRepoURL(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetRepoURL(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRepoURL sets the "repo_url" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableRepoURL(v *string) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetRepoURL(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRepoFilename sets the "repo_filename" field.
|
|
func (_c *VirtualMachineCreate) SetRepoFilename(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetRepoFilename(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRepoFilename sets the "repo_filename" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableRepoFilename(v *string) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetRepoFilename(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetBranch sets the "branch" field.
|
|
func (_c *VirtualMachineCreate) SetBranch(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetBranch(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableBranch sets the "branch" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableBranch(v *string) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetBranch(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetIsRecycled sets the "is_recycled" field.
|
|
func (_c *VirtualMachineCreate) SetIsRecycled(v bool) *VirtualMachineCreate {
|
|
_c.mutation.SetIsRecycled(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIsRecycled sets the "is_recycled" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableIsRecycled(v *bool) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetIsRecycled(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetConditions sets the "conditions" field.
|
|
func (_c *VirtualMachineCreate) SetConditions(v *types.VirtualMachineCondition) *VirtualMachineCreate {
|
|
_c.mutation.SetConditions(v)
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *VirtualMachineCreate) SetCreatedAt(v time.Time) *VirtualMachineCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableCreatedAt(v *time.Time) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *VirtualMachineCreate) SetUpdatedAt(v time.Time) *VirtualMachineCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *VirtualMachineCreate) SetNillableUpdatedAt(v *time.Time) *VirtualMachineCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *VirtualMachineCreate) SetID(v string) *VirtualMachineCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetHost sets the "host" edge to the Host entity.
|
|
func (_c *VirtualMachineCreate) SetHost(v *Host) *VirtualMachineCreate {
|
|
return _c.SetHostID(v.ID)
|
|
}
|
|
|
|
// SetModel sets the "model" edge to the Model entity.
|
|
func (_c *VirtualMachineCreate) SetModel(v *Model) *VirtualMachineCreate {
|
|
return _c.SetModelID(v.ID)
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_c *VirtualMachineCreate) SetUser(v *User) *VirtualMachineCreate {
|
|
return _c.SetUserID(v.ID)
|
|
}
|
|
|
|
// AddTaskIDs adds the "tasks" edge to the Task entity by IDs.
|
|
func (_c *VirtualMachineCreate) AddTaskIDs(ids ...uuid.UUID) *VirtualMachineCreate {
|
|
_c.mutation.AddTaskIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddTasks adds the "tasks" edges to the Task entity.
|
|
func (_c *VirtualMachineCreate) AddTasks(v ...*Task) *VirtualMachineCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddTaskIDs(ids...)
|
|
}
|
|
|
|
// AddTaskVMIDs adds the "task_vms" edge to the TaskVirtualMachine entity by IDs.
|
|
func (_c *VirtualMachineCreate) AddTaskVMIDs(ids ...uuid.UUID) *VirtualMachineCreate {
|
|
_c.mutation.AddTaskVMIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddTaskVms adds the "task_vms" edges to the TaskVirtualMachine entity.
|
|
func (_c *VirtualMachineCreate) AddTaskVms(v ...*TaskVirtualMachine) *VirtualMachineCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddTaskVMIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the VirtualMachineMutation object of the builder.
|
|
func (_c *VirtualMachineCreate) Mutation() *VirtualMachineMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the VirtualMachine in the database.
|
|
func (_c *VirtualMachineCreate) Save(ctx context.Context) (*VirtualMachine, error) {
|
|
if err := _c.defaults(); err != nil {
|
|
return nil, err
|
|
}
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *VirtualMachineCreate) SaveX(ctx context.Context) *VirtualMachine {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *VirtualMachineCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *VirtualMachineCreate) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_c *VirtualMachineCreate) defaults() error {
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
if virtualmachine.DefaultCreatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized virtualmachine.DefaultCreatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := virtualmachine.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
if virtualmachine.DefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized virtualmachine.DefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := virtualmachine.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *VirtualMachineCreate) check() error {
|
|
if _, ok := _c.mutation.HostID(); !ok {
|
|
return &ValidationError{Name: "host_id", err: errors.New(`db: missing required field "VirtualMachine.host_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`db: missing required field "VirtualMachine.name"`)}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "VirtualMachine.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "VirtualMachine.updated_at"`)}
|
|
}
|
|
if len(_c.mutation.HostIDs()) == 0 {
|
|
return &ValidationError{Name: "host", err: errors.New(`db: missing required edge "VirtualMachine.host"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *VirtualMachineCreate) sqlSave(ctx context.Context) (*VirtualMachine, error) {
|
|
if err := _c.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := _c.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
if _spec.ID.Value != nil {
|
|
if id, ok := _spec.ID.Value.(string); ok {
|
|
_node.ID = id
|
|
} else {
|
|
return nil, fmt.Errorf("unexpected VirtualMachine.ID type: %T", _spec.ID.Value)
|
|
}
|
|
}
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *VirtualMachineCreate) createSpec() (*VirtualMachine, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &VirtualMachine{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(virtualmachine.Table, sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString))
|
|
)
|
|
_spec.OnConflict = _c.conflict
|
|
if id, ok := _c.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = id
|
|
}
|
|
if value, ok := _c.mutation.DeletedAt(); ok {
|
|
_spec.SetField(virtualmachine.FieldDeletedAt, field.TypeTime, value)
|
|
_node.DeletedAt = value
|
|
}
|
|
if value, ok := _c.mutation.EnvironmentID(); ok {
|
|
_spec.SetField(virtualmachine.FieldEnvironmentID, field.TypeString, value)
|
|
_node.EnvironmentID = value
|
|
}
|
|
if value, ok := _c.mutation.Name(); ok {
|
|
_spec.SetField(virtualmachine.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := _c.mutation.Hostname(); ok {
|
|
_spec.SetField(virtualmachine.FieldHostname, field.TypeString, value)
|
|
_node.Hostname = value
|
|
}
|
|
if value, ok := _c.mutation.Arch(); ok {
|
|
_spec.SetField(virtualmachine.FieldArch, field.TypeString, value)
|
|
_node.Arch = value
|
|
}
|
|
if value, ok := _c.mutation.Cores(); ok {
|
|
_spec.SetField(virtualmachine.FieldCores, field.TypeInt, value)
|
|
_node.Cores = value
|
|
}
|
|
if value, ok := _c.mutation.Memory(); ok {
|
|
_spec.SetField(virtualmachine.FieldMemory, field.TypeInt64, value)
|
|
_node.Memory = value
|
|
}
|
|
if value, ok := _c.mutation.Os(); ok {
|
|
_spec.SetField(virtualmachine.FieldOs, field.TypeString, value)
|
|
_node.Os = value
|
|
}
|
|
if value, ok := _c.mutation.ExternalIP(); ok {
|
|
_spec.SetField(virtualmachine.FieldExternalIP, field.TypeString, value)
|
|
_node.ExternalIP = value
|
|
}
|
|
if value, ok := _c.mutation.InternalIP(); ok {
|
|
_spec.SetField(virtualmachine.FieldInternalIP, field.TypeString, value)
|
|
_node.InternalIP = value
|
|
}
|
|
if value, ok := _c.mutation.TTLKind(); ok {
|
|
_spec.SetField(virtualmachine.FieldTTLKind, field.TypeString, value)
|
|
_node.TTLKind = value
|
|
}
|
|
if value, ok := _c.mutation.TTL(); ok {
|
|
_spec.SetField(virtualmachine.FieldTTL, field.TypeInt64, value)
|
|
_node.TTL = value
|
|
}
|
|
if value, ok := _c.mutation.Version(); ok {
|
|
_spec.SetField(virtualmachine.FieldVersion, field.TypeString, value)
|
|
_node.Version = value
|
|
}
|
|
if value, ok := _c.mutation.MachineID(); ok {
|
|
_spec.SetField(virtualmachine.FieldMachineID, field.TypeString, value)
|
|
_node.MachineID = value
|
|
}
|
|
if value, ok := _c.mutation.RepoURL(); ok {
|
|
_spec.SetField(virtualmachine.FieldRepoURL, field.TypeString, value)
|
|
_node.RepoURL = value
|
|
}
|
|
if value, ok := _c.mutation.RepoFilename(); ok {
|
|
_spec.SetField(virtualmachine.FieldRepoFilename, field.TypeString, value)
|
|
_node.RepoFilename = value
|
|
}
|
|
if value, ok := _c.mutation.Branch(); ok {
|
|
_spec.SetField(virtualmachine.FieldBranch, field.TypeString, value)
|
|
_node.Branch = value
|
|
}
|
|
if value, ok := _c.mutation.IsRecycled(); ok {
|
|
_spec.SetField(virtualmachine.FieldIsRecycled, field.TypeBool, value)
|
|
_node.IsRecycled = value
|
|
}
|
|
if value, ok := _c.mutation.Conditions(); ok {
|
|
_spec.SetField(virtualmachine.FieldConditions, field.TypeJSON, value)
|
|
_node.Conditions = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(virtualmachine.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(virtualmachine.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if nodes := _c.mutation.HostIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: virtualmachine.HostTable,
|
|
Columns: []string{virtualmachine.HostColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.HostID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.ModelIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: virtualmachine.ModelTable,
|
|
Columns: []string{virtualmachine.ModelColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(model.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.ModelID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: virtualmachine.UserTable,
|
|
Columns: []string{virtualmachine.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.UserID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.TasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: virtualmachine.TasksTable,
|
|
Columns: virtualmachine.TasksPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
createE := &TaskVirtualMachineCreate{config: _c.config, mutation: newTaskVirtualMachineMutation(_c.config, OpCreate)}
|
|
createE.defaults()
|
|
_, specE := createE.createSpec()
|
|
edge.Target.Fields = specE.Fields
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.TaskVmsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: virtualmachine.TaskVmsTable,
|
|
Columns: []string{virtualmachine.TaskVmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskvirtualmachine.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.VirtualMachine.Create().
|
|
// SetDeletedAt(v).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.VirtualMachineUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *VirtualMachineCreate) OnConflict(opts ...sql.ConflictOption) *VirtualMachineUpsertOne {
|
|
_c.conflict = opts
|
|
return &VirtualMachineUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.VirtualMachine.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *VirtualMachineCreate) OnConflictColumns(columns ...string) *VirtualMachineUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &VirtualMachineUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// VirtualMachineUpsertOne is the builder for "upsert"-ing
|
|
// one VirtualMachine node.
|
|
VirtualMachineUpsertOne struct {
|
|
create *VirtualMachineCreate
|
|
}
|
|
|
|
// VirtualMachineUpsert is the "OnConflict" setter.
|
|
VirtualMachineUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *VirtualMachineUpsert) SetDeletedAt(v time.Time) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldDeletedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateDeletedAt() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *VirtualMachineUpsert) ClearDeletedAt() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// SetHostID sets the "host_id" field.
|
|
func (u *VirtualMachineUpsert) SetHostID(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldHostID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateHostID sets the "host_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateHostID() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldHostID)
|
|
return u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *VirtualMachineUpsert) SetUserID(v uuid.UUID) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldUserID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateUserID() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldUserID)
|
|
return u
|
|
}
|
|
|
|
// ClearUserID clears the value of the "user_id" field.
|
|
func (u *VirtualMachineUpsert) ClearUserID() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldUserID)
|
|
return u
|
|
}
|
|
|
|
// SetModelID sets the "model_id" field.
|
|
func (u *VirtualMachineUpsert) SetModelID(v uuid.UUID) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldModelID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateModelID sets the "model_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateModelID() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldModelID)
|
|
return u
|
|
}
|
|
|
|
// ClearModelID clears the value of the "model_id" field.
|
|
func (u *VirtualMachineUpsert) ClearModelID() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldModelID)
|
|
return u
|
|
}
|
|
|
|
// SetEnvironmentID sets the "environment_id" field.
|
|
func (u *VirtualMachineUpsert) SetEnvironmentID(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldEnvironmentID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateEnvironmentID sets the "environment_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateEnvironmentID() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldEnvironmentID)
|
|
return u
|
|
}
|
|
|
|
// ClearEnvironmentID clears the value of the "environment_id" field.
|
|
func (u *VirtualMachineUpsert) ClearEnvironmentID() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldEnvironmentID)
|
|
return u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *VirtualMachineUpsert) SetName(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateName() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldName)
|
|
return u
|
|
}
|
|
|
|
// SetHostname sets the "hostname" field.
|
|
func (u *VirtualMachineUpsert) SetHostname(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldHostname, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateHostname sets the "hostname" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateHostname() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldHostname)
|
|
return u
|
|
}
|
|
|
|
// ClearHostname clears the value of the "hostname" field.
|
|
func (u *VirtualMachineUpsert) ClearHostname() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldHostname)
|
|
return u
|
|
}
|
|
|
|
// SetArch sets the "arch" field.
|
|
func (u *VirtualMachineUpsert) SetArch(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldArch, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateArch sets the "arch" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateArch() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldArch)
|
|
return u
|
|
}
|
|
|
|
// ClearArch clears the value of the "arch" field.
|
|
func (u *VirtualMachineUpsert) ClearArch() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldArch)
|
|
return u
|
|
}
|
|
|
|
// SetCores sets the "cores" field.
|
|
func (u *VirtualMachineUpsert) SetCores(v int) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldCores, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCores sets the "cores" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateCores() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldCores)
|
|
return u
|
|
}
|
|
|
|
// AddCores adds v to the "cores" field.
|
|
func (u *VirtualMachineUpsert) AddCores(v int) *VirtualMachineUpsert {
|
|
u.Add(virtualmachine.FieldCores, v)
|
|
return u
|
|
}
|
|
|
|
// ClearCores clears the value of the "cores" field.
|
|
func (u *VirtualMachineUpsert) ClearCores() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldCores)
|
|
return u
|
|
}
|
|
|
|
// SetMemory sets the "memory" field.
|
|
func (u *VirtualMachineUpsert) SetMemory(v int64) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldMemory, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateMemory sets the "memory" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateMemory() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldMemory)
|
|
return u
|
|
}
|
|
|
|
// AddMemory adds v to the "memory" field.
|
|
func (u *VirtualMachineUpsert) AddMemory(v int64) *VirtualMachineUpsert {
|
|
u.Add(virtualmachine.FieldMemory, v)
|
|
return u
|
|
}
|
|
|
|
// ClearMemory clears the value of the "memory" field.
|
|
func (u *VirtualMachineUpsert) ClearMemory() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldMemory)
|
|
return u
|
|
}
|
|
|
|
// SetOs sets the "os" field.
|
|
func (u *VirtualMachineUpsert) SetOs(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldOs, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateOs sets the "os" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateOs() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldOs)
|
|
return u
|
|
}
|
|
|
|
// ClearOs clears the value of the "os" field.
|
|
func (u *VirtualMachineUpsert) ClearOs() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldOs)
|
|
return u
|
|
}
|
|
|
|
// SetExternalIP sets the "external_ip" field.
|
|
func (u *VirtualMachineUpsert) SetExternalIP(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldExternalIP, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateExternalIP sets the "external_ip" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateExternalIP() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldExternalIP)
|
|
return u
|
|
}
|
|
|
|
// ClearExternalIP clears the value of the "external_ip" field.
|
|
func (u *VirtualMachineUpsert) ClearExternalIP() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldExternalIP)
|
|
return u
|
|
}
|
|
|
|
// SetInternalIP sets the "internal_ip" field.
|
|
func (u *VirtualMachineUpsert) SetInternalIP(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldInternalIP, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateInternalIP sets the "internal_ip" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateInternalIP() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldInternalIP)
|
|
return u
|
|
}
|
|
|
|
// ClearInternalIP clears the value of the "internal_ip" field.
|
|
func (u *VirtualMachineUpsert) ClearInternalIP() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldInternalIP)
|
|
return u
|
|
}
|
|
|
|
// SetTTLKind sets the "ttl_kind" field.
|
|
func (u *VirtualMachineUpsert) SetTTLKind(v consts.VirtualmachineTTLKind) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldTTLKind, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTTLKind sets the "ttl_kind" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateTTLKind() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldTTLKind)
|
|
return u
|
|
}
|
|
|
|
// ClearTTLKind clears the value of the "ttl_kind" field.
|
|
func (u *VirtualMachineUpsert) ClearTTLKind() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldTTLKind)
|
|
return u
|
|
}
|
|
|
|
// SetTTL sets the "ttl" field.
|
|
func (u *VirtualMachineUpsert) SetTTL(v int64) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldTTL, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTTL sets the "ttl" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateTTL() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldTTL)
|
|
return u
|
|
}
|
|
|
|
// AddTTL adds v to the "ttl" field.
|
|
func (u *VirtualMachineUpsert) AddTTL(v int64) *VirtualMachineUpsert {
|
|
u.Add(virtualmachine.FieldTTL, v)
|
|
return u
|
|
}
|
|
|
|
// ClearTTL clears the value of the "ttl" field.
|
|
func (u *VirtualMachineUpsert) ClearTTL() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldTTL)
|
|
return u
|
|
}
|
|
|
|
// SetVersion sets the "version" field.
|
|
func (u *VirtualMachineUpsert) SetVersion(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldVersion, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateVersion sets the "version" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateVersion() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldVersion)
|
|
return u
|
|
}
|
|
|
|
// ClearVersion clears the value of the "version" field.
|
|
func (u *VirtualMachineUpsert) ClearVersion() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldVersion)
|
|
return u
|
|
}
|
|
|
|
// SetMachineID sets the "machine_id" field.
|
|
func (u *VirtualMachineUpsert) SetMachineID(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldMachineID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateMachineID sets the "machine_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateMachineID() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldMachineID)
|
|
return u
|
|
}
|
|
|
|
// ClearMachineID clears the value of the "machine_id" field.
|
|
func (u *VirtualMachineUpsert) ClearMachineID() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldMachineID)
|
|
return u
|
|
}
|
|
|
|
// SetRepoURL sets the "repo_url" field.
|
|
func (u *VirtualMachineUpsert) SetRepoURL(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldRepoURL, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateRepoURL sets the "repo_url" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateRepoURL() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldRepoURL)
|
|
return u
|
|
}
|
|
|
|
// ClearRepoURL clears the value of the "repo_url" field.
|
|
func (u *VirtualMachineUpsert) ClearRepoURL() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldRepoURL)
|
|
return u
|
|
}
|
|
|
|
// SetRepoFilename sets the "repo_filename" field.
|
|
func (u *VirtualMachineUpsert) SetRepoFilename(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldRepoFilename, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateRepoFilename sets the "repo_filename" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateRepoFilename() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldRepoFilename)
|
|
return u
|
|
}
|
|
|
|
// ClearRepoFilename clears the value of the "repo_filename" field.
|
|
func (u *VirtualMachineUpsert) ClearRepoFilename() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldRepoFilename)
|
|
return u
|
|
}
|
|
|
|
// SetBranch sets the "branch" field.
|
|
func (u *VirtualMachineUpsert) SetBranch(v string) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldBranch, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateBranch sets the "branch" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateBranch() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldBranch)
|
|
return u
|
|
}
|
|
|
|
// ClearBranch clears the value of the "branch" field.
|
|
func (u *VirtualMachineUpsert) ClearBranch() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldBranch)
|
|
return u
|
|
}
|
|
|
|
// SetIsRecycled sets the "is_recycled" field.
|
|
func (u *VirtualMachineUpsert) SetIsRecycled(v bool) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldIsRecycled, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIsRecycled sets the "is_recycled" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateIsRecycled() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldIsRecycled)
|
|
return u
|
|
}
|
|
|
|
// ClearIsRecycled clears the value of the "is_recycled" field.
|
|
func (u *VirtualMachineUpsert) ClearIsRecycled() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldIsRecycled)
|
|
return u
|
|
}
|
|
|
|
// SetConditions sets the "conditions" field.
|
|
func (u *VirtualMachineUpsert) SetConditions(v *types.VirtualMachineCondition) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldConditions, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateConditions sets the "conditions" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateConditions() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldConditions)
|
|
return u
|
|
}
|
|
|
|
// ClearConditions clears the value of the "conditions" field.
|
|
func (u *VirtualMachineUpsert) ClearConditions() *VirtualMachineUpsert {
|
|
u.SetNull(virtualmachine.FieldConditions)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *VirtualMachineUpsert) SetCreatedAt(v time.Time) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateCreatedAt() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *VirtualMachineUpsert) SetUpdatedAt(v time.Time) *VirtualMachineUpsert {
|
|
u.Set(virtualmachine.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsert) UpdateUpdatedAt() *VirtualMachineUpsert {
|
|
u.SetExcluded(virtualmachine.FieldUpdatedAt)
|
|
return u
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.VirtualMachine.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(virtualmachine.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *VirtualMachineUpsertOne) UpdateNewValues() *VirtualMachineUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
if _, exists := u.create.mutation.ID(); exists {
|
|
s.SetIgnore(virtualmachine.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.VirtualMachine.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *VirtualMachineUpsertOne) Ignore() *VirtualMachineUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
return u
|
|
}
|
|
|
|
// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
// Supported only by SQLite and PostgreSQL.
|
|
func (u *VirtualMachineUpsertOne) DoNothing() *VirtualMachineUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the VirtualMachineCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *VirtualMachineUpsertOne) Update(set func(*VirtualMachineUpsert)) *VirtualMachineUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&VirtualMachineUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *VirtualMachineUpsertOne) SetDeletedAt(v time.Time) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateDeletedAt() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *VirtualMachineUpsertOne) ClearDeletedAt() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetHostID sets the "host_id" field.
|
|
func (u *VirtualMachineUpsertOne) SetHostID(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetHostID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateHostID sets the "host_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateHostID() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateHostID()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *VirtualMachineUpsertOne) SetUserID(v uuid.UUID) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateUserID() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// ClearUserID clears the value of the "user_id" field.
|
|
func (u *VirtualMachineUpsertOne) ClearUserID() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearUserID()
|
|
})
|
|
}
|
|
|
|
// SetModelID sets the "model_id" field.
|
|
func (u *VirtualMachineUpsertOne) SetModelID(v uuid.UUID) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetModelID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateModelID sets the "model_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateModelID() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateModelID()
|
|
})
|
|
}
|
|
|
|
// ClearModelID clears the value of the "model_id" field.
|
|
func (u *VirtualMachineUpsertOne) ClearModelID() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearModelID()
|
|
})
|
|
}
|
|
|
|
// SetEnvironmentID sets the "environment_id" field.
|
|
func (u *VirtualMachineUpsertOne) SetEnvironmentID(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetEnvironmentID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnvironmentID sets the "environment_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateEnvironmentID() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateEnvironmentID()
|
|
})
|
|
}
|
|
|
|
// ClearEnvironmentID clears the value of the "environment_id" field.
|
|
func (u *VirtualMachineUpsertOne) ClearEnvironmentID() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearEnvironmentID()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *VirtualMachineUpsertOne) SetName(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateName() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetHostname sets the "hostname" field.
|
|
func (u *VirtualMachineUpsertOne) SetHostname(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetHostname(v)
|
|
})
|
|
}
|
|
|
|
// UpdateHostname sets the "hostname" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateHostname() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateHostname()
|
|
})
|
|
}
|
|
|
|
// ClearHostname clears the value of the "hostname" field.
|
|
func (u *VirtualMachineUpsertOne) ClearHostname() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearHostname()
|
|
})
|
|
}
|
|
|
|
// SetArch sets the "arch" field.
|
|
func (u *VirtualMachineUpsertOne) SetArch(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetArch(v)
|
|
})
|
|
}
|
|
|
|
// UpdateArch sets the "arch" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateArch() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateArch()
|
|
})
|
|
}
|
|
|
|
// ClearArch clears the value of the "arch" field.
|
|
func (u *VirtualMachineUpsertOne) ClearArch() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearArch()
|
|
})
|
|
}
|
|
|
|
// SetCores sets the "cores" field.
|
|
func (u *VirtualMachineUpsertOne) SetCores(v int) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetCores(v)
|
|
})
|
|
}
|
|
|
|
// AddCores adds v to the "cores" field.
|
|
func (u *VirtualMachineUpsertOne) AddCores(v int) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.AddCores(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCores sets the "cores" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateCores() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateCores()
|
|
})
|
|
}
|
|
|
|
// ClearCores clears the value of the "cores" field.
|
|
func (u *VirtualMachineUpsertOne) ClearCores() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearCores()
|
|
})
|
|
}
|
|
|
|
// SetMemory sets the "memory" field.
|
|
func (u *VirtualMachineUpsertOne) SetMemory(v int64) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetMemory(v)
|
|
})
|
|
}
|
|
|
|
// AddMemory adds v to the "memory" field.
|
|
func (u *VirtualMachineUpsertOne) AddMemory(v int64) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.AddMemory(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMemory sets the "memory" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateMemory() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateMemory()
|
|
})
|
|
}
|
|
|
|
// ClearMemory clears the value of the "memory" field.
|
|
func (u *VirtualMachineUpsertOne) ClearMemory() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearMemory()
|
|
})
|
|
}
|
|
|
|
// SetOs sets the "os" field.
|
|
func (u *VirtualMachineUpsertOne) SetOs(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetOs(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOs sets the "os" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateOs() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateOs()
|
|
})
|
|
}
|
|
|
|
// ClearOs clears the value of the "os" field.
|
|
func (u *VirtualMachineUpsertOne) ClearOs() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearOs()
|
|
})
|
|
}
|
|
|
|
// SetExternalIP sets the "external_ip" field.
|
|
func (u *VirtualMachineUpsertOne) SetExternalIP(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetExternalIP(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExternalIP sets the "external_ip" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateExternalIP() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateExternalIP()
|
|
})
|
|
}
|
|
|
|
// ClearExternalIP clears the value of the "external_ip" field.
|
|
func (u *VirtualMachineUpsertOne) ClearExternalIP() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearExternalIP()
|
|
})
|
|
}
|
|
|
|
// SetInternalIP sets the "internal_ip" field.
|
|
func (u *VirtualMachineUpsertOne) SetInternalIP(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetInternalIP(v)
|
|
})
|
|
}
|
|
|
|
// UpdateInternalIP sets the "internal_ip" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateInternalIP() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateInternalIP()
|
|
})
|
|
}
|
|
|
|
// ClearInternalIP clears the value of the "internal_ip" field.
|
|
func (u *VirtualMachineUpsertOne) ClearInternalIP() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearInternalIP()
|
|
})
|
|
}
|
|
|
|
// SetTTLKind sets the "ttl_kind" field.
|
|
func (u *VirtualMachineUpsertOne) SetTTLKind(v consts.VirtualmachineTTLKind) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetTTLKind(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTTLKind sets the "ttl_kind" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateTTLKind() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateTTLKind()
|
|
})
|
|
}
|
|
|
|
// ClearTTLKind clears the value of the "ttl_kind" field.
|
|
func (u *VirtualMachineUpsertOne) ClearTTLKind() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearTTLKind()
|
|
})
|
|
}
|
|
|
|
// SetTTL sets the "ttl" field.
|
|
func (u *VirtualMachineUpsertOne) SetTTL(v int64) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetTTL(v)
|
|
})
|
|
}
|
|
|
|
// AddTTL adds v to the "ttl" field.
|
|
func (u *VirtualMachineUpsertOne) AddTTL(v int64) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.AddTTL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTTL sets the "ttl" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateTTL() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateTTL()
|
|
})
|
|
}
|
|
|
|
// ClearTTL clears the value of the "ttl" field.
|
|
func (u *VirtualMachineUpsertOne) ClearTTL() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearTTL()
|
|
})
|
|
}
|
|
|
|
// SetVersion sets the "version" field.
|
|
func (u *VirtualMachineUpsertOne) SetVersion(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetVersion(v)
|
|
})
|
|
}
|
|
|
|
// UpdateVersion sets the "version" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateVersion() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateVersion()
|
|
})
|
|
}
|
|
|
|
// ClearVersion clears the value of the "version" field.
|
|
func (u *VirtualMachineUpsertOne) ClearVersion() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearVersion()
|
|
})
|
|
}
|
|
|
|
// SetMachineID sets the "machine_id" field.
|
|
func (u *VirtualMachineUpsertOne) SetMachineID(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetMachineID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMachineID sets the "machine_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateMachineID() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateMachineID()
|
|
})
|
|
}
|
|
|
|
// ClearMachineID clears the value of the "machine_id" field.
|
|
func (u *VirtualMachineUpsertOne) ClearMachineID() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearMachineID()
|
|
})
|
|
}
|
|
|
|
// SetRepoURL sets the "repo_url" field.
|
|
func (u *VirtualMachineUpsertOne) SetRepoURL(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetRepoURL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoURL sets the "repo_url" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateRepoURL() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateRepoURL()
|
|
})
|
|
}
|
|
|
|
// ClearRepoURL clears the value of the "repo_url" field.
|
|
func (u *VirtualMachineUpsertOne) ClearRepoURL() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearRepoURL()
|
|
})
|
|
}
|
|
|
|
// SetRepoFilename sets the "repo_filename" field.
|
|
func (u *VirtualMachineUpsertOne) SetRepoFilename(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetRepoFilename(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoFilename sets the "repo_filename" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateRepoFilename() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateRepoFilename()
|
|
})
|
|
}
|
|
|
|
// ClearRepoFilename clears the value of the "repo_filename" field.
|
|
func (u *VirtualMachineUpsertOne) ClearRepoFilename() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearRepoFilename()
|
|
})
|
|
}
|
|
|
|
// SetBranch sets the "branch" field.
|
|
func (u *VirtualMachineUpsertOne) SetBranch(v string) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetBranch(v)
|
|
})
|
|
}
|
|
|
|
// UpdateBranch sets the "branch" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateBranch() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateBranch()
|
|
})
|
|
}
|
|
|
|
// ClearBranch clears the value of the "branch" field.
|
|
func (u *VirtualMachineUpsertOne) ClearBranch() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearBranch()
|
|
})
|
|
}
|
|
|
|
// SetIsRecycled sets the "is_recycled" field.
|
|
func (u *VirtualMachineUpsertOne) SetIsRecycled(v bool) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetIsRecycled(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsRecycled sets the "is_recycled" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateIsRecycled() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateIsRecycled()
|
|
})
|
|
}
|
|
|
|
// ClearIsRecycled clears the value of the "is_recycled" field.
|
|
func (u *VirtualMachineUpsertOne) ClearIsRecycled() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearIsRecycled()
|
|
})
|
|
}
|
|
|
|
// SetConditions sets the "conditions" field.
|
|
func (u *VirtualMachineUpsertOne) SetConditions(v *types.VirtualMachineCondition) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetConditions(v)
|
|
})
|
|
}
|
|
|
|
// UpdateConditions sets the "conditions" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateConditions() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateConditions()
|
|
})
|
|
}
|
|
|
|
// ClearConditions clears the value of the "conditions" field.
|
|
func (u *VirtualMachineUpsertOne) ClearConditions() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearConditions()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *VirtualMachineUpsertOne) SetCreatedAt(v time.Time) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateCreatedAt() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *VirtualMachineUpsertOne) SetUpdatedAt(v time.Time) *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertOne) UpdateUpdatedAt() *VirtualMachineUpsertOne {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *VirtualMachineUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for VirtualMachineCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *VirtualMachineUpsertOne) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Exec executes the UPSERT query and returns the inserted/updated ID.
|
|
func (u *VirtualMachineUpsertOne) ID(ctx context.Context) (id string, err error) {
|
|
if u.create.driver.Dialect() == dialect.MySQL {
|
|
// In case of "ON CONFLICT", there is no way to get back non-numeric ID
|
|
// fields from the database since MySQL does not support the RETURNING clause.
|
|
return id, errors.New("db: VirtualMachineUpsertOne.ID is not supported by MySQL driver. Use VirtualMachineUpsertOne.Exec instead")
|
|
}
|
|
node, err := u.create.Save(ctx)
|
|
if err != nil {
|
|
return id, err
|
|
}
|
|
return node.ID, nil
|
|
}
|
|
|
|
// IDX is like ID, but panics if an error occurs.
|
|
func (u *VirtualMachineUpsertOne) IDX(ctx context.Context) string {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// VirtualMachineCreateBulk is the builder for creating many VirtualMachine entities in bulk.
|
|
type VirtualMachineCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*VirtualMachineCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the VirtualMachine entities in the database.
|
|
func (_c *VirtualMachineCreateBulk) Save(ctx context.Context) ([]*VirtualMachine, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*VirtualMachine, len(_c.builders))
|
|
mutators := make([]Mutator, len(_c.builders))
|
|
for i := range _c.builders {
|
|
func(i int, root context.Context) {
|
|
builder := _c.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*VirtualMachineMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
var err error
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
spec.OnConflict = _c.conflict
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
}
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &nodes[i].ID
|
|
mutation.done = true
|
|
return nodes[i], nil
|
|
})
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
mut = builder.hooks[i](mut)
|
|
}
|
|
mutators[i] = mut
|
|
}(i, ctx)
|
|
}
|
|
if len(mutators) > 0 {
|
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_c *VirtualMachineCreateBulk) SaveX(ctx context.Context) []*VirtualMachine {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *VirtualMachineCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *VirtualMachineCreateBulk) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.VirtualMachine.CreateBulk(builders...).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.VirtualMachineUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *VirtualMachineCreateBulk) OnConflict(opts ...sql.ConflictOption) *VirtualMachineUpsertBulk {
|
|
_c.conflict = opts
|
|
return &VirtualMachineUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.VirtualMachine.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *VirtualMachineCreateBulk) OnConflictColumns(columns ...string) *VirtualMachineUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &VirtualMachineUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// VirtualMachineUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of VirtualMachine nodes.
|
|
type VirtualMachineUpsertBulk struct {
|
|
create *VirtualMachineCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.VirtualMachine.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(virtualmachine.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *VirtualMachineUpsertBulk) UpdateNewValues() *VirtualMachineUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
for _, b := range u.create.builders {
|
|
if _, exists := b.mutation.ID(); exists {
|
|
s.SetIgnore(virtualmachine.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.VirtualMachine.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *VirtualMachineUpsertBulk) Ignore() *VirtualMachineUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
return u
|
|
}
|
|
|
|
// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
// Supported only by SQLite and PostgreSQL.
|
|
func (u *VirtualMachineUpsertBulk) DoNothing() *VirtualMachineUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the VirtualMachineCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *VirtualMachineUpsertBulk) Update(set func(*VirtualMachineUpsert)) *VirtualMachineUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&VirtualMachineUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *VirtualMachineUpsertBulk) SetDeletedAt(v time.Time) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateDeletedAt() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearDeletedAt() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetHostID sets the "host_id" field.
|
|
func (u *VirtualMachineUpsertBulk) SetHostID(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetHostID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateHostID sets the "host_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateHostID() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateHostID()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *VirtualMachineUpsertBulk) SetUserID(v uuid.UUID) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateUserID() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// ClearUserID clears the value of the "user_id" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearUserID() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearUserID()
|
|
})
|
|
}
|
|
|
|
// SetModelID sets the "model_id" field.
|
|
func (u *VirtualMachineUpsertBulk) SetModelID(v uuid.UUID) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetModelID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateModelID sets the "model_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateModelID() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateModelID()
|
|
})
|
|
}
|
|
|
|
// ClearModelID clears the value of the "model_id" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearModelID() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearModelID()
|
|
})
|
|
}
|
|
|
|
// SetEnvironmentID sets the "environment_id" field.
|
|
func (u *VirtualMachineUpsertBulk) SetEnvironmentID(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetEnvironmentID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnvironmentID sets the "environment_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateEnvironmentID() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateEnvironmentID()
|
|
})
|
|
}
|
|
|
|
// ClearEnvironmentID clears the value of the "environment_id" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearEnvironmentID() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearEnvironmentID()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *VirtualMachineUpsertBulk) SetName(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateName() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetHostname sets the "hostname" field.
|
|
func (u *VirtualMachineUpsertBulk) SetHostname(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetHostname(v)
|
|
})
|
|
}
|
|
|
|
// UpdateHostname sets the "hostname" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateHostname() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateHostname()
|
|
})
|
|
}
|
|
|
|
// ClearHostname clears the value of the "hostname" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearHostname() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearHostname()
|
|
})
|
|
}
|
|
|
|
// SetArch sets the "arch" field.
|
|
func (u *VirtualMachineUpsertBulk) SetArch(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetArch(v)
|
|
})
|
|
}
|
|
|
|
// UpdateArch sets the "arch" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateArch() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateArch()
|
|
})
|
|
}
|
|
|
|
// ClearArch clears the value of the "arch" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearArch() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearArch()
|
|
})
|
|
}
|
|
|
|
// SetCores sets the "cores" field.
|
|
func (u *VirtualMachineUpsertBulk) SetCores(v int) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetCores(v)
|
|
})
|
|
}
|
|
|
|
// AddCores adds v to the "cores" field.
|
|
func (u *VirtualMachineUpsertBulk) AddCores(v int) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.AddCores(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCores sets the "cores" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateCores() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateCores()
|
|
})
|
|
}
|
|
|
|
// ClearCores clears the value of the "cores" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearCores() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearCores()
|
|
})
|
|
}
|
|
|
|
// SetMemory sets the "memory" field.
|
|
func (u *VirtualMachineUpsertBulk) SetMemory(v int64) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetMemory(v)
|
|
})
|
|
}
|
|
|
|
// AddMemory adds v to the "memory" field.
|
|
func (u *VirtualMachineUpsertBulk) AddMemory(v int64) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.AddMemory(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMemory sets the "memory" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateMemory() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateMemory()
|
|
})
|
|
}
|
|
|
|
// ClearMemory clears the value of the "memory" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearMemory() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearMemory()
|
|
})
|
|
}
|
|
|
|
// SetOs sets the "os" field.
|
|
func (u *VirtualMachineUpsertBulk) SetOs(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetOs(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOs sets the "os" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateOs() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateOs()
|
|
})
|
|
}
|
|
|
|
// ClearOs clears the value of the "os" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearOs() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearOs()
|
|
})
|
|
}
|
|
|
|
// SetExternalIP sets the "external_ip" field.
|
|
func (u *VirtualMachineUpsertBulk) SetExternalIP(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetExternalIP(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExternalIP sets the "external_ip" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateExternalIP() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateExternalIP()
|
|
})
|
|
}
|
|
|
|
// ClearExternalIP clears the value of the "external_ip" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearExternalIP() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearExternalIP()
|
|
})
|
|
}
|
|
|
|
// SetInternalIP sets the "internal_ip" field.
|
|
func (u *VirtualMachineUpsertBulk) SetInternalIP(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetInternalIP(v)
|
|
})
|
|
}
|
|
|
|
// UpdateInternalIP sets the "internal_ip" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateInternalIP() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateInternalIP()
|
|
})
|
|
}
|
|
|
|
// ClearInternalIP clears the value of the "internal_ip" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearInternalIP() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearInternalIP()
|
|
})
|
|
}
|
|
|
|
// SetTTLKind sets the "ttl_kind" field.
|
|
func (u *VirtualMachineUpsertBulk) SetTTLKind(v consts.VirtualmachineTTLKind) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetTTLKind(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTTLKind sets the "ttl_kind" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateTTLKind() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateTTLKind()
|
|
})
|
|
}
|
|
|
|
// ClearTTLKind clears the value of the "ttl_kind" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearTTLKind() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearTTLKind()
|
|
})
|
|
}
|
|
|
|
// SetTTL sets the "ttl" field.
|
|
func (u *VirtualMachineUpsertBulk) SetTTL(v int64) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetTTL(v)
|
|
})
|
|
}
|
|
|
|
// AddTTL adds v to the "ttl" field.
|
|
func (u *VirtualMachineUpsertBulk) AddTTL(v int64) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.AddTTL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTTL sets the "ttl" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateTTL() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateTTL()
|
|
})
|
|
}
|
|
|
|
// ClearTTL clears the value of the "ttl" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearTTL() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearTTL()
|
|
})
|
|
}
|
|
|
|
// SetVersion sets the "version" field.
|
|
func (u *VirtualMachineUpsertBulk) SetVersion(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetVersion(v)
|
|
})
|
|
}
|
|
|
|
// UpdateVersion sets the "version" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateVersion() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateVersion()
|
|
})
|
|
}
|
|
|
|
// ClearVersion clears the value of the "version" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearVersion() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearVersion()
|
|
})
|
|
}
|
|
|
|
// SetMachineID sets the "machine_id" field.
|
|
func (u *VirtualMachineUpsertBulk) SetMachineID(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetMachineID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMachineID sets the "machine_id" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateMachineID() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateMachineID()
|
|
})
|
|
}
|
|
|
|
// ClearMachineID clears the value of the "machine_id" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearMachineID() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearMachineID()
|
|
})
|
|
}
|
|
|
|
// SetRepoURL sets the "repo_url" field.
|
|
func (u *VirtualMachineUpsertBulk) SetRepoURL(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetRepoURL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoURL sets the "repo_url" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateRepoURL() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateRepoURL()
|
|
})
|
|
}
|
|
|
|
// ClearRepoURL clears the value of the "repo_url" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearRepoURL() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearRepoURL()
|
|
})
|
|
}
|
|
|
|
// SetRepoFilename sets the "repo_filename" field.
|
|
func (u *VirtualMachineUpsertBulk) SetRepoFilename(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetRepoFilename(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoFilename sets the "repo_filename" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateRepoFilename() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateRepoFilename()
|
|
})
|
|
}
|
|
|
|
// ClearRepoFilename clears the value of the "repo_filename" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearRepoFilename() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearRepoFilename()
|
|
})
|
|
}
|
|
|
|
// SetBranch sets the "branch" field.
|
|
func (u *VirtualMachineUpsertBulk) SetBranch(v string) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetBranch(v)
|
|
})
|
|
}
|
|
|
|
// UpdateBranch sets the "branch" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateBranch() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateBranch()
|
|
})
|
|
}
|
|
|
|
// ClearBranch clears the value of the "branch" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearBranch() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearBranch()
|
|
})
|
|
}
|
|
|
|
// SetIsRecycled sets the "is_recycled" field.
|
|
func (u *VirtualMachineUpsertBulk) SetIsRecycled(v bool) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetIsRecycled(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsRecycled sets the "is_recycled" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateIsRecycled() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateIsRecycled()
|
|
})
|
|
}
|
|
|
|
// ClearIsRecycled clears the value of the "is_recycled" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearIsRecycled() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearIsRecycled()
|
|
})
|
|
}
|
|
|
|
// SetConditions sets the "conditions" field.
|
|
func (u *VirtualMachineUpsertBulk) SetConditions(v *types.VirtualMachineCondition) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetConditions(v)
|
|
})
|
|
}
|
|
|
|
// UpdateConditions sets the "conditions" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateConditions() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateConditions()
|
|
})
|
|
}
|
|
|
|
// ClearConditions clears the value of the "conditions" field.
|
|
func (u *VirtualMachineUpsertBulk) ClearConditions() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.ClearConditions()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *VirtualMachineUpsertBulk) SetCreatedAt(v time.Time) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateCreatedAt() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *VirtualMachineUpsertBulk) SetUpdatedAt(v time.Time) *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *VirtualMachineUpsertBulk) UpdateUpdatedAt() *VirtualMachineUpsertBulk {
|
|
return u.Update(func(s *VirtualMachineUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *VirtualMachineUpsertBulk) Exec(ctx context.Context) error {
|
|
if u.create.err != nil {
|
|
return u.create.err
|
|
}
|
|
for i, b := range u.create.builders {
|
|
if len(b.conflict) != 0 {
|
|
return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the VirtualMachineCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for VirtualMachineCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *VirtualMachineUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|