// 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/Wei-Shaw/sub2api/ent/errorpassthroughrule"
)

// ErrorPassthroughRuleCreate is the builder for creating a ErrorPassthroughRule entity.
type ErrorPassthroughRuleCreate struct {
	config
	mutation *ErrorPassthroughRuleMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetCreatedAt sets the "created_at" field.
func (_c *ErrorPassthroughRuleCreate) SetCreatedAt(v time.Time) *ErrorPassthroughRuleCreate {
	_c.mutation.SetCreatedAt(v)
	return _c
}

// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *ErrorPassthroughRuleCreate) SetNillableCreatedAt(v *time.Time) *ErrorPassthroughRuleCreate {
	if v != nil {
		_c.SetCreatedAt(*v)
	}
	return _c
}

// SetUpdatedAt sets the "updated_at" field.
func (_c *ErrorPassthroughRuleCreate) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleCreate {
	_c.mutation.SetUpdatedAt(v)
	return _c
}

// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *ErrorPassthroughRuleCreate) SetNillableUpdatedAt(v *time.Time) *ErrorPassthroughRuleCreate {
	if v != nil {
		_c.SetUpdatedAt(*v)
	}
	return _c
}

// SetName sets the "name" field.
func (_c *ErrorPassthroughRuleCreate) SetName(v string) *ErrorPassthroughRuleCreate {
	_c.mutation.SetName(v)
	return _c
}

// SetEnabled sets the "enabled" field.
func (_c *ErrorPassthroughRuleCreate) SetEnabled(v bool) *ErrorPassthroughRuleCreate {
	_c.mutation.SetEnabled(v)
	return _c
}

// SetNillableEnabled sets the "enabled" field if the given value is not nil.
func (_c *ErrorPassthroughRuleCreate) SetNillableEnabled(v *bool) *ErrorPassthroughRuleCreate {
	if v != nil {
		_c.SetEnabled(*v)
	}
	return _c
}

// SetPriority sets the "priority" field.
func (_c *ErrorPassthroughRuleCreate) SetPriority(v int) *ErrorPassthroughRuleCreate {
	_c.mutation.SetPriority(v)
	return _c
}

// SetNillablePriority sets the "priority" field if the given value is not nil.
func (_c *ErrorPassthroughRuleCreate) SetNillablePriority(v *int) *ErrorPassthroughRuleCreate {
	if v != nil {
		_c.SetPriority(*v)
	}
	return _c
}

// SetErrorCodes sets the "error_codes" field.
func (_c *ErrorPassthroughRuleCreate) SetErrorCodes(v []int) *ErrorPassthroughRuleCreate {
	_c.mutation.SetErrorCodes(v)
	return _c
}

// SetKeywords sets the "keywords" field.
func (_c *ErrorPassthroughRuleCreate) SetKeywords(v []string) *ErrorPassthroughRuleCreate {
	_c.mutation.SetKeywords(v)
	return _c
}

// SetMatchMode sets the "match_mode" field.
func (_c *ErrorPassthroughRuleCreate) SetMatchMode(v string) *ErrorPassthroughRuleCreate {
	_c.mutation.SetMatchMode(v)
	return _c
}

// SetNillableMatchMode sets the "match_mode" field if the given value is not nil.
func (_c *ErrorPassthroughRuleCreate) SetNillableMatchMode(v *string) *ErrorPassthroughRuleCreate {
	if v != nil {
		_c.SetMatchMode(*v)
	}
	return _c
}

// SetPlatforms sets the "platforms" field.
func (_c *ErrorPassthroughRuleCreate) SetPlatforms(v []string) *ErrorPassthroughRuleCreate {
	_c.mutation.SetPlatforms(v)
	return _c
}

// SetPassthroughCode sets the "passthrough_code" field.
func (_c *ErrorPassthroughRuleCreate) SetPassthroughCode(v bool) *ErrorPassthroughRuleCreate {
	_c.mutation.SetPassthroughCode(v)
	return _c
}

// SetNillablePassthroughCode sets the "passthrough_code" field if the given value is not nil.
func (_c *ErrorPassthroughRuleCreate) SetNillablePassthroughCode(v *bool) *ErrorPassthroughRuleCreate {
	if v != nil {
		_c.SetPassthroughCode(*v)
	}
	return _c
}

// SetResponseCode sets the "response_code" field.
func (_c *ErrorPassthroughRuleCreate) SetResponseCode(v int) *ErrorPassthroughRuleCreate {
	_c.mutation.SetResponseCode(v)
	return _c
}

