account_update.go 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337
  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/account"
  12. "github.com/Wei-Shaw/sub2api/ent/group"
  13. "github.com/Wei-Shaw/sub2api/ent/predicate"
  14. "github.com/Wei-Shaw/sub2api/ent/proxy"
  15. "github.com/Wei-Shaw/sub2api/ent/usagelog"
  16. )
  17. // AccountUpdate is the builder for updating Account entities.
  18. type AccountUpdate struct {
  19. config
  20. hooks []Hook
  21. mutation *AccountMutation
  22. }
  23. // Where appends a list predicates to the AccountUpdate builder.
  24. func (_u *AccountUpdate) Where(ps ...predicate.Account) *AccountUpdate {
  25. _u.mutation.Where(ps...)
  26. return _u
  27. }
  28. // SetUpdatedAt sets the "updated_at" field.
  29. func (_u *AccountUpdate) SetUpdatedAt(v time.Time) *AccountUpdate {
  30. _u.mutation.SetUpdatedAt(v)
  31. return _u
  32. }
  33. // SetDeletedAt sets the "deleted_at" field.
  34. func (_u *AccountUpdate) SetDeletedAt(v time.Time) *AccountUpdate {
  35. _u.mutation.SetDeletedAt(v)
  36. return _u
  37. }
  38. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  39. func (_u *AccountUpdate) SetNillableDeletedAt(v *time.Time) *AccountUpdate {
  40. if v != nil {
  41. _u.SetDeletedAt(*v)
  42. }
  43. return _u
  44. }
  45. // ClearDeletedAt clears the value of the "deleted_at" field.
  46. func (_u *AccountUpdate) ClearDeletedAt() *AccountUpdate {
  47. _u.mutation.ClearDeletedAt()
  48. return _u
  49. }
  50. // SetName sets the "name" field.
  51. func (_u *AccountUpdate) SetName(v string) *AccountUpdate {
  52. _u.mutation.SetName(v)
  53. return _u
  54. }
  55. // SetNillableName sets the "name" field if the given value is not nil.
  56. func (_u *AccountUpdate) SetNillableName(v *string) *AccountUpdate {
  57. if v != nil {
  58. _u.SetName(*v)
  59. }
  60. return _u
  61. }
  62. // SetNotes sets the "notes" field.
  63. func (_u *AccountUpdate) SetNotes(v string) *AccountUpdate {
  64. _u.mutation.SetNotes(v)
  65. return _u
  66. }
  67. // SetNillableNotes sets the "notes" field if the given value is not nil.
  68. func (_u *AccountUpdate) SetNillableNotes(v *string) *AccountUpdate {
  69. if v != nil {
  70. _u.SetNotes(*v)
  71. }
  72. return _u
  73. }
  74. // ClearNotes clears the value of the "notes" field.
  75. func (_u *AccountUpdate) ClearNotes() *AccountUpdate {
  76. _u.mutation.ClearNotes()
  77. return _u
  78. }
  79. // SetPlatform sets the "platform" field.
  80. func (_u *AccountUpdate) SetPlatform(v string) *AccountUpdate {
  81. _u.mutation.SetPlatform(v)
  82. return _u
  83. }
  84. // SetNillablePlatform sets the "platform" field if the given value is not nil.
  85. func (_u *AccountUpdate) SetNillablePlatform(v *string) *AccountUpdate {
  86. if v != nil {
  87. _u.SetPlatform(*v)
  88. }
  89. return _u
  90. }
  91. // SetType sets the "type" field.
  92. func (_u *AccountUpdate) SetType(v string) *AccountUpdate {
  93. _u.mutation.SetType(v)
  94. return _u
  95. }
  96. // SetNillableType sets the "type" field if the given value is not nil.
  97. func (_u *AccountUpdate) SetNillableType(v *string) *AccountUpdate {
  98. if v != nil {
  99. _u.SetType(*v)
  100. }
  101. return _u
  102. }
  103. // SetCredentials sets the "credentials" field.
  104. func (_u *AccountUpdate) SetCredentials(v map[string]interface{}) *AccountUpdate {
  105. _u.mutation.SetCredentials(v)
  106. return _u
  107. }
  108. // SetExtra sets the "extra" field.
  109. func (_u *AccountUpdate) SetExtra(v map[string]interface{}) *AccountUpdate {
  110. _u.mutation.SetExtra(v)
  111. return _u
  112. }
  113. // SetProxyID sets the "proxy_id" field.
  114. func (_u *AccountUpdate) SetProxyID(v int64) *AccountUpdate {
  115. _u.mutation.SetProxyID(v)
  116. return _u
  117. }
  118. // SetNillableProxyID sets the "proxy_id" field if the given value is not nil.
  119. func (_u *AccountUpdate) SetNillableProxyID(v *int64) *AccountUpdate {
  120. if v != nil {
  121. _u.SetProxyID(*v)
  122. }
  123. return _u
  124. }
  125. // ClearProxyID clears the value of the "proxy_id" field.
  126. func (_u *AccountUpdate) ClearProxyID() *AccountUpdate {
  127. _u.mutation.ClearProxyID()
  128. return _u
  129. }
  130. // SetProxyFallbackOriginID sets the "proxy_fallback_origin_id" field.
  131. func (_u *AccountUpdate) SetProxyFallbackOriginID(v int64) *AccountUpdate {
  132. _u.mutation.ResetProxyFallbackOriginID()
  133. _u.mutation.SetProxyFallbackOriginID(v)
  134. return _u
  135. }
  136. // SetNillableProxyFallbackOriginID sets the "proxy_fallback_origin_id" field if the given value is not nil.
  137. func (_u *AccountUpdate) SetNillableProxyFallbackOriginID(v *int64) *AccountUpdate {
  138. if v != nil {
  139. _u.SetProxyFallbackOriginID(*v)
  140. }
  141. return _u
  142. }
  143. // AddProxyFallbackOriginID adds value to the "proxy_fallback_origin_id" field.
  144. func (_u *AccountUpdate) AddProxyFallbackOriginID(v int64) *AccountUpdate {
  145. _u.mutation.AddProxyFallbackOriginID(v)
  146. return _u
  147. }
  148. // ClearProxyFallbackOriginID clears the value of the "proxy_fallback_origin_id" field.
  149. func (_u *AccountUpdate) ClearProxyFallbackOriginID() *AccountUpdate {
  150. _u.mutation.ClearProxyFallbackOriginID()
  151. return _u
  152. }
  153. // SetConcurrency sets the "concurrency" field.
  154. func (_u *AccountUpdate) SetConcurrency(v int) *AccountUpdate {
  155. _u.mutation.ResetConcurrency()
  156. _u.mutation.SetConcurrency(v)
  157. return _u
  158. }
  159. // SetNillableConcurrency sets the "concurrency" field if the given value is not nil.
  160. func (_u *AccountUpdate) SetNillableConcurrency(v *int) *AccountUpdate {
  161. if v != nil {
  162. _u.SetConcurrency(*v)
  163. }
  164. return _u
  165. }
  166. // AddConcurrency adds value to the "concurrency" field.
  167. func (_u *AccountUpdate) AddConcurrency(v int) *AccountUpdate {
  168. _u.mutation.AddConcurrency(v)
  169. return _u
  170. }
  171. // SetLoadFactor sets the "load_factor" field.
  172. func (_u *AccountUpdate) SetLoadFactor(v int) *AccountUpdate {
  173. _u.mutation.ResetLoadFactor()
  174. _u.mutation.SetLoadFactor(v)
  175. return _u
  176. }
  177. // SetNillableLoadFactor sets the "load_factor" field if the given value is not nil.
  178. func (_u *AccountUpdate) SetNillableLoadFactor(v *int) *AccountUpdate {
  179. if v != nil {
  180. _u.SetLoadFactor(*v)
  181. }
  182. return _u
  183. }
  184. // AddLoadFactor adds value to the "load_factor" field.
  185. func (_u *AccountUpdate) AddLoadFactor(v int) *AccountUpdate {
  186. _u.mutation.AddLoadFactor(v)
  187. return _u
  188. }
  189. // ClearLoadFactor clears the value of the "load_factor" field.
  190. func (_u *AccountUpdate) ClearLoadFactor() *AccountUpdate {
  191. _u.mutation.ClearLoadFactor()
  192. return _u
  193. }
  194. // SetPriority sets the "priority" field.
  195. func (_u *AccountUpdate) SetPriority(v int) *AccountUpdate {
  196. _u.mutation.ResetPriority()
  197. _u.mutation.SetPriority(v)
  198. return _u
  199. }
  200. // SetNillablePriority sets the "priority" field if the given value is not nil.
  201. func (_u *AccountUpdate) SetNillablePriority(v *int) *AccountUpdate {
  202. if v != nil {
  203. _u.SetPriority(*v)
  204. }
  205. return _u
  206. }
  207. // AddPriority adds value to the "priority" field.
  208. func (_u *AccountUpdate) AddPriority(v int) *AccountUpdate {
  209. _u.mutation.AddPriority(v)
  210. return _u
  211. }
  212. // SetRateMultiplier sets the "rate_multiplier" field.
  213. func (_u *AccountUpdate) SetRateMultiplier(v float64) *AccountUpdate {
  214. _u.mutation.ResetRateMultiplier()
  215. _u.mutation.SetRateMultiplier(v)
  216. return _u
  217. }
  218. // SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
  219. func (_u *AccountUpdate) SetNillableRateMultiplier(v *float64) *AccountUpdate {
  220. if v != nil {
  221. _u.SetRateMultiplier(*v)
  222. }
  223. return _u
  224. }
  225. // AddRateMultiplier adds value to the "rate_multiplier" field.
  226. func (_u *AccountUpdate) AddRateMultiplier(v float64) *AccountUpdate {
  227. _u.mutation.AddRateMultiplier(v)
  228. return _u
  229. }
  230. // SetStatus sets the "status" field.
  231. func (_u *AccountUpdate) SetStatus(v string) *AccountUpdate {
  232. _u.mutation.SetStatus(v)
  233. return _u
  234. }
  235. // SetNillableStatus sets the "status" field if the given value is not nil.
  236. func (_u *AccountUpdate) SetNillableStatus(v *string) *AccountUpdate {
  237. if v != nil {
  238. _u.SetStatus(*v)
  239. }
  240. return _u
  241. }
  242. // SetErrorMessage sets the "error_message" field.
  243. func (_u *AccountUpdate) SetErrorMessage(v string) *AccountUpdate {
  244. _u.mutation.SetErrorMessage(v)
  245. return _u
  246. }
  247. // SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
  248. func (_u *AccountUpdate) SetNillableErrorMessage(v *string) *AccountUpdate {
  249. if v != nil {
  250. _u.SetErrorMessage(*v)
  251. }
  252. return _u
  253. }
  254. // ClearErrorMessage clears the value of the "error_message" field.
  255. func (_u *AccountUpdate) ClearErrorMessage() *AccountUpdate {
  256. _u.mutation.ClearErrorMessage()
  257. return _u
  258. }
  259. // SetLastUsedAt sets the "last_used_at" field.
  260. func (_u *AccountUpdate) SetLastUsedAt(v time.Time) *AccountUpdate {
  261. _u.mutation.SetLastUsedAt(v)
  262. return _u
  263. }
  264. // SetNillableLastUsedAt sets the "last_used_at" field if the given value is not nil.
  265. func (_u *AccountUpdate) SetNillableLastUsedAt(v *time.Time) *AccountUpdate {
  266. if v != nil {
  267. _u.SetLastUsedAt(*v)
  268. }
  269. return _u
  270. }
  271. // ClearLastUsedAt clears the value of the "last_used_at" field.
  272. func (_u *AccountUpdate) ClearLastUsedAt() *AccountUpdate {
  273. _u.mutation.ClearLastUsedAt()
  274. return _u
  275. }
  276. // SetExpiresAt sets the "expires_at" field.
  277. func (_u *AccountUpdate) SetExpiresAt(v time.Time) *AccountUpdate {
  278. _u.mutation.SetExpiresAt(v)
  279. return _u
  280. }
  281. // SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
  282. func (_u *AccountUpdate) SetNillableExpiresAt(v *time.Time) *AccountUpdate {
  283. if v != nil {
  284. _u.SetExpiresAt(*v)
  285. }
  286. return _u
  287. }
  288. // ClearExpiresAt clears the value of the "expires_at" field.
  289. func (_u *AccountUpdate) ClearExpiresAt() *AccountUpdate {
  290. _u.mutation.ClearExpiresAt()
  291. return _u
  292. }
  293. // SetAutoPauseOnExpired sets the "auto_pause_on_expired" field.
  294. func (_u *AccountUpdate) SetAutoPauseOnExpired(v bool) *AccountUpdate {
  295. _u.mutation.SetAutoPauseOnExpired(v)
  296. return _u
  297. }
  298. // SetNillableAutoPauseOnExpired sets the "auto_pause_on_expired" field if the given value is not nil.
  299. func (_u *AccountUpdate) SetNillableAutoPauseOnExpired(v *bool) *AccountUpdate {
  300. if v != nil {
  301. _u.SetAutoPauseOnExpired(*v)
  302. }
  303. return _u
  304. }
  305. // SetSchedulable sets the "schedulable" field.
  306. func (_u *AccountUpdate) SetSchedulable(v bool) *AccountUpdate {
  307. _u.mutation.SetSchedulable(v)
  308. return _u
  309. }
  310. // SetNillableSchedulable sets the "schedulable" field if the given value is not nil.
  311. func (_u *AccountUpdate) SetNillableSchedulable(v *bool) *AccountUpdate {
  312. if v != nil {
  313. _u.SetSchedulable(*v)
  314. }
  315. return _u
  316. }
  317. // SetRateLimitedAt sets the "rate_limited_at" field.
  318. func (_u *AccountUpdate) SetRateLimitedAt(v time.Time) *AccountUpdate {
  319. _u.mutation.SetRateLimitedAt(v)
  320. return _u
  321. }
  322. // SetNillableRateLimitedAt sets the "rate_limited_at" field if the given value is not nil.
  323. func (_u *AccountUpdate) SetNillableRateLimitedAt(v *time.Time) *AccountUpdate {
  324. if v != nil {
  325. _u.SetRateLimitedAt(*v)
  326. }
  327. return _u
  328. }
  329. // ClearRateLimitedAt clears the value of the "rate_limited_at" field.
  330. func (_u *AccountUpdate) ClearRateLimitedAt() *AccountUpdate {
  331. _u.mutation.ClearRateLimitedAt()
  332. return _u
  333. }
  334. // SetRateLimitResetAt sets the "rate_limit_reset_at" field.
  335. func (_u *AccountUpdate) SetRateLimitResetAt(v time.Time) *AccountUpdate {
  336. _u.mutation.SetRateLimitResetAt(v)
  337. return _u
  338. }
  339. // SetNillableRateLimitResetAt sets the "rate_limit_reset_at" field if the given value is not nil.
  340. func (_u *AccountUpdate) SetNillableRateLimitResetAt(v *time.Time) *AccountUpdate {
  341. if v != nil {
  342. _u.SetRateLimitResetAt(*v)
  343. }
  344. return _u
  345. }
  346. // ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
  347. func (_u *AccountUpdate) ClearRateLimitResetAt() *AccountUpdate {
  348. _u.mutation.ClearRateLimitResetAt()
  349. return _u
  350. }
  351. // SetOverloadUntil sets the "overload_until" field.
  352. func (_u *AccountUpdate) SetOverloadUntil(v time.Time) *AccountUpdate {
  353. _u.mutation.SetOverloadUntil(v)
  354. return _u
  355. }
  356. // SetNillableOverloadUntil sets the "overload_until" field if the given value is not nil.
  357. func (_u *AccountUpdate) SetNillableOverloadUntil(v *time.Time) *AccountUpdate {
  358. if v != nil {
  359. _u.SetOverloadUntil(*v)
  360. }
  361. return _u
  362. }
  363. // ClearOverloadUntil clears the value of the "overload_until" field.
  364. func (_u *AccountUpdate) ClearOverloadUntil() *AccountUpdate {
  365. _u.mutation.ClearOverloadUntil()
  366. return _u
  367. }
  368. // SetTempUnschedulableUntil sets the "temp_unschedulable_until" field.
  369. func (_u *AccountUpdate) SetTempUnschedulableUntil(v time.Time) *AccountUpdate {
  370. _u.mutation.SetTempUnschedulableUntil(v)
  371. return _u
  372. }
  373. // SetNillableTempUnschedulableUntil sets the "temp_unschedulable_until" field if the given value is not nil.
  374. func (_u *AccountUpdate) SetNillableTempUnschedulableUntil(v *time.Time) *AccountUpdate {
  375. if v != nil {
  376. _u.SetTempUnschedulableUntil(*v)
  377. }
  378. return _u
  379. }
  380. // ClearTempUnschedulableUntil clears the value of the "temp_unschedulable_until" field.
  381. func (_u *AccountUpdate) ClearTempUnschedulableUntil() *AccountUpdate {
  382. _u.mutation.ClearTempUnschedulableUntil()
  383. return _u
  384. }
  385. // SetTempUnschedulableReason sets the "temp_unschedulable_reason" field.
  386. func (_u *AccountUpdate) SetTempUnschedulableReason(v string) *AccountUpdate {
  387. _u.mutation.SetTempUnschedulableReason(v)
  388. return _u
  389. }
  390. // SetNillableTempUnschedulableReason sets the "temp_unschedulable_reason" field if the given value is not nil.
  391. func (_u *AccountUpdate) SetNillableTempUnschedulableReason(v *string) *AccountUpdate {
  392. if v != nil {
  393. _u.SetTempUnschedulableReason(*v)
  394. }
  395. return _u
  396. }
  397. // ClearTempUnschedulableReason clears the value of the "temp_unschedulable_reason" field.
  398. func (_u *AccountUpdate) ClearTempUnschedulableReason() *AccountUpdate {
  399. _u.mutation.ClearTempUnschedulableReason()
  400. return _u
  401. }
  402. // SetSessionWindowStart sets the "session_window_start" field.
  403. func (_u *AccountUpdate) SetSessionWindowStart(v time.Time) *AccountUpdate {
  404. _u.mutation.SetSessionWindowStart(v)
  405. return _u
  406. }
  407. // SetNillableSessionWindowStart sets the "session_window_start" field if the given value is not nil.
  408. func (_u *AccountUpdate) SetNillableSessionWindowStart(v *time.Time) *AccountUpdate {
  409. if v != nil {
  410. _u.SetSessionWindowStart(*v)
  411. }
  412. return _u
  413. }
  414. // ClearSessionWindowStart clears the value of the "session_window_start" field.
  415. func (_u *AccountUpdate) ClearSessionWindowStart() *AccountUpdate {
  416. _u.mutation.ClearSessionWindowStart()
  417. return _u
  418. }
  419. // SetSessionWindowEnd sets the "session_window_end" field.
  420. func (_u *AccountUpdate) SetSessionWindowEnd(v time.Time) *AccountUpdate {
  421. _u.mutation.SetSessionWindowEnd(v)
  422. return _u
  423. }
  424. // SetNillableSessionWindowEnd sets the "session_window_end" field if the given value is not nil.
  425. func (_u *AccountUpdate) SetNillableSessionWindowEnd(v *time.Time) *AccountUpdate {
  426. if v != nil {
  427. _u.SetSessionWindowEnd(*v)
  428. }
  429. return _u
  430. }
  431. // ClearSessionWindowEnd clears the value of the "session_window_end" field.
  432. func (_u *AccountUpdate) ClearSessionWindowEnd() *AccountUpdate {
  433. _u.mutation.ClearSessionWindowEnd()
  434. return _u
  435. }
  436. // SetSessionWindowStatus sets the "session_window_status" field.
  437. func (_u *AccountUpdate) SetSessionWindowStatus(v string) *AccountUpdate {
  438. _u.mutation.SetSessionWindowStatus(v)
  439. return _u
  440. }
  441. // SetNillableSessionWindowStatus sets the "session_window_status" field if the given value is not nil.
  442. func (_u *AccountUpdate) SetNillableSessionWindowStatus(v *string) *AccountUpdate {
  443. if v != nil {
  444. _u.SetSessionWindowStatus(*v)
  445. }
  446. return _u
  447. }
  448. // ClearSessionWindowStatus clears the value of the "session_window_status" field.
  449. func (_u *AccountUpdate) ClearSessionWindowStatus() *AccountUpdate {
  450. _u.mutation.ClearSessionWindowStatus()
  451. return _u
  452. }
  453. // SetParentAccountID sets the "parent_account_id" field.
  454. func (_u *AccountUpdate) SetParentAccountID(v int64) *AccountUpdate {
  455. _u.mutation.SetParentAccountID(v)
  456. return _u
  457. }
  458. // SetNillableParentAccountID sets the "parent_account_id" field if the given value is not nil.
  459. func (_u *AccountUpdate) SetNillableParentAccountID(v *int64) *AccountUpdate {
  460. if v != nil {
  461. _u.SetParentAccountID(*v)
  462. }
  463. return _u
  464. }
  465. // ClearParentAccountID clears the value of the "parent_account_id" field.
  466. func (_u *AccountUpdate) ClearParentAccountID() *AccountUpdate {
  467. _u.mutation.ClearParentAccountID()
  468. return _u
  469. }
  470. // SetQuotaDimension sets the "quota_dimension" field.
  471. func (_u *AccountUpdate) SetQuotaDimension(v account.QuotaDimension) *AccountUpdate {
  472. _u.mutation.SetQuotaDimension(v)
  473. return _u
  474. }
  475. // SetNillableQuotaDimension sets the "quota_dimension" field if the given value is not nil.
  476. func (_u *AccountUpdate) SetNillableQuotaDimension(v *account.QuotaDimension) *AccountUpdate {
  477. if v != nil {
  478. _u.SetQuotaDimension(*v)
  479. }
  480. return _u
  481. }
  482. // AddGroupIDs adds the "groups" edge to the Group entity by IDs.
  483. func (_u *AccountUpdate) AddGroupIDs(ids ...int64) *AccountUpdate {
  484. _u.mutation.AddGroupIDs(ids...)
  485. return _u
  486. }
  487. // AddGroups adds the "groups" edges to the Group entity.
  488. func (_u *AccountUpdate) AddGroups(v ...*Group) *AccountUpdate {
  489. ids := make([]int64, len(v))
  490. for i := range v {
  491. ids[i] = v[i].ID
  492. }
  493. return _u.AddGroupIDs(ids...)
  494. }
  495. // SetProxy sets the "proxy" edge to the Proxy entity.
  496. func (_u *AccountUpdate) SetProxy(v *Proxy) *AccountUpdate {
  497. return _u.SetProxyID(v.ID)
  498. }
  499. // SetParentID sets the "parent" edge to the Account entity by ID.
  500. func (_u *AccountUpdate) SetParentID(id int64) *AccountUpdate {
  501. _u.mutation.SetParentID(id)
  502. return _u
  503. }
  504. // SetNillableParentID sets the "parent" edge to the Account entity by ID if the given value is not nil.
  505. func (_u *AccountUpdate) SetNillableParentID(id *int64) *AccountUpdate {
  506. if id != nil {
  507. _u = _u.SetParentID(*id)
  508. }
  509. return _u
  510. }
  511. // SetParent sets the "parent" edge to the Account entity.
  512. func (_u *AccountUpdate) SetParent(v *Account) *AccountUpdate {
  513. return _u.SetParentID(v.ID)
  514. }
  515. // AddChildIDs adds the "children" edge to the Account entity by IDs.
  516. func (_u *AccountUpdate) AddChildIDs(ids ...int64) *AccountUpdate {
  517. _u.mutation.AddChildIDs(ids...)
  518. return _u
  519. }
  520. // AddChildren adds the "children" edges to the Account entity.
  521. func (_u *AccountUpdate) AddChildren(v ...*Account) *AccountUpdate {
  522. ids := make([]int64, len(v))
  523. for i := range v {
  524. ids[i] = v[i].ID
  525. }
  526. return _u.AddChildIDs(ids...)
  527. }
  528. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
  529. func (_u *AccountUpdate) AddUsageLogIDs(ids ...int64) *AccountUpdate {
  530. _u.mutation.AddUsageLogIDs(ids...)
  531. return _u
  532. }
  533. // AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
  534. func (_u *AccountUpdate) AddUsageLogs(v ...*UsageLog) *AccountUpdate {
  535. ids := make([]int64, len(v))
  536. for i := range v {
  537. ids[i] = v[i].ID
  538. }
  539. return _u.AddUsageLogIDs(ids...)
  540. }
  541. // Mutation returns the AccountMutation object of the builder.
  542. func (_u *AccountUpdate) Mutation() *AccountMutation {
  543. return _u.mutation
  544. }
  545. // ClearGroups clears all "groups" edges to the Group entity.
  546. func (_u *AccountUpdate) ClearGroups() *AccountUpdate {
  547. _u.mutation.ClearGroups()
  548. return _u
  549. }
  550. // RemoveGroupIDs removes the "groups" edge to Group entities by IDs.
  551. func (_u *AccountUpdate) RemoveGroupIDs(ids ...int64) *AccountUpdate {
  552. _u.mutation.RemoveGroupIDs(ids...)
  553. return _u
  554. }
  555. // RemoveGroups removes "groups" edges to Group entities.
  556. func (_u *AccountUpdate) RemoveGroups(v ...*Group) *AccountUpdate {
  557. ids := make([]int64, len(v))
  558. for i := range v {
  559. ids[i] = v[i].ID
  560. }
  561. return _u.RemoveGroupIDs(ids...)
  562. }
  563. // ClearProxy clears the "proxy" edge to the Proxy entity.
  564. func (_u *AccountUpdate) ClearProxy() *AccountUpdate {
  565. _u.mutation.ClearProxy()
  566. return _u
  567. }
  568. // ClearParent clears the "parent" edge to the Account entity.
  569. func (_u *AccountUpdate) ClearParent() *AccountUpdate {
  570. _u.mutation.ClearParent()
  571. return _u
  572. }
  573. // ClearChildren clears all "children" edges to the Account entity.
  574. func (_u *AccountUpdate) ClearChildren() *AccountUpdate {
  575. _u.mutation.ClearChildren()
  576. return _u
  577. }
  578. // RemoveChildIDs removes the "children" edge to Account entities by IDs.
  579. func (_u *AccountUpdate) RemoveChildIDs(ids ...int64) *AccountUpdate {
  580. _u.mutation.RemoveChildIDs(ids...)
  581. return _u
  582. }
  583. // RemoveChildren removes "children" edges to Account entities.
  584. func (_u *AccountUpdate) RemoveChildren(v ...*Account) *AccountUpdate {
  585. ids := make([]int64, len(v))
  586. for i := range v {
  587. ids[i] = v[i].ID
  588. }
  589. return _u.RemoveChildIDs(ids...)
  590. }
  591. // ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity.
  592. func (_u *AccountUpdate) ClearUsageLogs() *AccountUpdate {
  593. _u.mutation.ClearUsageLogs()
  594. return _u
  595. }
  596. // RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs.
  597. func (_u *AccountUpdate) RemoveUsageLogIDs(ids ...int64) *AccountUpdate {
  598. _u.mutation.RemoveUsageLogIDs(ids...)
  599. return _u
  600. }
  601. // RemoveUsageLogs removes "usage_logs" edges to UsageLog entities.
  602. func (_u *AccountUpdate) RemoveUsageLogs(v ...*UsageLog) *AccountUpdate {
  603. ids := make([]int64, len(v))
  604. for i := range v {
  605. ids[i] = v[i].ID
  606. }
  607. return _u.RemoveUsageLogIDs(ids...)
  608. }
  609. // Save executes the query and returns the number of nodes affected by the update operation.
  610. func (_u *AccountUpdate) Save(ctx context.Context) (int, error) {
  611. if err := _u.defaults(); err != nil {
  612. return 0, err
  613. }
  614. return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
  615. }
  616. // SaveX is like Save, but panics if an error occurs.
  617. func (_u *AccountUpdate) SaveX(ctx context.Context) int {
  618. affected, err := _u.Save(ctx)
  619. if err != nil {
  620. panic(err)
  621. }
  622. return affected
  623. }
  624. // Exec executes the query.
  625. func (_u *AccountUpdate) Exec(ctx context.Context) error {
  626. _, err := _u.Save(ctx)
  627. return err
  628. }
  629. // ExecX is like Exec, but panics if an error occurs.
  630. func (_u *AccountUpdate) ExecX(ctx context.Context) {
  631. if err := _u.Exec(ctx); err != nil {
  632. panic(err)
  633. }
  634. }
  635. // defaults sets the default values of the builder before save.
  636. func (_u *AccountUpdate) defaults() error {
  637. if _, ok := _u.mutation.UpdatedAt(); !ok {
  638. if account.UpdateDefaultUpdatedAt == nil {
  639. return fmt.Errorf("ent: uninitialized account.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  640. }
  641. v := account.UpdateDefaultUpdatedAt()
  642. _u.mutation.SetUpdatedAt(v)
  643. }
  644. return nil
  645. }
  646. // check runs all checks and user-defined validators on the builder.
  647. func (_u *AccountUpdate) check() error {
  648. if v, ok := _u.mutation.Name(); ok {
  649. if err := account.NameValidator(v); err != nil {
  650. return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Account.name": %w`, err)}
  651. }
  652. }
  653. if v, ok := _u.mutation.Platform(); ok {
  654. if err := account.PlatformValidator(v); err != nil {
  655. return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "Account.platform": %w`, err)}
  656. }
  657. }
  658. if v, ok := _u.mutation.GetType(); ok {
  659. if err := account.TypeValidator(v); err != nil {
  660. return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Account.type": %w`, err)}
  661. }
  662. }
  663. if v, ok := _u.mutation.Status(); ok {
  664. if err := account.StatusValidator(v); err != nil {
  665. return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Account.status": %w`, err)}
  666. }
  667. }
  668. if v, ok := _u.mutation.SessionWindowStatus(); ok {
  669. if err := account.SessionWindowStatusValidator(v); err != nil {
  670. return &ValidationError{Name: "session_window_status", err: fmt.Errorf(`ent: validator failed for field "Account.session_window_status": %w`, err)}
  671. }
  672. }
  673. if v, ok := _u.mutation.QuotaDimension(); ok {
  674. if err := account.QuotaDimensionValidator(v); err != nil {
  675. return &ValidationError{Name: "quota_dimension", err: fmt.Errorf(`ent: validator failed for field "Account.quota_dimension": %w`, err)}
  676. }
  677. }
  678. return nil
  679. }
  680. func (_u *AccountUpdate) sqlSave(ctx context.Context) (_node int, err error) {
  681. if err := _u.check(); err != nil {
  682. return _node, err
  683. }
  684. _spec := sqlgraph.NewUpdateSpec(account.Table, account.Columns, sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64))
  685. if ps := _u.mutation.predicates; len(ps) > 0 {
  686. _spec.Predicate = func(selector *sql.Selector) {
  687. for i := range ps {
  688. ps[i](selector)
  689. }
  690. }
  691. }
  692. if value, ok := _u.mutation.UpdatedAt(); ok {
  693. _spec.SetField(account.FieldUpdatedAt, field.TypeTime, value)
  694. }
  695. if value, ok := _u.mutation.DeletedAt(); ok {
  696. _spec.SetField(account.FieldDeletedAt, field.TypeTime, value)
  697. }
  698. if _u.mutation.DeletedAtCleared() {
  699. _spec.ClearField(account.FieldDeletedAt, field.TypeTime)
  700. }
  701. if value, ok := _u.mutation.Name(); ok {
  702. _spec.SetField(account.FieldName, field.TypeString, value)
  703. }
  704. if value, ok := _u.mutation.Notes(); ok {
  705. _spec.SetField(account.FieldNotes, field.TypeString, value)
  706. }
  707. if _u.mutation.NotesCleared() {
  708. _spec.ClearField(account.FieldNotes, field.TypeString)
  709. }
  710. if value, ok := _u.mutation.Platform(); ok {
  711. _spec.SetField(account.FieldPlatform, field.TypeString, value)
  712. }
  713. if value, ok := _u.mutation.GetType(); ok {
  714. _spec.SetField(account.FieldType, field.TypeString, value)
  715. }
  716. if value, ok := _u.mutation.Credentials(); ok {
  717. _spec.SetField(account.FieldCredentials, field.TypeJSON, value)
  718. }
  719. if value, ok := _u.mutation.Extra(); ok {
  720. _spec.SetField(account.FieldExtra, field.TypeJSON, value)
  721. }
  722. if value, ok := _u.mutation.ProxyFallbackOriginID(); ok {
  723. _spec.SetField(account.FieldProxyFallbackOriginID, field.TypeInt64, value)
  724. }
  725. if value, ok := _u.mutation.AddedProxyFallbackOriginID(); ok {
  726. _spec.AddField(account.FieldProxyFallbackOriginID, field.TypeInt64, value)
  727. }
  728. if _u.mutation.ProxyFallbackOriginIDCleared() {
  729. _spec.ClearField(account.FieldProxyFallbackOriginID, field.TypeInt64)
  730. }
  731. if value, ok := _u.mutation.Concurrency(); ok {
  732. _spec.SetField(account.FieldConcurrency, field.TypeInt, value)
  733. }
  734. if value, ok := _u.mutation.AddedConcurrency(); ok {
  735. _spec.AddField(account.FieldConcurrency, field.TypeInt, value)
  736. }
  737. if value, ok := _u.mutation.LoadFactor(); ok {
  738. _spec.SetField(account.FieldLoadFactor, field.TypeInt, value)
  739. }
  740. if value, ok := _u.mutation.AddedLoadFactor(); ok {
  741. _spec.AddField(account.FieldLoadFactor, field.TypeInt, value)
  742. }
  743. if _u.mutation.LoadFactorCleared() {
  744. _spec.ClearField(account.FieldLoadFactor, field.TypeInt)
  745. }
  746. if value, ok := _u.mutation.Priority(); ok {
  747. _spec.SetField(account.FieldPriority, field.TypeInt, value)
  748. }
  749. if value, ok := _u.mutation.AddedPriority(); ok {
  750. _spec.AddField(account.FieldPriority, field.TypeInt, value)
  751. }
  752. if value, ok := _u.mutation.RateMultiplier(); ok {
  753. _spec.SetField(account.FieldRateMultiplier, field.TypeFloat64, value)
  754. }
  755. if value, ok := _u.mutation.AddedRateMultiplier(); ok {
  756. _spec.AddField(account.FieldRateMultiplier, field.TypeFloat64, value)
  757. }
  758. if value, ok := _u.mutation.Status(); ok {
  759. _spec.SetField(account.FieldStatus, field.TypeString, value)
  760. }
  761. if value, ok := _u.mutation.ErrorMessage(); ok {
  762. _spec.SetField(account.FieldErrorMessage, field.TypeString, value)
  763. }
  764. if _u.mutation.ErrorMessageCleared() {
  765. _spec.ClearField(account.FieldErrorMessage, field.TypeString)
  766. }
  767. if value, ok := _u.mutation.LastUsedAt(); ok {
  768. _spec.SetField(account.FieldLastUsedAt, field.TypeTime, value)
  769. }
  770. if _u.mutation.LastUsedAtCleared() {
  771. _spec.ClearField(account.FieldLastUsedAt, field.TypeTime)
  772. }
  773. if value, ok := _u.mutation.ExpiresAt(); ok {
  774. _spec.SetField(account.FieldExpiresAt, field.TypeTime, value)
  775. }
  776. if _u.mutation.ExpiresAtCleared() {
  777. _spec.ClearField(account.FieldExpiresAt, field.TypeTime)
  778. }
  779. if value, ok := _u.mutation.AutoPauseOnExpired(); ok {
  780. _spec.SetField(account.FieldAutoPauseOnExpired, field.TypeBool, value)
  781. }
  782. if value, ok := _u.mutation.Schedulable(); ok {
  783. _spec.SetField(account.FieldSchedulable, field.TypeBool, value)
  784. }
  785. if value, ok := _u.mutation.RateLimitedAt(); ok {
  786. _spec.SetField(account.FieldRateLimitedAt, field.TypeTime, value)
  787. }
  788. if _u.mutation.RateLimitedAtCleared() {
  789. _spec.ClearField(account.FieldRateLimitedAt, field.TypeTime)
  790. }
  791. if value, ok := _u.mutation.RateLimitResetAt(); ok {
  792. _spec.SetField(account.FieldRateLimitResetAt, field.TypeTime, value)
  793. }
  794. if _u.mutation.RateLimitResetAtCleared() {
  795. _spec.ClearField(account.FieldRateLimitResetAt, field.TypeTime)
  796. }
  797. if value, ok := _u.mutation.OverloadUntil(); ok {
  798. _spec.SetField(account.FieldOverloadUntil, field.TypeTime, value)
  799. }
  800. if _u.mutation.OverloadUntilCleared() {
  801. _spec.ClearField(account.FieldOverloadUntil, field.TypeTime)
  802. }
  803. if value, ok := _u.mutation.TempUnschedulableUntil(); ok {
  804. _spec.SetField(account.FieldTempUnschedulableUntil, field.TypeTime, value)
  805. }
  806. if _u.mutation.TempUnschedulableUntilCleared() {
  807. _spec.ClearField(account.FieldTempUnschedulableUntil, field.TypeTime)
  808. }
  809. if value, ok := _u.mutation.TempUnschedulableReason(); ok {
  810. _spec.SetField(account.FieldTempUnschedulableReason, field.TypeString, value)
  811. }
  812. if _u.mutation.TempUnschedulableReasonCleared() {
  813. _spec.ClearField(account.FieldTempUnschedulableReason, field.TypeString)
  814. }
  815. if value, ok := _u.mutation.SessionWindowStart(); ok {
  816. _spec.SetField(account.FieldSessionWindowStart, field.TypeTime, value)
  817. }
  818. if _u.mutation.SessionWindowStartCleared() {
  819. _spec.ClearField(account.FieldSessionWindowStart, field.TypeTime)
  820. }
  821. if value, ok := _u.mutation.SessionWindowEnd(); ok {
  822. _spec.SetField(account.FieldSessionWindowEnd, field.TypeTime, value)
  823. }
  824. if _u.mutation.SessionWindowEndCleared() {
  825. _spec.ClearField(account.FieldSessionWindowEnd, field.TypeTime)
  826. }
  827. if value, ok := _u.mutation.SessionWindowStatus(); ok {
  828. _spec.SetField(account.FieldSessionWindowStatus, field.TypeString, value)
  829. }
  830. if _u.mutation.SessionWindowStatusCleared() {
  831. _spec.ClearField(account.FieldSessionWindowStatus, field.TypeString)
  832. }
  833. if value, ok := _u.mutation.QuotaDimension(); ok {
  834. _spec.SetField(account.FieldQuotaDimension, field.TypeEnum, value)
  835. }
  836. if _u.mutation.GroupsCleared() {
  837. edge := &sqlgraph.EdgeSpec{
  838. Rel: sqlgraph.M2M,
  839. Inverse: false,
  840. Table: account.GroupsTable,
  841. Columns: account.GroupsPrimaryKey,
  842. Bidi: false,
  843. Target: &sqlgraph.EdgeTarget{
  844. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  845. },
  846. }
  847. createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
  848. createE.defaults()
  849. _, specE := createE.createSpec()
  850. edge.Target.Fields = specE.Fields
  851. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  852. }
  853. if nodes := _u.mutation.RemovedGroupsIDs(); len(nodes) > 0 && !_u.mutation.GroupsCleared() {
  854. edge := &sqlgraph.EdgeSpec{
  855. Rel: sqlgraph.M2M,
  856. Inverse: false,
  857. Table: account.GroupsTable,
  858. Columns: account.GroupsPrimaryKey,
  859. Bidi: false,
  860. Target: &sqlgraph.EdgeTarget{
  861. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  862. },
  863. }
  864. for _, k := range nodes {
  865. edge.Target.Nodes = append(edge.Target.Nodes, k)
  866. }
  867. createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
  868. createE.defaults()
  869. _, specE := createE.createSpec()
  870. edge.Target.Fields = specE.Fields
  871. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  872. }
  873. if nodes := _u.mutation.GroupsIDs(); len(nodes) > 0 {
  874. edge := &sqlgraph.EdgeSpec{
  875. Rel: sqlgraph.M2M,
  876. Inverse: false,
  877. Table: account.GroupsTable,
  878. Columns: account.GroupsPrimaryKey,
  879. Bidi: false,
  880. Target: &sqlgraph.EdgeTarget{
  881. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  882. },
  883. }
  884. for _, k := range nodes {
  885. edge.Target.Nodes = append(edge.Target.Nodes, k)
  886. }
  887. createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
  888. createE.defaults()
  889. _, specE := createE.createSpec()
  890. edge.Target.Fields = specE.Fields
  891. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  892. }
  893. if _u.mutation.ProxyCleared() {
  894. edge := &sqlgraph.EdgeSpec{
  895. Rel: sqlgraph.M2O,
  896. Inverse: false,
  897. Table: account.ProxyTable,
  898. Columns: []string{account.ProxyColumn},
  899. Bidi: false,
  900. Target: &sqlgraph.EdgeTarget{
  901. IDSpec: sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64),
  902. },
  903. }
  904. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  905. }
  906. if nodes := _u.mutation.ProxyIDs(); len(nodes) > 0 {
  907. edge := &sqlgraph.EdgeSpec{
  908. Rel: sqlgraph.M2O,
  909. Inverse: false,
  910. Table: account.ProxyTable,
  911. Columns: []string{account.ProxyColumn},
  912. Bidi: false,
  913. Target: &sqlgraph.EdgeTarget{
  914. IDSpec: sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64),
  915. },
  916. }
  917. for _, k := range nodes {
  918. edge.Target.Nodes = append(edge.Target.Nodes, k)
  919. }
  920. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  921. }
  922. if _u.mutation.ParentCleared() {
  923. edge := &sqlgraph.EdgeSpec{
  924. Rel: sqlgraph.M2O,
  925. Inverse: true,
  926. Table: account.ParentTable,
  927. Columns: []string{account.ParentColumn},
  928. Bidi: false,
  929. Target: &sqlgraph.EdgeTarget{
  930. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  931. },
  932. }
  933. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  934. }
  935. if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 {
  936. edge := &sqlgraph.EdgeSpec{
  937. Rel: sqlgraph.M2O,
  938. Inverse: true,
  939. Table: account.ParentTable,
  940. Columns: []string{account.ParentColumn},
  941. Bidi: false,
  942. Target: &sqlgraph.EdgeTarget{
  943. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  944. },
  945. }
  946. for _, k := range nodes {
  947. edge.Target.Nodes = append(edge.Target.Nodes, k)
  948. }
  949. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  950. }
  951. if _u.mutation.ChildrenCleared() {
  952. edge := &sqlgraph.EdgeSpec{
  953. Rel: sqlgraph.O2M,
  954. Inverse: false,
  955. Table: account.ChildrenTable,
  956. Columns: []string{account.ChildrenColumn},
  957. Bidi: false,
  958. Target: &sqlgraph.EdgeTarget{
  959. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  960. },
  961. }
  962. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  963. }
  964. if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() {
  965. edge := &sqlgraph.EdgeSpec{
  966. Rel: sqlgraph.O2M,
  967. Inverse: false,
  968. Table: account.ChildrenTable,
  969. Columns: []string{account.ChildrenColumn},
  970. Bidi: false,
  971. Target: &sqlgraph.EdgeTarget{
  972. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  973. },
  974. }
  975. for _, k := range nodes {
  976. edge.Target.Nodes = append(edge.Target.Nodes, k)
  977. }
  978. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  979. }
  980. if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 {
  981. edge := &sqlgraph.EdgeSpec{
  982. Rel: sqlgraph.O2M,
  983. Inverse: false,
  984. Table: account.ChildrenTable,
  985. Columns: []string{account.ChildrenColumn},
  986. Bidi: false,
  987. Target: &sqlgraph.EdgeTarget{
  988. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  989. },
  990. }
  991. for _, k := range nodes {
  992. edge.Target.Nodes = append(edge.Target.Nodes, k)
  993. }
  994. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  995. }
  996. if _u.mutation.UsageLogsCleared() {
  997. edge := &sqlgraph.EdgeSpec{
  998. Rel: sqlgraph.O2M,
  999. Inverse: false,
  1000. Table: account.UsageLogsTable,
  1001. Columns: []string{account.UsageLogsColumn},
  1002. Bidi: false,
  1003. Target: &sqlgraph.EdgeTarget{
  1004. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  1005. },
  1006. }
  1007. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1008. }
  1009. if nodes := _u.mutation.RemovedUsageLogsIDs(); len(nodes) > 0 && !_u.mutation.UsageLogsCleared() {
  1010. edge := &sqlgraph.EdgeSpec{
  1011. Rel: sqlgraph.O2M,
  1012. Inverse: false,
  1013. Table: account.UsageLogsTable,
  1014. Columns: []string{account.UsageLogsColumn},
  1015. Bidi: false,
  1016. Target: &sqlgraph.EdgeTarget{
  1017. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  1018. },
  1019. }
  1020. for _, k := range nodes {
  1021. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1022. }
  1023. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1024. }
  1025. if nodes := _u.mutation.UsageLogsIDs(); len(nodes) > 0 {
  1026. edge := &sqlgraph.EdgeSpec{
  1027. Rel: sqlgraph.O2M,
  1028. Inverse: false,
  1029. Table: account.UsageLogsTable,
  1030. Columns: []string{account.UsageLogsColumn},
  1031. Bidi: false,
  1032. Target: &sqlgraph.EdgeTarget{
  1033. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  1034. },
  1035. }
  1036. for _, k := range nodes {
  1037. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1038. }
  1039. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1040. }
  1041. if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
  1042. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  1043. err = &NotFoundError{account.Label}
  1044. } else if sqlgraph.IsConstraintError(err) {
  1045. err = &ConstraintError{msg: err.Error(), wrap: err}
  1046. }
  1047. return 0, err
  1048. }
  1049. _u.mutation.done = true
  1050. return _node, nil
  1051. }
  1052. // AccountUpdateOne is the builder for updating a single Account entity.
  1053. type AccountUpdateOne struct {
  1054. config
  1055. fields []string
  1056. hooks []Hook
  1057. mutation *AccountMutation
  1058. }
  1059. // SetUpdatedAt sets the "updated_at" field.
  1060. func (_u *AccountUpdateOne) SetUpdatedAt(v time.Time) *AccountUpdateOne {
  1061. _u.mutation.SetUpdatedAt(v)
  1062. return _u
  1063. }
  1064. // SetDeletedAt sets the "deleted_at" field.
  1065. func (_u *AccountUpdateOne) SetDeletedAt(v time.Time) *AccountUpdateOne {
  1066. _u.mutation.SetDeletedAt(v)
  1067. return _u
  1068. }
  1069. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  1070. func (_u *AccountUpdateOne) SetNillableDeletedAt(v *time.Time) *AccountUpdateOne {
  1071. if v != nil {
  1072. _u.SetDeletedAt(*v)
  1073. }
  1074. return _u
  1075. }
  1076. // ClearDeletedAt clears the value of the "deleted_at" field.
  1077. func (_u *AccountUpdateOne) ClearDeletedAt() *AccountUpdateOne {
  1078. _u.mutation.ClearDeletedAt()
  1079. return _u
  1080. }
  1081. // SetName sets the "name" field.
  1082. func (_u *AccountUpdateOne) SetName(v string) *AccountUpdateOne {
  1083. _u.mutation.SetName(v)
  1084. return _u
  1085. }
  1086. // SetNillableName sets the "name" field if the given value is not nil.
  1087. func (_u *AccountUpdateOne) SetNillableName(v *string) *AccountUpdateOne {
  1088. if v != nil {
  1089. _u.SetName(*v)
  1090. }
  1091. return _u
  1092. }
  1093. // SetNotes sets the "notes" field.
  1094. func (_u *AccountUpdateOne) SetNotes(v string) *AccountUpdateOne {
  1095. _u.mutation.SetNotes(v)
  1096. return _u
  1097. }
  1098. // SetNillableNotes sets the "notes" field if the given value is not nil.
  1099. func (_u *AccountUpdateOne) SetNillableNotes(v *string) *AccountUpdateOne {
  1100. if v != nil {
  1101. _u.SetNotes(*v)
  1102. }
  1103. return _u
  1104. }
  1105. // ClearNotes clears the value of the "notes" field.
  1106. func (_u *AccountUpdateOne) ClearNotes() *AccountUpdateOne {
  1107. _u.mutation.ClearNotes()
  1108. return _u
  1109. }
  1110. // SetPlatform sets the "platform" field.
  1111. func (_u *AccountUpdateOne) SetPlatform(v string) *AccountUpdateOne {
  1112. _u.mutation.SetPlatform(v)
  1113. return _u
  1114. }
  1115. // SetNillablePlatform sets the "platform" field if the given value is not nil.
  1116. func (_u *AccountUpdateOne) SetNillablePlatform(v *string) *AccountUpdateOne {
  1117. if v != nil {
  1118. _u.SetPlatform(*v)
  1119. }
  1120. return _u
  1121. }
  1122. // SetType sets the "type" field.
  1123. func (_u *AccountUpdateOne) SetType(v string) *AccountUpdateOne {
  1124. _u.mutation.SetType(v)
  1125. return _u
  1126. }
  1127. // SetNillableType sets the "type" field if the given value is not nil.
  1128. func (_u *AccountUpdateOne) SetNillableType(v *string) *AccountUpdateOne {
  1129. if v != nil {
  1130. _u.SetType(*v)
  1131. }
  1132. return _u
  1133. }
  1134. // SetCredentials sets the "credentials" field.
  1135. func (_u *AccountUpdateOne) SetCredentials(v map[string]interface{}) *AccountUpdateOne {
  1136. _u.mutation.SetCredentials(v)
  1137. return _u
  1138. }
  1139. // SetExtra sets the "extra" field.
  1140. func (_u *AccountUpdateOne) SetExtra(v map[string]interface{}) *AccountUpdateOne {
  1141. _u.mutation.SetExtra(v)
  1142. return _u
  1143. }
  1144. // SetProxyID sets the "proxy_id" field.
  1145. func (_u *AccountUpdateOne) SetProxyID(v int64) *AccountUpdateOne {
  1146. _u.mutation.SetProxyID(v)
  1147. return _u
  1148. }
  1149. // SetNillableProxyID sets the "proxy_id" field if the given value is not nil.
  1150. func (_u *AccountUpdateOne) SetNillableProxyID(v *int64) *AccountUpdateOne {
  1151. if v != nil {
  1152. _u.SetProxyID(*v)
  1153. }
  1154. return _u
  1155. }
  1156. // ClearProxyID clears the value of the "proxy_id" field.
  1157. func (_u *AccountUpdateOne) ClearProxyID() *AccountUpdateOne {
  1158. _u.mutation.ClearProxyID()
  1159. return _u
  1160. }
  1161. // SetProxyFallbackOriginID sets the "proxy_fallback_origin_id" field.
  1162. func (_u *AccountUpdateOne) SetProxyFallbackOriginID(v int64) *AccountUpdateOne {
  1163. _u.mutation.ResetProxyFallbackOriginID()
  1164. _u.mutation.SetProxyFallbackOriginID(v)
  1165. return _u
  1166. }
  1167. // SetNillableProxyFallbackOriginID sets the "proxy_fallback_origin_id" field if the given value is not nil.
  1168. func (_u *AccountUpdateOne) SetNillableProxyFallbackOriginID(v *int64) *AccountUpdateOne {
  1169. if v != nil {
  1170. _u.SetProxyFallbackOriginID(*v)
  1171. }
  1172. return _u
  1173. }
  1174. // AddProxyFallbackOriginID adds value to the "proxy_fallback_origin_id" field.
  1175. func (_u *AccountUpdateOne) AddProxyFallbackOriginID(v int64) *AccountUpdateOne {
  1176. _u.mutation.AddProxyFallbackOriginID(v)
  1177. return _u
  1178. }
  1179. // ClearProxyFallbackOriginID clears the value of the "proxy_fallback_origin_id" field.
  1180. func (_u *AccountUpdateOne) ClearProxyFallbackOriginID() *AccountUpdateOne {
  1181. _u.mutation.ClearProxyFallbackOriginID()
  1182. return _u
  1183. }
  1184. // SetConcurrency sets the "concurrency" field.
  1185. func (_u *AccountUpdateOne) SetConcurrency(v int) *AccountUpdateOne {
  1186. _u.mutation.ResetConcurrency()
  1187. _u.mutation.SetConcurrency(v)
  1188. return _u
  1189. }
  1190. // SetNillableConcurrency sets the "concurrency" field if the given value is not nil.
  1191. func (_u *AccountUpdateOne) SetNillableConcurrency(v *int) *AccountUpdateOne {
  1192. if v != nil {
  1193. _u.SetConcurrency(*v)
  1194. }
  1195. return _u
  1196. }
  1197. // AddConcurrency adds value to the "concurrency" field.
  1198. func (_u *AccountUpdateOne) AddConcurrency(v int) *AccountUpdateOne {
  1199. _u.mutation.AddConcurrency(v)
  1200. return _u
  1201. }
  1202. // SetLoadFactor sets the "load_factor" field.
  1203. func (_u *AccountUpdateOne) SetLoadFactor(v int) *AccountUpdateOne {
  1204. _u.mutation.ResetLoadFactor()
  1205. _u.mutation.SetLoadFactor(v)
  1206. return _u
  1207. }
  1208. // SetNillableLoadFactor sets the "load_factor" field if the given value is not nil.
  1209. func (_u *AccountUpdateOne) SetNillableLoadFactor(v *int) *AccountUpdateOne {
  1210. if v != nil {
  1211. _u.SetLoadFactor(*v)
  1212. }
  1213. return _u
  1214. }
  1215. // AddLoadFactor adds value to the "load_factor" field.
  1216. func (_u *AccountUpdateOne) AddLoadFactor(v int) *AccountUpdateOne {
  1217. _u.mutation.AddLoadFactor(v)
  1218. return _u
  1219. }
  1220. // ClearLoadFactor clears the value of the "load_factor" field.
  1221. func (_u *AccountUpdateOne) ClearLoadFactor() *AccountUpdateOne {
  1222. _u.mutation.ClearLoadFactor()
  1223. return _u
  1224. }
  1225. // SetPriority sets the "priority" field.
  1226. func (_u *AccountUpdateOne) SetPriority(v int) *AccountUpdateOne {
  1227. _u.mutation.ResetPriority()
  1228. _u.mutation.SetPriority(v)
  1229. return _u
  1230. }
  1231. // SetNillablePriority sets the "priority" field if the given value is not nil.
  1232. func (_u *AccountUpdateOne) SetNillablePriority(v *int) *AccountUpdateOne {
  1233. if v != nil {
  1234. _u.SetPriority(*v)
  1235. }
  1236. return _u
  1237. }
  1238. // AddPriority adds value to the "priority" field.
  1239. func (_u *AccountUpdateOne) AddPriority(v int) *AccountUpdateOne {
  1240. _u.mutation.AddPriority(v)
  1241. return _u
  1242. }
  1243. // SetRateMultiplier sets the "rate_multiplier" field.
  1244. func (_u *AccountUpdateOne) SetRateMultiplier(v float64) *AccountUpdateOne {
  1245. _u.mutation.ResetRateMultiplier()
  1246. _u.mutation.SetRateMultiplier(v)
  1247. return _u
  1248. }
  1249. // SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
  1250. func (_u *AccountUpdateOne) SetNillableRateMultiplier(v *float64) *AccountUpdateOne {
  1251. if v != nil {
  1252. _u.SetRateMultiplier(*v)
  1253. }
  1254. return _u
  1255. }
  1256. // AddRateMultiplier adds value to the "rate_multiplier" field.
  1257. func (_u *AccountUpdateOne) AddRateMultiplier(v float64) *AccountUpdateOne {
  1258. _u.mutation.AddRateMultiplier(v)
  1259. return _u
  1260. }
  1261. // SetStatus sets the "status" field.
  1262. func (_u *AccountUpdateOne) SetStatus(v string) *AccountUpdateOne {
  1263. _u.mutation.SetStatus(v)
  1264. return _u
  1265. }
  1266. // SetNillableStatus sets the "status" field if the given value is not nil.
  1267. func (_u *AccountUpdateOne) SetNillableStatus(v *string) *AccountUpdateOne {
  1268. if v != nil {
  1269. _u.SetStatus(*v)
  1270. }
  1271. return _u
  1272. }
  1273. // SetErrorMessage sets the "error_message" field.
  1274. func (_u *AccountUpdateOne) SetErrorMessage(v string) *AccountUpdateOne {
  1275. _u.mutation.SetErrorMessage(v)
  1276. return _u
  1277. }
  1278. // SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
  1279. func (_u *AccountUpdateOne) SetNillableErrorMessage(v *string) *AccountUpdateOne {
  1280. if v != nil {
  1281. _u.SetErrorMessage(*v)
  1282. }
  1283. return _u
  1284. }
  1285. // ClearErrorMessage clears the value of the "error_message" field.
  1286. func (_u *AccountUpdateOne) ClearErrorMessage() *AccountUpdateOne {
  1287. _u.mutation.ClearErrorMessage()
  1288. return _u
  1289. }
  1290. // SetLastUsedAt sets the "last_used_at" field.
  1291. func (_u *AccountUpdateOne) SetLastUsedAt(v time.Time) *AccountUpdateOne {
  1292. _u.mutation.SetLastUsedAt(v)
  1293. return _u
  1294. }
  1295. // SetNillableLastUsedAt sets the "last_used_at" field if the given value is not nil.
  1296. func (_u *AccountUpdateOne) SetNillableLastUsedAt(v *time.Time) *AccountUpdateOne {
  1297. if v != nil {
  1298. _u.SetLastUsedAt(*v)
  1299. }
  1300. return _u
  1301. }
  1302. // ClearLastUsedAt clears the value of the "last_used_at" field.
  1303. func (_u *AccountUpdateOne) ClearLastUsedAt() *AccountUpdateOne {
  1304. _u.mutation.ClearLastUsedAt()
  1305. return _u
  1306. }
  1307. // SetExpiresAt sets the "expires_at" field.
  1308. func (_u *AccountUpdateOne) SetExpiresAt(v time.Time) *AccountUpdateOne {
  1309. _u.mutation.SetExpiresAt(v)
  1310. return _u
  1311. }
  1312. // SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
  1313. func (_u *AccountUpdateOne) SetNillableExpiresAt(v *time.Time) *AccountUpdateOne {
  1314. if v != nil {
  1315. _u.SetExpiresAt(*v)
  1316. }
  1317. return _u
  1318. }
  1319. // ClearExpiresAt clears the value of the "expires_at" field.
  1320. func (_u *AccountUpdateOne) ClearExpiresAt() *AccountUpdateOne {
  1321. _u.mutation.ClearExpiresAt()
  1322. return _u
  1323. }
  1324. // SetAutoPauseOnExpired sets the "auto_pause_on_expired" field.
  1325. func (_u *AccountUpdateOne) SetAutoPauseOnExpired(v bool) *AccountUpdateOne {
  1326. _u.mutation.SetAutoPauseOnExpired(v)
  1327. return _u
  1328. }
  1329. // SetNillableAutoPauseOnExpired sets the "auto_pause_on_expired" field if the given value is not nil.
  1330. func (_u *AccountUpdateOne) SetNillableAutoPauseOnExpired(v *bool) *AccountUpdateOne {
  1331. if v != nil {
  1332. _u.SetAutoPauseOnExpired(*v)
  1333. }
  1334. return _u
  1335. }
  1336. // SetSchedulable sets the "schedulable" field.
  1337. func (_u *AccountUpdateOne) SetSchedulable(v bool) *AccountUpdateOne {
  1338. _u.mutation.SetSchedulable(v)
  1339. return _u
  1340. }
  1341. // SetNillableSchedulable sets the "schedulable" field if the given value is not nil.
  1342. func (_u *AccountUpdateOne) SetNillableSchedulable(v *bool) *AccountUpdateOne {
  1343. if v != nil {
  1344. _u.SetSchedulable(*v)
  1345. }
  1346. return _u
  1347. }
  1348. // SetRateLimitedAt sets the "rate_limited_at" field.
  1349. func (_u *AccountUpdateOne) SetRateLimitedAt(v time.Time) *AccountUpdateOne {
  1350. _u.mutation.SetRateLimitedAt(v)
  1351. return _u
  1352. }
  1353. // SetNillableRateLimitedAt sets the "rate_limited_at" field if the given value is not nil.
  1354. func (_u *AccountUpdateOne) SetNillableRateLimitedAt(v *time.Time) *AccountUpdateOne {
  1355. if v != nil {
  1356. _u.SetRateLimitedAt(*v)
  1357. }
  1358. return _u
  1359. }
  1360. // ClearRateLimitedAt clears the value of the "rate_limited_at" field.
  1361. func (_u *AccountUpdateOne) ClearRateLimitedAt() *AccountUpdateOne {
  1362. _u.mutation.ClearRateLimitedAt()
  1363. return _u
  1364. }
  1365. // SetRateLimitResetAt sets the "rate_limit_reset_at" field.
  1366. func (_u *AccountUpdateOne) SetRateLimitResetAt(v time.Time) *AccountUpdateOne {
  1367. _u.mutation.SetRateLimitResetAt(v)
  1368. return _u
  1369. }
  1370. // SetNillableRateLimitResetAt sets the "rate_limit_reset_at" field if the given value is not nil.
  1371. func (_u *AccountUpdateOne) SetNillableRateLimitResetAt(v *time.Time) *AccountUpdateOne {
  1372. if v != nil {
  1373. _u.SetRateLimitResetAt(*v)
  1374. }
  1375. return _u
  1376. }
  1377. // ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
  1378. func (_u *AccountUpdateOne) ClearRateLimitResetAt() *AccountUpdateOne {
  1379. _u.mutation.ClearRateLimitResetAt()
  1380. return _u
  1381. }
  1382. // SetOverloadUntil sets the "overload_until" field.
  1383. func (_u *AccountUpdateOne) SetOverloadUntil(v time.Time) *AccountUpdateOne {
  1384. _u.mutation.SetOverloadUntil(v)
  1385. return _u
  1386. }
  1387. // SetNillableOverloadUntil sets the "overload_until" field if the given value is not nil.
  1388. func (_u *AccountUpdateOne) SetNillableOverloadUntil(v *time.Time) *AccountUpdateOne {
  1389. if v != nil {
  1390. _u.SetOverloadUntil(*v)
  1391. }
  1392. return _u
  1393. }
  1394. // ClearOverloadUntil clears the value of the "overload_until" field.
  1395. func (_u *AccountUpdateOne) ClearOverloadUntil() *AccountUpdateOne {
  1396. _u.mutation.ClearOverloadUntil()
  1397. return _u
  1398. }
  1399. // SetTempUnschedulableUntil sets the "temp_unschedulable_until" field.
  1400. func (_u *AccountUpdateOne) SetTempUnschedulableUntil(v time.Time) *AccountUpdateOne {
  1401. _u.mutation.SetTempUnschedulableUntil(v)
  1402. return _u
  1403. }
  1404. // SetNillableTempUnschedulableUntil sets the "temp_unschedulable_until" field if the given value is not nil.
  1405. func (_u *AccountUpdateOne) SetNillableTempUnschedulableUntil(v *time.Time) *AccountUpdateOne {
  1406. if v != nil {
  1407. _u.SetTempUnschedulableUntil(*v)
  1408. }
  1409. return _u
  1410. }
  1411. // ClearTempUnschedulableUntil clears the value of the "temp_unschedulable_until" field.
  1412. func (_u *AccountUpdateOne) ClearTempUnschedulableUntil() *AccountUpdateOne {
  1413. _u.mutation.ClearTempUnschedulableUntil()
  1414. return _u
  1415. }
  1416. // SetTempUnschedulableReason sets the "temp_unschedulable_reason" field.
  1417. func (_u *AccountUpdateOne) SetTempUnschedulableReason(v string) *AccountUpdateOne {
  1418. _u.mutation.SetTempUnschedulableReason(v)
  1419. return _u
  1420. }
  1421. // SetNillableTempUnschedulableReason sets the "temp_unschedulable_reason" field if the given value is not nil.
  1422. func (_u *AccountUpdateOne) SetNillableTempUnschedulableReason(v *string) *AccountUpdateOne {
  1423. if v != nil {
  1424. _u.SetTempUnschedulableReason(*v)
  1425. }
  1426. return _u
  1427. }
  1428. // ClearTempUnschedulableReason clears the value of the "temp_unschedulable_reason" field.
  1429. func (_u *AccountUpdateOne) ClearTempUnschedulableReason() *AccountUpdateOne {
  1430. _u.mutation.ClearTempUnschedulableReason()
  1431. return _u
  1432. }
  1433. // SetSessionWindowStart sets the "session_window_start" field.
  1434. func (_u *AccountUpdateOne) SetSessionWindowStart(v time.Time) *AccountUpdateOne {
  1435. _u.mutation.SetSessionWindowStart(v)
  1436. return _u
  1437. }
  1438. // SetNillableSessionWindowStart sets the "session_window_start" field if the given value is not nil.
  1439. func (_u *AccountUpdateOne) SetNillableSessionWindowStart(v *time.Time) *AccountUpdateOne {
  1440. if v != nil {
  1441. _u.SetSessionWindowStart(*v)
  1442. }
  1443. return _u
  1444. }
  1445. // ClearSessionWindowStart clears the value of the "session_window_start" field.
  1446. func (_u *AccountUpdateOne) ClearSessionWindowStart() *AccountUpdateOne {
  1447. _u.mutation.ClearSessionWindowStart()
  1448. return _u
  1449. }
  1450. // SetSessionWindowEnd sets the "session_window_end" field.
  1451. func (_u *AccountUpdateOne) SetSessionWindowEnd(v time.Time) *AccountUpdateOne {
  1452. _u.mutation.SetSessionWindowEnd(v)
  1453. return _u
  1454. }
  1455. // SetNillableSessionWindowEnd sets the "session_window_end" field if the given value is not nil.
  1456. func (_u *AccountUpdateOne) SetNillableSessionWindowEnd(v *time.Time) *AccountUpdateOne {
  1457. if v != nil {
  1458. _u.SetSessionWindowEnd(*v)
  1459. }
  1460. return _u
  1461. }
  1462. // ClearSessionWindowEnd clears the value of the "session_window_end" field.
  1463. func (_u *AccountUpdateOne) ClearSessionWindowEnd() *AccountUpdateOne {
  1464. _u.mutation.ClearSessionWindowEnd()
  1465. return _u
  1466. }
  1467. // SetSessionWindowStatus sets the "session_window_status" field.
  1468. func (_u *AccountUpdateOne) SetSessionWindowStatus(v string) *AccountUpdateOne {
  1469. _u.mutation.SetSessionWindowStatus(v)
  1470. return _u
  1471. }
  1472. // SetNillableSessionWindowStatus sets the "session_window_status" field if the given value is not nil.
  1473. func (_u *AccountUpdateOne) SetNillableSessionWindowStatus(v *string) *AccountUpdateOne {
  1474. if v != nil {
  1475. _u.SetSessionWindowStatus(*v)
  1476. }
  1477. return _u
  1478. }
  1479. // ClearSessionWindowStatus clears the value of the "session_window_status" field.
  1480. func (_u *AccountUpdateOne) ClearSessionWindowStatus() *AccountUpdateOne {
  1481. _u.mutation.ClearSessionWindowStatus()
  1482. return _u
  1483. }
  1484. // SetParentAccountID sets the "parent_account_id" field.
  1485. func (_u *AccountUpdateOne) SetParentAccountID(v int64) *AccountUpdateOne {
  1486. _u.mutation.SetParentAccountID(v)
  1487. return _u
  1488. }
  1489. // SetNillableParentAccountID sets the "parent_account_id" field if the given value is not nil.
  1490. func (_u *AccountUpdateOne) SetNillableParentAccountID(v *int64) *AccountUpdateOne {
  1491. if v != nil {
  1492. _u.SetParentAccountID(*v)
  1493. }
  1494. return _u
  1495. }
  1496. // ClearParentAccountID clears the value of the "parent_account_id" field.
  1497. func (_u *AccountUpdateOne) ClearParentAccountID() *AccountUpdateOne {
  1498. _u.mutation.ClearParentAccountID()
  1499. return _u
  1500. }
  1501. // SetQuotaDimension sets the "quota_dimension" field.
  1502. func (_u *AccountUpdateOne) SetQuotaDimension(v account.QuotaDimension) *AccountUpdateOne {
  1503. _u.mutation.SetQuotaDimension(v)
  1504. return _u
  1505. }
  1506. // SetNillableQuotaDimension sets the "quota_dimension" field if the given value is not nil.
  1507. func (_u *AccountUpdateOne) SetNillableQuotaDimension(v *account.QuotaDimension) *AccountUpdateOne {
  1508. if v != nil {
  1509. _u.SetQuotaDimension(*v)
  1510. }
  1511. return _u
  1512. }
  1513. // AddGroupIDs adds the "groups" edge to the Group entity by IDs.
  1514. func (_u *AccountUpdateOne) AddGroupIDs(ids ...int64) *AccountUpdateOne {
  1515. _u.mutation.AddGroupIDs(ids...)
  1516. return _u
  1517. }
  1518. // AddGroups adds the "groups" edges to the Group entity.
  1519. func (_u *AccountUpdateOne) AddGroups(v ...*Group) *AccountUpdateOne {
  1520. ids := make([]int64, len(v))
  1521. for i := range v {
  1522. ids[i] = v[i].ID
  1523. }
  1524. return _u.AddGroupIDs(ids...)
  1525. }
  1526. // SetProxy sets the "proxy" edge to the Proxy entity.
  1527. func (_u *AccountUpdateOne) SetProxy(v *Proxy) *AccountUpdateOne {
  1528. return _u.SetProxyID(v.ID)
  1529. }
  1530. // SetParentID sets the "parent" edge to the Account entity by ID.
  1531. func (_u *AccountUpdateOne) SetParentID(id int64) *AccountUpdateOne {
  1532. _u.mutation.SetParentID(id)
  1533. return _u
  1534. }
  1535. // SetNillableParentID sets the "parent" edge to the Account entity by ID if the given value is not nil.
  1536. func (_u *AccountUpdateOne) SetNillableParentID(id *int64) *AccountUpdateOne {
  1537. if id != nil {
  1538. _u = _u.SetParentID(*id)
  1539. }
  1540. return _u
  1541. }
  1542. // SetParent sets the "parent" edge to the Account entity.
  1543. func (_u *AccountUpdateOne) SetParent(v *Account) *AccountUpdateOne {
  1544. return _u.SetParentID(v.ID)
  1545. }
  1546. // AddChildIDs adds the "children" edge to the Account entity by IDs.
  1547. func (_u *AccountUpdateOne) AddChildIDs(ids ...int64) *AccountUpdateOne {
  1548. _u.mutation.AddChildIDs(ids...)
  1549. return _u
  1550. }
  1551. // AddChildren adds the "children" edges to the Account entity.
  1552. func (_u *AccountUpdateOne) AddChildren(v ...*Account) *AccountUpdateOne {
  1553. ids := make([]int64, len(v))
  1554. for i := range v {
  1555. ids[i] = v[i].ID
  1556. }
  1557. return _u.AddChildIDs(ids...)
  1558. }
  1559. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
  1560. func (_u *AccountUpdateOne) AddUsageLogIDs(ids ...int64) *AccountUpdateOne {
  1561. _u.mutation.AddUsageLogIDs(ids...)
  1562. return _u
  1563. }
  1564. // AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
  1565. func (_u *AccountUpdateOne) AddUsageLogs(v ...*UsageLog) *AccountUpdateOne {
  1566. ids := make([]int64, len(v))
  1567. for i := range v {
  1568. ids[i] = v[i].ID
  1569. }
  1570. return _u.AddUsageLogIDs(ids...)
  1571. }
  1572. // Mutation returns the AccountMutation object of the builder.
  1573. func (_u *AccountUpdateOne) Mutation() *AccountMutation {
  1574. return _u.mutation
  1575. }
  1576. // ClearGroups clears all "groups" edges to the Group entity.
  1577. func (_u *AccountUpdateOne) ClearGroups() *AccountUpdateOne {
  1578. _u.mutation.ClearGroups()
  1579. return _u
  1580. }
  1581. // RemoveGroupIDs removes the "groups" edge to Group entities by IDs.
  1582. func (_u *AccountUpdateOne) RemoveGroupIDs(ids ...int64) *AccountUpdateOne {
  1583. _u.mutation.RemoveGroupIDs(ids...)
  1584. return _u
  1585. }
  1586. // RemoveGroups removes "groups" edges to Group entities.
  1587. func (_u *AccountUpdateOne) RemoveGroups(v ...*Group) *AccountUpdateOne {
  1588. ids := make([]int64, len(v))
  1589. for i := range v {
  1590. ids[i] = v[i].ID
  1591. }
  1592. return _u.RemoveGroupIDs(ids...)
  1593. }
  1594. // ClearProxy clears the "proxy" edge to the Proxy entity.
  1595. func (_u *AccountUpdateOne) ClearProxy() *AccountUpdateOne {
  1596. _u.mutation.ClearProxy()
  1597. return _u
  1598. }
  1599. // ClearParent clears the "parent" edge to the Account entity.
  1600. func (_u *AccountUpdateOne) ClearParent() *AccountUpdateOne {
  1601. _u.mutation.ClearParent()
  1602. return _u
  1603. }
  1604. // ClearChildren clears all "children" edges to the Account entity.
  1605. func (_u *AccountUpdateOne) ClearChildren() *AccountUpdateOne {
  1606. _u.mutation.ClearChildren()
  1607. return _u
  1608. }
  1609. // RemoveChildIDs removes the "children" edge to Account entities by IDs.
  1610. func (_u *AccountUpdateOne) RemoveChildIDs(ids ...int64) *AccountUpdateOne {
  1611. _u.mutation.RemoveChildIDs(ids...)
  1612. return _u
  1613. }
  1614. // RemoveChildren removes "children" edges to Account entities.
  1615. func (_u *AccountUpdateOne) RemoveChildren(v ...*Account) *AccountUpdateOne {
  1616. ids := make([]int64, len(v))
  1617. for i := range v {
  1618. ids[i] = v[i].ID
  1619. }
  1620. return _u.RemoveChildIDs(ids...)
  1621. }
  1622. // ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity.
  1623. func (_u *AccountUpdateOne) ClearUsageLogs() *AccountUpdateOne {
  1624. _u.mutation.ClearUsageLogs()
  1625. return _u
  1626. }
  1627. // RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs.
  1628. func (_u *AccountUpdateOne) RemoveUsageLogIDs(ids ...int64) *AccountUpdateOne {
  1629. _u.mutation.RemoveUsageLogIDs(ids...)
  1630. return _u
  1631. }
  1632. // RemoveUsageLogs removes "usage_logs" edges to UsageLog entities.
  1633. func (_u *AccountUpdateOne) RemoveUsageLogs(v ...*UsageLog) *AccountUpdateOne {
  1634. ids := make([]int64, len(v))
  1635. for i := range v {
  1636. ids[i] = v[i].ID
  1637. }
  1638. return _u.RemoveUsageLogIDs(ids...)
  1639. }
  1640. // Where appends a list predicates to the AccountUpdate builder.
  1641. func (_u *AccountUpdateOne) Where(ps ...predicate.Account) *AccountUpdateOne {
  1642. _u.mutation.Where(ps...)
  1643. return _u
  1644. }
  1645. // Select allows selecting one or more fields (columns) of the returned entity.
  1646. // The default is selecting all fields defined in the entity schema.
  1647. func (_u *AccountUpdateOne) Select(field string, fields ...string) *AccountUpdateOne {
  1648. _u.fields = append([]string{field}, fields...)
  1649. return _u
  1650. }
  1651. // Save executes the query and returns the updated Account entity.
  1652. func (_u *AccountUpdateOne) Save(ctx context.Context) (*Account, error) {
  1653. if err := _u.defaults(); err != nil {
  1654. return nil, err
  1655. }
  1656. return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
  1657. }
  1658. // SaveX is like Save, but panics if an error occurs.
  1659. func (_u *AccountUpdateOne) SaveX(ctx context.Context) *Account {
  1660. node, err := _u.Save(ctx)
  1661. if err != nil {
  1662. panic(err)
  1663. }
  1664. return node
  1665. }
  1666. // Exec executes the query on the entity.
  1667. func (_u *AccountUpdateOne) Exec(ctx context.Context) error {
  1668. _, err := _u.Save(ctx)
  1669. return err
  1670. }
  1671. // ExecX is like Exec, but panics if an error occurs.
  1672. func (_u *AccountUpdateOne) ExecX(ctx context.Context) {
  1673. if err := _u.Exec(ctx); err != nil {
  1674. panic(err)
  1675. }
  1676. }
  1677. // defaults sets the default values of the builder before save.
  1678. func (_u *AccountUpdateOne) defaults() error {
  1679. if _, ok := _u.mutation.UpdatedAt(); !ok {
  1680. if account.UpdateDefaultUpdatedAt == nil {
  1681. return fmt.Errorf("ent: uninitialized account.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  1682. }
  1683. v := account.UpdateDefaultUpdatedAt()
  1684. _u.mutation.SetUpdatedAt(v)
  1685. }
  1686. return nil
  1687. }
  1688. // check runs all checks and user-defined validators on the builder.
  1689. func (_u *AccountUpdateOne) check() error {
  1690. if v, ok := _u.mutation.Name(); ok {
  1691. if err := account.NameValidator(v); err != nil {
  1692. return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Account.name": %w`, err)}
  1693. }
  1694. }
  1695. if v, ok := _u.mutation.Platform(); ok {
  1696. if err := account.PlatformValidator(v); err != nil {
  1697. return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "Account.platform": %w`, err)}
  1698. }
  1699. }
  1700. if v, ok := _u.mutation.GetType(); ok {
  1701. if err := account.TypeValidator(v); err != nil {
  1702. return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Account.type": %w`, err)}
  1703. }
  1704. }
  1705. if v, ok := _u.mutation.Status(); ok {
  1706. if err := account.StatusValidator(v); err != nil {
  1707. return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Account.status": %w`, err)}
  1708. }
  1709. }
  1710. if v, ok := _u.mutation.SessionWindowStatus(); ok {
  1711. if err := account.SessionWindowStatusValidator(v); err != nil {
  1712. return &ValidationError{Name: "session_window_status", err: fmt.Errorf(`ent: validator failed for field "Account.session_window_status": %w`, err)}
  1713. }
  1714. }
  1715. if v, ok := _u.mutation.QuotaDimension(); ok {
  1716. if err := account.QuotaDimensionValidator(v); err != nil {
  1717. return &ValidationError{Name: "quota_dimension", err: fmt.Errorf(`ent: validator failed for field "Account.quota_dimension": %w`, err)}
  1718. }
  1719. }
  1720. return nil
  1721. }
  1722. func (_u *AccountUpdateOne) sqlSave(ctx context.Context) (_node *Account, err error) {
  1723. if err := _u.check(); err != nil {
  1724. return _node, err
  1725. }
  1726. _spec := sqlgraph.NewUpdateSpec(account.Table, account.Columns, sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64))
  1727. id, ok := _u.mutation.ID()
  1728. if !ok {
  1729. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Account.id" for update`)}
  1730. }
  1731. _spec.Node.ID.Value = id
  1732. if fields := _u.fields; len(fields) > 0 {
  1733. _spec.Node.Columns = make([]string, 0, len(fields))
  1734. _spec.Node.Columns = append(_spec.Node.Columns, account.FieldID)
  1735. for _, f := range fields {
  1736. if !account.ValidColumn(f) {
  1737. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  1738. }
  1739. if f != account.FieldID {
  1740. _spec.Node.Columns = append(_spec.Node.Columns, f)
  1741. }
  1742. }
  1743. }
  1744. if ps := _u.mutation.predicates; len(ps) > 0 {
  1745. _spec.Predicate = func(selector *sql.Selector) {
  1746. for i := range ps {
  1747. ps[i](selector)
  1748. }
  1749. }
  1750. }
  1751. if value, ok := _u.mutation.UpdatedAt(); ok {
  1752. _spec.SetField(account.FieldUpdatedAt, field.TypeTime, value)
  1753. }
  1754. if value, ok := _u.mutation.DeletedAt(); ok {
  1755. _spec.SetField(account.FieldDeletedAt, field.TypeTime, value)
  1756. }
  1757. if _u.mutation.DeletedAtCleared() {
  1758. _spec.ClearField(account.FieldDeletedAt, field.TypeTime)
  1759. }
  1760. if value, ok := _u.mutation.Name(); ok {
  1761. _spec.SetField(account.FieldName, field.TypeString, value)
  1762. }
  1763. if value, ok := _u.mutation.Notes(); ok {
  1764. _spec.SetField(account.FieldNotes, field.TypeString, value)
  1765. }
  1766. if _u.mutation.NotesCleared() {
  1767. _spec.ClearField(account.FieldNotes, field.TypeString)
  1768. }
  1769. if value, ok := _u.mutation.Platform(); ok {
  1770. _spec.SetField(account.FieldPlatform, field.TypeString, value)
  1771. }
  1772. if value, ok := _u.mutation.GetType(); ok {
  1773. _spec.SetField(account.FieldType, field.TypeString, value)
  1774. }
  1775. if value, ok := _u.mutation.Credentials(); ok {
  1776. _spec.SetField(account.FieldCredentials, field.TypeJSON, value)
  1777. }
  1778. if value, ok := _u.mutation.Extra(); ok {
  1779. _spec.SetField(account.FieldExtra, field.TypeJSON, value)
  1780. }
  1781. if value, ok := _u.mutation.ProxyFallbackOriginID(); ok {
  1782. _spec.SetField(account.FieldProxyFallbackOriginID, field.TypeInt64, value)
  1783. }
  1784. if value, ok := _u.mutation.AddedProxyFallbackOriginID(); ok {
  1785. _spec.AddField(account.FieldProxyFallbackOriginID, field.TypeInt64, value)
  1786. }
  1787. if _u.mutation.ProxyFallbackOriginIDCleared() {
  1788. _spec.ClearField(account.FieldProxyFallbackOriginID, field.TypeInt64)
  1789. }
  1790. if value, ok := _u.mutation.Concurrency(); ok {
  1791. _spec.SetField(account.FieldConcurrency, field.TypeInt, value)
  1792. }
  1793. if value, ok := _u.mutation.AddedConcurrency(); ok {
  1794. _spec.AddField(account.FieldConcurrency, field.TypeInt, value)
  1795. }
  1796. if value, ok := _u.mutation.LoadFactor(); ok {
  1797. _spec.SetField(account.FieldLoadFactor, field.TypeInt, value)
  1798. }
  1799. if value, ok := _u.mutation.AddedLoadFactor(); ok {
  1800. _spec.AddField(account.FieldLoadFactor, field.TypeInt, value)
  1801. }
  1802. if _u.mutation.LoadFactorCleared() {
  1803. _spec.ClearField(account.FieldLoadFactor, field.TypeInt)
  1804. }
  1805. if value, ok := _u.mutation.Priority(); ok {
  1806. _spec.SetField(account.FieldPriority, field.TypeInt, value)
  1807. }
  1808. if value, ok := _u.mutation.AddedPriority(); ok {
  1809. _spec.AddField(account.FieldPriority, field.TypeInt, value)
  1810. }
  1811. if value, ok := _u.mutation.RateMultiplier(); ok {
  1812. _spec.SetField(account.FieldRateMultiplier, field.TypeFloat64, value)
  1813. }
  1814. if value, ok := _u.mutation.AddedRateMultiplier(); ok {
  1815. _spec.AddField(account.FieldRateMultiplier, field.TypeFloat64, value)
  1816. }
  1817. if value, ok := _u.mutation.Status(); ok {
  1818. _spec.SetField(account.FieldStatus, field.TypeString, value)
  1819. }
  1820. if value, ok := _u.mutation.ErrorMessage(); ok {
  1821. _spec.SetField(account.FieldErrorMessage, field.TypeString, value)
  1822. }
  1823. if _u.mutation.ErrorMessageCleared() {
  1824. _spec.ClearField(account.FieldErrorMessage, field.TypeString)
  1825. }
  1826. if value, ok := _u.mutation.LastUsedAt(); ok {
  1827. _spec.SetField(account.FieldLastUsedAt, field.TypeTime, value)
  1828. }
  1829. if _u.mutation.LastUsedAtCleared() {
  1830. _spec.ClearField(account.FieldLastUsedAt, field.TypeTime)
  1831. }
  1832. if value, ok := _u.mutation.ExpiresAt(); ok {
  1833. _spec.SetField(account.FieldExpiresAt, field.TypeTime, value)
  1834. }
  1835. if _u.mutation.ExpiresAtCleared() {
  1836. _spec.ClearField(account.FieldExpiresAt, field.TypeTime)
  1837. }
  1838. if value, ok := _u.mutation.AutoPauseOnExpired(); ok {
  1839. _spec.SetField(account.FieldAutoPauseOnExpired, field.TypeBool, value)
  1840. }
  1841. if value, ok := _u.mutation.Schedulable(); ok {
  1842. _spec.SetField(account.FieldSchedulable, field.TypeBool, value)
  1843. }
  1844. if value, ok := _u.mutation.RateLimitedAt(); ok {
  1845. _spec.SetField(account.FieldRateLimitedAt, field.TypeTime, value)
  1846. }
  1847. if _u.mutation.RateLimitedAtCleared() {
  1848. _spec.ClearField(account.FieldRateLimitedAt, field.TypeTime)
  1849. }
  1850. if value, ok := _u.mutation.RateLimitResetAt(); ok {
  1851. _spec.SetField(account.FieldRateLimitResetAt, field.TypeTime, value)
  1852. }
  1853. if _u.mutation.RateLimitResetAtCleared() {
  1854. _spec.ClearField(account.FieldRateLimitResetAt, field.TypeTime)
  1855. }
  1856. if value, ok := _u.mutation.OverloadUntil(); ok {
  1857. _spec.SetField(account.FieldOverloadUntil, field.TypeTime, value)
  1858. }
  1859. if _u.mutation.OverloadUntilCleared() {
  1860. _spec.ClearField(account.FieldOverloadUntil, field.TypeTime)
  1861. }
  1862. if value, ok := _u.mutation.TempUnschedulableUntil(); ok {
  1863. _spec.SetField(account.FieldTempUnschedulableUntil, field.TypeTime, value)
  1864. }
  1865. if _u.mutation.TempUnschedulableUntilCleared() {
  1866. _spec.ClearField(account.FieldTempUnschedulableUntil, field.TypeTime)
  1867. }
  1868. if value, ok := _u.mutation.TempUnschedulableReason(); ok {
  1869. _spec.SetField(account.FieldTempUnschedulableReason, field.TypeString, value)
  1870. }
  1871. if _u.mutation.TempUnschedulableReasonCleared() {
  1872. _spec.ClearField(account.FieldTempUnschedulableReason, field.TypeString)
  1873. }
  1874. if value, ok := _u.mutation.SessionWindowStart(); ok {
  1875. _spec.SetField(account.FieldSessionWindowStart, field.TypeTime, value)
  1876. }
  1877. if _u.mutation.SessionWindowStartCleared() {
  1878. _spec.ClearField(account.FieldSessionWindowStart, field.TypeTime)
  1879. }
  1880. if value, ok := _u.mutation.SessionWindowEnd(); ok {
  1881. _spec.SetField(account.FieldSessionWindowEnd, field.TypeTime, value)
  1882. }
  1883. if _u.mutation.SessionWindowEndCleared() {
  1884. _spec.ClearField(account.FieldSessionWindowEnd, field.TypeTime)
  1885. }
  1886. if value, ok := _u.mutation.SessionWindowStatus(); ok {
  1887. _spec.SetField(account.FieldSessionWindowStatus, field.TypeString, value)
  1888. }
  1889. if _u.mutation.SessionWindowStatusCleared() {
  1890. _spec.ClearField(account.FieldSessionWindowStatus, field.TypeString)
  1891. }
  1892. if value, ok := _u.mutation.QuotaDimension(); ok {
  1893. _spec.SetField(account.FieldQuotaDimension, field.TypeEnum, value)
  1894. }
  1895. if _u.mutation.GroupsCleared() {
  1896. edge := &sqlgraph.EdgeSpec{
  1897. Rel: sqlgraph.M2M,
  1898. Inverse: false,
  1899. Table: account.GroupsTable,
  1900. Columns: account.GroupsPrimaryKey,
  1901. Bidi: false,
  1902. Target: &sqlgraph.EdgeTarget{
  1903. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  1904. },
  1905. }
  1906. createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
  1907. createE.defaults()
  1908. _, specE := createE.createSpec()
  1909. edge.Target.Fields = specE.Fields
  1910. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1911. }
  1912. if nodes := _u.mutation.RemovedGroupsIDs(); len(nodes) > 0 && !_u.mutation.GroupsCleared() {
  1913. edge := &sqlgraph.EdgeSpec{
  1914. Rel: sqlgraph.M2M,
  1915. Inverse: false,
  1916. Table: account.GroupsTable,
  1917. Columns: account.GroupsPrimaryKey,
  1918. Bidi: false,
  1919. Target: &sqlgraph.EdgeTarget{
  1920. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  1921. },
  1922. }
  1923. for _, k := range nodes {
  1924. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1925. }
  1926. createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
  1927. createE.defaults()
  1928. _, specE := createE.createSpec()
  1929. edge.Target.Fields = specE.Fields
  1930. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1931. }
  1932. if nodes := _u.mutation.GroupsIDs(); len(nodes) > 0 {
  1933. edge := &sqlgraph.EdgeSpec{
  1934. Rel: sqlgraph.M2M,
  1935. Inverse: false,
  1936. Table: account.GroupsTable,
  1937. Columns: account.GroupsPrimaryKey,
  1938. Bidi: false,
  1939. Target: &sqlgraph.EdgeTarget{
  1940. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  1941. },
  1942. }
  1943. for _, k := range nodes {
  1944. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1945. }
  1946. createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
  1947. createE.defaults()
  1948. _, specE := createE.createSpec()
  1949. edge.Target.Fields = specE.Fields
  1950. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1951. }
  1952. if _u.mutation.ProxyCleared() {
  1953. edge := &sqlgraph.EdgeSpec{
  1954. Rel: sqlgraph.M2O,
  1955. Inverse: false,
  1956. Table: account.ProxyTable,
  1957. Columns: []string{account.ProxyColumn},
  1958. Bidi: false,
  1959. Target: &sqlgraph.EdgeTarget{
  1960. IDSpec: sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64),
  1961. },
  1962. }
  1963. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1964. }
  1965. if nodes := _u.mutation.ProxyIDs(); len(nodes) > 0 {
  1966. edge := &sqlgraph.EdgeSpec{
  1967. Rel: sqlgraph.M2O,
  1968. Inverse: false,
  1969. Table: account.ProxyTable,
  1970. Columns: []string{account.ProxyColumn},
  1971. Bidi: false,
  1972. Target: &sqlgraph.EdgeTarget{
  1973. IDSpec: sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64),
  1974. },
  1975. }
  1976. for _, k := range nodes {
  1977. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1978. }
  1979. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1980. }
  1981. if _u.mutation.ParentCleared() {
  1982. edge := &sqlgraph.EdgeSpec{
  1983. Rel: sqlgraph.M2O,
  1984. Inverse: true,
  1985. Table: account.ParentTable,
  1986. Columns: []string{account.ParentColumn},
  1987. Bidi: false,
  1988. Target: &sqlgraph.EdgeTarget{
  1989. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  1990. },
  1991. }
  1992. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1993. }
  1994. if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 {
  1995. edge := &sqlgraph.EdgeSpec{
  1996. Rel: sqlgraph.M2O,
  1997. Inverse: true,
  1998. Table: account.ParentTable,
  1999. Columns: []string{account.ParentColumn},
  2000. Bidi: false,
  2001. Target: &sqlgraph.EdgeTarget{
  2002. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  2003. },
  2004. }
  2005. for _, k := range nodes {
  2006. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2007. }
  2008. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2009. }
  2010. if _u.mutation.ChildrenCleared() {
  2011. edge := &sqlgraph.EdgeSpec{
  2012. Rel: sqlgraph.O2M,
  2013. Inverse: false,
  2014. Table: account.ChildrenTable,
  2015. Columns: []string{account.ChildrenColumn},
  2016. Bidi: false,
  2017. Target: &sqlgraph.EdgeTarget{
  2018. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  2019. },
  2020. }
  2021. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2022. }
  2023. if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() {
  2024. edge := &sqlgraph.EdgeSpec{
  2025. Rel: sqlgraph.O2M,
  2026. Inverse: false,
  2027. Table: account.ChildrenTable,
  2028. Columns: []string{account.ChildrenColumn},
  2029. Bidi: false,
  2030. Target: &sqlgraph.EdgeTarget{
  2031. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  2032. },
  2033. }
  2034. for _, k := range nodes {
  2035. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2036. }
  2037. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2038. }
  2039. if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 {
  2040. edge := &sqlgraph.EdgeSpec{
  2041. Rel: sqlgraph.O2M,
  2042. Inverse: false,
  2043. Table: account.ChildrenTable,
  2044. Columns: []string{account.ChildrenColumn},
  2045. Bidi: false,
  2046. Target: &sqlgraph.EdgeTarget{
  2047. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  2048. },
  2049. }
  2050. for _, k := range nodes {
  2051. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2052. }
  2053. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2054. }
  2055. if _u.mutation.UsageLogsCleared() {
  2056. edge := &sqlgraph.EdgeSpec{
  2057. Rel: sqlgraph.O2M,
  2058. Inverse: false,
  2059. Table: account.UsageLogsTable,
  2060. Columns: []string{account.UsageLogsColumn},
  2061. Bidi: false,
  2062. Target: &sqlgraph.EdgeTarget{
  2063. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  2064. },
  2065. }
  2066. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2067. }
  2068. if nodes := _u.mutation.RemovedUsageLogsIDs(); len(nodes) > 0 && !_u.mutation.UsageLogsCleared() {
  2069. edge := &sqlgraph.EdgeSpec{
  2070. Rel: sqlgraph.O2M,
  2071. Inverse: false,
  2072. Table: account.UsageLogsTable,
  2073. Columns: []string{account.UsageLogsColumn},
  2074. Bidi: false,
  2075. Target: &sqlgraph.EdgeTarget{
  2076. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  2077. },
  2078. }
  2079. for _, k := range nodes {
  2080. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2081. }
  2082. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  2083. }
  2084. if nodes := _u.mutation.UsageLogsIDs(); len(nodes) > 0 {
  2085. edge := &sqlgraph.EdgeSpec{
  2086. Rel: sqlgraph.O2M,
  2087. Inverse: false,
  2088. Table: account.UsageLogsTable,
  2089. Columns: []string{account.UsageLogsColumn},
  2090. Bidi: false,
  2091. Target: &sqlgraph.EdgeTarget{
  2092. IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
  2093. },
  2094. }
  2095. for _, k := range nodes {
  2096. edge.Target.Nodes = append(edge.Target.Nodes, k)
  2097. }
  2098. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  2099. }
  2100. _node = &Account{config: _u.config}
  2101. _spec.Assign = _node.assignValues
  2102. _spec.ScanValues = _node.scanValues
  2103. if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
  2104. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  2105. err = &NotFoundError{account.Label}
  2106. } else if sqlgraph.IsConstraintError(err) {
  2107. err = &ConstraintError{msg: err.Error(), wrap: err}
  2108. }
  2109. return nil, err
  2110. }
  2111. _u.mutation.done = true
  2112. return _node, nil
  2113. }