tlsfingerprintprofile_create.go 46 KB

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