// SetNillableResponseCode sets the "response_code" field if the given value is not nil.
func (_c *ErrorPassthroughRuleCreate) SetNillableResponseCode(v *int) *ErrorPassthroughRuleCreate {
	if v != nil {
		_c.SetResponseCode(*v)
	}
	return _c
}

// SetPassthroughBody sets the "passthrough_body" field.
func (_c *ErrorPassthroughRuleCreate) SetPassthroughBody(v bool) *ErrorPassthroughRuleCreate {
	_c.mutation.SetPassthroughBody(v)
	return _c
}

// SetNillablePassthroughBody sets the "passthrough_body" field if the given value is not nil.
func (_c *ErrorPassthroughRuleCreate) SetNillablePassthroughBody(v *bool) *ErrorPassthroughRuleCreate {
	if v != nil {
		_c.SetPassthroughBody(*v)
	}
	return _c
}

// SetCustomMessage sets the "custom_message" field.
func (_c *ErrorPassthroughRuleCreate) SetCustomMessage(v string) *ErrorPassthroughRuleCreate {
	_c.mutation.SetCustomMessage(v)
	return _c
}

// SetNillableCustomMessage sets the "custom_message" field if the given value is not nil.
func (_c *ErrorPassthroughRuleCreate) SetNillableCustomMessage(v *string) *ErrorPassthroughRuleCreate {
	if v != nil {
		_c.SetCustomMessage(*v)
	}
	return _c
}

// SetSkipMonitoring sets the "skip_monitoring" field.
func (_c *ErrorPassthroughRuleCreate) SetSkipMonitoring(v bool) *ErrorPassthroughRuleCreate {
	_c.mutation.SetSkipMonitoring(v)
	return _c
}

// SetNillableSkipMonitoring sets the "skip_monitoring" field if the given value is not nil.
func (_c *ErrorPassthroughRuleCreate) SetNillableSkipMonitoring(v *bool) *ErrorPassthroughRuleCreate {
	if v != nil {
		_c.SetSkipMonitoring(*v)
	}
	return _c
}

// SetDescription sets the "description" field.
func (_c *ErrorPassthroughRuleCreate) SetDescription(v string) *ErrorPassthroughRuleCreate {
	_c.mutation.SetDescription(v)
	return _c
}

// SetNillableDescription sets the "description" field if the given value is not nil.
func (_c *ErrorPassthroughRuleCreate) SetNillableDescription(v *string) *ErrorPassthroughRuleCreate {
	if v != nil {
		_c.SetDescription(*v)
	}
	return _c
}

// Mutation returns the ErrorPassthroughRuleMutation object of the builder.
func (_c *ErrorPassthroughRuleCreate) Mutation() *ErrorPassthroughRuleMutation {
	return _c.mutation
}

// Save creates the ErrorPassthroughRule in the database.
func (_c *ErrorPassthroughRuleCreate) Save(ctx context.Context) (*ErrorPassthroughRule, error) {
	_c.defaults()
	return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}

