| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- "github.com/Wei-Shaw/sub2api/ent/account"
- "github.com/Wei-Shaw/sub2api/ent/apikey"
- "github.com/Wei-Shaw/sub2api/ent/group"
- "github.com/Wei-Shaw/sub2api/ent/predicate"
- "github.com/Wei-Shaw/sub2api/ent/usagelog"
- "github.com/Wei-Shaw/sub2api/ent/user"
- "github.com/Wei-Shaw/sub2api/ent/usersubscription"
- )
- // UsageLogUpdate is the builder for updating UsageLog entities.
- type UsageLogUpdate struct {
- config
- hooks []Hook
- mutation *UsageLogMutation
- }
- // Where appends a list predicates to the UsageLogUpdate builder.
- func (_u *UsageLogUpdate) Where(ps ...predicate.UsageLog) *UsageLogUpdate {
- _u.mutation.Where(ps...)
- return _u
- }
- // SetUserID sets the "user_id" field.
- func (_u *UsageLogUpdate) SetUserID(v int64) *UsageLogUpdate {
- _u.mutation.SetUserID(v)
- return _u
- }
- // SetNillableUserID sets the "user_id" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableUserID(v *int64) *UsageLogUpdate {
- if v != nil {
- _u.SetUserID(*v)
- }
- return _u
- }
- // SetAPIKeyID sets the "api_key_id" field.
- func (_u *UsageLogUpdate) SetAPIKeyID(v int64) *UsageLogUpdate {
- _u.mutation.SetAPIKeyID(v)
- return _u
- }
- // SetNillableAPIKeyID sets the "api_key_id" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableAPIKeyID(v *int64) *UsageLogUpdate {
- if v != nil {
- _u.SetAPIKeyID(*v)
- }
- return _u
- }
- // SetAccountID sets the "account_id" field.
- func (_u *UsageLogUpdate) SetAccountID(v int64) *UsageLogUpdate {
- _u.mutation.SetAccountID(v)
- return _u
- }
- // SetNillableAccountID sets the "account_id" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableAccountID(v *int64) *UsageLogUpdate {
- if v != nil {
- _u.SetAccountID(*v)
- }
- return _u
- }
- // SetRequestID sets the "request_id" field.
- func (_u *UsageLogUpdate) SetRequestID(v string) *UsageLogUpdate {
- _u.mutation.SetRequestID(v)
- return _u
- }
- // SetNillableRequestID sets the "request_id" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableRequestID(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetRequestID(*v)
- }
- return _u
- }
- // SetModel sets the "model" field.
- func (_u *UsageLogUpdate) SetModel(v string) *UsageLogUpdate {
- _u.mutation.SetModel(v)
- return _u
- }
- // SetNillableModel sets the "model" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableModel(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetModel(*v)
- }
- return _u
- }
- // SetRequestedModel sets the "requested_model" field.
- func (_u *UsageLogUpdate) SetRequestedModel(v string) *UsageLogUpdate {
- _u.mutation.SetRequestedModel(v)
- return _u
- }
- // SetNillableRequestedModel sets the "requested_model" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableRequestedModel(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetRequestedModel(*v)
- }
- return _u
- }
- // ClearRequestedModel clears the value of the "requested_model" field.
- func (_u *UsageLogUpdate) ClearRequestedModel() *UsageLogUpdate {
- _u.mutation.ClearRequestedModel()
- return _u
- }
- // SetUpstreamModel sets the "upstream_model" field.
- func (_u *UsageLogUpdate) SetUpstreamModel(v string) *UsageLogUpdate {
- _u.mutation.SetUpstreamModel(v)
- return _u
- }
- // SetNillableUpstreamModel sets the "upstream_model" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableUpstreamModel(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetUpstreamModel(*v)
- }
- return _u
- }
- // ClearUpstreamModel clears the value of the "upstream_model" field.
- func (_u *UsageLogUpdate) ClearUpstreamModel() *UsageLogUpdate {
- _u.mutation.ClearUpstreamModel()
- return _u
- }
- // SetUpstreamResponseModel sets the "upstream_response_model" field.
- func (_u *UsageLogUpdate) SetUpstreamResponseModel(v string) *UsageLogUpdate {
- _u.mutation.SetUpstreamResponseModel(v)
- return _u
- }
- // SetNillableUpstreamResponseModel sets the "upstream_response_model" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableUpstreamResponseModel(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetUpstreamResponseModel(*v)
- }
- return _u
- }
- // ClearUpstreamResponseModel clears the value of the "upstream_response_model" field.
- func (_u *UsageLogUpdate) ClearUpstreamResponseModel() *UsageLogUpdate {
- _u.mutation.ClearUpstreamResponseModel()
- return _u
- }
- // SetUpstreamModelMismatch sets the "upstream_model_mismatch" field.
- func (_u *UsageLogUpdate) SetUpstreamModelMismatch(v bool) *UsageLogUpdate {
- _u.mutation.SetUpstreamModelMismatch(v)
- return _u
- }
- // SetNillableUpstreamModelMismatch sets the "upstream_model_mismatch" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableUpstreamModelMismatch(v *bool) *UsageLogUpdate {
- if v != nil {
- _u.SetUpstreamModelMismatch(*v)
- }
- return _u
- }
- // ClearUpstreamModelMismatch clears the value of the "upstream_model_mismatch" field.
- func (_u *UsageLogUpdate) ClearUpstreamModelMismatch() *UsageLogUpdate {
- _u.mutation.ClearUpstreamModelMismatch()
- return _u
- }
- // SetChannelID sets the "channel_id" field.
- func (_u *UsageLogUpdate) SetChannelID(v int64) *UsageLogUpdate {
- _u.mutation.ResetChannelID()
- _u.mutation.SetChannelID(v)
- return _u
- }
- // SetNillableChannelID sets the "channel_id" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableChannelID(v *int64) *UsageLogUpdate {
- if v != nil {
- _u.SetChannelID(*v)
- }
- return _u
- }
- // AddChannelID adds value to the "channel_id" field.
- func (_u *UsageLogUpdate) AddChannelID(v int64) *UsageLogUpdate {
- _u.mutation.AddChannelID(v)
- return _u
- }
- // ClearChannelID clears the value of the "channel_id" field.
- func (_u *UsageLogUpdate) ClearChannelID() *UsageLogUpdate {
- _u.mutation.ClearChannelID()
- return _u
- }
- // SetModelMappingChain sets the "model_mapping_chain" field.
- func (_u *UsageLogUpdate) SetModelMappingChain(v string) *UsageLogUpdate {
- _u.mutation.SetModelMappingChain(v)
- return _u
- }
- // SetNillableModelMappingChain sets the "model_mapping_chain" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableModelMappingChain(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetModelMappingChain(*v)
- }
- return _u
- }
- // ClearModelMappingChain clears the value of the "model_mapping_chain" field.
- func (_u *UsageLogUpdate) ClearModelMappingChain() *UsageLogUpdate {
- _u.mutation.ClearModelMappingChain()
- return _u
- }
- // SetBillingTier sets the "billing_tier" field.
- func (_u *UsageLogUpdate) SetBillingTier(v string) *UsageLogUpdate {
- _u.mutation.SetBillingTier(v)
- return _u
- }
- // SetNillableBillingTier sets the "billing_tier" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableBillingTier(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetBillingTier(*v)
- }
- return _u
- }
- // ClearBillingTier clears the value of the "billing_tier" field.
- func (_u *UsageLogUpdate) ClearBillingTier() *UsageLogUpdate {
- _u.mutation.ClearBillingTier()
- return _u
- }
- // SetBillingMode sets the "billing_mode" field.
- func (_u *UsageLogUpdate) SetBillingMode(v string) *UsageLogUpdate {
- _u.mutation.SetBillingMode(v)
- return _u
- }
- // SetNillableBillingMode sets the "billing_mode" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableBillingMode(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetBillingMode(*v)
- }
- return _u
- }
- // ClearBillingMode clears the value of the "billing_mode" field.
- func (_u *UsageLogUpdate) ClearBillingMode() *UsageLogUpdate {
- _u.mutation.ClearBillingMode()
- return _u
- }
- // SetGroupID sets the "group_id" field.
- func (_u *UsageLogUpdate) SetGroupID(v int64) *UsageLogUpdate {
- _u.mutation.SetGroupID(v)
- return _u
- }
- // SetNillableGroupID sets the "group_id" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableGroupID(v *int64) *UsageLogUpdate {
- if v != nil {
- _u.SetGroupID(*v)
- }
- return _u
- }
- // ClearGroupID clears the value of the "group_id" field.
- func (_u *UsageLogUpdate) ClearGroupID() *UsageLogUpdate {
- _u.mutation.ClearGroupID()
- return _u
- }
- // SetSubscriptionID sets the "subscription_id" field.
- func (_u *UsageLogUpdate) SetSubscriptionID(v int64) *UsageLogUpdate {
- _u.mutation.SetSubscriptionID(v)
- return _u
- }
- // SetNillableSubscriptionID sets the "subscription_id" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableSubscriptionID(v *int64) *UsageLogUpdate {
- if v != nil {
- _u.SetSubscriptionID(*v)
- }
- return _u
- }
- // ClearSubscriptionID clears the value of the "subscription_id" field.
- func (_u *UsageLogUpdate) ClearSubscriptionID() *UsageLogUpdate {
- _u.mutation.ClearSubscriptionID()
- return _u
- }
- // SetInputTokens sets the "input_tokens" field.
- func (_u *UsageLogUpdate) SetInputTokens(v int) *UsageLogUpdate {
- _u.mutation.ResetInputTokens()
- _u.mutation.SetInputTokens(v)
- return _u
- }
- // SetNillableInputTokens sets the "input_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableInputTokens(v *int) *UsageLogUpdate {
- if v != nil {
- _u.SetInputTokens(*v)
- }
- return _u
- }
- // AddInputTokens adds value to the "input_tokens" field.
- func (_u *UsageLogUpdate) AddInputTokens(v int) *UsageLogUpdate {
- _u.mutation.AddInputTokens(v)
- return _u
- }
- // SetOutputTokens sets the "output_tokens" field.
- func (_u *UsageLogUpdate) SetOutputTokens(v int) *UsageLogUpdate {
- _u.mutation.ResetOutputTokens()
- _u.mutation.SetOutputTokens(v)
- return _u
- }
- // SetNillableOutputTokens sets the "output_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableOutputTokens(v *int) *UsageLogUpdate {
- if v != nil {
- _u.SetOutputTokens(*v)
- }
- return _u
- }
- // AddOutputTokens adds value to the "output_tokens" field.
- func (_u *UsageLogUpdate) AddOutputTokens(v int) *UsageLogUpdate {
- _u.mutation.AddOutputTokens(v)
- return _u
- }
- // SetCacheCreationTokens sets the "cache_creation_tokens" field.
- func (_u *UsageLogUpdate) SetCacheCreationTokens(v int) *UsageLogUpdate {
- _u.mutation.ResetCacheCreationTokens()
- _u.mutation.SetCacheCreationTokens(v)
- return _u
- }
- // SetNillableCacheCreationTokens sets the "cache_creation_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableCacheCreationTokens(v *int) *UsageLogUpdate {
- if v != nil {
- _u.SetCacheCreationTokens(*v)
- }
- return _u
- }
- // AddCacheCreationTokens adds value to the "cache_creation_tokens" field.
- func (_u *UsageLogUpdate) AddCacheCreationTokens(v int) *UsageLogUpdate {
- _u.mutation.AddCacheCreationTokens(v)
- return _u
- }
- // SetCacheReadTokens sets the "cache_read_tokens" field.
- func (_u *UsageLogUpdate) SetCacheReadTokens(v int) *UsageLogUpdate {
- _u.mutation.ResetCacheReadTokens()
- _u.mutation.SetCacheReadTokens(v)
- return _u
- }
- // SetNillableCacheReadTokens sets the "cache_read_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableCacheReadTokens(v *int) *UsageLogUpdate {
- if v != nil {
- _u.SetCacheReadTokens(*v)
- }
- return _u
- }
- // AddCacheReadTokens adds value to the "cache_read_tokens" field.
- func (_u *UsageLogUpdate) AddCacheReadTokens(v int) *UsageLogUpdate {
- _u.mutation.AddCacheReadTokens(v)
- return _u
- }
- // SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
- func (_u *UsageLogUpdate) SetCacheCreation5mTokens(v int) *UsageLogUpdate {
- _u.mutation.ResetCacheCreation5mTokens()
- _u.mutation.SetCacheCreation5mTokens(v)
- return _u
- }
- // SetNillableCacheCreation5mTokens sets the "cache_creation_5m_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableCacheCreation5mTokens(v *int) *UsageLogUpdate {
- if v != nil {
- _u.SetCacheCreation5mTokens(*v)
- }
- return _u
- }
- // AddCacheCreation5mTokens adds value to the "cache_creation_5m_tokens" field.
- func (_u *UsageLogUpdate) AddCacheCreation5mTokens(v int) *UsageLogUpdate {
- _u.mutation.AddCacheCreation5mTokens(v)
- return _u
- }
- // SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
- func (_u *UsageLogUpdate) SetCacheCreation1hTokens(v int) *UsageLogUpdate {
- _u.mutation.ResetCacheCreation1hTokens()
- _u.mutation.SetCacheCreation1hTokens(v)
- return _u
- }
- // SetNillableCacheCreation1hTokens sets the "cache_creation_1h_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableCacheCreation1hTokens(v *int) *UsageLogUpdate {
- if v != nil {
- _u.SetCacheCreation1hTokens(*v)
- }
- return _u
- }
- // AddCacheCreation1hTokens adds value to the "cache_creation_1h_tokens" field.
- func (_u *UsageLogUpdate) AddCacheCreation1hTokens(v int) *UsageLogUpdate {
- _u.mutation.AddCacheCreation1hTokens(v)
- return _u
- }
- // SetInputCost sets the "input_cost" field.
- func (_u *UsageLogUpdate) SetInputCost(v float64) *UsageLogUpdate {
- _u.mutation.ResetInputCost()
- _u.mutation.SetInputCost(v)
- return _u
- }
- // SetNillableInputCost sets the "input_cost" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableInputCost(v *float64) *UsageLogUpdate {
- if v != nil {
- _u.SetInputCost(*v)
- }
- return _u
- }
- // AddInputCost adds value to the "input_cost" field.
- func (_u *UsageLogUpdate) AddInputCost(v float64) *UsageLogUpdate {
- _u.mutation.AddInputCost(v)
- return _u
- }
- // SetOutputCost sets the "output_cost" field.
- func (_u *UsageLogUpdate) SetOutputCost(v float64) *UsageLogUpdate {
- _u.mutation.ResetOutputCost()
- _u.mutation.SetOutputCost(v)
- return _u
- }
- // SetNillableOutputCost sets the "output_cost" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableOutputCost(v *float64) *UsageLogUpdate {
- if v != nil {
- _u.SetOutputCost(*v)
- }
- return _u
- }
- // AddOutputCost adds value to the "output_cost" field.
- func (_u *UsageLogUpdate) AddOutputCost(v float64) *UsageLogUpdate {
- _u.mutation.AddOutputCost(v)
- return _u
- }
- // SetCacheCreationCost sets the "cache_creation_cost" field.
- func (_u *UsageLogUpdate) SetCacheCreationCost(v float64) *UsageLogUpdate {
- _u.mutation.ResetCacheCreationCost()
- _u.mutation.SetCacheCreationCost(v)
- return _u
- }
- // SetNillableCacheCreationCost sets the "cache_creation_cost" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableCacheCreationCost(v *float64) *UsageLogUpdate {
- if v != nil {
- _u.SetCacheCreationCost(*v)
- }
- return _u
- }
- // AddCacheCreationCost adds value to the "cache_creation_cost" field.
- func (_u *UsageLogUpdate) AddCacheCreationCost(v float64) *UsageLogUpdate {
- _u.mutation.AddCacheCreationCost(v)
- return _u
- }
- // SetCacheReadCost sets the "cache_read_cost" field.
- func (_u *UsageLogUpdate) SetCacheReadCost(v float64) *UsageLogUpdate {
- _u.mutation.ResetCacheReadCost()
- _u.mutation.SetCacheReadCost(v)
- return _u
- }
- // SetNillableCacheReadCost sets the "cache_read_cost" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableCacheReadCost(v *float64) *UsageLogUpdate {
- if v != nil {
- _u.SetCacheReadCost(*v)
- }
- return _u
- }
- // AddCacheReadCost adds value to the "cache_read_cost" field.
- func (_u *UsageLogUpdate) AddCacheReadCost(v float64) *UsageLogUpdate {
- _u.mutation.AddCacheReadCost(v)
- return _u
- }
- // SetTotalCost sets the "total_cost" field.
- func (_u *UsageLogUpdate) SetTotalCost(v float64) *UsageLogUpdate {
- _u.mutation.ResetTotalCost()
- _u.mutation.SetTotalCost(v)
- return _u
- }
- // SetNillableTotalCost sets the "total_cost" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableTotalCost(v *float64) *UsageLogUpdate {
- if v != nil {
- _u.SetTotalCost(*v)
- }
- return _u
- }
- // AddTotalCost adds value to the "total_cost" field.
- func (_u *UsageLogUpdate) AddTotalCost(v float64) *UsageLogUpdate {
- _u.mutation.AddTotalCost(v)
- return _u
- }
- // SetActualCost sets the "actual_cost" field.
- func (_u *UsageLogUpdate) SetActualCost(v float64) *UsageLogUpdate {
- _u.mutation.ResetActualCost()
- _u.mutation.SetActualCost(v)
- return _u
- }
- // SetNillableActualCost sets the "actual_cost" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableActualCost(v *float64) *UsageLogUpdate {
- if v != nil {
- _u.SetActualCost(*v)
- }
- return _u
- }
- // AddActualCost adds value to the "actual_cost" field.
- func (_u *UsageLogUpdate) AddActualCost(v float64) *UsageLogUpdate {
- _u.mutation.AddActualCost(v)
- return _u
- }
- // SetRateMultiplier sets the "rate_multiplier" field.
- func (_u *UsageLogUpdate) SetRateMultiplier(v float64) *UsageLogUpdate {
- _u.mutation.ResetRateMultiplier()
- _u.mutation.SetRateMultiplier(v)
- return _u
- }
- // SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableRateMultiplier(v *float64) *UsageLogUpdate {
- if v != nil {
- _u.SetRateMultiplier(*v)
- }
- return _u
- }
- // AddRateMultiplier adds value to the "rate_multiplier" field.
- func (_u *UsageLogUpdate) AddRateMultiplier(v float64) *UsageLogUpdate {
- _u.mutation.AddRateMultiplier(v)
- return _u
- }
- // SetLongContextBillingApplied sets the "long_context_billing_applied" field.
- func (_u *UsageLogUpdate) SetLongContextBillingApplied(v bool) *UsageLogUpdate {
- _u.mutation.SetLongContextBillingApplied(v)
- return _u
- }
- // SetNillableLongContextBillingApplied sets the "long_context_billing_applied" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableLongContextBillingApplied(v *bool) *UsageLogUpdate {
- if v != nil {
- _u.SetLongContextBillingApplied(*v)
- }
- return _u
- }
- // SetAccountRateMultiplier sets the "account_rate_multiplier" field.
- func (_u *UsageLogUpdate) SetAccountRateMultiplier(v float64) *UsageLogUpdate {
- _u.mutation.ResetAccountRateMultiplier()
- _u.mutation.SetAccountRateMultiplier(v)
- return _u
- }
- // SetNillableAccountRateMultiplier sets the "account_rate_multiplier" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableAccountRateMultiplier(v *float64) *UsageLogUpdate {
- if v != nil {
- _u.SetAccountRateMultiplier(*v)
- }
- return _u
- }
- // AddAccountRateMultiplier adds value to the "account_rate_multiplier" field.
- func (_u *UsageLogUpdate) AddAccountRateMultiplier(v float64) *UsageLogUpdate {
- _u.mutation.AddAccountRateMultiplier(v)
- return _u
- }
- // ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
- func (_u *UsageLogUpdate) ClearAccountRateMultiplier() *UsageLogUpdate {
- _u.mutation.ClearAccountRateMultiplier()
- return _u
- }
- // SetBillingType sets the "billing_type" field.
- func (_u *UsageLogUpdate) SetBillingType(v int8) *UsageLogUpdate {
- _u.mutation.ResetBillingType()
- _u.mutation.SetBillingType(v)
- return _u
- }
- // SetNillableBillingType sets the "billing_type" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableBillingType(v *int8) *UsageLogUpdate {
- if v != nil {
- _u.SetBillingType(*v)
- }
- return _u
- }
- // AddBillingType adds value to the "billing_type" field.
- func (_u *UsageLogUpdate) AddBillingType(v int8) *UsageLogUpdate {
- _u.mutation.AddBillingType(v)
- return _u
- }
- // SetStream sets the "stream" field.
- func (_u *UsageLogUpdate) SetStream(v bool) *UsageLogUpdate {
- _u.mutation.SetStream(v)
- return _u
- }
- // SetNillableStream sets the "stream" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableStream(v *bool) *UsageLogUpdate {
- if v != nil {
- _u.SetStream(*v)
- }
- return _u
- }
- // SetDurationMs sets the "duration_ms" field.
- func (_u *UsageLogUpdate) SetDurationMs(v int) *UsageLogUpdate {
- _u.mutation.ResetDurationMs()
- _u.mutation.SetDurationMs(v)
- return _u
- }
- // SetNillableDurationMs sets the "duration_ms" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableDurationMs(v *int) *UsageLogUpdate {
- if v != nil {
- _u.SetDurationMs(*v)
- }
- return _u
- }
- // AddDurationMs adds value to the "duration_ms" field.
- func (_u *UsageLogUpdate) AddDurationMs(v int) *UsageLogUpdate {
- _u.mutation.AddDurationMs(v)
- return _u
- }
- // ClearDurationMs clears the value of the "duration_ms" field.
- func (_u *UsageLogUpdate) ClearDurationMs() *UsageLogUpdate {
- _u.mutation.ClearDurationMs()
- return _u
- }
- // SetFirstTokenMs sets the "first_token_ms" field.
- func (_u *UsageLogUpdate) SetFirstTokenMs(v int) *UsageLogUpdate {
- _u.mutation.ResetFirstTokenMs()
- _u.mutation.SetFirstTokenMs(v)
- return _u
- }
- // SetNillableFirstTokenMs sets the "first_token_ms" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableFirstTokenMs(v *int) *UsageLogUpdate {
- if v != nil {
- _u.SetFirstTokenMs(*v)
- }
- return _u
- }
- // AddFirstTokenMs adds value to the "first_token_ms" field.
- func (_u *UsageLogUpdate) AddFirstTokenMs(v int) *UsageLogUpdate {
- _u.mutation.AddFirstTokenMs(v)
- return _u
- }
- // ClearFirstTokenMs clears the value of the "first_token_ms" field.
- func (_u *UsageLogUpdate) ClearFirstTokenMs() *UsageLogUpdate {
- _u.mutation.ClearFirstTokenMs()
- return _u
- }
- // SetUserAgent sets the "user_agent" field.
- func (_u *UsageLogUpdate) SetUserAgent(v string) *UsageLogUpdate {
- _u.mutation.SetUserAgent(v)
- return _u
- }
- // SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableUserAgent(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetUserAgent(*v)
- }
- return _u
- }
- // ClearUserAgent clears the value of the "user_agent" field.
- func (_u *UsageLogUpdate) ClearUserAgent() *UsageLogUpdate {
- _u.mutation.ClearUserAgent()
- return _u
- }
- // SetIPAddress sets the "ip_address" field.
- func (_u *UsageLogUpdate) SetIPAddress(v string) *UsageLogUpdate {
- _u.mutation.SetIPAddress(v)
- return _u
- }
- // SetNillableIPAddress sets the "ip_address" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableIPAddress(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetIPAddress(*v)
- }
- return _u
- }
- // ClearIPAddress clears the value of the "ip_address" field.
- func (_u *UsageLogUpdate) ClearIPAddress() *UsageLogUpdate {
- _u.mutation.ClearIPAddress()
- return _u
- }
- // SetImageCount sets the "image_count" field.
- func (_u *UsageLogUpdate) SetImageCount(v int) *UsageLogUpdate {
- _u.mutation.ResetImageCount()
- _u.mutation.SetImageCount(v)
- return _u
- }
- // SetNillableImageCount sets the "image_count" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableImageCount(v *int) *UsageLogUpdate {
- if v != nil {
- _u.SetImageCount(*v)
- }
- return _u
- }
- // AddImageCount adds value to the "image_count" field.
- func (_u *UsageLogUpdate) AddImageCount(v int) *UsageLogUpdate {
- _u.mutation.AddImageCount(v)
- return _u
- }
- // SetImageSize sets the "image_size" field.
- func (_u *UsageLogUpdate) SetImageSize(v string) *UsageLogUpdate {
- _u.mutation.SetImageSize(v)
- return _u
- }
- // SetNillableImageSize sets the "image_size" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableImageSize(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetImageSize(*v)
- }
- return _u
- }
- // ClearImageSize clears the value of the "image_size" field.
- func (_u *UsageLogUpdate) ClearImageSize() *UsageLogUpdate {
- _u.mutation.ClearImageSize()
- return _u
- }
- // SetImageInputSize sets the "image_input_size" field.
- func (_u *UsageLogUpdate) SetImageInputSize(v string) *UsageLogUpdate {
- _u.mutation.SetImageInputSize(v)
- return _u
- }
- // SetNillableImageInputSize sets the "image_input_size" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableImageInputSize(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetImageInputSize(*v)
- }
- return _u
- }
- // ClearImageInputSize clears the value of the "image_input_size" field.
- func (_u *UsageLogUpdate) ClearImageInputSize() *UsageLogUpdate {
- _u.mutation.ClearImageInputSize()
- return _u
- }
- // SetImageOutputSize sets the "image_output_size" field.
- func (_u *UsageLogUpdate) SetImageOutputSize(v string) *UsageLogUpdate {
- _u.mutation.SetImageOutputSize(v)
- return _u
- }
- // SetNillableImageOutputSize sets the "image_output_size" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableImageOutputSize(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetImageOutputSize(*v)
- }
- return _u
- }
- // ClearImageOutputSize clears the value of the "image_output_size" field.
- func (_u *UsageLogUpdate) ClearImageOutputSize() *UsageLogUpdate {
- _u.mutation.ClearImageOutputSize()
- return _u
- }
- // SetImageSizeSource sets the "image_size_source" field.
- func (_u *UsageLogUpdate) SetImageSizeSource(v string) *UsageLogUpdate {
- _u.mutation.SetImageSizeSource(v)
- return _u
- }
- // SetNillableImageSizeSource sets the "image_size_source" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableImageSizeSource(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetImageSizeSource(*v)
- }
- return _u
- }
- // ClearImageSizeSource clears the value of the "image_size_source" field.
- func (_u *UsageLogUpdate) ClearImageSizeSource() *UsageLogUpdate {
- _u.mutation.ClearImageSizeSource()
- return _u
- }
- // SetImageSizeBreakdown sets the "image_size_breakdown" field.
- func (_u *UsageLogUpdate) SetImageSizeBreakdown(v map[string]int) *UsageLogUpdate {
- _u.mutation.SetImageSizeBreakdown(v)
- return _u
- }
- // ClearImageSizeBreakdown clears the value of the "image_size_breakdown" field.
- func (_u *UsageLogUpdate) ClearImageSizeBreakdown() *UsageLogUpdate {
- _u.mutation.ClearImageSizeBreakdown()
- return _u
- }
- // SetVideoCount sets the "video_count" field.
- func (_u *UsageLogUpdate) SetVideoCount(v int) *UsageLogUpdate {
- _u.mutation.ResetVideoCount()
- _u.mutation.SetVideoCount(v)
- return _u
- }
- // SetNillableVideoCount sets the "video_count" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableVideoCount(v *int) *UsageLogUpdate {
- if v != nil {
- _u.SetVideoCount(*v)
- }
- return _u
- }
- // AddVideoCount adds value to the "video_count" field.
- func (_u *UsageLogUpdate) AddVideoCount(v int) *UsageLogUpdate {
- _u.mutation.AddVideoCount(v)
- return _u
- }
- // SetVideoResolution sets the "video_resolution" field.
- func (_u *UsageLogUpdate) SetVideoResolution(v string) *UsageLogUpdate {
- _u.mutation.SetVideoResolution(v)
- return _u
- }
- // SetNillableVideoResolution sets the "video_resolution" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableVideoResolution(v *string) *UsageLogUpdate {
- if v != nil {
- _u.SetVideoResolution(*v)
- }
- return _u
- }
- // ClearVideoResolution clears the value of the "video_resolution" field.
- func (_u *UsageLogUpdate) ClearVideoResolution() *UsageLogUpdate {
- _u.mutation.ClearVideoResolution()
- return _u
- }
- // SetVideoDurationSeconds sets the "video_duration_seconds" field.
- func (_u *UsageLogUpdate) SetVideoDurationSeconds(v int) *UsageLogUpdate {
- _u.mutation.ResetVideoDurationSeconds()
- _u.mutation.SetVideoDurationSeconds(v)
- return _u
- }
- // SetNillableVideoDurationSeconds sets the "video_duration_seconds" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableVideoDurationSeconds(v *int) *UsageLogUpdate {
- if v != nil {
- _u.SetVideoDurationSeconds(*v)
- }
- return _u
- }
- // AddVideoDurationSeconds adds value to the "video_duration_seconds" field.
- func (_u *UsageLogUpdate) AddVideoDurationSeconds(v int) *UsageLogUpdate {
- _u.mutation.AddVideoDurationSeconds(v)
- return _u
- }
- // ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field.
- func (_u *UsageLogUpdate) ClearVideoDurationSeconds() *UsageLogUpdate {
- _u.mutation.ClearVideoDurationSeconds()
- return _u
- }
- // SetCacheTTLOverridden sets the "cache_ttl_overridden" field.
- func (_u *UsageLogUpdate) SetCacheTTLOverridden(v bool) *UsageLogUpdate {
- _u.mutation.SetCacheTTLOverridden(v)
- return _u
- }
- // SetNillableCacheTTLOverridden sets the "cache_ttl_overridden" field if the given value is not nil.
- func (_u *UsageLogUpdate) SetNillableCacheTTLOverridden(v *bool) *UsageLogUpdate {
- if v != nil {
- _u.SetCacheTTLOverridden(*v)
- }
- return _u
- }
- // SetUser sets the "user" edge to the User entity.
- func (_u *UsageLogUpdate) SetUser(v *User) *UsageLogUpdate {
- return _u.SetUserID(v.ID)
- }
- // SetAPIKey sets the "api_key" edge to the APIKey entity.
- func (_u *UsageLogUpdate) SetAPIKey(v *APIKey) *UsageLogUpdate {
- return _u.SetAPIKeyID(v.ID)
- }
- // SetAccount sets the "account" edge to the Account entity.
- func (_u *UsageLogUpdate) SetAccount(v *Account) *UsageLogUpdate {
- return _u.SetAccountID(v.ID)
- }
- // SetGroup sets the "group" edge to the Group entity.
- func (_u *UsageLogUpdate) SetGroup(v *Group) *UsageLogUpdate {
- return _u.SetGroupID(v.ID)
- }
- // SetSubscription sets the "subscription" edge to the UserSubscription entity.
- func (_u *UsageLogUpdate) SetSubscription(v *UserSubscription) *UsageLogUpdate {
- return _u.SetSubscriptionID(v.ID)
- }
- // Mutation returns the UsageLogMutation object of the builder.
- func (_u *UsageLogUpdate) Mutation() *UsageLogMutation {
- return _u.mutation
- }
- // ClearUser clears the "user" edge to the User entity.
- func (_u *UsageLogUpdate) ClearUser() *UsageLogUpdate {
- _u.mutation.ClearUser()
- return _u
- }
- // ClearAPIKey clears the "api_key" edge to the APIKey entity.
- func (_u *UsageLogUpdate) ClearAPIKey() *UsageLogUpdate {
- _u.mutation.ClearAPIKey()
- return _u
- }
- // ClearAccount clears the "account" edge to the Account entity.
- func (_u *UsageLogUpdate) ClearAccount() *UsageLogUpdate {
- _u.mutation.ClearAccount()
- return _u
- }
- // ClearGroup clears the "group" edge to the Group entity.
- func (_u *UsageLogUpdate) ClearGroup() *UsageLogUpdate {
- _u.mutation.ClearGroup()
- return _u
- }
- // ClearSubscription clears the "subscription" edge to the UserSubscription entity.
- func (_u *UsageLogUpdate) ClearSubscription() *UsageLogUpdate {
- _u.mutation.ClearSubscription()
- return _u
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (_u *UsageLogUpdate) Save(ctx context.Context) (int, error) {
- return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_u *UsageLogUpdate) SaveX(ctx context.Context) int {
- affected, err := _u.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (_u *UsageLogUpdate) Exec(ctx context.Context) error {
- _, err := _u.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_u *UsageLogUpdate) ExecX(ctx context.Context) {
- if err := _u.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_u *UsageLogUpdate) check() error {
- if v, ok := _u.mutation.RequestID(); ok {
- if err := usagelog.RequestIDValidator(v); err != nil {
- return &ValidationError{Name: "request_id", err: fmt.Errorf(`ent: validator failed for field "UsageLog.request_id": %w`, err)}
- }
- }
- if v, ok := _u.mutation.Model(); ok {
- if err := usagelog.ModelValidator(v); err != nil {
- return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model": %w`, err)}
- }
- }
- if v, ok := _u.mutation.RequestedModel(); ok {
- if err := usagelog.RequestedModelValidator(v); err != nil {
- return &ValidationError{Name: "requested_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.requested_model": %w`, err)}
- }
- }
- if v, ok := _u.mutation.UpstreamModel(); ok {
- if err := usagelog.UpstreamModelValidator(v); err != nil {
- return &ValidationError{Name: "upstream_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.upstream_model": %w`, err)}
- }
- }
- if v, ok := _u.mutation.UpstreamResponseModel(); ok {
- if err := usagelog.UpstreamResponseModelValidator(v); err != nil {
- return &ValidationError{Name: "upstream_response_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.upstream_response_model": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ModelMappingChain(); ok {
- if err := usagelog.ModelMappingChainValidator(v); err != nil {
- return &ValidationError{Name: "model_mapping_chain", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model_mapping_chain": %w`, err)}
- }
- }
- if v, ok := _u.mutation.BillingTier(); ok {
- if err := usagelog.BillingTierValidator(v); err != nil {
- return &ValidationError{Name: "billing_tier", err: fmt.Errorf(`ent: validator failed for field "UsageLog.billing_tier": %w`, err)}
- }
- }
- if v, ok := _u.mutation.BillingMode(); ok {
- if err := usagelog.BillingModeValidator(v); err != nil {
- return &ValidationError{Name: "billing_mode", err: fmt.Errorf(`ent: validator failed for field "UsageLog.billing_mode": %w`, err)}
- }
- }
- if v, ok := _u.mutation.UserAgent(); ok {
- if err := usagelog.UserAgentValidator(v); err != nil {
- return &ValidationError{Name: "user_agent", err: fmt.Errorf(`ent: validator failed for field "UsageLog.user_agent": %w`, err)}
- }
- }
- if v, ok := _u.mutation.IPAddress(); ok {
- if err := usagelog.IPAddressValidator(v); err != nil {
- return &ValidationError{Name: "ip_address", err: fmt.Errorf(`ent: validator failed for field "UsageLog.ip_address": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ImageSize(); ok {
- if err := usagelog.ImageSizeValidator(v); err != nil {
- return &ValidationError{Name: "image_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ImageInputSize(); ok {
- if err := usagelog.ImageInputSizeValidator(v); err != nil {
- return &ValidationError{Name: "image_input_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_input_size": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ImageOutputSize(); ok {
- if err := usagelog.ImageOutputSizeValidator(v); err != nil {
- return &ValidationError{Name: "image_output_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_output_size": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ImageSizeSource(); ok {
- if err := usagelog.ImageSizeSourceValidator(v); err != nil {
- return &ValidationError{Name: "image_size_source", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size_source": %w`, err)}
- }
- }
- if v, ok := _u.mutation.VideoResolution(); ok {
- if err := usagelog.VideoResolutionValidator(v); err != nil {
- return &ValidationError{Name: "video_resolution", err: fmt.Errorf(`ent: validator failed for field "UsageLog.video_resolution": %w`, err)}
- }
- }
- if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
- return errors.New(`ent: clearing a required unique edge "UsageLog.user"`)
- }
- if _u.mutation.APIKeyCleared() && len(_u.mutation.APIKeyIDs()) > 0 {
- return errors.New(`ent: clearing a required unique edge "UsageLog.api_key"`)
- }
- if _u.mutation.AccountCleared() && len(_u.mutation.AccountIDs()) > 0 {
- return errors.New(`ent: clearing a required unique edge "UsageLog.account"`)
- }
- return nil
- }
- func (_u *UsageLogUpdate) sqlSave(ctx context.Context) (_node int, err error) {
- if err := _u.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(usagelog.Table, usagelog.Columns, sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64))
- if ps := _u.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := _u.mutation.RequestID(); ok {
- _spec.SetField(usagelog.FieldRequestID, field.TypeString, value)
- }
- if value, ok := _u.mutation.Model(); ok {
- _spec.SetField(usagelog.FieldModel, field.TypeString, value)
- }
- if value, ok := _u.mutation.RequestedModel(); ok {
- _spec.SetField(usagelog.FieldRequestedModel, field.TypeString, value)
- }
- if _u.mutation.RequestedModelCleared() {
- _spec.ClearField(usagelog.FieldRequestedModel, field.TypeString)
- }
- if value, ok := _u.mutation.UpstreamModel(); ok {
- _spec.SetField(usagelog.FieldUpstreamModel, field.TypeString, value)
- }
- if _u.mutation.UpstreamModelCleared() {
- _spec.ClearField(usagelog.FieldUpstreamModel, field.TypeString)
- }
- if value, ok := _u.mutation.UpstreamResponseModel(); ok {
- _spec.SetField(usagelog.FieldUpstreamResponseModel, field.TypeString, value)
- }
- if _u.mutation.UpstreamResponseModelCleared() {
- _spec.ClearField(usagelog.FieldUpstreamResponseModel, field.TypeString)
- }
- if value, ok := _u.mutation.UpstreamModelMismatch(); ok {
- _spec.SetField(usagelog.FieldUpstreamModelMismatch, field.TypeBool, value)
- }
- if _u.mutation.UpstreamModelMismatchCleared() {
- _spec.ClearField(usagelog.FieldUpstreamModelMismatch, field.TypeBool)
- }
- if value, ok := _u.mutation.ChannelID(); ok {
- _spec.SetField(usagelog.FieldChannelID, field.TypeInt64, value)
- }
- if value, ok := _u.mutation.AddedChannelID(); ok {
- _spec.AddField(usagelog.FieldChannelID, field.TypeInt64, value)
- }
- if _u.mutation.ChannelIDCleared() {
- _spec.ClearField(usagelog.FieldChannelID, field.TypeInt64)
- }
- if value, ok := _u.mutation.ModelMappingChain(); ok {
- _spec.SetField(usagelog.FieldModelMappingChain, field.TypeString, value)
- }
- if _u.mutation.ModelMappingChainCleared() {
- _spec.ClearField(usagelog.FieldModelMappingChain, field.TypeString)
- }
- if value, ok := _u.mutation.BillingTier(); ok {
- _spec.SetField(usagelog.FieldBillingTier, field.TypeString, value)
- }
- if _u.mutation.BillingTierCleared() {
- _spec.ClearField(usagelog.FieldBillingTier, field.TypeString)
- }
- if value, ok := _u.mutation.BillingMode(); ok {
- _spec.SetField(usagelog.FieldBillingMode, field.TypeString, value)
- }
- if _u.mutation.BillingModeCleared() {
- _spec.ClearField(usagelog.FieldBillingMode, field.TypeString)
- }
- if value, ok := _u.mutation.InputTokens(); ok {
- _spec.SetField(usagelog.FieldInputTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedInputTokens(); ok {
- _spec.AddField(usagelog.FieldInputTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.OutputTokens(); ok {
- _spec.SetField(usagelog.FieldOutputTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedOutputTokens(); ok {
- _spec.AddField(usagelog.FieldOutputTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.CacheCreationTokens(); ok {
- _spec.SetField(usagelog.FieldCacheCreationTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedCacheCreationTokens(); ok {
- _spec.AddField(usagelog.FieldCacheCreationTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.CacheReadTokens(); ok {
- _spec.SetField(usagelog.FieldCacheReadTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedCacheReadTokens(); ok {
- _spec.AddField(usagelog.FieldCacheReadTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.CacheCreation5mTokens(); ok {
- _spec.SetField(usagelog.FieldCacheCreation5mTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedCacheCreation5mTokens(); ok {
- _spec.AddField(usagelog.FieldCacheCreation5mTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.CacheCreation1hTokens(); ok {
- _spec.SetField(usagelog.FieldCacheCreation1hTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedCacheCreation1hTokens(); ok {
- _spec.AddField(usagelog.FieldCacheCreation1hTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.InputCost(); ok {
- _spec.SetField(usagelog.FieldInputCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedInputCost(); ok {
- _spec.AddField(usagelog.FieldInputCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.OutputCost(); ok {
- _spec.SetField(usagelog.FieldOutputCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedOutputCost(); ok {
- _spec.AddField(usagelog.FieldOutputCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.CacheCreationCost(); ok {
- _spec.SetField(usagelog.FieldCacheCreationCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedCacheCreationCost(); ok {
- _spec.AddField(usagelog.FieldCacheCreationCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.CacheReadCost(); ok {
- _spec.SetField(usagelog.FieldCacheReadCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedCacheReadCost(); ok {
- _spec.AddField(usagelog.FieldCacheReadCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.TotalCost(); ok {
- _spec.SetField(usagelog.FieldTotalCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedTotalCost(); ok {
- _spec.AddField(usagelog.FieldTotalCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.ActualCost(); ok {
- _spec.SetField(usagelog.FieldActualCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedActualCost(); ok {
- _spec.AddField(usagelog.FieldActualCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.RateMultiplier(); ok {
- _spec.SetField(usagelog.FieldRateMultiplier, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedRateMultiplier(); ok {
- _spec.AddField(usagelog.FieldRateMultiplier, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.LongContextBillingApplied(); ok {
- _spec.SetField(usagelog.FieldLongContextBillingApplied, field.TypeBool, value)
- }
- if value, ok := _u.mutation.AccountRateMultiplier(); ok {
- _spec.SetField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedAccountRateMultiplier(); ok {
- _spec.AddField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64, value)
- }
- if _u.mutation.AccountRateMultiplierCleared() {
- _spec.ClearField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64)
- }
- if value, ok := _u.mutation.BillingType(); ok {
- _spec.SetField(usagelog.FieldBillingType, field.TypeInt8, value)
- }
- if value, ok := _u.mutation.AddedBillingType(); ok {
- _spec.AddField(usagelog.FieldBillingType, field.TypeInt8, value)
- }
- if value, ok := _u.mutation.Stream(); ok {
- _spec.SetField(usagelog.FieldStream, field.TypeBool, value)
- }
- if value, ok := _u.mutation.DurationMs(); ok {
- _spec.SetField(usagelog.FieldDurationMs, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedDurationMs(); ok {
- _spec.AddField(usagelog.FieldDurationMs, field.TypeInt, value)
- }
- if _u.mutation.DurationMsCleared() {
- _spec.ClearField(usagelog.FieldDurationMs, field.TypeInt)
- }
- if value, ok := _u.mutation.FirstTokenMs(); ok {
- _spec.SetField(usagelog.FieldFirstTokenMs, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedFirstTokenMs(); ok {
- _spec.AddField(usagelog.FieldFirstTokenMs, field.TypeInt, value)
- }
- if _u.mutation.FirstTokenMsCleared() {
- _spec.ClearField(usagelog.FieldFirstTokenMs, field.TypeInt)
- }
- if value, ok := _u.mutation.UserAgent(); ok {
- _spec.SetField(usagelog.FieldUserAgent, field.TypeString, value)
- }
- if _u.mutation.UserAgentCleared() {
- _spec.ClearField(usagelog.FieldUserAgent, field.TypeString)
- }
- if value, ok := _u.mutation.IPAddress(); ok {
- _spec.SetField(usagelog.FieldIPAddress, field.TypeString, value)
- }
- if _u.mutation.IPAddressCleared() {
- _spec.ClearField(usagelog.FieldIPAddress, field.TypeString)
- }
- if value, ok := _u.mutation.ImageCount(); ok {
- _spec.SetField(usagelog.FieldImageCount, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedImageCount(); ok {
- _spec.AddField(usagelog.FieldImageCount, field.TypeInt, value)
- }
- if value, ok := _u.mutation.ImageSize(); ok {
- _spec.SetField(usagelog.FieldImageSize, field.TypeString, value)
- }
- if _u.mutation.ImageSizeCleared() {
- _spec.ClearField(usagelog.FieldImageSize, field.TypeString)
- }
- if value, ok := _u.mutation.ImageInputSize(); ok {
- _spec.SetField(usagelog.FieldImageInputSize, field.TypeString, value)
- }
- if _u.mutation.ImageInputSizeCleared() {
- _spec.ClearField(usagelog.FieldImageInputSize, field.TypeString)
- }
- if value, ok := _u.mutation.ImageOutputSize(); ok {
- _spec.SetField(usagelog.FieldImageOutputSize, field.TypeString, value)
- }
- if _u.mutation.ImageOutputSizeCleared() {
- _spec.ClearField(usagelog.FieldImageOutputSize, field.TypeString)
- }
- if value, ok := _u.mutation.ImageSizeSource(); ok {
- _spec.SetField(usagelog.FieldImageSizeSource, field.TypeString, value)
- }
- if _u.mutation.ImageSizeSourceCleared() {
- _spec.ClearField(usagelog.FieldImageSizeSource, field.TypeString)
- }
- if value, ok := _u.mutation.ImageSizeBreakdown(); ok {
- _spec.SetField(usagelog.FieldImageSizeBreakdown, field.TypeJSON, value)
- }
- if _u.mutation.ImageSizeBreakdownCleared() {
- _spec.ClearField(usagelog.FieldImageSizeBreakdown, field.TypeJSON)
- }
- if value, ok := _u.mutation.VideoCount(); ok {
- _spec.SetField(usagelog.FieldVideoCount, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedVideoCount(); ok {
- _spec.AddField(usagelog.FieldVideoCount, field.TypeInt, value)
- }
- if value, ok := _u.mutation.VideoResolution(); ok {
- _spec.SetField(usagelog.FieldVideoResolution, field.TypeString, value)
- }
- if _u.mutation.VideoResolutionCleared() {
- _spec.ClearField(usagelog.FieldVideoResolution, field.TypeString)
- }
- if value, ok := _u.mutation.VideoDurationSeconds(); ok {
- _spec.SetField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedVideoDurationSeconds(); ok {
- _spec.AddField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value)
- }
- if _u.mutation.VideoDurationSecondsCleared() {
- _spec.ClearField(usagelog.FieldVideoDurationSeconds, field.TypeInt)
- }
- if value, ok := _u.mutation.CacheTTLOverridden(); ok {
- _spec.SetField(usagelog.FieldCacheTTLOverridden, field.TypeBool, value)
- }
- if _u.mutation.UserCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.UserTable,
- Columns: []string{usagelog.UserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.UserTable,
- Columns: []string{usagelog.UserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.APIKeyCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.APIKeyTable,
- Columns: []string{usagelog.APIKeyColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.APIKeyIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.APIKeyTable,
- Columns: []string{usagelog.APIKeyColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.AccountCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.AccountTable,
- Columns: []string{usagelog.AccountColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.AccountIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.AccountTable,
- Columns: []string{usagelog.AccountColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.GroupCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.GroupTable,
- Columns: []string{usagelog.GroupColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.GroupTable,
- Columns: []string{usagelog.GroupColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.SubscriptionCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.SubscriptionTable,
- Columns: []string{usagelog.SubscriptionColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.SubscriptionIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.SubscriptionTable,
- Columns: []string{usagelog.SubscriptionColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{usagelog.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- _u.mutation.done = true
- return _node, nil
- }
- // UsageLogUpdateOne is the builder for updating a single UsageLog entity.
- type UsageLogUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *UsageLogMutation
- }
- // SetUserID sets the "user_id" field.
- func (_u *UsageLogUpdateOne) SetUserID(v int64) *UsageLogUpdateOne {
- _u.mutation.SetUserID(v)
- return _u
- }
- // SetNillableUserID sets the "user_id" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableUserID(v *int64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetUserID(*v)
- }
- return _u
- }
- // SetAPIKeyID sets the "api_key_id" field.
- func (_u *UsageLogUpdateOne) SetAPIKeyID(v int64) *UsageLogUpdateOne {
- _u.mutation.SetAPIKeyID(v)
- return _u
- }
- // SetNillableAPIKeyID sets the "api_key_id" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableAPIKeyID(v *int64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetAPIKeyID(*v)
- }
- return _u
- }
- // SetAccountID sets the "account_id" field.
- func (_u *UsageLogUpdateOne) SetAccountID(v int64) *UsageLogUpdateOne {
- _u.mutation.SetAccountID(v)
- return _u
- }
- // SetNillableAccountID sets the "account_id" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableAccountID(v *int64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetAccountID(*v)
- }
- return _u
- }
- // SetRequestID sets the "request_id" field.
- func (_u *UsageLogUpdateOne) SetRequestID(v string) *UsageLogUpdateOne {
- _u.mutation.SetRequestID(v)
- return _u
- }
- // SetNillableRequestID sets the "request_id" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableRequestID(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetRequestID(*v)
- }
- return _u
- }
- // SetModel sets the "model" field.
- func (_u *UsageLogUpdateOne) SetModel(v string) *UsageLogUpdateOne {
- _u.mutation.SetModel(v)
- return _u
- }
- // SetNillableModel sets the "model" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableModel(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetModel(*v)
- }
- return _u
- }
- // SetRequestedModel sets the "requested_model" field.
- func (_u *UsageLogUpdateOne) SetRequestedModel(v string) *UsageLogUpdateOne {
- _u.mutation.SetRequestedModel(v)
- return _u
- }
- // SetNillableRequestedModel sets the "requested_model" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableRequestedModel(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetRequestedModel(*v)
- }
- return _u
- }
- // ClearRequestedModel clears the value of the "requested_model" field.
- func (_u *UsageLogUpdateOne) ClearRequestedModel() *UsageLogUpdateOne {
- _u.mutation.ClearRequestedModel()
- return _u
- }
- // SetUpstreamModel sets the "upstream_model" field.
- func (_u *UsageLogUpdateOne) SetUpstreamModel(v string) *UsageLogUpdateOne {
- _u.mutation.SetUpstreamModel(v)
- return _u
- }
- // SetNillableUpstreamModel sets the "upstream_model" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableUpstreamModel(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetUpstreamModel(*v)
- }
- return _u
- }
- // ClearUpstreamModel clears the value of the "upstream_model" field.
- func (_u *UsageLogUpdateOne) ClearUpstreamModel() *UsageLogUpdateOne {
- _u.mutation.ClearUpstreamModel()
- return _u
- }
- // SetUpstreamResponseModel sets the "upstream_response_model" field.
- func (_u *UsageLogUpdateOne) SetUpstreamResponseModel(v string) *UsageLogUpdateOne {
- _u.mutation.SetUpstreamResponseModel(v)
- return _u
- }
- // SetNillableUpstreamResponseModel sets the "upstream_response_model" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableUpstreamResponseModel(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetUpstreamResponseModel(*v)
- }
- return _u
- }
- // ClearUpstreamResponseModel clears the value of the "upstream_response_model" field.
- func (_u *UsageLogUpdateOne) ClearUpstreamResponseModel() *UsageLogUpdateOne {
- _u.mutation.ClearUpstreamResponseModel()
- return _u
- }
- // SetUpstreamModelMismatch sets the "upstream_model_mismatch" field.
- func (_u *UsageLogUpdateOne) SetUpstreamModelMismatch(v bool) *UsageLogUpdateOne {
- _u.mutation.SetUpstreamModelMismatch(v)
- return _u
- }
- // SetNillableUpstreamModelMismatch sets the "upstream_model_mismatch" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableUpstreamModelMismatch(v *bool) *UsageLogUpdateOne {
- if v != nil {
- _u.SetUpstreamModelMismatch(*v)
- }
- return _u
- }
- // ClearUpstreamModelMismatch clears the value of the "upstream_model_mismatch" field.
- func (_u *UsageLogUpdateOne) ClearUpstreamModelMismatch() *UsageLogUpdateOne {
- _u.mutation.ClearUpstreamModelMismatch()
- return _u
- }
- // SetChannelID sets the "channel_id" field.
- func (_u *UsageLogUpdateOne) SetChannelID(v int64) *UsageLogUpdateOne {
- _u.mutation.ResetChannelID()
- _u.mutation.SetChannelID(v)
- return _u
- }
- // SetNillableChannelID sets the "channel_id" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableChannelID(v *int64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetChannelID(*v)
- }
- return _u
- }
- // AddChannelID adds value to the "channel_id" field.
- func (_u *UsageLogUpdateOne) AddChannelID(v int64) *UsageLogUpdateOne {
- _u.mutation.AddChannelID(v)
- return _u
- }
- // ClearChannelID clears the value of the "channel_id" field.
- func (_u *UsageLogUpdateOne) ClearChannelID() *UsageLogUpdateOne {
- _u.mutation.ClearChannelID()
- return _u
- }
- // SetModelMappingChain sets the "model_mapping_chain" field.
- func (_u *UsageLogUpdateOne) SetModelMappingChain(v string) *UsageLogUpdateOne {
- _u.mutation.SetModelMappingChain(v)
- return _u
- }
- // SetNillableModelMappingChain sets the "model_mapping_chain" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableModelMappingChain(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetModelMappingChain(*v)
- }
- return _u
- }
- // ClearModelMappingChain clears the value of the "model_mapping_chain" field.
- func (_u *UsageLogUpdateOne) ClearModelMappingChain() *UsageLogUpdateOne {
- _u.mutation.ClearModelMappingChain()
- return _u
- }
- // SetBillingTier sets the "billing_tier" field.
- func (_u *UsageLogUpdateOne) SetBillingTier(v string) *UsageLogUpdateOne {
- _u.mutation.SetBillingTier(v)
- return _u
- }
- // SetNillableBillingTier sets the "billing_tier" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableBillingTier(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetBillingTier(*v)
- }
- return _u
- }
- // ClearBillingTier clears the value of the "billing_tier" field.
- func (_u *UsageLogUpdateOne) ClearBillingTier() *UsageLogUpdateOne {
- _u.mutation.ClearBillingTier()
- return _u
- }
- // SetBillingMode sets the "billing_mode" field.
- func (_u *UsageLogUpdateOne) SetBillingMode(v string) *UsageLogUpdateOne {
- _u.mutation.SetBillingMode(v)
- return _u
- }
- // SetNillableBillingMode sets the "billing_mode" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableBillingMode(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetBillingMode(*v)
- }
- return _u
- }
- // ClearBillingMode clears the value of the "billing_mode" field.
- func (_u *UsageLogUpdateOne) ClearBillingMode() *UsageLogUpdateOne {
- _u.mutation.ClearBillingMode()
- return _u
- }
- // SetGroupID sets the "group_id" field.
- func (_u *UsageLogUpdateOne) SetGroupID(v int64) *UsageLogUpdateOne {
- _u.mutation.SetGroupID(v)
- return _u
- }
- // SetNillableGroupID sets the "group_id" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableGroupID(v *int64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetGroupID(*v)
- }
- return _u
- }
- // ClearGroupID clears the value of the "group_id" field.
- func (_u *UsageLogUpdateOne) ClearGroupID() *UsageLogUpdateOne {
- _u.mutation.ClearGroupID()
- return _u
- }
- // SetSubscriptionID sets the "subscription_id" field.
- func (_u *UsageLogUpdateOne) SetSubscriptionID(v int64) *UsageLogUpdateOne {
- _u.mutation.SetSubscriptionID(v)
- return _u
- }
- // SetNillableSubscriptionID sets the "subscription_id" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableSubscriptionID(v *int64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetSubscriptionID(*v)
- }
- return _u
- }
- // ClearSubscriptionID clears the value of the "subscription_id" field.
- func (_u *UsageLogUpdateOne) ClearSubscriptionID() *UsageLogUpdateOne {
- _u.mutation.ClearSubscriptionID()
- return _u
- }
- // SetInputTokens sets the "input_tokens" field.
- func (_u *UsageLogUpdateOne) SetInputTokens(v int) *UsageLogUpdateOne {
- _u.mutation.ResetInputTokens()
- _u.mutation.SetInputTokens(v)
- return _u
- }
- // SetNillableInputTokens sets the "input_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableInputTokens(v *int) *UsageLogUpdateOne {
- if v != nil {
- _u.SetInputTokens(*v)
- }
- return _u
- }
- // AddInputTokens adds value to the "input_tokens" field.
- func (_u *UsageLogUpdateOne) AddInputTokens(v int) *UsageLogUpdateOne {
- _u.mutation.AddInputTokens(v)
- return _u
- }
- // SetOutputTokens sets the "output_tokens" field.
- func (_u *UsageLogUpdateOne) SetOutputTokens(v int) *UsageLogUpdateOne {
- _u.mutation.ResetOutputTokens()
- _u.mutation.SetOutputTokens(v)
- return _u
- }
- // SetNillableOutputTokens sets the "output_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableOutputTokens(v *int) *UsageLogUpdateOne {
- if v != nil {
- _u.SetOutputTokens(*v)
- }
- return _u
- }
- // AddOutputTokens adds value to the "output_tokens" field.
- func (_u *UsageLogUpdateOne) AddOutputTokens(v int) *UsageLogUpdateOne {
- _u.mutation.AddOutputTokens(v)
- return _u
- }
- // SetCacheCreationTokens sets the "cache_creation_tokens" field.
- func (_u *UsageLogUpdateOne) SetCacheCreationTokens(v int) *UsageLogUpdateOne {
- _u.mutation.ResetCacheCreationTokens()
- _u.mutation.SetCacheCreationTokens(v)
- return _u
- }
- // SetNillableCacheCreationTokens sets the "cache_creation_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableCacheCreationTokens(v *int) *UsageLogUpdateOne {
- if v != nil {
- _u.SetCacheCreationTokens(*v)
- }
- return _u
- }
- // AddCacheCreationTokens adds value to the "cache_creation_tokens" field.
- func (_u *UsageLogUpdateOne) AddCacheCreationTokens(v int) *UsageLogUpdateOne {
- _u.mutation.AddCacheCreationTokens(v)
- return _u
- }
- // SetCacheReadTokens sets the "cache_read_tokens" field.
- func (_u *UsageLogUpdateOne) SetCacheReadTokens(v int) *UsageLogUpdateOne {
- _u.mutation.ResetCacheReadTokens()
- _u.mutation.SetCacheReadTokens(v)
- return _u
- }
- // SetNillableCacheReadTokens sets the "cache_read_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableCacheReadTokens(v *int) *UsageLogUpdateOne {
- if v != nil {
- _u.SetCacheReadTokens(*v)
- }
- return _u
- }
- // AddCacheReadTokens adds value to the "cache_read_tokens" field.
- func (_u *UsageLogUpdateOne) AddCacheReadTokens(v int) *UsageLogUpdateOne {
- _u.mutation.AddCacheReadTokens(v)
- return _u
- }
- // SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
- func (_u *UsageLogUpdateOne) SetCacheCreation5mTokens(v int) *UsageLogUpdateOne {
- _u.mutation.ResetCacheCreation5mTokens()
- _u.mutation.SetCacheCreation5mTokens(v)
- return _u
- }
- // SetNillableCacheCreation5mTokens sets the "cache_creation_5m_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableCacheCreation5mTokens(v *int) *UsageLogUpdateOne {
- if v != nil {
- _u.SetCacheCreation5mTokens(*v)
- }
- return _u
- }
- // AddCacheCreation5mTokens adds value to the "cache_creation_5m_tokens" field.
- func (_u *UsageLogUpdateOne) AddCacheCreation5mTokens(v int) *UsageLogUpdateOne {
- _u.mutation.AddCacheCreation5mTokens(v)
- return _u
- }
- // SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
- func (_u *UsageLogUpdateOne) SetCacheCreation1hTokens(v int) *UsageLogUpdateOne {
- _u.mutation.ResetCacheCreation1hTokens()
- _u.mutation.SetCacheCreation1hTokens(v)
- return _u
- }
- // SetNillableCacheCreation1hTokens sets the "cache_creation_1h_tokens" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableCacheCreation1hTokens(v *int) *UsageLogUpdateOne {
- if v != nil {
- _u.SetCacheCreation1hTokens(*v)
- }
- return _u
- }
- // AddCacheCreation1hTokens adds value to the "cache_creation_1h_tokens" field.
- func (_u *UsageLogUpdateOne) AddCacheCreation1hTokens(v int) *UsageLogUpdateOne {
- _u.mutation.AddCacheCreation1hTokens(v)
- return _u
- }
- // SetInputCost sets the "input_cost" field.
- func (_u *UsageLogUpdateOne) SetInputCost(v float64) *UsageLogUpdateOne {
- _u.mutation.ResetInputCost()
- _u.mutation.SetInputCost(v)
- return _u
- }
- // SetNillableInputCost sets the "input_cost" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableInputCost(v *float64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetInputCost(*v)
- }
- return _u
- }
- // AddInputCost adds value to the "input_cost" field.
- func (_u *UsageLogUpdateOne) AddInputCost(v float64) *UsageLogUpdateOne {
- _u.mutation.AddInputCost(v)
- return _u
- }
- // SetOutputCost sets the "output_cost" field.
- func (_u *UsageLogUpdateOne) SetOutputCost(v float64) *UsageLogUpdateOne {
- _u.mutation.ResetOutputCost()
- _u.mutation.SetOutputCost(v)
- return _u
- }
- // SetNillableOutputCost sets the "output_cost" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableOutputCost(v *float64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetOutputCost(*v)
- }
- return _u
- }
- // AddOutputCost adds value to the "output_cost" field.
- func (_u *UsageLogUpdateOne) AddOutputCost(v float64) *UsageLogUpdateOne {
- _u.mutation.AddOutputCost(v)
- return _u
- }
- // SetCacheCreationCost sets the "cache_creation_cost" field.
- func (_u *UsageLogUpdateOne) SetCacheCreationCost(v float64) *UsageLogUpdateOne {
- _u.mutation.ResetCacheCreationCost()
- _u.mutation.SetCacheCreationCost(v)
- return _u
- }
- // SetNillableCacheCreationCost sets the "cache_creation_cost" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableCacheCreationCost(v *float64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetCacheCreationCost(*v)
- }
- return _u
- }
- // AddCacheCreationCost adds value to the "cache_creation_cost" field.
- func (_u *UsageLogUpdateOne) AddCacheCreationCost(v float64) *UsageLogUpdateOne {
- _u.mutation.AddCacheCreationCost(v)
- return _u
- }
- // SetCacheReadCost sets the "cache_read_cost" field.
- func (_u *UsageLogUpdateOne) SetCacheReadCost(v float64) *UsageLogUpdateOne {
- _u.mutation.ResetCacheReadCost()
- _u.mutation.SetCacheReadCost(v)
- return _u
- }
- // SetNillableCacheReadCost sets the "cache_read_cost" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableCacheReadCost(v *float64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetCacheReadCost(*v)
- }
- return _u
- }
- // AddCacheReadCost adds value to the "cache_read_cost" field.
- func (_u *UsageLogUpdateOne) AddCacheReadCost(v float64) *UsageLogUpdateOne {
- _u.mutation.AddCacheReadCost(v)
- return _u
- }
- // SetTotalCost sets the "total_cost" field.
- func (_u *UsageLogUpdateOne) SetTotalCost(v float64) *UsageLogUpdateOne {
- _u.mutation.ResetTotalCost()
- _u.mutation.SetTotalCost(v)
- return _u
- }
- // SetNillableTotalCost sets the "total_cost" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableTotalCost(v *float64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetTotalCost(*v)
- }
- return _u
- }
- // AddTotalCost adds value to the "total_cost" field.
- func (_u *UsageLogUpdateOne) AddTotalCost(v float64) *UsageLogUpdateOne {
- _u.mutation.AddTotalCost(v)
- return _u
- }
- // SetActualCost sets the "actual_cost" field.
- func (_u *UsageLogUpdateOne) SetActualCost(v float64) *UsageLogUpdateOne {
- _u.mutation.ResetActualCost()
- _u.mutation.SetActualCost(v)
- return _u
- }
- // SetNillableActualCost sets the "actual_cost" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableActualCost(v *float64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetActualCost(*v)
- }
- return _u
- }
- // AddActualCost adds value to the "actual_cost" field.
- func (_u *UsageLogUpdateOne) AddActualCost(v float64) *UsageLogUpdateOne {
- _u.mutation.AddActualCost(v)
- return _u
- }
- // SetRateMultiplier sets the "rate_multiplier" field.
- func (_u *UsageLogUpdateOne) SetRateMultiplier(v float64) *UsageLogUpdateOne {
- _u.mutation.ResetRateMultiplier()
- _u.mutation.SetRateMultiplier(v)
- return _u
- }
- // SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableRateMultiplier(v *float64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetRateMultiplier(*v)
- }
- return _u
- }
- // AddRateMultiplier adds value to the "rate_multiplier" field.
- func (_u *UsageLogUpdateOne) AddRateMultiplier(v float64) *UsageLogUpdateOne {
- _u.mutation.AddRateMultiplier(v)
- return _u
- }
- // SetLongContextBillingApplied sets the "long_context_billing_applied" field.
- func (_u *UsageLogUpdateOne) SetLongContextBillingApplied(v bool) *UsageLogUpdateOne {
- _u.mutation.SetLongContextBillingApplied(v)
- return _u
- }
- // SetNillableLongContextBillingApplied sets the "long_context_billing_applied" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableLongContextBillingApplied(v *bool) *UsageLogUpdateOne {
- if v != nil {
- _u.SetLongContextBillingApplied(*v)
- }
- return _u
- }
- // SetAccountRateMultiplier sets the "account_rate_multiplier" field.
- func (_u *UsageLogUpdateOne) SetAccountRateMultiplier(v float64) *UsageLogUpdateOne {
- _u.mutation.ResetAccountRateMultiplier()
- _u.mutation.SetAccountRateMultiplier(v)
- return _u
- }
- // SetNillableAccountRateMultiplier sets the "account_rate_multiplier" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableAccountRateMultiplier(v *float64) *UsageLogUpdateOne {
- if v != nil {
- _u.SetAccountRateMultiplier(*v)
- }
- return _u
- }
- // AddAccountRateMultiplier adds value to the "account_rate_multiplier" field.
- func (_u *UsageLogUpdateOne) AddAccountRateMultiplier(v float64) *UsageLogUpdateOne {
- _u.mutation.AddAccountRateMultiplier(v)
- return _u
- }
- // ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
- func (_u *UsageLogUpdateOne) ClearAccountRateMultiplier() *UsageLogUpdateOne {
- _u.mutation.ClearAccountRateMultiplier()
- return _u
- }
- // SetBillingType sets the "billing_type" field.
- func (_u *UsageLogUpdateOne) SetBillingType(v int8) *UsageLogUpdateOne {
- _u.mutation.ResetBillingType()
- _u.mutation.SetBillingType(v)
- return _u
- }
- // SetNillableBillingType sets the "billing_type" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableBillingType(v *int8) *UsageLogUpdateOne {
- if v != nil {
- _u.SetBillingType(*v)
- }
- return _u
- }
- // AddBillingType adds value to the "billing_type" field.
- func (_u *UsageLogUpdateOne) AddBillingType(v int8) *UsageLogUpdateOne {
- _u.mutation.AddBillingType(v)
- return _u
- }
- // SetStream sets the "stream" field.
- func (_u *UsageLogUpdateOne) SetStream(v bool) *UsageLogUpdateOne {
- _u.mutation.SetStream(v)
- return _u
- }
- // SetNillableStream sets the "stream" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableStream(v *bool) *UsageLogUpdateOne {
- if v != nil {
- _u.SetStream(*v)
- }
- return _u
- }
- // SetDurationMs sets the "duration_ms" field.
- func (_u *UsageLogUpdateOne) SetDurationMs(v int) *UsageLogUpdateOne {
- _u.mutation.ResetDurationMs()
- _u.mutation.SetDurationMs(v)
- return _u
- }
- // SetNillableDurationMs sets the "duration_ms" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableDurationMs(v *int) *UsageLogUpdateOne {
- if v != nil {
- _u.SetDurationMs(*v)
- }
- return _u
- }
- // AddDurationMs adds value to the "duration_ms" field.
- func (_u *UsageLogUpdateOne) AddDurationMs(v int) *UsageLogUpdateOne {
- _u.mutation.AddDurationMs(v)
- return _u
- }
- // ClearDurationMs clears the value of the "duration_ms" field.
- func (_u *UsageLogUpdateOne) ClearDurationMs() *UsageLogUpdateOne {
- _u.mutation.ClearDurationMs()
- return _u
- }
- // SetFirstTokenMs sets the "first_token_ms" field.
- func (_u *UsageLogUpdateOne) SetFirstTokenMs(v int) *UsageLogUpdateOne {
- _u.mutation.ResetFirstTokenMs()
- _u.mutation.SetFirstTokenMs(v)
- return _u
- }
- // SetNillableFirstTokenMs sets the "first_token_ms" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableFirstTokenMs(v *int) *UsageLogUpdateOne {
- if v != nil {
- _u.SetFirstTokenMs(*v)
- }
- return _u
- }
- // AddFirstTokenMs adds value to the "first_token_ms" field.
- func (_u *UsageLogUpdateOne) AddFirstTokenMs(v int) *UsageLogUpdateOne {
- _u.mutation.AddFirstTokenMs(v)
- return _u
- }
- // ClearFirstTokenMs clears the value of the "first_token_ms" field.
- func (_u *UsageLogUpdateOne) ClearFirstTokenMs() *UsageLogUpdateOne {
- _u.mutation.ClearFirstTokenMs()
- return _u
- }
- // SetUserAgent sets the "user_agent" field.
- func (_u *UsageLogUpdateOne) SetUserAgent(v string) *UsageLogUpdateOne {
- _u.mutation.SetUserAgent(v)
- return _u
- }
- // SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableUserAgent(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetUserAgent(*v)
- }
- return _u
- }
- // ClearUserAgent clears the value of the "user_agent" field.
- func (_u *UsageLogUpdateOne) ClearUserAgent() *UsageLogUpdateOne {
- _u.mutation.ClearUserAgent()
- return _u
- }
- // SetIPAddress sets the "ip_address" field.
- func (_u *UsageLogUpdateOne) SetIPAddress(v string) *UsageLogUpdateOne {
- _u.mutation.SetIPAddress(v)
- return _u
- }
- // SetNillableIPAddress sets the "ip_address" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableIPAddress(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetIPAddress(*v)
- }
- return _u
- }
- // ClearIPAddress clears the value of the "ip_address" field.
- func (_u *UsageLogUpdateOne) ClearIPAddress() *UsageLogUpdateOne {
- _u.mutation.ClearIPAddress()
- return _u
- }
- // SetImageCount sets the "image_count" field.
- func (_u *UsageLogUpdateOne) SetImageCount(v int) *UsageLogUpdateOne {
- _u.mutation.ResetImageCount()
- _u.mutation.SetImageCount(v)
- return _u
- }
- // SetNillableImageCount sets the "image_count" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableImageCount(v *int) *UsageLogUpdateOne {
- if v != nil {
- _u.SetImageCount(*v)
- }
- return _u
- }
- // AddImageCount adds value to the "image_count" field.
- func (_u *UsageLogUpdateOne) AddImageCount(v int) *UsageLogUpdateOne {
- _u.mutation.AddImageCount(v)
- return _u
- }
- // SetImageSize sets the "image_size" field.
- func (_u *UsageLogUpdateOne) SetImageSize(v string) *UsageLogUpdateOne {
- _u.mutation.SetImageSize(v)
- return _u
- }
- // SetNillableImageSize sets the "image_size" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableImageSize(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetImageSize(*v)
- }
- return _u
- }
- // ClearImageSize clears the value of the "image_size" field.
- func (_u *UsageLogUpdateOne) ClearImageSize() *UsageLogUpdateOne {
- _u.mutation.ClearImageSize()
- return _u
- }
- // SetImageInputSize sets the "image_input_size" field.
- func (_u *UsageLogUpdateOne) SetImageInputSize(v string) *UsageLogUpdateOne {
- _u.mutation.SetImageInputSize(v)
- return _u
- }
- // SetNillableImageInputSize sets the "image_input_size" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableImageInputSize(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetImageInputSize(*v)
- }
- return _u
- }
- // ClearImageInputSize clears the value of the "image_input_size" field.
- func (_u *UsageLogUpdateOne) ClearImageInputSize() *UsageLogUpdateOne {
- _u.mutation.ClearImageInputSize()
- return _u
- }
- // SetImageOutputSize sets the "image_output_size" field.
- func (_u *UsageLogUpdateOne) SetImageOutputSize(v string) *UsageLogUpdateOne {
- _u.mutation.SetImageOutputSize(v)
- return _u
- }
- // SetNillableImageOutputSize sets the "image_output_size" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableImageOutputSize(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetImageOutputSize(*v)
- }
- return _u
- }
- // ClearImageOutputSize clears the value of the "image_output_size" field.
- func (_u *UsageLogUpdateOne) ClearImageOutputSize() *UsageLogUpdateOne {
- _u.mutation.ClearImageOutputSize()
- return _u
- }
- // SetImageSizeSource sets the "image_size_source" field.
- func (_u *UsageLogUpdateOne) SetImageSizeSource(v string) *UsageLogUpdateOne {
- _u.mutation.SetImageSizeSource(v)
- return _u
- }
- // SetNillableImageSizeSource sets the "image_size_source" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableImageSizeSource(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetImageSizeSource(*v)
- }
- return _u
- }
- // ClearImageSizeSource clears the value of the "image_size_source" field.
- func (_u *UsageLogUpdateOne) ClearImageSizeSource() *UsageLogUpdateOne {
- _u.mutation.ClearImageSizeSource()
- return _u
- }
- // SetImageSizeBreakdown sets the "image_size_breakdown" field.
- func (_u *UsageLogUpdateOne) SetImageSizeBreakdown(v map[string]int) *UsageLogUpdateOne {
- _u.mutation.SetImageSizeBreakdown(v)
- return _u
- }
- // ClearImageSizeBreakdown clears the value of the "image_size_breakdown" field.
- func (_u *UsageLogUpdateOne) ClearImageSizeBreakdown() *UsageLogUpdateOne {
- _u.mutation.ClearImageSizeBreakdown()
- return _u
- }
- // SetVideoCount sets the "video_count" field.
- func (_u *UsageLogUpdateOne) SetVideoCount(v int) *UsageLogUpdateOne {
- _u.mutation.ResetVideoCount()
- _u.mutation.SetVideoCount(v)
- return _u
- }
- // SetNillableVideoCount sets the "video_count" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableVideoCount(v *int) *UsageLogUpdateOne {
- if v != nil {
- _u.SetVideoCount(*v)
- }
- return _u
- }
- // AddVideoCount adds value to the "video_count" field.
- func (_u *UsageLogUpdateOne) AddVideoCount(v int) *UsageLogUpdateOne {
- _u.mutation.AddVideoCount(v)
- return _u
- }
- // SetVideoResolution sets the "video_resolution" field.
- func (_u *UsageLogUpdateOne) SetVideoResolution(v string) *UsageLogUpdateOne {
- _u.mutation.SetVideoResolution(v)
- return _u
- }
- // SetNillableVideoResolution sets the "video_resolution" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableVideoResolution(v *string) *UsageLogUpdateOne {
- if v != nil {
- _u.SetVideoResolution(*v)
- }
- return _u
- }
- // ClearVideoResolution clears the value of the "video_resolution" field.
- func (_u *UsageLogUpdateOne) ClearVideoResolution() *UsageLogUpdateOne {
- _u.mutation.ClearVideoResolution()
- return _u
- }
- // SetVideoDurationSeconds sets the "video_duration_seconds" field.
- func (_u *UsageLogUpdateOne) SetVideoDurationSeconds(v int) *UsageLogUpdateOne {
- _u.mutation.ResetVideoDurationSeconds()
- _u.mutation.SetVideoDurationSeconds(v)
- return _u
- }
- // SetNillableVideoDurationSeconds sets the "video_duration_seconds" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableVideoDurationSeconds(v *int) *UsageLogUpdateOne {
- if v != nil {
- _u.SetVideoDurationSeconds(*v)
- }
- return _u
- }
- // AddVideoDurationSeconds adds value to the "video_duration_seconds" field.
- func (_u *UsageLogUpdateOne) AddVideoDurationSeconds(v int) *UsageLogUpdateOne {
- _u.mutation.AddVideoDurationSeconds(v)
- return _u
- }
- // ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field.
- func (_u *UsageLogUpdateOne) ClearVideoDurationSeconds() *UsageLogUpdateOne {
- _u.mutation.ClearVideoDurationSeconds()
- return _u
- }
- // SetCacheTTLOverridden sets the "cache_ttl_overridden" field.
- func (_u *UsageLogUpdateOne) SetCacheTTLOverridden(v bool) *UsageLogUpdateOne {
- _u.mutation.SetCacheTTLOverridden(v)
- return _u
- }
- // SetNillableCacheTTLOverridden sets the "cache_ttl_overridden" field if the given value is not nil.
- func (_u *UsageLogUpdateOne) SetNillableCacheTTLOverridden(v *bool) *UsageLogUpdateOne {
- if v != nil {
- _u.SetCacheTTLOverridden(*v)
- }
- return _u
- }
- // SetUser sets the "user" edge to the User entity.
- func (_u *UsageLogUpdateOne) SetUser(v *User) *UsageLogUpdateOne {
- return _u.SetUserID(v.ID)
- }
- // SetAPIKey sets the "api_key" edge to the APIKey entity.
- func (_u *UsageLogUpdateOne) SetAPIKey(v *APIKey) *UsageLogUpdateOne {
- return _u.SetAPIKeyID(v.ID)
- }
- // SetAccount sets the "account" edge to the Account entity.
- func (_u *UsageLogUpdateOne) SetAccount(v *Account) *UsageLogUpdateOne {
- return _u.SetAccountID(v.ID)
- }
- // SetGroup sets the "group" edge to the Group entity.
- func (_u *UsageLogUpdateOne) SetGroup(v *Group) *UsageLogUpdateOne {
- return _u.SetGroupID(v.ID)
- }
- // SetSubscription sets the "subscription" edge to the UserSubscription entity.
- func (_u *UsageLogUpdateOne) SetSubscription(v *UserSubscription) *UsageLogUpdateOne {
- return _u.SetSubscriptionID(v.ID)
- }
- // Mutation returns the UsageLogMutation object of the builder.
- func (_u *UsageLogUpdateOne) Mutation() *UsageLogMutation {
- return _u.mutation
- }
- // ClearUser clears the "user" edge to the User entity.
- func (_u *UsageLogUpdateOne) ClearUser() *UsageLogUpdateOne {
- _u.mutation.ClearUser()
- return _u
- }
- // ClearAPIKey clears the "api_key" edge to the APIKey entity.
- func (_u *UsageLogUpdateOne) ClearAPIKey() *UsageLogUpdateOne {
- _u.mutation.ClearAPIKey()
- return _u
- }
- // ClearAccount clears the "account" edge to the Account entity.
- func (_u *UsageLogUpdateOne) ClearAccount() *UsageLogUpdateOne {
- _u.mutation.ClearAccount()
- return _u
- }
- // ClearGroup clears the "group" edge to the Group entity.
- func (_u *UsageLogUpdateOne) ClearGroup() *UsageLogUpdateOne {
- _u.mutation.ClearGroup()
- return _u
- }
- // ClearSubscription clears the "subscription" edge to the UserSubscription entity.
- func (_u *UsageLogUpdateOne) ClearSubscription() *UsageLogUpdateOne {
- _u.mutation.ClearSubscription()
- return _u
- }
- // Where appends a list predicates to the UsageLogUpdate builder.
- func (_u *UsageLogUpdateOne) Where(ps ...predicate.UsageLog) *UsageLogUpdateOne {
- _u.mutation.Where(ps...)
- return _u
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (_u *UsageLogUpdateOne) Select(field string, fields ...string) *UsageLogUpdateOne {
- _u.fields = append([]string{field}, fields...)
- return _u
- }
- // Save executes the query and returns the updated UsageLog entity.
- func (_u *UsageLogUpdateOne) Save(ctx context.Context) (*UsageLog, error) {
- return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_u *UsageLogUpdateOne) SaveX(ctx context.Context) *UsageLog {
- node, err := _u.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (_u *UsageLogUpdateOne) Exec(ctx context.Context) error {
- _, err := _u.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_u *UsageLogUpdateOne) ExecX(ctx context.Context) {
- if err := _u.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_u *UsageLogUpdateOne) check() error {
- if v, ok := _u.mutation.RequestID(); ok {
- if err := usagelog.RequestIDValidator(v); err != nil {
- return &ValidationError{Name: "request_id", err: fmt.Errorf(`ent: validator failed for field "UsageLog.request_id": %w`, err)}
- }
- }
- if v, ok := _u.mutation.Model(); ok {
- if err := usagelog.ModelValidator(v); err != nil {
- return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model": %w`, err)}
- }
- }
- if v, ok := _u.mutation.RequestedModel(); ok {
- if err := usagelog.RequestedModelValidator(v); err != nil {
- return &ValidationError{Name: "requested_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.requested_model": %w`, err)}
- }
- }
- if v, ok := _u.mutation.UpstreamModel(); ok {
- if err := usagelog.UpstreamModelValidator(v); err != nil {
- return &ValidationError{Name: "upstream_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.upstream_model": %w`, err)}
- }
- }
- if v, ok := _u.mutation.UpstreamResponseModel(); ok {
- if err := usagelog.UpstreamResponseModelValidator(v); err != nil {
- return &ValidationError{Name: "upstream_response_model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.upstream_response_model": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ModelMappingChain(); ok {
- if err := usagelog.ModelMappingChainValidator(v); err != nil {
- return &ValidationError{Name: "model_mapping_chain", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model_mapping_chain": %w`, err)}
- }
- }
- if v, ok := _u.mutation.BillingTier(); ok {
- if err := usagelog.BillingTierValidator(v); err != nil {
- return &ValidationError{Name: "billing_tier", err: fmt.Errorf(`ent: validator failed for field "UsageLog.billing_tier": %w`, err)}
- }
- }
- if v, ok := _u.mutation.BillingMode(); ok {
- if err := usagelog.BillingModeValidator(v); err != nil {
- return &ValidationError{Name: "billing_mode", err: fmt.Errorf(`ent: validator failed for field "UsageLog.billing_mode": %w`, err)}
- }
- }
- if v, ok := _u.mutation.UserAgent(); ok {
- if err := usagelog.UserAgentValidator(v); err != nil {
- return &ValidationError{Name: "user_agent", err: fmt.Errorf(`ent: validator failed for field "UsageLog.user_agent": %w`, err)}
- }
- }
- if v, ok := _u.mutation.IPAddress(); ok {
- if err := usagelog.IPAddressValidator(v); err != nil {
- return &ValidationError{Name: "ip_address", err: fmt.Errorf(`ent: validator failed for field "UsageLog.ip_address": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ImageSize(); ok {
- if err := usagelog.ImageSizeValidator(v); err != nil {
- return &ValidationError{Name: "image_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ImageInputSize(); ok {
- if err := usagelog.ImageInputSizeValidator(v); err != nil {
- return &ValidationError{Name: "image_input_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_input_size": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ImageOutputSize(); ok {
- if err := usagelog.ImageOutputSizeValidator(v); err != nil {
- return &ValidationError{Name: "image_output_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_output_size": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ImageSizeSource(); ok {
- if err := usagelog.ImageSizeSourceValidator(v); err != nil {
- return &ValidationError{Name: "image_size_source", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size_source": %w`, err)}
- }
- }
- if v, ok := _u.mutation.VideoResolution(); ok {
- if err := usagelog.VideoResolutionValidator(v); err != nil {
- return &ValidationError{Name: "video_resolution", err: fmt.Errorf(`ent: validator failed for field "UsageLog.video_resolution": %w`, err)}
- }
- }
- if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
- return errors.New(`ent: clearing a required unique edge "UsageLog.user"`)
- }
- if _u.mutation.APIKeyCleared() && len(_u.mutation.APIKeyIDs()) > 0 {
- return errors.New(`ent: clearing a required unique edge "UsageLog.api_key"`)
- }
- if _u.mutation.AccountCleared() && len(_u.mutation.AccountIDs()) > 0 {
- return errors.New(`ent: clearing a required unique edge "UsageLog.account"`)
- }
- return nil
- }
- func (_u *UsageLogUpdateOne) sqlSave(ctx context.Context) (_node *UsageLog, err error) {
- if err := _u.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(usagelog.Table, usagelog.Columns, sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64))
- id, ok := _u.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UsageLog.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := _u.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, usagelog.FieldID)
- for _, f := range fields {
- if !usagelog.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != usagelog.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := _u.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := _u.mutation.RequestID(); ok {
- _spec.SetField(usagelog.FieldRequestID, field.TypeString, value)
- }
- if value, ok := _u.mutation.Model(); ok {
- _spec.SetField(usagelog.FieldModel, field.TypeString, value)
- }
- if value, ok := _u.mutation.RequestedModel(); ok {
- _spec.SetField(usagelog.FieldRequestedModel, field.TypeString, value)
- }
- if _u.mutation.RequestedModelCleared() {
- _spec.ClearField(usagelog.FieldRequestedModel, field.TypeString)
- }
- if value, ok := _u.mutation.UpstreamModel(); ok {
- _spec.SetField(usagelog.FieldUpstreamModel, field.TypeString, value)
- }
- if _u.mutation.UpstreamModelCleared() {
- _spec.ClearField(usagelog.FieldUpstreamModel, field.TypeString)
- }
- if value, ok := _u.mutation.UpstreamResponseModel(); ok {
- _spec.SetField(usagelog.FieldUpstreamResponseModel, field.TypeString, value)
- }
- if _u.mutation.UpstreamResponseModelCleared() {
- _spec.ClearField(usagelog.FieldUpstreamResponseModel, field.TypeString)
- }
- if value, ok := _u.mutation.UpstreamModelMismatch(); ok {
- _spec.SetField(usagelog.FieldUpstreamModelMismatch, field.TypeBool, value)
- }
- if _u.mutation.UpstreamModelMismatchCleared() {
- _spec.ClearField(usagelog.FieldUpstreamModelMismatch, field.TypeBool)
- }
- if value, ok := _u.mutation.ChannelID(); ok {
- _spec.SetField(usagelog.FieldChannelID, field.TypeInt64, value)
- }
- if value, ok := _u.mutation.AddedChannelID(); ok {
- _spec.AddField(usagelog.FieldChannelID, field.TypeInt64, value)
- }
- if _u.mutation.ChannelIDCleared() {
- _spec.ClearField(usagelog.FieldChannelID, field.TypeInt64)
- }
- if value, ok := _u.mutation.ModelMappingChain(); ok {
- _spec.SetField(usagelog.FieldModelMappingChain, field.TypeString, value)
- }
- if _u.mutation.ModelMappingChainCleared() {
- _spec.ClearField(usagelog.FieldModelMappingChain, field.TypeString)
- }
- if value, ok := _u.mutation.BillingTier(); ok {
- _spec.SetField(usagelog.FieldBillingTier, field.TypeString, value)
- }
- if _u.mutation.BillingTierCleared() {
- _spec.ClearField(usagelog.FieldBillingTier, field.TypeString)
- }
- if value, ok := _u.mutation.BillingMode(); ok {
- _spec.SetField(usagelog.FieldBillingMode, field.TypeString, value)
- }
- if _u.mutation.BillingModeCleared() {
- _spec.ClearField(usagelog.FieldBillingMode, field.TypeString)
- }
- if value, ok := _u.mutation.InputTokens(); ok {
- _spec.SetField(usagelog.FieldInputTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedInputTokens(); ok {
- _spec.AddField(usagelog.FieldInputTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.OutputTokens(); ok {
- _spec.SetField(usagelog.FieldOutputTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedOutputTokens(); ok {
- _spec.AddField(usagelog.FieldOutputTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.CacheCreationTokens(); ok {
- _spec.SetField(usagelog.FieldCacheCreationTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedCacheCreationTokens(); ok {
- _spec.AddField(usagelog.FieldCacheCreationTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.CacheReadTokens(); ok {
- _spec.SetField(usagelog.FieldCacheReadTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedCacheReadTokens(); ok {
- _spec.AddField(usagelog.FieldCacheReadTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.CacheCreation5mTokens(); ok {
- _spec.SetField(usagelog.FieldCacheCreation5mTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedCacheCreation5mTokens(); ok {
- _spec.AddField(usagelog.FieldCacheCreation5mTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.CacheCreation1hTokens(); ok {
- _spec.SetField(usagelog.FieldCacheCreation1hTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedCacheCreation1hTokens(); ok {
- _spec.AddField(usagelog.FieldCacheCreation1hTokens, field.TypeInt, value)
- }
- if value, ok := _u.mutation.InputCost(); ok {
- _spec.SetField(usagelog.FieldInputCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedInputCost(); ok {
- _spec.AddField(usagelog.FieldInputCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.OutputCost(); ok {
- _spec.SetField(usagelog.FieldOutputCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedOutputCost(); ok {
- _spec.AddField(usagelog.FieldOutputCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.CacheCreationCost(); ok {
- _spec.SetField(usagelog.FieldCacheCreationCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedCacheCreationCost(); ok {
- _spec.AddField(usagelog.FieldCacheCreationCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.CacheReadCost(); ok {
- _spec.SetField(usagelog.FieldCacheReadCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedCacheReadCost(); ok {
- _spec.AddField(usagelog.FieldCacheReadCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.TotalCost(); ok {
- _spec.SetField(usagelog.FieldTotalCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedTotalCost(); ok {
- _spec.AddField(usagelog.FieldTotalCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.ActualCost(); ok {
- _spec.SetField(usagelog.FieldActualCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedActualCost(); ok {
- _spec.AddField(usagelog.FieldActualCost, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.RateMultiplier(); ok {
- _spec.SetField(usagelog.FieldRateMultiplier, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedRateMultiplier(); ok {
- _spec.AddField(usagelog.FieldRateMultiplier, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.LongContextBillingApplied(); ok {
- _spec.SetField(usagelog.FieldLongContextBillingApplied, field.TypeBool, value)
- }
- if value, ok := _u.mutation.AccountRateMultiplier(); ok {
- _spec.SetField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedAccountRateMultiplier(); ok {
- _spec.AddField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64, value)
- }
- if _u.mutation.AccountRateMultiplierCleared() {
- _spec.ClearField(usagelog.FieldAccountRateMultiplier, field.TypeFloat64)
- }
- if value, ok := _u.mutation.BillingType(); ok {
- _spec.SetField(usagelog.FieldBillingType, field.TypeInt8, value)
- }
- if value, ok := _u.mutation.AddedBillingType(); ok {
- _spec.AddField(usagelog.FieldBillingType, field.TypeInt8, value)
- }
- if value, ok := _u.mutation.Stream(); ok {
- _spec.SetField(usagelog.FieldStream, field.TypeBool, value)
- }
- if value, ok := _u.mutation.DurationMs(); ok {
- _spec.SetField(usagelog.FieldDurationMs, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedDurationMs(); ok {
- _spec.AddField(usagelog.FieldDurationMs, field.TypeInt, value)
- }
- if _u.mutation.DurationMsCleared() {
- _spec.ClearField(usagelog.FieldDurationMs, field.TypeInt)
- }
- if value, ok := _u.mutation.FirstTokenMs(); ok {
- _spec.SetField(usagelog.FieldFirstTokenMs, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedFirstTokenMs(); ok {
- _spec.AddField(usagelog.FieldFirstTokenMs, field.TypeInt, value)
- }
- if _u.mutation.FirstTokenMsCleared() {
- _spec.ClearField(usagelog.FieldFirstTokenMs, field.TypeInt)
- }
- if value, ok := _u.mutation.UserAgent(); ok {
- _spec.SetField(usagelog.FieldUserAgent, field.TypeString, value)
- }
- if _u.mutation.UserAgentCleared() {
- _spec.ClearField(usagelog.FieldUserAgent, field.TypeString)
- }
- if value, ok := _u.mutation.IPAddress(); ok {
- _spec.SetField(usagelog.FieldIPAddress, field.TypeString, value)
- }
- if _u.mutation.IPAddressCleared() {
- _spec.ClearField(usagelog.FieldIPAddress, field.TypeString)
- }
- if value, ok := _u.mutation.ImageCount(); ok {
- _spec.SetField(usagelog.FieldImageCount, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedImageCount(); ok {
- _spec.AddField(usagelog.FieldImageCount, field.TypeInt, value)
- }
- if value, ok := _u.mutation.ImageSize(); ok {
- _spec.SetField(usagelog.FieldImageSize, field.TypeString, value)
- }
- if _u.mutation.ImageSizeCleared() {
- _spec.ClearField(usagelog.FieldImageSize, field.TypeString)
- }
- if value, ok := _u.mutation.ImageInputSize(); ok {
- _spec.SetField(usagelog.FieldImageInputSize, field.TypeString, value)
- }
- if _u.mutation.ImageInputSizeCleared() {
- _spec.ClearField(usagelog.FieldImageInputSize, field.TypeString)
- }
- if value, ok := _u.mutation.ImageOutputSize(); ok {
- _spec.SetField(usagelog.FieldImageOutputSize, field.TypeString, value)
- }
- if _u.mutation.ImageOutputSizeCleared() {
- _spec.ClearField(usagelog.FieldImageOutputSize, field.TypeString)
- }
- if value, ok := _u.mutation.ImageSizeSource(); ok {
- _spec.SetField(usagelog.FieldImageSizeSource, field.TypeString, value)
- }
- if _u.mutation.ImageSizeSourceCleared() {
- _spec.ClearField(usagelog.FieldImageSizeSource, field.TypeString)
- }
- if value, ok := _u.mutation.ImageSizeBreakdown(); ok {
- _spec.SetField(usagelog.FieldImageSizeBreakdown, field.TypeJSON, value)
- }
- if _u.mutation.ImageSizeBreakdownCleared() {
- _spec.ClearField(usagelog.FieldImageSizeBreakdown, field.TypeJSON)
- }
- if value, ok := _u.mutation.VideoCount(); ok {
- _spec.SetField(usagelog.FieldVideoCount, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedVideoCount(); ok {
- _spec.AddField(usagelog.FieldVideoCount, field.TypeInt, value)
- }
- if value, ok := _u.mutation.VideoResolution(); ok {
- _spec.SetField(usagelog.FieldVideoResolution, field.TypeString, value)
- }
- if _u.mutation.VideoResolutionCleared() {
- _spec.ClearField(usagelog.FieldVideoResolution, field.TypeString)
- }
- if value, ok := _u.mutation.VideoDurationSeconds(); ok {
- _spec.SetField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedVideoDurationSeconds(); ok {
- _spec.AddField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value)
- }
- if _u.mutation.VideoDurationSecondsCleared() {
- _spec.ClearField(usagelog.FieldVideoDurationSeconds, field.TypeInt)
- }
- if value, ok := _u.mutation.CacheTTLOverridden(); ok {
- _spec.SetField(usagelog.FieldCacheTTLOverridden, field.TypeBool, value)
- }
- if _u.mutation.UserCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.UserTable,
- Columns: []string{usagelog.UserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.UserTable,
- Columns: []string{usagelog.UserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.APIKeyCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.APIKeyTable,
- Columns: []string{usagelog.APIKeyColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.APIKeyIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.APIKeyTable,
- Columns: []string{usagelog.APIKeyColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.AccountCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.AccountTable,
- Columns: []string{usagelog.AccountColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.AccountIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.AccountTable,
- Columns: []string{usagelog.AccountColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.GroupCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.GroupTable,
- Columns: []string{usagelog.GroupColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.GroupTable,
- Columns: []string{usagelog.GroupColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.SubscriptionCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.SubscriptionTable,
- Columns: []string{usagelog.SubscriptionColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.SubscriptionIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usagelog.SubscriptionTable,
- Columns: []string{usagelog.SubscriptionColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- _node = &UsageLog{config: _u.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{usagelog.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- _u.mutation.done = true
- return _node, nil
- }
|