You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudreve/ent/storagepolicy_create.go

1660 lines
50 KiB

// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/cloudreve/Cloudreve/v4/ent/entity"
"github.com/cloudreve/Cloudreve/v4/ent/file"
"github.com/cloudreve/Cloudreve/v4/ent/group"
"github.com/cloudreve/Cloudreve/v4/ent/node"
"github.com/cloudreve/Cloudreve/v4/ent/storagepolicy"
"github.com/cloudreve/Cloudreve/v4/ent/user"
"github.com/cloudreve/Cloudreve/v4/inventory/types"
)
// StoragePolicyCreate is the builder for creating a StoragePolicy entity.
type StoragePolicyCreate struct {
config
mutation *StoragePolicyMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func (spc *StoragePolicyCreate) SetCreatedAt(t time.Time) *StoragePolicyCreate {
spc.mutation.SetCreatedAt(t)
return spc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableCreatedAt(t *time.Time) *StoragePolicyCreate {
if t != nil {
spc.SetCreatedAt(*t)
}
return spc
}
// SetUpdatedAt sets the "updated_at" field.
func (spc *StoragePolicyCreate) SetUpdatedAt(t time.Time) *StoragePolicyCreate {
spc.mutation.SetUpdatedAt(t)
return spc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableUpdatedAt(t *time.Time) *StoragePolicyCreate {
if t != nil {
spc.SetUpdatedAt(*t)
}
return spc
}
// SetDeletedAt sets the "deleted_at" field.
func (spc *StoragePolicyCreate) SetDeletedAt(t time.Time) *StoragePolicyCreate {
spc.mutation.SetDeletedAt(t)
return spc
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableDeletedAt(t *time.Time) *StoragePolicyCreate {
if t != nil {
spc.SetDeletedAt(*t)
}
return spc
}
// SetName sets the "name" field.
func (spc *StoragePolicyCreate) SetName(s string) *StoragePolicyCreate {
spc.mutation.SetName(s)
return spc
}
// SetType sets the "type" field.
func (spc *StoragePolicyCreate) SetType(s string) *StoragePolicyCreate {
spc.mutation.SetType(s)
return spc
}
// SetServer sets the "server" field.
func (spc *StoragePolicyCreate) SetServer(s string) *StoragePolicyCreate {
spc.mutation.SetServer(s)
return spc
}
// SetNillableServer sets the "server" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableServer(s *string) *StoragePolicyCreate {
if s != nil {
spc.SetServer(*s)
}
return spc
}
// SetBucketName sets the "bucket_name" field.
func (spc *StoragePolicyCreate) SetBucketName(s string) *StoragePolicyCreate {
spc.mutation.SetBucketName(s)
return spc
}
// SetNillableBucketName sets the "bucket_name" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableBucketName(s *string) *StoragePolicyCreate {
if s != nil {
spc.SetBucketName(*s)
}
return spc
}
// SetIsPrivate sets the "is_private" field.
func (spc *StoragePolicyCreate) SetIsPrivate(b bool) *StoragePolicyCreate {
spc.mutation.SetIsPrivate(b)
return spc
}
// SetNillableIsPrivate sets the "is_private" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableIsPrivate(b *bool) *StoragePolicyCreate {
if b != nil {
spc.SetIsPrivate(*b)
}
return spc
}
// SetAccessKey sets the "access_key" field.
func (spc *StoragePolicyCreate) SetAccessKey(s string) *StoragePolicyCreate {
spc.mutation.SetAccessKey(s)
return spc
}
// SetNillableAccessKey sets the "access_key" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableAccessKey(s *string) *StoragePolicyCreate {
if s != nil {
spc.SetAccessKey(*s)
}
return spc
}
// SetSecretKey sets the "secret_key" field.
func (spc *StoragePolicyCreate) SetSecretKey(s string) *StoragePolicyCreate {
spc.mutation.SetSecretKey(s)
return spc
}
// SetNillableSecretKey sets the "secret_key" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableSecretKey(s *string) *StoragePolicyCreate {
if s != nil {
spc.SetSecretKey(*s)
}
return spc
}
// SetMaxSize sets the "max_size" field.
func (spc *StoragePolicyCreate) SetMaxSize(i int64) *StoragePolicyCreate {
spc.mutation.SetMaxSize(i)
return spc
}
// SetNillableMaxSize sets the "max_size" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableMaxSize(i *int64) *StoragePolicyCreate {
if i != nil {
spc.SetMaxSize(*i)
}
return spc
}
// SetDirNameRule sets the "dir_name_rule" field.
func (spc *StoragePolicyCreate) SetDirNameRule(s string) *StoragePolicyCreate {
spc.mutation.SetDirNameRule(s)
return spc
}
// SetNillableDirNameRule sets the "dir_name_rule" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableDirNameRule(s *string) *StoragePolicyCreate {
if s != nil {
spc.SetDirNameRule(*s)
}
return spc
}
// SetFileNameRule sets the "file_name_rule" field.
func (spc *StoragePolicyCreate) SetFileNameRule(s string) *StoragePolicyCreate {
spc.mutation.SetFileNameRule(s)
return spc
}
// SetNillableFileNameRule sets the "file_name_rule" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableFileNameRule(s *string) *StoragePolicyCreate {
if s != nil {
spc.SetFileNameRule(*s)
}
return spc
}
// SetSettings sets the "settings" field.
func (spc *StoragePolicyCreate) SetSettings(ts *types.PolicySetting) *StoragePolicyCreate {
spc.mutation.SetSettings(ts)
return spc
}
// SetNodeID sets the "node_id" field.
func (spc *StoragePolicyCreate) SetNodeID(i int) *StoragePolicyCreate {
spc.mutation.SetNodeID(i)
return spc
}
// SetNillableNodeID sets the "node_id" field if the given value is not nil.
func (spc *StoragePolicyCreate) SetNillableNodeID(i *int) *StoragePolicyCreate {
if i != nil {
spc.SetNodeID(*i)
}
return spc
}
// AddUserIDs adds the "users" edge to the User entity by IDs.
func (spc *StoragePolicyCreate) AddUserIDs(ids ...int) *StoragePolicyCreate {
spc.mutation.AddUserIDs(ids...)
return spc
}
// AddUsers adds the "users" edges to the User entity.
func (spc *StoragePolicyCreate) AddUsers(u ...*User) *StoragePolicyCreate {
ids := make([]int, len(u))
for i := range u {
ids[i] = u[i].ID
}
return spc.AddUserIDs(ids...)
}
// AddGroupIDs adds the "groups" edge to the Group entity by IDs.
func (spc *StoragePolicyCreate) AddGroupIDs(ids ...int) *StoragePolicyCreate {
spc.mutation.AddGroupIDs(ids...)
return spc
}
// AddGroups adds the "groups" edges to the Group entity.
func (spc *StoragePolicyCreate) AddGroups(g ...*Group) *StoragePolicyCreate {
ids := make([]int, len(g))
for i := range g {
ids[i] = g[i].ID
}
return spc.AddGroupIDs(ids...)
}
// AddFileIDs adds the "files" edge to the File entity by IDs.
func (spc *StoragePolicyCreate) AddFileIDs(ids ...int) *StoragePolicyCreate {
spc.mutation.AddFileIDs(ids...)
return spc
}
// AddFiles adds the "files" edges to the File entity.
func (spc *StoragePolicyCreate) AddFiles(f ...*File) *StoragePolicyCreate {
ids := make([]int, len(f))
for i := range f {
ids[i] = f[i].ID
}
return spc.AddFileIDs(ids...)
}
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (spc *StoragePolicyCreate) AddEntityIDs(ids ...int) *StoragePolicyCreate {
spc.mutation.AddEntityIDs(ids...)
return spc
}
// AddEntities adds the "entities" edges to the Entity entity.
func (spc *StoragePolicyCreate) AddEntities(e ...*Entity) *StoragePolicyCreate {
ids := make([]int, len(e))
for i := range e {
ids[i] = e[i].ID
}
return spc.AddEntityIDs(ids...)
}
// SetNode sets the "node" edge to the Node entity.
func (spc *StoragePolicyCreate) SetNode(n *Node) *StoragePolicyCreate {
return spc.SetNodeID(n.ID)
}
// Mutation returns the StoragePolicyMutation object of the builder.
func (spc *StoragePolicyCreate) Mutation() *StoragePolicyMutation {
return spc.mutation
}
// Save creates the StoragePolicy in the database.
func (spc *StoragePolicyCreate) Save(ctx context.Context) (*StoragePolicy, error) {
if err := spc.defaults(); err != nil {
return nil, err
}
return withHooks(ctx, spc.sqlSave, spc.mutation, spc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (spc *StoragePolicyCreate) SaveX(ctx context.Context) *StoragePolicy {
v, err := spc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (spc *StoragePolicyCreate) Exec(ctx context.Context) error {
_, err := spc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (spc *StoragePolicyCreate) ExecX(ctx context.Context) {
if err := spc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (spc *StoragePolicyCreate) defaults() error {
if _, ok := spc.mutation.CreatedAt(); !ok {
if storagepolicy.DefaultCreatedAt == nil {
return fmt.Errorf("ent: uninitialized storagepolicy.DefaultCreatedAt (forgotten import ent/runtime?)")
}
v := storagepolicy.DefaultCreatedAt()
spc.mutation.SetCreatedAt(v)
}
if _, ok := spc.mutation.UpdatedAt(); !ok {
if storagepolicy.DefaultUpdatedAt == nil {
return fmt.Errorf("ent: uninitialized storagepolicy.DefaultUpdatedAt (forgotten import ent/runtime?)")
}
v := storagepolicy.DefaultUpdatedAt()
spc.mutation.SetUpdatedAt(v)
}
if _, ok := spc.mutation.Settings(); !ok {
v := storagepolicy.DefaultSettings
spc.mutation.SetSettings(v)
}
return nil
}
// check runs all checks and user-defined validators on the builder.
func (spc *StoragePolicyCreate) check() error {
if _, ok := spc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "StoragePolicy.created_at"`)}
}
if _, ok := spc.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "StoragePolicy.updated_at"`)}
}
if _, ok := spc.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "StoragePolicy.name"`)}
}
if _, ok := spc.mutation.GetType(); !ok {
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "StoragePolicy.type"`)}
}
return nil
}
func (spc *StoragePolicyCreate) sqlSave(ctx context.Context) (*StoragePolicy, error) {
if err := spc.check(); err != nil {
return nil, err
}
_node, _spec := spc.createSpec()
if err := sqlgraph.CreateNode(ctx, spc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
spc.mutation.id = &_node.ID
spc.mutation.done = true
return _node, nil
}
func (spc *StoragePolicyCreate) createSpec() (*StoragePolicy, *sqlgraph.CreateSpec) {
var (
_node = &StoragePolicy{config: spc.config}
_spec = sqlgraph.NewCreateSpec(storagepolicy.Table, sqlgraph.NewFieldSpec(storagepolicy.FieldID, field.TypeInt))
)
if id, ok := spc.mutation.ID(); ok {
_node.ID = id
id64 := int64(id)
_spec.ID.Value = id64
}
_spec.OnConflict = spc.conflict
if value, ok := spc.mutation.CreatedAt(); ok {
_spec.SetField(storagepolicy.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := spc.mutation.UpdatedAt(); ok {
_spec.SetField(storagepolicy.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := spc.mutation.DeletedAt(); ok {
_spec.SetField(storagepolicy.FieldDeletedAt, field.TypeTime, value)
_node.DeletedAt = &value
}
if value, ok := spc.mutation.Name(); ok {
_spec.SetField(storagepolicy.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := spc.mutation.GetType(); ok {
_spec.SetField(storagepolicy.FieldType, field.TypeString, value)
_node.Type = value
}
if value, ok := spc.mutation.Server(); ok {
_spec.SetField(storagepolicy.FieldServer, field.TypeString, value)
_node.Server = value
}
if value, ok := spc.mutation.BucketName(); ok {
_spec.SetField(storagepolicy.FieldBucketName, field.TypeString, value)
_node.BucketName = value
}
if value, ok := spc.mutation.IsPrivate(); ok {
_spec.SetField(storagepolicy.FieldIsPrivate, field.TypeBool, value)
_node.IsPrivate = value
}
if value, ok := spc.mutation.AccessKey(); ok {
_spec.SetField(storagepolicy.FieldAccessKey, field.TypeString, value)
_node.AccessKey = value
}
if value, ok := spc.mutation.SecretKey(); ok {
_spec.SetField(storagepolicy.FieldSecretKey, field.TypeString, value)
_node.SecretKey = value
}
if value, ok := spc.mutation.MaxSize(); ok {
_spec.SetField(storagepolicy.FieldMaxSize, field.TypeInt64, value)
_node.MaxSize = value
}
if value, ok := spc.mutation.DirNameRule(); ok {
_spec.SetField(storagepolicy.FieldDirNameRule, field.TypeString, value)
_node.DirNameRule = value
}
if value, ok := spc.mutation.FileNameRule(); ok {
_spec.SetField(storagepolicy.FieldFileNameRule, field.TypeString, value)
_node.FileNameRule = value
}
if value, ok := spc.mutation.Settings(); ok {
_spec.SetField(storagepolicy.FieldSettings, field.TypeJSON, value)
_node.Settings = value
}
if nodes := spc.mutation.UsersIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: storagepolicy.UsersTable,
Columns: []string{storagepolicy.UsersColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := spc.mutation.GroupsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: storagepolicy.GroupsTable,
Columns: []string{storagepolicy.GroupsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := spc.mutation.FilesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: storagepolicy.FilesTable,
Columns: []string{storagepolicy.FilesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(file.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := spc.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: storagepolicy.EntitiesTable,
Columns: []string{storagepolicy.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := spc.mutation.NodeIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: storagepolicy.NodeTable,
Columns: []string{storagepolicy.NodeColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(node.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.NodeID = nodes[0]
_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.StoragePolicy.Create().
// SetCreatedAt(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.StoragePolicyUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (spc *StoragePolicyCreate) OnConflict(opts ...sql.ConflictOption) *StoragePolicyUpsertOne {
spc.conflict = opts
return &StoragePolicyUpsertOne{
create: spc,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.StoragePolicy.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (spc *StoragePolicyCreate) OnConflictColumns(columns ...string) *StoragePolicyUpsertOne {
spc.conflict = append(spc.conflict, sql.ConflictColumns(columns...))
return &StoragePolicyUpsertOne{
create: spc,
}
}
type (
// StoragePolicyUpsertOne is the builder for "upsert"-ing
// one StoragePolicy node.
StoragePolicyUpsertOne struct {
create *StoragePolicyCreate
}
// StoragePolicyUpsert is the "OnConflict" setter.
StoragePolicyUpsert struct {
*sql.UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func (u *StoragePolicyUpsert) SetUpdatedAt(v time.Time) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateUpdatedAt() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldUpdatedAt)
return u
}
// SetDeletedAt sets the "deleted_at" field.
func (u *StoragePolicyUpsert) SetDeletedAt(v time.Time) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldDeletedAt, v)
return u
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateDeletedAt() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldDeletedAt)
return u
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *StoragePolicyUpsert) ClearDeletedAt() *StoragePolicyUpsert {
u.SetNull(storagepolicy.FieldDeletedAt)
return u
}
// SetName sets the "name" field.
func (u *StoragePolicyUpsert) SetName(v string) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldName, v)
return u
}
// UpdateName sets the "name" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateName() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldName)
return u
}
// SetType sets the "type" field.
func (u *StoragePolicyUpsert) SetType(v string) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldType, v)
return u
}
// UpdateType sets the "type" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateType() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldType)
return u
}
// SetServer sets the "server" field.
func (u *StoragePolicyUpsert) SetServer(v string) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldServer, v)
return u
}
// UpdateServer sets the "server" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateServer() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldServer)
return u
}
// ClearServer clears the value of the "server" field.
func (u *StoragePolicyUpsert) ClearServer() *StoragePolicyUpsert {
u.SetNull(storagepolicy.FieldServer)
return u
}
// SetBucketName sets the "bucket_name" field.
func (u *StoragePolicyUpsert) SetBucketName(v string) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldBucketName, v)
return u
}
// UpdateBucketName sets the "bucket_name" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateBucketName() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldBucketName)
return u
}
// ClearBucketName clears the value of the "bucket_name" field.
func (u *StoragePolicyUpsert) ClearBucketName() *StoragePolicyUpsert {
u.SetNull(storagepolicy.FieldBucketName)
return u
}
// SetIsPrivate sets the "is_private" field.
func (u *StoragePolicyUpsert) SetIsPrivate(v bool) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldIsPrivate, v)
return u
}
// UpdateIsPrivate sets the "is_private" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateIsPrivate() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldIsPrivate)
return u
}
// ClearIsPrivate clears the value of the "is_private" field.
func (u *StoragePolicyUpsert) ClearIsPrivate() *StoragePolicyUpsert {
u.SetNull(storagepolicy.FieldIsPrivate)
return u
}
// SetAccessKey sets the "access_key" field.
func (u *StoragePolicyUpsert) SetAccessKey(v string) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldAccessKey, v)
return u
}
// UpdateAccessKey sets the "access_key" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateAccessKey() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldAccessKey)
return u
}
// ClearAccessKey clears the value of the "access_key" field.
func (u *StoragePolicyUpsert) ClearAccessKey() *StoragePolicyUpsert {
u.SetNull(storagepolicy.FieldAccessKey)
return u
}
// SetSecretKey sets the "secret_key" field.
func (u *StoragePolicyUpsert) SetSecretKey(v string) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldSecretKey, v)
return u
}
// UpdateSecretKey sets the "secret_key" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateSecretKey() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldSecretKey)
return u
}
// ClearSecretKey clears the value of the "secret_key" field.
func (u *StoragePolicyUpsert) ClearSecretKey() *StoragePolicyUpsert {
u.SetNull(storagepolicy.FieldSecretKey)
return u
}
// SetMaxSize sets the "max_size" field.
func (u *StoragePolicyUpsert) SetMaxSize(v int64) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldMaxSize, v)
return u
}
// UpdateMaxSize sets the "max_size" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateMaxSize() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldMaxSize)
return u
}
// AddMaxSize adds v to the "max_size" field.
func (u *StoragePolicyUpsert) AddMaxSize(v int64) *StoragePolicyUpsert {
u.Add(storagepolicy.FieldMaxSize, v)
return u
}
// ClearMaxSize clears the value of the "max_size" field.
func (u *StoragePolicyUpsert) ClearMaxSize() *StoragePolicyUpsert {
u.SetNull(storagepolicy.FieldMaxSize)
return u
}
// SetDirNameRule sets the "dir_name_rule" field.
func (u *StoragePolicyUpsert) SetDirNameRule(v string) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldDirNameRule, v)
return u
}
// UpdateDirNameRule sets the "dir_name_rule" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateDirNameRule() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldDirNameRule)
return u
}
// ClearDirNameRule clears the value of the "dir_name_rule" field.
func (u *StoragePolicyUpsert) ClearDirNameRule() *StoragePolicyUpsert {
u.SetNull(storagepolicy.FieldDirNameRule)
return u
}
// SetFileNameRule sets the "file_name_rule" field.
func (u *StoragePolicyUpsert) SetFileNameRule(v string) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldFileNameRule, v)
return u
}
// UpdateFileNameRule sets the "file_name_rule" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateFileNameRule() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldFileNameRule)
return u
}
// ClearFileNameRule clears the value of the "file_name_rule" field.
func (u *StoragePolicyUpsert) ClearFileNameRule() *StoragePolicyUpsert {
u.SetNull(storagepolicy.FieldFileNameRule)
return u
}
// SetSettings sets the "settings" field.
func (u *StoragePolicyUpsert) SetSettings(v *types.PolicySetting) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldSettings, v)
return u
}
// UpdateSettings sets the "settings" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateSettings() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldSettings)
return u
}
// ClearSettings clears the value of the "settings" field.
func (u *StoragePolicyUpsert) ClearSettings() *StoragePolicyUpsert {
u.SetNull(storagepolicy.FieldSettings)
return u
}
// SetNodeID sets the "node_id" field.
func (u *StoragePolicyUpsert) SetNodeID(v int) *StoragePolicyUpsert {
u.Set(storagepolicy.FieldNodeID, v)
return u
}
// UpdateNodeID sets the "node_id" field to the value that was provided on create.
func (u *StoragePolicyUpsert) UpdateNodeID() *StoragePolicyUpsert {
u.SetExcluded(storagepolicy.FieldNodeID)
return u
}
// ClearNodeID clears the value of the "node_id" field.
func (u *StoragePolicyUpsert) ClearNodeID() *StoragePolicyUpsert {
u.SetNull(storagepolicy.FieldNodeID)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.StoragePolicy.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *StoragePolicyUpsertOne) UpdateNewValues() *StoragePolicyUpsertOne {
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.CreatedAt(); exists {
s.SetIgnore(storagepolicy.FieldCreatedAt)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.StoragePolicy.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *StoragePolicyUpsertOne) Ignore() *StoragePolicyUpsertOne {
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 *StoragePolicyUpsertOne) DoNothing() *StoragePolicyUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the StoragePolicyCreate.OnConflict
// documentation for more info.
func (u *StoragePolicyUpsertOne) Update(set func(*StoragePolicyUpsert)) *StoragePolicyUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&StoragePolicyUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *StoragePolicyUpsertOne) SetUpdatedAt(v time.Time) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateUpdatedAt() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateUpdatedAt()
})
}
// SetDeletedAt sets the "deleted_at" field.
func (u *StoragePolicyUpsertOne) SetDeletedAt(v time.Time) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetDeletedAt(v)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateDeletedAt() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateDeletedAt()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *StoragePolicyUpsertOne) ClearDeletedAt() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearDeletedAt()
})
}
// SetName sets the "name" field.
func (u *StoragePolicyUpsertOne) SetName(v string) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetName(v)
})
}
// UpdateName sets the "name" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateName() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateName()
})
}
// SetType sets the "type" field.
func (u *StoragePolicyUpsertOne) SetType(v string) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetType(v)
})
}
// UpdateType sets the "type" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateType() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateType()
})
}
// SetServer sets the "server" field.
func (u *StoragePolicyUpsertOne) SetServer(v string) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetServer(v)
})
}
// UpdateServer sets the "server" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateServer() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateServer()
})
}
// ClearServer clears the value of the "server" field.
func (u *StoragePolicyUpsertOne) ClearServer() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearServer()
})
}
// SetBucketName sets the "bucket_name" field.
func (u *StoragePolicyUpsertOne) SetBucketName(v string) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetBucketName(v)
})
}
// UpdateBucketName sets the "bucket_name" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateBucketName() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateBucketName()
})
}
// ClearBucketName clears the value of the "bucket_name" field.
func (u *StoragePolicyUpsertOne) ClearBucketName() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearBucketName()
})
}
// SetIsPrivate sets the "is_private" field.
func (u *StoragePolicyUpsertOne) SetIsPrivate(v bool) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetIsPrivate(v)
})
}
// UpdateIsPrivate sets the "is_private" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateIsPrivate() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateIsPrivate()
})
}
// ClearIsPrivate clears the value of the "is_private" field.
func (u *StoragePolicyUpsertOne) ClearIsPrivate() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearIsPrivate()
})
}
// SetAccessKey sets the "access_key" field.
func (u *StoragePolicyUpsertOne) SetAccessKey(v string) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetAccessKey(v)
})
}
// UpdateAccessKey sets the "access_key" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateAccessKey() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateAccessKey()
})
}
// ClearAccessKey clears the value of the "access_key" field.
func (u *StoragePolicyUpsertOne) ClearAccessKey() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearAccessKey()
})
}
// SetSecretKey sets the "secret_key" field.
func (u *StoragePolicyUpsertOne) SetSecretKey(v string) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetSecretKey(v)
})
}
// UpdateSecretKey sets the "secret_key" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateSecretKey() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateSecretKey()
})
}
// ClearSecretKey clears the value of the "secret_key" field.
func (u *StoragePolicyUpsertOne) ClearSecretKey() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearSecretKey()
})
}
// SetMaxSize sets the "max_size" field.
func (u *StoragePolicyUpsertOne) SetMaxSize(v int64) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetMaxSize(v)
})
}
// AddMaxSize adds v to the "max_size" field.
func (u *StoragePolicyUpsertOne) AddMaxSize(v int64) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.AddMaxSize(v)
})
}
// UpdateMaxSize sets the "max_size" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateMaxSize() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateMaxSize()
})
}
// ClearMaxSize clears the value of the "max_size" field.
func (u *StoragePolicyUpsertOne) ClearMaxSize() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearMaxSize()
})
}
// SetDirNameRule sets the "dir_name_rule" field.
func (u *StoragePolicyUpsertOne) SetDirNameRule(v string) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetDirNameRule(v)
})
}
// UpdateDirNameRule sets the "dir_name_rule" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateDirNameRule() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateDirNameRule()
})
}
// ClearDirNameRule clears the value of the "dir_name_rule" field.
func (u *StoragePolicyUpsertOne) ClearDirNameRule() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearDirNameRule()
})
}
// SetFileNameRule sets the "file_name_rule" field.
func (u *StoragePolicyUpsertOne) SetFileNameRule(v string) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetFileNameRule(v)
})
}
// UpdateFileNameRule sets the "file_name_rule" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateFileNameRule() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateFileNameRule()
})
}
// ClearFileNameRule clears the value of the "file_name_rule" field.
func (u *StoragePolicyUpsertOne) ClearFileNameRule() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearFileNameRule()
})
}
// SetSettings sets the "settings" field.
func (u *StoragePolicyUpsertOne) SetSettings(v *types.PolicySetting) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetSettings(v)
})
}
// UpdateSettings sets the "settings" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateSettings() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateSettings()
})
}
// ClearSettings clears the value of the "settings" field.
func (u *StoragePolicyUpsertOne) ClearSettings() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearSettings()
})
}
// SetNodeID sets the "node_id" field.
func (u *StoragePolicyUpsertOne) SetNodeID(v int) *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetNodeID(v)
})
}
// UpdateNodeID sets the "node_id" field to the value that was provided on create.
func (u *StoragePolicyUpsertOne) UpdateNodeID() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateNodeID()
})
}
// ClearNodeID clears the value of the "node_id" field.
func (u *StoragePolicyUpsertOne) ClearNodeID() *StoragePolicyUpsertOne {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearNodeID()
})
}
// Exec executes the query.
func (u *StoragePolicyUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for StoragePolicyCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *StoragePolicyUpsertOne) 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 *StoragePolicyUpsertOne) ID(ctx context.Context) (id int, err error) {
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 *StoragePolicyUpsertOne) IDX(ctx context.Context) int {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
func (m *StoragePolicyCreate) SetRawID(t int) *StoragePolicyCreate {
m.mutation.SetRawID(t)
return m
}
// StoragePolicyCreateBulk is the builder for creating many StoragePolicy entities in bulk.
type StoragePolicyCreateBulk struct {
config
err error
builders []*StoragePolicyCreate
conflict []sql.ConflictOption
}
// Save creates the StoragePolicy entities in the database.
func (spcb *StoragePolicyCreateBulk) Save(ctx context.Context) ([]*StoragePolicy, error) {
if spcb.err != nil {
return nil, spcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(spcb.builders))
nodes := make([]*StoragePolicy, len(spcb.builders))
mutators := make([]Mutator, len(spcb.builders))
for i := range spcb.builders {
func(i int, root context.Context) {
builder := spcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*StoragePolicyMutation)
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, spcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = spcb.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, spcb.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
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(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, spcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (spcb *StoragePolicyCreateBulk) SaveX(ctx context.Context) []*StoragePolicy {
v, err := spcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (spcb *StoragePolicyCreateBulk) Exec(ctx context.Context) error {
_, err := spcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (spcb *StoragePolicyCreateBulk) ExecX(ctx context.Context) {
if err := spcb.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.StoragePolicy.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.StoragePolicyUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (spcb *StoragePolicyCreateBulk) OnConflict(opts ...sql.ConflictOption) *StoragePolicyUpsertBulk {
spcb.conflict = opts
return &StoragePolicyUpsertBulk{
create: spcb,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.StoragePolicy.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (spcb *StoragePolicyCreateBulk) OnConflictColumns(columns ...string) *StoragePolicyUpsertBulk {
spcb.conflict = append(spcb.conflict, sql.ConflictColumns(columns...))
return &StoragePolicyUpsertBulk{
create: spcb,
}
}
// StoragePolicyUpsertBulk is the builder for "upsert"-ing
// a bulk of StoragePolicy nodes.
type StoragePolicyUpsertBulk struct {
create *StoragePolicyCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.StoragePolicy.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *StoragePolicyUpsertBulk) UpdateNewValues() *StoragePolicyUpsertBulk {
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.CreatedAt(); exists {
s.SetIgnore(storagepolicy.FieldCreatedAt)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.StoragePolicy.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *StoragePolicyUpsertBulk) Ignore() *StoragePolicyUpsertBulk {
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 *StoragePolicyUpsertBulk) DoNothing() *StoragePolicyUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the StoragePolicyCreateBulk.OnConflict
// documentation for more info.
func (u *StoragePolicyUpsertBulk) Update(set func(*StoragePolicyUpsert)) *StoragePolicyUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&StoragePolicyUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *StoragePolicyUpsertBulk) SetUpdatedAt(v time.Time) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateUpdatedAt() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateUpdatedAt()
})
}
// SetDeletedAt sets the "deleted_at" field.
func (u *StoragePolicyUpsertBulk) SetDeletedAt(v time.Time) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetDeletedAt(v)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateDeletedAt() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateDeletedAt()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *StoragePolicyUpsertBulk) ClearDeletedAt() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearDeletedAt()
})
}
// SetName sets the "name" field.
func (u *StoragePolicyUpsertBulk) SetName(v string) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetName(v)
})
}
// UpdateName sets the "name" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateName() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateName()
})
}
// SetType sets the "type" field.
func (u *StoragePolicyUpsertBulk) SetType(v string) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetType(v)
})
}
// UpdateType sets the "type" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateType() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateType()
})
}
// SetServer sets the "server" field.
func (u *StoragePolicyUpsertBulk) SetServer(v string) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetServer(v)
})
}
// UpdateServer sets the "server" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateServer() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateServer()
})
}
// ClearServer clears the value of the "server" field.
func (u *StoragePolicyUpsertBulk) ClearServer() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearServer()
})
}
// SetBucketName sets the "bucket_name" field.
func (u *StoragePolicyUpsertBulk) SetBucketName(v string) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetBucketName(v)
})
}
// UpdateBucketName sets the "bucket_name" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateBucketName() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateBucketName()
})
}
// ClearBucketName clears the value of the "bucket_name" field.
func (u *StoragePolicyUpsertBulk) ClearBucketName() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearBucketName()
})
}
// SetIsPrivate sets the "is_private" field.
func (u *StoragePolicyUpsertBulk) SetIsPrivate(v bool) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetIsPrivate(v)
})
}
// UpdateIsPrivate sets the "is_private" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateIsPrivate() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateIsPrivate()
})
}
// ClearIsPrivate clears the value of the "is_private" field.
func (u *StoragePolicyUpsertBulk) ClearIsPrivate() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearIsPrivate()
})
}
// SetAccessKey sets the "access_key" field.
func (u *StoragePolicyUpsertBulk) SetAccessKey(v string) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetAccessKey(v)
})
}
// UpdateAccessKey sets the "access_key" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateAccessKey() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateAccessKey()
})
}
// ClearAccessKey clears the value of the "access_key" field.
func (u *StoragePolicyUpsertBulk) ClearAccessKey() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearAccessKey()
})
}
// SetSecretKey sets the "secret_key" field.
func (u *StoragePolicyUpsertBulk) SetSecretKey(v string) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetSecretKey(v)
})
}
// UpdateSecretKey sets the "secret_key" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateSecretKey() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateSecretKey()
})
}
// ClearSecretKey clears the value of the "secret_key" field.
func (u *StoragePolicyUpsertBulk) ClearSecretKey() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearSecretKey()
})
}
// SetMaxSize sets the "max_size" field.
func (u *StoragePolicyUpsertBulk) SetMaxSize(v int64) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetMaxSize(v)
})
}
// AddMaxSize adds v to the "max_size" field.
func (u *StoragePolicyUpsertBulk) AddMaxSize(v int64) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.AddMaxSize(v)
})
}
// UpdateMaxSize sets the "max_size" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateMaxSize() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateMaxSize()
})
}
// ClearMaxSize clears the value of the "max_size" field.
func (u *StoragePolicyUpsertBulk) ClearMaxSize() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearMaxSize()
})
}
// SetDirNameRule sets the "dir_name_rule" field.
func (u *StoragePolicyUpsertBulk) SetDirNameRule(v string) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetDirNameRule(v)
})
}
// UpdateDirNameRule sets the "dir_name_rule" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateDirNameRule() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateDirNameRule()
})
}
// ClearDirNameRule clears the value of the "dir_name_rule" field.
func (u *StoragePolicyUpsertBulk) ClearDirNameRule() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearDirNameRule()
})
}
// SetFileNameRule sets the "file_name_rule" field.
func (u *StoragePolicyUpsertBulk) SetFileNameRule(v string) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetFileNameRule(v)
})
}
// UpdateFileNameRule sets the "file_name_rule" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateFileNameRule() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateFileNameRule()
})
}
// ClearFileNameRule clears the value of the "file_name_rule" field.
func (u *StoragePolicyUpsertBulk) ClearFileNameRule() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearFileNameRule()
})
}
// SetSettings sets the "settings" field.
func (u *StoragePolicyUpsertBulk) SetSettings(v *types.PolicySetting) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetSettings(v)
})
}
// UpdateSettings sets the "settings" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateSettings() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateSettings()
})
}
// ClearSettings clears the value of the "settings" field.
func (u *StoragePolicyUpsertBulk) ClearSettings() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearSettings()
})
}
// SetNodeID sets the "node_id" field.
func (u *StoragePolicyUpsertBulk) SetNodeID(v int) *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.SetNodeID(v)
})
}
// UpdateNodeID sets the "node_id" field to the value that was provided on create.
func (u *StoragePolicyUpsertBulk) UpdateNodeID() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.UpdateNodeID()
})
}
// ClearNodeID clears the value of the "node_id" field.
func (u *StoragePolicyUpsertBulk) ClearNodeID() *StoragePolicyUpsertBulk {
return u.Update(func(s *StoragePolicyUpsert) {
s.ClearNodeID()
})
}
// Exec executes the query.
func (u *StoragePolicyUpsertBulk) 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("ent: OnConflict was set for builder %d. Set it on the StoragePolicyCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for StoragePolicyCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *StoragePolicyUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}