// SaveX calls Save and panics if Save returns an error.
func (_c *ErrorPassthroughRuleCreate) SaveX(ctx context.Context) *ErrorPassthroughRule {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (_c *ErrorPassthroughRuleCreate) Exec(ctx context.Context) error {
	_, err := _c.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (_c *ErrorPassthroughRuleCreate) 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 *ErrorPassthroughRuleCreate) defaults() {
	if _, ok := _c.mutation.CreatedAt(); !ok {
		v := errorpassthroughrule.DefaultCreatedAt()
		_c.mutation.SetCreatedAt(v)
	}
	if _, ok := _c.mutation.UpdatedAt(); !ok {
		v := errorpassthroughrule.DefaultUpdatedAt()
		_c.mutation.SetUpdatedAt(v)
	}
	if _, ok := _c.mutation.Enabled(); !ok {
		v := errorpassthroughrule.DefaultEnabled
		_c.mutation.SetEnabled(v)
	}
	if _, ok := _c.mutation.Priority(); !ok {
		v := errorpassthroughrule.DefaultPriority
		_c.mutation.SetPriority(v)
	}
	if _, ok := _c.mutation.MatchMode(); !ok {
		v := errorpassthroughrule.DefaultMatchMode
		_c.mutation.SetMatchMode(v)
	}
	if _, ok := _c.mutation.PassthroughCode(); !ok {
		v := errorpassthroughrule.DefaultPassthroughCode
		_c.mutation.SetPassthroughCode(v)
	}
	if _, ok := _c.mutation.PassthroughBody(); !ok {
		v := errorpassthroughrule.DefaultPassthroughBody
		_c.mutation.SetPassthroughBody(v)
	}
	if _, ok := _c.mutation.SkipMonitoring(); !ok {
		v := errorpassthroughrule.DefaultSkipMonitoring
		_c.mutation.SetSkipMonitoring(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (_c *ErrorPassthroughRuleCreate) check() error {
	if _, ok := _c.mutation.CreatedAt(); !ok {
		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ErrorPassthroughRule.created_at"`)}
	}
	if _, ok := _c.mutation.UpdatedAt(); !ok {
		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ErrorPassthroughRule.updated_at"`)}
	}
	if _, ok := _c.mutation.Name(); !ok {
		return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ErrorPassthroughRule.name"`)}
	}
	if v, ok := _c.mutation.Name(); ok {
		if err := errorpassthroughrule.NameValidator(v); err != nil {
			return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ErrorPassthroughRule.name": %w`, err)}
		}
	}
	if _, ok := _c.mutation.Enabled(); !ok {
		return &ValidationError{Name: "enabled", err: errors.New(`ent: missing required field "ErrorPassthroughRule.enabled"`)}
	}
	if _, ok := _c.mutation.Priority(); !ok {
		return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "ErrorPassthroughRule.priority"`)}
	}
	if _, ok := _c.mutation.MatchMode(); !ok {
		return &ValidationError{Name: "match_mode", err: errors.New(`ent: missing required field "ErrorPassthroughRule.match_mode"`)}
	}
	if v, ok := _c.mutation.MatchMode(); ok {
		if err := errorpassthroughrule.MatchModeValidator(v); err != nil {
			return &ValidationError{Name: "match_mode", err: fmt.Errorf(`ent: validator failed for field "ErrorPassthroughRule.match_mode": %w`, err)}
		}
	}
	if _, ok := _c.mutation.PassthroughCode(); !ok {
		return &ValidationError{Name: "passthrough_code", err: errors.New(`ent: missing required field "ErrorPassthroughRule.passthrough_code"`)}
	}
	if _, ok := _c.mutation.PassthroughBody(); !ok {
		return &ValidationError{Name: "passthrough_body", err: errors.New(`ent: missing required field "ErrorPassthroughRule.passthrough_body"`)}
	}
	if _, ok := _c.mutation.SkipMonitoring(); !ok {
		return &ValidationError{Name: "skip_monitoring", err: errors.New(`ent: missing required field "ErrorPassthroughRule.skip_monitoring"`)}
	}
	return nil
}

func (_c *ErrorPassthroughRuleCreate) sqlSave(ctx context.Context) (*ErrorPassthroughRule, 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
	}
	id := _spec.ID.Value.(int64)
	_node.ID = int64(id)
	_c.mutation.id = &_node.ID
	_c.mutation.done = true
	return _node, nil
}

func (_c *ErrorPassthroughRuleCreate) createSpec() (*ErrorPassthroughRule, *sqlgraph.CreateSpec) {
	var (
		_node = &ErrorPassthroughRule{config: _c.config}
		_spec = sqlgraph.NewCreateSpec(errorpassthroughrule.Table, sqlgraph.NewFieldSpec(errorpassthroughrule.FieldID, field.TypeInt64))
	)
	_spec.OnConflict = _c.conflict
	if value, ok := _c.mutation.CreatedAt(); ok {
		_spec.SetField(errorpassthroughrule.FieldCreatedAt, field.TypeTime, value)
		_node.CreatedAt = value
	}
	if value, ok := _c.mutation.UpdatedAt(); ok {
		_spec.SetField(errorpassthroughrule.FieldUpdatedAt, field.TypeTime, value)
		_node.UpdatedAt = value
	}
	if value, ok := _c.mutation.Name(); ok {
		_spec.SetField(errorpassthroughrule.FieldName, field.TypeString, value)
		_node.Name = value
	}
	if value, ok := _c.mutation.Enabled(); ok {
		_spec.SetField(errorpassthroughrule.FieldEnabled, field.TypeBool, value)
		_node.Enabled = value
	}
	if value, ok := _c.mutation.Priority(); ok {
		_spec.SetField(errorpassthroughrule.FieldPriority, field.TypeInt, value)
		_node.Priority = value
	}
	if value, ok := _c.mutation.ErrorCodes(); ok {
		_spec.SetField(errorpassthroughrule.FieldErrorCodes, field.TypeJSON, value)
		_node.ErrorCodes = value
	}
	if value, ok := _c.mutation.Keywords(); ok {
		_spec.SetField(errorpassthroughrule.FieldKeywords, field.TypeJSON, value)
		_node.Keywords = value
	}
	if value, ok := _c.mutation.MatchMode(); ok {
		_spec.SetField(errorpassthroughrule.FieldMatchMode, field.TypeString, value)
		_node.MatchMode = value
	}
	if value, ok := _c.mutation.Platforms(); ok {
		_spec.SetField(errorpassthroughrule.FieldPlatforms, field.TypeJSON, value)
		_node.Platforms = value
	}
	if value, ok := _c.mutation.PassthroughCode(); ok {
		_spec.SetField(errorpassthroughrule.FieldPassthroughCode, field.TypeBool, value)
		_node.PassthroughCode = value
	}
	if value, ok := _c.mutation.ResponseCode(); ok {
		_spec.SetField(errorpassthroughrule.FieldResponseCode, field.TypeInt, value)
		_node.ResponseCode = &value
	}
	if value, ok := _c.mutation.PassthroughBody(); ok {
		_spec.SetField(errorpassthroughrule.FieldPassthroughBody, field.TypeBool, value)
		_node.PassthroughBody = value
	}
	if value, ok := _c.mutation.CustomMessage(); ok {
		_spec.SetField(errorpassthroughrule.FieldCustomMessage, field.TypeString, value)
		_node.CustomMessage = &value
	}
	if value, ok := _c.mutation.SkipMonitoring(); ok {
		_spec.SetField(errorpassthroughrule.FieldSkipMonitoring, field.TypeBool, value)
		_node.SkipMonitoring = value
	}
	if value, ok := _c.mutation.Description(); ok {
		_spec.SetField(errorpassthroughrule.FieldDescription, field.TypeString, value)
		_node.Description = &value
	}
	return _node, _spec
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.ErrorPassthroughRule.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.ErrorPassthroughRuleUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
func (_c *ErrorPassthroughRuleCreate) OnConflict(opts ...sql.ConflictOption) *ErrorPassthroughRuleUpsertOne {
	_c.conflict = opts
	return &ErrorPassthroughRuleUpsertOne{
		create: _c,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.ErrorPassthroughRule.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (_c *ErrorPassthroughRuleCreate) OnConflictColumns(columns ...string) *ErrorPassthroughRuleUpsertOne {
	_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
	return &ErrorPassthroughRuleUpsertOne{
		create: _c,
	}
}

type (
	// ErrorPassthroughRuleUpsertOne is the builder for "upsert"-ing
	//  one ErrorPassthroughRule node.
	ErrorPassthroughRuleUpsertOne struct {
		create *ErrorPassthroughRuleCreate
	}

	// ErrorPassthroughRuleUpsert is the "OnConflict" setter.
	ErrorPassthroughRuleUpsert struct {
		*sql.UpdateSet
	}
)

// SetUpdatedAt sets the "updated_at" field.
func (u *ErrorPassthroughRuleUpsert) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldUpdatedAt, v)
	return u
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdateUpdatedAt() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldUpdatedAt)
	return u
}

// SetName sets the "name" field.
func (u *ErrorPassthroughRuleUpsert) SetName(v string) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldName, v)
	return u
}

// UpdateName sets the "name" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdateName() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldName)
	return u
}

// SetEnabled sets the "enabled" field.
func (u *ErrorPassthroughRuleUpsert) SetEnabled(v bool) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldEnabled, v)
	return u
}

// UpdateEnabled sets the "enabled" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdateEnabled() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldEnabled)
	return u
}

// SetPriority sets the "priority" field.
func (u *ErrorPassthroughRuleUpsert) SetPriority(v int) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldPriority, v)
	return u
}

// UpdatePriority sets the "priority" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdatePriority() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldPriority)
	return u
}

// AddPriority adds v to the "priority" field.
func (u *ErrorPassthroughRuleUpsert) AddPriority(v int) *ErrorPassthroughRuleUpsert {
	u.Add(errorpassthroughrule.FieldPriority, v)
	return u
}

// SetErrorCodes sets the "error_codes" field.
func (u *ErrorPassthroughRuleUpsert) SetErrorCodes(v []int) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldErrorCodes, v)
	return u
}

// UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdateErrorCodes() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldErrorCodes)
	return u
}

// ClearErrorCodes clears the value of the "error_codes" field.
func (u *ErrorPassthroughRuleUpsert) ClearErrorCodes() *ErrorPassthroughRuleUpsert {
	u.SetNull(errorpassthroughrule.FieldErrorCodes)
	return u
}

// SetKeywords sets the "keywords" field.
func (u *ErrorPassthroughRuleUpsert) SetKeywords(v []string) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldKeywords, v)
	return u
}

// UpdateKeywords sets the "keywords" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdateKeywords() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldKeywords)
	return u
}

// ClearKeywords clears the value of the "keywords" field.
func (u *ErrorPassthroughRuleUpsert) ClearKeywords() *ErrorPassthroughRuleUpsert {
	u.SetNull(errorpassthroughrule.FieldKeywords)
	return u
}

// SetMatchMode sets the "match_mode" field.
func (u *ErrorPassthroughRuleUpsert) SetMatchMode(v string) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldMatchMode, v)
	return u
}

// UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdateMatchMode() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldMatchMode)
	return u
}

// SetPlatforms sets the "platforms" field.
func (u *ErrorPassthroughRuleUpsert) SetPlatforms(v []string) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldPlatforms, v)
	return u
}

// UpdatePlatforms sets the "platforms" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdatePlatforms() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldPlatforms)
	return u
}

// ClearPlatforms clears the value of the "platforms" field.
func (u *ErrorPassthroughRuleUpsert) ClearPlatforms() *ErrorPassthroughRuleUpsert {
	u.SetNull(errorpassthroughrule.FieldPlatforms)
	return u
}

// SetPassthroughCode sets the "passthrough_code" field.
func (u *ErrorPassthroughRuleUpsert) SetPassthroughCode(v bool) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldPassthroughCode, v)
	return u
}

// UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdatePassthroughCode() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldPassthroughCode)
	return u
}

// SetResponseCode sets the "response_code" field.
func (u *ErrorPassthroughRuleUpsert) SetResponseCode(v int) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldResponseCode, v)
	return u
}

// UpdateResponseCode sets the "response_code" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdateResponseCode() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldResponseCode)
	return u
}

// AddResponseCode adds v to the "response_code" field.
func (u *ErrorPassthroughRuleUpsert) AddResponseCode(v int) *ErrorPassthroughRuleUpsert {
	u.Add(errorpassthroughrule.FieldResponseCode, v)
	return u
}

// ClearResponseCode clears the value of the "response_code" field.
func (u *ErrorPassthroughRuleUpsert) ClearResponseCode() *ErrorPassthroughRuleUpsert {
	u.SetNull(errorpassthroughrule.FieldResponseCode)
	return u
}

// SetPassthroughBody sets the "passthrough_body" field.
func (u *ErrorPassthroughRuleUpsert) SetPassthroughBody(v bool) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldPassthroughBody, v)
	return u
}

// UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdatePassthroughBody() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldPassthroughBody)
	return u
}

// SetCustomMessage sets the "custom_message" field.
func (u *ErrorPassthroughRuleUpsert) SetCustomMessage(v string) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldCustomMessage, v)
	return u
}

// UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdateCustomMessage() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldCustomMessage)
	return u
}

// ClearCustomMessage clears the value of the "custom_message" field.
func (u *ErrorPassthroughRuleUpsert) ClearCustomMessage() *ErrorPassthroughRuleUpsert {
	u.SetNull(errorpassthroughrule.FieldCustomMessage)
	return u
}

// SetSkipMonitoring sets the "skip_monitoring" field.
func (u *ErrorPassthroughRuleUpsert) SetSkipMonitoring(v bool) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldSkipMonitoring, v)
	return u
}

// UpdateSkipMonitoring sets the "skip_monitoring" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdateSkipMonitoring() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldSkipMonitoring)
	return u
}

// SetDescription sets the "description" field.
func (u *ErrorPassthroughRuleUpsert) SetDescription(v string) *ErrorPassthroughRuleUpsert {
	u.Set(errorpassthroughrule.FieldDescription, v)
	return u
}

// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsert) UpdateDescription() *ErrorPassthroughRuleUpsert {
	u.SetExcluded(errorpassthroughrule.FieldDescription)
	return u
}

// ClearDescription clears the value of the "description" field.
func (u *ErrorPassthroughRuleUpsert) ClearDescription() *ErrorPassthroughRuleUpsert {
	u.SetNull(errorpassthroughrule.FieldDescription)
	return u
}

// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
//	client.ErrorPassthroughRule.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//		).
//		Exec(ctx)
func (u *ErrorPassthroughRuleUpsertOne) UpdateNewValues() *ErrorPassthroughRuleUpsertOne {
	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(errorpassthroughrule.FieldCreatedAt)
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.ErrorPassthroughRule.Create().
//	    OnConflict(sql.ResolveWithIgnore()).
//	    Exec(ctx)
func (u *ErrorPassthroughRuleUpsertOne) Ignore() *ErrorPassthroughRuleUpsertOne {
	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 *ErrorPassthroughRuleUpsertOne) DoNothing() *ErrorPassthroughRuleUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the ErrorPassthroughRuleCreate.OnConflict
// documentation for more info.
func (u *ErrorPassthroughRuleUpsertOne) Update(set func(*ErrorPassthroughRuleUpsert)) *ErrorPassthroughRuleUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&ErrorPassthroughRuleUpsert{UpdateSet: update})
	}))
	return u
}

// SetUpdatedAt sets the "updated_at" field.
func (u *ErrorPassthroughRuleUpsertOne) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdateUpdatedAt() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateUpdatedAt()
	})
}

// SetName sets the "name" field.
func (u *ErrorPassthroughRuleUpsertOne) SetName(v string) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetName(v)
	})
}

// UpdateName sets the "name" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdateName() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateName()
	})
}

// SetEnabled sets the "enabled" field.
func (u *ErrorPassthroughRuleUpsertOne) SetEnabled(v bool) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetEnabled(v)
	})
}

// UpdateEnabled sets the "enabled" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdateEnabled() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateEnabled()
	})
}

// SetPriority sets the "priority" field.
func (u *ErrorPassthroughRuleUpsertOne) SetPriority(v int) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetPriority(v)
	})
}

// AddPriority adds v to the "priority" field.
func (u *ErrorPassthroughRuleUpsertOne) AddPriority(v int) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.AddPriority(v)
	})
}

// UpdatePriority sets the "priority" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdatePriority() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdatePriority()
	})
}

// SetErrorCodes sets the "error_codes" field.
func (u *ErrorPassthroughRuleUpsertOne) SetErrorCodes(v []int) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetErrorCodes(v)
	})
}

// UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdateErrorCodes() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateErrorCodes()
	})
}

// ClearErrorCodes clears the value of the "error_codes" field.
func (u *ErrorPassthroughRuleUpsertOne) ClearErrorCodes() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearErrorCodes()
	})
}

// SetKeywords sets the "keywords" field.
func (u *ErrorPassthroughRuleUpsertOne) SetKeywords(v []string) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetKeywords(v)
	})
}

// UpdateKeywords sets the "keywords" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdateKeywords() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateKeywords()
	})
}

// ClearKeywords clears the value of the "keywords" field.
func (u *ErrorPassthroughRuleUpsertOne) ClearKeywords() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearKeywords()
	})
}

// SetMatchMode sets the "match_mode" field.
func (u *ErrorPassthroughRuleUpsertOne) SetMatchMode(v string) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetMatchMode(v)
	})
}

// UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdateMatchMode() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateMatchMode()
	})
}

// SetPlatforms sets the "platforms" field.
func (u *ErrorPassthroughRuleUpsertOne) SetPlatforms(v []string) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetPlatforms(v)
	})
}

// UpdatePlatforms sets the "platforms" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdatePlatforms() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdatePlatforms()
	})
}

// ClearPlatforms clears the value of the "platforms" field.
func (u *ErrorPassthroughRuleUpsertOne) ClearPlatforms() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearPlatforms()
	})
}

// SetPassthroughCode sets the "passthrough_code" field.
func (u *ErrorPassthroughRuleUpsertOne) SetPassthroughCode(v bool) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetPassthroughCode(v)
	})
}

// UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdatePassthroughCode() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdatePassthroughCode()
	})
}

// SetResponseCode sets the "response_code" field.
func (u *ErrorPassthroughRuleUpsertOne) SetResponseCode(v int) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetResponseCode(v)
	})
}

// AddResponseCode adds v to the "response_code" field.
func (u *ErrorPassthroughRuleUpsertOne) AddResponseCode(v int) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.AddResponseCode(v)
	})
}

// UpdateResponseCode sets the "response_code" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdateResponseCode() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateResponseCode()
	})
}

// ClearResponseCode clears the value of the "response_code" field.
func (u *ErrorPassthroughRuleUpsertOne) ClearResponseCode() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearResponseCode()
	})
}

// SetPassthroughBody sets the "passthrough_body" field.
func (u *ErrorPassthroughRuleUpsertOne) SetPassthroughBody(v bool) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetPassthroughBody(v)
	})
}

// UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdatePassthroughBody() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdatePassthroughBody()
	})
}

// SetCustomMessage sets the "custom_message" field.
func (u *ErrorPassthroughRuleUpsertOne) SetCustomMessage(v string) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetCustomMessage(v)
	})
}

// UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdateCustomMessage() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateCustomMessage()
	})
}

// ClearCustomMessage clears the value of the "custom_message" field.
func (u *ErrorPassthroughRuleUpsertOne) ClearCustomMessage() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearCustomMessage()
	})
}

// SetSkipMonitoring sets the "skip_monitoring" field.
func (u *ErrorPassthroughRuleUpsertOne) SetSkipMonitoring(v bool) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetSkipMonitoring(v)
	})
}

// UpdateSkipMonitoring sets the "skip_monitoring" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdateSkipMonitoring() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateSkipMonitoring()
	})
}

// SetDescription sets the "description" field.
func (u *ErrorPassthroughRuleUpsertOne) SetDescription(v string) *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetDescription(v)
	})
}

// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertOne) UpdateDescription() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateDescription()
	})
}

// ClearDescription clears the value of the "description" field.
func (u *ErrorPassthroughRuleUpsertOne) ClearDescription() *ErrorPassthroughRuleUpsertOne {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearDescription()
	})
}

// Exec executes the query.
func (u *ErrorPassthroughRuleUpsertOne) Exec(ctx context.Context) error {
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for ErrorPassthroughRuleCreate.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *ErrorPassthroughRuleUpsertOne) 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 *ErrorPassthroughRuleUpsertOne) ID(ctx context.Context) (id int64, 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 *ErrorPassthroughRuleUpsertOne) IDX(ctx context.Context) int64 {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

// ErrorPassthroughRuleCreateBulk is the builder for creating many ErrorPassthroughRule entities in bulk.
type ErrorPassthroughRuleCreateBulk struct {
	config
	err      error
	builders []*ErrorPassthroughRuleCreate
	conflict []sql.ConflictOption
}

// Save creates the ErrorPassthroughRule entities in the database.
func (_c *ErrorPassthroughRuleCreateBulk) Save(ctx context.Context) ([]*ErrorPassthroughRule, error) {
	if _c.err != nil {
		return nil, _c.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
	nodes := make([]*ErrorPassthroughRule, 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.(*ErrorPassthroughRuleMutation)
				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
				if specs[i].ID.Value != nil {
					id := specs[i].ID.Value.(int64)
					nodes[i].ID = int64(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 *ErrorPassthroughRuleCreateBulk) SaveX(ctx context.Context) []*ErrorPassthroughRule {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (_c *ErrorPassthroughRuleCreateBulk) Exec(ctx context.Context) error {
	_, err := _c.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (_c *ErrorPassthroughRuleCreateBulk) 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.ErrorPassthroughRule.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.ErrorPassthroughRuleUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
func (_c *ErrorPassthroughRuleCreateBulk) OnConflict(opts ...sql.ConflictOption) *ErrorPassthroughRuleUpsertBulk {
	_c.conflict = opts
	return &ErrorPassthroughRuleUpsertBulk{
		create: _c,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.ErrorPassthroughRule.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (_c *ErrorPassthroughRuleCreateBulk) OnConflictColumns(columns ...string) *ErrorPassthroughRuleUpsertBulk {
	_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
	return &ErrorPassthroughRuleUpsertBulk{
		create: _c,
	}
}

// ErrorPassthroughRuleUpsertBulk is the builder for "upsert"-ing
// a bulk of ErrorPassthroughRule nodes.
type ErrorPassthroughRuleUpsertBulk struct {
	create *ErrorPassthroughRuleCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.ErrorPassthroughRule.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//		).
//		Exec(ctx)
func (u *ErrorPassthroughRuleUpsertBulk) UpdateNewValues() *ErrorPassthroughRuleUpsertBulk {
	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(errorpassthroughrule.FieldCreatedAt)
			}
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.ErrorPassthroughRule.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
func (u *ErrorPassthroughRuleUpsertBulk) Ignore() *ErrorPassthroughRuleUpsertBulk {
	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 *ErrorPassthroughRuleUpsertBulk) DoNothing() *ErrorPassthroughRuleUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the ErrorPassthroughRuleCreateBulk.OnConflict
// documentation for more info.
func (u *ErrorPassthroughRuleUpsertBulk) Update(set func(*ErrorPassthroughRuleUpsert)) *ErrorPassthroughRuleUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&ErrorPassthroughRuleUpsert{UpdateSet: update})
	}))
	return u
}

// SetUpdatedAt sets the "updated_at" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdateUpdatedAt() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateUpdatedAt()
	})
}

// SetName sets the "name" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetName(v string) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetName(v)
	})
}

// UpdateName sets the "name" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdateName() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateName()
	})
}

// SetEnabled sets the "enabled" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetEnabled(v bool) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetEnabled(v)
	})
}

// UpdateEnabled sets the "enabled" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdateEnabled() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateEnabled()
	})
}

// SetPriority sets the "priority" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetPriority(v int) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetPriority(v)
	})
}

// AddPriority adds v to the "priority" field.
func (u *ErrorPassthroughRuleUpsertBulk) AddPriority(v int) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.AddPriority(v)
	})
}

// UpdatePriority sets the "priority" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdatePriority() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdatePriority()
	})
}

// SetErrorCodes sets the "error_codes" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetErrorCodes(v []int) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetErrorCodes(v)
	})
}

// UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdateErrorCodes() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateErrorCodes()
	})
}

// ClearErrorCodes clears the value of the "error_codes" field.
func (u *ErrorPassthroughRuleUpsertBulk) ClearErrorCodes() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearErrorCodes()
	})
}

// SetKeywords sets the "keywords" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetKeywords(v []string) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetKeywords(v)
	})
}

// UpdateKeywords sets the "keywords" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdateKeywords() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateKeywords()
	})
}

// ClearKeywords clears the value of the "keywords" field.
func (u *ErrorPassthroughRuleUpsertBulk) ClearKeywords() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearKeywords()
	})
}

// SetMatchMode sets the "match_mode" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetMatchMode(v string) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetMatchMode(v)
	})
}

// UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdateMatchMode() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateMatchMode()
	})
}

// SetPlatforms sets the "platforms" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetPlatforms(v []string) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetPlatforms(v)
	})
}

// UpdatePlatforms sets the "platforms" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdatePlatforms() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdatePlatforms()
	})
}

// ClearPlatforms clears the value of the "platforms" field.
func (u *ErrorPassthroughRuleUpsertBulk) ClearPlatforms() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearPlatforms()
	})
}

// SetPassthroughCode sets the "passthrough_code" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetPassthroughCode(v bool) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetPassthroughCode(v)
	})
}

// UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdatePassthroughCode() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdatePassthroughCode()
	})
}

// SetResponseCode sets the "response_code" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetResponseCode(v int) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetResponseCode(v)
	})
}

// AddResponseCode adds v to the "response_code" field.
func (u *ErrorPassthroughRuleUpsertBulk) AddResponseCode(v int) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.AddResponseCode(v)
	})
}

// UpdateResponseCode sets the "response_code" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdateResponseCode() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateResponseCode()
	})
}

// ClearResponseCode clears the value of the "response_code" field.
func (u *ErrorPassthroughRuleUpsertBulk) ClearResponseCode() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearResponseCode()
	})
}

// SetPassthroughBody sets the "passthrough_body" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetPassthroughBody(v bool) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetPassthroughBody(v)
	})
}

// UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdatePassthroughBody() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdatePassthroughBody()
	})
}

// SetCustomMessage sets the "custom_message" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetCustomMessage(v string) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetCustomMessage(v)
	})
}

// UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdateCustomMessage() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateCustomMessage()
	})
}

// ClearCustomMessage clears the value of the "custom_message" field.
func (u *ErrorPassthroughRuleUpsertBulk) ClearCustomMessage() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearCustomMessage()
	})
}

// SetSkipMonitoring sets the "skip_monitoring" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetSkipMonitoring(v bool) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetSkipMonitoring(v)
	})
}

// UpdateSkipMonitoring sets the "skip_monitoring" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdateSkipMonitoring() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateSkipMonitoring()
	})
}

// SetDescription sets the "description" field.
func (u *ErrorPassthroughRuleUpsertBulk) SetDescription(v string) *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.SetDescription(v)
	})
}

// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *ErrorPassthroughRuleUpsertBulk) UpdateDescription() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.UpdateDescription()
	})
}

// ClearDescription clears the value of the "description" field.
func (u *ErrorPassthroughRuleUpsertBulk) ClearDescription() *ErrorPassthroughRuleUpsertBulk {
	return u.Update(func(s *ErrorPassthroughRuleUpsert) {
		s.ClearDescription()
	})
}

// Exec executes the query.
func (u *ErrorPassthroughRuleUpsertBulk) 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 ErrorPassthroughRuleCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for ErrorPassthroughRuleCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *ErrorPassthroughRuleUpsertBulk) ExecX(ctx context.Context) {
	if err := u.create.Exec(ctx); err != nil {
		panic(err)
	}
}
