errorpassthroughrule_create.go 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "entgo.io/ent/dialect/sql"
  9. "entgo.io/ent/dialect/sql/sqlgraph"
  10. "entgo.io/ent/schema/field"
  11. "github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
  12. )
  13. // ErrorPassthroughRuleCreate is the builder for creating a ErrorPassthroughRule entity.
  14. type ErrorPassthroughRuleCreate struct {
  15. config
  16. mutation *ErrorPassthroughRuleMutation
  17. hooks []Hook
  18. conflict []sql.ConflictOption
  19. }
  20. // SetCreatedAt sets the "created_at" field.
  21. func (_c *ErrorPassthroughRuleCreate) SetCreatedAt(v time.Time) *ErrorPassthroughRuleCreate {
  22. _c.mutation.SetCreatedAt(v)
  23. return _c
  24. }
  25. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  26. func (_c *ErrorPassthroughRuleCreate) SetNillableCreatedAt(v *time.Time) *ErrorPassthroughRuleCreate {
  27. if v != nil {
  28. _c.SetCreatedAt(*v)
  29. }
  30. return _c
  31. }
  32. // SetUpdatedAt sets the "updated_at" field.
  33. func (_c *ErrorPassthroughRuleCreate) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleCreate {
  34. _c.mutation.SetUpdatedAt(v)
  35. return _c
  36. }
  37. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  38. func (_c *ErrorPassthroughRuleCreate) SetNillableUpdatedAt(v *time.Time) *ErrorPassthroughRuleCreate {
  39. if v != nil {
  40. _c.SetUpdatedAt(*v)
  41. }
  42. return _c
  43. }
  44. // SetName sets the "name" field.
  45. func (_c *ErrorPassthroughRuleCreate) SetName(v string) *ErrorPassthroughRuleCreate {
  46. _c.mutation.SetName(v)
  47. return _c
  48. }
  49. // SetEnabled sets the "enabled" field.
  50. func (_c *ErrorPassthroughRuleCreate) SetEnabled(v bool) *ErrorPassthroughRuleCreate {
  51. _c.mutation.SetEnabled(v)
  52. return _c
  53. }
  54. // SetNillableEnabled sets the "enabled" field if the given value is not nil.
  55. func (_c *ErrorPassthroughRuleCreate) SetNillableEnabled(v *bool) *ErrorPassthroughRuleCreate {
  56. if v != nil {
  57. _c.SetEnabled(*v)
  58. }
  59. return _c
  60. }
  61. // SetPriority sets the "priority" field.
  62. func (_c *ErrorPassthroughRuleCreate) SetPriority(v int) *ErrorPassthroughRuleCreate {
  63. _c.mutation.SetPriority(v)
  64. return _c
  65. }
  66. // SetNillablePriority sets the "priority" field if the given value is not nil.
  67. func (_c *ErrorPassthroughRuleCreate) SetNillablePriority(v *int) *ErrorPassthroughRuleCreate {
  68. if v != nil {
  69. _c.SetPriority(*v)
  70. }
  71. return _c
  72. }
  73. // SetErrorCodes sets the "error_codes" field.
  74. func (_c *ErrorPassthroughRuleCreate) SetErrorCodes(v []int) *ErrorPassthroughRuleCreate {
  75. _c.mutation.SetErrorCodes(v)
  76. return _c
  77. }
  78. // SetKeywords sets the "keywords" field.
  79. func (_c *ErrorPassthroughRuleCreate) SetKeywords(v []string) *ErrorPassthroughRuleCreate {
  80. _c.mutation.SetKeywords(v)
  81. return _c
  82. }
  83. // SetMatchMode sets the "match_mode" field.
  84. func (_c *ErrorPassthroughRuleCreate) SetMatchMode(v string) *ErrorPassthroughRuleCreate {
  85. _c.mutation.SetMatchMode(v)
  86. return _c
  87. }
  88. // SetNillableMatchMode sets the "match_mode" field if the given value is not nil.
  89. func (_c *ErrorPassthroughRuleCreate) SetNillableMatchMode(v *string) *ErrorPassthroughRuleCreate {
  90. if v != nil {
  91. _c.SetMatchMode(*v)
  92. }
  93. return _c
  94. }
  95. // SetPlatforms sets the "platforms" field.
  96. func (_c *ErrorPassthroughRuleCreate) SetPlatforms(v []string) *ErrorPassthroughRuleCreate {
  97. _c.mutation.SetPlatforms(v)
  98. return _c
  99. }
  100. // SetPassthroughCode sets the "passthrough_code" field.
  101. func (_c *ErrorPassthroughRuleCreate) SetPassthroughCode(v bool) *ErrorPassthroughRuleCreate {
  102. _c.mutation.SetPassthroughCode(v)
  103. return _c
  104. }
  105. // SetNillablePassthroughCode sets the "passthrough_code" field if the given value is not nil.
  106. func (_c *ErrorPassthroughRuleCreate) SetNillablePassthroughCode(v *bool) *ErrorPassthroughRuleCreate {
  107. if v != nil {
  108. _c.SetPassthroughCode(*v)
  109. }
  110. return _c
  111. }
  112. // SetResponseCode sets the "response_code" field.
  113. func (_c *ErrorPassthroughRuleCreate) SetResponseCode(v int) *ErrorPassthroughRuleCreate {
  114. _c.mutation.SetResponseCode(v)
  115. return _c
  116. }
  117. // SetNillableResponseCode sets the "response_code" field if the given value is not nil.
  118. func (_c *ErrorPassthroughRuleCreate) SetNillableResponseCode(v *int) *ErrorPassthroughRuleCreate {
  119. if v != nil {
  120. _c.SetResponseCode(*v)
  121. }
  122. return _c
  123. }
  124. // SetPassthroughBody sets the "passthrough_body" field.
  125. func (_c *ErrorPassthroughRuleCreate) SetPassthroughBody(v bool) *ErrorPassthroughRuleCreate {
  126. _c.mutation.SetPassthroughBody(v)
  127. return _c
  128. }
  129. // SetNillablePassthroughBody sets the "passthrough_body" field if the given value is not nil.
  130. func (_c *ErrorPassthroughRuleCreate) SetNillablePassthroughBody(v *bool) *ErrorPassthroughRuleCreate {
  131. if v != nil {
  132. _c.SetPassthroughBody(*v)
  133. }
  134. return _c
  135. }
  136. // SetCustomMessage sets the "custom_message" field.
  137. func (_c *ErrorPassthroughRuleCreate) SetCustomMessage(v string) *ErrorPassthroughRuleCreate {
  138. _c.mutation.SetCustomMessage(v)
  139. return _c
  140. }
  141. // SetNillableCustomMessage sets the "custom_message" field if the given value is not nil.
  142. func (_c *ErrorPassthroughRuleCreate) SetNillableCustomMessage(v *string) *ErrorPassthroughRuleCreate {
  143. if v != nil {
  144. _c.SetCustomMessage(*v)
  145. }
  146. return _c
  147. }
  148. // SetSkipMonitoring sets the "skip_monitoring" field.
  149. func (_c *ErrorPassthroughRuleCreate) SetSkipMonitoring(v bool) *ErrorPassthroughRuleCreate {
  150. _c.mutation.SetSkipMonitoring(v)
  151. return _c
  152. }
  153. // SetNillableSkipMonitoring sets the "skip_monitoring" field if the given value is not nil.
  154. func (_c *ErrorPassthroughRuleCreate) SetNillableSkipMonitoring(v *bool) *ErrorPassthroughRuleCreate {
  155. if v != nil {
  156. _c.SetSkipMonitoring(*v)
  157. }
  158. return _c
  159. }
  160. // SetDescription sets the "description" field.
  161. func (_c *ErrorPassthroughRuleCreate) SetDescription(v string) *ErrorPassthroughRuleCreate {
  162. _c.mutation.SetDescription(v)
  163. return _c
  164. }
  165. // SetNillableDescription sets the "description" field if the given value is not nil.
  166. func (_c *ErrorPassthroughRuleCreate) SetNillableDescription(v *string) *ErrorPassthroughRuleCreate {
  167. if v != nil {
  168. _c.SetDescription(*v)
  169. }
  170. return _c
  171. }
  172. // Mutation returns the ErrorPassthroughRuleMutation object of the builder.
  173. func (_c *ErrorPassthroughRuleCreate) Mutation() *ErrorPassthroughRuleMutation {
  174. return _c.mutation
  175. }
  176. // Save creates the ErrorPassthroughRule in the database.
  177. func (_c *ErrorPassthroughRuleCreate) Save(ctx context.Context) (*ErrorPassthroughRule, error) {
  178. _c.defaults()
  179. return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
  180. }
  181. // SaveX calls Save and panics if Save returns an error.
  182. func (_c *ErrorPassthroughRuleCreate) SaveX(ctx context.Context) *ErrorPassthroughRule {
  183. v, err := _c.Save(ctx)
  184. if err != nil {
  185. panic(err)
  186. }
  187. return v
  188. }
  189. // Exec executes the query.
  190. func (_c *ErrorPassthroughRuleCreate) Exec(ctx context.Context) error {
  191. _, err := _c.Save(ctx)
  192. return err
  193. }
  194. // ExecX is like Exec, but panics if an error occurs.
  195. func (_c *ErrorPassthroughRuleCreate) ExecX(ctx context.Context) {
  196. if err := _c.Exec(ctx); err != nil {
  197. panic(err)
  198. }
  199. }
  200. // defaults sets the default values of the builder before save.
  201. func (_c *ErrorPassthroughRuleCreate) defaults() {
  202. if _, ok := _c.mutation.CreatedAt(); !ok {
  203. v := errorpassthroughrule.DefaultCreatedAt()
  204. _c.mutation.SetCreatedAt(v)
  205. }
  206. if _, ok := _c.mutation.UpdatedAt(); !ok {
  207. v := errorpassthroughrule.DefaultUpdatedAt()
  208. _c.mutation.SetUpdatedAt(v)
  209. }
  210. if _, ok := _c.mutation.Enabled(); !ok {
  211. v := errorpassthroughrule.DefaultEnabled
  212. _c.mutation.SetEnabled(v)
  213. }
  214. if _, ok := _c.mutation.Priority(); !ok {
  215. v := errorpassthroughrule.DefaultPriority
  216. _c.mutation.SetPriority(v)
  217. }
  218. if _, ok := _c.mutation.MatchMode(); !ok {
  219. v := errorpassthroughrule.DefaultMatchMode
  220. _c.mutation.SetMatchMode(v)
  221. }
  222. if _, ok := _c.mutation.PassthroughCode(); !ok {
  223. v := errorpassthroughrule.DefaultPassthroughCode
  224. _c.mutation.SetPassthroughCode(v)
  225. }
  226. if _, ok := _c.mutation.PassthroughBody(); !ok {
  227. v := errorpassthroughrule.DefaultPassthroughBody
  228. _c.mutation.SetPassthroughBody(v)
  229. }
  230. if _, ok := _c.mutation.SkipMonitoring(); !ok {
  231. v := errorpassthroughrule.DefaultSkipMonitoring
  232. _c.mutation.SetSkipMonitoring(v)
  233. }
  234. }
  235. // check runs all checks and user-defined validators on the builder.
  236. func (_c *ErrorPassthroughRuleCreate) check() error {
  237. if _, ok := _c.mutation.CreatedAt(); !ok {
  238. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ErrorPassthroughRule.created_at"`)}
  239. }
  240. if _, ok := _c.mutation.UpdatedAt(); !ok {
  241. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ErrorPassthroughRule.updated_at"`)}
  242. }
  243. if _, ok := _c.mutation.Name(); !ok {
  244. return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ErrorPassthroughRule.name"`)}
  245. }
  246. if v, ok := _c.mutation.Name(); ok {
  247. if err := errorpassthroughrule.NameValidator(v); err != nil {
  248. return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ErrorPassthroughRule.name": %w`, err)}
  249. }
  250. }
  251. if _, ok := _c.mutation.Enabled(); !ok {
  252. return &ValidationError{Name: "enabled", err: errors.New(`ent: missing required field "ErrorPassthroughRule.enabled"`)}
  253. }
  254. if _, ok := _c.mutation.Priority(); !ok {
  255. return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "ErrorPassthroughRule.priority"`)}
  256. }
  257. if _, ok := _c.mutation.MatchMode(); !ok {
  258. return &ValidationError{Name: "match_mode", err: errors.New(`ent: missing required field "ErrorPassthroughRule.match_mode"`)}
  259. }
  260. if v, ok := _c.mutation.MatchMode(); ok {
  261. if err := errorpassthroughrule.MatchModeValidator(v); err != nil {
  262. return &ValidationError{Name: "match_mode", err: fmt.Errorf(`ent: validator failed for field "ErrorPassthroughRule.match_mode": %w`, err)}
  263. }
  264. }
  265. if _, ok := _c.mutation.PassthroughCode(); !ok {
  266. return &ValidationError{Name: "passthrough_code", err: errors.New(`ent: missing required field "ErrorPassthroughRule.passthrough_code"`)}
  267. }
  268. if _, ok := _c.mutation.PassthroughBody(); !ok {
  269. return &ValidationError{Name: "passthrough_body", err: errors.New(`ent: missing required field "ErrorPassthroughRule.passthrough_body"`)}
  270. }
  271. if _, ok := _c.mutation.SkipMonitoring(); !ok {
  272. return &ValidationError{Name: "skip_monitoring", err: errors.New(`ent: missing required field "ErrorPassthroughRule.skip_monitoring"`)}
  273. }
  274. return nil
  275. }
  276. func (_c *ErrorPassthroughRuleCreate) sqlSave(ctx context.Context) (*ErrorPassthroughRule, error) {
  277. if err := _c.check(); err != nil {
  278. return nil, err
  279. }
  280. _node, _spec := _c.createSpec()
  281. if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
  282. if sqlgraph.IsConstraintError(err) {
  283. err = &ConstraintError{msg: err.Error(), wrap: err}
  284. }
  285. return nil, err
  286. }
  287. id := _spec.ID.Value.(int64)
  288. _node.ID = int64(id)
  289. _c.mutation.id = &_node.ID
  290. _c.mutation.done = true
  291. return _node, nil
  292. }
  293. func (_c *ErrorPassthroughRuleCreate) createSpec() (*ErrorPassthroughRule, *sqlgraph.CreateSpec) {
  294. var (
  295. _node = &ErrorPassthroughRule{config: _c.config}
  296. _spec = sqlgraph.NewCreateSpec(errorpassthroughrule.Table, sqlgraph.NewFieldSpec(errorpassthroughrule.FieldID, field.TypeInt64))
  297. )
  298. _spec.OnConflict = _c.conflict
  299. if value, ok := _c.mutation.CreatedAt(); ok {
  300. _spec.SetField(errorpassthroughrule.FieldCreatedAt, field.TypeTime, value)
  301. _node.CreatedAt = value
  302. }
  303. if value, ok := _c.mutation.UpdatedAt(); ok {
  304. _spec.SetField(errorpassthroughrule.FieldUpdatedAt, field.TypeTime, value)
  305. _node.UpdatedAt = value
  306. }
  307. if value, ok := _c.mutation.Name(); ok {
  308. _spec.SetField(errorpassthroughrule.FieldName, field.TypeString, value)
  309. _node.Name = value
  310. }
  311. if value, ok := _c.mutation.Enabled(); ok {
  312. _spec.SetField(errorpassthroughrule.FieldEnabled, field.TypeBool, value)
  313. _node.Enabled = value
  314. }
  315. if value, ok := _c.mutation.Priority(); ok {
  316. _spec.SetField(errorpassthroughrule.FieldPriority, field.TypeInt, value)
  317. _node.Priority = value
  318. }
  319. if value, ok := _c.mutation.ErrorCodes(); ok {
  320. _spec.SetField(errorpassthroughrule.FieldErrorCodes, field.TypeJSON, value)
  321. _node.ErrorCodes = value
  322. }
  323. if value, ok := _c.mutation.Keywords(); ok {
  324. _spec.SetField(errorpassthroughrule.FieldKeywords, field.TypeJSON, value)
  325. _node.Keywords = value
  326. }
  327. if value, ok := _c.mutation.MatchMode(); ok {
  328. _spec.SetField(errorpassthroughrule.FieldMatchMode, field.TypeString, value)
  329. _node.MatchMode = value
  330. }
  331. if value, ok := _c.mutation.Platforms(); ok {
  332. _spec.SetField(errorpassthroughrule.FieldPlatforms, field.TypeJSON, value)
  333. _node.Platforms = value
  334. }
  335. if value, ok := _c.mutation.PassthroughCode(); ok {
  336. _spec.SetField(errorpassthroughrule.FieldPassthroughCode, field.TypeBool, value)
  337. _node.PassthroughCode = value
  338. }
  339. if value, ok := _c.mutation.ResponseCode(); ok {
  340. _spec.SetField(errorpassthroughrule.FieldResponseCode, field.TypeInt, value)
  341. _node.ResponseCode = &value
  342. }
  343. if value, ok := _c.mutation.PassthroughBody(); ok {
  344. _spec.SetField(errorpassthroughrule.FieldPassthroughBody, field.TypeBool, value)
  345. _node.PassthroughBody = value
  346. }
  347. if value, ok := _c.mutation.CustomMessage(); ok {
  348. _spec.SetField(errorpassthroughrule.FieldCustomMessage, field.TypeString, value)
  349. _node.CustomMessage = &value
  350. }
  351. if value, ok := _c.mutation.SkipMonitoring(); ok {
  352. _spec.SetField(errorpassthroughrule.FieldSkipMonitoring, field.TypeBool, value)
  353. _node.SkipMonitoring = value
  354. }
  355. if value, ok := _c.mutation.Description(); ok {
  356. _spec.SetField(errorpassthroughrule.FieldDescription, field.TypeString, value)
  357. _node.Description = &value
  358. }
  359. return _node, _spec
  360. }
  361. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  362. // of the `INSERT` statement. For example:
  363. //
  364. // client.ErrorPassthroughRule.Create().
  365. // SetCreatedAt(v).
  366. // OnConflict(
  367. // // Update the row with the new values
  368. // // the was proposed for insertion.
  369. // sql.ResolveWithNewValues(),
  370. // ).
  371. // // Override some of the fields with custom
  372. // // update values.
  373. // Update(func(u *ent.ErrorPassthroughRuleUpsert) {
  374. // SetCreatedAt(v+v).
  375. // }).
  376. // Exec(ctx)
  377. func (_c *ErrorPassthroughRuleCreate) OnConflict(opts ...sql.ConflictOption) *ErrorPassthroughRuleUpsertOne {
  378. _c.conflict = opts
  379. return &ErrorPassthroughRuleUpsertOne{
  380. create: _c,
  381. }
  382. }
  383. // OnConflictColumns calls `OnConflict` and configures the columns
  384. // as conflict target. Using this option is equivalent to using:
  385. //
  386. // client.ErrorPassthroughRule.Create().
  387. // OnConflict(sql.ConflictColumns(columns...)).
  388. // Exec(ctx)
  389. func (_c *ErrorPassthroughRuleCreate) OnConflictColumns(columns ...string) *ErrorPassthroughRuleUpsertOne {
  390. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  391. return &ErrorPassthroughRuleUpsertOne{
  392. create: _c,
  393. }
  394. }
  395. type (
  396. // ErrorPassthroughRuleUpsertOne is the builder for "upsert"-ing
  397. // one ErrorPassthroughRule node.
  398. ErrorPassthroughRuleUpsertOne struct {
  399. create *ErrorPassthroughRuleCreate
  400. }
  401. // ErrorPassthroughRuleUpsert is the "OnConflict" setter.
  402. ErrorPassthroughRuleUpsert struct {
  403. *sql.UpdateSet
  404. }
  405. )
  406. // SetUpdatedAt sets the "updated_at" field.
  407. func (u *ErrorPassthroughRuleUpsert) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleUpsert {
  408. u.Set(errorpassthroughrule.FieldUpdatedAt, v)
  409. return u
  410. }
  411. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  412. func (u *ErrorPassthroughRuleUpsert) UpdateUpdatedAt() *ErrorPassthroughRuleUpsert {
  413. u.SetExcluded(errorpassthroughrule.FieldUpdatedAt)
  414. return u
  415. }
  416. // SetName sets the "name" field.
  417. func (u *ErrorPassthroughRuleUpsert) SetName(v string) *ErrorPassthroughRuleUpsert {
  418. u.Set(errorpassthroughrule.FieldName, v)
  419. return u
  420. }
  421. // UpdateName sets the "name" field to the value that was provided on create.
  422. func (u *ErrorPassthroughRuleUpsert) UpdateName() *ErrorPassthroughRuleUpsert {
  423. u.SetExcluded(errorpassthroughrule.FieldName)
  424. return u
  425. }
  426. // SetEnabled sets the "enabled" field.
  427. func (u *ErrorPassthroughRuleUpsert) SetEnabled(v bool) *ErrorPassthroughRuleUpsert {
  428. u.Set(errorpassthroughrule.FieldEnabled, v)
  429. return u
  430. }
  431. // UpdateEnabled sets the "enabled" field to the value that was provided on create.
  432. func (u *ErrorPassthroughRuleUpsert) UpdateEnabled() *ErrorPassthroughRuleUpsert {
  433. u.SetExcluded(errorpassthroughrule.FieldEnabled)
  434. return u
  435. }
  436. // SetPriority sets the "priority" field.
  437. func (u *ErrorPassthroughRuleUpsert) SetPriority(v int) *ErrorPassthroughRuleUpsert {
  438. u.Set(errorpassthroughrule.FieldPriority, v)
  439. return u
  440. }
  441. // UpdatePriority sets the "priority" field to the value that was provided on create.
  442. func (u *ErrorPassthroughRuleUpsert) UpdatePriority() *ErrorPassthroughRuleUpsert {
  443. u.SetExcluded(errorpassthroughrule.FieldPriority)
  444. return u
  445. }
  446. // AddPriority adds v to the "priority" field.
  447. func (u *ErrorPassthroughRuleUpsert) AddPriority(v int) *ErrorPassthroughRuleUpsert {
  448. u.Add(errorpassthroughrule.FieldPriority, v)
  449. return u
  450. }
  451. // SetErrorCodes sets the "error_codes" field.
  452. func (u *ErrorPassthroughRuleUpsert) SetErrorCodes(v []int) *ErrorPassthroughRuleUpsert {
  453. u.Set(errorpassthroughrule.FieldErrorCodes, v)
  454. return u
  455. }
  456. // UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
  457. func (u *ErrorPassthroughRuleUpsert) UpdateErrorCodes() *ErrorPassthroughRuleUpsert {
  458. u.SetExcluded(errorpassthroughrule.FieldErrorCodes)
  459. return u
  460. }
  461. // ClearErrorCodes clears the value of the "error_codes" field.
  462. func (u *ErrorPassthroughRuleUpsert) ClearErrorCodes() *ErrorPassthroughRuleUpsert {
  463. u.SetNull(errorpassthroughrule.FieldErrorCodes)
  464. return u
  465. }
  466. // SetKeywords sets the "keywords" field.
  467. func (u *ErrorPassthroughRuleUpsert) SetKeywords(v []string) *ErrorPassthroughRuleUpsert {
  468. u.Set(errorpassthroughrule.FieldKeywords, v)
  469. return u
  470. }
  471. // UpdateKeywords sets the "keywords" field to the value that was provided on create.
  472. func (u *ErrorPassthroughRuleUpsert) UpdateKeywords() *ErrorPassthroughRuleUpsert {
  473. u.SetExcluded(errorpassthroughrule.FieldKeywords)
  474. return u
  475. }
  476. // ClearKeywords clears the value of the "keywords" field.
  477. func (u *ErrorPassthroughRuleUpsert) ClearKeywords() *ErrorPassthroughRuleUpsert {
  478. u.SetNull(errorpassthroughrule.FieldKeywords)
  479. return u
  480. }
  481. // SetMatchMode sets the "match_mode" field.
  482. func (u *ErrorPassthroughRuleUpsert) SetMatchMode(v string) *ErrorPassthroughRuleUpsert {
  483. u.Set(errorpassthroughrule.FieldMatchMode, v)
  484. return u
  485. }
  486. // UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
  487. func (u *ErrorPassthroughRuleUpsert) UpdateMatchMode() *ErrorPassthroughRuleUpsert {
  488. u.SetExcluded(errorpassthroughrule.FieldMatchMode)
  489. return u
  490. }
  491. // SetPlatforms sets the "platforms" field.
  492. func (u *ErrorPassthroughRuleUpsert) SetPlatforms(v []string) *ErrorPassthroughRuleUpsert {
  493. u.Set(errorpassthroughrule.FieldPlatforms, v)
  494. return u
  495. }
  496. // UpdatePlatforms sets the "platforms" field to the value that was provided on create.
  497. func (u *ErrorPassthroughRuleUpsert) UpdatePlatforms() *ErrorPassthroughRuleUpsert {
  498. u.SetExcluded(errorpassthroughrule.FieldPlatforms)
  499. return u
  500. }
  501. // ClearPlatforms clears the value of the "platforms" field.
  502. func (u *ErrorPassthroughRuleUpsert) ClearPlatforms() *ErrorPassthroughRuleUpsert {
  503. u.SetNull(errorpassthroughrule.FieldPlatforms)
  504. return u
  505. }
  506. // SetPassthroughCode sets the "passthrough_code" field.
  507. func (u *ErrorPassthroughRuleUpsert) SetPassthroughCode(v bool) *ErrorPassthroughRuleUpsert {
  508. u.Set(errorpassthroughrule.FieldPassthroughCode, v)
  509. return u
  510. }
  511. // UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
  512. func (u *ErrorPassthroughRuleUpsert) UpdatePassthroughCode() *ErrorPassthroughRuleUpsert {
  513. u.SetExcluded(errorpassthroughrule.FieldPassthroughCode)
  514. return u
  515. }
  516. // SetResponseCode sets the "response_code" field.
  517. func (u *ErrorPassthroughRuleUpsert) SetResponseCode(v int) *ErrorPassthroughRuleUpsert {
  518. u.Set(errorpassthroughrule.FieldResponseCode, v)
  519. return u
  520. }
  521. // UpdateResponseCode sets the "response_code" field to the value that was provided on create.
  522. func (u *ErrorPassthroughRuleUpsert) UpdateResponseCode() *ErrorPassthroughRuleUpsert {
  523. u.SetExcluded(errorpassthroughrule.FieldResponseCode)
  524. return u
  525. }
  526. // AddResponseCode adds v to the "response_code" field.
  527. func (u *ErrorPassthroughRuleUpsert) AddResponseCode(v int) *ErrorPassthroughRuleUpsert {
  528. u.Add(errorpassthroughrule.FieldResponseCode, v)
  529. return u
  530. }
  531. // ClearResponseCode clears the value of the "response_code" field.
  532. func (u *ErrorPassthroughRuleUpsert) ClearResponseCode() *ErrorPassthroughRuleUpsert {
  533. u.SetNull(errorpassthroughrule.FieldResponseCode)
  534. return u
  535. }
  536. // SetPassthroughBody sets the "passthrough_body" field.
  537. func (u *ErrorPassthroughRuleUpsert) SetPassthroughBody(v bool) *ErrorPassthroughRuleUpsert {
  538. u.Set(errorpassthroughrule.FieldPassthroughBody, v)
  539. return u
  540. }
  541. // UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
  542. func (u *ErrorPassthroughRuleUpsert) UpdatePassthroughBody() *ErrorPassthroughRuleUpsert {
  543. u.SetExcluded(errorpassthroughrule.FieldPassthroughBody)
  544. return u
  545. }
  546. // SetCustomMessage sets the "custom_message" field.
  547. func (u *ErrorPassthroughRuleUpsert) SetCustomMessage(v string) *ErrorPassthroughRuleUpsert {
  548. u.Set(errorpassthroughrule.FieldCustomMessage, v)
  549. return u
  550. }
  551. // UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
  552. func (u *ErrorPassthroughRuleUpsert) UpdateCustomMessage() *ErrorPassthroughRuleUpsert {
  553. u.SetExcluded(errorpassthroughrule.FieldCustomMessage)
  554. return u
  555. }
  556. // ClearCustomMessage clears the value of the "custom_message" field.
  557. func (u *ErrorPassthroughRuleUpsert) ClearCustomMessage() *ErrorPassthroughRuleUpsert {
  558. u.SetNull(errorpassthroughrule.FieldCustomMessage)
  559. return u
  560. }
  561. // SetSkipMonitoring sets the "skip_monitoring" field.
  562. func (u *ErrorPassthroughRuleUpsert) SetSkipMonitoring(v bool) *ErrorPassthroughRuleUpsert {
  563. u.Set(errorpassthroughrule.FieldSkipMonitoring, v)
  564. return u
  565. }
  566. // UpdateSkipMonitoring sets the "skip_monitoring" field to the value that was provided on create.
  567. func (u *ErrorPassthroughRuleUpsert) UpdateSkipMonitoring() *ErrorPassthroughRuleUpsert {
  568. u.SetExcluded(errorpassthroughrule.FieldSkipMonitoring)
  569. return u
  570. }
  571. // SetDescription sets the "description" field.
  572. func (u *ErrorPassthroughRuleUpsert) SetDescription(v string) *ErrorPassthroughRuleUpsert {
  573. u.Set(errorpassthroughrule.FieldDescription, v)
  574. return u
  575. }
  576. // UpdateDescription sets the "description" field to the value that was provided on create.
  577. func (u *ErrorPassthroughRuleUpsert) UpdateDescription() *ErrorPassthroughRuleUpsert {
  578. u.SetExcluded(errorpassthroughrule.FieldDescription)
  579. return u
  580. }
  581. // ClearDescription clears the value of the "description" field.
  582. func (u *ErrorPassthroughRuleUpsert) ClearDescription() *ErrorPassthroughRuleUpsert {
  583. u.SetNull(errorpassthroughrule.FieldDescription)
  584. return u
  585. }
  586. // UpdateNewValues updates the mutable fields using the new values that were set on create.
  587. // Using this option is equivalent to using:
  588. //
  589. // client.ErrorPassthroughRule.Create().
  590. // OnConflict(
  591. // sql.ResolveWithNewValues(),
  592. // ).
  593. // Exec(ctx)
  594. func (u *ErrorPassthroughRuleUpsertOne) UpdateNewValues() *ErrorPassthroughRuleUpsertOne {
  595. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  596. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  597. if _, exists := u.create.mutation.CreatedAt(); exists {
  598. s.SetIgnore(errorpassthroughrule.FieldCreatedAt)
  599. }
  600. }))
  601. return u
  602. }
  603. // Ignore sets each column to itself in case of conflict.
  604. // Using this option is equivalent to using:
  605. //
  606. // client.ErrorPassthroughRule.Create().
  607. // OnConflict(sql.ResolveWithIgnore()).
  608. // Exec(ctx)
  609. func (u *ErrorPassthroughRuleUpsertOne) Ignore() *ErrorPassthroughRuleUpsertOne {
  610. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  611. return u
  612. }
  613. // DoNothing configures the conflict_action to `DO NOTHING`.
  614. // Supported only by SQLite and PostgreSQL.
  615. func (u *ErrorPassthroughRuleUpsertOne) DoNothing() *ErrorPassthroughRuleUpsertOne {
  616. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  617. return u
  618. }
  619. // Update allows overriding fields `UPDATE` values. See the ErrorPassthroughRuleCreate.OnConflict
  620. // documentation for more info.
  621. func (u *ErrorPassthroughRuleUpsertOne) Update(set func(*ErrorPassthroughRuleUpsert)) *ErrorPassthroughRuleUpsertOne {
  622. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  623. set(&ErrorPassthroughRuleUpsert{UpdateSet: update})
  624. }))
  625. return u
  626. }
  627. // SetUpdatedAt sets the "updated_at" field.
  628. func (u *ErrorPassthroughRuleUpsertOne) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleUpsertOne {
  629. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  630. s.SetUpdatedAt(v)
  631. })
  632. }
  633. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  634. func (u *ErrorPassthroughRuleUpsertOne) UpdateUpdatedAt() *ErrorPassthroughRuleUpsertOne {
  635. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  636. s.UpdateUpdatedAt()
  637. })
  638. }
  639. // SetName sets the "name" field.
  640. func (u *ErrorPassthroughRuleUpsertOne) SetName(v string) *ErrorPassthroughRuleUpsertOne {
  641. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  642. s.SetName(v)
  643. })
  644. }
  645. // UpdateName sets the "name" field to the value that was provided on create.
  646. func (u *ErrorPassthroughRuleUpsertOne) UpdateName() *ErrorPassthroughRuleUpsertOne {
  647. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  648. s.UpdateName()
  649. })
  650. }
  651. // SetEnabled sets the "enabled" field.
  652. func (u *ErrorPassthroughRuleUpsertOne) SetEnabled(v bool) *ErrorPassthroughRuleUpsertOne {
  653. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  654. s.SetEnabled(v)
  655. })
  656. }
  657. // UpdateEnabled sets the "enabled" field to the value that was provided on create.
  658. func (u *ErrorPassthroughRuleUpsertOne) UpdateEnabled() *ErrorPassthroughRuleUpsertOne {
  659. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  660. s.UpdateEnabled()
  661. })
  662. }
  663. // SetPriority sets the "priority" field.
  664. func (u *ErrorPassthroughRuleUpsertOne) SetPriority(v int) *ErrorPassthroughRuleUpsertOne {
  665. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  666. s.SetPriority(v)
  667. })
  668. }
  669. // AddPriority adds v to the "priority" field.
  670. func (u *ErrorPassthroughRuleUpsertOne) AddPriority(v int) *ErrorPassthroughRuleUpsertOne {
  671. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  672. s.AddPriority(v)
  673. })
  674. }
  675. // UpdatePriority sets the "priority" field to the value that was provided on create.
  676. func (u *ErrorPassthroughRuleUpsertOne) UpdatePriority() *ErrorPassthroughRuleUpsertOne {
  677. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  678. s.UpdatePriority()
  679. })
  680. }
  681. // SetErrorCodes sets the "error_codes" field.
  682. func (u *ErrorPassthroughRuleUpsertOne) SetErrorCodes(v []int) *ErrorPassthroughRuleUpsertOne {
  683. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  684. s.SetErrorCodes(v)
  685. })
  686. }
  687. // UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
  688. func (u *ErrorPassthroughRuleUpsertOne) UpdateErrorCodes() *ErrorPassthroughRuleUpsertOne {
  689. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  690. s.UpdateErrorCodes()
  691. })
  692. }
  693. // ClearErrorCodes clears the value of the "error_codes" field.
  694. func (u *ErrorPassthroughRuleUpsertOne) ClearErrorCodes() *ErrorPassthroughRuleUpsertOne {
  695. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  696. s.ClearErrorCodes()
  697. })
  698. }
  699. // SetKeywords sets the "keywords" field.
  700. func (u *ErrorPassthroughRuleUpsertOne) SetKeywords(v []string) *ErrorPassthroughRuleUpsertOne {
  701. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  702. s.SetKeywords(v)
  703. })
  704. }
  705. // UpdateKeywords sets the "keywords" field to the value that was provided on create.
  706. func (u *ErrorPassthroughRuleUpsertOne) UpdateKeywords() *ErrorPassthroughRuleUpsertOne {
  707. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  708. s.UpdateKeywords()
  709. })
  710. }
  711. // ClearKeywords clears the value of the "keywords" field.
  712. func (u *ErrorPassthroughRuleUpsertOne) ClearKeywords() *ErrorPassthroughRuleUpsertOne {
  713. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  714. s.ClearKeywords()
  715. })
  716. }
  717. // SetMatchMode sets the "match_mode" field.
  718. func (u *ErrorPassthroughRuleUpsertOne) SetMatchMode(v string) *ErrorPassthroughRuleUpsertOne {
  719. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  720. s.SetMatchMode(v)
  721. })
  722. }
  723. // UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
  724. func (u *ErrorPassthroughRuleUpsertOne) UpdateMatchMode() *ErrorPassthroughRuleUpsertOne {
  725. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  726. s.UpdateMatchMode()
  727. })
  728. }
  729. // SetPlatforms sets the "platforms" field.
  730. func (u *ErrorPassthroughRuleUpsertOne) SetPlatforms(v []string) *ErrorPassthroughRuleUpsertOne {
  731. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  732. s.SetPlatforms(v)
  733. })
  734. }
  735. // UpdatePlatforms sets the "platforms" field to the value that was provided on create.
  736. func (u *ErrorPassthroughRuleUpsertOne) UpdatePlatforms() *ErrorPassthroughRuleUpsertOne {
  737. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  738. s.UpdatePlatforms()
  739. })
  740. }
  741. // ClearPlatforms clears the value of the "platforms" field.
  742. func (u *ErrorPassthroughRuleUpsertOne) ClearPlatforms() *ErrorPassthroughRuleUpsertOne {
  743. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  744. s.ClearPlatforms()
  745. })
  746. }
  747. // SetPassthroughCode sets the "passthrough_code" field.
  748. func (u *ErrorPassthroughRuleUpsertOne) SetPassthroughCode(v bool) *ErrorPassthroughRuleUpsertOne {
  749. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  750. s.SetPassthroughCode(v)
  751. })
  752. }
  753. // UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
  754. func (u *ErrorPassthroughRuleUpsertOne) UpdatePassthroughCode() *ErrorPassthroughRuleUpsertOne {
  755. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  756. s.UpdatePassthroughCode()
  757. })
  758. }
  759. // SetResponseCode sets the "response_code" field.
  760. func (u *ErrorPassthroughRuleUpsertOne) SetResponseCode(v int) *ErrorPassthroughRuleUpsertOne {
  761. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  762. s.SetResponseCode(v)
  763. })
  764. }
  765. // AddResponseCode adds v to the "response_code" field.
  766. func (u *ErrorPassthroughRuleUpsertOne) AddResponseCode(v int) *ErrorPassthroughRuleUpsertOne {
  767. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  768. s.AddResponseCode(v)
  769. })
  770. }
  771. // UpdateResponseCode sets the "response_code" field to the value that was provided on create.
  772. func (u *ErrorPassthroughRuleUpsertOne) UpdateResponseCode() *ErrorPassthroughRuleUpsertOne {
  773. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  774. s.UpdateResponseCode()
  775. })
  776. }
  777. // ClearResponseCode clears the value of the "response_code" field.
  778. func (u *ErrorPassthroughRuleUpsertOne) ClearResponseCode() *ErrorPassthroughRuleUpsertOne {
  779. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  780. s.ClearResponseCode()
  781. })
  782. }
  783. // SetPassthroughBody sets the "passthrough_body" field.
  784. func (u *ErrorPassthroughRuleUpsertOne) SetPassthroughBody(v bool) *ErrorPassthroughRuleUpsertOne {
  785. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  786. s.SetPassthroughBody(v)
  787. })
  788. }
  789. // UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
  790. func (u *ErrorPassthroughRuleUpsertOne) UpdatePassthroughBody() *ErrorPassthroughRuleUpsertOne {
  791. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  792. s.UpdatePassthroughBody()
  793. })
  794. }
  795. // SetCustomMessage sets the "custom_message" field.
  796. func (u *ErrorPassthroughRuleUpsertOne) SetCustomMessage(v string) *ErrorPassthroughRuleUpsertOne {
  797. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  798. s.SetCustomMessage(v)
  799. })
  800. }
  801. // UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
  802. func (u *ErrorPassthroughRuleUpsertOne) UpdateCustomMessage() *ErrorPassthroughRuleUpsertOne {
  803. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  804. s.UpdateCustomMessage()
  805. })
  806. }
  807. // ClearCustomMessage clears the value of the "custom_message" field.
  808. func (u *ErrorPassthroughRuleUpsertOne) ClearCustomMessage() *ErrorPassthroughRuleUpsertOne {
  809. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  810. s.ClearCustomMessage()
  811. })
  812. }
  813. // SetSkipMonitoring sets the "skip_monitoring" field.
  814. func (u *ErrorPassthroughRuleUpsertOne) SetSkipMonitoring(v bool) *ErrorPassthroughRuleUpsertOne {
  815. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  816. s.SetSkipMonitoring(v)
  817. })
  818. }
  819. // UpdateSkipMonitoring sets the "skip_monitoring" field to the value that was provided on create.
  820. func (u *ErrorPassthroughRuleUpsertOne) UpdateSkipMonitoring() *ErrorPassthroughRuleUpsertOne {
  821. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  822. s.UpdateSkipMonitoring()
  823. })
  824. }
  825. // SetDescription sets the "description" field.
  826. func (u *ErrorPassthroughRuleUpsertOne) SetDescription(v string) *ErrorPassthroughRuleUpsertOne {
  827. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  828. s.SetDescription(v)
  829. })
  830. }
  831. // UpdateDescription sets the "description" field to the value that was provided on create.
  832. func (u *ErrorPassthroughRuleUpsertOne) UpdateDescription() *ErrorPassthroughRuleUpsertOne {
  833. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  834. s.UpdateDescription()
  835. })
  836. }
  837. // ClearDescription clears the value of the "description" field.
  838. func (u *ErrorPassthroughRuleUpsertOne) ClearDescription() *ErrorPassthroughRuleUpsertOne {
  839. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  840. s.ClearDescription()
  841. })
  842. }
  843. // Exec executes the query.
  844. func (u *ErrorPassthroughRuleUpsertOne) Exec(ctx context.Context) error {
  845. if len(u.create.conflict) == 0 {
  846. return errors.New("ent: missing options for ErrorPassthroughRuleCreate.OnConflict")
  847. }
  848. return u.create.Exec(ctx)
  849. }
  850. // ExecX is like Exec, but panics if an error occurs.
  851. func (u *ErrorPassthroughRuleUpsertOne) ExecX(ctx context.Context) {
  852. if err := u.create.Exec(ctx); err != nil {
  853. panic(err)
  854. }
  855. }
  856. // Exec executes the UPSERT query and returns the inserted/updated ID.
  857. func (u *ErrorPassthroughRuleUpsertOne) ID(ctx context.Context) (id int64, err error) {
  858. node, err := u.create.Save(ctx)
  859. if err != nil {
  860. return id, err
  861. }
  862. return node.ID, nil
  863. }
  864. // IDX is like ID, but panics if an error occurs.
  865. func (u *ErrorPassthroughRuleUpsertOne) IDX(ctx context.Context) int64 {
  866. id, err := u.ID(ctx)
  867. if err != nil {
  868. panic(err)
  869. }
  870. return id
  871. }
  872. // ErrorPassthroughRuleCreateBulk is the builder for creating many ErrorPassthroughRule entities in bulk.
  873. type ErrorPassthroughRuleCreateBulk struct {
  874. config
  875. err error
  876. builders []*ErrorPassthroughRuleCreate
  877. conflict []sql.ConflictOption
  878. }
  879. // Save creates the ErrorPassthroughRule entities in the database.
  880. func (_c *ErrorPassthroughRuleCreateBulk) Save(ctx context.Context) ([]*ErrorPassthroughRule, error) {
  881. if _c.err != nil {
  882. return nil, _c.err
  883. }
  884. specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
  885. nodes := make([]*ErrorPassthroughRule, len(_c.builders))
  886. mutators := make([]Mutator, len(_c.builders))
  887. for i := range _c.builders {
  888. func(i int, root context.Context) {
  889. builder := _c.builders[i]
  890. builder.defaults()
  891. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  892. mutation, ok := m.(*ErrorPassthroughRuleMutation)
  893. if !ok {
  894. return nil, fmt.Errorf("unexpected mutation type %T", m)
  895. }
  896. if err := builder.check(); err != nil {
  897. return nil, err
  898. }
  899. builder.mutation = mutation
  900. var err error
  901. nodes[i], specs[i] = builder.createSpec()
  902. if i < len(mutators)-1 {
  903. _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
  904. } else {
  905. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  906. spec.OnConflict = _c.conflict
  907. // Invoke the actual operation on the latest mutation in the chain.
  908. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
  909. if sqlgraph.IsConstraintError(err) {
  910. err = &ConstraintError{msg: err.Error(), wrap: err}
  911. }
  912. }
  913. }
  914. if err != nil {
  915. return nil, err
  916. }
  917. mutation.id = &nodes[i].ID
  918. if specs[i].ID.Value != nil {
  919. id := specs[i].ID.Value.(int64)
  920. nodes[i].ID = int64(id)
  921. }
  922. mutation.done = true
  923. return nodes[i], nil
  924. })
  925. for i := len(builder.hooks) - 1; i >= 0; i-- {
  926. mut = builder.hooks[i](mut)
  927. }
  928. mutators[i] = mut
  929. }(i, ctx)
  930. }
  931. if len(mutators) > 0 {
  932. if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
  933. return nil, err
  934. }
  935. }
  936. return nodes, nil
  937. }
  938. // SaveX is like Save, but panics if an error occurs.
  939. func (_c *ErrorPassthroughRuleCreateBulk) SaveX(ctx context.Context) []*ErrorPassthroughRule {
  940. v, err := _c.Save(ctx)
  941. if err != nil {
  942. panic(err)
  943. }
  944. return v
  945. }
  946. // Exec executes the query.
  947. func (_c *ErrorPassthroughRuleCreateBulk) Exec(ctx context.Context) error {
  948. _, err := _c.Save(ctx)
  949. return err
  950. }
  951. // ExecX is like Exec, but panics if an error occurs.
  952. func (_c *ErrorPassthroughRuleCreateBulk) ExecX(ctx context.Context) {
  953. if err := _c.Exec(ctx); err != nil {
  954. panic(err)
  955. }
  956. }
  957. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  958. // of the `INSERT` statement. For example:
  959. //
  960. // client.ErrorPassthroughRule.CreateBulk(builders...).
  961. // OnConflict(
  962. // // Update the row with the new values
  963. // // the was proposed for insertion.
  964. // sql.ResolveWithNewValues(),
  965. // ).
  966. // // Override some of the fields with custom
  967. // // update values.
  968. // Update(func(u *ent.ErrorPassthroughRuleUpsert) {
  969. // SetCreatedAt(v+v).
  970. // }).
  971. // Exec(ctx)
  972. func (_c *ErrorPassthroughRuleCreateBulk) OnConflict(opts ...sql.ConflictOption) *ErrorPassthroughRuleUpsertBulk {
  973. _c.conflict = opts
  974. return &ErrorPassthroughRuleUpsertBulk{
  975. create: _c,
  976. }
  977. }
  978. // OnConflictColumns calls `OnConflict` and configures the columns
  979. // as conflict target. Using this option is equivalent to using:
  980. //
  981. // client.ErrorPassthroughRule.Create().
  982. // OnConflict(sql.ConflictColumns(columns...)).
  983. // Exec(ctx)
  984. func (_c *ErrorPassthroughRuleCreateBulk) OnConflictColumns(columns ...string) *ErrorPassthroughRuleUpsertBulk {
  985. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  986. return &ErrorPassthroughRuleUpsertBulk{
  987. create: _c,
  988. }
  989. }
  990. // ErrorPassthroughRuleUpsertBulk is the builder for "upsert"-ing
  991. // a bulk of ErrorPassthroughRule nodes.
  992. type ErrorPassthroughRuleUpsertBulk struct {
  993. create *ErrorPassthroughRuleCreateBulk
  994. }
  995. // UpdateNewValues updates the mutable fields using the new values that
  996. // were set on create. Using this option is equivalent to using:
  997. //
  998. // client.ErrorPassthroughRule.Create().
  999. // OnConflict(
  1000. // sql.ResolveWithNewValues(),
  1001. // ).
  1002. // Exec(ctx)
  1003. func (u *ErrorPassthroughRuleUpsertBulk) UpdateNewValues() *ErrorPassthroughRuleUpsertBulk {
  1004. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1005. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1006. for _, b := range u.create.builders {
  1007. if _, exists := b.mutation.CreatedAt(); exists {
  1008. s.SetIgnore(errorpassthroughrule.FieldCreatedAt)
  1009. }
  1010. }
  1011. }))
  1012. return u
  1013. }
  1014. // Ignore sets each column to itself in case of conflict.
  1015. // Using this option is equivalent to using:
  1016. //
  1017. // client.ErrorPassthroughRule.Create().
  1018. // OnConflict(sql.ResolveWithIgnore()).
  1019. // Exec(ctx)
  1020. func (u *ErrorPassthroughRuleUpsertBulk) Ignore() *ErrorPassthroughRuleUpsertBulk {
  1021. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1022. return u
  1023. }
  1024. // DoNothing configures the conflict_action to `DO NOTHING`.
  1025. // Supported only by SQLite and PostgreSQL.
  1026. func (u *ErrorPassthroughRuleUpsertBulk) DoNothing() *ErrorPassthroughRuleUpsertBulk {
  1027. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1028. return u
  1029. }
  1030. // Update allows overriding fields `UPDATE` values. See the ErrorPassthroughRuleCreateBulk.OnConflict
  1031. // documentation for more info.
  1032. func (u *ErrorPassthroughRuleUpsertBulk) Update(set func(*ErrorPassthroughRuleUpsert)) *ErrorPassthroughRuleUpsertBulk {
  1033. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1034. set(&ErrorPassthroughRuleUpsert{UpdateSet: update})
  1035. }))
  1036. return u
  1037. }
  1038. // SetUpdatedAt sets the "updated_at" field.
  1039. func (u *ErrorPassthroughRuleUpsertBulk) SetUpdatedAt(v time.Time) *ErrorPassthroughRuleUpsertBulk {
  1040. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1041. s.SetUpdatedAt(v)
  1042. })
  1043. }
  1044. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1045. func (u *ErrorPassthroughRuleUpsertBulk) UpdateUpdatedAt() *ErrorPassthroughRuleUpsertBulk {
  1046. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1047. s.UpdateUpdatedAt()
  1048. })
  1049. }
  1050. // SetName sets the "name" field.
  1051. func (u *ErrorPassthroughRuleUpsertBulk) SetName(v string) *ErrorPassthroughRuleUpsertBulk {
  1052. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1053. s.SetName(v)
  1054. })
  1055. }
  1056. // UpdateName sets the "name" field to the value that was provided on create.
  1057. func (u *ErrorPassthroughRuleUpsertBulk) UpdateName() *ErrorPassthroughRuleUpsertBulk {
  1058. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1059. s.UpdateName()
  1060. })
  1061. }
  1062. // SetEnabled sets the "enabled" field.
  1063. func (u *ErrorPassthroughRuleUpsertBulk) SetEnabled(v bool) *ErrorPassthroughRuleUpsertBulk {
  1064. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1065. s.SetEnabled(v)
  1066. })
  1067. }
  1068. // UpdateEnabled sets the "enabled" field to the value that was provided on create.
  1069. func (u *ErrorPassthroughRuleUpsertBulk) UpdateEnabled() *ErrorPassthroughRuleUpsertBulk {
  1070. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1071. s.UpdateEnabled()
  1072. })
  1073. }
  1074. // SetPriority sets the "priority" field.
  1075. func (u *ErrorPassthroughRuleUpsertBulk) SetPriority(v int) *ErrorPassthroughRuleUpsertBulk {
  1076. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1077. s.SetPriority(v)
  1078. })
  1079. }
  1080. // AddPriority adds v to the "priority" field.
  1081. func (u *ErrorPassthroughRuleUpsertBulk) AddPriority(v int) *ErrorPassthroughRuleUpsertBulk {
  1082. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1083. s.AddPriority(v)
  1084. })
  1085. }
  1086. // UpdatePriority sets the "priority" field to the value that was provided on create.
  1087. func (u *ErrorPassthroughRuleUpsertBulk) UpdatePriority() *ErrorPassthroughRuleUpsertBulk {
  1088. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1089. s.UpdatePriority()
  1090. })
  1091. }
  1092. // SetErrorCodes sets the "error_codes" field.
  1093. func (u *ErrorPassthroughRuleUpsertBulk) SetErrorCodes(v []int) *ErrorPassthroughRuleUpsertBulk {
  1094. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1095. s.SetErrorCodes(v)
  1096. })
  1097. }
  1098. // UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
  1099. func (u *ErrorPassthroughRuleUpsertBulk) UpdateErrorCodes() *ErrorPassthroughRuleUpsertBulk {
  1100. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1101. s.UpdateErrorCodes()
  1102. })
  1103. }
  1104. // ClearErrorCodes clears the value of the "error_codes" field.
  1105. func (u *ErrorPassthroughRuleUpsertBulk) ClearErrorCodes() *ErrorPassthroughRuleUpsertBulk {
  1106. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1107. s.ClearErrorCodes()
  1108. })
  1109. }
  1110. // SetKeywords sets the "keywords" field.
  1111. func (u *ErrorPassthroughRuleUpsertBulk) SetKeywords(v []string) *ErrorPassthroughRuleUpsertBulk {
  1112. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1113. s.SetKeywords(v)
  1114. })
  1115. }
  1116. // UpdateKeywords sets the "keywords" field to the value that was provided on create.
  1117. func (u *ErrorPassthroughRuleUpsertBulk) UpdateKeywords() *ErrorPassthroughRuleUpsertBulk {
  1118. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1119. s.UpdateKeywords()
  1120. })
  1121. }
  1122. // ClearKeywords clears the value of the "keywords" field.
  1123. func (u *ErrorPassthroughRuleUpsertBulk) ClearKeywords() *ErrorPassthroughRuleUpsertBulk {
  1124. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1125. s.ClearKeywords()
  1126. })
  1127. }
  1128. // SetMatchMode sets the "match_mode" field.
  1129. func (u *ErrorPassthroughRuleUpsertBulk) SetMatchMode(v string) *ErrorPassthroughRuleUpsertBulk {
  1130. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1131. s.SetMatchMode(v)
  1132. })
  1133. }
  1134. // UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
  1135. func (u *ErrorPassthroughRuleUpsertBulk) UpdateMatchMode() *ErrorPassthroughRuleUpsertBulk {
  1136. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1137. s.UpdateMatchMode()
  1138. })
  1139. }
  1140. // SetPlatforms sets the "platforms" field.
  1141. func (u *ErrorPassthroughRuleUpsertBulk) SetPlatforms(v []string) *ErrorPassthroughRuleUpsertBulk {
  1142. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1143. s.SetPlatforms(v)
  1144. })
  1145. }
  1146. // UpdatePlatforms sets the "platforms" field to the value that was provided on create.
  1147. func (u *ErrorPassthroughRuleUpsertBulk) UpdatePlatforms() *ErrorPassthroughRuleUpsertBulk {
  1148. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1149. s.UpdatePlatforms()
  1150. })
  1151. }
  1152. // ClearPlatforms clears the value of the "platforms" field.
  1153. func (u *ErrorPassthroughRuleUpsertBulk) ClearPlatforms() *ErrorPassthroughRuleUpsertBulk {
  1154. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1155. s.ClearPlatforms()
  1156. })
  1157. }
  1158. // SetPassthroughCode sets the "passthrough_code" field.
  1159. func (u *ErrorPassthroughRuleUpsertBulk) SetPassthroughCode(v bool) *ErrorPassthroughRuleUpsertBulk {
  1160. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1161. s.SetPassthroughCode(v)
  1162. })
  1163. }
  1164. // UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
  1165. func (u *ErrorPassthroughRuleUpsertBulk) UpdatePassthroughCode() *ErrorPassthroughRuleUpsertBulk {
  1166. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1167. s.UpdatePassthroughCode()
  1168. })
  1169. }
  1170. // SetResponseCode sets the "response_code" field.
  1171. func (u *ErrorPassthroughRuleUpsertBulk) SetResponseCode(v int) *ErrorPassthroughRuleUpsertBulk {
  1172. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1173. s.SetResponseCode(v)
  1174. })
  1175. }
  1176. // AddResponseCode adds v to the "response_code" field.
  1177. func (u *ErrorPassthroughRuleUpsertBulk) AddResponseCode(v int) *ErrorPassthroughRuleUpsertBulk {
  1178. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1179. s.AddResponseCode(v)
  1180. })
  1181. }
  1182. // UpdateResponseCode sets the "response_code" field to the value that was provided on create.
  1183. func (u *ErrorPassthroughRuleUpsertBulk) UpdateResponseCode() *ErrorPassthroughRuleUpsertBulk {
  1184. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1185. s.UpdateResponseCode()
  1186. })
  1187. }
  1188. // ClearResponseCode clears the value of the "response_code" field.
  1189. func (u *ErrorPassthroughRuleUpsertBulk) ClearResponseCode() *ErrorPassthroughRuleUpsertBulk {
  1190. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1191. s.ClearResponseCode()
  1192. })
  1193. }
  1194. // SetPassthroughBody sets the "passthrough_body" field.
  1195. func (u *ErrorPassthroughRuleUpsertBulk) SetPassthroughBody(v bool) *ErrorPassthroughRuleUpsertBulk {
  1196. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1197. s.SetPassthroughBody(v)
  1198. })
  1199. }
  1200. // UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
  1201. func (u *ErrorPassthroughRuleUpsertBulk) UpdatePassthroughBody() *ErrorPassthroughRuleUpsertBulk {
  1202. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1203. s.UpdatePassthroughBody()
  1204. })
  1205. }
  1206. // SetCustomMessage sets the "custom_message" field.
  1207. func (u *ErrorPassthroughRuleUpsertBulk) SetCustomMessage(v string) *ErrorPassthroughRuleUpsertBulk {
  1208. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1209. s.SetCustomMessage(v)
  1210. })
  1211. }
  1212. // UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
  1213. func (u *ErrorPassthroughRuleUpsertBulk) UpdateCustomMessage() *ErrorPassthroughRuleUpsertBulk {
  1214. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1215. s.UpdateCustomMessage()
  1216. })
  1217. }
  1218. // ClearCustomMessage clears the value of the "custom_message" field.
  1219. func (u *ErrorPassthroughRuleUpsertBulk) ClearCustomMessage() *ErrorPassthroughRuleUpsertBulk {
  1220. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1221. s.ClearCustomMessage()
  1222. })
  1223. }
  1224. // SetSkipMonitoring sets the "skip_monitoring" field.
  1225. func (u *ErrorPassthroughRuleUpsertBulk) SetSkipMonitoring(v bool) *ErrorPassthroughRuleUpsertBulk {
  1226. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1227. s.SetSkipMonitoring(v)
  1228. })
  1229. }
  1230. // UpdateSkipMonitoring sets the "skip_monitoring" field to the value that was provided on create.
  1231. func (u *ErrorPassthroughRuleUpsertBulk) UpdateSkipMonitoring() *ErrorPassthroughRuleUpsertBulk {
  1232. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1233. s.UpdateSkipMonitoring()
  1234. })
  1235. }
  1236. // SetDescription sets the "description" field.
  1237. func (u *ErrorPassthroughRuleUpsertBulk) SetDescription(v string) *ErrorPassthroughRuleUpsertBulk {
  1238. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1239. s.SetDescription(v)
  1240. })
  1241. }
  1242. // UpdateDescription sets the "description" field to the value that was provided on create.
  1243. func (u *ErrorPassthroughRuleUpsertBulk) UpdateDescription() *ErrorPassthroughRuleUpsertBulk {
  1244. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1245. s.UpdateDescription()
  1246. })
  1247. }
  1248. // ClearDescription clears the value of the "description" field.
  1249. func (u *ErrorPassthroughRuleUpsertBulk) ClearDescription() *ErrorPassthroughRuleUpsertBulk {
  1250. return u.Update(func(s *ErrorPassthroughRuleUpsert) {
  1251. s.ClearDescription()
  1252. })
  1253. }
  1254. // Exec executes the query.
  1255. func (u *ErrorPassthroughRuleUpsertBulk) Exec(ctx context.Context) error {
  1256. if u.create.err != nil {
  1257. return u.create.err
  1258. }
  1259. for i, b := range u.create.builders {
  1260. if len(b.conflict) != 0 {
  1261. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ErrorPassthroughRuleCreateBulk instead", i)
  1262. }
  1263. }
  1264. if len(u.create.conflict) == 0 {
  1265. return errors.New("ent: missing options for ErrorPassthroughRuleCreateBulk.OnConflict")
  1266. }
  1267. return u.create.Exec(ctx)
  1268. }
  1269. // ExecX is like Exec, but panics if an error occurs.
  1270. func (u *ErrorPassthroughRuleUpsertBulk) ExecX(ctx context.Context) {
  1271. if err := u.create.Exec(ctx); err != nil {
  1272. panic(err)
  1273. }
  1274. }