usagelog_create.go 133 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252
  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/apikey"
  13. "github.com/Wei-Shaw/sub2api/ent/group"
  14. "github.com/Wei-Shaw/sub2api/ent/usagelog"
  15. "github.com/Wei-Shaw/sub2api/ent/user"
  16. "github.com/Wei-Shaw/sub2api/ent/usersubscription"
  17. )
  18. // UsageLogCreate is the builder for creating a UsageLog entity.
  19. type UsageLogCreate struct {
  20. config
  21. mutation *UsageLogMutation
  22. hooks []Hook
  23. conflict []sql.ConflictOption
  24. }
  25. // SetUserID sets the "user_id" field.
  26. func (_c *UsageLogCreate) SetUserID(v int64) *UsageLogCreate {
  27. _c.mutation.SetUserID(v)
  28. return _c
  29. }
  30. // SetAPIKeyID sets the "api_key_id" field.
  31. func (_c *UsageLogCreate) SetAPIKeyID(v int64) *UsageLogCreate {
  32. _c.mutation.SetAPIKeyID(v)
  33. return _c
  34. }
  35. // SetAccountID sets the "account_id" field.
  36. func (_c *UsageLogCreate) SetAccountID(v int64) *UsageLogCreate {
  37. _c.mutation.SetAccountID(v)
  38. return _c
  39. }
  40. // SetRequestID sets the "request_id" field.
  41. func (_c *UsageLogCreate) SetRequestID(v string) *UsageLogCreate {
  42. _c.mutation.SetRequestID(v)
  43. return _c
  44. }
  45. // SetModel sets the "model" field.
  46. func (_c *UsageLogCreate) SetModel(v string) *UsageLogCreate {
  47. _c.mutation.SetModel(v)
  48. return _c
  49. }
  50. // SetRequestedModel sets the "requested_model" field.
  51. func (_c *UsageLogCreate) SetRequestedModel(v string) *UsageLogCreate {
  52. _c.mutation.SetRequestedModel(v)
  53. return _c
  54. }
  55. // SetNillableRequestedModel sets the "requested_model" field if the given value is not nil.
  56. func (_c *UsageLogCreate) SetNillableRequestedModel(v *string) *UsageLogCreate {
  57. if v != nil {
  58. _c.SetRequestedModel(*v)
  59. }
  60. return _c
  61. }
  62. // SetUpstreamModel sets the "upstream_model" field.
  63. func (_c *UsageLogCreate) SetUpstreamModel(v string) *UsageLogCreate {
  64. _c.mutation.SetUpstreamModel(v)
  65. return _c
  66. }
  67. // SetNillableUpstreamModel sets the "upstream_model" field if the given value is not nil.
  68. func (_c *UsageLogCreate) SetNillableUpstreamModel(v *string) *UsageLogCreate {
  69. if v != nil {
  70. _c.SetUpstreamModel(*v)
  71. }
  72. return _c
  73. }
  74. // SetUpstreamResponseModel sets the "upstream_response_model" field.
  75. func (_c *UsageLogCreate) SetUpstreamResponseModel(v string) *UsageLogCreate {
  76. _c.mutation.SetUpstreamResponseModel(v)
  77. return _c
  78. }
  79. // SetNillableUpstreamResponseModel sets the "upstream_response_model" field if the given value is not nil.
  80. func (_c *UsageLogCreate) SetNillableUpstreamResponseModel(v *string) *UsageLogCreate {
  81. if v != nil {
  82. _c.SetUpstreamResponseModel(*v)
  83. }
  84. return _c
  85. }
  86. // SetUpstreamModelMismatch sets the "upstream_model_mismatch" field.
  87. func (_c *UsageLogCreate) SetUpstreamModelMismatch(v bool) *UsageLogCreate {
  88. _c.mutation.SetUpstreamModelMismatch(v)
  89. return _c
  90. }
  91. // SetNillableUpstreamModelMismatch sets the "upstream_model_mismatch" field if the given value is not nil.
  92. func (_c *UsageLogCreate) SetNillableUpstreamModelMismatch(v *bool) *UsageLogCreate {
  93. if v != nil {
  94. _c.SetUpstreamModelMismatch(*v)
  95. }
  96. return _c
  97. }
  98. // SetChannelID sets the "channel_id" field.
  99. func (_c *UsageLogCreate) SetChannelID(v int64) *UsageLogCreate {
  100. _c.mutation.SetChannelID(v)
  101. return _c
  102. }
  103. // SetNillableChannelID sets the "channel_id" field if the given value is not nil.
  104. func (_c *UsageLogCreate) SetNillableChannelID(v *int64) *UsageLogCreate {
  105. if v != nil {
  106. _c.SetChannelID(*v)
  107. }
  108. return _c
  109. }
  110. // SetModelMappingChain sets the "model_mapping_chain" field.
  111. func (_c *UsageLogCreate) SetModelMappingChain(v string) *UsageLogCreate {
  112. _c.mutation.SetModelMappingChain(v)
  113. return _c
  114. }
  115. // SetNillableModelMappingChain sets the "model_mapping_chain" field if the given value is not nil.
  116. func (_c *UsageLogCreate) SetNillableModelMappingChain(v *string) *UsageLogCreate {
  117. if v != nil {
  118. _c.SetModelMappingChain(*v)
  119. }
  120. return _c
  121. }
  122. // SetBillingTier sets the "billing_tier" field.
  123. func (_c *UsageLogCreate) SetBillingTier(v string) *UsageLogCreate {
  124. _c.mutation.SetBillingTier(v)
  125. return _c
  126. }
  127. // SetNillableBillingTier sets the "billing_tier" field if the given value is not nil.
  128. func (_c *UsageLogCreate) SetNillableBillingTier(v *string) *UsageLogCreate {
  129. if v != nil {
  130. _c.SetBillingTier(*v)
  131. }
  132. return _c
  133. }
  134. // SetBillingMode sets the "billing_mode" field.
  135. func (_c *UsageLogCreate) SetBillingMode(v string) *UsageLogCreate {
  136. _c.mutation.SetBillingMode(v)
  137. return _c
  138. }
  139. // SetNillableBillingMode sets the "billing_mode" field if the given value is not nil.
  140. func (_c *UsageLogCreate) SetNillableBillingMode(v *string) *UsageLogCreate {
  141. if v != nil {
  142. _c.SetBillingMode(*v)
  143. }
  144. return _c
  145. }
  146. // SetGroupID sets the "group_id" field.
  147. func (_c *UsageLogCreate) SetGroupID(v int64) *UsageLogCreate {
  148. _c.mutation.SetGroupID(v)
  149. return _c
  150. }
  151. // SetNillableGroupID sets the "group_id" field if the given value is not nil.
  152. func (_c *UsageLogCreate) SetNillableGroupID(v *int64) *UsageLogCreate {
  153. if v != nil {
  154. _c.SetGroupID(*v)
  155. }
  156. return _c
  157. }
  158. // SetSubscriptionID sets the "subscription_id" field.
  159. func (_c *UsageLogCreate) SetSubscriptionID(v int64) *UsageLogCreate {
  160. _c.mutation.SetSubscriptionID(v)
  161. return _c
  162. }
  163. // SetNillableSubscriptionID sets the "subscription_id" field if the given value is not nil.
  164. func (_c *UsageLogCreate) SetNillableSubscriptionID(v *int64) *UsageLogCreate {
  165. if v != nil {
  166. _c.SetSubscriptionID(*v)
  167. }
  168. return _c
  169. }
  170. // SetInputTokens sets the "input_tokens" field.
  171. func (_c *UsageLogCreate) SetInputTokens(v int) *UsageLogCreate {
  172. _c.mutation.SetInputTokens(v)
  173. return _c
  174. }
  175. // SetNillableInputTokens sets the "input_tokens" field if the given value is not nil.
  176. func (_c *UsageLogCreate) SetNillableInputTokens(v *int) *UsageLogCreate {
  177. if v != nil {
  178. _c.SetInputTokens(*v)
  179. }
  180. return _c
  181. }
  182. // SetOutputTokens sets the "output_tokens" field.
  183. func (_c *UsageLogCreate) SetOutputTokens(v int) *UsageLogCreate {
  184. _c.mutation.SetOutputTokens(v)
  185. return _c
  186. }
  187. // SetNillableOutputTokens sets the "output_tokens" field if the given value is not nil.
  188. func (_c *UsageLogCreate) SetNillableOutputTokens(v *int) *UsageLogCreate {
  189. if v != nil {
  190. _c.SetOutputTokens(*v)
  191. }
  192. return _c
  193. }
  194. // SetCacheCreationTokens sets the "cache_creation_tokens" field.
  195. func (_c *UsageLogCreate) SetCacheCreationTokens(v int) *UsageLogCreate {
  196. _c.mutation.SetCacheCreationTokens(v)
  197. return _c
  198. }
  199. // SetNillableCacheCreationTokens sets the "cache_creation_tokens" field if the given value is not nil.
  200. func (_c *UsageLogCreate) SetNillableCacheCreationTokens(v *int) *UsageLogCreate {
  201. if v != nil {
  202. _c.SetCacheCreationTokens(*v)
  203. }
  204. return _c
  205. }
  206. // SetCacheReadTokens sets the "cache_read_tokens" field.
  207. func (_c *UsageLogCreate) SetCacheReadTokens(v int) *UsageLogCreate {
  208. _c.mutation.SetCacheReadTokens(v)
  209. return _c
  210. }
  211. // SetNillableCacheReadTokens sets the "cache_read_tokens" field if the given value is not nil.
  212. func (_c *UsageLogCreate) SetNillableCacheReadTokens(v *int) *UsageLogCreate {
  213. if v != nil {
  214. _c.SetCacheReadTokens(*v)
  215. }
  216. return _c
  217. }
  218. // SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
  219. func (_c *UsageLogCreate) SetCacheCreation5mTokens(v int) *UsageLogCreate {
  220. _c.mutation.SetCacheCreation5mTokens(v)
  221. return _c
  222. }
  223. // SetNillableCacheCreation5mTokens sets the "cache_creation_5m_tokens" field if the given value is not nil.
  224. func (_c *UsageLogCreate) SetNillableCacheCreation5mTokens(v *int) *UsageLogCreate {
  225. if v != nil {
  226. _c.SetCacheCreation5mTokens(*v)
  227. }
  228. return _c
  229. }
  230. // SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
  231. func (_c *UsageLogCreate) SetCacheCreation1hTokens(v int) *UsageLogCreate {
  232. _c.mutation.SetCacheCreation1hTokens(v)
  233. return _c
  234. }
  235. // SetNillableCacheCreation1hTokens sets the "cache_creation_1h_tokens" field if the given value is not nil.
  236. func (_c *UsageLogCreate) SetNillableCacheCreation1hTokens(v *int) *UsageLogCreate {
  237. if v != nil {
  238. _c.SetCacheCreation1hTokens(*v)
  239. }
  240. return _c
  241. }
  242. // SetInputCost sets the "input_cost" field.
  243. func (_c *UsageLogCreate) SetInputCost(v float64) *UsageLogCreate {
  244. _c.mutation.SetInputCost(v)
  245. return _c
  246. }
  247. // SetNillableInputCost sets the "input_cost" field if the given value is not nil.
  248. func (_c *UsageLogCreate) SetNillableInputCost(v *float64) *UsageLogCreate {
  249. if v != nil {
  250. _c.SetInputCost(*v)
  251. }
  252. return _c
  253. }
  254. // SetOutputCost sets the "output_cost" field.
  255. func (_c *UsageLogCreate) SetOutputCost(v float64) *UsageLogCreate {
  256. _c.mutation.SetOutputCost(v)
  257. return _c
  258. }
  259. // SetNillableOutputCost sets the "output_cost" field if the given value is not nil.
  260. func (_c *UsageLogCreate) SetNillableOutputCost(v *float64) *UsageLogCreate {
  261. if v != nil {
  262. _c.SetOutputCost(*v)
  263. }
  264. return _c
  265. }
  266. // SetCacheCreationCost sets the "cache_creation_cost" field.
  267. func (_c *UsageLogCreate) SetCacheCreationCost(v float64) *UsageLogCreate {
  268. _c.mutation.SetCacheCreationCost(v)
  269. return _c
  270. }
  271. // SetNillableCacheCreationCost sets the "cache_creation_cost" field if the given value is not nil.
  272. func (_c *UsageLogCreate) SetNillableCacheCreationCost(v *float64) *UsageLogCreate {
  273. if v != nil {
  274. _c.SetCacheCreationCost(*v)
  275. }
  276. return _c
  277. }
  278. // SetCacheReadCost sets the "cache_read_cost" field.
  279. func (_c *UsageLogCreate) SetCacheReadCost(v float64) *UsageLogCreate {
  280. _c.mutation.SetCacheReadCost(v)
  281. return _c
  282. }
  283. // SetNillableCacheReadCost sets the "cache_read_cost" field if the given value is not nil.
  284. func (_c *UsageLogCreate) SetNillableCacheReadCost(v *float64) *UsageLogCreate {
  285. if v != nil {
  286. _c.SetCacheReadCost(*v)
  287. }
  288. return _c
  289. }
  290. // SetTotalCost sets the "total_cost" field.
  291. func (_c *UsageLogCreate) SetTotalCost(v float64) *UsageLogCreate {
  292. _c.mutation.SetTotalCost(v)
  293. return _c
  294. }
  295. // SetNillableTotalCost sets the "total_cost" field if the given value is not nil.
  296. func (_c *UsageLogCreate) SetNillableTotalCost(v *float64) *UsageLogCreate {
  297. if v != nil {
  298. _c.SetTotalCost(*v)
  299. }
  300. return _c
  301. }
  302. // SetActualCost sets the "actual_cost" field.
  303. func (_c *UsageLogCreate) SetActualCost(v float64) *UsageLogCreate {
  304. _c.mutation.SetActualCost(v)
  305. return _c
  306. }
  307. // SetNillableActualCost sets the "actual_cost" field if the given value is not nil.
  308. func (_c *UsageLogCreate) SetNillableActualCost(v *float64) *UsageLogCreate {
  309. if v != nil {
  310. _c.SetActualCost(*v)
  311. }
  312. return _c
  313. }
  314. // SetRateMultiplier sets the "rate_multiplier" field.
  315. func (_c *UsageLogCreate) SetRateMultiplier(v float64) *UsageLogCreate {
  316. _c.mutation.SetRateMultiplier(v)
  317. return _c
  318. }
  319. // SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
  320. func (_c *UsageLogCreate) SetNillableRateMultiplier(v *float64) *UsageLogCreate {
  321. if v != nil {
  322. _c.SetRateMultiplier(*v)
  323. }
  324. return _c
  325. }
  326. // SetLongContextBillingApplied sets the "long_context_billing_applied" field.
  327. func (_c *UsageLogCreate) SetLongContextBillingApplied(v bool) *UsageLogCreate {
  328. _c.mutation.SetLongContextBillingApplied(v)
  329. return _c
  330. }
  331. // SetNillableLongContextBillingApplied sets the "long_context_billing_applied" field if the given value is not nil.
  332. func (_c *UsageLogCreate) SetNillableLongContextBillingApplied(v *bool) *UsageLogCreate {
  333. if v != nil {
  334. _c.SetLongContextBillingApplied(*v)
  335. }
  336. return _c
  337. }
  338. // SetAccountRateMultiplier sets the "account_rate_multiplier" field.
  339. func (_c *UsageLogCreate) SetAccountRateMultiplier(v float64) *UsageLogCreate {
  340. _c.mutation.SetAccountRateMultiplier(v)
  341. return _c
  342. }
  343. // SetNillableAccountRateMultiplier sets the "account_rate_multiplier" field if the given value is not nil.
  344. func (_c *UsageLogCreate) SetNillableAccountRateMultiplier(v *float64) *UsageLogCreate {
  345. if v != nil {
  346. _c.SetAccountRateMultiplier(*v)
  347. }
  348. return _c
  349. }
  350. // SetBillingType sets the "billing_type" field.
  351. func (_c *UsageLogCreate) SetBillingType(v int8) *UsageLogCreate {
  352. _c.mutation.SetBillingType(v)
  353. return _c
  354. }
  355. // SetNillableBillingType sets the "billing_type" field if the given value is not nil.
  356. func (_c *UsageLogCreate) SetNillableBillingType(v *int8) *UsageLogCreate {
  357. if v != nil {
  358. _c.SetBillingType(*v)
  359. }
  360. return _c
  361. }
  362. // SetStream sets the "stream" field.
  363. func (_c *UsageLogCreate) SetStream(v bool) *UsageLogCreate {
  364. _c.mutation.SetStream(v)
  365. return _c
  366. }
  367. // SetNillableStream sets the "stream" field if the given value is not nil.
  368. func (_c *UsageLogCreate) SetNillableStream(v *bool) *UsageLogCreate {
  369. if v != nil {
  370. _c.SetStream(*v)
  371. }
  372. return _c
  373. }
  374. // SetDurationMs sets the "duration_ms" field.
  375. func (_c *UsageLogCreate) SetDurationMs(v int) *UsageLogCreate {
  376. _c.mutation.SetDurationMs(v)
  377. return _c
  378. }
  379. // SetNillableDurationMs sets the "duration_ms" field if the given value is not nil.
  380. func (_c *UsageLogCreate) SetNillableDurationMs(v *int) *UsageLogCreate {
  381. if v != nil {
  382. _c.SetDurationMs(*v)
  383. }
  384. return _c
  385. }
  386. // SetFirstTokenMs sets the "first_token_ms" field.
  387. func (_c *UsageLogCreate) SetFirstTokenMs(v int) *UsageLogCreate {
  388. _c.mutation.SetFirstTokenMs(v)
  389. return _c
  390. }
  391. // SetNillableFirstTokenMs sets the "first_token_ms" field if the given value is not nil.
  392. func (_c *UsageLogCreate) SetNillableFirstTokenMs(v *int) *UsageLogCreate {
  393. if v != nil {
  394. _c.SetFirstTokenMs(*v)
  395. }
  396. return _c
  397. }
  398. // SetUserAgent sets the "user_agent" field.
  399. func (_c *UsageLogCreate) SetUserAgent(v string) *UsageLogCreate {
  400. _c.mutation.SetUserAgent(v)
  401. return _c
  402. }
  403. // SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
  404. func (_c *UsageLogCreate) SetNillableUserAgent(v *string) *UsageLogCreate {
  405. if v != nil {
  406. _c.SetUserAgent(*v)
  407. }
  408. return _c
  409. }
  410. // SetIPAddress sets the "ip_address" field.
  411. func (_c *UsageLogCreate) SetIPAddress(v string) *UsageLogCreate {
  412. _c.mutation.SetIPAddress(v)
  413. return _c
  414. }
  415. // SetNillableIPAddress sets the "ip_address" field if the given value is not nil.
  416. func (_c *UsageLogCreate) SetNillableIPAddress(v *string) *UsageLogCreate {
  417. if v != nil {
  418. _c.SetIPAddress(*v)
  419. }
  420. return _c
  421. }
  422. // SetImageCount sets the "image_count" field.
  423. func (_c *UsageLogCreate) SetImageCount(v int) *UsageLogCreate {
  424. _c.mutation.SetImageCount(v)
  425. return _c
  426. }
  427. // SetNillableImageCount sets the "image_count" field if the given value is not nil.
  428. func (_c *UsageLogCreate) SetNillableImageCount(v *int) *UsageLogCreate {
  429. if v != nil {
  430. _c.SetImageCount(*v)
  431. }
  432. return _c
  433. }
  434. // SetImageSize sets the "image_size" field.
  435. func (_c *UsageLogCreate) SetImageSize(v string) *UsageLogCreate {
  436. _c.mutation.SetImageSize(v)
  437. return _c
  438. }
  439. // SetNillableImageSize sets the "image_size" field if the given value is not nil.
  440. func (_c *UsageLogCreate) SetNillableImageSize(v *string) *UsageLogCreate {
  441. if v != nil {
  442. _c.SetImageSize(*v)
  443. }
  444. return _c
  445. }
  446. // SetImageInputSize sets the "image_input_size" field.
  447. func (_c *UsageLogCreate) SetImageInputSize(v string) *UsageLogCreate {
  448. _c.mutation.SetImageInputSize(v)
  449. return _c
  450. }
  451. // SetNillableImageInputSize sets the "image_input_size" field if the given value is not nil.
  452. func (_c *UsageLogCreate) SetNillableImageInputSize(v *string) *UsageLogCreate {
  453. if v != nil {
  454. _c.SetImageInputSize(*v)
  455. }
  456. return _c
  457. }
  458. // SetImageOutputSize sets the "image_output_size" field.
  459. func (_c *UsageLogCreate) SetImageOutputSize(v string) *UsageLogCreate {
  460. _c.mutation.SetImageOutputSize(v)
  461. return _c
  462. }
  463. // SetNillableImageOutputSize sets the "image_output_size" field if the given value is not nil.
  464. func (_c *UsageLogCreate) SetNillableImageOutputSize(v *string) *UsageLogCreate {
  465. if v != nil {
  466. _c.SetImageOutputSize(*v)
  467. }
  468. return _c
  469. }
  470. // SetImageSizeSource sets the "image_size_source" field.
  471. func (_c *UsageLogCreate) SetImageSizeSource(v string) *UsageLogCreate {
  472. _c.mutation.SetImageSizeSource(v)
  473. return _c
  474. }
  475. // SetNillableImageSizeSource sets the "image_size_source" field if the given value is not nil.
  476. func (_c *UsageLogCreate) SetNillableImageSizeSource(v *string) *UsageLogCreate {
  477. if v != nil {
  478. _c.SetImageSizeSource(*v)
  479. }
  480. return _c
  481. }
  482. // SetImageSizeBreakdown sets the "image_size_breakdown" field.
  483. func (_c *UsageLogCreate) SetImageSizeBreakdown(v map[string]int) *UsageLogCreate {
  484. _c.mutation.SetImageSizeBreakdown(v)
  485. return _c
  486. }
  487. // SetVideoCount sets the "video_count" field.
  488. func (_c *UsageLogCreate) SetVideoCount(v int) *UsageLogCreate {
  489. _c.mutation.SetVideoCount(v)
  490. return _c
  491. }
  492. // SetNillableVideoCount sets the "video_count" field if the given value is not nil.
  493. func (_c *UsageLogCreate) SetNillableVideoCount(v *int) *UsageLogCreate {
  494. if v != nil {
  495. _c.SetVideoCount(*v)
  496. }
  497. return _c
  498. }
  499. // SetVideoResolution sets the "video_resolution" field.
  500. func (_c *UsageLogCreate) SetVideoResolution(v string) *UsageLogCreate {
  501. _c.mutation.SetVideoResolution(v)
  502. return _c
  503. }
  504. // SetNillableVideoResolution sets the "video_resolution" field if the given value is not nil.
  505. func (_c *UsageLogCreate) SetNillableVideoResolution(v *string) *UsageLogCreate {
  506. if v != nil {
  507. _c.SetVideoResolution(*v)
  508. }
  509. return _c
  510. }
  511. // SetVideoDurationSeconds sets the "video_duration_seconds" field.
  512. func (_c *UsageLogCreate) SetVideoDurationSeconds(v int) *UsageLogCreate {
  513. _c.mutation.SetVideoDurationSeconds(v)
  514. return _c
  515. }
  516. // SetNillableVideoDurationSeconds sets the "video_duration_seconds" field if the given value is not nil.
  517. func (_c *UsageLogCreate) SetNillableVideoDurationSeconds(v *int) *UsageLogCreate {
  518. if v != nil {
  519. _c.SetVideoDurationSeconds(*v)
  520. }
  521. return _c
  522. }
  523. // SetCacheTTLOverridden sets the "cache_ttl_overridden" field.
  524. func (_c *UsageLogCreate) SetCacheTTLOverridden(v bool) *UsageLogCreate {
  525. _c.mutation.SetCacheTTLOverridden(v)
  526. return _c
  527. }
  528. // SetNillableCacheTTLOverridden sets the "cache_ttl_overridden" field if the given value is not nil.
  529. func (_c *UsageLogCreate) SetNillableCacheTTLOverridden(v *bool) *UsageLogCreate {
  530. if v != nil {
  531. _c.SetCacheTTLOverridden(*v)
  532. }
  533. return _c
  534. }
  535. // SetCreatedAt sets the "created_at" field.
  536. func (_c *UsageLogCreate) SetCreatedAt(v time.Time) *UsageLogCreate {
  537. _c.mutation.SetCreatedAt(v)
  538. return _c
  539. }
  540. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  541. func (_c *UsageLogCreate) SetNillableCreatedAt(v *time.Time) *UsageLogCreate {
  542. if v != nil {
  543. _c.SetCreatedAt(*v)
  544. }
  545. return _c
  546. }
  547. // SetUser sets the "user" edge to the User entity.
  548. func (_c *UsageLogCreate) SetUser(v *User) *UsageLogCreate {
  549. return _c.SetUserID(v.ID)
  550. }
  551. // SetAPIKey sets the "api_key" edge to the APIKey entity.
  552. func (_c *UsageLogCreate) SetAPIKey(v *APIKey) *UsageLogCreate {
  553. return _c.SetAPIKeyID(v.ID)
  554. }
  555. // SetAccount sets the "account" edge to the Account entity.
  556. func (_c *UsageLogCreate) SetAccount(v *Account) *UsageLogCreate {
  557. return _c.SetAccountID(v.ID)
  558. }
  559. // SetGroup sets the "group" edge to the Group entity.
  560. func (_c *UsageLogCreate) SetGroup(v *Group) *UsageLogCreate {
  561. return _c.SetGroupID(v.ID)
  562. }
  563. // SetSubscription sets the "subscription" edge to the UserSubscription entity.
  564. func (_c *UsageLogCreate) SetSubscription(v *UserSubscription) *UsageLogCreate {
  565. return _c.SetSubscriptionID(v.ID)
  566. }
  567. // Mutation returns the UsageLogMutation object of the builder.
  568. func (_c *UsageLogCreate) Mutation() *UsageLogMutation {
  569. return _c.mutation
  570. }
  571. // Save creates the UsageLog in the database.
  572. func (_c *UsageLogCreate) Save(ctx context.Context) (*UsageLog, error) {
  573. _c.defaults()
  574. return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
  575. }
  576. // SaveX calls Save and panics if Save returns an error.
  577. func (_c *UsageLogCreate) SaveX(ctx context.Context) *UsageLog {
  578. v, err := _c.Save(ctx)
  579. if err != nil {
  580. panic(err)
  581. }
  582. return v
  583. }
  584. // Exec executes the query.
  585. func (_c *UsageLogCreate) Exec(ctx context.Context) error {
  586. _, err := _c.Save(ctx)
  587. return err
  588. }
  589. // ExecX is like Exec, but panics if an error occurs.
  590. func (_c *UsageLogCreate) ExecX(ctx context.Context) {
  591. if err := _c.Exec(ctx); err != nil {
  592. panic(err)
  593. }
  594. }
  595. // defaults sets the default values of the builder before save.
  596. func (_c *UsageLogCreate) defaults() {
  597. if _, ok := _c.mutation.InputTokens(); !ok {
  598. v := usagelog.DefaultInputTokens
  599. _c.mutation.SetInputTokens(v)
  600. }
  601. if _, ok := _c.mutation.OutputTokens(); !ok {
  602. v := usagelog.DefaultOutputTokens
  603. _c.mutation.SetOutputTokens(v)
  604. }
  605. if _, ok := _c.mutation.CacheCreationTokens(); !ok {
  606. v := usagelog.DefaultCacheCreationTokens
  607. _c.mutation.SetCacheCreationTokens(v)
  608. }
  609. if _, ok := _c.mutation.CacheReadTokens(); !ok {
  610. v := usagelog.DefaultCacheReadTokens
  611. _c.mutation.SetCacheReadTokens(v)
  612. }
  613. if _, ok := _c.mutation.CacheCreation5mTokens(); !ok {
  614. v := usagelog.DefaultCacheCreation5mTokens
  615. _c.mutation.SetCacheCreation5mTokens(v)
  616. }
  617. if _, ok := _c.mutation.CacheCreation1hTokens(); !ok {
  618. v := usagelog.DefaultCacheCreation1hTokens
  619. _c.mutation.SetCacheCreation1hTokens(v)
  620. }
  621. if _, ok := _c.mutation.InputCost(); !ok {
  622. v := usagelog.DefaultInputCost
  623. _c.mutation.SetInputCost(v)
  624. }
  625. if _, ok := _c.mutation.OutputCost(); !ok {
  626. v := usagelog.DefaultOutputCost
  627. _c.mutation.SetOutputCost(v)
  628. }
  629. if _, ok := _c.mutation.CacheCreationCost(); !ok {
  630. v := usagelog.DefaultCacheCreationCost
  631. _c.mutation.SetCacheCreationCost(v)
  632. }
  633. if _, ok := _c.mutation.CacheReadCost(); !ok {
  634. v := usagelog.DefaultCacheReadCost
  635. _c.mutation.SetCacheReadCost(v)
  636. }
  637. if _, ok := _c.mutation.TotalCost(); !ok {
  638. v := usagelog.DefaultTotalCost
  639. _c.mutation.SetTotalCost(v)
  640. }
  641. if _, ok := _c.mutation.ActualCost(); !ok {
  642. v := usagelog.DefaultActualCost
  643. _c.mutation.SetActualCost(v)
  644. }
  645. if _, ok := _c.mutation.RateMultiplier(); !ok {
  646. v := usagelog.DefaultRateMultiplier
  647. _c.mutation.SetRateMultiplier(v)
  648. }
  649. if _, ok := _c.mutation.LongContextBillingApplied(); !ok {
  650. v := usagelog.DefaultLongContextBillingApplied
  651. _c.mutation.SetLongContextBillingApplied(v)
  652. }
  653. if _, ok := _c.mutation.BillingType(); !ok {
  654. v := usagelog.DefaultBillingType
  655. _c.mutation.SetBillingType(v)
  656. }
  657. if _, ok := _c.mutation.Stream(); !ok {
  658. v := usagelog.DefaultStream
  659. _c.mutation.SetStream(v)
  660. }
  661. if _, ok := _c.mutation.ImageCount(); !ok {
  662. v := usagelog.DefaultImageCount
  663. _c.mutation.SetImageCount(v)
  664. }
  665. if _, ok := _c.mutation.VideoCount(); !ok {
  666. v := usagelog.DefaultVideoCount
  667. _c.mutation.SetVideoCount(v)
  668. }
  669. if _, ok := _c.mutation.CacheTTLOverridden(); !ok {
  670. v := usagelog.DefaultCacheTTLOverridden
  671. _c.mutation.SetCacheTTLOverridden(v)
  672. }
  673. if _, ok := _c.mutation.CreatedAt(); !ok {
  674. v := usagelog.DefaultCreatedAt()
  675. _c.mutation.SetCreatedAt(v)
  676. }
  677. }
  678. // check runs all checks and user-defined validators on the builder.
  679. func (_c *UsageLogCreate) check() error {
  680. if _, ok := _c.mutation.UserID(); !ok {
  681. return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UsageLog.user_id"`)}
  682. }
  683. if _, ok := _c.mutation.APIKeyID(); !ok {
  684. return &ValidationError{Name: "api_key_id", err: errors.New(`ent: missing required field "UsageLog.api_key_id"`)}
  685. }
  686. if _, ok := _c.mutation.AccountID(); !ok {
  687. return &ValidationError{Name: "account_id", err: errors.New(`ent: missing required field "UsageLog.account_id"`)}
  688. }
  689. if _, ok := _c.mutation.RequestID(); !ok {
  690. return &ValidationError{Name: "request_id", err: errors.New(`ent: missing required field "UsageLog.request_id"`)}
  691. }
  692. if v, ok := _c.mutation.RequestID(); ok {
  693. if err := usagelog.RequestIDValidator(v); err != nil {
  694. return &ValidationError{Name: "request_id", err: fmt.Errorf(`ent: validator failed for field "UsageLog.request_id": %w`, err)}
  695. }
  696. }
  697. if _, ok := _c.mutation.Model(); !ok {
  698. return &ValidationError{Name: "model", err: errors.New(`ent: missing required field "UsageLog.model"`)}
  699. }
  700. if v, ok := _c.mutation.Model(); ok {
  701. if err := usagelog.ModelValidator(v); err != nil {
  702. return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model": %w`, err)}
  703. }
  704. }
  705. if v, ok := _c.mutation.RequestedModel(); ok {
  706. if err := usagelog.RequestedModelValidator(v); err != nil {
  707. return &ValidationError{Name: "requested_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.requested_model": %w`, err)}
  708. }
  709. }
  710. if v, ok := _c.mutation.UpstreamModel(); ok {
  711. if err := usagelog.UpstreamModelValidator(v); err != nil {
  712. return &ValidationError{Name: "upstream_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.upstream_model": %w`, err)}
  713. }
  714. }
  715. if v, ok := _c.mutation.UpstreamResponseModel(); ok {
  716. if err := usagelog.UpstreamResponseModelValidator(v); err != nil {
  717. return &ValidationError{Name: "upstream_response_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.upstream_response_model": %w`, err)}
  718. }
  719. }
  720. if v, ok := _c.mutation.ModelMappingChain(); ok {
  721. if err := usagelog.ModelMappingChainValidator(v); err != nil {
  722. return &ValidationError{Name: "model_mapping_chain", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model_mapping_chain": %w`, err)}
  723. }
  724. }
  725. if v, ok := _c.mutation.BillingTier(); ok {
  726. if err := usagelog.BillingTierValidator(v); err != nil {
  727. return &ValidationError{Name: "billing_tier", err: fmt.Errorf(`ent: validator failed for field "UsageLog.billing_tier": %w`, err)}
  728. }
  729. }
  730. if v, ok := _c.mutation.BillingMode(); ok {
  731. if err := usagelog.BillingModeValidator(v); err != nil {
  732. return &ValidationError{Name: "billing_mode", err: fmt.Errorf(`ent: validator failed for field "UsageLog.billing_mode": %w`, err)}
  733. }
  734. }
  735. if _, ok := _c.mutation.InputTokens(); !ok {
  736. return &ValidationError{Name: "input_tokens", err: errors.New(`ent: missing required field "UsageLog.input_tokens"`)}
  737. }
  738. if _, ok := _c.mutation.OutputTokens(); !ok {
  739. return &ValidationError{Name: "output_tokens", err: errors.New(`ent: missing required field "UsageLog.output_tokens"`)}
  740. }
  741. if _, ok := _c.mutation.CacheCreationTokens(); !ok {
  742. return &ValidationError{Name: "cache_creation_tokens", err: errors.New(`ent: missing required field "UsageLog.cache_creation_tokens"`)}
  743. }
  744. if _, ok := _c.mutation.CacheReadTokens(); !ok {
  745. return &ValidationError{Name: "cache_read_tokens", err: errors.New(`ent: missing required field "UsageLog.cache_read_tokens"`)}
  746. }
  747. if _, ok := _c.mutation.CacheCreation5mTokens(); !ok {
  748. return &ValidationError{Name: "cache_creation_5m_tokens", err: errors.New(`ent: missing required field "UsageLog.cache_creation_5m_tokens"`)}
  749. }
  750. if _, ok := _c.mutation.CacheCreation1hTokens(); !ok {
  751. return &ValidationError{Name: "cache_creation_1h_tokens", err: errors.New(`ent: missing required field "UsageLog.cache_creation_1h_tokens"`)}
  752. }
  753. if _, ok := _c.mutation.InputCost(); !ok {
  754. return &ValidationError{Name: "input_cost", err: errors.New(`ent: missing required field "UsageLog.input_cost"`)}
  755. }
  756. if _, ok := _c.mutation.OutputCost(); !ok {
  757. return &ValidationError{Name: "output_cost", err: errors.New(`ent: missing required field "UsageLog.output_cost"`)}
  758. }
  759. if _, ok := _c.mutation.CacheCreationCost(); !ok {
  760. return &ValidationError{Name: "cache_creation_cost", err: errors.New(`ent: missing required field "UsageLog.cache_creation_cost"`)}
  761. }
  762. if _, ok := _c.mutation.CacheReadCost(); !ok {
  763. return &ValidationError{Name: "cache_read_cost", err: errors.New(`ent: missing required field "UsageLog.cache_read_cost"`)}
  764. }
  765. if _, ok := _c.mutation.TotalCost(); !ok {
  766. return &ValidationError{Name: "total_cost", err: errors.New(`ent: missing required field "UsageLog.total_cost"`)}
  767. }
  768. if _, ok := _c.mutation.ActualCost(); !ok {
  769. return &ValidationError{Name: "actual_cost", err: errors.New(`ent: missing required field "UsageLog.actual_cost"`)}
  770. }
  771. if _, ok := _c.mutation.RateMultiplier(); !ok {
  772. return &ValidationError{Name: "rate_multiplier", err: errors.New(`ent: missing required field "UsageLog.rate_multiplier"`)}
  773. }
  774. if _, ok := _c.mutation.LongContextBillingApplied(); !ok {
  775. return &ValidationError{Name: "long_context_billing_applied", err: errors.New(`ent: missing required field "UsageLog.long_context_billing_applied"`)}
  776. }
  777. if _, ok := _c.mutation.BillingType(); !ok {
  778. return &ValidationError{Name: "billing_type", err: errors.New(`ent: missing required field "UsageLog.billing_type"`)}
  779. }
  780. if _, ok := _c.mutation.Stream(); !ok {
  781. return &ValidationError{Name: "stream", err: errors.New(`ent: missing required field "UsageLog.stream"`)}
  782. }
  783. if v, ok := _c.mutation.UserAgent(); ok {
  784. if err := usagelog.UserAgentValidator(v); err != nil {
  785. return &ValidationError{Name: "user_agent", err: fmt.Errorf(`ent: validator failed for field "UsageLog.user_agent": %w`, err)}
  786. }
  787. }
  788. if v, ok := _c.mutation.IPAddress(); ok {
  789. if err := usagelog.IPAddressValidator(v); err != nil {
  790. return &ValidationError{Name: "ip_address", err: fmt.Errorf(`ent: validator failed for field "UsageLog.ip_address": %w`, err)}
  791. }
  792. }
  793. if _, ok := _c.mutation.ImageCount(); !ok {
  794. return &ValidationError{Name: "image_count", err: errors.New(`ent: missing required field "UsageLog.image_count"`)}
  795. }
  796. if v, ok := _c.mutation.ImageSize(); ok {
  797. if err := usagelog.ImageSizeValidator(v); err != nil {
  798. return &ValidationError{Name: "image_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size": %w`, err)}
  799. }
  800. }
  801. if v, ok := _c.mutation.ImageInputSize(); ok {
  802. if err := usagelog.ImageInputSizeValidator(v); err != nil {
  803. return &ValidationError{Name: "image_input_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_input_size": %w`, err)}
  804. }
  805. }
  806. if v, ok := _c.mutation.ImageOutputSize(); ok {
  807. if err := usagelog.ImageOutputSizeValidator(v); err != nil {
  808. return &ValidationError{Name: "image_output_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_output_size": %w`, err)}
  809. }
  810. }
  811. if v, ok := _c.mutation.ImageSizeSource(); ok {
  812. if err := usagelog.ImageSizeSourceValidator(v); err != nil {
  813. return &ValidationError{Name: "image_size_source", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size_source": %w`, err)}
  814. }
  815. }
  816. if _, ok := _c.mutation.VideoCount(); !ok {
  817. return &ValidationError{Name: "video_count", err: errors.New(`ent: missing required field "UsageLog.video_count"`)}
  818. }
  819. if v, ok := _c.mutation.VideoResolution(); ok {
  820. if err := usagelog.VideoResolutionValidator(v); err != nil {
  821. return &ValidationError{Name: "video_resolution", err: fmt.Errorf(`ent: validator failed for field "UsageLog.video_resolution": %w`, err)}
  822. }
  823. }
  824. if _, ok := _c.mutation.CacheTTLOverridden(); !ok {
  825. return &ValidationError{Name: "cache_ttl_overridden", err: errors.New(`ent: missing required field "UsageLog.cache_ttl_overridden"`)}
  826. }
  827. if _, ok := _c.mutation.CreatedAt(); !ok {
  828. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UsageLog.created_at"`)}
  829. }
  830. if len(_c.mutation.UserIDs()) == 0 {
  831. return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UsageLog.user"`)}
  832. }
  833. if len(_c.mutation.APIKeyIDs()) == 0 {
  834. return &ValidationError{Name: "api_key", err: errors.New(`ent: missing required edge "UsageLog.api_key"`)}
  835. }
  836. if len(_c.mutation.AccountIDs()) == 0 {
  837. return &ValidationError{Name: "account", err: errors.New(`ent: missing required edge "UsageLog.account"`)}
  838. }
  839. return nil
  840. }
  841. func (_c *UsageLogCreate) sqlSave(ctx context.Context) (*UsageLog, error) {
  842. if err := _c.check(); err != nil {
  843. return nil, err
  844. }
  845. _node, _spec := _c.createSpec()
  846. if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
  847. if sqlgraph.IsConstraintError(err) {
  848. err = &ConstraintError{msg: err.Error(), wrap: err}
  849. }
  850. return nil, err
  851. }
  852. id := _spec.ID.Value.(int64)
  853. _node.ID = int64(id)
  854. _c.mutation.id = &_node.ID
  855. _c.mutation.done = true
  856. return _node, nil
  857. }
  858. func (_c *UsageLogCreate) createSpec() (*UsageLog, *sqlgraph.CreateSpec) {
  859. var (
  860. _node = &UsageLog{config: _c.config}
  861. _spec = sqlgraph.NewCreateSpec(usagelog.Table, sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64))
  862. )
  863. _spec.OnConflict = _c.conflict
  864. if value, ok := _c.mutation.RequestID(); ok {
  865. _spec.SetField(usagelog.FieldRequestID, field.TypeString, value)
  866. _node.RequestID = value
  867. }
  868. if value, ok := _c.mutation.Model(); ok {
  869. _spec.SetField(usagelog.FieldModel, field.TypeString, value)
  870. _node.Model = value
  871. }
  872. if value, ok := _c.mutation.RequestedModel(); ok {
  873. _spec.SetField(usagelog.FieldRequestedModel, field.TypeString, value)
  874. _node.RequestedModel = &value
  875. }
  876. if value, ok := _c.mutation.UpstreamModel(); ok {
  877. _spec.SetField(usagelog.FieldUpstreamModel, field.TypeString, value)
  878. _node.UpstreamModel = &value
  879. }
  880. if value, ok := _c.mutation.UpstreamResponseModel(); ok {
  881. _spec.SetField(usagelog.FieldUpstreamResponseModel, field.TypeString, value)
  882. _node.UpstreamResponseModel = &value
  883. }
  884. if value, ok := _c.mutation.UpstreamModelMismatch(); ok {
  885. _spec.SetField(usagelog.FieldUpstreamModelMismatch, field.TypeBool, value)
  886. _node.UpstreamModelMismatch = &value
  887. }
  888. if value, ok := _c.mutation.ChannelID(); ok {
  889. _spec.SetField(usagelog.FieldChannelID, field.TypeInt64, value)
  890. _node.ChannelID = &value
  891. }
  892. if value, ok := _c.mutation.ModelMappingChain(); ok {
  893. _spec.SetField(usagelog.FieldModelMappingChain, field.TypeString, value)
  894. _node.ModelMappingChain = &value
  895. }
  896. if value, ok := _c.mutation.BillingTier(); ok {
  897. _spec.SetField(usagelog.FieldBillingTier, field.TypeString, value)
  898. _node.BillingTier = &value
  899. }
  900. if value, ok := _c.mutation.BillingMode(); ok {
  901. _spec.SetField(usagelog.FieldBillingMode, field.TypeString, value)
  902. _node.BillingMode = &value
  903. }
  904. if value, ok := _c.mutation.InputTokens(); ok {
  905. _spec.SetField(usagelog.FieldInputTokens, field.TypeInt, value)
  906. _node.InputTokens = value
  907. }
  908. if value, ok := _c.mutation.OutputTokens(); ok {
  909. _spec.SetField(usagelog.FieldOutputTokens, field.TypeInt, value)
  910. _node.OutputTokens = value
  911. }
  912. if value, ok := _c.mutation.CacheCreationTokens(); ok {
  913. _spec.SetField(usagelog.FieldCacheCreationTokens, field.TypeInt, value)
  914. _node.CacheCreationTokens = value
  915. }
  916. if value, ok := _c.mutation.CacheReadTokens(); ok {
  917. _spec.SetField(usagelog.FieldCacheReadTokens, field.TypeInt, value)
  918. _node.CacheReadTokens = value
  919. }
  920. if value, ok := _c.mutation.CacheCreation5mTokens(); ok {
  921. _spec.SetField(usagelog.FieldCacheCreation5mTokens, field.TypeInt, value)
  922. _node.CacheCreation5mTokens = value
  923. }
  924. if value, ok := _c.mutation.CacheCreation1hTokens(); ok {
  925. _spec.SetField(usagelog.FieldCacheCreation1hTokens, field.TypeInt, value)
  926. _node.CacheCreation1hTokens = value
  927. }
  928. if value, ok := _c.mutation.InputCost(); ok {
  929. _spec.SetField(usagelog.FieldInputCost, field.TypeFloat64, value)
  930. _node.InputCost = value
  931. }
  932. if value, ok := _c.mutation.OutputCost(); ok {
  933. _spec.SetField(usagelog.FieldOutputCost, field.TypeFloat64, value)
  934. _node.OutputCost = value
  935. }
  936. if value, ok := _c.mutation.CacheCreationCost(); ok {
  937. _spec.SetField(usagelog.FieldCacheCreationCost, field.TypeFloat64, value)
  938. _node.CacheCreationCost = value
  939. }
  940. if value, ok := _c.mutation.CacheReadCost(); ok {
  941. _spec.SetField(usagelog.FieldCacheReadCost, field.TypeFloat64, value)
  942. _node.CacheReadCost = value
  943. }
  944. if value, ok := _c.mutation.TotalCost(); ok {
  945. _spec.SetField(usagelog.FieldTotalCost, field.TypeFloat64, value)
  946. _node.TotalCost = value
  947. }
  948. if value, ok := _c.mutation.ActualCost(); ok {
  949. _spec.SetField(usagelog.FieldActualCost, field.TypeFloat64, value)
  950. _node.ActualCost = value
  951. }
  952. if value, ok := _c.mutation.RateMultiplier(); ok {
  953. _spec.SetField(usagelog.FieldRateMultiplier, field.TypeFloat64, value)
  954. _node.RateMultiplier = value
  955. }
  956. if value, ok := _c.mutation.LongContextBillingApplied(); ok {
  957. _spec.SetField(usagelog.FieldLongContextBillingApplied, field.TypeBool, value)
  958. _node.LongContextBillingApplied = value
  959. }
  960. if value, ok := _c.mutation.AccountRateMultiplier(); ok {
  961. _spec.SetField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64, value)
  962. _node.AccountRateMultiplier = &value
  963. }
  964. if value, ok := _c.mutation.BillingType(); ok {
  965. _spec.SetField(usagelog.FieldBillingType, field.TypeInt8, value)
  966. _node.BillingType = value
  967. }
  968. if value, ok := _c.mutation.Stream(); ok {
  969. _spec.SetField(usagelog.FieldStream, field.TypeBool, value)
  970. _node.Stream = value
  971. }
  972. if value, ok := _c.mutation.DurationMs(); ok {
  973. _spec.SetField(usagelog.FieldDurationMs, field.TypeInt, value)
  974. _node.DurationMs = &value
  975. }
  976. if value, ok := _c.mutation.FirstTokenMs(); ok {
  977. _spec.SetField(usagelog.FieldFirstTokenMs, field.TypeInt, value)
  978. _node.FirstTokenMs = &value
  979. }
  980. if value, ok := _c.mutation.UserAgent(); ok {
  981. _spec.SetField(usagelog.FieldUserAgent, field.TypeString, value)
  982. _node.UserAgent = &value
  983. }
  984. if value, ok := _c.mutation.IPAddress(); ok {
  985. _spec.SetField(usagelog.FieldIPAddress, field.TypeString, value)
  986. _node.IPAddress = &value
  987. }
  988. if value, ok := _c.mutation.ImageCount(); ok {
  989. _spec.SetField(usagelog.FieldImageCount, field.TypeInt, value)
  990. _node.ImageCount = value
  991. }
  992. if value, ok := _c.mutation.ImageSize(); ok {
  993. _spec.SetField(usagelog.FieldImageSize, field.TypeString, value)
  994. _node.ImageSize = &value
  995. }
  996. if value, ok := _c.mutation.ImageInputSize(); ok {
  997. _spec.SetField(usagelog.FieldImageInputSize, field.TypeString, value)
  998. _node.ImageInputSize = &value
  999. }
  1000. if value, ok := _c.mutation.ImageOutputSize(); ok {
  1001. _spec.SetField(usagelog.FieldImageOutputSize, field.TypeString, value)
  1002. _node.ImageOutputSize = &value
  1003. }
  1004. if value, ok := _c.mutation.ImageSizeSource(); ok {
  1005. _spec.SetField(usagelog.FieldImageSizeSource, field.TypeString, value)
  1006. _node.ImageSizeSource = &value
  1007. }
  1008. if value, ok := _c.mutation.ImageSizeBreakdown(); ok {
  1009. _spec.SetField(usagelog.FieldImageSizeBreakdown, field.TypeJSON, value)
  1010. _node.ImageSizeBreakdown = value
  1011. }
  1012. if value, ok := _c.mutation.VideoCount(); ok {
  1013. _spec.SetField(usagelog.FieldVideoCount, field.TypeInt, value)
  1014. _node.VideoCount = value
  1015. }
  1016. if value, ok := _c.mutation.VideoResolution(); ok {
  1017. _spec.SetField(usagelog.FieldVideoResolution, field.TypeString, value)
  1018. _node.VideoResolution = &value
  1019. }
  1020. if value, ok := _c.mutation.VideoDurationSeconds(); ok {
  1021. _spec.SetField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value)
  1022. _node.VideoDurationSeconds = &value
  1023. }
  1024. if value, ok := _c.mutation.CacheTTLOverridden(); ok {
  1025. _spec.SetField(usagelog.FieldCacheTTLOverridden, field.TypeBool, value)
  1026. _node.CacheTTLOverridden = value
  1027. }
  1028. if value, ok := _c.mutation.CreatedAt(); ok {
  1029. _spec.SetField(usagelog.FieldCreatedAt, field.TypeTime, value)
  1030. _node.CreatedAt = value
  1031. }
  1032. if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
  1033. edge := &sqlgraph.EdgeSpec{
  1034. Rel: sqlgraph.M2O,
  1035. Inverse: true,
  1036. Table: usagelog.UserTable,
  1037. Columns: []string{usagelog.UserColumn},
  1038. Bidi: false,
  1039. Target: &sqlgraph.EdgeTarget{
  1040. IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
  1041. },
  1042. }
  1043. for _, k := range nodes {
  1044. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1045. }
  1046. _node.UserID = nodes[0]
  1047. _spec.Edges = append(_spec.Edges, edge)
  1048. }
  1049. if nodes := _c.mutation.APIKeyIDs(); len(nodes) > 0 {
  1050. edge := &sqlgraph.EdgeSpec{
  1051. Rel: sqlgraph.M2O,
  1052. Inverse: true,
  1053. Table: usagelog.APIKeyTable,
  1054. Columns: []string{usagelog.APIKeyColumn},
  1055. Bidi: false,
  1056. Target: &sqlgraph.EdgeTarget{
  1057. IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
  1058. },
  1059. }
  1060. for _, k := range nodes {
  1061. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1062. }
  1063. _node.APIKeyID = nodes[0]
  1064. _spec.Edges = append(_spec.Edges, edge)
  1065. }
  1066. if nodes := _c.mutation.AccountIDs(); len(nodes) > 0 {
  1067. edge := &sqlgraph.EdgeSpec{
  1068. Rel: sqlgraph.M2O,
  1069. Inverse: true,
  1070. Table: usagelog.AccountTable,
  1071. Columns: []string{usagelog.AccountColumn},
  1072. Bidi: false,
  1073. Target: &sqlgraph.EdgeTarget{
  1074. IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
  1075. },
  1076. }
  1077. for _, k := range nodes {
  1078. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1079. }
  1080. _node.AccountID = nodes[0]
  1081. _spec.Edges = append(_spec.Edges, edge)
  1082. }
  1083. if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
  1084. edge := &sqlgraph.EdgeSpec{
  1085. Rel: sqlgraph.M2O,
  1086. Inverse: true,
  1087. Table: usagelog.GroupTable,
  1088. Columns: []string{usagelog.GroupColumn},
  1089. Bidi: false,
  1090. Target: &sqlgraph.EdgeTarget{
  1091. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  1092. },
  1093. }
  1094. for _, k := range nodes {
  1095. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1096. }
  1097. _node.GroupID = &nodes[0]
  1098. _spec.Edges = append(_spec.Edges, edge)
  1099. }
  1100. if nodes := _c.mutation.SubscriptionIDs(); len(nodes) > 0 {
  1101. edge := &sqlgraph.EdgeSpec{
  1102. Rel: sqlgraph.M2O,
  1103. Inverse: true,
  1104. Table: usagelog.SubscriptionTable,
  1105. Columns: []string{usagelog.SubscriptionColumn},
  1106. Bidi: false,
  1107. Target: &sqlgraph.EdgeTarget{
  1108. IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
  1109. },
  1110. }
  1111. for _, k := range nodes {
  1112. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1113. }
  1114. _node.SubscriptionID = &nodes[0]
  1115. _spec.Edges = append(_spec.Edges, edge)
  1116. }
  1117. return _node, _spec
  1118. }
  1119. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1120. // of the `INSERT` statement. For example:
  1121. //
  1122. // client.UsageLog.Create().
  1123. // SetUserID(v).
  1124. // OnConflict(
  1125. // // Update the row with the new values
  1126. // // the was proposed for insertion.
  1127. // sql.ResolveWithNewValues(),
  1128. // ).
  1129. // // Override some of the fields with custom
  1130. // // update values.
  1131. // Update(func(u *ent.UsageLogUpsert) {
  1132. // SetUserID(v+v).
  1133. // }).
  1134. // Exec(ctx)
  1135. func (_c *UsageLogCreate) OnConflict(opts ...sql.ConflictOption) *UsageLogUpsertOne {
  1136. _c.conflict = opts
  1137. return &UsageLogUpsertOne{
  1138. create: _c,
  1139. }
  1140. }
  1141. // OnConflictColumns calls `OnConflict` and configures the columns
  1142. // as conflict target. Using this option is equivalent to using:
  1143. //
  1144. // client.UsageLog.Create().
  1145. // OnConflict(sql.ConflictColumns(columns...)).
  1146. // Exec(ctx)
  1147. func (_c *UsageLogCreate) OnConflictColumns(columns ...string) *UsageLogUpsertOne {
  1148. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  1149. return &UsageLogUpsertOne{
  1150. create: _c,
  1151. }
  1152. }
  1153. type (
  1154. // UsageLogUpsertOne is the builder for "upsert"-ing
  1155. // one UsageLog node.
  1156. UsageLogUpsertOne struct {
  1157. create *UsageLogCreate
  1158. }
  1159. // UsageLogUpsert is the "OnConflict" setter.
  1160. UsageLogUpsert struct {
  1161. *sql.UpdateSet
  1162. }
  1163. )
  1164. // SetUserID sets the "user_id" field.
  1165. func (u *UsageLogUpsert) SetUserID(v int64) *UsageLogUpsert {
  1166. u.Set(usagelog.FieldUserID, v)
  1167. return u
  1168. }
  1169. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  1170. func (u *UsageLogUpsert) UpdateUserID() *UsageLogUpsert {
  1171. u.SetExcluded(usagelog.FieldUserID)
  1172. return u
  1173. }
  1174. // SetAPIKeyID sets the "api_key_id" field.
  1175. func (u *UsageLogUpsert) SetAPIKeyID(v int64) *UsageLogUpsert {
  1176. u.Set(usagelog.FieldAPIKeyID, v)
  1177. return u
  1178. }
  1179. // UpdateAPIKeyID sets the "api_key_id" field to the value that was provided on create.
  1180. func (u *UsageLogUpsert) UpdateAPIKeyID() *UsageLogUpsert {
  1181. u.SetExcluded(usagelog.FieldAPIKeyID)
  1182. return u
  1183. }
  1184. // SetAccountID sets the "account_id" field.
  1185. func (u *UsageLogUpsert) SetAccountID(v int64) *UsageLogUpsert {
  1186. u.Set(usagelog.FieldAccountID, v)
  1187. return u
  1188. }
  1189. // UpdateAccountID sets the "account_id" field to the value that was provided on create.
  1190. func (u *UsageLogUpsert) UpdateAccountID() *UsageLogUpsert {
  1191. u.SetExcluded(usagelog.FieldAccountID)
  1192. return u
  1193. }
  1194. // SetRequestID sets the "request_id" field.
  1195. func (u *UsageLogUpsert) SetRequestID(v string) *UsageLogUpsert {
  1196. u.Set(usagelog.FieldRequestID, v)
  1197. return u
  1198. }
  1199. // UpdateRequestID sets the "request_id" field to the value that was provided on create.
  1200. func (u *UsageLogUpsert) UpdateRequestID() *UsageLogUpsert {
  1201. u.SetExcluded(usagelog.FieldRequestID)
  1202. return u
  1203. }
  1204. // SetModel sets the "model" field.
  1205. func (u *UsageLogUpsert) SetModel(v string) *UsageLogUpsert {
  1206. u.Set(usagelog.FieldModel, v)
  1207. return u
  1208. }
  1209. // UpdateModel sets the "model" field to the value that was provided on create.
  1210. func (u *UsageLogUpsert) UpdateModel() *UsageLogUpsert {
  1211. u.SetExcluded(usagelog.FieldModel)
  1212. return u
  1213. }
  1214. // SetRequestedModel sets the "requested_model" field.
  1215. func (u *UsageLogUpsert) SetRequestedModel(v string) *UsageLogUpsert {
  1216. u.Set(usagelog.FieldRequestedModel, v)
  1217. return u
  1218. }
  1219. // UpdateRequestedModel sets the "requested_model" field to the value that was provided on create.
  1220. func (u *UsageLogUpsert) UpdateRequestedModel() *UsageLogUpsert {
  1221. u.SetExcluded(usagelog.FieldRequestedModel)
  1222. return u
  1223. }
  1224. // ClearRequestedModel clears the value of the "requested_model" field.
  1225. func (u *UsageLogUpsert) ClearRequestedModel() *UsageLogUpsert {
  1226. u.SetNull(usagelog.FieldRequestedModel)
  1227. return u
  1228. }
  1229. // SetUpstreamModel sets the "upstream_model" field.
  1230. func (u *UsageLogUpsert) SetUpstreamModel(v string) *UsageLogUpsert {
  1231. u.Set(usagelog.FieldUpstreamModel, v)
  1232. return u
  1233. }
  1234. // UpdateUpstreamModel sets the "upstream_model" field to the value that was provided on create.
  1235. func (u *UsageLogUpsert) UpdateUpstreamModel() *UsageLogUpsert {
  1236. u.SetExcluded(usagelog.FieldUpstreamModel)
  1237. return u
  1238. }
  1239. // ClearUpstreamModel clears the value of the "upstream_model" field.
  1240. func (u *UsageLogUpsert) ClearUpstreamModel() *UsageLogUpsert {
  1241. u.SetNull(usagelog.FieldUpstreamModel)
  1242. return u
  1243. }
  1244. // SetUpstreamResponseModel sets the "upstream_response_model" field.
  1245. func (u *UsageLogUpsert) SetUpstreamResponseModel(v string) *UsageLogUpsert {
  1246. u.Set(usagelog.FieldUpstreamResponseModel, v)
  1247. return u
  1248. }
  1249. // UpdateUpstreamResponseModel sets the "upstream_response_model" field to the value that was provided on create.
  1250. func (u *UsageLogUpsert) UpdateUpstreamResponseModel() *UsageLogUpsert {
  1251. u.SetExcluded(usagelog.FieldUpstreamResponseModel)
  1252. return u
  1253. }
  1254. // ClearUpstreamResponseModel clears the value of the "upstream_response_model" field.
  1255. func (u *UsageLogUpsert) ClearUpstreamResponseModel() *UsageLogUpsert {
  1256. u.SetNull(usagelog.FieldUpstreamResponseModel)
  1257. return u
  1258. }
  1259. // SetUpstreamModelMismatch sets the "upstream_model_mismatch" field.
  1260. func (u *UsageLogUpsert) SetUpstreamModelMismatch(v bool) *UsageLogUpsert {
  1261. u.Set(usagelog.FieldUpstreamModelMismatch, v)
  1262. return u
  1263. }
  1264. // UpdateUpstreamModelMismatch sets the "upstream_model_mismatch" field to the value that was provided on create.
  1265. func (u *UsageLogUpsert) UpdateUpstreamModelMismatch() *UsageLogUpsert {
  1266. u.SetExcluded(usagelog.FieldUpstreamModelMismatch)
  1267. return u
  1268. }
  1269. // ClearUpstreamModelMismatch clears the value of the "upstream_model_mismatch" field.
  1270. func (u *UsageLogUpsert) ClearUpstreamModelMismatch() *UsageLogUpsert {
  1271. u.SetNull(usagelog.FieldUpstreamModelMismatch)
  1272. return u
  1273. }
  1274. // SetChannelID sets the "channel_id" field.
  1275. func (u *UsageLogUpsert) SetChannelID(v int64) *UsageLogUpsert {
  1276. u.Set(usagelog.FieldChannelID, v)
  1277. return u
  1278. }
  1279. // UpdateChannelID sets the "channel_id" field to the value that was provided on create.
  1280. func (u *UsageLogUpsert) UpdateChannelID() *UsageLogUpsert {
  1281. u.SetExcluded(usagelog.FieldChannelID)
  1282. return u
  1283. }
  1284. // AddChannelID adds v to the "channel_id" field.
  1285. func (u *UsageLogUpsert) AddChannelID(v int64) *UsageLogUpsert {
  1286. u.Add(usagelog.FieldChannelID, v)
  1287. return u
  1288. }
  1289. // ClearChannelID clears the value of the "channel_id" field.
  1290. func (u *UsageLogUpsert) ClearChannelID() *UsageLogUpsert {
  1291. u.SetNull(usagelog.FieldChannelID)
  1292. return u
  1293. }
  1294. // SetModelMappingChain sets the "model_mapping_chain" field.
  1295. func (u *UsageLogUpsert) SetModelMappingChain(v string) *UsageLogUpsert {
  1296. u.Set(usagelog.FieldModelMappingChain, v)
  1297. return u
  1298. }
  1299. // UpdateModelMappingChain sets the "model_mapping_chain" field to the value that was provided on create.
  1300. func (u *UsageLogUpsert) UpdateModelMappingChain() *UsageLogUpsert {
  1301. u.SetExcluded(usagelog.FieldModelMappingChain)
  1302. return u
  1303. }
  1304. // ClearModelMappingChain clears the value of the "model_mapping_chain" field.
  1305. func (u *UsageLogUpsert) ClearModelMappingChain() *UsageLogUpsert {
  1306. u.SetNull(usagelog.FieldModelMappingChain)
  1307. return u
  1308. }
  1309. // SetBillingTier sets the "billing_tier" field.
  1310. func (u *UsageLogUpsert) SetBillingTier(v string) *UsageLogUpsert {
  1311. u.Set(usagelog.FieldBillingTier, v)
  1312. return u
  1313. }
  1314. // UpdateBillingTier sets the "billing_tier" field to the value that was provided on create.
  1315. func (u *UsageLogUpsert) UpdateBillingTier() *UsageLogUpsert {
  1316. u.SetExcluded(usagelog.FieldBillingTier)
  1317. return u
  1318. }
  1319. // ClearBillingTier clears the value of the "billing_tier" field.
  1320. func (u *UsageLogUpsert) ClearBillingTier() *UsageLogUpsert {
  1321. u.SetNull(usagelog.FieldBillingTier)
  1322. return u
  1323. }
  1324. // SetBillingMode sets the "billing_mode" field.
  1325. func (u *UsageLogUpsert) SetBillingMode(v string) *UsageLogUpsert {
  1326. u.Set(usagelog.FieldBillingMode, v)
  1327. return u
  1328. }
  1329. // UpdateBillingMode sets the "billing_mode" field to the value that was provided on create.
  1330. func (u *UsageLogUpsert) UpdateBillingMode() *UsageLogUpsert {
  1331. u.SetExcluded(usagelog.FieldBillingMode)
  1332. return u
  1333. }
  1334. // ClearBillingMode clears the value of the "billing_mode" field.
  1335. func (u *UsageLogUpsert) ClearBillingMode() *UsageLogUpsert {
  1336. u.SetNull(usagelog.FieldBillingMode)
  1337. return u
  1338. }
  1339. // SetGroupID sets the "group_id" field.
  1340. func (u *UsageLogUpsert) SetGroupID(v int64) *UsageLogUpsert {
  1341. u.Set(usagelog.FieldGroupID, v)
  1342. return u
  1343. }
  1344. // UpdateGroupID sets the "group_id" field to the value that was provided on create.
  1345. func (u *UsageLogUpsert) UpdateGroupID() *UsageLogUpsert {
  1346. u.SetExcluded(usagelog.FieldGroupID)
  1347. return u
  1348. }
  1349. // ClearGroupID clears the value of the "group_id" field.
  1350. func (u *UsageLogUpsert) ClearGroupID() *UsageLogUpsert {
  1351. u.SetNull(usagelog.FieldGroupID)
  1352. return u
  1353. }
  1354. // SetSubscriptionID sets the "subscription_id" field.
  1355. func (u *UsageLogUpsert) SetSubscriptionID(v int64) *UsageLogUpsert {
  1356. u.Set(usagelog.FieldSubscriptionID, v)
  1357. return u
  1358. }
  1359. // UpdateSubscriptionID sets the "subscription_id" field to the value that was provided on create.
  1360. func (u *UsageLogUpsert) UpdateSubscriptionID() *UsageLogUpsert {
  1361. u.SetExcluded(usagelog.FieldSubscriptionID)
  1362. return u
  1363. }
  1364. // ClearSubscriptionID clears the value of the "subscription_id" field.
  1365. func (u *UsageLogUpsert) ClearSubscriptionID() *UsageLogUpsert {
  1366. u.SetNull(usagelog.FieldSubscriptionID)
  1367. return u
  1368. }
  1369. // SetInputTokens sets the "input_tokens" field.
  1370. func (u *UsageLogUpsert) SetInputTokens(v int) *UsageLogUpsert {
  1371. u.Set(usagelog.FieldInputTokens, v)
  1372. return u
  1373. }
  1374. // UpdateInputTokens sets the "input_tokens" field to the value that was provided on create.
  1375. func (u *UsageLogUpsert) UpdateInputTokens() *UsageLogUpsert {
  1376. u.SetExcluded(usagelog.FieldInputTokens)
  1377. return u
  1378. }
  1379. // AddInputTokens adds v to the "input_tokens" field.
  1380. func (u *UsageLogUpsert) AddInputTokens(v int) *UsageLogUpsert {
  1381. u.Add(usagelog.FieldInputTokens, v)
  1382. return u
  1383. }
  1384. // SetOutputTokens sets the "output_tokens" field.
  1385. func (u *UsageLogUpsert) SetOutputTokens(v int) *UsageLogUpsert {
  1386. u.Set(usagelog.FieldOutputTokens, v)
  1387. return u
  1388. }
  1389. // UpdateOutputTokens sets the "output_tokens" field to the value that was provided on create.
  1390. func (u *UsageLogUpsert) UpdateOutputTokens() *UsageLogUpsert {
  1391. u.SetExcluded(usagelog.FieldOutputTokens)
  1392. return u
  1393. }
  1394. // AddOutputTokens adds v to the "output_tokens" field.
  1395. func (u *UsageLogUpsert) AddOutputTokens(v int) *UsageLogUpsert {
  1396. u.Add(usagelog.FieldOutputTokens, v)
  1397. return u
  1398. }
  1399. // SetCacheCreationTokens sets the "cache_creation_tokens" field.
  1400. func (u *UsageLogUpsert) SetCacheCreationTokens(v int) *UsageLogUpsert {
  1401. u.Set(usagelog.FieldCacheCreationTokens, v)
  1402. return u
  1403. }
  1404. // UpdateCacheCreationTokens sets the "cache_creation_tokens" field to the value that was provided on create.
  1405. func (u *UsageLogUpsert) UpdateCacheCreationTokens() *UsageLogUpsert {
  1406. u.SetExcluded(usagelog.FieldCacheCreationTokens)
  1407. return u
  1408. }
  1409. // AddCacheCreationTokens adds v to the "cache_creation_tokens" field.
  1410. func (u *UsageLogUpsert) AddCacheCreationTokens(v int) *UsageLogUpsert {
  1411. u.Add(usagelog.FieldCacheCreationTokens, v)
  1412. return u
  1413. }
  1414. // SetCacheReadTokens sets the "cache_read_tokens" field.
  1415. func (u *UsageLogUpsert) SetCacheReadTokens(v int) *UsageLogUpsert {
  1416. u.Set(usagelog.FieldCacheReadTokens, v)
  1417. return u
  1418. }
  1419. // UpdateCacheReadTokens sets the "cache_read_tokens" field to the value that was provided on create.
  1420. func (u *UsageLogUpsert) UpdateCacheReadTokens() *UsageLogUpsert {
  1421. u.SetExcluded(usagelog.FieldCacheReadTokens)
  1422. return u
  1423. }
  1424. // AddCacheReadTokens adds v to the "cache_read_tokens" field.
  1425. func (u *UsageLogUpsert) AddCacheReadTokens(v int) *UsageLogUpsert {
  1426. u.Add(usagelog.FieldCacheReadTokens, v)
  1427. return u
  1428. }
  1429. // SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
  1430. func (u *UsageLogUpsert) SetCacheCreation5mTokens(v int) *UsageLogUpsert {
  1431. u.Set(usagelog.FieldCacheCreation5mTokens, v)
  1432. return u
  1433. }
  1434. // UpdateCacheCreation5mTokens sets the "cache_creation_5m_tokens" field to the value that was provided on create.
  1435. func (u *UsageLogUpsert) UpdateCacheCreation5mTokens() *UsageLogUpsert {
  1436. u.SetExcluded(usagelog.FieldCacheCreation5mTokens)
  1437. return u
  1438. }
  1439. // AddCacheCreation5mTokens adds v to the "cache_creation_5m_tokens" field.
  1440. func (u *UsageLogUpsert) AddCacheCreation5mTokens(v int) *UsageLogUpsert {
  1441. u.Add(usagelog.FieldCacheCreation5mTokens, v)
  1442. return u
  1443. }
  1444. // SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
  1445. func (u *UsageLogUpsert) SetCacheCreation1hTokens(v int) *UsageLogUpsert {
  1446. u.Set(usagelog.FieldCacheCreation1hTokens, v)
  1447. return u
  1448. }
  1449. // UpdateCacheCreation1hTokens sets the "cache_creation_1h_tokens" field to the value that was provided on create.
  1450. func (u *UsageLogUpsert) UpdateCacheCreation1hTokens() *UsageLogUpsert {
  1451. u.SetExcluded(usagelog.FieldCacheCreation1hTokens)
  1452. return u
  1453. }
  1454. // AddCacheCreation1hTokens adds v to the "cache_creation_1h_tokens" field.
  1455. func (u *UsageLogUpsert) AddCacheCreation1hTokens(v int) *UsageLogUpsert {
  1456. u.Add(usagelog.FieldCacheCreation1hTokens, v)
  1457. return u
  1458. }
  1459. // SetInputCost sets the "input_cost" field.
  1460. func (u *UsageLogUpsert) SetInputCost(v float64) *UsageLogUpsert {
  1461. u.Set(usagelog.FieldInputCost, v)
  1462. return u
  1463. }
  1464. // UpdateInputCost sets the "input_cost" field to the value that was provided on create.
  1465. func (u *UsageLogUpsert) UpdateInputCost() *UsageLogUpsert {
  1466. u.SetExcluded(usagelog.FieldInputCost)
  1467. return u
  1468. }
  1469. // AddInputCost adds v to the "input_cost" field.
  1470. func (u *UsageLogUpsert) AddInputCost(v float64) *UsageLogUpsert {
  1471. u.Add(usagelog.FieldInputCost, v)
  1472. return u
  1473. }
  1474. // SetOutputCost sets the "output_cost" field.
  1475. func (u *UsageLogUpsert) SetOutputCost(v float64) *UsageLogUpsert {
  1476. u.Set(usagelog.FieldOutputCost, v)
  1477. return u
  1478. }
  1479. // UpdateOutputCost sets the "output_cost" field to the value that was provided on create.
  1480. func (u *UsageLogUpsert) UpdateOutputCost() *UsageLogUpsert {
  1481. u.SetExcluded(usagelog.FieldOutputCost)
  1482. return u
  1483. }
  1484. // AddOutputCost adds v to the "output_cost" field.
  1485. func (u *UsageLogUpsert) AddOutputCost(v float64) *UsageLogUpsert {
  1486. u.Add(usagelog.FieldOutputCost, v)
  1487. return u
  1488. }
  1489. // SetCacheCreationCost sets the "cache_creation_cost" field.
  1490. func (u *UsageLogUpsert) SetCacheCreationCost(v float64) *UsageLogUpsert {
  1491. u.Set(usagelog.FieldCacheCreationCost, v)
  1492. return u
  1493. }
  1494. // UpdateCacheCreationCost sets the "cache_creation_cost" field to the value that was provided on create.
  1495. func (u *UsageLogUpsert) UpdateCacheCreationCost() *UsageLogUpsert {
  1496. u.SetExcluded(usagelog.FieldCacheCreationCost)
  1497. return u
  1498. }
  1499. // AddCacheCreationCost adds v to the "cache_creation_cost" field.
  1500. func (u *UsageLogUpsert) AddCacheCreationCost(v float64) *UsageLogUpsert {
  1501. u.Add(usagelog.FieldCacheCreationCost, v)
  1502. return u
  1503. }
  1504. // SetCacheReadCost sets the "cache_read_cost" field.
  1505. func (u *UsageLogUpsert) SetCacheReadCost(v float64) *UsageLogUpsert {
  1506. u.Set(usagelog.FieldCacheReadCost, v)
  1507. return u
  1508. }
  1509. // UpdateCacheReadCost sets the "cache_read_cost" field to the value that was provided on create.
  1510. func (u *UsageLogUpsert) UpdateCacheReadCost() *UsageLogUpsert {
  1511. u.SetExcluded(usagelog.FieldCacheReadCost)
  1512. return u
  1513. }
  1514. // AddCacheReadCost adds v to the "cache_read_cost" field.
  1515. func (u *UsageLogUpsert) AddCacheReadCost(v float64) *UsageLogUpsert {
  1516. u.Add(usagelog.FieldCacheReadCost, v)
  1517. return u
  1518. }
  1519. // SetTotalCost sets the "total_cost" field.
  1520. func (u *UsageLogUpsert) SetTotalCost(v float64) *UsageLogUpsert {
  1521. u.Set(usagelog.FieldTotalCost, v)
  1522. return u
  1523. }
  1524. // UpdateTotalCost sets the "total_cost" field to the value that was provided on create.
  1525. func (u *UsageLogUpsert) UpdateTotalCost() *UsageLogUpsert {
  1526. u.SetExcluded(usagelog.FieldTotalCost)
  1527. return u
  1528. }
  1529. // AddTotalCost adds v to the "total_cost" field.
  1530. func (u *UsageLogUpsert) AddTotalCost(v float64) *UsageLogUpsert {
  1531. u.Add(usagelog.FieldTotalCost, v)
  1532. return u
  1533. }
  1534. // SetActualCost sets the "actual_cost" field.
  1535. func (u *UsageLogUpsert) SetActualCost(v float64) *UsageLogUpsert {
  1536. u.Set(usagelog.FieldActualCost, v)
  1537. return u
  1538. }
  1539. // UpdateActualCost sets the "actual_cost" field to the value that was provided on create.
  1540. func (u *UsageLogUpsert) UpdateActualCost() *UsageLogUpsert {
  1541. u.SetExcluded(usagelog.FieldActualCost)
  1542. return u
  1543. }
  1544. // AddActualCost adds v to the "actual_cost" field.
  1545. func (u *UsageLogUpsert) AddActualCost(v float64) *UsageLogUpsert {
  1546. u.Add(usagelog.FieldActualCost, v)
  1547. return u
  1548. }
  1549. // SetRateMultiplier sets the "rate_multiplier" field.
  1550. func (u *UsageLogUpsert) SetRateMultiplier(v float64) *UsageLogUpsert {
  1551. u.Set(usagelog.FieldRateMultiplier, v)
  1552. return u
  1553. }
  1554. // UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
  1555. func (u *UsageLogUpsert) UpdateRateMultiplier() *UsageLogUpsert {
  1556. u.SetExcluded(usagelog.FieldRateMultiplier)
  1557. return u
  1558. }
  1559. // AddRateMultiplier adds v to the "rate_multiplier" field.
  1560. func (u *UsageLogUpsert) AddRateMultiplier(v float64) *UsageLogUpsert {
  1561. u.Add(usagelog.FieldRateMultiplier, v)
  1562. return u
  1563. }
  1564. // SetLongContextBillingApplied sets the "long_context_billing_applied" field.
  1565. func (u *UsageLogUpsert) SetLongContextBillingApplied(v bool) *UsageLogUpsert {
  1566. u.Set(usagelog.FieldLongContextBillingApplied, v)
  1567. return u
  1568. }
  1569. // UpdateLongContextBillingApplied sets the "long_context_billing_applied" field to the value that was provided on create.
  1570. func (u *UsageLogUpsert) UpdateLongContextBillingApplied() *UsageLogUpsert {
  1571. u.SetExcluded(usagelog.FieldLongContextBillingApplied)
  1572. return u
  1573. }
  1574. // SetAccountRateMultiplier sets the "account_rate_multiplier" field.
  1575. func (u *UsageLogUpsert) SetAccountRateMultiplier(v float64) *UsageLogUpsert {
  1576. u.Set(usagelog.FieldAccountRateMultiplier, v)
  1577. return u
  1578. }
  1579. // UpdateAccountRateMultiplier sets the "account_rate_multiplier" field to the value that was provided on create.
  1580. func (u *UsageLogUpsert) UpdateAccountRateMultiplier() *UsageLogUpsert {
  1581. u.SetExcluded(usagelog.FieldAccountRateMultiplier)
  1582. return u
  1583. }
  1584. // AddAccountRateMultiplier adds v to the "account_rate_multiplier" field.
  1585. func (u *UsageLogUpsert) AddAccountRateMultiplier(v float64) *UsageLogUpsert {
  1586. u.Add(usagelog.FieldAccountRateMultiplier, v)
  1587. return u
  1588. }
  1589. // ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
  1590. func (u *UsageLogUpsert) ClearAccountRateMultiplier() *UsageLogUpsert {
  1591. u.SetNull(usagelog.FieldAccountRateMultiplier)
  1592. return u
  1593. }
  1594. // SetBillingType sets the "billing_type" field.
  1595. func (u *UsageLogUpsert) SetBillingType(v int8) *UsageLogUpsert {
  1596. u.Set(usagelog.FieldBillingType, v)
  1597. return u
  1598. }
  1599. // UpdateBillingType sets the "billing_type" field to the value that was provided on create.
  1600. func (u *UsageLogUpsert) UpdateBillingType() *UsageLogUpsert {
  1601. u.SetExcluded(usagelog.FieldBillingType)
  1602. return u
  1603. }
  1604. // AddBillingType adds v to the "billing_type" field.
  1605. func (u *UsageLogUpsert) AddBillingType(v int8) *UsageLogUpsert {
  1606. u.Add(usagelog.FieldBillingType, v)
  1607. return u
  1608. }
  1609. // SetStream sets the "stream" field.
  1610. func (u *UsageLogUpsert) SetStream(v bool) *UsageLogUpsert {
  1611. u.Set(usagelog.FieldStream, v)
  1612. return u
  1613. }
  1614. // UpdateStream sets the "stream" field to the value that was provided on create.
  1615. func (u *UsageLogUpsert) UpdateStream() *UsageLogUpsert {
  1616. u.SetExcluded(usagelog.FieldStream)
  1617. return u
  1618. }
  1619. // SetDurationMs sets the "duration_ms" field.
  1620. func (u *UsageLogUpsert) SetDurationMs(v int) *UsageLogUpsert {
  1621. u.Set(usagelog.FieldDurationMs, v)
  1622. return u
  1623. }
  1624. // UpdateDurationMs sets the "duration_ms" field to the value that was provided on create.
  1625. func (u *UsageLogUpsert) UpdateDurationMs() *UsageLogUpsert {
  1626. u.SetExcluded(usagelog.FieldDurationMs)
  1627. return u
  1628. }
  1629. // AddDurationMs adds v to the "duration_ms" field.
  1630. func (u *UsageLogUpsert) AddDurationMs(v int) *UsageLogUpsert {
  1631. u.Add(usagelog.FieldDurationMs, v)
  1632. return u
  1633. }
  1634. // ClearDurationMs clears the value of the "duration_ms" field.
  1635. func (u *UsageLogUpsert) ClearDurationMs() *UsageLogUpsert {
  1636. u.SetNull(usagelog.FieldDurationMs)
  1637. return u
  1638. }
  1639. // SetFirstTokenMs sets the "first_token_ms" field.
  1640. func (u *UsageLogUpsert) SetFirstTokenMs(v int) *UsageLogUpsert {
  1641. u.Set(usagelog.FieldFirstTokenMs, v)
  1642. return u
  1643. }
  1644. // UpdateFirstTokenMs sets the "first_token_ms" field to the value that was provided on create.
  1645. func (u *UsageLogUpsert) UpdateFirstTokenMs() *UsageLogUpsert {
  1646. u.SetExcluded(usagelog.FieldFirstTokenMs)
  1647. return u
  1648. }
  1649. // AddFirstTokenMs adds v to the "first_token_ms" field.
  1650. func (u *UsageLogUpsert) AddFirstTokenMs(v int) *UsageLogUpsert {
  1651. u.Add(usagelog.FieldFirstTokenMs, v)
  1652. return u
  1653. }
  1654. // ClearFirstTokenMs clears the value of the "first_token_ms" field.
  1655. func (u *UsageLogUpsert) ClearFirstTokenMs() *UsageLogUpsert {
  1656. u.SetNull(usagelog.FieldFirstTokenMs)
  1657. return u
  1658. }
  1659. // SetUserAgent sets the "user_agent" field.
  1660. func (u *UsageLogUpsert) SetUserAgent(v string) *UsageLogUpsert {
  1661. u.Set(usagelog.FieldUserAgent, v)
  1662. return u
  1663. }
  1664. // UpdateUserAgent sets the "user_agent" field to the value that was provided on create.
  1665. func (u *UsageLogUpsert) UpdateUserAgent() *UsageLogUpsert {
  1666. u.SetExcluded(usagelog.FieldUserAgent)
  1667. return u
  1668. }
  1669. // ClearUserAgent clears the value of the "user_agent" field.
  1670. func (u *UsageLogUpsert) ClearUserAgent() *UsageLogUpsert {
  1671. u.SetNull(usagelog.FieldUserAgent)
  1672. return u
  1673. }
  1674. // SetIPAddress sets the "ip_address" field.
  1675. func (u *UsageLogUpsert) SetIPAddress(v string) *UsageLogUpsert {
  1676. u.Set(usagelog.FieldIPAddress, v)
  1677. return u
  1678. }
  1679. // UpdateIPAddress sets the "ip_address" field to the value that was provided on create.
  1680. func (u *UsageLogUpsert) UpdateIPAddress() *UsageLogUpsert {
  1681. u.SetExcluded(usagelog.FieldIPAddress)
  1682. return u
  1683. }
  1684. // ClearIPAddress clears the value of the "ip_address" field.
  1685. func (u *UsageLogUpsert) ClearIPAddress() *UsageLogUpsert {
  1686. u.SetNull(usagelog.FieldIPAddress)
  1687. return u
  1688. }
  1689. // SetImageCount sets the "image_count" field.
  1690. func (u *UsageLogUpsert) SetImageCount(v int) *UsageLogUpsert {
  1691. u.Set(usagelog.FieldImageCount, v)
  1692. return u
  1693. }
  1694. // UpdateImageCount sets the "image_count" field to the value that was provided on create.
  1695. func (u *UsageLogUpsert) UpdateImageCount() *UsageLogUpsert {
  1696. u.SetExcluded(usagelog.FieldImageCount)
  1697. return u
  1698. }
  1699. // AddImageCount adds v to the "image_count" field.
  1700. func (u *UsageLogUpsert) AddImageCount(v int) *UsageLogUpsert {
  1701. u.Add(usagelog.FieldImageCount, v)
  1702. return u
  1703. }
  1704. // SetImageSize sets the "image_size" field.
  1705. func (u *UsageLogUpsert) SetImageSize(v string) *UsageLogUpsert {
  1706. u.Set(usagelog.FieldImageSize, v)
  1707. return u
  1708. }
  1709. // UpdateImageSize sets the "image_size" field to the value that was provided on create.
  1710. func (u *UsageLogUpsert) UpdateImageSize() *UsageLogUpsert {
  1711. u.SetExcluded(usagelog.FieldImageSize)
  1712. return u
  1713. }
  1714. // ClearImageSize clears the value of the "image_size" field.
  1715. func (u *UsageLogUpsert) ClearImageSize() *UsageLogUpsert {
  1716. u.SetNull(usagelog.FieldImageSize)
  1717. return u
  1718. }
  1719. // SetImageInputSize sets the "image_input_size" field.
  1720. func (u *UsageLogUpsert) SetImageInputSize(v string) *UsageLogUpsert {
  1721. u.Set(usagelog.FieldImageInputSize, v)
  1722. return u
  1723. }
  1724. // UpdateImageInputSize sets the "image_input_size" field to the value that was provided on create.
  1725. func (u *UsageLogUpsert) UpdateImageInputSize() *UsageLogUpsert {
  1726. u.SetExcluded(usagelog.FieldImageInputSize)
  1727. return u
  1728. }
  1729. // ClearImageInputSize clears the value of the "image_input_size" field.
  1730. func (u *UsageLogUpsert) ClearImageInputSize() *UsageLogUpsert {
  1731. u.SetNull(usagelog.FieldImageInputSize)
  1732. return u
  1733. }
  1734. // SetImageOutputSize sets the "image_output_size" field.
  1735. func (u *UsageLogUpsert) SetImageOutputSize(v string) *UsageLogUpsert {
  1736. u.Set(usagelog.FieldImageOutputSize, v)
  1737. return u
  1738. }
  1739. // UpdateImageOutputSize sets the "image_output_size" field to the value that was provided on create.
  1740. func (u *UsageLogUpsert) UpdateImageOutputSize() *UsageLogUpsert {
  1741. u.SetExcluded(usagelog.FieldImageOutputSize)
  1742. return u
  1743. }
  1744. // ClearImageOutputSize clears the value of the "image_output_size" field.
  1745. func (u *UsageLogUpsert) ClearImageOutputSize() *UsageLogUpsert {
  1746. u.SetNull(usagelog.FieldImageOutputSize)
  1747. return u
  1748. }
  1749. // SetImageSizeSource sets the "image_size_source" field.
  1750. func (u *UsageLogUpsert) SetImageSizeSource(v string) *UsageLogUpsert {
  1751. u.Set(usagelog.FieldImageSizeSource, v)
  1752. return u
  1753. }
  1754. // UpdateImageSizeSource sets the "image_size_source" field to the value that was provided on create.
  1755. func (u *UsageLogUpsert) UpdateImageSizeSource() *UsageLogUpsert {
  1756. u.SetExcluded(usagelog.FieldImageSizeSource)
  1757. return u
  1758. }
  1759. // ClearImageSizeSource clears the value of the "image_size_source" field.
  1760. func (u *UsageLogUpsert) ClearImageSizeSource() *UsageLogUpsert {
  1761. u.SetNull(usagelog.FieldImageSizeSource)
  1762. return u
  1763. }
  1764. // SetImageSizeBreakdown sets the "image_size_breakdown" field.
  1765. func (u *UsageLogUpsert) SetImageSizeBreakdown(v map[string]int) *UsageLogUpsert {
  1766. u.Set(usagelog.FieldImageSizeBreakdown, v)
  1767. return u
  1768. }
  1769. // UpdateImageSizeBreakdown sets the "image_size_breakdown" field to the value that was provided on create.
  1770. func (u *UsageLogUpsert) UpdateImageSizeBreakdown() *UsageLogUpsert {
  1771. u.SetExcluded(usagelog.FieldImageSizeBreakdown)
  1772. return u
  1773. }
  1774. // ClearImageSizeBreakdown clears the value of the "image_size_breakdown" field.
  1775. func (u *UsageLogUpsert) ClearImageSizeBreakdown() *UsageLogUpsert {
  1776. u.SetNull(usagelog.FieldImageSizeBreakdown)
  1777. return u
  1778. }
  1779. // SetVideoCount sets the "video_count" field.
  1780. func (u *UsageLogUpsert) SetVideoCount(v int) *UsageLogUpsert {
  1781. u.Set(usagelog.FieldVideoCount, v)
  1782. return u
  1783. }
  1784. // UpdateVideoCount sets the "video_count" field to the value that was provided on create.
  1785. func (u *UsageLogUpsert) UpdateVideoCount() *UsageLogUpsert {
  1786. u.SetExcluded(usagelog.FieldVideoCount)
  1787. return u
  1788. }
  1789. // AddVideoCount adds v to the "video_count" field.
  1790. func (u *UsageLogUpsert) AddVideoCount(v int) *UsageLogUpsert {
  1791. u.Add(usagelog.FieldVideoCount, v)
  1792. return u
  1793. }
  1794. // SetVideoResolution sets the "video_resolution" field.
  1795. func (u *UsageLogUpsert) SetVideoResolution(v string) *UsageLogUpsert {
  1796. u.Set(usagelog.FieldVideoResolution, v)
  1797. return u
  1798. }
  1799. // UpdateVideoResolution sets the "video_resolution" field to the value that was provided on create.
  1800. func (u *UsageLogUpsert) UpdateVideoResolution() *UsageLogUpsert {
  1801. u.SetExcluded(usagelog.FieldVideoResolution)
  1802. return u
  1803. }
  1804. // ClearVideoResolution clears the value of the "video_resolution" field.
  1805. func (u *UsageLogUpsert) ClearVideoResolution() *UsageLogUpsert {
  1806. u.SetNull(usagelog.FieldVideoResolution)
  1807. return u
  1808. }
  1809. // SetVideoDurationSeconds sets the "video_duration_seconds" field.
  1810. func (u *UsageLogUpsert) SetVideoDurationSeconds(v int) *UsageLogUpsert {
  1811. u.Set(usagelog.FieldVideoDurationSeconds, v)
  1812. return u
  1813. }
  1814. // UpdateVideoDurationSeconds sets the "video_duration_seconds" field to the value that was provided on create.
  1815. func (u *UsageLogUpsert) UpdateVideoDurationSeconds() *UsageLogUpsert {
  1816. u.SetExcluded(usagelog.FieldVideoDurationSeconds)
  1817. return u
  1818. }
  1819. // AddVideoDurationSeconds adds v to the "video_duration_seconds" field.
  1820. func (u *UsageLogUpsert) AddVideoDurationSeconds(v int) *UsageLogUpsert {
  1821. u.Add(usagelog.FieldVideoDurationSeconds, v)
  1822. return u
  1823. }
  1824. // ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field.
  1825. func (u *UsageLogUpsert) ClearVideoDurationSeconds() *UsageLogUpsert {
  1826. u.SetNull(usagelog.FieldVideoDurationSeconds)
  1827. return u
  1828. }
  1829. // SetCacheTTLOverridden sets the "cache_ttl_overridden" field.
  1830. func (u *UsageLogUpsert) SetCacheTTLOverridden(v bool) *UsageLogUpsert {
  1831. u.Set(usagelog.FieldCacheTTLOverridden, v)
  1832. return u
  1833. }
  1834. // UpdateCacheTTLOverridden sets the "cache_ttl_overridden" field to the value that was provided on create.
  1835. func (u *UsageLogUpsert) UpdateCacheTTLOverridden() *UsageLogUpsert {
  1836. u.SetExcluded(usagelog.FieldCacheTTLOverridden)
  1837. return u
  1838. }
  1839. // UpdateNewValues updates the mutable fields using the new values that were set on create.
  1840. // Using this option is equivalent to using:
  1841. //
  1842. // client.UsageLog.Create().
  1843. // OnConflict(
  1844. // sql.ResolveWithNewValues(),
  1845. // ).
  1846. // Exec(ctx)
  1847. func (u *UsageLogUpsertOne) UpdateNewValues() *UsageLogUpsertOne {
  1848. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1849. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1850. if _, exists := u.create.mutation.CreatedAt(); exists {
  1851. s.SetIgnore(usagelog.FieldCreatedAt)
  1852. }
  1853. }))
  1854. return u
  1855. }
  1856. // Ignore sets each column to itself in case of conflict.
  1857. // Using this option is equivalent to using:
  1858. //
  1859. // client.UsageLog.Create().
  1860. // OnConflict(sql.ResolveWithIgnore()).
  1861. // Exec(ctx)
  1862. func (u *UsageLogUpsertOne) Ignore() *UsageLogUpsertOne {
  1863. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1864. return u
  1865. }
  1866. // DoNothing configures the conflict_action to `DO NOTHING`.
  1867. // Supported only by SQLite and PostgreSQL.
  1868. func (u *UsageLogUpsertOne) DoNothing() *UsageLogUpsertOne {
  1869. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1870. return u
  1871. }
  1872. // Update allows overriding fields `UPDATE` values. See the UsageLogCreate.OnConflict
  1873. // documentation for more info.
  1874. func (u *UsageLogUpsertOne) Update(set func(*UsageLogUpsert)) *UsageLogUpsertOne {
  1875. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1876. set(&UsageLogUpsert{UpdateSet: update})
  1877. }))
  1878. return u
  1879. }
  1880. // SetUserID sets the "user_id" field.
  1881. func (u *UsageLogUpsertOne) SetUserID(v int64) *UsageLogUpsertOne {
  1882. return u.Update(func(s *UsageLogUpsert) {
  1883. s.SetUserID(v)
  1884. })
  1885. }
  1886. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  1887. func (u *UsageLogUpsertOne) UpdateUserID() *UsageLogUpsertOne {
  1888. return u.Update(func(s *UsageLogUpsert) {
  1889. s.UpdateUserID()
  1890. })
  1891. }
  1892. // SetAPIKeyID sets the "api_key_id" field.
  1893. func (u *UsageLogUpsertOne) SetAPIKeyID(v int64) *UsageLogUpsertOne {
  1894. return u.Update(func(s *UsageLogUpsert) {
  1895. s.SetAPIKeyID(v)
  1896. })
  1897. }
  1898. // UpdateAPIKeyID sets the "api_key_id" field to the value that was provided on create.
  1899. func (u *UsageLogUpsertOne) UpdateAPIKeyID() *UsageLogUpsertOne {
  1900. return u.Update(func(s *UsageLogUpsert) {
  1901. s.UpdateAPIKeyID()
  1902. })
  1903. }
  1904. // SetAccountID sets the "account_id" field.
  1905. func (u *UsageLogUpsertOne) SetAccountID(v int64) *UsageLogUpsertOne {
  1906. return u.Update(func(s *UsageLogUpsert) {
  1907. s.SetAccountID(v)
  1908. })
  1909. }
  1910. // UpdateAccountID sets the "account_id" field to the value that was provided on create.
  1911. func (u *UsageLogUpsertOne) UpdateAccountID() *UsageLogUpsertOne {
  1912. return u.Update(func(s *UsageLogUpsert) {
  1913. s.UpdateAccountID()
  1914. })
  1915. }
  1916. // SetRequestID sets the "request_id" field.
  1917. func (u *UsageLogUpsertOne) SetRequestID(v string) *UsageLogUpsertOne {
  1918. return u.Update(func(s *UsageLogUpsert) {
  1919. s.SetRequestID(v)
  1920. })
  1921. }
  1922. // UpdateRequestID sets the "request_id" field to the value that was provided on create.
  1923. func (u *UsageLogUpsertOne) UpdateRequestID() *UsageLogUpsertOne {
  1924. return u.Update(func(s *UsageLogUpsert) {
  1925. s.UpdateRequestID()
  1926. })
  1927. }
  1928. // SetModel sets the "model" field.
  1929. func (u *UsageLogUpsertOne) SetModel(v string) *UsageLogUpsertOne {
  1930. return u.Update(func(s *UsageLogUpsert) {
  1931. s.SetModel(v)
  1932. })
  1933. }
  1934. // UpdateModel sets the "model" field to the value that was provided on create.
  1935. func (u *UsageLogUpsertOne) UpdateModel() *UsageLogUpsertOne {
  1936. return u.Update(func(s *UsageLogUpsert) {
  1937. s.UpdateModel()
  1938. })
  1939. }
  1940. // SetRequestedModel sets the "requested_model" field.
  1941. func (u *UsageLogUpsertOne) SetRequestedModel(v string) *UsageLogUpsertOne {
  1942. return u.Update(func(s *UsageLogUpsert) {
  1943. s.SetRequestedModel(v)
  1944. })
  1945. }
  1946. // UpdateRequestedModel sets the "requested_model" field to the value that was provided on create.
  1947. func (u *UsageLogUpsertOne) UpdateRequestedModel() *UsageLogUpsertOne {
  1948. return u.Update(func(s *UsageLogUpsert) {
  1949. s.UpdateRequestedModel()
  1950. })
  1951. }
  1952. // ClearRequestedModel clears the value of the "requested_model" field.
  1953. func (u *UsageLogUpsertOne) ClearRequestedModel() *UsageLogUpsertOne {
  1954. return u.Update(func(s *UsageLogUpsert) {
  1955. s.ClearRequestedModel()
  1956. })
  1957. }
  1958. // SetUpstreamModel sets the "upstream_model" field.
  1959. func (u *UsageLogUpsertOne) SetUpstreamModel(v string) *UsageLogUpsertOne {
  1960. return u.Update(func(s *UsageLogUpsert) {
  1961. s.SetUpstreamModel(v)
  1962. })
  1963. }
  1964. // UpdateUpstreamModel sets the "upstream_model" field to the value that was provided on create.
  1965. func (u *UsageLogUpsertOne) UpdateUpstreamModel() *UsageLogUpsertOne {
  1966. return u.Update(func(s *UsageLogUpsert) {
  1967. s.UpdateUpstreamModel()
  1968. })
  1969. }
  1970. // ClearUpstreamModel clears the value of the "upstream_model" field.
  1971. func (u *UsageLogUpsertOne) ClearUpstreamModel() *UsageLogUpsertOne {
  1972. return u.Update(func(s *UsageLogUpsert) {
  1973. s.ClearUpstreamModel()
  1974. })
  1975. }
  1976. // SetUpstreamResponseModel sets the "upstream_response_model" field.
  1977. func (u *UsageLogUpsertOne) SetUpstreamResponseModel(v string) *UsageLogUpsertOne {
  1978. return u.Update(func(s *UsageLogUpsert) {
  1979. s.SetUpstreamResponseModel(v)
  1980. })
  1981. }
  1982. // UpdateUpstreamResponseModel sets the "upstream_response_model" field to the value that was provided on create.
  1983. func (u *UsageLogUpsertOne) UpdateUpstreamResponseModel() *UsageLogUpsertOne {
  1984. return u.Update(func(s *UsageLogUpsert) {
  1985. s.UpdateUpstreamResponseModel()
  1986. })
  1987. }
  1988. // ClearUpstreamResponseModel clears the value of the "upstream_response_model" field.
  1989. func (u *UsageLogUpsertOne) ClearUpstreamResponseModel() *UsageLogUpsertOne {
  1990. return u.Update(func(s *UsageLogUpsert) {
  1991. s.ClearUpstreamResponseModel()
  1992. })
  1993. }
  1994. // SetUpstreamModelMismatch sets the "upstream_model_mismatch" field.
  1995. func (u *UsageLogUpsertOne) SetUpstreamModelMismatch(v bool) *UsageLogUpsertOne {
  1996. return u.Update(func(s *UsageLogUpsert) {
  1997. s.SetUpstreamModelMismatch(v)
  1998. })
  1999. }
  2000. // UpdateUpstreamModelMismatch sets the "upstream_model_mismatch" field to the value that was provided on create.
  2001. func (u *UsageLogUpsertOne) UpdateUpstreamModelMismatch() *UsageLogUpsertOne {
  2002. return u.Update(func(s *UsageLogUpsert) {
  2003. s.UpdateUpstreamModelMismatch()
  2004. })
  2005. }
  2006. // ClearUpstreamModelMismatch clears the value of the "upstream_model_mismatch" field.
  2007. func (u *UsageLogUpsertOne) ClearUpstreamModelMismatch() *UsageLogUpsertOne {
  2008. return u.Update(func(s *UsageLogUpsert) {
  2009. s.ClearUpstreamModelMismatch()
  2010. })
  2011. }
  2012. // SetChannelID sets the "channel_id" field.
  2013. func (u *UsageLogUpsertOne) SetChannelID(v int64) *UsageLogUpsertOne {
  2014. return u.Update(func(s *UsageLogUpsert) {
  2015. s.SetChannelID(v)
  2016. })
  2017. }
  2018. // AddChannelID adds v to the "channel_id" field.
  2019. func (u *UsageLogUpsertOne) AddChannelID(v int64) *UsageLogUpsertOne {
  2020. return u.Update(func(s *UsageLogUpsert) {
  2021. s.AddChannelID(v)
  2022. })
  2023. }
  2024. // UpdateChannelID sets the "channel_id" field to the value that was provided on create.
  2025. func (u *UsageLogUpsertOne) UpdateChannelID() *UsageLogUpsertOne {
  2026. return u.Update(func(s *UsageLogUpsert) {
  2027. s.UpdateChannelID()
  2028. })
  2029. }
  2030. // ClearChannelID clears the value of the "channel_id" field.
  2031. func (u *UsageLogUpsertOne) ClearChannelID() *UsageLogUpsertOne {
  2032. return u.Update(func(s *UsageLogUpsert) {
  2033. s.ClearChannelID()
  2034. })
  2035. }
  2036. // SetModelMappingChain sets the "model_mapping_chain" field.
  2037. func (u *UsageLogUpsertOne) SetModelMappingChain(v string) *UsageLogUpsertOne {
  2038. return u.Update(func(s *UsageLogUpsert) {
  2039. s.SetModelMappingChain(v)
  2040. })
  2041. }
  2042. // UpdateModelMappingChain sets the "model_mapping_chain" field to the value that was provided on create.
  2043. func (u *UsageLogUpsertOne) UpdateModelMappingChain() *UsageLogUpsertOne {
  2044. return u.Update(func(s *UsageLogUpsert) {
  2045. s.UpdateModelMappingChain()
  2046. })
  2047. }
  2048. // ClearModelMappingChain clears the value of the "model_mapping_chain" field.
  2049. func (u *UsageLogUpsertOne) ClearModelMappingChain() *UsageLogUpsertOne {
  2050. return u.Update(func(s *UsageLogUpsert) {
  2051. s.ClearModelMappingChain()
  2052. })
  2053. }
  2054. // SetBillingTier sets the "billing_tier" field.
  2055. func (u *UsageLogUpsertOne) SetBillingTier(v string) *UsageLogUpsertOne {
  2056. return u.Update(func(s *UsageLogUpsert) {
  2057. s.SetBillingTier(v)
  2058. })
  2059. }
  2060. // UpdateBillingTier sets the "billing_tier" field to the value that was provided on create.
  2061. func (u *UsageLogUpsertOne) UpdateBillingTier() *UsageLogUpsertOne {
  2062. return u.Update(func(s *UsageLogUpsert) {
  2063. s.UpdateBillingTier()
  2064. })
  2065. }
  2066. // ClearBillingTier clears the value of the "billing_tier" field.
  2067. func (u *UsageLogUpsertOne) ClearBillingTier() *UsageLogUpsertOne {
  2068. return u.Update(func(s *UsageLogUpsert) {
  2069. s.ClearBillingTier()
  2070. })
  2071. }
  2072. // SetBillingMode sets the "billing_mode" field.
  2073. func (u *UsageLogUpsertOne) SetBillingMode(v string) *UsageLogUpsertOne {
  2074. return u.Update(func(s *UsageLogUpsert) {
  2075. s.SetBillingMode(v)
  2076. })
  2077. }
  2078. // UpdateBillingMode sets the "billing_mode" field to the value that was provided on create.
  2079. func (u *UsageLogUpsertOne) UpdateBillingMode() *UsageLogUpsertOne {
  2080. return u.Update(func(s *UsageLogUpsert) {
  2081. s.UpdateBillingMode()
  2082. })
  2083. }
  2084. // ClearBillingMode clears the value of the "billing_mode" field.
  2085. func (u *UsageLogUpsertOne) ClearBillingMode() *UsageLogUpsertOne {
  2086. return u.Update(func(s *UsageLogUpsert) {
  2087. s.ClearBillingMode()
  2088. })
  2089. }
  2090. // SetGroupID sets the "group_id" field.
  2091. func (u *UsageLogUpsertOne) SetGroupID(v int64) *UsageLogUpsertOne {
  2092. return u.Update(func(s *UsageLogUpsert) {
  2093. s.SetGroupID(v)
  2094. })
  2095. }
  2096. // UpdateGroupID sets the "group_id" field to the value that was provided on create.
  2097. func (u *UsageLogUpsertOne) UpdateGroupID() *UsageLogUpsertOne {
  2098. return u.Update(func(s *UsageLogUpsert) {
  2099. s.UpdateGroupID()
  2100. })
  2101. }
  2102. // ClearGroupID clears the value of the "group_id" field.
  2103. func (u *UsageLogUpsertOne) ClearGroupID() *UsageLogUpsertOne {
  2104. return u.Update(func(s *UsageLogUpsert) {
  2105. s.ClearGroupID()
  2106. })
  2107. }
  2108. // SetSubscriptionID sets the "subscription_id" field.
  2109. func (u *UsageLogUpsertOne) SetSubscriptionID(v int64) *UsageLogUpsertOne {
  2110. return u.Update(func(s *UsageLogUpsert) {
  2111. s.SetSubscriptionID(v)
  2112. })
  2113. }
  2114. // UpdateSubscriptionID sets the "subscription_id" field to the value that was provided on create.
  2115. func (u *UsageLogUpsertOne) UpdateSubscriptionID() *UsageLogUpsertOne {
  2116. return u.Update(func(s *UsageLogUpsert) {
  2117. s.UpdateSubscriptionID()
  2118. })
  2119. }
  2120. // ClearSubscriptionID clears the value of the "subscription_id" field.
  2121. func (u *UsageLogUpsertOne) ClearSubscriptionID() *UsageLogUpsertOne {
  2122. return u.Update(func(s *UsageLogUpsert) {
  2123. s.ClearSubscriptionID()
  2124. })
  2125. }
  2126. // SetInputTokens sets the "input_tokens" field.
  2127. func (u *UsageLogUpsertOne) SetInputTokens(v int) *UsageLogUpsertOne {
  2128. return u.Update(func(s *UsageLogUpsert) {
  2129. s.SetInputTokens(v)
  2130. })
  2131. }
  2132. // AddInputTokens adds v to the "input_tokens" field.
  2133. func (u *UsageLogUpsertOne) AddInputTokens(v int) *UsageLogUpsertOne {
  2134. return u.Update(func(s *UsageLogUpsert) {
  2135. s.AddInputTokens(v)
  2136. })
  2137. }
  2138. // UpdateInputTokens sets the "input_tokens" field to the value that was provided on create.
  2139. func (u *UsageLogUpsertOne) UpdateInputTokens() *UsageLogUpsertOne {
  2140. return u.Update(func(s *UsageLogUpsert) {
  2141. s.UpdateInputTokens()
  2142. })
  2143. }
  2144. // SetOutputTokens sets the "output_tokens" field.
  2145. func (u *UsageLogUpsertOne) SetOutputTokens(v int) *UsageLogUpsertOne {
  2146. return u.Update(func(s *UsageLogUpsert) {
  2147. s.SetOutputTokens(v)
  2148. })
  2149. }
  2150. // AddOutputTokens adds v to the "output_tokens" field.
  2151. func (u *UsageLogUpsertOne) AddOutputTokens(v int) *UsageLogUpsertOne {
  2152. return u.Update(func(s *UsageLogUpsert) {
  2153. s.AddOutputTokens(v)
  2154. })
  2155. }
  2156. // UpdateOutputTokens sets the "output_tokens" field to the value that was provided on create.
  2157. func (u *UsageLogUpsertOne) UpdateOutputTokens() *UsageLogUpsertOne {
  2158. return u.Update(func(s *UsageLogUpsert) {
  2159. s.UpdateOutputTokens()
  2160. })
  2161. }
  2162. // SetCacheCreationTokens sets the "cache_creation_tokens" field.
  2163. func (u *UsageLogUpsertOne) SetCacheCreationTokens(v int) *UsageLogUpsertOne {
  2164. return u.Update(func(s *UsageLogUpsert) {
  2165. s.SetCacheCreationTokens(v)
  2166. })
  2167. }
  2168. // AddCacheCreationTokens adds v to the "cache_creation_tokens" field.
  2169. func (u *UsageLogUpsertOne) AddCacheCreationTokens(v int) *UsageLogUpsertOne {
  2170. return u.Update(func(s *UsageLogUpsert) {
  2171. s.AddCacheCreationTokens(v)
  2172. })
  2173. }
  2174. // UpdateCacheCreationTokens sets the "cache_creation_tokens" field to the value that was provided on create.
  2175. func (u *UsageLogUpsertOne) UpdateCacheCreationTokens() *UsageLogUpsertOne {
  2176. return u.Update(func(s *UsageLogUpsert) {
  2177. s.UpdateCacheCreationTokens()
  2178. })
  2179. }
  2180. // SetCacheReadTokens sets the "cache_read_tokens" field.
  2181. func (u *UsageLogUpsertOne) SetCacheReadTokens(v int) *UsageLogUpsertOne {
  2182. return u.Update(func(s *UsageLogUpsert) {
  2183. s.SetCacheReadTokens(v)
  2184. })
  2185. }
  2186. // AddCacheReadTokens adds v to the "cache_read_tokens" field.
  2187. func (u *UsageLogUpsertOne) AddCacheReadTokens(v int) *UsageLogUpsertOne {
  2188. return u.Update(func(s *UsageLogUpsert) {
  2189. s.AddCacheReadTokens(v)
  2190. })
  2191. }
  2192. // UpdateCacheReadTokens sets the "cache_read_tokens" field to the value that was provided on create.
  2193. func (u *UsageLogUpsertOne) UpdateCacheReadTokens() *UsageLogUpsertOne {
  2194. return u.Update(func(s *UsageLogUpsert) {
  2195. s.UpdateCacheReadTokens()
  2196. })
  2197. }
  2198. // SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
  2199. func (u *UsageLogUpsertOne) SetCacheCreation5mTokens(v int) *UsageLogUpsertOne {
  2200. return u.Update(func(s *UsageLogUpsert) {
  2201. s.SetCacheCreation5mTokens(v)
  2202. })
  2203. }
  2204. // AddCacheCreation5mTokens adds v to the "cache_creation_5m_tokens" field.
  2205. func (u *UsageLogUpsertOne) AddCacheCreation5mTokens(v int) *UsageLogUpsertOne {
  2206. return u.Update(func(s *UsageLogUpsert) {
  2207. s.AddCacheCreation5mTokens(v)
  2208. })
  2209. }
  2210. // UpdateCacheCreation5mTokens sets the "cache_creation_5m_tokens" field to the value that was provided on create.
  2211. func (u *UsageLogUpsertOne) UpdateCacheCreation5mTokens() *UsageLogUpsertOne {
  2212. return u.Update(func(s *UsageLogUpsert) {
  2213. s.UpdateCacheCreation5mTokens()
  2214. })
  2215. }
  2216. // SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
  2217. func (u *UsageLogUpsertOne) SetCacheCreation1hTokens(v int) *UsageLogUpsertOne {
  2218. return u.Update(func(s *UsageLogUpsert) {
  2219. s.SetCacheCreation1hTokens(v)
  2220. })
  2221. }
  2222. // AddCacheCreation1hTokens adds v to the "cache_creation_1h_tokens" field.
  2223. func (u *UsageLogUpsertOne) AddCacheCreation1hTokens(v int) *UsageLogUpsertOne {
  2224. return u.Update(func(s *UsageLogUpsert) {
  2225. s.AddCacheCreation1hTokens(v)
  2226. })
  2227. }
  2228. // UpdateCacheCreation1hTokens sets the "cache_creation_1h_tokens" field to the value that was provided on create.
  2229. func (u *UsageLogUpsertOne) UpdateCacheCreation1hTokens() *UsageLogUpsertOne {
  2230. return u.Update(func(s *UsageLogUpsert) {
  2231. s.UpdateCacheCreation1hTokens()
  2232. })
  2233. }
  2234. // SetInputCost sets the "input_cost" field.
  2235. func (u *UsageLogUpsertOne) SetInputCost(v float64) *UsageLogUpsertOne {
  2236. return u.Update(func(s *UsageLogUpsert) {
  2237. s.SetInputCost(v)
  2238. })
  2239. }
  2240. // AddInputCost adds v to the "input_cost" field.
  2241. func (u *UsageLogUpsertOne) AddInputCost(v float64) *UsageLogUpsertOne {
  2242. return u.Update(func(s *UsageLogUpsert) {
  2243. s.AddInputCost(v)
  2244. })
  2245. }
  2246. // UpdateInputCost sets the "input_cost" field to the value that was provided on create.
  2247. func (u *UsageLogUpsertOne) UpdateInputCost() *UsageLogUpsertOne {
  2248. return u.Update(func(s *UsageLogUpsert) {
  2249. s.UpdateInputCost()
  2250. })
  2251. }
  2252. // SetOutputCost sets the "output_cost" field.
  2253. func (u *UsageLogUpsertOne) SetOutputCost(v float64) *UsageLogUpsertOne {
  2254. return u.Update(func(s *UsageLogUpsert) {
  2255. s.SetOutputCost(v)
  2256. })
  2257. }
  2258. // AddOutputCost adds v to the "output_cost" field.
  2259. func (u *UsageLogUpsertOne) AddOutputCost(v float64) *UsageLogUpsertOne {
  2260. return u.Update(func(s *UsageLogUpsert) {
  2261. s.AddOutputCost(v)
  2262. })
  2263. }
  2264. // UpdateOutputCost sets the "output_cost" field to the value that was provided on create.
  2265. func (u *UsageLogUpsertOne) UpdateOutputCost() *UsageLogUpsertOne {
  2266. return u.Update(func(s *UsageLogUpsert) {
  2267. s.UpdateOutputCost()
  2268. })
  2269. }
  2270. // SetCacheCreationCost sets the "cache_creation_cost" field.
  2271. func (u *UsageLogUpsertOne) SetCacheCreationCost(v float64) *UsageLogUpsertOne {
  2272. return u.Update(func(s *UsageLogUpsert) {
  2273. s.SetCacheCreationCost(v)
  2274. })
  2275. }
  2276. // AddCacheCreationCost adds v to the "cache_creation_cost" field.
  2277. func (u *UsageLogUpsertOne) AddCacheCreationCost(v float64) *UsageLogUpsertOne {
  2278. return u.Update(func(s *UsageLogUpsert) {
  2279. s.AddCacheCreationCost(v)
  2280. })
  2281. }
  2282. // UpdateCacheCreationCost sets the "cache_creation_cost" field to the value that was provided on create.
  2283. func (u *UsageLogUpsertOne) UpdateCacheCreationCost() *UsageLogUpsertOne {
  2284. return u.Update(func(s *UsageLogUpsert) {
  2285. s.UpdateCacheCreationCost()
  2286. })
  2287. }
  2288. // SetCacheReadCost sets the "cache_read_cost" field.
  2289. func (u *UsageLogUpsertOne) SetCacheReadCost(v float64) *UsageLogUpsertOne {
  2290. return u.Update(func(s *UsageLogUpsert) {
  2291. s.SetCacheReadCost(v)
  2292. })
  2293. }
  2294. // AddCacheReadCost adds v to the "cache_read_cost" field.
  2295. func (u *UsageLogUpsertOne) AddCacheReadCost(v float64) *UsageLogUpsertOne {
  2296. return u.Update(func(s *UsageLogUpsert) {
  2297. s.AddCacheReadCost(v)
  2298. })
  2299. }
  2300. // UpdateCacheReadCost sets the "cache_read_cost" field to the value that was provided on create.
  2301. func (u *UsageLogUpsertOne) UpdateCacheReadCost() *UsageLogUpsertOne {
  2302. return u.Update(func(s *UsageLogUpsert) {
  2303. s.UpdateCacheReadCost()
  2304. })
  2305. }
  2306. // SetTotalCost sets the "total_cost" field.
  2307. func (u *UsageLogUpsertOne) SetTotalCost(v float64) *UsageLogUpsertOne {
  2308. return u.Update(func(s *UsageLogUpsert) {
  2309. s.SetTotalCost(v)
  2310. })
  2311. }
  2312. // AddTotalCost adds v to the "total_cost" field.
  2313. func (u *UsageLogUpsertOne) AddTotalCost(v float64) *UsageLogUpsertOne {
  2314. return u.Update(func(s *UsageLogUpsert) {
  2315. s.AddTotalCost(v)
  2316. })
  2317. }
  2318. // UpdateTotalCost sets the "total_cost" field to the value that was provided on create.
  2319. func (u *UsageLogUpsertOne) UpdateTotalCost() *UsageLogUpsertOne {
  2320. return u.Update(func(s *UsageLogUpsert) {
  2321. s.UpdateTotalCost()
  2322. })
  2323. }
  2324. // SetActualCost sets the "actual_cost" field.
  2325. func (u *UsageLogUpsertOne) SetActualCost(v float64) *UsageLogUpsertOne {
  2326. return u.Update(func(s *UsageLogUpsert) {
  2327. s.SetActualCost(v)
  2328. })
  2329. }
  2330. // AddActualCost adds v to the "actual_cost" field.
  2331. func (u *UsageLogUpsertOne) AddActualCost(v float64) *UsageLogUpsertOne {
  2332. return u.Update(func(s *UsageLogUpsert) {
  2333. s.AddActualCost(v)
  2334. })
  2335. }
  2336. // UpdateActualCost sets the "actual_cost" field to the value that was provided on create.
  2337. func (u *UsageLogUpsertOne) UpdateActualCost() *UsageLogUpsertOne {
  2338. return u.Update(func(s *UsageLogUpsert) {
  2339. s.UpdateActualCost()
  2340. })
  2341. }
  2342. // SetRateMultiplier sets the "rate_multiplier" field.
  2343. func (u *UsageLogUpsertOne) SetRateMultiplier(v float64) *UsageLogUpsertOne {
  2344. return u.Update(func(s *UsageLogUpsert) {
  2345. s.SetRateMultiplier(v)
  2346. })
  2347. }
  2348. // AddRateMultiplier adds v to the "rate_multiplier" field.
  2349. func (u *UsageLogUpsertOne) AddRateMultiplier(v float64) *UsageLogUpsertOne {
  2350. return u.Update(func(s *UsageLogUpsert) {
  2351. s.AddRateMultiplier(v)
  2352. })
  2353. }
  2354. // UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
  2355. func (u *UsageLogUpsertOne) UpdateRateMultiplier() *UsageLogUpsertOne {
  2356. return u.Update(func(s *UsageLogUpsert) {
  2357. s.UpdateRateMultiplier()
  2358. })
  2359. }
  2360. // SetLongContextBillingApplied sets the "long_context_billing_applied" field.
  2361. func (u *UsageLogUpsertOne) SetLongContextBillingApplied(v bool) *UsageLogUpsertOne {
  2362. return u.Update(func(s *UsageLogUpsert) {
  2363. s.SetLongContextBillingApplied(v)
  2364. })
  2365. }
  2366. // UpdateLongContextBillingApplied sets the "long_context_billing_applied" field to the value that was provided on create.
  2367. func (u *UsageLogUpsertOne) UpdateLongContextBillingApplied() *UsageLogUpsertOne {
  2368. return u.Update(func(s *UsageLogUpsert) {
  2369. s.UpdateLongContextBillingApplied()
  2370. })
  2371. }
  2372. // SetAccountRateMultiplier sets the "account_rate_multiplier" field.
  2373. func (u *UsageLogUpsertOne) SetAccountRateMultiplier(v float64) *UsageLogUpsertOne {
  2374. return u.Update(func(s *UsageLogUpsert) {
  2375. s.SetAccountRateMultiplier(v)
  2376. })
  2377. }
  2378. // AddAccountRateMultiplier adds v to the "account_rate_multiplier" field.
  2379. func (u *UsageLogUpsertOne) AddAccountRateMultiplier(v float64) *UsageLogUpsertOne {
  2380. return u.Update(func(s *UsageLogUpsert) {
  2381. s.AddAccountRateMultiplier(v)
  2382. })
  2383. }
  2384. // UpdateAccountRateMultiplier sets the "account_rate_multiplier" field to the value that was provided on create.
  2385. func (u *UsageLogUpsertOne) UpdateAccountRateMultiplier() *UsageLogUpsertOne {
  2386. return u.Update(func(s *UsageLogUpsert) {
  2387. s.UpdateAccountRateMultiplier()
  2388. })
  2389. }
  2390. // ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
  2391. func (u *UsageLogUpsertOne) ClearAccountRateMultiplier() *UsageLogUpsertOne {
  2392. return u.Update(func(s *UsageLogUpsert) {
  2393. s.ClearAccountRateMultiplier()
  2394. })
  2395. }
  2396. // SetBillingType sets the "billing_type" field.
  2397. func (u *UsageLogUpsertOne) SetBillingType(v int8) *UsageLogUpsertOne {
  2398. return u.Update(func(s *UsageLogUpsert) {
  2399. s.SetBillingType(v)
  2400. })
  2401. }
  2402. // AddBillingType adds v to the "billing_type" field.
  2403. func (u *UsageLogUpsertOne) AddBillingType(v int8) *UsageLogUpsertOne {
  2404. return u.Update(func(s *UsageLogUpsert) {
  2405. s.AddBillingType(v)
  2406. })
  2407. }
  2408. // UpdateBillingType sets the "billing_type" field to the value that was provided on create.
  2409. func (u *UsageLogUpsertOne) UpdateBillingType() *UsageLogUpsertOne {
  2410. return u.Update(func(s *UsageLogUpsert) {
  2411. s.UpdateBillingType()
  2412. })
  2413. }
  2414. // SetStream sets the "stream" field.
  2415. func (u *UsageLogUpsertOne) SetStream(v bool) *UsageLogUpsertOne {
  2416. return u.Update(func(s *UsageLogUpsert) {
  2417. s.SetStream(v)
  2418. })
  2419. }
  2420. // UpdateStream sets the "stream" field to the value that was provided on create.
  2421. func (u *UsageLogUpsertOne) UpdateStream() *UsageLogUpsertOne {
  2422. return u.Update(func(s *UsageLogUpsert) {
  2423. s.UpdateStream()
  2424. })
  2425. }
  2426. // SetDurationMs sets the "duration_ms" field.
  2427. func (u *UsageLogUpsertOne) SetDurationMs(v int) *UsageLogUpsertOne {
  2428. return u.Update(func(s *UsageLogUpsert) {
  2429. s.SetDurationMs(v)
  2430. })
  2431. }
  2432. // AddDurationMs adds v to the "duration_ms" field.
  2433. func (u *UsageLogUpsertOne) AddDurationMs(v int) *UsageLogUpsertOne {
  2434. return u.Update(func(s *UsageLogUpsert) {
  2435. s.AddDurationMs(v)
  2436. })
  2437. }
  2438. // UpdateDurationMs sets the "duration_ms" field to the value that was provided on create.
  2439. func (u *UsageLogUpsertOne) UpdateDurationMs() *UsageLogUpsertOne {
  2440. return u.Update(func(s *UsageLogUpsert) {
  2441. s.UpdateDurationMs()
  2442. })
  2443. }
  2444. // ClearDurationMs clears the value of the "duration_ms" field.
  2445. func (u *UsageLogUpsertOne) ClearDurationMs() *UsageLogUpsertOne {
  2446. return u.Update(func(s *UsageLogUpsert) {
  2447. s.ClearDurationMs()
  2448. })
  2449. }
  2450. // SetFirstTokenMs sets the "first_token_ms" field.
  2451. func (u *UsageLogUpsertOne) SetFirstTokenMs(v int) *UsageLogUpsertOne {
  2452. return u.Update(func(s *UsageLogUpsert) {
  2453. s.SetFirstTokenMs(v)
  2454. })
  2455. }
  2456. // AddFirstTokenMs adds v to the "first_token_ms" field.
  2457. func (u *UsageLogUpsertOne) AddFirstTokenMs(v int) *UsageLogUpsertOne {
  2458. return u.Update(func(s *UsageLogUpsert) {
  2459. s.AddFirstTokenMs(v)
  2460. })
  2461. }
  2462. // UpdateFirstTokenMs sets the "first_token_ms" field to the value that was provided on create.
  2463. func (u *UsageLogUpsertOne) UpdateFirstTokenMs() *UsageLogUpsertOne {
  2464. return u.Update(func(s *UsageLogUpsert) {
  2465. s.UpdateFirstTokenMs()
  2466. })
  2467. }
  2468. // ClearFirstTokenMs clears the value of the "first_token_ms" field.
  2469. func (u *UsageLogUpsertOne) ClearFirstTokenMs() *UsageLogUpsertOne {
  2470. return u.Update(func(s *UsageLogUpsert) {
  2471. s.ClearFirstTokenMs()
  2472. })
  2473. }
  2474. // SetUserAgent sets the "user_agent" field.
  2475. func (u *UsageLogUpsertOne) SetUserAgent(v string) *UsageLogUpsertOne {
  2476. return u.Update(func(s *UsageLogUpsert) {
  2477. s.SetUserAgent(v)
  2478. })
  2479. }
  2480. // UpdateUserAgent sets the "user_agent" field to the value that was provided on create.
  2481. func (u *UsageLogUpsertOne) UpdateUserAgent() *UsageLogUpsertOne {
  2482. return u.Update(func(s *UsageLogUpsert) {
  2483. s.UpdateUserAgent()
  2484. })
  2485. }
  2486. // ClearUserAgent clears the value of the "user_agent" field.
  2487. func (u *UsageLogUpsertOne) ClearUserAgent() *UsageLogUpsertOne {
  2488. return u.Update(func(s *UsageLogUpsert) {
  2489. s.ClearUserAgent()
  2490. })
  2491. }
  2492. // SetIPAddress sets the "ip_address" field.
  2493. func (u *UsageLogUpsertOne) SetIPAddress(v string) *UsageLogUpsertOne {
  2494. return u.Update(func(s *UsageLogUpsert) {
  2495. s.SetIPAddress(v)
  2496. })
  2497. }
  2498. // UpdateIPAddress sets the "ip_address" field to the value that was provided on create.
  2499. func (u *UsageLogUpsertOne) UpdateIPAddress() *UsageLogUpsertOne {
  2500. return u.Update(func(s *UsageLogUpsert) {
  2501. s.UpdateIPAddress()
  2502. })
  2503. }
  2504. // ClearIPAddress clears the value of the "ip_address" field.
  2505. func (u *UsageLogUpsertOne) ClearIPAddress() *UsageLogUpsertOne {
  2506. return u.Update(func(s *UsageLogUpsert) {
  2507. s.ClearIPAddress()
  2508. })
  2509. }
  2510. // SetImageCount sets the "image_count" field.
  2511. func (u *UsageLogUpsertOne) SetImageCount(v int) *UsageLogUpsertOne {
  2512. return u.Update(func(s *UsageLogUpsert) {
  2513. s.SetImageCount(v)
  2514. })
  2515. }
  2516. // AddImageCount adds v to the "image_count" field.
  2517. func (u *UsageLogUpsertOne) AddImageCount(v int) *UsageLogUpsertOne {
  2518. return u.Update(func(s *UsageLogUpsert) {
  2519. s.AddImageCount(v)
  2520. })
  2521. }
  2522. // UpdateImageCount sets the "image_count" field to the value that was provided on create.
  2523. func (u *UsageLogUpsertOne) UpdateImageCount() *UsageLogUpsertOne {
  2524. return u.Update(func(s *UsageLogUpsert) {
  2525. s.UpdateImageCount()
  2526. })
  2527. }
  2528. // SetImageSize sets the "image_size" field.
  2529. func (u *UsageLogUpsertOne) SetImageSize(v string) *UsageLogUpsertOne {
  2530. return u.Update(func(s *UsageLogUpsert) {
  2531. s.SetImageSize(v)
  2532. })
  2533. }
  2534. // UpdateImageSize sets the "image_size" field to the value that was provided on create.
  2535. func (u *UsageLogUpsertOne) UpdateImageSize() *UsageLogUpsertOne {
  2536. return u.Update(func(s *UsageLogUpsert) {
  2537. s.UpdateImageSize()
  2538. })
  2539. }
  2540. // ClearImageSize clears the value of the "image_size" field.
  2541. func (u *UsageLogUpsertOne) ClearImageSize() *UsageLogUpsertOne {
  2542. return u.Update(func(s *UsageLogUpsert) {
  2543. s.ClearImageSize()
  2544. })
  2545. }
  2546. // SetImageInputSize sets the "image_input_size" field.
  2547. func (u *UsageLogUpsertOne) SetImageInputSize(v string) *UsageLogUpsertOne {
  2548. return u.Update(func(s *UsageLogUpsert) {
  2549. s.SetImageInputSize(v)
  2550. })
  2551. }
  2552. // UpdateImageInputSize sets the "image_input_size" field to the value that was provided on create.
  2553. func (u *UsageLogUpsertOne) UpdateImageInputSize() *UsageLogUpsertOne {
  2554. return u.Update(func(s *UsageLogUpsert) {
  2555. s.UpdateImageInputSize()
  2556. })
  2557. }
  2558. // ClearImageInputSize clears the value of the "image_input_size" field.
  2559. func (u *UsageLogUpsertOne) ClearImageInputSize() *UsageLogUpsertOne {
  2560. return u.Update(func(s *UsageLogUpsert) {
  2561. s.ClearImageInputSize()
  2562. })
  2563. }
  2564. // SetImageOutputSize sets the "image_output_size" field.
  2565. func (u *UsageLogUpsertOne) SetImageOutputSize(v string) *UsageLogUpsertOne {
  2566. return u.Update(func(s *UsageLogUpsert) {
  2567. s.SetImageOutputSize(v)
  2568. })
  2569. }
  2570. // UpdateImageOutputSize sets the "image_output_size" field to the value that was provided on create.
  2571. func (u *UsageLogUpsertOne) UpdateImageOutputSize() *UsageLogUpsertOne {
  2572. return u.Update(func(s *UsageLogUpsert) {
  2573. s.UpdateImageOutputSize()
  2574. })
  2575. }
  2576. // ClearImageOutputSize clears the value of the "image_output_size" field.
  2577. func (u *UsageLogUpsertOne) ClearImageOutputSize() *UsageLogUpsertOne {
  2578. return u.Update(func(s *UsageLogUpsert) {
  2579. s.ClearImageOutputSize()
  2580. })
  2581. }
  2582. // SetImageSizeSource sets the "image_size_source" field.
  2583. func (u *UsageLogUpsertOne) SetImageSizeSource(v string) *UsageLogUpsertOne {
  2584. return u.Update(func(s *UsageLogUpsert) {
  2585. s.SetImageSizeSource(v)
  2586. })
  2587. }
  2588. // UpdateImageSizeSource sets the "image_size_source" field to the value that was provided on create.
  2589. func (u *UsageLogUpsertOne) UpdateImageSizeSource() *UsageLogUpsertOne {
  2590. return u.Update(func(s *UsageLogUpsert) {
  2591. s.UpdateImageSizeSource()
  2592. })
  2593. }
  2594. // ClearImageSizeSource clears the value of the "image_size_source" field.
  2595. func (u *UsageLogUpsertOne) ClearImageSizeSource() *UsageLogUpsertOne {
  2596. return u.Update(func(s *UsageLogUpsert) {
  2597. s.ClearImageSizeSource()
  2598. })
  2599. }
  2600. // SetImageSizeBreakdown sets the "image_size_breakdown" field.
  2601. func (u *UsageLogUpsertOne) SetImageSizeBreakdown(v map[string]int) *UsageLogUpsertOne {
  2602. return u.Update(func(s *UsageLogUpsert) {
  2603. s.SetImageSizeBreakdown(v)
  2604. })
  2605. }
  2606. // UpdateImageSizeBreakdown sets the "image_size_breakdown" field to the value that was provided on create.
  2607. func (u *UsageLogUpsertOne) UpdateImageSizeBreakdown() *UsageLogUpsertOne {
  2608. return u.Update(func(s *UsageLogUpsert) {
  2609. s.UpdateImageSizeBreakdown()
  2610. })
  2611. }
  2612. // ClearImageSizeBreakdown clears the value of the "image_size_breakdown" field.
  2613. func (u *UsageLogUpsertOne) ClearImageSizeBreakdown() *UsageLogUpsertOne {
  2614. return u.Update(func(s *UsageLogUpsert) {
  2615. s.ClearImageSizeBreakdown()
  2616. })
  2617. }
  2618. // SetVideoCount sets the "video_count" field.
  2619. func (u *UsageLogUpsertOne) SetVideoCount(v int) *UsageLogUpsertOne {
  2620. return u.Update(func(s *UsageLogUpsert) {
  2621. s.SetVideoCount(v)
  2622. })
  2623. }
  2624. // AddVideoCount adds v to the "video_count" field.
  2625. func (u *UsageLogUpsertOne) AddVideoCount(v int) *UsageLogUpsertOne {
  2626. return u.Update(func(s *UsageLogUpsert) {
  2627. s.AddVideoCount(v)
  2628. })
  2629. }
  2630. // UpdateVideoCount sets the "video_count" field to the value that was provided on create.
  2631. func (u *UsageLogUpsertOne) UpdateVideoCount() *UsageLogUpsertOne {
  2632. return u.Update(func(s *UsageLogUpsert) {
  2633. s.UpdateVideoCount()
  2634. })
  2635. }
  2636. // SetVideoResolution sets the "video_resolution" field.
  2637. func (u *UsageLogUpsertOne) SetVideoResolution(v string) *UsageLogUpsertOne {
  2638. return u.Update(func(s *UsageLogUpsert) {
  2639. s.SetVideoResolution(v)
  2640. })
  2641. }
  2642. // UpdateVideoResolution sets the "video_resolution" field to the value that was provided on create.
  2643. func (u *UsageLogUpsertOne) UpdateVideoResolution() *UsageLogUpsertOne {
  2644. return u.Update(func(s *UsageLogUpsert) {
  2645. s.UpdateVideoResolution()
  2646. })
  2647. }
  2648. // ClearVideoResolution clears the value of the "video_resolution" field.
  2649. func (u *UsageLogUpsertOne) ClearVideoResolution() *UsageLogUpsertOne {
  2650. return u.Update(func(s *UsageLogUpsert) {
  2651. s.ClearVideoResolution()
  2652. })
  2653. }
  2654. // SetVideoDurationSeconds sets the "video_duration_seconds" field.
  2655. func (u *UsageLogUpsertOne) SetVideoDurationSeconds(v int) *UsageLogUpsertOne {
  2656. return u.Update(func(s *UsageLogUpsert) {
  2657. s.SetVideoDurationSeconds(v)
  2658. })
  2659. }
  2660. // AddVideoDurationSeconds adds v to the "video_duration_seconds" field.
  2661. func (u *UsageLogUpsertOne) AddVideoDurationSeconds(v int) *UsageLogUpsertOne {
  2662. return u.Update(func(s *UsageLogUpsert) {
  2663. s.AddVideoDurationSeconds(v)
  2664. })
  2665. }
  2666. // UpdateVideoDurationSeconds sets the "video_duration_seconds" field to the value that was provided on create.
  2667. func (u *UsageLogUpsertOne) UpdateVideoDurationSeconds() *UsageLogUpsertOne {
  2668. return u.Update(func(s *UsageLogUpsert) {
  2669. s.UpdateVideoDurationSeconds()
  2670. })
  2671. }
  2672. // ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field.
  2673. func (u *UsageLogUpsertOne) ClearVideoDurationSeconds() *UsageLogUpsertOne {
  2674. return u.Update(func(s *UsageLogUpsert) {
  2675. s.ClearVideoDurationSeconds()
  2676. })
  2677. }
  2678. // SetCacheTTLOverridden sets the "cache_ttl_overridden" field.
  2679. func (u *UsageLogUpsertOne) SetCacheTTLOverridden(v bool) *UsageLogUpsertOne {
  2680. return u.Update(func(s *UsageLogUpsert) {
  2681. s.SetCacheTTLOverridden(v)
  2682. })
  2683. }
  2684. // UpdateCacheTTLOverridden sets the "cache_ttl_overridden" field to the value that was provided on create.
  2685. func (u *UsageLogUpsertOne) UpdateCacheTTLOverridden() *UsageLogUpsertOne {
  2686. return u.Update(func(s *UsageLogUpsert) {
  2687. s.UpdateCacheTTLOverridden()
  2688. })
  2689. }
  2690. // Exec executes the query.
  2691. func (u *UsageLogUpsertOne) Exec(ctx context.Context) error {
  2692. if len(u.create.conflict) == 0 {
  2693. return errors.New("ent: missing options for UsageLogCreate.OnConflict")
  2694. }
  2695. return u.create.Exec(ctx)
  2696. }
  2697. // ExecX is like Exec, but panics if an error occurs.
  2698. func (u *UsageLogUpsertOne) ExecX(ctx context.Context) {
  2699. if err := u.create.Exec(ctx); err != nil {
  2700. panic(err)
  2701. }
  2702. }
  2703. // Exec executes the UPSERT query and returns the inserted/updated ID.
  2704. func (u *UsageLogUpsertOne) ID(ctx context.Context) (id int64, err error) {
  2705. node, err := u.create.Save(ctx)
  2706. if err != nil {
  2707. return id, err
  2708. }
  2709. return node.ID, nil
  2710. }
  2711. // IDX is like ID, but panics if an error occurs.
  2712. func (u *UsageLogUpsertOne) IDX(ctx context.Context) int64 {
  2713. id, err := u.ID(ctx)
  2714. if err != nil {
  2715. panic(err)
  2716. }
  2717. return id
  2718. }
  2719. // UsageLogCreateBulk is the builder for creating many UsageLog entities in bulk.
  2720. type UsageLogCreateBulk struct {
  2721. config
  2722. err error
  2723. builders []*UsageLogCreate
  2724. conflict []sql.ConflictOption
  2725. }
  2726. // Save creates the UsageLog entities in the database.
  2727. func (_c *UsageLogCreateBulk) Save(ctx context.Context) ([]*UsageLog, error) {
  2728. if _c.err != nil {
  2729. return nil, _c.err
  2730. }
  2731. specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
  2732. nodes := make([]*UsageLog, len(_c.builders))
  2733. mutators := make([]Mutator, len(_c.builders))
  2734. for i := range _c.builders {
  2735. func(i int, root context.Context) {
  2736. builder := _c.builders[i]
  2737. builder.defaults()
  2738. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  2739. mutation, ok := m.(*UsageLogMutation)
  2740. if !ok {
  2741. return nil, fmt.Errorf("unexpected mutation type %T", m)
  2742. }
  2743. if err := builder.check(); err != nil {
  2744. return nil, err
  2745. }
  2746. builder.mutation = mutation
  2747. var err error
  2748. nodes[i], specs[i] = builder.createSpec()
  2749. if i < len(mutators)-1 {
  2750. _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
  2751. } else {
  2752. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  2753. spec.OnConflict = _c.conflict
  2754. // Invoke the actual operation on the latest mutation in the chain.
  2755. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
  2756. if sqlgraph.IsConstraintError(err) {
  2757. err = &ConstraintError{msg: err.Error(), wrap: err}
  2758. }
  2759. }
  2760. }
  2761. if err != nil {
  2762. return nil, err
  2763. }
  2764. mutation.id = &nodes[i].ID
  2765. if specs[i].ID.Value != nil {
  2766. id := specs[i].ID.Value.(int64)
  2767. nodes[i].ID = int64(id)
  2768. }
  2769. mutation.done = true
  2770. return nodes[i], nil
  2771. })
  2772. for i := len(builder.hooks) - 1; i >= 0; i-- {
  2773. mut = builder.hooks[i](mut)
  2774. }
  2775. mutators[i] = mut
  2776. }(i, ctx)
  2777. }
  2778. if len(mutators) > 0 {
  2779. if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
  2780. return nil, err
  2781. }
  2782. }
  2783. return nodes, nil
  2784. }
  2785. // SaveX is like Save, but panics if an error occurs.
  2786. func (_c *UsageLogCreateBulk) SaveX(ctx context.Context) []*UsageLog {
  2787. v, err := _c.Save(ctx)
  2788. if err != nil {
  2789. panic(err)
  2790. }
  2791. return v
  2792. }
  2793. // Exec executes the query.
  2794. func (_c *UsageLogCreateBulk) Exec(ctx context.Context) error {
  2795. _, err := _c.Save(ctx)
  2796. return err
  2797. }
  2798. // ExecX is like Exec, but panics if an error occurs.
  2799. func (_c *UsageLogCreateBulk) ExecX(ctx context.Context) {
  2800. if err := _c.Exec(ctx); err != nil {
  2801. panic(err)
  2802. }
  2803. }
  2804. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  2805. // of the `INSERT` statement. For example:
  2806. //
  2807. // client.UsageLog.CreateBulk(builders...).
  2808. // OnConflict(
  2809. // // Update the row with the new values
  2810. // // the was proposed for insertion.
  2811. // sql.ResolveWithNewValues(),
  2812. // ).
  2813. // // Override some of the fields with custom
  2814. // // update values.
  2815. // Update(func(u *ent.UsageLogUpsert) {
  2816. // SetUserID(v+v).
  2817. // }).
  2818. // Exec(ctx)
  2819. func (_c *UsageLogCreateBulk) OnConflict(opts ...sql.ConflictOption) *UsageLogUpsertBulk {
  2820. _c.conflict = opts
  2821. return &UsageLogUpsertBulk{
  2822. create: _c,
  2823. }
  2824. }
  2825. // OnConflictColumns calls `OnConflict` and configures the columns
  2826. // as conflict target. Using this option is equivalent to using:
  2827. //
  2828. // client.UsageLog.Create().
  2829. // OnConflict(sql.ConflictColumns(columns...)).
  2830. // Exec(ctx)
  2831. func (_c *UsageLogCreateBulk) OnConflictColumns(columns ...string) *UsageLogUpsertBulk {
  2832. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  2833. return &UsageLogUpsertBulk{
  2834. create: _c,
  2835. }
  2836. }
  2837. // UsageLogUpsertBulk is the builder for "upsert"-ing
  2838. // a bulk of UsageLog nodes.
  2839. type UsageLogUpsertBulk struct {
  2840. create *UsageLogCreateBulk
  2841. }
  2842. // UpdateNewValues updates the mutable fields using the new values that
  2843. // were set on create. Using this option is equivalent to using:
  2844. //
  2845. // client.UsageLog.Create().
  2846. // OnConflict(
  2847. // sql.ResolveWithNewValues(),
  2848. // ).
  2849. // Exec(ctx)
  2850. func (u *UsageLogUpsertBulk) UpdateNewValues() *UsageLogUpsertBulk {
  2851. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  2852. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  2853. for _, b := range u.create.builders {
  2854. if _, exists := b.mutation.CreatedAt(); exists {
  2855. s.SetIgnore(usagelog.FieldCreatedAt)
  2856. }
  2857. }
  2858. }))
  2859. return u
  2860. }
  2861. // Ignore sets each column to itself in case of conflict.
  2862. // Using this option is equivalent to using:
  2863. //
  2864. // client.UsageLog.Create().
  2865. // OnConflict(sql.ResolveWithIgnore()).
  2866. // Exec(ctx)
  2867. func (u *UsageLogUpsertBulk) Ignore() *UsageLogUpsertBulk {
  2868. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  2869. return u
  2870. }
  2871. // DoNothing configures the conflict_action to `DO NOTHING`.
  2872. // Supported only by SQLite and PostgreSQL.
  2873. func (u *UsageLogUpsertBulk) DoNothing() *UsageLogUpsertBulk {
  2874. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  2875. return u
  2876. }
  2877. // Update allows overriding fields `UPDATE` values. See the UsageLogCreateBulk.OnConflict
  2878. // documentation for more info.
  2879. func (u *UsageLogUpsertBulk) Update(set func(*UsageLogUpsert)) *UsageLogUpsertBulk {
  2880. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  2881. set(&UsageLogUpsert{UpdateSet: update})
  2882. }))
  2883. return u
  2884. }
  2885. // SetUserID sets the "user_id" field.
  2886. func (u *UsageLogUpsertBulk) SetUserID(v int64) *UsageLogUpsertBulk {
  2887. return u.Update(func(s *UsageLogUpsert) {
  2888. s.SetUserID(v)
  2889. })
  2890. }
  2891. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  2892. func (u *UsageLogUpsertBulk) UpdateUserID() *UsageLogUpsertBulk {
  2893. return u.Update(func(s *UsageLogUpsert) {
  2894. s.UpdateUserID()
  2895. })
  2896. }
  2897. // SetAPIKeyID sets the "api_key_id" field.
  2898. func (u *UsageLogUpsertBulk) SetAPIKeyID(v int64) *UsageLogUpsertBulk {
  2899. return u.Update(func(s *UsageLogUpsert) {
  2900. s.SetAPIKeyID(v)
  2901. })
  2902. }
  2903. // UpdateAPIKeyID sets the "api_key_id" field to the value that was provided on create.
  2904. func (u *UsageLogUpsertBulk) UpdateAPIKeyID() *UsageLogUpsertBulk {
  2905. return u.Update(func(s *UsageLogUpsert) {
  2906. s.UpdateAPIKeyID()
  2907. })
  2908. }
  2909. // SetAccountID sets the "account_id" field.
  2910. func (u *UsageLogUpsertBulk) SetAccountID(v int64) *UsageLogUpsertBulk {
  2911. return u.Update(func(s *UsageLogUpsert) {
  2912. s.SetAccountID(v)
  2913. })
  2914. }
  2915. // UpdateAccountID sets the "account_id" field to the value that was provided on create.
  2916. func (u *UsageLogUpsertBulk) UpdateAccountID() *UsageLogUpsertBulk {
  2917. return u.Update(func(s *UsageLogUpsert) {
  2918. s.UpdateAccountID()
  2919. })
  2920. }
  2921. // SetRequestID sets the "request_id" field.
  2922. func (u *UsageLogUpsertBulk) SetRequestID(v string) *UsageLogUpsertBulk {
  2923. return u.Update(func(s *UsageLogUpsert) {
  2924. s.SetRequestID(v)
  2925. })
  2926. }
  2927. // UpdateRequestID sets the "request_id" field to the value that was provided on create.
  2928. func (u *UsageLogUpsertBulk) UpdateRequestID() *UsageLogUpsertBulk {
  2929. return u.Update(func(s *UsageLogUpsert) {
  2930. s.UpdateRequestID()
  2931. })
  2932. }
  2933. // SetModel sets the "model" field.
  2934. func (u *UsageLogUpsertBulk) SetModel(v string) *UsageLogUpsertBulk {
  2935. return u.Update(func(s *UsageLogUpsert) {
  2936. s.SetModel(v)
  2937. })
  2938. }
  2939. // UpdateModel sets the "model" field to the value that was provided on create.
  2940. func (u *UsageLogUpsertBulk) UpdateModel() *UsageLogUpsertBulk {
  2941. return u.Update(func(s *UsageLogUpsert) {
  2942. s.UpdateModel()
  2943. })
  2944. }
  2945. // SetRequestedModel sets the "requested_model" field.
  2946. func (u *UsageLogUpsertBulk) SetRequestedModel(v string) *UsageLogUpsertBulk {
  2947. return u.Update(func(s *UsageLogUpsert) {
  2948. s.SetRequestedModel(v)
  2949. })
  2950. }
  2951. // UpdateRequestedModel sets the "requested_model" field to the value that was provided on create.
  2952. func (u *UsageLogUpsertBulk) UpdateRequestedModel() *UsageLogUpsertBulk {
  2953. return u.Update(func(s *UsageLogUpsert) {
  2954. s.UpdateRequestedModel()
  2955. })
  2956. }
  2957. // ClearRequestedModel clears the value of the "requested_model" field.
  2958. func (u *UsageLogUpsertBulk) ClearRequestedModel() *UsageLogUpsertBulk {
  2959. return u.Update(func(s *UsageLogUpsert) {
  2960. s.ClearRequestedModel()
  2961. })
  2962. }
  2963. // SetUpstreamModel sets the "upstream_model" field.
  2964. func (u *UsageLogUpsertBulk) SetUpstreamModel(v string) *UsageLogUpsertBulk {
  2965. return u.Update(func(s *UsageLogUpsert) {
  2966. s.SetUpstreamModel(v)
  2967. })
  2968. }
  2969. // UpdateUpstreamModel sets the "upstream_model" field to the value that was provided on create.
  2970. func (u *UsageLogUpsertBulk) UpdateUpstreamModel() *UsageLogUpsertBulk {
  2971. return u.Update(func(s *UsageLogUpsert) {
  2972. s.UpdateUpstreamModel()
  2973. })
  2974. }
  2975. // ClearUpstreamModel clears the value of the "upstream_model" field.
  2976. func (u *UsageLogUpsertBulk) ClearUpstreamModel() *UsageLogUpsertBulk {
  2977. return u.Update(func(s *UsageLogUpsert) {
  2978. s.ClearUpstreamModel()
  2979. })
  2980. }
  2981. // SetUpstreamResponseModel sets the "upstream_response_model" field.
  2982. func (u *UsageLogUpsertBulk) SetUpstreamResponseModel(v string) *UsageLogUpsertBulk {
  2983. return u.Update(func(s *UsageLogUpsert) {
  2984. s.SetUpstreamResponseModel(v)
  2985. })
  2986. }
  2987. // UpdateUpstreamResponseModel sets the "upstream_response_model" field to the value that was provided on create.
  2988. func (u *UsageLogUpsertBulk) UpdateUpstreamResponseModel() *UsageLogUpsertBulk {
  2989. return u.Update(func(s *UsageLogUpsert) {
  2990. s.UpdateUpstreamResponseModel()
  2991. })
  2992. }
  2993. // ClearUpstreamResponseModel clears the value of the "upstream_response_model" field.
  2994. func (u *UsageLogUpsertBulk) ClearUpstreamResponseModel() *UsageLogUpsertBulk {
  2995. return u.Update(func(s *UsageLogUpsert) {
  2996. s.ClearUpstreamResponseModel()
  2997. })
  2998. }
  2999. // SetUpstreamModelMismatch sets the "upstream_model_mismatch" field.
  3000. func (u *UsageLogUpsertBulk) SetUpstreamModelMismatch(v bool) *UsageLogUpsertBulk {
  3001. return u.Update(func(s *UsageLogUpsert) {
  3002. s.SetUpstreamModelMismatch(v)
  3003. })
  3004. }
  3005. // UpdateUpstreamModelMismatch sets the "upstream_model_mismatch" field to the value that was provided on create.
  3006. func (u *UsageLogUpsertBulk) UpdateUpstreamModelMismatch() *UsageLogUpsertBulk {
  3007. return u.Update(func(s *UsageLogUpsert) {
  3008. s.UpdateUpstreamModelMismatch()
  3009. })
  3010. }
  3011. // ClearUpstreamModelMismatch clears the value of the "upstream_model_mismatch" field.
  3012. func (u *UsageLogUpsertBulk) ClearUpstreamModelMismatch() *UsageLogUpsertBulk {
  3013. return u.Update(func(s *UsageLogUpsert) {
  3014. s.ClearUpstreamModelMismatch()
  3015. })
  3016. }
  3017. // SetChannelID sets the "channel_id" field.
  3018. func (u *UsageLogUpsertBulk) SetChannelID(v int64) *UsageLogUpsertBulk {
  3019. return u.Update(func(s *UsageLogUpsert) {
  3020. s.SetChannelID(v)
  3021. })
  3022. }
  3023. // AddChannelID adds v to the "channel_id" field.
  3024. func (u *UsageLogUpsertBulk) AddChannelID(v int64) *UsageLogUpsertBulk {
  3025. return u.Update(func(s *UsageLogUpsert) {
  3026. s.AddChannelID(v)
  3027. })
  3028. }
  3029. // UpdateChannelID sets the "channel_id" field to the value that was provided on create.
  3030. func (u *UsageLogUpsertBulk) UpdateChannelID() *UsageLogUpsertBulk {
  3031. return u.Update(func(s *UsageLogUpsert) {
  3032. s.UpdateChannelID()
  3033. })
  3034. }
  3035. // ClearChannelID clears the value of the "channel_id" field.
  3036. func (u *UsageLogUpsertBulk) ClearChannelID() *UsageLogUpsertBulk {
  3037. return u.Update(func(s *UsageLogUpsert) {
  3038. s.ClearChannelID()
  3039. })
  3040. }
  3041. // SetModelMappingChain sets the "model_mapping_chain" field.
  3042. func (u *UsageLogUpsertBulk) SetModelMappingChain(v string) *UsageLogUpsertBulk {
  3043. return u.Update(func(s *UsageLogUpsert) {
  3044. s.SetModelMappingChain(v)
  3045. })
  3046. }
  3047. // UpdateModelMappingChain sets the "model_mapping_chain" field to the value that was provided on create.
  3048. func (u *UsageLogUpsertBulk) UpdateModelMappingChain() *UsageLogUpsertBulk {
  3049. return u.Update(func(s *UsageLogUpsert) {
  3050. s.UpdateModelMappingChain()
  3051. })
  3052. }
  3053. // ClearModelMappingChain clears the value of the "model_mapping_chain" field.
  3054. func (u *UsageLogUpsertBulk) ClearModelMappingChain() *UsageLogUpsertBulk {
  3055. return u.Update(func(s *UsageLogUpsert) {
  3056. s.ClearModelMappingChain()
  3057. })
  3058. }
  3059. // SetBillingTier sets the "billing_tier" field.
  3060. func (u *UsageLogUpsertBulk) SetBillingTier(v string) *UsageLogUpsertBulk {
  3061. return u.Update(func(s *UsageLogUpsert) {
  3062. s.SetBillingTier(v)
  3063. })
  3064. }
  3065. // UpdateBillingTier sets the "billing_tier" field to the value that was provided on create.
  3066. func (u *UsageLogUpsertBulk) UpdateBillingTier() *UsageLogUpsertBulk {
  3067. return u.Update(func(s *UsageLogUpsert) {
  3068. s.UpdateBillingTier()
  3069. })
  3070. }
  3071. // ClearBillingTier clears the value of the "billing_tier" field.
  3072. func (u *UsageLogUpsertBulk) ClearBillingTier() *UsageLogUpsertBulk {
  3073. return u.Update(func(s *UsageLogUpsert) {
  3074. s.ClearBillingTier()
  3075. })
  3076. }
  3077. // SetBillingMode sets the "billing_mode" field.
  3078. func (u *UsageLogUpsertBulk) SetBillingMode(v string) *UsageLogUpsertBulk {
  3079. return u.Update(func(s *UsageLogUpsert) {
  3080. s.SetBillingMode(v)
  3081. })
  3082. }
  3083. // UpdateBillingMode sets the "billing_mode" field to the value that was provided on create.
  3084. func (u *UsageLogUpsertBulk) UpdateBillingMode() *UsageLogUpsertBulk {
  3085. return u.Update(func(s *UsageLogUpsert) {
  3086. s.UpdateBillingMode()
  3087. })
  3088. }
  3089. // ClearBillingMode clears the value of the "billing_mode" field.
  3090. func (u *UsageLogUpsertBulk) ClearBillingMode() *UsageLogUpsertBulk {
  3091. return u.Update(func(s *UsageLogUpsert) {
  3092. s.ClearBillingMode()
  3093. })
  3094. }
  3095. // SetGroupID sets the "group_id" field.
  3096. func (u *UsageLogUpsertBulk) SetGroupID(v int64) *UsageLogUpsertBulk {
  3097. return u.Update(func(s *UsageLogUpsert) {
  3098. s.SetGroupID(v)
  3099. })
  3100. }
  3101. // UpdateGroupID sets the "group_id" field to the value that was provided on create.
  3102. func (u *UsageLogUpsertBulk) UpdateGroupID() *UsageLogUpsertBulk {
  3103. return u.Update(func(s *UsageLogUpsert) {
  3104. s.UpdateGroupID()
  3105. })
  3106. }
  3107. // ClearGroupID clears the value of the "group_id" field.
  3108. func (u *UsageLogUpsertBulk) ClearGroupID() *UsageLogUpsertBulk {
  3109. return u.Update(func(s *UsageLogUpsert) {
  3110. s.ClearGroupID()
  3111. })
  3112. }
  3113. // SetSubscriptionID sets the "subscription_id" field.
  3114. func (u *UsageLogUpsertBulk) SetSubscriptionID(v int64) *UsageLogUpsertBulk {
  3115. return u.Update(func(s *UsageLogUpsert) {
  3116. s.SetSubscriptionID(v)
  3117. })
  3118. }
  3119. // UpdateSubscriptionID sets the "subscription_id" field to the value that was provided on create.
  3120. func (u *UsageLogUpsertBulk) UpdateSubscriptionID() *UsageLogUpsertBulk {
  3121. return u.Update(func(s *UsageLogUpsert) {
  3122. s.UpdateSubscriptionID()
  3123. })
  3124. }
  3125. // ClearSubscriptionID clears the value of the "subscription_id" field.
  3126. func (u *UsageLogUpsertBulk) ClearSubscriptionID() *UsageLogUpsertBulk {
  3127. return u.Update(func(s *UsageLogUpsert) {
  3128. s.ClearSubscriptionID()
  3129. })
  3130. }
  3131. // SetInputTokens sets the "input_tokens" field.
  3132. func (u *UsageLogUpsertBulk) SetInputTokens(v int) *UsageLogUpsertBulk {
  3133. return u.Update(func(s *UsageLogUpsert) {
  3134. s.SetInputTokens(v)
  3135. })
  3136. }
  3137. // AddInputTokens adds v to the "input_tokens" field.
  3138. func (u *UsageLogUpsertBulk) AddInputTokens(v int) *UsageLogUpsertBulk {
  3139. return u.Update(func(s *UsageLogUpsert) {
  3140. s.AddInputTokens(v)
  3141. })
  3142. }
  3143. // UpdateInputTokens sets the "input_tokens" field to the value that was provided on create.
  3144. func (u *UsageLogUpsertBulk) UpdateInputTokens() *UsageLogUpsertBulk {
  3145. return u.Update(func(s *UsageLogUpsert) {
  3146. s.UpdateInputTokens()
  3147. })
  3148. }
  3149. // SetOutputTokens sets the "output_tokens" field.
  3150. func (u *UsageLogUpsertBulk) SetOutputTokens(v int) *UsageLogUpsertBulk {
  3151. return u.Update(func(s *UsageLogUpsert) {
  3152. s.SetOutputTokens(v)
  3153. })
  3154. }
  3155. // AddOutputTokens adds v to the "output_tokens" field.
  3156. func (u *UsageLogUpsertBulk) AddOutputTokens(v int) *UsageLogUpsertBulk {
  3157. return u.Update(func(s *UsageLogUpsert) {
  3158. s.AddOutputTokens(v)
  3159. })
  3160. }
  3161. // UpdateOutputTokens sets the "output_tokens" field to the value that was provided on create.
  3162. func (u *UsageLogUpsertBulk) UpdateOutputTokens() *UsageLogUpsertBulk {
  3163. return u.Update(func(s *UsageLogUpsert) {
  3164. s.UpdateOutputTokens()
  3165. })
  3166. }
  3167. // SetCacheCreationTokens sets the "cache_creation_tokens" field.
  3168. func (u *UsageLogUpsertBulk) SetCacheCreationTokens(v int) *UsageLogUpsertBulk {
  3169. return u.Update(func(s *UsageLogUpsert) {
  3170. s.SetCacheCreationTokens(v)
  3171. })
  3172. }
  3173. // AddCacheCreationTokens adds v to the "cache_creation_tokens" field.
  3174. func (u *UsageLogUpsertBulk) AddCacheCreationTokens(v int) *UsageLogUpsertBulk {
  3175. return u.Update(func(s *UsageLogUpsert) {
  3176. s.AddCacheCreationTokens(v)
  3177. })
  3178. }
  3179. // UpdateCacheCreationTokens sets the "cache_creation_tokens" field to the value that was provided on create.
  3180. func (u *UsageLogUpsertBulk) UpdateCacheCreationTokens() *UsageLogUpsertBulk {
  3181. return u.Update(func(s *UsageLogUpsert) {
  3182. s.UpdateCacheCreationTokens()
  3183. })
  3184. }
  3185. // SetCacheReadTokens sets the "cache_read_tokens" field.
  3186. func (u *UsageLogUpsertBulk) SetCacheReadTokens(v int) *UsageLogUpsertBulk {
  3187. return u.Update(func(s *UsageLogUpsert) {
  3188. s.SetCacheReadTokens(v)
  3189. })
  3190. }
  3191. // AddCacheReadTokens adds v to the "cache_read_tokens" field.
  3192. func (u *UsageLogUpsertBulk) AddCacheReadTokens(v int) *UsageLogUpsertBulk {
  3193. return u.Update(func(s *UsageLogUpsert) {
  3194. s.AddCacheReadTokens(v)
  3195. })
  3196. }
  3197. // UpdateCacheReadTokens sets the "cache_read_tokens" field to the value that was provided on create.
  3198. func (u *UsageLogUpsertBulk) UpdateCacheReadTokens() *UsageLogUpsertBulk {
  3199. return u.Update(func(s *UsageLogUpsert) {
  3200. s.UpdateCacheReadTokens()
  3201. })
  3202. }
  3203. // SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
  3204. func (u *UsageLogUpsertBulk) SetCacheCreation5mTokens(v int) *UsageLogUpsertBulk {
  3205. return u.Update(func(s *UsageLogUpsert) {
  3206. s.SetCacheCreation5mTokens(v)
  3207. })
  3208. }
  3209. // AddCacheCreation5mTokens adds v to the "cache_creation_5m_tokens" field.
  3210. func (u *UsageLogUpsertBulk) AddCacheCreation5mTokens(v int) *UsageLogUpsertBulk {
  3211. return u.Update(func(s *UsageLogUpsert) {
  3212. s.AddCacheCreation5mTokens(v)
  3213. })
  3214. }
  3215. // UpdateCacheCreation5mTokens sets the "cache_creation_5m_tokens" field to the value that was provided on create.
  3216. func (u *UsageLogUpsertBulk) UpdateCacheCreation5mTokens() *UsageLogUpsertBulk {
  3217. return u.Update(func(s *UsageLogUpsert) {
  3218. s.UpdateCacheCreation5mTokens()
  3219. })
  3220. }
  3221. // SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
  3222. func (u *UsageLogUpsertBulk) SetCacheCreation1hTokens(v int) *UsageLogUpsertBulk {
  3223. return u.Update(func(s *UsageLogUpsert) {
  3224. s.SetCacheCreation1hTokens(v)
  3225. })
  3226. }
  3227. // AddCacheCreation1hTokens adds v to the "cache_creation_1h_tokens" field.
  3228. func (u *UsageLogUpsertBulk) AddCacheCreation1hTokens(v int) *UsageLogUpsertBulk {
  3229. return u.Update(func(s *UsageLogUpsert) {
  3230. s.AddCacheCreation1hTokens(v)
  3231. })
  3232. }
  3233. // UpdateCacheCreation1hTokens sets the "cache_creation_1h_tokens" field to the value that was provided on create.
  3234. func (u *UsageLogUpsertBulk) UpdateCacheCreation1hTokens() *UsageLogUpsertBulk {
  3235. return u.Update(func(s *UsageLogUpsert) {
  3236. s.UpdateCacheCreation1hTokens()
  3237. })
  3238. }
  3239. // SetInputCost sets the "input_cost" field.
  3240. func (u *UsageLogUpsertBulk) SetInputCost(v float64) *UsageLogUpsertBulk {
  3241. return u.Update(func(s *UsageLogUpsert) {
  3242. s.SetInputCost(v)
  3243. })
  3244. }
  3245. // AddInputCost adds v to the "input_cost" field.
  3246. func (u *UsageLogUpsertBulk) AddInputCost(v float64) *UsageLogUpsertBulk {
  3247. return u.Update(func(s *UsageLogUpsert) {
  3248. s.AddInputCost(v)
  3249. })
  3250. }
  3251. // UpdateInputCost sets the "input_cost" field to the value that was provided on create.
  3252. func (u *UsageLogUpsertBulk) UpdateInputCost() *UsageLogUpsertBulk {
  3253. return u.Update(func(s *UsageLogUpsert) {
  3254. s.UpdateInputCost()
  3255. })
  3256. }
  3257. // SetOutputCost sets the "output_cost" field.
  3258. func (u *UsageLogUpsertBulk) SetOutputCost(v float64) *UsageLogUpsertBulk {
  3259. return u.Update(func(s *UsageLogUpsert) {
  3260. s.SetOutputCost(v)
  3261. })
  3262. }
  3263. // AddOutputCost adds v to the "output_cost" field.
  3264. func (u *UsageLogUpsertBulk) AddOutputCost(v float64) *UsageLogUpsertBulk {
  3265. return u.Update(func(s *UsageLogUpsert) {
  3266. s.AddOutputCost(v)
  3267. })
  3268. }
  3269. // UpdateOutputCost sets the "output_cost" field to the value that was provided on create.
  3270. func (u *UsageLogUpsertBulk) UpdateOutputCost() *UsageLogUpsertBulk {
  3271. return u.Update(func(s *UsageLogUpsert) {
  3272. s.UpdateOutputCost()
  3273. })
  3274. }
  3275. // SetCacheCreationCost sets the "cache_creation_cost" field.
  3276. func (u *UsageLogUpsertBulk) SetCacheCreationCost(v float64) *UsageLogUpsertBulk {
  3277. return u.Update(func(s *UsageLogUpsert) {
  3278. s.SetCacheCreationCost(v)
  3279. })
  3280. }
  3281. // AddCacheCreationCost adds v to the "cache_creation_cost" field.
  3282. func (u *UsageLogUpsertBulk) AddCacheCreationCost(v float64) *UsageLogUpsertBulk {
  3283. return u.Update(func(s *UsageLogUpsert) {
  3284. s.AddCacheCreationCost(v)
  3285. })
  3286. }
  3287. // UpdateCacheCreationCost sets the "cache_creation_cost" field to the value that was provided on create.
  3288. func (u *UsageLogUpsertBulk) UpdateCacheCreationCost() *UsageLogUpsertBulk {
  3289. return u.Update(func(s *UsageLogUpsert) {
  3290. s.UpdateCacheCreationCost()
  3291. })
  3292. }
  3293. // SetCacheReadCost sets the "cache_read_cost" field.
  3294. func (u *UsageLogUpsertBulk) SetCacheReadCost(v float64) *UsageLogUpsertBulk {
  3295. return u.Update(func(s *UsageLogUpsert) {
  3296. s.SetCacheReadCost(v)
  3297. })
  3298. }
  3299. // AddCacheReadCost adds v to the "cache_read_cost" field.
  3300. func (u *UsageLogUpsertBulk) AddCacheReadCost(v float64) *UsageLogUpsertBulk {
  3301. return u.Update(func(s *UsageLogUpsert) {
  3302. s.AddCacheReadCost(v)
  3303. })
  3304. }
  3305. // UpdateCacheReadCost sets the "cache_read_cost" field to the value that was provided on create.
  3306. func (u *UsageLogUpsertBulk) UpdateCacheReadCost() *UsageLogUpsertBulk {
  3307. return u.Update(func(s *UsageLogUpsert) {
  3308. s.UpdateCacheReadCost()
  3309. })
  3310. }
  3311. // SetTotalCost sets the "total_cost" field.
  3312. func (u *UsageLogUpsertBulk) SetTotalCost(v float64) *UsageLogUpsertBulk {
  3313. return u.Update(func(s *UsageLogUpsert) {
  3314. s.SetTotalCost(v)
  3315. })
  3316. }
  3317. // AddTotalCost adds v to the "total_cost" field.
  3318. func (u *UsageLogUpsertBulk) AddTotalCost(v float64) *UsageLogUpsertBulk {
  3319. return u.Update(func(s *UsageLogUpsert) {
  3320. s.AddTotalCost(v)
  3321. })
  3322. }
  3323. // UpdateTotalCost sets the "total_cost" field to the value that was provided on create.
  3324. func (u *UsageLogUpsertBulk) UpdateTotalCost() *UsageLogUpsertBulk {
  3325. return u.Update(func(s *UsageLogUpsert) {
  3326. s.UpdateTotalCost()
  3327. })
  3328. }
  3329. // SetActualCost sets the "actual_cost" field.
  3330. func (u *UsageLogUpsertBulk) SetActualCost(v float64) *UsageLogUpsertBulk {
  3331. return u.Update(func(s *UsageLogUpsert) {
  3332. s.SetActualCost(v)
  3333. })
  3334. }
  3335. // AddActualCost adds v to the "actual_cost" field.
  3336. func (u *UsageLogUpsertBulk) AddActualCost(v float64) *UsageLogUpsertBulk {
  3337. return u.Update(func(s *UsageLogUpsert) {
  3338. s.AddActualCost(v)
  3339. })
  3340. }
  3341. // UpdateActualCost sets the "actual_cost" field to the value that was provided on create.
  3342. func (u *UsageLogUpsertBulk) UpdateActualCost() *UsageLogUpsertBulk {
  3343. return u.Update(func(s *UsageLogUpsert) {
  3344. s.UpdateActualCost()
  3345. })
  3346. }
  3347. // SetRateMultiplier sets the "rate_multiplier" field.
  3348. func (u *UsageLogUpsertBulk) SetRateMultiplier(v float64) *UsageLogUpsertBulk {
  3349. return u.Update(func(s *UsageLogUpsert) {
  3350. s.SetRateMultiplier(v)
  3351. })
  3352. }
  3353. // AddRateMultiplier adds v to the "rate_multiplier" field.
  3354. func (u *UsageLogUpsertBulk) AddRateMultiplier(v float64) *UsageLogUpsertBulk {
  3355. return u.Update(func(s *UsageLogUpsert) {
  3356. s.AddRateMultiplier(v)
  3357. })
  3358. }
  3359. // UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
  3360. func (u *UsageLogUpsertBulk) UpdateRateMultiplier() *UsageLogUpsertBulk {
  3361. return u.Update(func(s *UsageLogUpsert) {
  3362. s.UpdateRateMultiplier()
  3363. })
  3364. }
  3365. // SetLongContextBillingApplied sets the "long_context_billing_applied" field.
  3366. func (u *UsageLogUpsertBulk) SetLongContextBillingApplied(v bool) *UsageLogUpsertBulk {
  3367. return u.Update(func(s *UsageLogUpsert) {
  3368. s.SetLongContextBillingApplied(v)
  3369. })
  3370. }
  3371. // UpdateLongContextBillingApplied sets the "long_context_billing_applied" field to the value that was provided on create.
  3372. func (u *UsageLogUpsertBulk) UpdateLongContextBillingApplied() *UsageLogUpsertBulk {
  3373. return u.Update(func(s *UsageLogUpsert) {
  3374. s.UpdateLongContextBillingApplied()
  3375. })
  3376. }
  3377. // SetAccountRateMultiplier sets the "account_rate_multiplier" field.
  3378. func (u *UsageLogUpsertBulk) SetAccountRateMultiplier(v float64) *UsageLogUpsertBulk {
  3379. return u.Update(func(s *UsageLogUpsert) {
  3380. s.SetAccountRateMultiplier(v)
  3381. })
  3382. }
  3383. // AddAccountRateMultiplier adds v to the "account_rate_multiplier" field.
  3384. func (u *UsageLogUpsertBulk) AddAccountRateMultiplier(v float64) *UsageLogUpsertBulk {
  3385. return u.Update(func(s *UsageLogUpsert) {
  3386. s.AddAccountRateMultiplier(v)
  3387. })
  3388. }
  3389. // UpdateAccountRateMultiplier sets the "account_rate_multiplier" field to the value that was provided on create.
  3390. func (u *UsageLogUpsertBulk) UpdateAccountRateMultiplier() *UsageLogUpsertBulk {
  3391. return u.Update(func(s *UsageLogUpsert) {
  3392. s.UpdateAccountRateMultiplier()
  3393. })
  3394. }
  3395. // ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
  3396. func (u *UsageLogUpsertBulk) ClearAccountRateMultiplier() *UsageLogUpsertBulk {
  3397. return u.Update(func(s *UsageLogUpsert) {
  3398. s.ClearAccountRateMultiplier()
  3399. })
  3400. }
  3401. // SetBillingType sets the "billing_type" field.
  3402. func (u *UsageLogUpsertBulk) SetBillingType(v int8) *UsageLogUpsertBulk {
  3403. return u.Update(func(s *UsageLogUpsert) {
  3404. s.SetBillingType(v)
  3405. })
  3406. }
  3407. // AddBillingType adds v to the "billing_type" field.
  3408. func (u *UsageLogUpsertBulk) AddBillingType(v int8) *UsageLogUpsertBulk {
  3409. return u.Update(func(s *UsageLogUpsert) {
  3410. s.AddBillingType(v)
  3411. })
  3412. }
  3413. // UpdateBillingType sets the "billing_type" field to the value that was provided on create.
  3414. func (u *UsageLogUpsertBulk) UpdateBillingType() *UsageLogUpsertBulk {
  3415. return u.Update(func(s *UsageLogUpsert) {
  3416. s.UpdateBillingType()
  3417. })
  3418. }
  3419. // SetStream sets the "stream" field.
  3420. func (u *UsageLogUpsertBulk) SetStream(v bool) *UsageLogUpsertBulk {
  3421. return u.Update(func(s *UsageLogUpsert) {
  3422. s.SetStream(v)
  3423. })
  3424. }
  3425. // UpdateStream sets the "stream" field to the value that was provided on create.
  3426. func (u *UsageLogUpsertBulk) UpdateStream() *UsageLogUpsertBulk {
  3427. return u.Update(func(s *UsageLogUpsert) {
  3428. s.UpdateStream()
  3429. })
  3430. }
  3431. // SetDurationMs sets the "duration_ms" field.
  3432. func (u *UsageLogUpsertBulk) SetDurationMs(v int) *UsageLogUpsertBulk {
  3433. return u.Update(func(s *UsageLogUpsert) {
  3434. s.SetDurationMs(v)
  3435. })
  3436. }
  3437. // AddDurationMs adds v to the "duration_ms" field.
  3438. func (u *UsageLogUpsertBulk) AddDurationMs(v int) *UsageLogUpsertBulk {
  3439. return u.Update(func(s *UsageLogUpsert) {
  3440. s.AddDurationMs(v)
  3441. })
  3442. }
  3443. // UpdateDurationMs sets the "duration_ms" field to the value that was provided on create.
  3444. func (u *UsageLogUpsertBulk) UpdateDurationMs() *UsageLogUpsertBulk {
  3445. return u.Update(func(s *UsageLogUpsert) {
  3446. s.UpdateDurationMs()
  3447. })
  3448. }
  3449. // ClearDurationMs clears the value of the "duration_ms" field.
  3450. func (u *UsageLogUpsertBulk) ClearDurationMs() *UsageLogUpsertBulk {
  3451. return u.Update(func(s *UsageLogUpsert) {
  3452. s.ClearDurationMs()
  3453. })
  3454. }
  3455. // SetFirstTokenMs sets the "first_token_ms" field.
  3456. func (u *UsageLogUpsertBulk) SetFirstTokenMs(v int) *UsageLogUpsertBulk {
  3457. return u.Update(func(s *UsageLogUpsert) {
  3458. s.SetFirstTokenMs(v)
  3459. })
  3460. }
  3461. // AddFirstTokenMs adds v to the "first_token_ms" field.
  3462. func (u *UsageLogUpsertBulk) AddFirstTokenMs(v int) *UsageLogUpsertBulk {
  3463. return u.Update(func(s *UsageLogUpsert) {
  3464. s.AddFirstTokenMs(v)
  3465. })
  3466. }
  3467. // UpdateFirstTokenMs sets the "first_token_ms" field to the value that was provided on create.
  3468. func (u *UsageLogUpsertBulk) UpdateFirstTokenMs() *UsageLogUpsertBulk {
  3469. return u.Update(func(s *UsageLogUpsert) {
  3470. s.UpdateFirstTokenMs()
  3471. })
  3472. }
  3473. // ClearFirstTokenMs clears the value of the "first_token_ms" field.
  3474. func (u *UsageLogUpsertBulk) ClearFirstTokenMs() *UsageLogUpsertBulk {
  3475. return u.Update(func(s *UsageLogUpsert) {
  3476. s.ClearFirstTokenMs()
  3477. })
  3478. }
  3479. // SetUserAgent sets the "user_agent" field.
  3480. func (u *UsageLogUpsertBulk) SetUserAgent(v string) *UsageLogUpsertBulk {
  3481. return u.Update(func(s *UsageLogUpsert) {
  3482. s.SetUserAgent(v)
  3483. })
  3484. }
  3485. // UpdateUserAgent sets the "user_agent" field to the value that was provided on create.
  3486. func (u *UsageLogUpsertBulk) UpdateUserAgent() *UsageLogUpsertBulk {
  3487. return u.Update(func(s *UsageLogUpsert) {
  3488. s.UpdateUserAgent()
  3489. })
  3490. }
  3491. // ClearUserAgent clears the value of the "user_agent" field.
  3492. func (u *UsageLogUpsertBulk) ClearUserAgent() *UsageLogUpsertBulk {
  3493. return u.Update(func(s *UsageLogUpsert) {
  3494. s.ClearUserAgent()
  3495. })
  3496. }
  3497. // SetIPAddress sets the "ip_address" field.
  3498. func (u *UsageLogUpsertBulk) SetIPAddress(v string) *UsageLogUpsertBulk {
  3499. return u.Update(func(s *UsageLogUpsert) {
  3500. s.SetIPAddress(v)
  3501. })
  3502. }
  3503. // UpdateIPAddress sets the "ip_address" field to the value that was provided on create.
  3504. func (u *UsageLogUpsertBulk) UpdateIPAddress() *UsageLogUpsertBulk {
  3505. return u.Update(func(s *UsageLogUpsert) {
  3506. s.UpdateIPAddress()
  3507. })
  3508. }
  3509. // ClearIPAddress clears the value of the "ip_address" field.
  3510. func (u *UsageLogUpsertBulk) ClearIPAddress() *UsageLogUpsertBulk {
  3511. return u.Update(func(s *UsageLogUpsert) {
  3512. s.ClearIPAddress()
  3513. })
  3514. }
  3515. // SetImageCount sets the "image_count" field.
  3516. func (u *UsageLogUpsertBulk) SetImageCount(v int) *UsageLogUpsertBulk {
  3517. return u.Update(func(s *UsageLogUpsert) {
  3518. s.SetImageCount(v)
  3519. })
  3520. }
  3521. // AddImageCount adds v to the "image_count" field.
  3522. func (u *UsageLogUpsertBulk) AddImageCount(v int) *UsageLogUpsertBulk {
  3523. return u.Update(func(s *UsageLogUpsert) {
  3524. s.AddImageCount(v)
  3525. })
  3526. }
  3527. // UpdateImageCount sets the "image_count" field to the value that was provided on create.
  3528. func (u *UsageLogUpsertBulk) UpdateImageCount() *UsageLogUpsertBulk {
  3529. return u.Update(func(s *UsageLogUpsert) {
  3530. s.UpdateImageCount()
  3531. })
  3532. }
  3533. // SetImageSize sets the "image_size" field.
  3534. func (u *UsageLogUpsertBulk) SetImageSize(v string) *UsageLogUpsertBulk {
  3535. return u.Update(func(s *UsageLogUpsert) {
  3536. s.SetImageSize(v)
  3537. })
  3538. }
  3539. // UpdateImageSize sets the "image_size" field to the value that was provided on create.
  3540. func (u *UsageLogUpsertBulk) UpdateImageSize() *UsageLogUpsertBulk {
  3541. return u.Update(func(s *UsageLogUpsert) {
  3542. s.UpdateImageSize()
  3543. })
  3544. }
  3545. // ClearImageSize clears the value of the "image_size" field.
  3546. func (u *UsageLogUpsertBulk) ClearImageSize() *UsageLogUpsertBulk {
  3547. return u.Update(func(s *UsageLogUpsert) {
  3548. s.ClearImageSize()
  3549. })
  3550. }
  3551. // SetImageInputSize sets the "image_input_size" field.
  3552. func (u *UsageLogUpsertBulk) SetImageInputSize(v string) *UsageLogUpsertBulk {
  3553. return u.Update(func(s *UsageLogUpsert) {
  3554. s.SetImageInputSize(v)
  3555. })
  3556. }
  3557. // UpdateImageInputSize sets the "image_input_size" field to the value that was provided on create.
  3558. func (u *UsageLogUpsertBulk) UpdateImageInputSize() *UsageLogUpsertBulk {
  3559. return u.Update(func(s *UsageLogUpsert) {
  3560. s.UpdateImageInputSize()
  3561. })
  3562. }
  3563. // ClearImageInputSize clears the value of the "image_input_size" field.
  3564. func (u *UsageLogUpsertBulk) ClearImageInputSize() *UsageLogUpsertBulk {
  3565. return u.Update(func(s *UsageLogUpsert) {
  3566. s.ClearImageInputSize()
  3567. })
  3568. }
  3569. // SetImageOutputSize sets the "image_output_size" field.
  3570. func (u *UsageLogUpsertBulk) SetImageOutputSize(v string) *UsageLogUpsertBulk {
  3571. return u.Update(func(s *UsageLogUpsert) {
  3572. s.SetImageOutputSize(v)
  3573. })
  3574. }
  3575. // UpdateImageOutputSize sets the "image_output_size" field to the value that was provided on create.
  3576. func (u *UsageLogUpsertBulk) UpdateImageOutputSize() *UsageLogUpsertBulk {
  3577. return u.Update(func(s *UsageLogUpsert) {
  3578. s.UpdateImageOutputSize()
  3579. })
  3580. }
  3581. // ClearImageOutputSize clears the value of the "image_output_size" field.
  3582. func (u *UsageLogUpsertBulk) ClearImageOutputSize() *UsageLogUpsertBulk {
  3583. return u.Update(func(s *UsageLogUpsert) {
  3584. s.ClearImageOutputSize()
  3585. })
  3586. }
  3587. // SetImageSizeSource sets the "image_size_source" field.
  3588. func (u *UsageLogUpsertBulk) SetImageSizeSource(v string) *UsageLogUpsertBulk {
  3589. return u.Update(func(s *UsageLogUpsert) {
  3590. s.SetImageSizeSource(v)
  3591. })
  3592. }
  3593. // UpdateImageSizeSource sets the "image_size_source" field to the value that was provided on create.
  3594. func (u *UsageLogUpsertBulk) UpdateImageSizeSource() *UsageLogUpsertBulk {
  3595. return u.Update(func(s *UsageLogUpsert) {
  3596. s.UpdateImageSizeSource()
  3597. })
  3598. }
  3599. // ClearImageSizeSource clears the value of the "image_size_source" field.
  3600. func (u *UsageLogUpsertBulk) ClearImageSizeSource() *UsageLogUpsertBulk {
  3601. return u.Update(func(s *UsageLogUpsert) {
  3602. s.ClearImageSizeSource()
  3603. })
  3604. }
  3605. // SetImageSizeBreakdown sets the "image_size_breakdown" field.
  3606. func (u *UsageLogUpsertBulk) SetImageSizeBreakdown(v map[string]int) *UsageLogUpsertBulk {
  3607. return u.Update(func(s *UsageLogUpsert) {
  3608. s.SetImageSizeBreakdown(v)
  3609. })
  3610. }
  3611. // UpdateImageSizeBreakdown sets the "image_size_breakdown" field to the value that was provided on create.
  3612. func (u *UsageLogUpsertBulk) UpdateImageSizeBreakdown() *UsageLogUpsertBulk {
  3613. return u.Update(func(s *UsageLogUpsert) {
  3614. s.UpdateImageSizeBreakdown()
  3615. })
  3616. }
  3617. // ClearImageSizeBreakdown clears the value of the "image_size_breakdown" field.
  3618. func (u *UsageLogUpsertBulk) ClearImageSizeBreakdown() *UsageLogUpsertBulk {
  3619. return u.Update(func(s *UsageLogUpsert) {
  3620. s.ClearImageSizeBreakdown()
  3621. })
  3622. }
  3623. // SetVideoCount sets the "video_count" field.
  3624. func (u *UsageLogUpsertBulk) SetVideoCount(v int) *UsageLogUpsertBulk {
  3625. return u.Update(func(s *UsageLogUpsert) {
  3626. s.SetVideoCount(v)
  3627. })
  3628. }
  3629. // AddVideoCount adds v to the "video_count" field.
  3630. func (u *UsageLogUpsertBulk) AddVideoCount(v int) *UsageLogUpsertBulk {
  3631. return u.Update(func(s *UsageLogUpsert) {
  3632. s.AddVideoCount(v)
  3633. })
  3634. }
  3635. // UpdateVideoCount sets the "video_count" field to the value that was provided on create.
  3636. func (u *UsageLogUpsertBulk) UpdateVideoCount() *UsageLogUpsertBulk {
  3637. return u.Update(func(s *UsageLogUpsert) {
  3638. s.UpdateVideoCount()
  3639. })
  3640. }
  3641. // SetVideoResolution sets the "video_resolution" field.
  3642. func (u *UsageLogUpsertBulk) SetVideoResolution(v string) *UsageLogUpsertBulk {
  3643. return u.Update(func(s *UsageLogUpsert) {
  3644. s.SetVideoResolution(v)
  3645. })
  3646. }
  3647. // UpdateVideoResolution sets the "video_resolution" field to the value that was provided on create.
  3648. func (u *UsageLogUpsertBulk) UpdateVideoResolution() *UsageLogUpsertBulk {
  3649. return u.Update(func(s *UsageLogUpsert) {
  3650. s.UpdateVideoResolution()
  3651. })
  3652. }
  3653. // ClearVideoResolution clears the value of the "video_resolution" field.
  3654. func (u *UsageLogUpsertBulk) ClearVideoResolution() *UsageLogUpsertBulk {
  3655. return u.Update(func(s *UsageLogUpsert) {
  3656. s.ClearVideoResolution()
  3657. })
  3658. }
  3659. // SetVideoDurationSeconds sets the "video_duration_seconds" field.
  3660. func (u *UsageLogUpsertBulk) SetVideoDurationSeconds(v int) *UsageLogUpsertBulk {
  3661. return u.Update(func(s *UsageLogUpsert) {
  3662. s.SetVideoDurationSeconds(v)
  3663. })
  3664. }
  3665. // AddVideoDurationSeconds adds v to the "video_duration_seconds" field.
  3666. func (u *UsageLogUpsertBulk) AddVideoDurationSeconds(v int) *UsageLogUpsertBulk {
  3667. return u.Update(func(s *UsageLogUpsert) {
  3668. s.AddVideoDurationSeconds(v)
  3669. })
  3670. }
  3671. // UpdateVideoDurationSeconds sets the "video_duration_seconds" field to the value that was provided on create.
  3672. func (u *UsageLogUpsertBulk) UpdateVideoDurationSeconds() *UsageLogUpsertBulk {
  3673. return u.Update(func(s *UsageLogUpsert) {
  3674. s.UpdateVideoDurationSeconds()
  3675. })
  3676. }
  3677. // ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field.
  3678. func (u *UsageLogUpsertBulk) ClearVideoDurationSeconds() *UsageLogUpsertBulk {
  3679. return u.Update(func(s *UsageLogUpsert) {
  3680. s.ClearVideoDurationSeconds()
  3681. })
  3682. }
  3683. // SetCacheTTLOverridden sets the "cache_ttl_overridden" field.
  3684. func (u *UsageLogUpsertBulk) SetCacheTTLOverridden(v bool) *UsageLogUpsertBulk {
  3685. return u.Update(func(s *UsageLogUpsert) {
  3686. s.SetCacheTTLOverridden(v)
  3687. })
  3688. }
  3689. // UpdateCacheTTLOverridden sets the "cache_ttl_overridden" field to the value that was provided on create.
  3690. func (u *UsageLogUpsertBulk) UpdateCacheTTLOverridden() *UsageLogUpsertBulk {
  3691. return u.Update(func(s *UsageLogUpsert) {
  3692. s.UpdateCacheTTLOverridden()
  3693. })
  3694. }
  3695. // Exec executes the query.
  3696. func (u *UsageLogUpsertBulk) Exec(ctx context.Context) error {
  3697. if u.create.err != nil {
  3698. return u.create.err
  3699. }
  3700. for i, b := range u.create.builders {
  3701. if len(b.conflict) != 0 {
  3702. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the UsageLogCreateBulk instead", i)
  3703. }
  3704. }
  3705. if len(u.create.conflict) == 0 {
  3706. return errors.New("ent: missing options for UsageLogCreateBulk.OnConflict")
  3707. }
  3708. return u.create.Exec(ctx)
  3709. }
  3710. // ExecX is like Exec, but panics if an error occurs.
  3711. func (u *UsageLogUpsertBulk) ExecX(ctx context.Context) {
  3712. if err := u.create.Exec(ctx); err != nil {
  3713. panic(err)
  3714. }
  3715. }