mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-25 13:48:18 +08:00
1320 lines
40 KiB
Go
1320 lines
40 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect"
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentrule"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentruleversion"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// AgentRuleCreate is the builder for creating a AgentRule entity.
|
|
type AgentRuleCreate struct {
|
|
config
|
|
mutation *AgentRuleMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_c *AgentRuleCreate) SetName(v string) *AgentRuleCreate {
|
|
_c.mutation.SetName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_c *AgentRuleCreate) SetDescription(v string) *AgentRuleCreate {
|
|
_c.mutation.SetDescription(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_c *AgentRuleCreate) SetNillableDescription(v *string) *AgentRuleCreate {
|
|
if v != nil {
|
|
_c.SetDescription(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetScopeType sets the "scope_type" field.
|
|
func (_c *AgentRuleCreate) SetScopeType(v agentrule.ScopeType) *AgentRuleCreate {
|
|
_c.mutation.SetScopeType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableScopeType sets the "scope_type" field if the given value is not nil.
|
|
func (_c *AgentRuleCreate) SetNillableScopeType(v *agentrule.ScopeType) *AgentRuleCreate {
|
|
if v != nil {
|
|
_c.SetScopeType(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetScopeID sets the "scope_id" field.
|
|
func (_c *AgentRuleCreate) SetScopeID(v string) *AgentRuleCreate {
|
|
_c.mutation.SetScopeID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableScopeID sets the "scope_id" field if the given value is not nil.
|
|
func (_c *AgentRuleCreate) SetNillableScopeID(v *string) *AgentRuleCreate {
|
|
if v != nil {
|
|
_c.SetScopeID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedBy sets the "created_by" field.
|
|
func (_c *AgentRuleCreate) SetCreatedBy(v uuid.UUID) *AgentRuleCreate {
|
|
_c.mutation.SetCreatedBy(v)
|
|
return _c
|
|
}
|
|
|
|
// SetActiveVersionID sets the "active_version_id" field.
|
|
func (_c *AgentRuleCreate) SetActiveVersionID(v uuid.UUID) *AgentRuleCreate {
|
|
_c.mutation.SetActiveVersionID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil.
|
|
func (_c *AgentRuleCreate) SetNillableActiveVersionID(v *uuid.UUID) *AgentRuleCreate {
|
|
if v != nil {
|
|
_c.SetActiveVersionID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetExtensionPackageID sets the "extension_package_id" field.
|
|
func (_c *AgentRuleCreate) SetExtensionPackageID(v string) *AgentRuleCreate {
|
|
_c.mutation.SetExtensionPackageID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableExtensionPackageID sets the "extension_package_id" field if the given value is not nil.
|
|
func (_c *AgentRuleCreate) SetNillableExtensionPackageID(v *string) *AgentRuleCreate {
|
|
if v != nil {
|
|
_c.SetExtensionPackageID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetExtensionRuleID sets the "extension_rule_id" field.
|
|
func (_c *AgentRuleCreate) SetExtensionRuleID(v string) *AgentRuleCreate {
|
|
_c.mutation.SetExtensionRuleID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableExtensionRuleID sets the "extension_rule_id" field if the given value is not nil.
|
|
func (_c *AgentRuleCreate) SetNillableExtensionRuleID(v *string) *AgentRuleCreate {
|
|
if v != nil {
|
|
_c.SetExtensionRuleID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetExtensionVersion sets the "extension_version" field.
|
|
func (_c *AgentRuleCreate) SetExtensionVersion(v string) *AgentRuleCreate {
|
|
_c.mutation.SetExtensionVersion(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableExtensionVersion sets the "extension_version" field if the given value is not nil.
|
|
func (_c *AgentRuleCreate) SetNillableExtensionVersion(v *string) *AgentRuleCreate {
|
|
if v != nil {
|
|
_c.SetExtensionVersion(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetIsDeleted sets the "is_deleted" field.
|
|
func (_c *AgentRuleCreate) SetIsDeleted(v bool) *AgentRuleCreate {
|
|
_c.mutation.SetIsDeleted(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil.
|
|
func (_c *AgentRuleCreate) SetNillableIsDeleted(v *bool) *AgentRuleCreate {
|
|
if v != nil {
|
|
_c.SetIsDeleted(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *AgentRuleCreate) SetCreatedAt(v time.Time) *AgentRuleCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *AgentRuleCreate) SetNillableCreatedAt(v *time.Time) *AgentRuleCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *AgentRuleCreate) SetUpdatedAt(v time.Time) *AgentRuleCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *AgentRuleCreate) SetNillableUpdatedAt(v *time.Time) *AgentRuleCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *AgentRuleCreate) SetID(v uuid.UUID) *AgentRuleCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableID sets the "id" field if the given value is not nil.
|
|
func (_c *AgentRuleCreate) SetNillableID(v *uuid.UUID) *AgentRuleCreate {
|
|
if v != nil {
|
|
_c.SetID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// AddVersionIDs adds the "versions" edge to the AgentRuleVersion entity by IDs.
|
|
func (_c *AgentRuleCreate) AddVersionIDs(ids ...uuid.UUID) *AgentRuleCreate {
|
|
_c.mutation.AddVersionIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddVersions adds the "versions" edges to the AgentRuleVersion entity.
|
|
func (_c *AgentRuleCreate) AddVersions(v ...*AgentRuleVersion) *AgentRuleCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddVersionIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the AgentRuleMutation object of the builder.
|
|
func (_c *AgentRuleCreate) Mutation() *AgentRuleMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the AgentRule in the database.
|
|
func (_c *AgentRuleCreate) Save(ctx context.Context) (*AgentRule, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *AgentRuleCreate) SaveX(ctx context.Context) *AgentRule {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *AgentRuleCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *AgentRuleCreate) 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 *AgentRuleCreate) defaults() {
|
|
if _, ok := _c.mutation.ScopeType(); !ok {
|
|
v := agentrule.DefaultScopeType
|
|
_c.mutation.SetScopeType(v)
|
|
}
|
|
if _, ok := _c.mutation.ScopeID(); !ok {
|
|
v := agentrule.DefaultScopeID
|
|
_c.mutation.SetScopeID(v)
|
|
}
|
|
if _, ok := _c.mutation.IsDeleted(); !ok {
|
|
v := agentrule.DefaultIsDeleted
|
|
_c.mutation.SetIsDeleted(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := agentrule.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
v := agentrule.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.ID(); !ok {
|
|
v := agentrule.DefaultID()
|
|
_c.mutation.SetID(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *AgentRuleCreate) check() error {
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`db: missing required field "AgentRule.name"`)}
|
|
}
|
|
if v, ok := _c.mutation.Name(); ok {
|
|
if err := agentrule.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentRule.name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.ScopeType(); !ok {
|
|
return &ValidationError{Name: "scope_type", err: errors.New(`db: missing required field "AgentRule.scope_type"`)}
|
|
}
|
|
if v, ok := _c.mutation.ScopeType(); ok {
|
|
if err := agentrule.ScopeTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentRule.scope_type": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.ScopeID(); !ok {
|
|
return &ValidationError{Name: "scope_id", err: errors.New(`db: missing required field "AgentRule.scope_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.CreatedBy(); !ok {
|
|
return &ValidationError{Name: "created_by", err: errors.New(`db: missing required field "AgentRule.created_by"`)}
|
|
}
|
|
if _, ok := _c.mutation.IsDeleted(); !ok {
|
|
return &ValidationError{Name: "is_deleted", err: errors.New(`db: missing required field "AgentRule.is_deleted"`)}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentRule.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "AgentRule.updated_at"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *AgentRuleCreate) sqlSave(ctx context.Context) (*AgentRule, error) {
|
|
if err := _c.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := _c.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
if _spec.ID.Value != nil {
|
|
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
|
_node.ID = *id
|
|
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *AgentRuleCreate) createSpec() (*AgentRule, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &AgentRule{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(agentrule.Table, sqlgraph.NewFieldSpec(agentrule.FieldID, field.TypeUUID))
|
|
)
|
|
_spec.OnConflict = _c.conflict
|
|
if id, ok := _c.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = &id
|
|
}
|
|
if value, ok := _c.mutation.Name(); ok {
|
|
_spec.SetField(agentrule.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := _c.mutation.Description(); ok {
|
|
_spec.SetField(agentrule.FieldDescription, field.TypeString, value)
|
|
_node.Description = value
|
|
}
|
|
if value, ok := _c.mutation.ScopeType(); ok {
|
|
_spec.SetField(agentrule.FieldScopeType, field.TypeEnum, value)
|
|
_node.ScopeType = value
|
|
}
|
|
if value, ok := _c.mutation.ScopeID(); ok {
|
|
_spec.SetField(agentrule.FieldScopeID, field.TypeString, value)
|
|
_node.ScopeID = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedBy(); ok {
|
|
_spec.SetField(agentrule.FieldCreatedBy, field.TypeUUID, value)
|
|
_node.CreatedBy = value
|
|
}
|
|
if value, ok := _c.mutation.ActiveVersionID(); ok {
|
|
_spec.SetField(agentrule.FieldActiveVersionID, field.TypeUUID, value)
|
|
_node.ActiveVersionID = &value
|
|
}
|
|
if value, ok := _c.mutation.ExtensionPackageID(); ok {
|
|
_spec.SetField(agentrule.FieldExtensionPackageID, field.TypeString, value)
|
|
_node.ExtensionPackageID = &value
|
|
}
|
|
if value, ok := _c.mutation.ExtensionRuleID(); ok {
|
|
_spec.SetField(agentrule.FieldExtensionRuleID, field.TypeString, value)
|
|
_node.ExtensionRuleID = &value
|
|
}
|
|
if value, ok := _c.mutation.ExtensionVersion(); ok {
|
|
_spec.SetField(agentrule.FieldExtensionVersion, field.TypeString, value)
|
|
_node.ExtensionVersion = &value
|
|
}
|
|
if value, ok := _c.mutation.IsDeleted(); ok {
|
|
_spec.SetField(agentrule.FieldIsDeleted, field.TypeBool, value)
|
|
_node.IsDeleted = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(agentrule.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(agentrule.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if nodes := _c.mutation.VersionsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: agentrule.VersionsTable,
|
|
Columns: []string{agentrule.VersionsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.AgentRule.Create().
|
|
// SetName(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.AgentRuleUpsert) {
|
|
// SetName(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *AgentRuleCreate) OnConflict(opts ...sql.ConflictOption) *AgentRuleUpsertOne {
|
|
_c.conflict = opts
|
|
return &AgentRuleUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.AgentRule.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *AgentRuleCreate) OnConflictColumns(columns ...string) *AgentRuleUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &AgentRuleUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// AgentRuleUpsertOne is the builder for "upsert"-ing
|
|
// one AgentRule node.
|
|
AgentRuleUpsertOne struct {
|
|
create *AgentRuleCreate
|
|
}
|
|
|
|
// AgentRuleUpsert is the "OnConflict" setter.
|
|
AgentRuleUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *AgentRuleUpsert) SetName(v string) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateName() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldName)
|
|
return u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *AgentRuleUpsert) SetDescription(v string) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldDescription, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateDescription() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldDescription)
|
|
return u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *AgentRuleUpsert) ClearDescription() *AgentRuleUpsert {
|
|
u.SetNull(agentrule.FieldDescription)
|
|
return u
|
|
}
|
|
|
|
// SetScopeType sets the "scope_type" field.
|
|
func (u *AgentRuleUpsert) SetScopeType(v agentrule.ScopeType) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldScopeType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateScopeType sets the "scope_type" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateScopeType() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldScopeType)
|
|
return u
|
|
}
|
|
|
|
// SetScopeID sets the "scope_id" field.
|
|
func (u *AgentRuleUpsert) SetScopeID(v string) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldScopeID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateScopeID sets the "scope_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateScopeID() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldScopeID)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedBy sets the "created_by" field.
|
|
func (u *AgentRuleUpsert) SetCreatedBy(v uuid.UUID) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldCreatedBy, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedBy sets the "created_by" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateCreatedBy() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldCreatedBy)
|
|
return u
|
|
}
|
|
|
|
// SetActiveVersionID sets the "active_version_id" field.
|
|
func (u *AgentRuleUpsert) SetActiveVersionID(v uuid.UUID) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldActiveVersionID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateActiveVersionID() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldActiveVersionID)
|
|
return u
|
|
}
|
|
|
|
// ClearActiveVersionID clears the value of the "active_version_id" field.
|
|
func (u *AgentRuleUpsert) ClearActiveVersionID() *AgentRuleUpsert {
|
|
u.SetNull(agentrule.FieldActiveVersionID)
|
|
return u
|
|
}
|
|
|
|
// SetExtensionPackageID sets the "extension_package_id" field.
|
|
func (u *AgentRuleUpsert) SetExtensionPackageID(v string) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldExtensionPackageID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateExtensionPackageID() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldExtensionPackageID)
|
|
return u
|
|
}
|
|
|
|
// ClearExtensionPackageID clears the value of the "extension_package_id" field.
|
|
func (u *AgentRuleUpsert) ClearExtensionPackageID() *AgentRuleUpsert {
|
|
u.SetNull(agentrule.FieldExtensionPackageID)
|
|
return u
|
|
}
|
|
|
|
// SetExtensionRuleID sets the "extension_rule_id" field.
|
|
func (u *AgentRuleUpsert) SetExtensionRuleID(v string) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldExtensionRuleID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateExtensionRuleID sets the "extension_rule_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateExtensionRuleID() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldExtensionRuleID)
|
|
return u
|
|
}
|
|
|
|
// ClearExtensionRuleID clears the value of the "extension_rule_id" field.
|
|
func (u *AgentRuleUpsert) ClearExtensionRuleID() *AgentRuleUpsert {
|
|
u.SetNull(agentrule.FieldExtensionRuleID)
|
|
return u
|
|
}
|
|
|
|
// SetExtensionVersion sets the "extension_version" field.
|
|
func (u *AgentRuleUpsert) SetExtensionVersion(v string) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldExtensionVersion, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateExtensionVersion sets the "extension_version" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateExtensionVersion() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldExtensionVersion)
|
|
return u
|
|
}
|
|
|
|
// ClearExtensionVersion clears the value of the "extension_version" field.
|
|
func (u *AgentRuleUpsert) ClearExtensionVersion() *AgentRuleUpsert {
|
|
u.SetNull(agentrule.FieldExtensionVersion)
|
|
return u
|
|
}
|
|
|
|
// SetIsDeleted sets the "is_deleted" field.
|
|
func (u *AgentRuleUpsert) SetIsDeleted(v bool) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldIsDeleted, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateIsDeleted() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldIsDeleted)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *AgentRuleUpsert) SetCreatedAt(v time.Time) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateCreatedAt() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *AgentRuleUpsert) SetUpdatedAt(v time.Time) *AgentRuleUpsert {
|
|
u.Set(agentrule.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsert) UpdateUpdatedAt() *AgentRuleUpsert {
|
|
u.SetExcluded(agentrule.FieldUpdatedAt)
|
|
return u
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.AgentRule.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(agentrule.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *AgentRuleUpsertOne) UpdateNewValues() *AgentRuleUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
if _, exists := u.create.mutation.ID(); exists {
|
|
s.SetIgnore(agentrule.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.AgentRule.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *AgentRuleUpsertOne) Ignore() *AgentRuleUpsertOne {
|
|
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 *AgentRuleUpsertOne) DoNothing() *AgentRuleUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the AgentRuleCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *AgentRuleUpsertOne) Update(set func(*AgentRuleUpsert)) *AgentRuleUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&AgentRuleUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *AgentRuleUpsertOne) SetName(v string) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateName() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *AgentRuleUpsertOne) SetDescription(v string) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetDescription(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateDescription() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateDescription()
|
|
})
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *AgentRuleUpsertOne) ClearDescription() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.ClearDescription()
|
|
})
|
|
}
|
|
|
|
// SetScopeType sets the "scope_type" field.
|
|
func (u *AgentRuleUpsertOne) SetScopeType(v agentrule.ScopeType) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetScopeType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScopeType sets the "scope_type" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateScopeType() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateScopeType()
|
|
})
|
|
}
|
|
|
|
// SetScopeID sets the "scope_id" field.
|
|
func (u *AgentRuleUpsertOne) SetScopeID(v string) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetScopeID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScopeID sets the "scope_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateScopeID() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateScopeID()
|
|
})
|
|
}
|
|
|
|
// SetCreatedBy sets the "created_by" field.
|
|
func (u *AgentRuleUpsertOne) SetCreatedBy(v uuid.UUID) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetCreatedBy(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedBy sets the "created_by" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateCreatedBy() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateCreatedBy()
|
|
})
|
|
}
|
|
|
|
// SetActiveVersionID sets the "active_version_id" field.
|
|
func (u *AgentRuleUpsertOne) SetActiveVersionID(v uuid.UUID) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetActiveVersionID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateActiveVersionID() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateActiveVersionID()
|
|
})
|
|
}
|
|
|
|
// ClearActiveVersionID clears the value of the "active_version_id" field.
|
|
func (u *AgentRuleUpsertOne) ClearActiveVersionID() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.ClearActiveVersionID()
|
|
})
|
|
}
|
|
|
|
// SetExtensionPackageID sets the "extension_package_id" field.
|
|
func (u *AgentRuleUpsertOne) SetExtensionPackageID(v string) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetExtensionPackageID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateExtensionPackageID() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateExtensionPackageID()
|
|
})
|
|
}
|
|
|
|
// ClearExtensionPackageID clears the value of the "extension_package_id" field.
|
|
func (u *AgentRuleUpsertOne) ClearExtensionPackageID() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.ClearExtensionPackageID()
|
|
})
|
|
}
|
|
|
|
// SetExtensionRuleID sets the "extension_rule_id" field.
|
|
func (u *AgentRuleUpsertOne) SetExtensionRuleID(v string) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetExtensionRuleID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExtensionRuleID sets the "extension_rule_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateExtensionRuleID() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateExtensionRuleID()
|
|
})
|
|
}
|
|
|
|
// ClearExtensionRuleID clears the value of the "extension_rule_id" field.
|
|
func (u *AgentRuleUpsertOne) ClearExtensionRuleID() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.ClearExtensionRuleID()
|
|
})
|
|
}
|
|
|
|
// SetExtensionVersion sets the "extension_version" field.
|
|
func (u *AgentRuleUpsertOne) SetExtensionVersion(v string) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetExtensionVersion(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExtensionVersion sets the "extension_version" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateExtensionVersion() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateExtensionVersion()
|
|
})
|
|
}
|
|
|
|
// ClearExtensionVersion clears the value of the "extension_version" field.
|
|
func (u *AgentRuleUpsertOne) ClearExtensionVersion() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.ClearExtensionVersion()
|
|
})
|
|
}
|
|
|
|
// SetIsDeleted sets the "is_deleted" field.
|
|
func (u *AgentRuleUpsertOne) SetIsDeleted(v bool) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetIsDeleted(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateIsDeleted() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateIsDeleted()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *AgentRuleUpsertOne) SetCreatedAt(v time.Time) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateCreatedAt() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *AgentRuleUpsertOne) SetUpdatedAt(v time.Time) *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertOne) UpdateUpdatedAt() *AgentRuleUpsertOne {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *AgentRuleUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for AgentRuleCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *AgentRuleUpsertOne) 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 *AgentRuleUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) {
|
|
if u.create.driver.Dialect() == dialect.MySQL {
|
|
// In case of "ON CONFLICT", there is no way to get back non-numeric ID
|
|
// fields from the database since MySQL does not support the RETURNING clause.
|
|
return id, errors.New("db: AgentRuleUpsertOne.ID is not supported by MySQL driver. Use AgentRuleUpsertOne.Exec instead")
|
|
}
|
|
node, err := u.create.Save(ctx)
|
|
if err != nil {
|
|
return id, err
|
|
}
|
|
return node.ID, nil
|
|
}
|
|
|
|
// IDX is like ID, but panics if an error occurs.
|
|
func (u *AgentRuleUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// AgentRuleCreateBulk is the builder for creating many AgentRule entities in bulk.
|
|
type AgentRuleCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*AgentRuleCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the AgentRule entities in the database.
|
|
func (_c *AgentRuleCreateBulk) Save(ctx context.Context) ([]*AgentRule, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*AgentRule, 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.(*AgentRuleMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
var err error
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
spec.OnConflict = _c.conflict
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
}
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &nodes[i].ID
|
|
mutation.done = true
|
|
return nodes[i], nil
|
|
})
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
mut = builder.hooks[i](mut)
|
|
}
|
|
mutators[i] = mut
|
|
}(i, ctx)
|
|
}
|
|
if len(mutators) > 0 {
|
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_c *AgentRuleCreateBulk) SaveX(ctx context.Context) []*AgentRule {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *AgentRuleCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *AgentRuleCreateBulk) 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.AgentRule.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.AgentRuleUpsert) {
|
|
// SetName(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *AgentRuleCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentRuleUpsertBulk {
|
|
_c.conflict = opts
|
|
return &AgentRuleUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.AgentRule.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *AgentRuleCreateBulk) OnConflictColumns(columns ...string) *AgentRuleUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &AgentRuleUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// AgentRuleUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of AgentRule nodes.
|
|
type AgentRuleUpsertBulk struct {
|
|
create *AgentRuleCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.AgentRule.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(agentrule.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *AgentRuleUpsertBulk) UpdateNewValues() *AgentRuleUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
for _, b := range u.create.builders {
|
|
if _, exists := b.mutation.ID(); exists {
|
|
s.SetIgnore(agentrule.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.AgentRule.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *AgentRuleUpsertBulk) Ignore() *AgentRuleUpsertBulk {
|
|
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 *AgentRuleUpsertBulk) DoNothing() *AgentRuleUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the AgentRuleCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *AgentRuleUpsertBulk) Update(set func(*AgentRuleUpsert)) *AgentRuleUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&AgentRuleUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *AgentRuleUpsertBulk) SetName(v string) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateName() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *AgentRuleUpsertBulk) SetDescription(v string) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetDescription(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateDescription() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateDescription()
|
|
})
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *AgentRuleUpsertBulk) ClearDescription() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.ClearDescription()
|
|
})
|
|
}
|
|
|
|
// SetScopeType sets the "scope_type" field.
|
|
func (u *AgentRuleUpsertBulk) SetScopeType(v agentrule.ScopeType) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetScopeType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScopeType sets the "scope_type" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateScopeType() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateScopeType()
|
|
})
|
|
}
|
|
|
|
// SetScopeID sets the "scope_id" field.
|
|
func (u *AgentRuleUpsertBulk) SetScopeID(v string) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetScopeID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScopeID sets the "scope_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateScopeID() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateScopeID()
|
|
})
|
|
}
|
|
|
|
// SetCreatedBy sets the "created_by" field.
|
|
func (u *AgentRuleUpsertBulk) SetCreatedBy(v uuid.UUID) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetCreatedBy(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedBy sets the "created_by" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateCreatedBy() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateCreatedBy()
|
|
})
|
|
}
|
|
|
|
// SetActiveVersionID sets the "active_version_id" field.
|
|
func (u *AgentRuleUpsertBulk) SetActiveVersionID(v uuid.UUID) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetActiveVersionID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateActiveVersionID() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateActiveVersionID()
|
|
})
|
|
}
|
|
|
|
// ClearActiveVersionID clears the value of the "active_version_id" field.
|
|
func (u *AgentRuleUpsertBulk) ClearActiveVersionID() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.ClearActiveVersionID()
|
|
})
|
|
}
|
|
|
|
// SetExtensionPackageID sets the "extension_package_id" field.
|
|
func (u *AgentRuleUpsertBulk) SetExtensionPackageID(v string) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetExtensionPackageID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateExtensionPackageID() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateExtensionPackageID()
|
|
})
|
|
}
|
|
|
|
// ClearExtensionPackageID clears the value of the "extension_package_id" field.
|
|
func (u *AgentRuleUpsertBulk) ClearExtensionPackageID() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.ClearExtensionPackageID()
|
|
})
|
|
}
|
|
|
|
// SetExtensionRuleID sets the "extension_rule_id" field.
|
|
func (u *AgentRuleUpsertBulk) SetExtensionRuleID(v string) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetExtensionRuleID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExtensionRuleID sets the "extension_rule_id" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateExtensionRuleID() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateExtensionRuleID()
|
|
})
|
|
}
|
|
|
|
// ClearExtensionRuleID clears the value of the "extension_rule_id" field.
|
|
func (u *AgentRuleUpsertBulk) ClearExtensionRuleID() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.ClearExtensionRuleID()
|
|
})
|
|
}
|
|
|
|
// SetExtensionVersion sets the "extension_version" field.
|
|
func (u *AgentRuleUpsertBulk) SetExtensionVersion(v string) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetExtensionVersion(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExtensionVersion sets the "extension_version" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateExtensionVersion() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateExtensionVersion()
|
|
})
|
|
}
|
|
|
|
// ClearExtensionVersion clears the value of the "extension_version" field.
|
|
func (u *AgentRuleUpsertBulk) ClearExtensionVersion() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.ClearExtensionVersion()
|
|
})
|
|
}
|
|
|
|
// SetIsDeleted sets the "is_deleted" field.
|
|
func (u *AgentRuleUpsertBulk) SetIsDeleted(v bool) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetIsDeleted(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateIsDeleted() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateIsDeleted()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *AgentRuleUpsertBulk) SetCreatedAt(v time.Time) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateCreatedAt() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *AgentRuleUpsertBulk) SetUpdatedAt(v time.Time) *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *AgentRuleUpsertBulk) UpdateUpdatedAt() *AgentRuleUpsertBulk {
|
|
return u.Update(func(s *AgentRuleUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *AgentRuleUpsertBulk) Exec(ctx context.Context) error {
|
|
if u.create.err != nil {
|
|
return u.create.err
|
|
}
|
|
for i, b := range u.create.builders {
|
|
if len(b.conflict) != 0 {
|
|
return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AgentRuleCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for AgentRuleCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *AgentRuleUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|